@wordpress/block-editor 6.1.12 → 6.1.15
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 +100 -98
- package/build/components/block-list/head.js +27 -0
- package/build/components/block-list/head.js.map +1 -0
- package/build/components/block-list/index.js +4 -2
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/iframe/index.js +34 -5
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/rich-text/use-input-rules.js +5 -2
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/use-setting/index.js +1 -1
- package/build/components/use-setting/index.js.map +1 -1
- package/build/components/writing-flow/index.js +27 -14
- package/build/components/writing-flow/index.js.map +1 -1
- package/build/components/writing-flow/use-select-all.js +36 -34
- package/build/components/writing-flow/use-select-all.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +8 -0
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/hooks/duotone.js +5 -2
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/layout.js +5 -2
- package/build/hooks/layout.js.map +1 -1
- package/build-module/components/block-list/head.js +19 -0
- package/build-module/components/block-list/head.js.map +1 -0
- package/build-module/components/block-list/index.js +3 -2
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/iframe/index.js +34 -5
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/rich-text/use-input-rules.js +5 -2
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/use-setting/index.js +1 -1
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/components/writing-flow/index.js +23 -12
- package/build-module/components/writing-flow/index.js.map +1 -1
- package/build-module/components/writing-flow/use-select-all.js +30 -28
- package/build-module/components/writing-flow/use-select-all.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +8 -0
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/hooks/duotone.js +5 -2
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/layout.js +5 -2
- package/build-module/hooks/layout.js.map +1 -1
- package/build-style/style-rtl.css +1 -1
- package/build-style/style.css +1 -1
- package/package.json +23 -23
- package/src/components/block-list/head.js +18 -0
- package/src/components/block-list/index.js +21 -18
- package/src/components/block-list-appender/style.scss +3 -4
- package/src/components/iframe/index.js +39 -7
- package/src/components/rich-text/use-input-rules.js +4 -2
- package/src/components/use-setting/index.js +1 -1
- package/src/components/writing-flow/index.js +23 -10
- package/src/components/writing-flow/use-select-all.js +33 -35
- package/src/components/writing-flow/use-tab-nav.js +8 -0
- package/src/hooks/duotone.js +13 -5
- package/src/hooks/layout.js +12 -4
|
@@ -35,6 +35,8 @@ var _backCompat = _interopRequireDefault(require("../block-tools/back-compat"));
|
|
|
35
35
|
|
|
36
36
|
var _blockSelectionClearer = require("../block-selection-clearer");
|
|
37
37
|
|
|
38
|
+
var _head = require("./head");
|
|
39
|
+
|
|
38
40
|
/**
|
|
39
41
|
* External dependencies
|
|
40
42
|
*/
|
|
@@ -73,14 +75,14 @@ function Root({
|
|
|
73
75
|
isNavigationMode: _isNavigationMode()
|
|
74
76
|
};
|
|
75
77
|
}, []);
|
|
76
|
-
return (0, _element.createElement)("div", {
|
|
78
|
+
return (0, _element.createElement)(_head.Head, null, (0, _element.createElement)("div", {
|
|
77
79
|
ref: (0, _compose.useMergeRefs)([(0, _blockSelectionClearer.useBlockSelectionClearer)(), (0, _useBlockDropZone.default)(), (0, _useInBetweenInserter.useInBetweenInserter)()]),
|
|
78
80
|
className: (0, _classnames.default)('block-editor-block-list__layout is-root-container', className, {
|
|
79
81
|
'is-outline-mode': isOutlineMode,
|
|
80
82
|
'is-focus-mode': isFocusMode && isLargeViewport,
|
|
81
83
|
'is-navigate-mode': isNavigationMode
|
|
82
84
|
})
|
|
83
|
-
}, children);
|
|
85
|
+
}, children));
|
|
84
86
|
}
|
|
85
87
|
|
|
86
88
|
function BlockList({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-list/index.js"],"names":["IntersectionObserver","Root","className","children","isLargeViewport","isOutlineMode","isFocusMode","isNavigationMode","select","getSettings","_isNavigationMode","blockEditorStore","outlineMode","focusMode","BlockList","props","Items","placeholder","rootClientId","renderAppender","__experimentalAppenderTagName","__experimentalLayout","layout","defaultLayout","intersectingBlocks","setIntersectingBlocks","Set","intersectionObserver","Observer","window","entries","oldIntersectingBlocks","newIntersectingBlocks","entry","clientId","target","getAttribute","action","isIntersecting","order","selectedBlocks","getBlockOrder","getSelectedBlockClientIds","map","has","includes","length","BlockListItems"],"mappings":";;;;;;;;;;;AAUA;;AAPA;;AAKA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-list/index.js"],"names":["IntersectionObserver","Root","className","children","isLargeViewport","isOutlineMode","isFocusMode","isNavigationMode","select","getSettings","_isNavigationMode","blockEditorStore","outlineMode","focusMode","BlockList","props","Items","placeholder","rootClientId","renderAppender","__experimentalAppenderTagName","__experimentalLayout","layout","defaultLayout","intersectingBlocks","setIntersectingBlocks","Set","intersectionObserver","Observer","window","entries","oldIntersectingBlocks","newIntersectingBlocks","entry","clientId","target","getAttribute","action","isIntersecting","order","selectedBlocks","getBlockOrder","getSelectedBlockClientIds","map","has","includes","length","BlockListItems"],"mappings":";;;;;;;;;;;AAUA;;AAPA;;AAKA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAxBA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AAYO,MAAMA,oBAAoB,GAAG,6BAA7B;;;AAEP,SAASC,IAAT,CAAe;AAAEC,EAAAA,SAAF;AAAaC,EAAAA;AAAb,CAAf,EAAyC;AACxC,QAAMC,eAAe,GAAG,+BAAkB,QAAlB,CAAxB;AACA,QAAM;AAAEC,IAAAA,aAAF;AAAi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,CAAwBV,QAAxB,CAAF,IACA,CAAEM,cAAc,CAACK,QAAf,CAAyBX,QAAzB;AANJ,KASC,4BAAC,cAAD;AACC,IAAA,YAAY,EAAGhB,YADhB;AAEC,IAAA,QAAQ,EAAGgB;AAFZ,IATD,CADC,CADH,CADD,EAmBGK,KAAK,CAACO,MAAN,GAAe,CAAf,IAAoB7B,WAnBvB,EAoBC,4BAAC,0BAAD;AACC,IAAA,OAAO,EAAGG,6BADX;AAEC,IAAA,YAAY,EAAGF,YAFhB;AAGC,IAAA,cAAc,EAAGC;AAHlB,IApBD,CADD;AA4BA;;AAEM,SAAS4B,cAAT,CAAyBhC,KAAzB,EAAiC;AACvC;AACA;AACA,SACC,4BAAC,uBAAD;AAAmB,IAAA,KAAK,EAAG;AAA3B,KACC,4BAAC,KAAD,EAAYA,KAAZ,CADD,CADD;AAKA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\nimport { useViewportMatch, useMergeRefs } from '@wordpress/compose';\nimport { createContext, useState, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockListBlock from './block';\nimport BlockListAppender from '../block-list-appender';\nimport useBlockDropZone from '../use-block-drop-zone';\nimport { useInBetweenInserter } from './use-in-between-inserter';\nimport { store as blockEditorStore } from '../../store';\nimport { usePreParsePatterns } from '../../utils/pre-parse-patterns';\nimport { LayoutProvider, defaultLayout } from './layout';\nimport BlockToolsBackCompat from '../block-tools/back-compat';\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { Head } from './head';\n\nexport const IntersectionObserver = createContext();\n\nfunction Root( { className, children } ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst { isOutlineMode, isFocusMode, isNavigationMode } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings, isNavigationMode: _isNavigationMode } = select(\n\t\t\t\tblockEditorStore\n\t\t\t);\n\t\t\tconst { outlineMode, focusMode } = getSettings();\n\t\t\treturn {\n\t\t\t\tisOutlineMode: outlineMode,\n\t\t\t\tisFocusMode: focusMode,\n\t\t\t\tisNavigationMode: _isNavigationMode(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\treturn (\n\t\t<Head>\n\t\t\t<div\n\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\tuseBlockSelectionClearer(),\n\t\t\t\t\tuseBlockDropZone(),\n\t\t\t\t\tuseInBetweenInserter(),\n\t\t\t\t] ) }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-block-list__layout is-root-container',\n\t\t\t\t\tclassName,\n\t\t\t\t\t{\n\t\t\t\t\t\t'is-outline-mode': isOutlineMode,\n\t\t\t\t\t\t'is-focus-mode': isFocusMode && isLargeViewport,\n\t\t\t\t\t\t'is-navigate-mode': isNavigationMode,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</Head>\n\t);\n}\n\nexport default function BlockList( { className, ...props } ) {\n\tusePreParsePatterns();\n\treturn (\n\t\t<BlockToolsBackCompat>\n\t\t\t<Root className={ className }>\n\t\t\t\t<BlockListItems { ...props } />\n\t\t\t</Root>\n\t\t</BlockToolsBackCompat>\n\t);\n}\n\nfunction Items( {\n\tplaceholder,\n\trootClientId,\n\trenderAppender,\n\t__experimentalAppenderTagName,\n\t__experimentalLayout: layout = defaultLayout,\n} ) {\n\tconst [ intersectingBlocks, setIntersectingBlocks ] = useState( new Set() );\n\tconst intersectionObserver = useMemo( () => {\n\t\tconst { IntersectionObserver: Observer } = window;\n\n\t\tif ( ! Observer ) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn new Observer( ( entries ) => {\n\t\t\tsetIntersectingBlocks( ( oldIntersectingBlocks ) => {\n\t\t\t\tconst newIntersectingBlocks = new Set( oldIntersectingBlocks );\n\t\t\t\tfor ( const entry of entries ) {\n\t\t\t\t\tconst clientId = entry.target.getAttribute( 'data-block' );\n\t\t\t\t\tconst action = entry.isIntersecting ? 'add' : 'delete';\n\t\t\t\t\tnewIntersectingBlocks[ action ]( clientId );\n\t\t\t\t}\n\t\t\t\treturn newIntersectingBlocks;\n\t\t\t} );\n\t\t} );\n\t}, [ setIntersectingBlocks ] );\n\tconst { order, selectedBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockOrder, getSelectedBlockClientIds } = select(\n\t\t\t\tblockEditorStore\n\t\t\t);\n\t\t\treturn {\n\t\t\t\torder: getBlockOrder( rootClientId ),\n\t\t\t\tselectedBlocks: getSelectedBlockClientIds(),\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\n\treturn (\n\t\t<LayoutProvider value={ layout }>\n\t\t\t<IntersectionObserver.Provider value={ intersectionObserver }>\n\t\t\t\t{ order.map( ( clientId ) => (\n\t\t\t\t\t<AsyncModeProvider\n\t\t\t\t\t\tkey={ clientId }\n\t\t\t\t\t\tvalue={\n\t\t\t\t\t\t\t// Only provide data asynchronously if the block is\n\t\t\t\t\t\t\t// not visible and not selected.\n\t\t\t\t\t\t\t! intersectingBlocks.has( clientId ) &&\n\t\t\t\t\t\t\t! selectedBlocks.includes( clientId )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockListBlock\n\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</AsyncModeProvider>\n\t\t\t\t) ) }\n\t\t\t</IntersectionObserver.Provider>\n\t\t\t{ order.length < 1 && placeholder }\n\t\t\t<BlockListAppender\n\t\t\t\ttagName={ __experimentalAppenderTagName }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t\trenderAppender={ renderAppender }\n\t\t\t/>\n\t\t</LayoutProvider>\n\t);\n}\n\nexport function BlockListItems( props ) {\n\t// This component needs to always be synchronous as it's the one changing\n\t// the async mode depending on the block selection.\n\treturn (\n\t\t<AsyncModeProvider value={ false }>\n\t\t\t<Items { ...props } />\n\t\t</AsyncModeProvider>\n\t);\n}\n"]}
|
|
@@ -57,6 +57,19 @@ function styleSheetsCompat(doc) {
|
|
|
57
57
|
|
|
58
58
|
if (!cssRules) {
|
|
59
59
|
return;
|
|
60
|
+
} // Generally, ignore inline styles. We add inline styles belonging to a
|
|
61
|
+
// stylesheet later, which may or may not match the selectors.
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
if (ownerNode.tagName !== 'LINK') {
|
|
65
|
+
return;
|
|
66
|
+
} // Don't try to add the reset styles, which were removed as a dependency
|
|
67
|
+
// from `edit-blocks` for the iframe since we don't need to reset admin
|
|
68
|
+
// styles.
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
if (ownerNode.id === 'wp-reset-editor-styles-css') {
|
|
72
|
+
return;
|
|
60
73
|
}
|
|
61
74
|
|
|
62
75
|
const isMatch = Array.from(cssRules).find(({
|
|
@@ -67,8 +80,15 @@ function styleSheetsCompat(doc) {
|
|
|
67
80
|
// eslint-disable-next-line no-console
|
|
68
81
|
console.error(`Stylesheet ${ownerNode.id} was not properly added.
|
|
69
82
|
For blocks, use the block API's style (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#style) or editorStyle (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#editor-style).
|
|
70
|
-
For themes, use add_editor_style (https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#editor-styles).`, ownerNode);
|
|
71
|
-
doc.head.appendChild(ownerNode.cloneNode(true));
|
|
83
|
+
For themes, use add_editor_style (https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#editor-styles).`, ownerNode.outerHTML);
|
|
84
|
+
doc.head.appendChild(ownerNode.cloneNode(true)); // Add inline styles belonging to the stylesheet.
|
|
85
|
+
|
|
86
|
+
const inlineCssId = ownerNode.id.replace('-css', '-inline-css');
|
|
87
|
+
const inlineCssElement = document.getElementById(inlineCssId);
|
|
88
|
+
|
|
89
|
+
if (inlineCssElement) {
|
|
90
|
+
doc.head.appendChild(inlineCssElement.cloneNode(true));
|
|
91
|
+
}
|
|
72
92
|
}
|
|
73
93
|
});
|
|
74
94
|
}
|
|
@@ -249,15 +269,24 @@ function Iframe({
|
|
|
249
269
|
href,
|
|
250
270
|
id,
|
|
251
271
|
rel,
|
|
252
|
-
media
|
|
253
|
-
|
|
272
|
+
media,
|
|
273
|
+
textContent
|
|
274
|
+
}) => {
|
|
254
275
|
const TagName = tagName.toLowerCase();
|
|
276
|
+
|
|
277
|
+
if (TagName === 'style') {
|
|
278
|
+
return (0, _element.createElement)(TagName, {
|
|
279
|
+
id,
|
|
280
|
+
key: id
|
|
281
|
+
}, textContent);
|
|
282
|
+
}
|
|
283
|
+
|
|
255
284
|
return (0, _element.createElement)(TagName, {
|
|
256
285
|
href,
|
|
257
286
|
id,
|
|
258
287
|
rel,
|
|
259
288
|
media,
|
|
260
|
-
key:
|
|
289
|
+
key: id
|
|
261
290
|
});
|
|
262
291
|
}), head);
|
|
263
292
|
return (0, _element.createElement)("iframe", (0, _extends2.default)({}, props, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"names":["BODY_CLASS_NAME","BLOCK_PREFIX","styleSheetsCompat","doc","Array","from","document","styleSheets","forEach","styleSheet","cssRules","e","ownerNode","isMatch","find","selectorText","includes","getElementById","id","console","error","head","appendChild","cloneNode","bubbleEvents","defaultView","frameElement","bubbleEvent","event","prototype","Object","getPrototypeOf","constructorName","constructor","name","Constructor","window","init","key","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","cancelled","dispatchEvent","preventDefault","eventTypes","addEventListener","setBodyClassName","dir","body","className","classList","startsWith","add","useParsedAssets","html","implementation","createHTMLDocument","innerHTML","children","loadScript","src","Promise","resolve","reject","script","createElement","onload","onerror","Iframe","contentRef","props","ref","forceRender","iframeDocument","setIframeDocument","styles","__editorAssets","scripts","clearerRef","setRef","node","setDocumentIfReady","contentDocument","readyState","documentElement","current","reduce","promise","then","finally","map","tagName","href","rel","media","index","TagName","toLowerCase"],"mappings":";;;;;;;;;AAGA;;;;AASA;;AACA;;AACA;;AAKA;;AAnBA;AACA;AACA;;AAcA;AACA;AACA;AAGA,MAAMA,eAAe,GAAG,uBAAxB;AACA,MAAMC,YAAY,GAAG,UAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,iBAAT,CAA4BC,GAA5B,EAAkC;AACjC;AACAC,EAAAA,KAAK,CAACC,IAAN,CAAYC,QAAQ,CAACC,WAArB,EAAmCC,OAAnC,CAA8CC,UAAF,IAAkB;AAC7D,QAAI;AACH;AACA;AACAA,MAAAA,UAAU,CAACC,QAAX;AACA,KAJD,CAIE,OAAQC,CAAR,EAAY;AACb;AACA;;AAED,UAAM;AAAEC,MAAAA,SAAF;AAAaF,MAAAA;AAAb,QAA0BD,UAAhC;;AAEA,QAAK,CAAEC,QAAP,EAAkB;AACjB;AACA;;AAED,UAAMG,OAAO,GAAGT,KAAK,CAACC,IAAN,CAAYK,QAAZ,EAAuBI,IAAvB,CACf,CAAE;AAAEC,MAAAA;AAAF,KAAF,KACCA,YAAY,KACVA,YAAY,CAACC,QAAb,CAAwB,IAAIhB,eAAiB,EAA7C,KACDe,YAAY,CAACC,QAAb,CAAwB,IAAIf,YAAc,EAA1C,CAFW,CAFE,CAAhB;;AAOA,QAAKY,OAAO,IAAI,CAAEV,GAAG,CAACc,cAAJ,CAAoBL,SAAS,CAACM,EAA9B,CAAlB,EAAuD;AACtD;AACAC,MAAAA,OAAO,CAACC,KAAR,CACE,cAAcR,SAAS,CAACM,EAAI;AACjC;AACA,mIAHG,EAICN,SAJD;AAMAT,MAAAA,GAAG,CAACkB,IAAJ,CAASC,WAAT,CAAsBV,SAAS,CAACW,SAAV,CAAqB,IAArB,CAAtB;AACA;AACD,GAhCD;AAiCA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AAC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IAAhB;AAAsBjF,MAAAA,EAAtB;AAA0BkF,MAAAA,GAA1B;AAA+BC,MAAAA,KAA/B;AAAyC,MAAA,GAAG,EAAGC;AAA/C,MADD;AAGA,GALC,CAFH,EAQGjF,IARH,CADD;AAaA,SACC,iEACMwD,KADN;AAEC,IAAA,GAAG,EAAG,2BAAc,CAAEC,GAAF,EAAOQ,MAAP,CAAd,CAFP;AAGC,IAAA,QAAQ,EAAC,GAHV;AAIC,IAAA,KAAK,EAAG,cAAI,eAAJ,CAJT;AAKC,IAAA,IAAI,EAAC;AALN,MAOGN,cAAc,IACf,2BACC,4BAAC,uCAAD;AAAe,IAAA,QAAQ,EAAGA;AAA1B,KACGf,QADH,CADD,EAICe,cAAc,CAACzB,IAJhB,CARF,EAcGyB,cAAc,IAAI,2BAAc3D,IAAd,EAAoB2D,cAAc,CAAC3D,IAAnC,CAdrB,CADD;AAkBA;;eAEc,yBAAYsD,MAAZ,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tcreatePortal,\n\tuseCallback,\n\tforwardRef,\n\tuseEffect,\n\tuseMemo,\n\tuseReducer,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\n\nconst BODY_CLASS_NAME = 'editor-styles-wrapper';\nconst BLOCK_PREFIX = 'wp-block';\n\n/**\n * Clones stylesheets targetting the editor canvas to the given document. A\n * stylesheet is considered targetting the editor a canvas if it contains the\n * `editor-styles-wrapper`, `wp-block`, or `wp-block-*` class selectors.\n *\n * Ideally, this hook should be removed in the future and styles should be added\n * explicitly as editor styles.\n *\n * @param {Document} doc The document to append cloned stylesheets to.\n */\nfunction styleSheetsCompat( doc ) {\n\t// Search the document for stylesheets targetting the editor canvas.\n\tArray.from( document.styleSheets ).forEach( ( styleSheet ) => {\n\t\ttry {\n\t\t\t// May fail for external styles.\n\t\t\t// eslint-disable-next-line no-unused-expressions\n\t\t\tstyleSheet.cssRules;\n\t\t} catch ( e ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { ownerNode, cssRules } = styleSheet;\n\n\t\tif ( ! cssRules ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst isMatch = Array.from( cssRules ).find(\n\t\t\t( { selectorText } ) =>\n\t\t\t\tselectorText &&\n\t\t\t\t( selectorText.includes( `.${ BODY_CLASS_NAME }` ) ||\n\t\t\t\t\tselectorText.includes( `.${ BLOCK_PREFIX }` ) )\n\t\t);\n\n\t\tif ( isMatch && ! doc.getElementById( ownerNode.id ) ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error(\n\t\t\t\t`Stylesheet ${ ownerNode.id } was not properly added.\nFor blocks, use the block API's style (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#style) or editorStyle (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#editor-style).\nFor themes, use add_editor_style (https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#editor-styles).`,\n\t\t\t\townerNode\n\t\t\t);\n\t\t\tdoc.head.appendChild( ownerNode.cloneNode( true ) );\n\t\t}\n\t} );\n}\n\n/**\n * Bubbles some event types (keydown, keypress, and dragover) to parent document\n * document to ensure that the keyboard shortcuts and drag and drop work.\n *\n * Ideally, we should remove event bubbling in the future. Keyboard shortcuts\n * should be context dependent, e.g. actions on blocks like Cmd+A should not\n * work globally outside the block editor.\n *\n * @param {Document} doc Document to attach listeners to.\n */\nfunction bubbleEvents( doc ) {\n\tconst { defaultView } = doc;\n\tconst { frameElement } = defaultView;\n\n\tfunction bubbleEvent( event ) {\n\t\tconst prototype = Object.getPrototypeOf( event );\n\t\tconst constructorName = prototype.constructor.name;\n\t\tconst Constructor = window[ constructorName ];\n\n\t\tconst init = {};\n\n\t\tfor ( const key in event ) {\n\t\t\tinit[ key ] = event[ key ];\n\t\t}\n\n\t\tif ( event instanceof defaultView.MouseEvent ) {\n\t\t\tconst rect = frameElement.getBoundingClientRect();\n\t\t\tinit.clientX += rect.left;\n\t\t\tinit.clientY += rect.top;\n\t\t}\n\n\t\tconst newEvent = new Constructor( event.type, init );\n\t\tconst cancelled = ! frameElement.dispatchEvent( newEvent );\n\n\t\tif ( cancelled ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\n\tconst eventTypes = [ 'keydown', 'keypress', 'dragover' ];\n\n\tfor ( const name of eventTypes ) {\n\t\tdoc.addEventListener( name, bubbleEvent );\n\t}\n}\n\n/**\n * Sets the document direction.\n *\n * Sets the `editor-styles-wrapper` class name on the body.\n *\n * Copies the `admin-color-*` class name to the body so that the admin color\n * scheme applies to components in the iframe.\n *\n * @param {Document} doc Document to add class name to.\n */\nfunction setBodyClassName( doc ) {\n\tdoc.dir = document.dir;\n\tdoc.body.className = BODY_CLASS_NAME;\n\n\tfor ( const name of document.body.classList ) {\n\t\tif ( name.startsWith( 'admin-color-' ) ) {\n\t\t\tdoc.body.classList.add( name );\n\t\t} else if ( name === 'wp-embed-responsive' ) {\n\t\t\t// Ideally ALL classes that are added through get_body_class should\n\t\t\t// be added in the editor too, which we'll somehow have to get from\n\t\t\t// the server in the future (which will run the PHP filters).\n\t\t\tdoc.body.classList.add( 'wp-embed-responsive' );\n\t\t}\n\t}\n}\n\nfunction useParsedAssets( html ) {\n\treturn useMemo( () => {\n\t\tconst doc = document.implementation.createHTMLDocument( '' );\n\t\tdoc.body.innerHTML = html;\n\t\treturn Array.from( doc.body.children );\n\t}, [ html ] );\n}\n\nasync function loadScript( doc, { id, src } ) {\n\treturn new Promise( ( resolve, reject ) => {\n\t\tconst script = doc.createElement( 'script' );\n\t\tscript.id = id;\n\t\tif ( src ) {\n\t\t\tscript.src = src;\n\t\t\tscript.onload = () => resolve();\n\t\t\tscript.onerror = () => reject();\n\t\t} else {\n\t\t\tresolve();\n\t\t}\n\t\tdoc.head.appendChild( script );\n\t} );\n}\n\nfunction Iframe( { contentRef, children, head, ...props }, ref ) {\n\tconst [ , forceRender ] = useReducer( () => ( {} ) );\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst styles = useParsedAssets( window.__editorAssets.styles );\n\tconst scripts = useParsedAssets( window.__editorAssets.scripts );\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst setRef = useCallback( ( node ) => {\n\t\tif ( ! node ) {\n\t\t\treturn;\n\t\t}\n\n\t\tfunction setDocumentIfReady() {\n\t\t\tconst { contentDocument } = node;\n\t\t\tconst { readyState, body, documentElement } = contentDocument;\n\n\t\t\tif ( readyState !== 'interactive' && readyState !== 'complete' ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif ( typeof contentRef === 'function' ) {\n\t\t\t\tcontentRef( body );\n\t\t\t} else if ( contentRef ) {\n\t\t\t\tcontentRef.current = body;\n\t\t\t}\n\n\t\t\tsetBodyClassName( contentDocument );\n\t\t\tbubbleEvents( contentDocument );\n\t\t\tsetBodyClassName( contentDocument );\n\t\t\tsetIframeDocument( contentDocument );\n\t\t\tclearerRef( documentElement );\n\t\t\tclearerRef( body );\n\n\t\t\tscripts\n\t\t\t\t.reduce(\n\t\t\t\t\t( promise, script ) =>\n\t\t\t\t\t\tpromise.then( () =>\n\t\t\t\t\t\t\tloadScript( contentDocument, script )\n\t\t\t\t\t\t),\n\t\t\t\t\tPromise.resolve()\n\t\t\t\t)\n\t\t\t\t.finally( () => {\n\t\t\t\t\t// When script are loaded, re-render blocks to allow them\n\t\t\t\t\t// to initialise.\n\t\t\t\t\tforceRender();\n\t\t\t\t} );\n\n\t\t\treturn true;\n\t\t}\n\n\t\tif ( setDocumentIfReady() ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Document is not immediately loaded in Firefox.\n\t\tnode.addEventListener( 'load', () => {\n\t\t\tsetDocumentIfReady();\n\t\t} );\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( iframeDocument ) {\n\t\t\tstyleSheetsCompat( iframeDocument );\n\t\t}\n\t}, [ iframeDocument ] );\n\n\thead = (\n\t\t<>\n\t\t\t<style>{ 'body{margin:0}' }</style>\n\t\t\t{ styles.map( ( { tagName, href, id, rel, media }, index ) => {\n\t\t\t\tconst TagName = tagName.toLowerCase();\n\t\t\t\treturn (\n\t\t\t\t\t<TagName { ...{ href, id, rel, media } } key={ index } />\n\t\t\t\t);\n\t\t\t} ) }\n\t\t\t{ head }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<iframe\n\t\t\t{ ...props }\n\t\t\tref={ useMergeRefs( [ ref, setRef ] ) }\n\t\t\ttabIndex=\"0\"\n\t\t\ttitle={ __( 'Editor canvas' ) }\n\t\t\tname=\"editor-canvas\"\n\t\t>\n\t\t\t{ iframeDocument &&\n\t\t\t\tcreatePortal(\n\t\t\t\t\t<StyleProvider document={ iframeDocument }>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</StyleProvider>,\n\t\t\t\t\tiframeDocument.body\n\t\t\t\t) }\n\t\t\t{ iframeDocument && createPortal( head, iframeDocument.head ) }\n\t\t</iframe>\n\t);\n}\n\nexport default forwardRef( Iframe );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"names":["BODY_CLASS_NAME","BLOCK_PREFIX","styleSheetsCompat","doc","Array","from","document","styleSheets","forEach","styleSheet","cssRules","e","ownerNode","tagName","id","isMatch","find","selectorText","includes","getElementById","console","error","outerHTML","head","appendChild","cloneNode","inlineCssId","replace","inlineCssElement","bubbleEvents","defaultView","frameElement","bubbleEvent","event","prototype","Object","getPrototypeOf","constructorName","constructor","name","Constructor","window","init","key","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","cancelled","dispatchEvent","preventDefault","eventTypes","addEventListener","setBodyClassName","dir","body","className","classList","startsWith","add","useParsedAssets","html","implementation","createHTMLDocument","innerHTML","children","loadScript","src","Promise","resolve","reject","script","createElement","onload","onerror","Iframe","contentRef","props","ref","forceRender","iframeDocument","setIframeDocument","styles","__editorAssets","scripts","clearerRef","setRef","node","setDocumentIfReady","contentDocument","readyState","documentElement","current","reduce","promise","then","finally","map","href","rel","media","textContent","TagName","toLowerCase"],"mappings":";;;;;;;;;AAGA;;;;AASA;;AACA;;AACA;;AAKA;;AAnBA;AACA;AACA;;AAcA;AACA;AACA;AAGA,MAAMA,eAAe,GAAG,uBAAxB;AACA,MAAMC,YAAY,GAAG,UAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,iBAAT,CAA4BC,GAA5B,EAAkC;AACjC;AACAC,EAAAA,KAAK,CAACC,IAAN,CAAYC,QAAQ,CAACC,WAArB,EAAmCC,OAAnC,CAA8CC,UAAF,IAAkB;AAC7D,QAAI;AACH;AACA;AACAA,MAAAA,UAAU,CAACC,QAAX;AACA,KAJD,CAIE,OAAQC,CAAR,EAAY;AACb;AACA;;AAED,UAAM;AAAEC,MAAAA,SAAF;AAAaF,MAAAA;AAAb,QAA0BD,UAAhC;;AAEA,QAAK,CAAEC,QAAP,EAAkB;AACjB;AACA,KAb4D,CAe7D;AACA;;;AACA,QAAKE,SAAS,CAACC,OAAV,KAAsB,MAA3B,EAAoC;AACnC;AACA,KAnB4D,CAqB7D;AACA;AACA;;;AACA,QAAKD,SAAS,CAACE,EAAV,KAAiB,4BAAtB,EAAqD;AACpD;AACA;;AAED,UAAMC,OAAO,GAAGX,KAAK,CAACC,IAAN,CAAYK,QAAZ,EAAuBM,IAAvB,CACf,CAAE;AAAEC,MAAAA;AAAF,KAAF,KACCA,YAAY,KACVA,YAAY,CAACC,QAAb,CAAwB,IAAIlB,eAAiB,EAA7C,KACDiB,YAAY,CAACC,QAAb,CAAwB,IAAIjB,YAAc,EAA1C,CAFW,CAFE,CAAhB;;AAOA,QAAKc,OAAO,IAAI,CAAEZ,GAAG,CAACgB,cAAJ,CAAoBP,SAAS,CAACE,EAA9B,CAAlB,EAAuD;AACtD;AACAM,MAAAA,OAAO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8D,cAAc,CAAC9D,IAAnC,CAdrB,CADD;AAkBA;;eAEc,yBAAYyD,MAAZ,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tcreatePortal,\n\tuseCallback,\n\tforwardRef,\n\tuseEffect,\n\tuseMemo,\n\tuseReducer,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\n\nconst BODY_CLASS_NAME = 'editor-styles-wrapper';\nconst BLOCK_PREFIX = 'wp-block';\n\n/**\n * Clones stylesheets targetting the editor canvas to the given document. A\n * stylesheet is considered targetting the editor a canvas if it contains the\n * `editor-styles-wrapper`, `wp-block`, or `wp-block-*` class selectors.\n *\n * Ideally, this hook should be removed in the future and styles should be added\n * explicitly as editor styles.\n *\n * @param {Document} doc The document to append cloned stylesheets to.\n */\nfunction styleSheetsCompat( doc ) {\n\t// Search the document for stylesheets targetting the editor canvas.\n\tArray.from( document.styleSheets ).forEach( ( styleSheet ) => {\n\t\ttry {\n\t\t\t// May fail for external styles.\n\t\t\t// eslint-disable-next-line no-unused-expressions\n\t\t\tstyleSheet.cssRules;\n\t\t} catch ( e ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { ownerNode, cssRules } = styleSheet;\n\n\t\tif ( ! cssRules ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Generally, ignore inline styles. We add inline styles belonging to a\n\t\t// stylesheet later, which may or may not match the selectors.\n\t\tif ( ownerNode.tagName !== 'LINK' ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Don't try to add the reset styles, which were removed as a dependency\n\t\t// from `edit-blocks` for the iframe since we don't need to reset admin\n\t\t// styles.\n\t\tif ( ownerNode.id === 'wp-reset-editor-styles-css' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst isMatch = Array.from( cssRules ).find(\n\t\t\t( { selectorText } ) =>\n\t\t\t\tselectorText &&\n\t\t\t\t( selectorText.includes( `.${ BODY_CLASS_NAME }` ) ||\n\t\t\t\t\tselectorText.includes( `.${ BLOCK_PREFIX }` ) )\n\t\t);\n\n\t\tif ( isMatch && ! doc.getElementById( ownerNode.id ) ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error(\n\t\t\t\t`Stylesheet ${ ownerNode.id } was not properly added.\nFor blocks, use the block API's style (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#style) or editorStyle (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#editor-style).\nFor themes, use add_editor_style (https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#editor-styles).`,\n\t\t\t\townerNode.outerHTML\n\t\t\t);\n\t\t\tdoc.head.appendChild( ownerNode.cloneNode( true ) );\n\n\t\t\t// Add inline styles belonging to the stylesheet.\n\t\t\tconst inlineCssId = ownerNode.id.replace( '-css', '-inline-css' );\n\t\t\tconst inlineCssElement = document.getElementById( inlineCssId );\n\n\t\t\tif ( inlineCssElement ) {\n\t\t\t\tdoc.head.appendChild( inlineCssElement.cloneNode( true ) );\n\t\t\t}\n\t\t}\n\t} );\n}\n\n/**\n * Bubbles some event types (keydown, keypress, and dragover) to parent document\n * document to ensure that the keyboard shortcuts and drag and drop work.\n *\n * Ideally, we should remove event bubbling in the future. Keyboard shortcuts\n * should be context dependent, e.g. actions on blocks like Cmd+A should not\n * work globally outside the block editor.\n *\n * @param {Document} doc Document to attach listeners to.\n */\nfunction bubbleEvents( doc ) {\n\tconst { defaultView } = doc;\n\tconst { frameElement } = defaultView;\n\n\tfunction bubbleEvent( event ) {\n\t\tconst prototype = Object.getPrototypeOf( event );\n\t\tconst constructorName = prototype.constructor.name;\n\t\tconst Constructor = window[ constructorName ];\n\n\t\tconst init = {};\n\n\t\tfor ( const key in event ) {\n\t\t\tinit[ key ] = event[ key ];\n\t\t}\n\n\t\tif ( event instanceof defaultView.MouseEvent ) {\n\t\t\tconst rect = frameElement.getBoundingClientRect();\n\t\t\tinit.clientX += rect.left;\n\t\t\tinit.clientY += rect.top;\n\t\t}\n\n\t\tconst newEvent = new Constructor( event.type, init );\n\t\tconst cancelled = ! frameElement.dispatchEvent( newEvent );\n\n\t\tif ( cancelled ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\n\tconst eventTypes = [ 'keydown', 'keypress', 'dragover' ];\n\n\tfor ( const name of eventTypes ) {\n\t\tdoc.addEventListener( name, bubbleEvent );\n\t}\n}\n\n/**\n * Sets the document direction.\n *\n * Sets the `editor-styles-wrapper` class name on the body.\n *\n * Copies the `admin-color-*` class name to the body so that the admin color\n * scheme applies to components in the iframe.\n *\n * @param {Document} doc Document to add class name to.\n */\nfunction setBodyClassName( doc ) {\n\tdoc.dir = document.dir;\n\tdoc.body.className = BODY_CLASS_NAME;\n\n\tfor ( const name of document.body.classList ) {\n\t\tif ( name.startsWith( 'admin-color-' ) ) {\n\t\t\tdoc.body.classList.add( name );\n\t\t} else if ( name === 'wp-embed-responsive' ) {\n\t\t\t// Ideally ALL classes that are added through get_body_class should\n\t\t\t// be added in the editor too, which we'll somehow have to get from\n\t\t\t// the server in the future (which will run the PHP filters).\n\t\t\tdoc.body.classList.add( 'wp-embed-responsive' );\n\t\t}\n\t}\n}\n\nfunction useParsedAssets( html ) {\n\treturn useMemo( () => {\n\t\tconst doc = document.implementation.createHTMLDocument( '' );\n\t\tdoc.body.innerHTML = html;\n\t\treturn Array.from( doc.body.children );\n\t}, [ html ] );\n}\n\nasync function loadScript( doc, { id, src } ) {\n\treturn new Promise( ( resolve, reject ) => {\n\t\tconst script = doc.createElement( 'script' );\n\t\tscript.id = id;\n\t\tif ( src ) {\n\t\t\tscript.src = src;\n\t\t\tscript.onload = () => resolve();\n\t\t\tscript.onerror = () => reject();\n\t\t} else {\n\t\t\tresolve();\n\t\t}\n\t\tdoc.head.appendChild( script );\n\t} );\n}\n\nfunction Iframe( { contentRef, children, head, ...props }, ref ) {\n\tconst [ , forceRender ] = useReducer( () => ( {} ) );\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst styles = useParsedAssets( window.__editorAssets.styles );\n\tconst scripts = useParsedAssets( window.__editorAssets.scripts );\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst setRef = useCallback( ( node ) => {\n\t\tif ( ! node ) {\n\t\t\treturn;\n\t\t}\n\n\t\tfunction setDocumentIfReady() {\n\t\t\tconst { contentDocument } = node;\n\t\t\tconst { readyState, body, documentElement } = contentDocument;\n\n\t\t\tif ( readyState !== 'interactive' && readyState !== 'complete' ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif ( typeof contentRef === 'function' ) {\n\t\t\t\tcontentRef( body );\n\t\t\t} else if ( contentRef ) {\n\t\t\t\tcontentRef.current = body;\n\t\t\t}\n\n\t\t\tsetBodyClassName( contentDocument );\n\t\t\tbubbleEvents( contentDocument );\n\t\t\tsetBodyClassName( contentDocument );\n\t\t\tsetIframeDocument( contentDocument );\n\t\t\tclearerRef( documentElement );\n\t\t\tclearerRef( body );\n\n\t\t\tscripts\n\t\t\t\t.reduce(\n\t\t\t\t\t( promise, script ) =>\n\t\t\t\t\t\tpromise.then( () =>\n\t\t\t\t\t\t\tloadScript( contentDocument, script )\n\t\t\t\t\t\t),\n\t\t\t\t\tPromise.resolve()\n\t\t\t\t)\n\t\t\t\t.finally( () => {\n\t\t\t\t\t// When script are loaded, re-render blocks to allow them\n\t\t\t\t\t// to initialise.\n\t\t\t\t\tforceRender();\n\t\t\t\t} );\n\n\t\t\treturn true;\n\t\t}\n\n\t\tif ( setDocumentIfReady() ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Document is not immediately loaded in Firefox.\n\t\tnode.addEventListener( 'load', () => {\n\t\t\tsetDocumentIfReady();\n\t\t} );\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( iframeDocument ) {\n\t\t\tstyleSheetsCompat( iframeDocument );\n\t\t}\n\t}, [ iframeDocument ] );\n\n\thead = (\n\t\t<>\n\t\t\t<style>{ 'body{margin:0}' }</style>\n\t\t\t{ styles.map(\n\t\t\t\t( { tagName, href, id, rel, media, textContent } ) => {\n\t\t\t\t\tconst TagName = tagName.toLowerCase();\n\n\t\t\t\t\tif ( TagName === 'style' ) {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<TagName { ...{ id } } key={ id }>\n\t\t\t\t\t\t\t\t{ textContent }\n\t\t\t\t\t\t\t</TagName>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<TagName { ...{ href, id, rel, media } } key={ id } />\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t) }\n\t\t\t{ head }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<iframe\n\t\t\t{ ...props }\n\t\t\tref={ useMergeRefs( [ ref, setRef ] ) }\n\t\t\ttabIndex=\"0\"\n\t\t\ttitle={ __( 'Editor canvas' ) }\n\t\t\tname=\"editor-canvas\"\n\t\t>\n\t\t\t{ iframeDocument &&\n\t\t\t\tcreatePortal(\n\t\t\t\t\t<StyleProvider document={ iframeDocument }>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</StyleProvider>,\n\t\t\t\t\tiframeDocument.body\n\t\t\t\t) }\n\t\t\t{ iframeDocument && createPortal( head, iframeDocument.head ) }\n\t\t</iframe>\n\t);\n}\n\nexport default forwardRef( Iframe );\n"]}
|
|
@@ -77,7 +77,8 @@ function useInputRules(props) {
|
|
|
77
77
|
|
|
78
78
|
function onInput(event) {
|
|
79
79
|
const {
|
|
80
|
-
inputType
|
|
80
|
+
inputType,
|
|
81
|
+
type
|
|
81
82
|
} = event;
|
|
82
83
|
const {
|
|
83
84
|
value,
|
|
@@ -86,7 +87,7 @@ function useInputRules(props) {
|
|
|
86
87
|
formatTypes
|
|
87
88
|
} = propsRef.current; // Only run input rules when inserting text.
|
|
88
89
|
|
|
89
|
-
if (inputType !== 'insertText') {
|
|
90
|
+
if (inputType !== 'insertText' && type !== 'compositionend') {
|
|
90
91
|
return;
|
|
91
92
|
}
|
|
92
93
|
|
|
@@ -116,8 +117,10 @@ function useInputRules(props) {
|
|
|
116
117
|
}
|
|
117
118
|
|
|
118
119
|
element.addEventListener('input', onInput);
|
|
120
|
+
element.addEventListener('compositionend', onInput);
|
|
119
121
|
return () => {
|
|
120
122
|
element.removeEventListener('input', onInput);
|
|
123
|
+
element.removeEventListener('compositionend', onInput);
|
|
121
124
|
};
|
|
122
125
|
}, []);
|
|
123
126
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/use-input-rules.js"],"names":["useInputRules","props","__unstableMarkLastChangeAsPersistent","__unstableMarkAutomaticChange","blockEditorStore","propsRef","current","element","inputRule","value","onReplace","start","text","characterBefore","slice","trimmedTextBefore","trim","prefixTransforms","filter","type","transformation","prefix","content","length","block","transform","onInput","event","inputType","onChange","__unstableAllowPrefixTransformations","formatTypes","transformed","reduce","accumlator","__unstableInputRule","activeFormats","addEventListener","removeEventListener"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;AAGO,SAASA,aAAT,CAAwBC,KAAxB,EAAgC;AACtC,QAAM;AACLC,IAAAA,oCADK;AAELC,IAAAA;AAFK,MAGF,uBAAaC,YAAb,CAHJ;AAIA,QAAMC,QAAQ,GAAG,qBAAQJ,KAAR,CAAjB;AACAI,EAAAA,QAAQ,CAACC,OAAT,GAAmBL,KAAnB;AACA,SAAO,2BAAgBM,OAAF,IAAe;AACnC,aAASC,SAAT,GAAqB;AACpB,YAAM;AAAEC,QAAAA,KAAF;AAASC,QAAAA;AAAT,UAAuBL,QAAQ,CAACC,OAAtC;;AAEA,UAAK,CAAEI,SAAP,EAAmB;AAClB;AACA;;AAED,YAAM;AAAEC,QAAAA,KAAF;AAASC,QAAAA;AAAT,UAAkBH,KAAxB;AACA,YAAMI,eAAe,GAAGD,IAAI,CAACE,KAAL,CAAYH,KAAK,GAAG,CAApB,EAAuBA,KAAvB,CAAxB,CARoB,CAUpB;;AACA,UAAKE,eAAe,KAAK,GAAzB,EAA+B;AAC9B;AACA;;AAED,YAAME,iBAAiB,GAAGH,IAAI,CAACE,KAAL,CAAY,CAAZ,EAAeH,KAAf,EAAuBK,IAAvB,EAA1B;AACA,YAAMC,gBAAgB,GAAG,gCAAoB,MAApB,EAA6BC,MAA7B,CACxB,CAAE;AAAEC,QAAAA;AAAF,OAAF,KAAgBA,IAAI,KAAK,QADD,CAAzB;AAGA,YAAMC,cAAc,GAAG,2BACtBH,gBADsB,EAEtB,CAAE;AAAEI,QAAAA;AAAF,OAAF,KAAkB;AACjB,eAAON,iBAAiB,KAAKM,MAA7B;AACA,OAJqB,CAAvB;;AAOA,UAAK,CAAED,cAAP,EAAwB;AACvB;AACA;;AAED,YAAME,OAAO,GAAG,4BAAc;AAC7Bb,QAAAA,KAAK,EAAE,qBAAOA,KAAP,EAAcE,KAAd,EAAqBC,IAAI,CAACW,MAA1B;AADsB,OAAd,CAAhB;AAGA,YAAMC,KAAK,GAAGJ,cAAc,CAACK,SAAf,CAA0BH,OAA1B,CAAd;AAEAZ,MAAAA,SAAS,CAAE,CAAEc,KAAF,CAAF,CAAT;;AACArB,MAAAA,6BAA6B;AAC7B;;AAED,aAASuB,OAAT,CAAkBC,KAAlB,EAA0B;AACzB,YAAM;AAAEC,QAAAA;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/use-input-rules.js"],"names":["useInputRules","props","__unstableMarkLastChangeAsPersistent","__unstableMarkAutomaticChange","blockEditorStore","propsRef","current","element","inputRule","value","onReplace","start","text","characterBefore","slice","trimmedTextBefore","trim","prefixTransforms","filter","type","transformation","prefix","content","length","block","transform","onInput","event","inputType","onChange","__unstableAllowPrefixTransformations","formatTypes","transformed","reduce","accumlator","__unstableInputRule","activeFormats","addEventListener","remove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,EAAsCZ,OAAtC;AACAnB,MAAAA,OAAO,CAAC+B,mBAAR,CAA6B,gBAA7B,EAA+CZ,OAA/C;AACA,KAHD;AAIA,GArFM,EAqFJ,EArFI,CAAP;AAsFA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { slice, toHTMLString } from '@wordpress/rich-text';\nimport { getBlockTransforms, findTransform } from '@wordpress/blocks';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nexport function useInputRules( props ) {\n\tconst {\n\t\t__unstableMarkLastChangeAsPersistent,\n\t\t__unstableMarkAutomaticChange,\n\t} = useDispatch( blockEditorStore );\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\treturn useRefEffect( ( element ) => {\n\t\tfunction inputRule() {\n\t\t\tconst { value, onReplace } = propsRef.current;\n\n\t\t\tif ( ! onReplace ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { start, text } = value;\n\t\t\tconst characterBefore = text.slice( start - 1, start );\n\n\t\t\t// The character right before the caret must be a plain space.\n\t\t\tif ( characterBefore !== ' ' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst trimmedTextBefore = text.slice( 0, start ).trim();\n\t\t\tconst prefixTransforms = getBlockTransforms( 'from' ).filter(\n\t\t\t\t( { type } ) => type === 'prefix'\n\t\t\t);\n\t\t\tconst transformation = findTransform(\n\t\t\t\tprefixTransforms,\n\t\t\t\t( { prefix } ) => {\n\t\t\t\t\treturn trimmedTextBefore === prefix;\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( ! transformation ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst content = toHTMLString( {\n\t\t\t\tvalue: slice( value, start, text.length ),\n\t\t\t} );\n\t\t\tconst block = transformation.transform( content );\n\n\t\t\tonReplace( [ block ] );\n\t\t\t__unstableMarkAutomaticChange();\n\t\t}\n\n\t\tfunction onInput( event ) {\n\t\t\tconst { inputType, type } = event;\n\t\t\tconst {\n\t\t\t\tvalue,\n\t\t\t\tonChange,\n\t\t\t\t__unstableAllowPrefixTransformations,\n\t\t\t\tformatTypes,\n\t\t\t} = propsRef.current;\n\n\t\t\t// Only run input rules when inserting text.\n\t\t\tif ( inputType !== 'insertText' && type !== 'compositionend' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( __unstableAllowPrefixTransformations && inputRule ) {\n\t\t\t\tinputRule();\n\t\t\t}\n\n\t\t\tconst transformed = formatTypes.reduce(\n\t\t\t\t( accumlator, { __unstableInputRule } ) => {\n\t\t\t\t\tif ( __unstableInputRule ) {\n\t\t\t\t\t\taccumlator = __unstableInputRule( accumlator );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn accumlator;\n\t\t\t\t},\n\t\t\t\tvalue\n\t\t\t);\n\n\t\t\tif ( transformed !== value ) {\n\t\t\t\t__unstableMarkLastChangeAsPersistent();\n\t\t\t\tonChange( {\n\t\t\t\t\t...transformed,\n\t\t\t\t\tactiveFormats: value.activeFormats,\n\t\t\t\t} );\n\t\t\t\t__unstableMarkAutomaticChange();\n\t\t\t}\n\t\t}\n\n\t\telement.addEventListener( 'input', onInput );\n\t\telement.addEventListener( 'compositionend', onInput );\n\t\treturn () => {\n\t\t\telement.removeEventListener( 'input', onInput );\n\t\t\telement.removeEventListener( 'compositionend', onInput );\n\t\t};\n\t}, [] );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/use-setting/index.js"],"names":["deprecatedFlags","settings","colors","undefined","gradients","disableCustomColors","disableCustomGradients","fontSizes","disableCustomFontSizes","enableCustomLineHeight","enableCustomUnits","enableCustomSpacing","PATHS_WITH_MERGE","useSetting","path","name","blockName","setting","select","blockEditorStore","getSettings","defaultsPath","blockPath","experimentalFeaturesResult","user","theme","core","deprecatedSettingsValue"],"mappings":";;;;;;;A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import { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit';\nimport { store as blockEditorStore } from '../../store';\n\nconst deprecatedFlags = {\n\t'color.palette': ( settings ) =>\n\t\tsettings.colors === undefined ? undefined : settings.colors,\n\t'color.gradients': ( settings ) =>\n\t\tsettings.gradients === undefined ? undefined : settings.gradients,\n\t'color.custom': ( settings ) =>\n\t\tsettings.disableCustomColors === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomColors,\n\t'color.customGradient': ( settings ) =>\n\t\tsettings.disableCustomGradients === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomGradients,\n\t'typography.fontSizes': ( settings ) =>\n\t\tsettings.fontSizes === undefined ? undefined : settings.fontSizes,\n\t'typography.customFontSize': ( settings ) =>\n\t\tsettings.disableCustomFontSizes === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomFontSizes,\n\t'typography.customLineHeight': ( settings ) =>\n\t\tsettings.enableCustomLineHeight,\n\t'spacing.units': ( settings ) => {\n\t\tif ( settings.enableCustomUnits === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( settings.enableCustomUnits === true ) {\n\t\t\treturn [ 'px', 'em', 'rem', 'vh', 'vw' ];\n\t\t}\n\n\t\treturn settings.enableCustomUnits;\n\t},\n\t'spacing.customPadding': ( settings ) => settings.enableCustomSpacing,\n};\n\nconst PATHS_WITH_MERGE = {\n\t'color.gradients': true,\n\t'color.palette': true,\n\t'typography.fontFamilies': true,\n\t'typography.fontSizes': true,\n};\n\n/**\n * Hook that retrieves the editor setting.\n * It works with nested objects using by finding the value at path.\n *\n * @param {string} path The path to the setting.\n *\n * @return {any} Returns the value defined for the setting.\n *\n * @example\n * ```js\n * const isEnabled = useSetting( 'typography.dropCap' );\n * ```\n */\nexport default function useSetting( path ) {\n\tconst { name: blockName } = useBlockEditContext();\n\n\tconst setting = useSelect(\n\t\t( select ) => {\n\t\t\tconst settings = select( blockEditorStore ).getSettings();\n\n\t\t\t// 1 - Use __experimental features, if available.\n\t\t\t// We cascade to the all value if the block one is not available.\n\t\t\tconst defaultsPath = `__experimentalFeatures.${ path }`;\n\t\t\tconst blockPath = `__experimentalFeatures.blocks.${ blockName }.${ path }`;\n\t\t\tconst experimentalFeaturesResult =\n\t\t\t\tget( settings, blockPath ) ?? get( settings, defaultsPath );\n\t\t\tif ( experimentalFeaturesResult !== undefined ) {\n\t\t\t\tif ( PATHS_WITH_MERGE[ path ] ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\texperimentalFeaturesResult.user ??\n\t\t\t\t\t\texperimentalFeaturesResult.theme ??\n\t\t\t\t\t\texperimentalFeaturesResult.core\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn experimentalFeaturesResult;\n\t\t\t}\n\n\t\t\t// 2 - Use deprecated settings, otherwise.\n\t\t\tconst deprecatedSettingsValue = deprecatedFlags[ path ]\n\t\t\t\t? deprecatedFlags[ path ]( settings )\n\t\t\t\t: undefined;\n\t\t\tif ( deprecatedSettingsValue !== undefined ) {\n\t\t\t\treturn deprecatedSettingsValue;\n\t\t\t}\n\n\t\t\t// 3 - Fall back for typography.dropCap:\n\t\t\t// This is only necessary to support typography.dropCap.\n\t\t\t// when __experimentalFeatures are not present (core without plugin).\n\t\t\t// To remove when __experimentalFeatures are ported to core.\n\t\t\treturn path === 'typography.dropCap' ? true : undefined;\n\t\t},\n\t\t[ blockName, path ]\n\t);\n\n\treturn setting;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/use-setting/index.js"],"names":["deprecatedFlags","settings","colors","undefined","gradients","disableCustomColors","disableCustomGradients","fontSizes","disableCustomFontSizes","enableCustomLineHeight","enableCustomUnits","enableCustomSpacing","PATHS_WITH_MERGE","useSetting","path","name","blockName","setting","select","blockEditorStore","getSettings","defaultsPath","blockPath","experimentalFeaturesResult","user","theme","core","deprecat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G,OAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit';\nimport { store as blockEditorStore } from '../../store';\n\nconst deprecatedFlags = {\n\t'color.palette': ( settings ) =>\n\t\tsettings.colors === undefined ? undefined : settings.colors,\n\t'color.gradients': ( settings ) =>\n\t\tsettings.gradients === undefined ? undefined : settings.gradients,\n\t'color.custom': ( settings ) =>\n\t\tsettings.disableCustomColors === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomColors,\n\t'color.customGradient': ( settings ) =>\n\t\tsettings.disableCustomGradients === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomGradients,\n\t'typography.fontSizes': ( settings ) =>\n\t\tsettings.fontSizes === undefined ? undefined : settings.fontSizes,\n\t'typography.customFontSize': ( settings ) =>\n\t\tsettings.disableCustomFontSizes === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomFontSizes,\n\t'typography.customLineHeight': ( settings ) =>\n\t\tsettings.enableCustomLineHeight,\n\t'spacing.units': ( settings ) => {\n\t\tif ( settings.enableCustomUnits === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( settings.enableCustomUnits === true ) {\n\t\t\treturn [ 'px', 'em', 'rem', 'vh', 'vw', '%' ];\n\t\t}\n\n\t\treturn settings.enableCustomUnits;\n\t},\n\t'spacing.customPadding': ( settings ) => settings.enableCustomSpacing,\n};\n\nconst PATHS_WITH_MERGE = {\n\t'color.gradients': true,\n\t'color.palette': true,\n\t'typography.fontFamilies': true,\n\t'typography.fontSizes': true,\n};\n\n/**\n * Hook that retrieves the editor setting.\n * It works with nested objects using by finding the value at path.\n *\n * @param {string} path The path to the setting.\n *\n * @return {any} Returns the value defined for the setting.\n *\n * @example\n * ```js\n * const isEnabled = useSetting( 'typography.dropCap' );\n * ```\n */\nexport default function useSetting( path ) {\n\tconst { name: blockName } = useBlockEditContext();\n\n\tconst setting = useSelect(\n\t\t( select ) => {\n\t\t\tconst settings = select( blockEditorStore ).getSettings();\n\n\t\t\t// 1 - Use __experimental features, if available.\n\t\t\t// We cascade to the all value if the block one is not available.\n\t\t\tconst defaultsPath = `__experimentalFeatures.${ path }`;\n\t\t\tconst blockPath = `__experimentalFeatures.blocks.${ blockName }.${ path }`;\n\t\t\tconst experimentalFeaturesResult =\n\t\t\t\tget( settings, blockPath ) ?? get( settings, defaultsPath );\n\t\t\tif ( experimentalFeaturesResult !== undefined ) {\n\t\t\t\tif ( PATHS_WITH_MERGE[ path ] ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\texperimentalFeaturesResult.user ??\n\t\t\t\t\t\texperimentalFeaturesResult.theme ??\n\t\t\t\t\t\texperimentalFeaturesResult.core\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn experimentalFeaturesResult;\n\t\t\t}\n\n\t\t\t// 2 - Use deprecated settings, otherwise.\n\t\t\tconst deprecatedSettingsValue = deprecatedFlags[ path ]\n\t\t\t\t? deprecatedFlags[ path ]( settings )\n\t\t\t\t: undefined;\n\t\t\tif ( deprecatedSettingsValue !== undefined ) {\n\t\t\t\treturn deprecatedSettingsValue;\n\t\t\t}\n\n\t\t\t// 3 - Fall back for typography.dropCap:\n\t\t\t// This is only necessary to support typography.dropCap.\n\t\t\t// when __experimentalFeatures are not present (core without plugin).\n\t\t\t// To remove when __experimentalFeatures are ported to core.\n\t\t\treturn path === 'typography.dropCap' ? true : undefined;\n\t\t},\n\t\t[ blockName, path ]\n\t);\n\n\treturn setting;\n}\n"]}
|
|
@@ -5,10 +5,14 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.default =
|
|
8
|
+
exports.default = void 0;
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
14
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
+
|
|
12
16
|
var _data = require("@wordpress/data");
|
|
13
17
|
|
|
14
18
|
var _i18n = require("@wordpress/i18n");
|
|
@@ -25,6 +29,10 @@ var _useSelectAll = _interopRequireDefault(require("./use-select-all"));
|
|
|
25
29
|
|
|
26
30
|
var _store = require("../../store");
|
|
27
31
|
|
|
32
|
+
/**
|
|
33
|
+
* External dependencies
|
|
34
|
+
*/
|
|
35
|
+
|
|
28
36
|
/**
|
|
29
37
|
* WordPress dependencies
|
|
30
38
|
*/
|
|
@@ -32,7 +40,19 @@ var _store = require("../../store");
|
|
|
32
40
|
/**
|
|
33
41
|
* Internal dependencies
|
|
34
42
|
*/
|
|
35
|
-
|
|
43
|
+
function WritingFlow({
|
|
44
|
+
children,
|
|
45
|
+
...props
|
|
46
|
+
}, forwardedRef) {
|
|
47
|
+
const [before, ref, after] = (0, _useTabNav.default)();
|
|
48
|
+
const hasMultiSelection = (0, _data.useSelect)(select => select(_store.store).hasMultiSelection(), []);
|
|
49
|
+
return (0, _element.createElement)(_element.Fragment, null, before, (0, _element.createElement)("div", (0, _extends2.default)({}, props, {
|
|
50
|
+
ref: (0, _compose.useMergeRefs)([forwardedRef, ref, (0, _useMultiSelection.default)(), (0, _useSelectAll.default)(), (0, _useArrowNav.default)()]),
|
|
51
|
+
className: (0, _classnames.default)(props.className, 'block-editor-writing-flow'),
|
|
52
|
+
tabIndex: -1,
|
|
53
|
+
"aria-label": hasMultiSelection ? (0, _i18n.__)('Multiple selected blocks') : undefined
|
|
54
|
+
}), children), after);
|
|
55
|
+
}
|
|
36
56
|
/**
|
|
37
57
|
* Handles selection and navigation across blocks. This component should be
|
|
38
58
|
* wrapped around BlockList.
|
|
@@ -40,16 +60,9 @@ var _store = require("../../store");
|
|
|
40
60
|
* @param {Object} props Component properties.
|
|
41
61
|
* @param {WPElement} props.children Children to be rendered.
|
|
42
62
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return (0, _element.createElement)(_element.Fragment, null, before, (0, _element.createElement)("div", {
|
|
49
|
-
ref: (0, _compose.useMergeRefs)([ref, (0, _useMultiSelection.default)(), (0, _useSelectAll.default)(), (0, _useArrowNav.default)()]),
|
|
50
|
-
className: "block-editor-writing-flow",
|
|
51
|
-
tabIndex: hasMultiSelection ? '0' : undefined,
|
|
52
|
-
"aria-label": hasMultiSelection ? (0, _i18n.__)('Multiple selected blocks') : undefined
|
|
53
|
-
}, children), after);
|
|
54
|
-
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
var _default = (0, _element.forwardRef)(WritingFlow);
|
|
66
|
+
|
|
67
|
+
exports.default = _default;
|
|
55
68
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/index.js"],"names":["WritingFlow","children","before","ref","after","hasMultiSelection","select","blockEditorStore","undefined"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/index.js"],"names":["WritingFlow","children","props","forwardedRef","before","ref","after","hasMultiSelection","select","blockEditorStore","className","undefined"],"mappings":";;;;;;;;;AAWA;;;;AARA;;AAKA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AApBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAOA,SAASA,WAAT,CAAsB;AAAEC,EAAAA,QAAF;AAAY,KAAGC;AAAf,CAAtB,EAA8CC,YAA9C,EAA6D;AAC5D,QAAM,CAAEC,MAAF,EAAUC,GAAV,EAAeC,KAAf,IAAyB,yBAA/B;AACA,QAAMC,iBAAiB,GAAG,qBACvBC,MAAF,IAAcA,MAAM,CAAEC,YAAF,CAAN,CAA2BF,iBAA3B,EADW,EAEzB,EAFyB,CAA1B;AAIA,SACC,qDACGH,MADH,EAEC,8DACMF,KADN;AAEC,IAAA,GAAG,EAAG,2BAAc,CACnBC,YADmB,EAEnBE,GAFmB,EAGnB,iCAHmB,EAInB,4BAJmB,EAKnB,2BALmB,CAAd,CAFP;AASC,IAAA,SAAS,EAAG,yBACXH,KAAK,CAACQ,SADK,EAEX,2BAFW,CATb;AAaC,IAAA,QAAQ,EAAG,CAAC,CAbb;AAcC,kBACCH,iBAAiB,GACd,cAAI,0BAAJ,CADc,GAEdI;AAjBL,MAoBGV,QApBH,CAFD,EAwBGK,KAxBH,CADD;AA4BA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;eACe,yBAAYN,WAAZ,C","sourcesContent":["/**\n * External dependencies\n */\nimport classNames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useMultiSelection from './use-multi-selection';\nimport useTabNav from './use-tab-nav';\nimport useArrowNav from './use-arrow-nav';\nimport useSelectAll from './use-select-all';\nimport { store as blockEditorStore } from '../../store';\n\nfunction WritingFlow( { children, ...props }, forwardedRef ) {\n\tconst [ before, ref, after ] = useTabNav();\n\tconst hasMultiSelection = useSelect(\n\t\t( select ) => select( blockEditorStore ).hasMultiSelection(),\n\t\t[]\n\t);\n\treturn (\n\t\t<>\n\t\t\t{ before }\n\t\t\t<div\n\t\t\t\t{ ...props }\n\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\tforwardedRef,\n\t\t\t\t\tref,\n\t\t\t\t\tuseMultiSelection(),\n\t\t\t\t\tuseSelectAll(),\n\t\t\t\t\tuseArrowNav(),\n\t\t\t\t] ) }\n\t\t\t\tclassName={ classNames(\n\t\t\t\t\tprops.className,\n\t\t\t\t\t'block-editor-writing-flow'\n\t\t\t\t) }\n\t\t\t\ttabIndex={ -1 }\n\t\t\t\taria-label={\n\t\t\t\t\thasMultiSelection\n\t\t\t\t\t\t? __( 'Multiple selected blocks' )\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t\t{ after }\n\t\t</>\n\t);\n}\n\n/**\n * Handles selection and navigation across blocks. This component should be\n * wrapped around BlockList.\n *\n * @param {Object} props Component properties.\n * @param {WPElement} props.children Children to be rendered.\n */\nexport default forwardRef( WritingFlow );\n"]}
|
|
@@ -9,12 +9,12 @@ var _lodash = require("lodash");
|
|
|
9
9
|
|
|
10
10
|
var _dom = require("@wordpress/dom");
|
|
11
11
|
|
|
12
|
-
var _element = require("@wordpress/element");
|
|
13
|
-
|
|
14
12
|
var _data = require("@wordpress/data");
|
|
15
13
|
|
|
16
14
|
var _keyboardShortcuts = require("@wordpress/keyboard-shortcuts");
|
|
17
15
|
|
|
16
|
+
var _compose = require("@wordpress/compose");
|
|
17
|
+
|
|
18
18
|
var _store = require("../../store");
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -29,7 +29,6 @@ var _store = require("../../store");
|
|
|
29
29
|
* Internal dependencies
|
|
30
30
|
*/
|
|
31
31
|
function useSelectAll() {
|
|
32
|
-
const ref = (0, _element.useRef)();
|
|
33
32
|
const {
|
|
34
33
|
getBlockOrder,
|
|
35
34
|
getSelectedBlockClientIds,
|
|
@@ -38,39 +37,42 @@ function useSelectAll() {
|
|
|
38
37
|
const {
|
|
39
38
|
multiSelect
|
|
40
39
|
} = (0, _data.useDispatch)(_store.store);
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
40
|
+
const isMatch = (0, _keyboardShortcuts.__unstableUseShortcutEventMatch)();
|
|
41
|
+
return (0, _compose.useRefEffect)(node => {
|
|
42
|
+
function onKeyDown(event) {
|
|
43
|
+
if (!isMatch('core/block-editor/select-all', event)) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (!(0, _dom.isEntirelySelected)(event.target)) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const selectedClientIds = getSelectedBlockClientIds();
|
|
52
|
+
const [firstSelectedClientId] = selectedClientIds;
|
|
53
|
+
const rootClientId = getBlockRootClientId(firstSelectedClientId);
|
|
54
|
+
let blockClientIds = getBlockOrder(rootClientId); // If we have selected all sibling nested blocks, try selecting up a
|
|
55
|
+
// level. See: https://github.com/WordPress/gutenberg/pull/31859/
|
|
56
|
+
|
|
57
|
+
if (selectedClientIds.length === blockClientIds.length) {
|
|
58
|
+
blockClientIds = getBlockOrder(getBlockRootClientId(rootClientId));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const firstClientId = (0, _lodash.first)(blockClientIds);
|
|
62
|
+
const lastClientId = (0, _lodash.last)(blockClientIds);
|
|
63
|
+
|
|
64
|
+
if (firstClientId === lastClientId) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
multiSelect(firstClientId, lastClientId);
|
|
69
|
+
event.preventDefault();
|
|
66
70
|
}
|
|
67
71
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
target: ref
|
|
72
|
+
node.addEventListener('keydown', onKeyDown);
|
|
73
|
+
return () => {
|
|
74
|
+
node.removeEventListener('keydown', onKeyDown);
|
|
75
|
+
};
|
|
73
76
|
});
|
|
74
|
-
return ref;
|
|
75
77
|
}
|
|
76
78
|
//# sourceMappingURL=use-select-all.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-select-all.js"],"names":["useSelectAll","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-select-all.js"],"names":["useSelectAll","getBlockOrder","getSelectedBlockClientIds","getBlockRootClientId","blockEditorStore","multiSelect","isMatch","node","onKeyDown","event","target","selectedClientIds","firstSelectedClientId","rootClientId","blockClientIds","length","firstClientId","lastClientId","preventDefault","addEventListener","removeEventListener"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAGe,SAASA,YAAT,GAAwB;AACtC,QAAM;AACLC,IAAAA,aADK;AAELC,IAAAA,yBAFK;AAGLC,IAAAA;AAHK,MAIF,qBAAWC,YAAX,CAJJ;AAKA,QAAM;AAAEC,IAAAA;AAAF,MAAkB,uBAAaD,YAAb,CAAxB;AACA,QAAME,OAAO,GAAG,yDAAhB;AAEA,SAAO,2BAAgBC,IAAF,IAAY;AAChC,aAASC,SAAT,CAAoBC,KAApB,EAA4B;AAC3B,UAAK,CAAEH,OAAO,CAAE,8BAAF,EAAkCG,KAAlC,CAAd,EAA0D;AACzD;AACA;;AAED,UAAK,CAAE,6BAAoBA,KAAK,CAACC,MAA1B,CAAP,EAA4C;AAC3C;AACA;;AAED,YAAMC,iBAAiB,GAAGT,yBAAyB,EAAnD;AACA,YAAM,CAAEU,qBAAF,IAA4BD,iBAAlC;AACA,YAAME,YAAY,GAAGV,oBAAoB,CAAES,qBAAF,CAAzC;AACA,UAAIE,cAAc,GAAGb,aAAa,CAAEY,YAAF,CAAlC,CAZ2B,CAc3B;AACA;;AACA,UAAKF,iBAAiB,CAACI,MAAlB,KAA6BD,cAAc,CAACC,MAAjD,EAA0D;AACzDD,QAAAA,cAAc,GAAGb,aAAa,CAC7BE,oBAAoB,CAAEU,YAAF,CADS,CAA9B;AAGA;;AAED,YAAMG,aAAa,GAAG,mBAAOF,cAAP,CAAtB;AACA,YAAMG,YAAY,GAAG,kBAAMH,cAAN,CAArB;;AAEA,UAAKE,aAAa,KAAKC,YAAvB,EAAsC;AACrC;AACA;;AAEDZ,MAAAA,WAAW,CAAEW,aAAF,EAAiBC,YAAjB,CAAX;AACAR,MAAAA,KAAK,CAACS,cAAN;AACA;;AAEDX,IAAAA,IAAI,CAACY,gBAAL,CAAuB,SAAvB,EAAkCX,SAAlC;AAEA,WAAO,MAAM;AACZD,MAAAA,IAAI,CAACa,mBAAL,CAA0B,SAA1B,EAAqCZ,SAArC;AACA,KAFD;AAGA,GAvCM,CAAP;AAwCA","sourcesContent":["/**\n * External dependencies\n */\nimport { first, last } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { isEntirelySelected } from '@wordpress/dom';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nexport default function useSelectAll() {\n\tconst {\n\t\tgetBlockOrder,\n\t\tgetSelectedBlockClientIds,\n\t\tgetBlockRootClientId,\n\t} = useSelect( blockEditorStore );\n\tconst { multiSelect } = useDispatch( blockEditorStore );\n\tconst isMatch = useShortcutEventMatch();\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( ! isMatch( 'core/block-editor/select-all', event ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! isEntirelySelected( event.target ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selectedClientIds = getSelectedBlockClientIds();\n\t\t\tconst [ firstSelectedClientId ] = selectedClientIds;\n\t\t\tconst rootClientId = getBlockRootClientId( firstSelectedClientId );\n\t\t\tlet blockClientIds = getBlockOrder( rootClientId );\n\n\t\t\t// If we have selected all sibling nested blocks, try selecting up a\n\t\t\t// level. See: https://github.com/WordPress/gutenberg/pull/31859/\n\t\t\tif ( selectedClientIds.length === blockClientIds.length ) {\n\t\t\t\tblockClientIds = getBlockOrder(\n\t\t\t\t\tgetBlockRootClientId( rootClientId )\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst firstClientId = first( blockClientIds );\n\t\t\tconst lastClientId = last( blockClientIds );\n\n\t\t\tif ( firstClientId === lastClientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tmultiSelect( firstClientId, lastClientId );\n\t\t\tevent.preventDefault();\n\t\t}\n\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t};\n\t} );\n}\n"]}
|
|
@@ -82,6 +82,7 @@ function useTabNav() {
|
|
|
82
82
|
function onKeyDown(event) {
|
|
83
83
|
if (event.keyCode === _keycodes.ESCAPE && !hasMultiSelection()) {
|
|
84
84
|
event.stopPropagation();
|
|
85
|
+
event.preventDefault();
|
|
85
86
|
setNavigationMode(true);
|
|
86
87
|
return;
|
|
87
88
|
} // In Edit mode, Tab should focus the first tabbable element after
|
|
@@ -100,6 +101,13 @@ function useTabNav() {
|
|
|
100
101
|
const direction = isShift ? 'findPrevious' : 'findNext';
|
|
101
102
|
|
|
102
103
|
if (!hasMultiSelection() && !getSelectedBlockClientId()) {
|
|
104
|
+
// Preserve the behaviour of entering navigation mode when
|
|
105
|
+
// tabbing into the content without a block selection.
|
|
106
|
+
// `onFocusCapture` already did this previously, but we need to
|
|
107
|
+
// do it again here because after clearing block selection,
|
|
108
|
+
// focus land on the writing flow container and pressing Tab
|
|
109
|
+
// will no longer send focus through the focus capture element.
|
|
110
|
+
if (event.target === node) setNavigationMode(true);
|
|
103
111
|
return;
|
|
104
112
|
} // Allow tabbing between form elements rendered in a block,
|
|
105
113
|
// such as inside a placeholder. Form elements are generally
|