From d36c32e2998a3078d05d80a6b633d6612c7cfde5 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Sun, 1 Oct 2017 09:41:23 +0000 Subject: [PATCH] Editor: pass the DOM library instance instead of a (fake) editor instance to `getCursorMarkerSpan()`. See #42029 git-svn-id: https://develop.svn.wordpress.org/trunk@41655 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/editor.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/wp-admin/js/editor.js b/src/wp-admin/js/editor.js index 2b26b83556..a9caaa1d5d 100644 --- a/src/wp-admin/js/editor.js +++ b/src/wp-admin/js/editor.js @@ -345,11 +345,11 @@ window.wp = window.wp || {}; * * Using DomQuery syntax to create it, since it's used as both text and as a DOM element. * - * @param {Object} editor The TinyMCE editor instance. + * @param {Object} domLib DOM library instance. * @param {string} content The content to insert into the cusror marker element. */ - function getCursorMarkerSpan( editor, content ) { - return editor.$( '' ).css( { + function getCursorMarkerSpan( domLib, content ) { + return domLib( '' ).css( { display: 'inline-block', width: 0, overflow: 'hidden', @@ -434,9 +434,8 @@ window.wp = window.wp || {}; * to run after the markers are added. * * @param {object} $textarea TinyMCE's textarea wrapped as a DomQuery object - * @param {object} jQuery A jQuery instance */ - function addHTMLBookmarkInTextAreaContent( $textarea, jQuery ) { + function addHTMLBookmarkInTextAreaContent( $textarea ) { if ( ! $textarea || ! $textarea.length ) { // If no valid $textarea object is provided, there's nothing we can do. return; @@ -456,7 +455,7 @@ window.wp = window.wp || {}; mode = htmlModeCursorStartPosition !== htmlModeCursorEndPosition ? 'range' : 'single', selectedText = null, - cursorMarkerSkeleton = getCursorMarkerSpan( { $: jQuery }, '' ); + cursorMarkerSkeleton = getCursorMarkerSpan( $$, '' ); if ( mode === 'range' ) { var markedText = textArea.value.slice( htmlModeCursorStartPosition, htmlModeCursorEndPosition ), @@ -646,7 +645,7 @@ window.wp = window.wp || {}; * The elements have hardcoded style that makes them invisible. This is done to avoid seeing * random content flickering in the editor when switching between modes. */ - var spanSkeleton = getCursorMarkerSpan( editor, selectionID ), + var spanSkeleton = getCursorMarkerSpan( editor.$, selectionID ), startElement = spanSkeleton.clone().addClass( 'mce_SELRES_start' ), endElement = spanSkeleton.clone().addClass( 'mce_SELRES_end' );