Changeset 42575 for branches/4.9
- Timestamp:
- 01/23/2018 05:47:52 PM (7 years ago)
- Location:
- branches/4.9
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.9
-
branches/4.9/src/wp-admin/js/editor.js
r42442 r42575 282 282 283 283 /** 284 * @summary Check if a shortcode has Live Preview enabled for it.285 *286 * Previewable shortcodes here refers to shortcodes that have Live Preview enabled.287 *288 * These shortcodes get rewritten when the editor is in Visual mode, which means that289 * we don't want to change anything inside them, i.e. inserting a selection marker290 * inside the shortcode will break it :(291 *292 * @link wp-includes/js/mce-view.js293 *294 * @param {string} shortcode The shortcode to check.295 * @return {boolean} If a shortcode has Live Preview or not296 */297 function isShortcodePreviewable( shortcode ) {298 var defaultPreviewableShortcodes = [ 'caption' ];299 300 return (301 defaultPreviewableShortcodes.indexOf( shortcode ) !== -1 ||302 wp.mce.views.get( shortcode ) !== undefined303 );304 305 }306 307 /**308 284 * @summary Get all shortcodes and their positions in the content 309 285 * … … 341 317 var showAsPlainText = shortcodeMatch[1] === '['; 342 318 343 /**344 * For more context check the docs for:345 *346 * @link isShortcodePreviewable347 *348 * In addition, if the shortcode will get rendered as plain text ( see above ),349 * we can treat it as text and use the selection markers in it.350 */351 var isPreviewable = ! showAsPlainText && isShortcodePreviewable( shortcodeMatch[2] );352 353 319 shortcodeInfo = { 354 320 shortcodeName: shortcodeMatch[2], … … 356 322 startIndex: shortcodeMatch.index, 357 323 endIndex: shortcodeMatch.index + shortcodeMatch[0].length, 358 length: shortcodeMatch[0].length, 359 isPreviewable: isPreviewable 324 length: shortcodeMatch[0].length 360 325 }; 361 326 … … 383 348 endIndex: shortcodeMatch.index + shortcodeMatch[ 0 ].length, 384 349 length: shortcodeMatch[ 0 ].length, 385 isPreviewable: true,386 350 urlAtStartOfContent: shortcodeMatch[ 1 ] === '', 387 351 urlAtEndOfContent: shortcodeMatch[ 3 ] === '' … … 466 430 467 431 var isCursorStartInShortcode = getShortcodeWrapperInfo( content, cursorStart ); 468 if ( isCursorStartInShortcode && isCursorStartInShortcode.isPreviewable) {432 if ( isCursorStartInShortcode && ! isCursorStartInShortcode.showAsPlainText ) { 469 433 /** 470 434 * If a URL is at the start or the end of the content, … … 483 447 484 448 var isCursorEndInShortcode = getShortcodeWrapperInfo( content, cursorEnd ); 485 if ( isCursorEndInShortcode && isCursorEndInShortcode.isPreviewable) {449 if ( isCursorEndInShortcode && ! isCursorEndInShortcode.showAsPlainText ) { 486 450 if ( isCursorEndInShortcode.urlAtEndOfContent ) { 487 451 cursorEnd = isCursorEndInShortcode.startIndex;
Note: See TracChangeset
for help on using the changeset viewer.