@@ -25,15 +25,7 @@ import {
25
25
getScrollContainer ,
26
26
} from '@wordpress/dom' ;
27
27
import { createBlobURL } from '@wordpress/blob' ;
28
- import {
29
- BACKSPACE ,
30
- DELETE ,
31
- ENTER ,
32
- LEFT ,
33
- RIGHT ,
34
- TINYMCE_ZERO_WIDTH_SPACE ,
35
- rawShortcut ,
36
- } from '@wordpress/keycodes' ;
28
+ import { BACKSPACE , DELETE , ENTER , LEFT , RIGHT , rawShortcut } from '@wordpress/keycodes' ;
37
29
import { withInstanceId , withSafeTimeout , Slot } from '@wordpress/components' ;
38
30
import { withSelect } from '@wordpress/data' ;
39
31
import { rawHandler } from '@wordpress/blocks' ;
@@ -58,6 +50,16 @@ import TokenUI from './tokens/ui';
58
50
59
51
const { Node } = window ;
60
52
53
+ /**
54
+ * Zero-width space character used by TinyMCE as a caret landing point for
55
+ * inline boundary nodes.
56
+ *
57
+ * @see tinymce/src/core/main/ts/text/Zwsp.ts
58
+ *
59
+ * @type {string }
60
+ */
61
+ const TINYMCE_ZWSP = '\uFEFF' ;
62
+
61
63
/**
62
64
* Returns true if the node is the inline node boundary. This is used in node
63
65
* filtering prevent the inline boundary from being included in the split which
@@ -72,7 +74,7 @@ const { Node } = window;
72
74
*/
73
75
export function isEmptyInlineBoundary ( node ) {
74
76
const text = node . nodeName === 'A' ? node . innerText : node . textContent ;
75
- return text === TINYMCE_ZERO_WIDTH_SPACE ;
77
+ return text === TINYMCE_ZWSP ;
76
78
}
77
79
78
80
/**
@@ -476,11 +478,11 @@ export class RichText extends Component {
476
478
// only be exempt when focusNode is not _only_ the ZWSP, which occurs
477
479
// when caret is placed on the right outside edge of inline boundary.
478
480
if ( ! isReverse && focusOffset === nodeValue . length &&
479
- nodeValue . length > 1 && nodeValue [ 0 ] === TINYMCE_ZERO_WIDTH_SPACE ) {
481
+ nodeValue . length > 1 && nodeValue [ 0 ] === TINYMCE_ZWSP ) {
480
482
offset = 0 ;
481
483
}
482
484
483
- if ( nodeValue [ offset ] === TINYMCE_ZERO_WIDTH_SPACE ) {
485
+ if ( nodeValue [ offset ] === TINYMCE_ZWSP ) {
484
486
event . stopPropagation ( ) ;
485
487
}
486
488
}
0 commit comments