Opened 12 years ago
Closed 11 years ago
#28305 closed defect (bug) (worksforme)
Visual Editor Anchor Button Behavior
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 3.9 |
| Component: | TinyMCE | Keywords: | close |
| Focuses: | Cc: |
Description
Hello.
The "anchor" button in the TinyMCE editor is acting a bit strange.
From Andrew Ozz's explanation here (http://wordpress.org/support/topic/anchors-using-button-dont-stay-when-updated?replies=5#post-5594599).
The anchor button is removing any highlighted text just prior to inserting the anchor.
Here are the steps to replicate:
- Create some text in visual view;
This is a test link. - Highlight the word
testand click the anchor button. - Add
myTestas the anchor name. - Switch to 'text' view.
You will see the editor has removed the word test and replaced it with <a id="myTest"></a>.
The original word test (or whatever you highlight just prior to clicking the anchor button) gets removed completely.
I think we just need to add back in the 'editor selection' when the link is created; and push it back to the WordPress editor.
Change History (6)
#2
@
12 years ago
Ah, I understand. But, what if you wanted to link textual elements using anchors; such as when creating a TOC at the top of a long page.
I can see this reasoning though. You could place an anchor directly directly before the heading (or whatever you use to separate the page elements).
It's just been my experience to use textual elements when using anchors (rarely ever use them). And it seems the way it is designed now; when creating an anchor, it should ONLY be used without wrapping any content first?
I'll add a voice to the TinyMCE thread if think it will help :)
Thanks Andrew.
#3
@
12 years ago
You could place an anchor directly before the heading (or whatever you use to separate the page elements).
Right. It doesn't make any difference if any text is wrapped in the link or not. The browsers don't render it as a link as there's no href attribute. The "original" HTML anchors were always empty, they only mark the spot the page is scrolled to. Then from HTML 4 any element with an ID can be used as anchor.
#4
@
11 years ago
I think this is normal behaviour. If you insert something when text is selected, the text will disappear.
#6
@
11 years ago
- Milestone Awaiting Review deleted
- Resolution set to worksforme
- Status changed from new to closed
Collapsing the selection could be an idea for enhancement for the TinyMCE "anchor" plugin. Replacing the selection is the standard behavior though, not sure if changing it would be better.
This is the "standard" behavior in all editors. When something is selected and you start typing or insert another element (like image), the selection is replaced.
For anchors it would probably be better to collapse the selection to the front, I'll make a small patch and see if the TinyMCE Devs would change it.