{"action":"reopened","issue":{"url":"https://api.github.com/repos/tinymce/tinymce/issues/2798","repository_url":"https://api.github.com/repos/tinymce/tinymce","labels_url":"https://api.github.com/repos/tinymce/tinymce/issues/2798/labels{/name}","comments_url":"https://api.github.com/repos/tinymce/tinymce/issues/2798/comments","events_url":"https://api.github.com/repos/tinymce/tinymce/issues/2798/events","html_url":"https://github.com/tinymce/tinymce/issues/2798","id":142329209,"number":2798,"title":"Inserting newlines at end of blocks in inline mode can clone ancestor elements of the TinyMCE editor","user":{"login":"Shenlok","id":923651,"avatar_url":"https://avatars.githubusercontent.com/u/923651?v=3","gravatar_id":"","url":"https://api.github.com/users/Shenlok","html_url":"https://github.com/Shenlok","followers_url":"https://api.github.com/users/Shenlok/followers","following_url":"https://api.github.com/users/Shenlok/following{/other_user}","gists_url":"https://api.github.com/users/Shenlok/gists{/gist_id}","starred_url":"https://api.github.com/users/Shenlok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shenlok/subscriptions","organizations_url":"https://api.github.com/users/Shenlok/orgs","repos_url":"https://api.github.com/users/Shenlok/repos","events_url":"https://api.github.com/users/Shenlok/events{/privacy}","received_events_url":"https://api.github.com/users/Shenlok/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/tinymce/tinymce/labels/component:%20keyboard","name":"component: keyboard","color":"bfe5bf"},{"url":"https://api.github.com/repos/tinymce/tinymce/labels/type:%20bug","name":"type: bug","color":"555555"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-03-21T12:11:26Z","updated_at":"2016-07-31T22:55:22Z","closed_at":null,"body":"[Codepen to repro](http://codepen.io/Shenlok/pen/RapMoO)\r\n\r\n# Problem\r\nWhen inserting newlines at the end of a block, some ancestor elements of the TinyMCE editor can be cloned and inserted into the editor's contents. This can be problematic if any ancestors have styles beyond simple text styling, e.g a margin or border.\r\n\r\n# Setup\r\nSee the linked codepen for a working reproduction of this issue.\r\n\r\nKey items to repro are:\r\n- `keep_styles != false` and `inline === true` in the tinymce config\r\n- The element on which you are initializing tinymce (the editor container) must be inside a \"text inline element\" as returned by `schema.getTextInlineElements()` ([source](https://github.com/tinymce/tinymce/blob/master/js/tinymce/classes/EnterKey.js#L204)) that has visual styling applied to it e.g border, margin.\r\n\r\n# Explanation and possible solution\r\nThe problematic code is [this loop](https://github.com/tinymce/tinymce/blob/master/js/tinymce/classes/EnterKey.js#L216-L236), where the `onEnterKey` handler attempts to create a new block that maintains text styling from the previous block. It does this by traversing the parent nodes of the block the caret was in when the enter key was pressed, and if they are \"text inline elements\" (see above) it will clone them and append them to the \"new\" block where the caret will be positioned (the new line). In the loop, the only terminating condition is where there is no more parent node to look at. In non-inline mode, this means we have reached the root of the editable content area (the TinyMCE editor iframe). But in inline mode, this search will continue until reaching the document element since there is no iframe.\r\n\r\nPerhaps a fix would be to add an additional check to this loop so that we don't traverse outside of the tinymce \"editable area\" boundary.\r\n\r\n\r\n"}}
{"actor":{"display_login":"blackcathikari"}}