@wordpress/block-editor 14.3.1 → 14.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/build/components/block-heading-level-dropdown/index.js +3 -1
- package/build/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build/components/block-list/block.js +27 -4
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/use-block-props/use-focus-first-element.js +0 -1
- package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js +9 -4
- package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +1 -1
- package/build/components/block-list/zoom-out-separator.js +18 -1
- package/build/components/block-list/zoom-out-separator.js.map +1 -1
- package/build/components/block-switcher/utils.js +1 -1
- package/build/components/block-switcher/utils.js.map +1 -1
- package/build/components/block-tools/zoom-out-toolbar.js +5 -2
- package/build/components/block-tools/zoom-out-toolbar.js.map +1 -1
- package/build/components/block-variation-transforms/index.js +12 -6
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/rich-text/event-listeners/paste-handler.js +2 -13
- package/build/components/rich-text/event-listeners/paste-handler.js.map +1 -1
- package/build/components/rich-text/index.js +34 -20
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/tool-selector/index.js +2 -1
- package/build/components/tool-selector/index.js.map +1 -1
- package/build/components/writing-flow/index.js +1 -2
- package/build/components/writing-flow/index.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +1 -4
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/components/writing-flow/use-input.js +1 -31
- package/build/components/writing-flow/use-input.js.map +1 -1
- package/build/components/writing-flow/use-select-all.js +1 -14
- package/build/components/writing-flow/use-select-all.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +2 -6
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/components/writing-flow/utils.js +0 -27
- package/build/components/writing-flow/utils.js.map +1 -1
- package/build/hooks/layout.js +12 -8
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +22 -28
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/hooks/use-zoom-out.js +20 -23
- package/build/hooks/use-zoom-out.js.map +1 -1
- package/build/store/private-actions.js +25 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +22 -0
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +21 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +12 -5
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/index.js +3 -1
- package/build-module/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build-module/components/block-list/block.js +28 -7
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js +0 -1
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js +9 -4
- package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +1 -1
- package/build-module/components/block-list/zoom-out-separator.js +18 -1
- package/build-module/components/block-list/zoom-out-separator.js.map +1 -1
- package/build-module/components/block-switcher/utils.js +1 -1
- package/build-module/components/block-switcher/utils.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-toolbar.js +5 -2
- package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -1
- package/build-module/components/block-variation-transforms/index.js +12 -6
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/rich-text/event-listeners/paste-handler.js +2 -13
- package/build-module/components/rich-text/event-listeners/paste-handler.js.map +1 -1
- package/build-module/components/rich-text/index.js +34 -20
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/tool-selector/index.js +2 -1
- package/build-module/components/tool-selector/index.js.map +1 -1
- package/build-module/components/writing-flow/index.js +1 -2
- package/build-module/components/writing-flow/index.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +1 -4
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/components/writing-flow/use-input.js +1 -31
- package/build-module/components/writing-flow/use-input.js.map +1 -1
- package/build-module/components/writing-flow/use-select-all.js +1 -14
- package/build-module/components/writing-flow/use-select-all.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +2 -6
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/components/writing-flow/utils.js +0 -26
- package/build-module/components/writing-flow/utils.js.map +1 -1
- package/build-module/hooks/layout.js +13 -9
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +22 -28
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/hooks/use-zoom-out.js +20 -23
- package/build-module/hooks/use-zoom-out.js.map +1 -1
- package/build-module/store/private-actions.js +23 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +20 -0
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +20 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +12 -5
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/content-rtl.css +10 -0
- package/build-style/content.css +10 -0
- package/build-style/style-rtl.css +4 -0
- package/build-style/style.css +4 -0
- package/package.json +20 -20
- package/src/components/block-heading-level-dropdown/index.js +7 -1
- package/src/components/block-list/block.js +47 -11
- package/src/components/block-list/content.scss +12 -0
- package/src/components/block-list/use-block-props/use-focus-first-element.js +0 -1
- package/src/components/block-list/use-block-props/use-zoom-out-mode-exit.js +7 -3
- package/src/components/block-list/zoom-out-separator.js +14 -1
- package/src/components/block-switcher/test/use-transformed.patterns.js +3 -3
- package/src/components/block-switcher/test/utils.js +3 -3
- package/src/components/block-switcher/utils.js +1 -1
- package/src/components/block-toolbar/style.scss +7 -0
- package/src/components/block-tools/zoom-out-toolbar.js +5 -2
- package/src/components/block-variation-transforms/index.js +13 -4
- package/src/components/rich-text/event-listeners/paste-handler.js +2 -7
- package/src/components/rich-text/index.js +36 -23
- package/src/components/tool-selector/index.js +4 -1
- package/src/components/writing-flow/index.js +0 -2
- package/src/components/writing-flow/use-arrow-nav.js +2 -9
- package/src/components/writing-flow/use-input.js +1 -36
- package/src/components/writing-flow/use-select-all.js +1 -18
- package/src/components/writing-flow/use-selection-observer.js +3 -14
- package/src/components/writing-flow/utils.js +0 -30
- package/src/hooks/layout.js +17 -12
- package/src/hooks/use-bindings-attributes.js +26 -32
- package/src/hooks/use-zoom-out.js +21 -27
- package/src/store/private-actions.js +23 -0
- package/src/store/private-selectors.js +20 -0
- package/src/store/reducer.js +20 -0
- package/src/store/selectors.js +13 -8
- package/src/store/test/private-selectors.js +2 -2
- package/src/store/test/selectors.js +10 -6
- package/build/components/writing-flow/use-event-redirect.js +0 -66
- package/build/components/writing-flow/use-event-redirect.js.map +0 -1
- package/build-module/components/writing-flow/use-event-redirect.js +0 -60
- package/build-module/components/writing-flow/use-event-redirect.js.map +0 -1
- package/src/components/writing-flow/use-event-redirect.js +0 -72
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = useEventRedirect;
|
|
7
|
-
var _compose = require("@wordpress/compose");
|
|
8
|
-
var _utils = require("./utils");
|
|
9
|
-
/**
|
|
10
|
-
* WordPress dependencies
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Whenever content editable is enabled on writing flow, it will have focus, so
|
|
19
|
-
* we need to dispatch some events to the root of the selection to ensure
|
|
20
|
-
* compatibility with rich text. In the future, perhaps the rich text event
|
|
21
|
-
* handlers should be attached to the window instead.
|
|
22
|
-
*
|
|
23
|
-
* Alternatively, we could try to find a way to always maintain rich text focus.
|
|
24
|
-
*/
|
|
25
|
-
function useEventRedirect() {
|
|
26
|
-
return (0, _compose.useRefEffect)(node => {
|
|
27
|
-
function onInput(event) {
|
|
28
|
-
if (event.target !== node) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
const {
|
|
32
|
-
ownerDocument
|
|
33
|
-
} = node;
|
|
34
|
-
const {
|
|
35
|
-
defaultView
|
|
36
|
-
} = ownerDocument;
|
|
37
|
-
const prototype = Object.getPrototypeOf(event);
|
|
38
|
-
const constructorName = prototype.constructor.name;
|
|
39
|
-
const Constructor = defaultView[constructorName];
|
|
40
|
-
const root = (0, _utils.getSelectionRoot)(ownerDocument);
|
|
41
|
-
if (!root || root === node) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const init = {};
|
|
45
|
-
for (const key in event) {
|
|
46
|
-
init[key] = event[key];
|
|
47
|
-
}
|
|
48
|
-
init.bubbles = false;
|
|
49
|
-
const newEvent = new Constructor(event.type, init);
|
|
50
|
-
const cancelled = !root.dispatchEvent(newEvent);
|
|
51
|
-
if (cancelled) {
|
|
52
|
-
event.preventDefault();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
const events = ['beforeinput', 'input', 'compositionstart', 'compositionend', 'compositionupdate', 'keydown'];
|
|
56
|
-
events.forEach(eventType => {
|
|
57
|
-
node.addEventListener(eventType, onInput);
|
|
58
|
-
});
|
|
59
|
-
return () => {
|
|
60
|
-
events.forEach(eventType => {
|
|
61
|
-
node.removeEventListener(eventType, onInput);
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
}, []);
|
|
65
|
-
}
|
|
66
|
-
//# sourceMappingURL=use-event-redirect.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_compose","require","_utils","useEventRedirect","useRefEffect","node","onInput","event","target","ownerDocument","defaultView","prototype","Object","getPrototypeOf","constructorName","constructor","name","Constructor","root","getSelectionRoot","init","key","bubbles","newEvent","type","cancelled","dispatchEvent","preventDefault","events","forEach","eventType","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-event-redirect.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getSelectionRoot } from './utils';\n\n/**\n * Whenever content editable is enabled on writing flow, it will have focus, so\n * we need to dispatch some events to the root of the selection to ensure\n * compatibility with rich text. In the future, perhaps the rich text event\n * handlers should be attached to the window instead.\n *\n * Alternatively, we could try to find a way to always maintain rich text focus.\n */\nexport default function useEventRedirect() {\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onInput( event ) {\n\t\t\tif ( event.target !== node ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\t\t\tconst prototype = Object.getPrototypeOf( event );\n\t\t\tconst constructorName = prototype.constructor.name;\n\t\t\tconst Constructor = defaultView[ constructorName ];\n\t\t\tconst root = getSelectionRoot( ownerDocument );\n\n\t\t\tif ( ! root || root === node ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst init = {};\n\n\t\t\tfor ( const key in event ) {\n\t\t\t\tinit[ key ] = event[ key ];\n\t\t\t}\n\n\t\t\tinit.bubbles = false;\n\n\t\t\tconst newEvent = new Constructor( event.type, init );\n\t\t\tconst cancelled = ! root.dispatchEvent( newEvent );\n\n\t\t\tif ( cancelled ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\n\t\tconst events = [\n\t\t\t'beforeinput',\n\t\t\t'input',\n\t\t\t'compositionstart',\n\t\t\t'compositionend',\n\t\t\t'compositionupdate',\n\t\t\t'keydown',\n\t\t];\n\n\t\tevents.forEach( ( eventType ) => {\n\t\t\tnode.addEventListener( eventType, onInput );\n\t\t} );\n\n\t\treturn () => {\n\t\t\tevents.forEach( ( eventType ) => {\n\t\t\t\tnode.removeEventList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aAAa,EACb,OAAO,EACP,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,SAAS,CACT;IAEDA,MAAM,CAACC,OAAO,CAAIC,SAAS,IAAM;MAChCzB,IAAI,CAAC0B,gBAAgB,CAAED,SAAS,EAAExB,OAAQ,CAAC;IAC5C,CAAE,CAAC;IAEH,OAAO,MAAM;MACZsB,MAAM,CAACC,OAAO,CAAIC,SAAS,IAAM;QAChCzB,IAAI,CAAC2B,mBAAmB,CAAEF,SAAS,EAAExB,OAAQ,CAAC;MAC/C,CAAE,CAAC;IACJ,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR","ignoreList":[]}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useRefEffect } from '@wordpress/compose';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { getSelectionRoot } from './utils';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Whenever content editable is enabled on writing flow, it will have focus, so
|
|
13
|
-
* we need to dispatch some events to the root of the selection to ensure
|
|
14
|
-
* compatibility with rich text. In the future, perhaps the rich text event
|
|
15
|
-
* handlers should be attached to the window instead.
|
|
16
|
-
*
|
|
17
|
-
* Alternatively, we could try to find a way to always maintain rich text focus.
|
|
18
|
-
*/
|
|
19
|
-
export default function useEventRedirect() {
|
|
20
|
-
return useRefEffect(node => {
|
|
21
|
-
function onInput(event) {
|
|
22
|
-
if (event.target !== node) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const {
|
|
26
|
-
ownerDocument
|
|
27
|
-
} = node;
|
|
28
|
-
const {
|
|
29
|
-
defaultView
|
|
30
|
-
} = ownerDocument;
|
|
31
|
-
const prototype = Object.getPrototypeOf(event);
|
|
32
|
-
const constructorName = prototype.constructor.name;
|
|
33
|
-
const Constructor = defaultView[constructorName];
|
|
34
|
-
const root = getSelectionRoot(ownerDocument);
|
|
35
|
-
if (!root || root === node) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
const init = {};
|
|
39
|
-
for (const key in event) {
|
|
40
|
-
init[key] = event[key];
|
|
41
|
-
}
|
|
42
|
-
init.bubbles = false;
|
|
43
|
-
const newEvent = new Constructor(event.type, init);
|
|
44
|
-
const cancelled = !root.dispatchEvent(newEvent);
|
|
45
|
-
if (cancelled) {
|
|
46
|
-
event.preventDefault();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
const events = ['beforeinput', 'input', 'compositionstart', 'compositionend', 'compositionupdate', 'keydown'];
|
|
50
|
-
events.forEach(eventType => {
|
|
51
|
-
node.addEventListener(eventType, onInput);
|
|
52
|
-
});
|
|
53
|
-
return () => {
|
|
54
|
-
events.forEach(eventType => {
|
|
55
|
-
node.removeEventListener(eventType, onInput);
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
}, []);
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=use-event-redirect.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useRefEffect","getSelectionRoot","useEventRedirect","node","onInput","event","target","ownerDocument","defaultView","prototype","Object","getPrototypeOf","constructorName","constructor","name","Constructor","root","init","key","bubbles","newEvent","type","cancelled","dispatchEvent","preventDefault","events","forEach","eventType","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-event-redirect.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getSelectionRoot } from './utils';\n\n/**\n * Whenever content editable is enabled on writing flow, it will have focus, so\n * we need to dispatch some events to the root of the selection to ensure\n * compatibility with rich text. In the future, perhaps the rich text event\n * handlers should be attached to the window instead.\n *\n * Alternatively, we could try to find a way to always maintain rich text focus.\n */\nexport default function useEventRedirect() {\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onInput( event ) {\n\t\t\tif ( event.target !== node ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\t\t\tconst prototype = Object.getPrototypeOf( event );\n\t\t\tconst constructorName = prototype.constructor.name;\n\t\t\tconst Constructor = defaultView[ constructorName ];\n\t\t\tconst root = getSelectionRoot( ownerDocument );\n\n\t\t\tif ( ! root || root === node ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst init = {};\n\n\t\t\tfor ( const key in event ) {\n\t\t\t\tinit[ key ] = event[ key ];\n\t\t\t}\n\n\t\t\tinit.bubbles = false;\n\n\t\t\tconst newEvent = new Constructor( event.type, init );\n\t\t\tconst cancelled = ! root.dispatchEvent( newEvent );\n\n\t\t\tif ( cancelled ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\n\t\tconst events = [\n\t\t\t'beforeinput',\n\t\t\t'input',\n\t\t\t'compositionstart',\n\t\t\t'compositionend',\n\t\t\t'compositionupdate',\n\t\t\t'keydown',\n\t\t];\n\n\t\tevents.forEach( ( eventType ) => {\n\t\t\tnode.addEventListener( eventType, onInput );\n\t\t} );\n\n\t\treturn () => {\n\t\t\tevents.forEach( ( eventType ) => {\n\t\t\t\tnode.removeEventListener( eventType, onInput );\n\t\t\t} );\n\t\t};\n\t}, [] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,oBAAoB;;AAEjD;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,SAAS;;AAE1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,gBAAgBA,CAAA,EAAG;EAC1C,OAAOF,YAAY,CAAIG,IAAI,IAAM;IAChC,SAASC,OAAOA,CAAEC,KAAK,EAAG;MACzB,IAAKA,KAAK,CAACC,MAAM,KAAKH,IAAI,EAAG;QAC5B;MACD;MAEA,MAAM;QAAEI;MAAc,CAAC,GAAGJ,IAAI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
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useRefEffect } from '@wordpress/compose';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { getSelectionRoot } from './utils';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Whenever content editable is enabled on writing flow, it will have focus, so
|
|
13
|
-
* we need to dispatch some events to the root of the selection to ensure
|
|
14
|
-
* compatibility with rich text. In the future, perhaps the rich text event
|
|
15
|
-
* handlers should be attached to the window instead.
|
|
16
|
-
*
|
|
17
|
-
* Alternatively, we could try to find a way to always maintain rich text focus.
|
|
18
|
-
*/
|
|
19
|
-
export default function useEventRedirect() {
|
|
20
|
-
return useRefEffect( ( node ) => {
|
|
21
|
-
function onInput( event ) {
|
|
22
|
-
if ( event.target !== node ) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const { ownerDocument } = node;
|
|
27
|
-
const { defaultView } = ownerDocument;
|
|
28
|
-
const prototype = Object.getPrototypeOf( event );
|
|
29
|
-
const constructorName = prototype.constructor.name;
|
|
30
|
-
const Constructor = defaultView[ constructorName ];
|
|
31
|
-
const root = getSelectionRoot( ownerDocument );
|
|
32
|
-
|
|
33
|
-
if ( ! root || root === node ) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const init = {};
|
|
38
|
-
|
|
39
|
-
for ( const key in event ) {
|
|
40
|
-
init[ key ] = event[ key ];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
init.bubbles = false;
|
|
44
|
-
|
|
45
|
-
const newEvent = new Constructor( event.type, init );
|
|
46
|
-
const cancelled = ! root.dispatchEvent( newEvent );
|
|
47
|
-
|
|
48
|
-
if ( cancelled ) {
|
|
49
|
-
event.preventDefault();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const events = [
|
|
54
|
-
'beforeinput',
|
|
55
|
-
'input',
|
|
56
|
-
'compositionstart',
|
|
57
|
-
'compositionend',
|
|
58
|
-
'compositionupdate',
|
|
59
|
-
'keydown',
|
|
60
|
-
];
|
|
61
|
-
|
|
62
|
-
events.forEach( ( eventType ) => {
|
|
63
|
-
node.addEventListener( eventType, onInput );
|
|
64
|
-
} );
|
|
65
|
-
|
|
66
|
-
return () => {
|
|
67
|
-
events.forEach( ( eventType ) => {
|
|
68
|
-
node.removeEventListener( eventType, onInput );
|
|
69
|
-
} );
|
|
70
|
-
};
|
|
71
|
-
}, [] );
|
|
72
|
-
}
|