#36434 closed task (blessed) (fixed)
Consider TinyMCE's implementation of `contenteditable="false"` for views
Reported by: | iseulde | Owned by: | iseulde |
---|---|---|---|
Milestone: | 4.6 | Priority: | high |
Severity: | normal | Version: | |
Component: | TinyMCE | Keywords: | has-patch |
Focuses: | javascript | Cc: |
Description
This was added to TinyMCE 4.3. See https://www.tinymce.com/docs/plugins/noneditable/.
Inspired by how we're doing it in WordPress, it works very similarly.
Attachments (5)
Change History (34)
#1
@
8 years ago
- Summary changed from Consider the new non-enditable plugin for views to Consider the new non-editable plugin for views
- Type changed from defect (bug) to enhancement
This ticket was mentioned in Slack in #core-editor by azaozz. View the logs.
8 years ago
#4
@
8 years ago
- Summary changed from Consider the new non-editable plugin for views to Consider TinyMCE's implementation of `contenteditable="false"` for views
#6
@
8 years ago
Not sure how to solve unbinding. Now we provide the node and unbinding happens before removal. If we switch to some kind of cleanup instead, running after the node's been removed, some information necessary to unbind is missing.
E.g.
In the case were we don't use iframes, and have mejs.
We need the ID associated with the node to remove the instance from the global object.
window.mejs.players[ $( node ).find( '.mejs-container' ).get( 0 ).id ].remove()
Maybe in this case the view instance needs to save IDs associated with its nodes, and check which nodes are missing on cleanup.
This ticket was mentioned in Slack in #core-editor by iseulde. View the logs.
8 years ago
This ticket was mentioned in Slack in #core-editor by iseulde. View the logs.
8 years ago
This ticket was mentioned in Slack in #core by ocean90. View the logs.
8 years ago
This ticket was mentioned in Slack in #core-tinymce by iseulde. View the logs.
8 years ago
#13
@
8 years ago
- Type changed from enhancement to task (blessed)
Waiting for addition of an improvement to handle unloading from upstream. Should be ready soon.
#14
@
8 years ago
There's an issue with the new code when I try to copy paste a shortcode view containing HTML code.
e.g: I have the following shortcode:
[toggle title="Toggle Title"]<h1>Lorem ipsum</h1>[/toggle]
in Visual Mode, copy the view and paste it, it generates the following view:
Switching back and forth between the Text and Visual mode restores the correct view.
The issue seems to come from the code inside wp-includes/js/tinymce/plugins/wpview/plugin.js line 90 (removing it fixes this issue):
// Make sure views are copied as their text. editor.on( 'drop objectselected', function( event ) { if ( isView( event.targetClone ) ) { event.targetClone = editor.getDoc().createTextNode( window.decodeURIComponent( editor.dom.getAttrib( event.targetClone, 'data-wpview-text' ) ) ); } } );
This ticket was mentioned in Slack in #core-editor by iseulde. View the logs.
8 years ago
#19
@
8 years ago
@programmin would a patch like 36434.4.patch help? So restoring the old -wrap class and passing the node as a third parameter as well, to prevent errors?
But you are right, there should be a note for developers in either case making them aware of the changes.
#20
@
8 years ago
@ocean90 It is fixed in 4.4.0... See https://github.com/tinymce/tinymce/blob/master/changelog.txt line 5 and 6.
(which is not in trunk)
This ticket was mentioned in Slack in #core by ocean90. View the logs.
8 years ago
#23
@
8 years ago
@programmin Did you get a chance to test 36434.4.patch?
This ticket was mentioned in Slack in #core-editor by ocean90. View the logs.
8 years ago
#25
@
8 years ago
As discussed with @azaozz, we think it is better to noop the unbind method and remove the event. Before this change it was very unreliable, and it's not clear how it should be done now. In any case it is best that views are iframed. All of core's views are iframed and the api encourages iframing.
#26
@
8 years ago
In 36434.5.patch:
- Add the back-compat changes from 36434.4.patch.
- Restore changing of the views iframes body classes when the editor body class name changes.
- Bind the mutation observer used to resize the view iframes to the iframe window. That prevents eventual memory leak when the view is deleted.
- Stop triggering/remove the
wp-mce-view-unbind
event as previously discussed.
Thinking we can keep the unbind method for now. In theory it can still be used to unbind before the view node is removed by the user (if a plugin ever needs that). This will need another look in 4.7.
#27
follow-up:
↓ 29
@
8 years ago
Still having issue when copy paste a shortcode view containing HTML tags. It was working in WP 4.5.3
The issue is line 119 of wp-includes/js/tinymce/plugins/wpview/plugin.js which creates a text node instead of an html node.
event.targetClone = editor.getDoc().createTextNode( window.decodeURIComponent( editor.dom.getAttrib( event.targetClone, 'data-wpview-text' ) ) );
#29
in reply to:
↑ 27
@
8 years ago
Replying to bduclos:
Still having issue when copy paste a shortcode view containing HTML tags.
Could you open a new ticket for this. I can see where it gets converted to text, just don't want to introduce potential security problem as the browsers will parse the inserted HTML.
To do:
Bugs:
Differences: