Skip to content

Commit a79442b

Browse files
committed
Revert "chore: Move TINYMCE_ZERO_WIDTH_SPACE to keycodes and expand name"
This reverts commit 9eddb36.
1 parent 9eddb36 commit a79442b

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

editor/components/rich-text/index.js

+14-12
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,7 @@ import {
2525
getScrollContainer,
2626
} from '@wordpress/dom';
2727
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';
3729
import { withInstanceId, withSafeTimeout, Slot } from '@wordpress/components';
3830
import { withSelect } from '@wordpress/data';
3931
import { rawHandler } from '@wordpress/blocks';
@@ -58,6 +50,16 @@ import TokenUI from './tokens/ui';
5850

5951
const { Node } = window;
6052

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+
6163
/**
6264
* Returns true if the node is the inline node boundary. This is used in node
6365
* filtering prevent the inline boundary from being included in the split which
@@ -72,7 +74,7 @@ const { Node } = window;
7274
*/
7375
export function isEmptyInlineBoundary( node ) {
7476
const text = node.nodeName === 'A' ? node.innerText : node.textContent;
75-
return text === TINYMCE_ZERO_WIDTH_SPACE;
77+
return text === TINYMCE_ZWSP;
7678
}
7779

7880
/**
@@ -476,11 +478,11 @@ export class RichText extends Component {
476478
// only be exempt when focusNode is not _only_ the ZWSP, which occurs
477479
// when caret is placed on the right outside edge of inline boundary.
478480
if ( ! isReverse && focusOffset === nodeValue.length &&
479-
nodeValue.length > 1 && nodeValue[ 0 ] === TINYMCE_ZERO_WIDTH_SPACE ) {
481+
nodeValue.length > 1 && nodeValue[ 0 ] === TINYMCE_ZWSP ) {
480482
offset = 0;
481483
}
482484

483-
if ( nodeValue[ offset ] === TINYMCE_ZERO_WIDTH_SPACE ) {
485+
if ( nodeValue[ offset ] === TINYMCE_ZWSP ) {
484486
event.stopPropagation();
485487
}
486488
}

packages/keycodes/src/index.js

-10
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,6 @@ export const CTRL = 'ctrl';
3333
export const COMMAND = 'meta';
3434
export const SHIFT = 'shift';
3535

36-
/**
37-
* Zero-width space character used by TinyMCE as a caret landing point for
38-
* inline boundary nodes.
39-
*
40-
* @see tinymce/src/core/main/ts/text/Zwsp.ts
41-
*
42-
* @type {string}
43-
*/
44-
export const TINYMCE_ZERO_WIDTH_SPACE = '\uFEFF';
45-
4636
/**
4737
* Return true if platform is MacOS.
4838
*

0 commit comments

Comments
 (0)