Skip to content

Commit

Permalink
Merge pull request #5563 from tinymce/TINY-4828
Browse files Browse the repository at this point in the history
TINY-4828: Fixed the placeholder not hiding when pasting content into the editor
  • Loading branch information
lnewson committed Apr 9, 2020
2 parents 73ce0fe + a90ee6b commit 1c76205
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modules/tinymce/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Version 5.3.0 (TBD)
Fixed issue with loading or pasting contents with large base64 encoded images on Safari #TINY-4715
Fixed supplementary special characters being truncated when inserted into the editor. Patch contributed by mlitwin. #TINY-4791
Fixed toolbar buttons not set to disabled when the editor is in readonly mode #TINY-4592
Fixed bug where title, width, height would be set to empty string values when updating an image and removing those using the image dialog. #TINY-4786
Fixed bug where title, width, height would be set to empty string values when updating an image and removing those using the image dialog #TINY-4786
Fixed the placeholder not hiding when pasting content into the editor #TINY-4828
Version 5.2.2 (TBD)
Fixed an issue where anchors could not be inserted on empty lines #TINY-2788
Version 5.2.1 (2020-03-25)
Expand Down
5 changes: 5 additions & 0 deletions modules/tinymce/src/core/main/ts/content/Placeholder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Editor from '../api/Editor';
import Env from '../api/Env';
import * as Events from '../api/Events';
import * as Settings from '../api/Settings';
import Delay from '../api/util/Delay';
import { EditorEvent } from '../api/util/EventDispatcher';
import VK from '../api/util/VK';
import * as Empty from '../dom/Empty';
Expand Down Expand Up @@ -114,6 +115,10 @@ const setup = (editor: Editor) => {
updatePlaceholder(e, true);
editor.on('change SetContent ExecCommand', updatePlaceholder);

// TINY-4828: Update the placeholder after pasting content. This needs to use a timeout as
// the browser doesn't update the dom until after the paste event has fired
editor.on('paste', (e) => Delay.setEditorTimeout(editor, () => updatePlaceholder(e)));

// Remove the placeholder attributes on remove
editor.on('remove', () => {
const body = editor.getBody();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ UnitTest.asynctest('webdriver.tinymce.core.content.PlaceholderTest', (success, f
tinyApi.sExecCommand('InsertOrderedList'),
sAssertPlaceholderNotExists,
sAssertCount(1)
]),
Log.stepsAsStep('TINY-4828', 'Check placeholder hides when pasting content into the editor', [
sSetContent('<p></p>'),
sAssertPlaceholderExists,
// Note: This fakes a paste event
Step.sync(() => {
editor.fire('paste');
editor.getBody().innerHTML = '<p>Pasted content</p>';
}),
sAssertPlaceholderNotExists,
sAssertCount(1)
])
].concat(browserSpecificTests), onSuccess, onFailure);
}, {
Expand Down

0 comments on commit 1c76205

Please sign in to comment.