@wordpress/block-editor 15.16.0 → 15.16.1-next.v.202604091042.0
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/build/components/autocomplete/index.cjs +1 -2
- package/build/components/autocomplete/index.cjs.map +3 -3
- package/build/components/block-list/block-crash-warning.cjs +4 -2
- package/build/components/block-list/block-crash-warning.cjs.map +2 -2
- package/build/components/block-list/block-html.cjs +6 -2
- package/build/components/block-list/block-html.cjs.map +2 -2
- package/build/components/block-mover/button.cjs +4 -3
- package/build/components/block-mover/button.cjs.map +2 -2
- package/build/components/block-mover/index.cjs +1 -8
- package/build/components/block-mover/index.cjs.map +2 -2
- package/build/components/iframe/get-compatibility-styles.cjs +1 -1
- package/build/components/iframe/get-compatibility-styles.cjs.map +2 -2
- package/build/components/inserter/media-tab/hooks.cjs +1 -1
- package/build/components/inserter/media-tab/hooks.cjs.map +2 -2
- package/build/components/link-control/search-input.cjs +1 -1
- package/build/components/link-control/search-input.cjs.map +2 -2
- package/build/components/link-picker/link-preview.cjs +2 -1
- package/build/components/link-picker/link-preview.cjs.map +3 -3
- package/build/components/rich-text/index.cjs +1 -1
- package/build/components/rich-text/index.cjs.map +2 -2
- package/build/components/rich-text/input-event.cjs +3 -3
- package/build/components/rich-text/input-event.cjs.map +2 -2
- package/build/components/use-on-block-drop/index.cjs +1 -1
- package/build/components/use-on-block-drop/index.cjs.map +2 -2
- package/build/components/use-paste-styles/index.cjs +2 -2
- package/build/components/use-paste-styles/index.cjs.map +2 -2
- package/build/hooks/block-style-variation.cjs +5 -6
- package/build/hooks/block-style-variation.cjs.map +3 -3
- package/build/hooks/index.cjs +2 -2
- package/build/hooks/index.cjs.map +2 -2
- package/build/private-apis.cjs +1 -1
- package/build/private-apis.cjs.map +1 -1
- package/build/store/actions.cjs +0 -8
- package/build/store/actions.cjs.map +2 -2
- package/build/store/reducer.cjs +52 -53
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs +12 -13
- package/build/store/selectors.cjs.map +2 -2
- package/build/store/utils.cjs +1 -1
- package/build/store/utils.cjs.map +2 -2
- package/build/utils/pasting.cjs +1 -1
- package/build/utils/pasting.cjs.map +2 -2
- package/build-module/components/autocomplete/index.mjs +1 -2
- package/build-module/components/autocomplete/index.mjs.map +2 -2
- package/build-module/components/block-list/block-crash-warning.mjs +4 -2
- package/build-module/components/block-list/block-crash-warning.mjs.map +2 -2
- package/build-module/components/block-list/block-html.mjs +7 -3
- package/build-module/components/block-list/block-html.mjs.map +2 -2
- package/build-module/components/block-mover/button.mjs +4 -3
- package/build-module/components/block-mover/button.mjs.map +2 -2
- package/build-module/components/block-mover/index.mjs +1 -8
- package/build-module/components/block-mover/index.mjs.map +2 -2
- package/build-module/components/iframe/get-compatibility-styles.mjs +1 -1
- package/build-module/components/iframe/get-compatibility-styles.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/hooks.mjs +1 -1
- package/build-module/components/inserter/media-tab/hooks.mjs.map +2 -2
- package/build-module/components/link-control/search-input.mjs +1 -1
- package/build-module/components/link-control/search-input.mjs.map +2 -2
- package/build-module/components/link-picker/link-preview.mjs +2 -1
- package/build-module/components/link-picker/link-preview.mjs.map +2 -2
- package/build-module/components/rich-text/index.mjs +2 -2
- package/build-module/components/rich-text/index.mjs.map +2 -2
- package/build-module/components/rich-text/input-event.mjs +2 -2
- package/build-module/components/rich-text/input-event.mjs.map +2 -2
- package/build-module/components/use-on-block-drop/index.mjs +1 -1
- package/build-module/components/use-on-block-drop/index.mjs.map +2 -2
- package/build-module/components/use-paste-styles/index.mjs +2 -2
- package/build-module/components/use-paste-styles/index.mjs.map +2 -2
- package/build-module/hooks/block-style-variation.mjs +4 -5
- package/build-module/hooks/block-style-variation.mjs.map +2 -2
- package/build-module/hooks/index.mjs +2 -2
- package/build-module/hooks/index.mjs.map +2 -2
- package/build-module/private-apis.mjs +2 -2
- package/build-module/private-apis.mjs.map +1 -1
- package/build-module/store/actions.mjs +0 -8
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/reducer.mjs +52 -53
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs +12 -13
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/store/utils.mjs +1 -1
- package/build-module/store/utils.mjs.map +2 -2
- package/build-module/utils/pasting.mjs +1 -1
- package/build-module/utils/pasting.mjs.map +2 -2
- package/build-style/style-rtl.css +0 -7
- package/build-style/style.css +0 -7
- package/package.json +38 -39
- package/src/autocompleters/style.scss +0 -8
- package/src/components/autocomplete/index.js +1 -2
- package/src/components/block-draggable/test/helpers.native.js +1 -1
- package/src/components/block-list/block-crash-warning.js +3 -1
- package/src/components/block-list/block-crash-warning.native.js +3 -1
- package/src/components/block-list/block-html.js +13 -3
- package/src/components/block-mover/button.js +7 -4
- package/src/components/block-mover/index.js +1 -8
- package/src/components/iframe/get-compatibility-styles.js +1 -1
- package/src/components/inserter/media-tab/hooks.js +1 -1
- package/src/components/link-control/README.md +2 -2
- package/src/components/link-control/search-input.js +1 -1
- package/src/components/link-picker/link-preview.js +2 -1
- package/src/components/rich-text/index.js +1 -1
- package/src/components/rich-text/index.native.js +1 -1
- package/src/components/rich-text/input-event.js +1 -1
- package/src/components/rich-text/input-event.native.js +1 -1
- package/src/components/rich-text/native/index.native.js +18 -17
- package/src/components/use-on-block-drop/index.js +1 -1
- package/src/components/use-paste-styles/index.js +2 -2
- package/src/hooks/block-style-variation.js +3 -4
- package/src/hooks/index.js +1 -1
- package/src/private-apis.js +2 -2
- package/src/store/actions.js +0 -8
- package/src/store/reducer.js +62 -67
- package/src/store/selectors.js +31 -21
- package/src/store/test/private-selectors.js +44 -41
- package/src/store/test/reducer.js +159 -88
- package/src/store/test/registry-selectors.js +1 -1
- package/src/store/test/selectors.js +265 -200
- package/src/store/utils.js +1 -1
- package/src/utils/pasting.js +1 -1
- package/build/autocompleters/link.cjs +0 -81
- package/build/autocompleters/link.cjs.map +0 -7
- package/build-module/autocompleters/link.mjs +0 -50
- package/build-module/autocompleters/link.mjs.map +0 -7
- package/src/autocompleters/link.js +0 -63
|
@@ -40,13 +40,12 @@ var import_element = require("@wordpress/element");
|
|
|
40
40
|
var import_blocks = require("@wordpress/blocks");
|
|
41
41
|
var import_context = require("../block-edit/context.cjs");
|
|
42
42
|
var import_block = __toESM(require("../../autocompleters/block.cjs"));
|
|
43
|
-
var import_link = __toESM(require("../../autocompleters/link.cjs"));
|
|
44
43
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
45
44
|
var EMPTY_ARRAY = [];
|
|
46
45
|
function useCompleters({ completers = EMPTY_ARRAY }) {
|
|
47
46
|
const { name } = (0, import_context.useBlockEditContext)();
|
|
48
47
|
return (0, import_element.useMemo)(() => {
|
|
49
|
-
let filteredCompleters = [...completers
|
|
48
|
+
let filteredCompleters = [...completers];
|
|
50
49
|
if (name === (0, import_blocks.getDefaultBlockName)() || (0, import_blocks.getBlockSupport)(name, "__experimentalSlashInserter", false)) {
|
|
51
50
|
filteredCompleters = [...filteredCompleters, import_block.default];
|
|
52
51
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/autocomplete/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { applyFilters, hasFilter } from '@wordpress/hooks';\nimport {\n\tAutocomplete,\n\t__unstableUseAutocompleteProps as useAutocompleteProps,\n} from '@wordpress/components';\nimport { useMemo } from '@wordpress/element';\nimport { getDefaultBlockName, getBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit/context';\nimport blockAutocompleter from '../../autocompleters/block';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAwC;AACxC,wBAGO;AACP,qBAAwB;AACxB,oBAAqD;AAKrD,qBAAoC;AACpC,mBAA+B;
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { applyFilters, hasFilter } from '@wordpress/hooks';\nimport {\n\tAutocomplete,\n\t__unstableUseAutocompleteProps as useAutocompleteProps,\n} from '@wordpress/components';\nimport { useMemo } from '@wordpress/element';\nimport { getDefaultBlockName, getBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit/context';\nimport blockAutocompleter from '../../autocompleters/block';\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation.\n *\n * @type {Array}\n */\nconst EMPTY_ARRAY = [];\n\nfunction useCompleters( { completers = EMPTY_ARRAY } ) {\n\tconst { name } = useBlockEditContext();\n\treturn useMemo( () => {\n\t\tlet filteredCompleters = [ ...completers ];\n\n\t\tif (\n\t\t\tname === getDefaultBlockName() ||\n\t\t\tgetBlockSupport( name, '__experimentalSlashInserter', false )\n\t\t) {\n\t\t\tfilteredCompleters = [ ...filteredCompleters, blockAutocompleter ];\n\t\t}\n\n\t\tif ( hasFilter( 'editor.Autocomplete.completers' ) ) {\n\t\t\t// Provide copies so filters may directly modify them.\n\t\t\tif ( filteredCompleters === completers ) {\n\t\t\t\tfilteredCompleters = filteredCompleters.map(\n\t\t\t\t\t( completer ) => ( { ...completer } )\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tfilteredCompleters = applyFilters(\n\t\t\t\t'editor.Autocomplete.completers',\n\t\t\t\tfilteredCompleters,\n\t\t\t\tname\n\t\t\t);\n\t\t}\n\n\t\treturn filteredCompleters;\n\t}, [ completers, name ] );\n}\n\nexport function useBlockEditorAutocompleteProps( props ) {\n\treturn useAutocompleteProps( {\n\t\t...props,\n\t\tcompleters: useCompleters( props ),\n\t} );\n}\n\n/**\n * Wrap the default Autocomplete component with one that supports a filter hook\n * for customizing its list of autocompleters.\n *\n * @type {React.FC}\n */\nfunction BlockEditorAutocomplete( props ) {\n\treturn <Autocomplete { ...props } completers={ useCompleters( props ) } />;\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/autocomplete/README.md\n */\nexport default BlockEditorAutocomplete;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAwC;AACxC,wBAGO;AACP,qBAAwB;AACxB,oBAAqD;AAKrD,qBAAoC;AACpC,mBAA+B;AAuDvB;AA/CR,IAAM,cAAc,CAAC;AAErB,SAAS,cAAe,EAAE,aAAa,YAAY,GAAI;AACtD,QAAM,EAAE,KAAK,QAAI,oCAAoB;AACrC,aAAO,wBAAS,MAAM;AACrB,QAAI,qBAAqB,CAAE,GAAG,UAAW;AAEzC,QACC,aAAS,mCAAoB,SAC7B,+BAAiB,MAAM,+BAA+B,KAAM,GAC3D;AACD,2BAAqB,CAAE,GAAG,oBAAoB,aAAAA,OAAmB;AAAA,IAClE;AAEA,YAAK,wBAAW,gCAAiC,GAAI;AAEpD,UAAK,uBAAuB,YAAa;AACxC,6BAAqB,mBAAmB;AAAA,UACvC,CAAE,eAAiB,EAAE,GAAG,UAAU;AAAA,QACnC;AAAA,MACD;AAEA,+BAAqB;AAAA,QACpB;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAEA,WAAO;AAAA,EACR,GAAG,CAAE,YAAY,IAAK,CAAE;AACzB;AAEO,SAAS,gCAAiC,OAAQ;AACxD,aAAO,kBAAAC,gCAAsB;AAAA,IAC5B,GAAG;AAAA,IACH,YAAY,cAAe,KAAM;AAAA,EAClC,CAAE;AACH;AAQA,SAAS,wBAAyB,OAAQ;AACzC,SAAO,4CAAC,kCAAe,GAAG,OAAQ,YAAa,cAAe,KAAM,GAAI;AACzE;AAKA,IAAO,uBAAQ;",
|
|
6
|
+
"names": ["blockAutocompleter", "useAutocompleteProps"]
|
|
7
7
|
}
|
|
@@ -30,12 +30,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// packages/block-editor/src/components/block-list/block-crash-warning.js
|
|
31
31
|
var block_crash_warning_exports = {};
|
|
32
32
|
__export(block_crash_warning_exports, {
|
|
33
|
-
default: () =>
|
|
33
|
+
default: () => BlockCrashWarning
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(block_crash_warning_exports);
|
|
36
36
|
var import_i18n = require("@wordpress/i18n");
|
|
37
37
|
var import_warning = __toESM(require("../warning/index.cjs"));
|
|
38
38
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
39
39
|
var warning = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_warning.default, { className: "block-editor-block-list__block-crash-warning", children: (0, import_i18n.__)("This block has encountered an error and cannot be previewed.") });
|
|
40
|
-
|
|
40
|
+
function BlockCrashWarning() {
|
|
41
|
+
return warning;
|
|
42
|
+
}
|
|
41
43
|
//# sourceMappingURL=block-crash-warning.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-list/block-crash-warning.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport Warning from '../warning';\n\nconst warning = (\n\t<Warning className=\"block-editor-block-list__block-crash-warning\">\n\t\t{ __( 'This block has encountered an error and cannot be previewed.' ) }\n\t</Warning>\n);\n\nexport default ()
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AAKnB,qBAAoB;AAGnB;AADD,IAAM,UACL,4CAAC,eAAAA,SAAA,EAAQ,WAAU,gDAChB,8BAAI,8DAA+D,GACtE;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport Warning from '../warning';\n\nconst warning = (\n\t<Warning className=\"block-editor-block-list__block-crash-warning\">\n\t\t{ __( 'This block has encountered an error and cannot be previewed.' ) }\n\t</Warning>\n);\n\nexport default function BlockCrashWarning() {\n\treturn warning;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AAKnB,qBAAoB;AAGnB;AADD,IAAM,UACL,4CAAC,eAAAA,SAAA,EAAQ,WAAU,gDAChB,8BAAI,8DAA+D,GACtE;AAGc,SAAR,oBAAqC;AAC3C,SAAO;AACR;",
|
|
6
6
|
"names": ["Warning"]
|
|
7
7
|
}
|
|
@@ -46,6 +46,10 @@ function BlockHTML({ clientId }) {
|
|
|
46
46
|
[clientId]
|
|
47
47
|
);
|
|
48
48
|
const { updateBlock } = (0, import_data.useDispatch)(import_store.store);
|
|
49
|
+
const blockContent = (0, import_element.useMemo)(
|
|
50
|
+
() => block ? (0, import_blocks.getBlockContent)(block) : "",
|
|
51
|
+
[block]
|
|
52
|
+
);
|
|
49
53
|
const onChange = () => {
|
|
50
54
|
const blockType = (0, import_blocks.getBlockType)(block.name);
|
|
51
55
|
if (!blockType) {
|
|
@@ -72,8 +76,8 @@ function BlockHTML({ clientId }) {
|
|
|
72
76
|
}
|
|
73
77
|
};
|
|
74
78
|
(0, import_element.useEffect)(() => {
|
|
75
|
-
setHtml(
|
|
76
|
-
}, [
|
|
79
|
+
setHtml(blockContent);
|
|
80
|
+
}, [blockContent]);
|
|
77
81
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
78
82
|
import_react_autosize_textarea.default,
|
|
79
83
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-list/block-html.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport TextareaAutosize from 'react-autosize-textarea';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useState } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tgetBlockAttributes,\n\tgetBlockContent,\n\tgetBlockType,\n\tgetSaveContent,\n\tvalidateBlock,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nfunction BlockHTML( { clientId } ) {\n\tconst [ html, setHtml ] = useState( '' );\n\tconst block = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlock( clientId ),\n\t\t[ clientId ]\n\t);\n\tconst { updateBlock } = useDispatch( blockEditorStore );\n\tconst onChange = () => {\n\t\tconst blockType = getBlockType( block.name );\n\n\t\tif ( ! blockType ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst attributes = getBlockAttributes(\n\t\t\tblockType,\n\t\t\thtml,\n\t\t\tblock.attributes\n\t\t);\n\n\t\t// If html is empty we reset the block to the default HTML and mark it as valid to avoid triggering an error\n\t\tconst content = html ? html : getSaveContent( blockType, attributes );\n\t\tconst [ isValid ] = html\n\t\t\t? validateBlock( {\n\t\t\t\t\t...block,\n\t\t\t\t\tattributes,\n\t\t\t\t\toriginalContent: content,\n\t\t\t } )\n\t\t\t: [ true ];\n\n\t\tupdateBlock( clientId, {\n\t\t\tattributes,\n\t\t\toriginalContent: content,\n\t\t\tisValid,\n\t\t} );\n\n\t\t// Ensure the state is updated if we reset so it displays the default content.\n\t\tif ( ! html ) {\n\t\t\tsetHtml( content );\n\t\t}\n\t};\n\n\tuseEffect( () => {\n\t\tsetHtml(
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qCAA6B;AAK7B,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport TextareaAutosize from 'react-autosize-textarea';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useMemo, useState } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tgetBlockAttributes,\n\tgetBlockContent,\n\tgetBlockType,\n\tgetSaveContent,\n\tvalidateBlock,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nfunction BlockHTML( { clientId } ) {\n\tconst [ html, setHtml ] = useState( '' );\n\tconst block = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlock( clientId ),\n\t\t[ clientId ]\n\t);\n\tconst { updateBlock } = useDispatch( blockEditorStore );\n\n\t// Derive block content as a primitive string so the effect only fires\n\t// when the serialized content genuinely changes, not when the block\n\t// object reference changes (which happens on every RESET_BLOCKS during\n\t// RTC sync, even for unchanged blocks).\n\tconst blockContent = useMemo(\n\t\t() => ( block ? getBlockContent( block ) : '' ),\n\t\t[ block ]\n\t);\n\n\tconst onChange = () => {\n\t\tconst blockType = getBlockType( block.name );\n\n\t\tif ( ! blockType ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst attributes = getBlockAttributes(\n\t\t\tblockType,\n\t\t\thtml,\n\t\t\tblock.attributes\n\t\t);\n\n\t\t// If html is empty we reset the block to the default HTML and mark it as valid to avoid triggering an error\n\t\tconst content = html ? html : getSaveContent( blockType, attributes );\n\t\tconst [ isValid ] = html\n\t\t\t? validateBlock( {\n\t\t\t\t\t...block,\n\t\t\t\t\tattributes,\n\t\t\t\t\toriginalContent: content,\n\t\t\t } )\n\t\t\t: [ true ];\n\n\t\tupdateBlock( clientId, {\n\t\t\tattributes,\n\t\t\toriginalContent: content,\n\t\t\tisValid,\n\t\t} );\n\n\t\t// Ensure the state is updated if we reset so it displays the default content.\n\t\tif ( ! html ) {\n\t\t\tsetHtml( content );\n\t\t}\n\t};\n\n\tuseEffect( () => {\n\t\tsetHtml( blockContent );\n\t}, [ blockContent ] );\n\n\treturn (\n\t\t<TextareaAutosize\n\t\t\tclassName=\"block-editor-block-list__block-html-textarea\"\n\t\t\tvalue={ html }\n\t\t\tonBlur={ on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MACA,WAAU;AAAA,MACV,OAAQ;AAAA,MACR,QAAS;AAAA,MACT,UAAW,CAAE,UAAW,QAAS,MAAM,OAAO,KAAM;AAAA;AAAA,EACrD;AAEF;AAEA,IAAO,qBAAQ;",
|
|
6
6
|
"names": ["blockEditorStore", "TextareaAutosize"]
|
|
7
7
|
}
|
|
@@ -41,6 +41,7 @@ var import_compose = require("@wordpress/compose");
|
|
|
41
41
|
var import_data = require("@wordpress/data");
|
|
42
42
|
var import_element = require("@wordpress/element");
|
|
43
43
|
var import_i18n = require("@wordpress/i18n");
|
|
44
|
+
var import_keycodes = require("@wordpress/keycodes");
|
|
44
45
|
var import_icons = require("@wordpress/icons");
|
|
45
46
|
var import_mover_description = require("./mover-description.cjs");
|
|
46
47
|
var import_store = require("../../store/index.cjs");
|
|
@@ -78,7 +79,6 @@ var BlockMoverButton = (0, import_element.forwardRef)(
|
|
|
78
79
|
const instanceId = (0, import_compose.useInstanceId)(BlockMoverButton);
|
|
79
80
|
const normalizedClientIds = Array.isArray(clientIds) ? clientIds : [clientIds];
|
|
80
81
|
const blocksCount = normalizedClientIds.length;
|
|
81
|
-
const { disabled } = props;
|
|
82
82
|
const {
|
|
83
83
|
blockType,
|
|
84
84
|
isDisabled,
|
|
@@ -109,7 +109,7 @@ var BlockMoverButton = (0, import_element.forwardRef)(
|
|
|
109
109
|
const { orientation: blockListOrientation } = getBlockListSettings(blockRootClientId) || {};
|
|
110
110
|
return {
|
|
111
111
|
blockType: block ? (0, import_blocks.getBlockType)(block.name) : null,
|
|
112
|
-
isDisabled:
|
|
112
|
+
isDisabled: direction === "up" ? isFirstBlock : isLastBlock,
|
|
113
113
|
rootClientId: blockRootClientId,
|
|
114
114
|
firstIndex: firstBlockIndex,
|
|
115
115
|
isFirst: isFirstBlock,
|
|
@@ -147,7 +147,8 @@ var BlockMoverButton = (0, import_element.forwardRef)(
|
|
|
147
147
|
...props,
|
|
148
148
|
onClick: isDisabled ? null : onClick,
|
|
149
149
|
disabled: isDisabled,
|
|
150
|
-
accessibleWhenDisabled: true
|
|
150
|
+
accessibleWhenDisabled: true,
|
|
151
|
+
shortcut: direction === "up" ? import_keycodes.displayShortcut.secondary("t") : import_keycodes.displayShortcut.secondary("y")
|
|
151
152
|
}
|
|
152
153
|
),
|
|
153
154
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.VisuallyHidden, { id: descriptionId, children: (0, import_mover_description.getBlockMoverDescription)(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-mover/button.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockType } from '@wordpress/blocks';\nimport { Button, VisuallyHidden } from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { forwardRef } from '@wordpress/element';\nimport { __, isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {\n\tchevronLeft,\n\tchevronRight,\n\tchevronUp,\n\tchevronDown,\n} from '@wordpress/icons';\nimport { getBlockMoverDescription } from './mover-description';\nimport { store as blockEditorStore } from '../../store';\n\nconst getArrowIcon = ( direction, orientation ) => {\n\tif ( direction === 'up' ) {\n\t\tif ( orientation === 'horizontal' ) {\n\t\t\treturn isRTL() ? chevronRight : chevronLeft;\n\t\t}\n\t\treturn chevronUp;\n\t} else if ( direction === 'down' ) {\n\t\tif ( orientation === 'horizontal' ) {\n\t\t\treturn isRTL() ? chevronLeft : chevronRight;\n\t\t}\n\t\treturn chevronDown;\n\t}\n\treturn null;\n};\n\nconst getMovementDirectionLabel = ( moveDirection, orientation ) => {\n\tif ( moveDirection === 'up' ) {\n\t\tif ( orientation === 'horizontal' ) {\n\t\t\treturn isRTL() ? __( 'Move right' ) : __( 'Move left' );\n\t\t}\n\t\treturn __( 'Move up' );\n\t} else if ( moveDirection === 'down' ) {\n\t\tif ( orientation === 'horizontal' ) {\n\t\t\treturn isRTL() ? __( 'Move left' ) : __( 'Move right' );\n\t\t}\n\t\treturn __( 'Move down' );\n\t}\n\treturn null;\n};\n\nconst BlockMoverButton = forwardRef(\n\t(\n\t\t{ clientIds, direction, orientation: moverOrientation, ...props },\n\t\tref\n\t) => {\n\t\tconst instanceId = useInstanceId( BlockMoverButton );\n\t\tconst normalizedClientIds = Array.isArray( clientIds )\n\t\t\t? clientIds\n\t\t\t: [ clientIds ];\n\t\tconst blocksCount = normalizedClientIds.length;\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,oBAA6B;AAC7B,wBAAuC;AACvC,qBAA8B;AAC9B,kBAAuC;AACvC,qBAA2B;AAC3B,kBAA0B;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockType } from '@wordpress/blocks';\nimport { Button, VisuallyHidden } from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { forwardRef } from '@wordpress/element';\nimport { __, isRTL } from '@wordpress/i18n';\nimport { displayShortcut } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport {\n\tchevronLeft,\n\tchevronRight,\n\tchevronUp,\n\tchevronDown,\n} from '@wordpress/icons';\nimport { getBlockMoverDescription } from './mover-description';\nimport { store as blockEditorStore } from '../../store';\n\nconst getArrowIcon = ( direction, orientation ) => {\n\tif ( direction === 'up' ) {\n\t\tif ( orientation === 'horizontal' ) {\n\t\t\treturn isRTL() ? chevronRight : chevronLeft;\n\t\t}\n\t\treturn chevronUp;\n\t} else if ( direction === 'down' ) {\n\t\tif ( orientation === 'horizontal' ) {\n\t\t\treturn isRTL() ? chevronLeft : chevronRight;\n\t\t}\n\t\treturn chevronDown;\n\t}\n\treturn null;\n};\n\nconst getMovementDirectionLabel = ( moveDirection, orientation ) => {\n\tif ( moveDirection === 'up' ) {\n\t\tif ( orientation === 'horizontal' ) {\n\t\t\treturn isRTL() ? __( 'Move right' ) : __( 'Move left' );\n\t\t}\n\t\treturn __( 'Move up' );\n\t} else if ( moveDirection === 'down' ) {\n\t\tif ( orientation === 'horizontal' ) {\n\t\t\treturn isRTL() ? __( 'Move left' ) : __( 'Move right' );\n\t\t}\n\t\treturn __( 'Move down' );\n\t}\n\treturn null;\n};\n\nconst BlockMoverButton = forwardRef(\n\t(\n\t\t{ clientIds, direction, orientation: moverOrientation, ...props },\n\t\tref\n\t) => {\n\t\tconst instanceId = useInstanceId( BlockMoverButton );\n\t\tconst normalizedClientIds = Array.isArray( clientIds )\n\t\t\t? clientIds\n\t\t\t: [ clientIds ];\n\t\tconst blocksCount = normalizedClientIds.length;\n\n\t\tconst {\n\t\t\tblockType,\n\t\t\tisDisabled,\n\t\t\trootClientId,\n\t\t\tisFirst,\n\t\t\tisLast,\n\t\t\tfirstIndex,\n\t\t\torientation = 'vertical',\n\t\t} = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetBlockIndex,\n\t\t\t\t\tgetBlockRootClientId,\n\t\t\t\t\tgetBlockOrder,\n\t\t\t\t\tgetBlock,\n\t\t\t\t\tgetBlockListSettings,\n\t\t\t\t} = select( blockEditorStore );\n\t\t\t\tconst firstClientId = normalizedClientIds[ 0 ];\n\t\t\t\tconst blockRootClientId = getBlockRootClientId( firstClientId );\n\t\t\t\tconst firstBlockIndex = getBlockIndex( firstClientId );\n\t\t\t\tconst lastBlockIndex = getBlockIndex(\n\t\t\t\t\tnormalizedClientIds[ normalizedClientIds.length - 1 ]\n\t\t\t\t);\n\t\t\t\tconst blockOrder = getBlockOrder( blockRootClientId );\n\t\t\t\tconst block = getBlock( firstClientId );\n\t\t\t\tconst isFirstBlock = firstBlockIndex === 0;\n\t\t\t\tconst isLastBlock = lastBlockIndex === blockOrder.length - 1;\n\t\t\t\tconst { orientation: blockListOrientation } =\n\t\t\t\t\tgetBlockListSettings( blockRootClientId ) || {};\n\n\t\t\t\treturn {\n\t\t\t\t\tblockType: block ? getBlockType( block.name ) : null,\n\t\t\t\t\tisDisabled: direction === 'up' ? isFirstBlock : isLastBlock,\n\t\t\t\t\trootClientId: blockRootClientId,\n\t\t\t\t\tfirstIndex: firstBlockIndex,\n\t\t\t\t\tisFirst: isFirstBlock,\n\t\t\t\t\tisLast: isLastBlock,\n\t\t\t\t\torientation: moverOrientation || blockListOrientation,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ clientIds, direction ]\n\t\t);\n\n\t\tconst { moveBlocksDown, moveBlocksUp } =\n\t\t\tuseDispatch( blockEditorStore );\n\t\tconst moverFunction =\n\t\t\tdirection === 'up' ? moveBlocksUp : moveBlocksDown;\n\n\t\tconst onClick = ( event ) => {\n\t\t\tmoverFunction( clientIds, rootClientId );\n\t\t\tif ( props.onClick ) {\n\t\t\t\tprops.onClick( event );\n\t\t\t}\n\t\t};\n\n\t\tconst descriptionId = `block-editor-block-mover-button__description-${ instanceId }`;\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tref={ ref }\n\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t'block-editor-block-mover-button',\n\t\t\t\t\t\t`is-${ direction }-button`\n\t\t\t\t\t) }\n\t\t\t\t\ticon={ getArrowIcon( direction, orientation ) }\n\t\t\t\t\tlabel={ getMovementDirectionLabel(\n\t\t\t\t\t\tdirection,\n\t\t\t\t\t\torientation\n\t\t\t\t\t) }\n\t\t\t\t\taria-describedby={ descriptionId }\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tonClick={ isDisabled ? null : onClick }\n\t\t\t\t\tdisabled={ isDisabled }\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\tshortcut={\n\t\t\t\t\t\tdirection === 'up'\n\t\t\t\t\t\t\t? displayShortcut.secondary( 't' )\n\t\t\t\t\t\t\t: displayShortcut.secondary( 'y' )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<VisuallyHidden id={ descriptionId }>\n\t\t\t\t\t{ getBlockMoverDescription(\n\t\t\t\t\t\tblocksCount,\n\t\t\t\t\t\tblockType && blockType.title,\n\t\t\t\t\t\tfirstIndex,\n\t\t\t\t\t\tisFirst,\n\t\t\t\t\t\tisLast,\n\t\t\t\t\t\tdirection === 'up' ? -1 : 1,\n\t\t\t\t\t\torientation\n\t\t\t\t\t) }\n\t\t\t\t</VisuallyHidden>\n\t\t\t</>\n\t\t);\n\t}\n);\n\nexport const BlockMoverUpButton = forwardRef( ( props, ref ) => {\n\treturn <BlockMoverButton direction=\"up\" ref={ ref } { ...props } />;\n} );\n\nexport const BlockMoverDownButton = forwardRef( ( props, ref ) => {\n\treturn <BlockMoverButton direction=\"down\" ref={ ref } { ...props } />;\n} );\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,oBAA6B;AAC7B,wBAAuC;AACvC,qBAA8B;AAC9B,kBAAuC;AACvC,qBAA2B;AAC3B,kBAA0B;AAC1B,sBAAgC;AAKhC,mBAKO;AACP,+BAAyC;AACzC,mBAA0C;AAqGvC;AAnGH,IAAM,eAAe,CAAE,WAAW,gBAAiB;AAClD,MAAK,cAAc,MAAO;AACzB,QAAK,gBAAgB,cAAe;AACnC,iBAAO,mBAAM,IAAI,4BAAe;AAAA,IACjC;AACA,WAAO;AAAA,EACR,WAAY,cAAc,QAAS;AAClC,QAAK,gBAAgB,cAAe;AACnC,iBAAO,mBAAM,IAAI,2BAAc;AAAA,IAChC;AACA,WAAO;AAAA,EACR;AACA,SAAO;AACR;AAEA,IAAM,4BAA4B,CAAE,eAAe,gBAAiB;AACnE,MAAK,kBAAkB,MAAO;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U,QAAO,KAAc,GAAG,OAAQ;AACpE,CAAE;",
|
|
6
6
|
"names": ["blockEditorStore", "clsx"]
|
|
7
7
|
}
|
|
@@ -42,12 +42,7 @@ var import_block_draggable = __toESM(require("../block-draggable/index.cjs"));
|
|
|
42
42
|
var import_button = require("./button.cjs");
|
|
43
43
|
var import_store = require("../../store/index.cjs");
|
|
44
44
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
45
|
-
function BlockMover({
|
|
46
|
-
clientIds,
|
|
47
|
-
hideDragHandle,
|
|
48
|
-
isBlockMoverUpButtonDisabled,
|
|
49
|
-
isBlockMoverDownButtonDisabled
|
|
50
|
-
}) {
|
|
45
|
+
function BlockMover({ clientIds, hideDragHandle }) {
|
|
51
46
|
const {
|
|
52
47
|
canMove,
|
|
53
48
|
rootClientId,
|
|
@@ -110,7 +105,6 @@ function BlockMover({
|
|
|
110
105
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.ToolbarItem, { children: (itemProps) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
111
106
|
import_button.BlockMoverUpButton,
|
|
112
107
|
{
|
|
113
|
-
disabled: isBlockMoverUpButtonDisabled,
|
|
114
108
|
clientIds,
|
|
115
109
|
...itemProps
|
|
116
110
|
}
|
|
@@ -118,7 +112,6 @@ function BlockMover({
|
|
|
118
112
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.ToolbarItem, { children: (itemProps) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
119
113
|
import_button.BlockMoverDownButton,
|
|
120
114
|
{
|
|
121
|
-
disabled: isBlockMoverDownButtonDisabled,
|
|
122
115
|
clientIds,
|
|
123
116
|
...itemProps
|
|
124
117
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-mover/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\n\nimport { dragHandle } from '@wordpress/icons';\nimport { ToolbarGroup, ToolbarItem, Button } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockDraggable from '../block-draggable';\nimport { BlockMoverUpButton, BlockMoverDownButton } from './button';\nimport { store as blockEditorStore } from '../../store';\n\nfunction BlockMover( {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAMjB,mBAA2B;AAC3B,wBAAkD;AAClD,kBAA0B;AAC1B,kBAAmB;AAKnB,6BAA2B;AAC3B,oBAAyD;AACzD,mBAA0C;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\n\nimport { dragHandle } from '@wordpress/icons';\nimport { ToolbarGroup, ToolbarItem, Button } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockDraggable from '../block-draggable';\nimport { BlockMoverUpButton, BlockMoverDownButton } from './button';\nimport { store as blockEditorStore } from '../../store';\n\nfunction BlockMover( { clientIds, hideDragHandle } ) {\n\tconst {\n\t\tcanMove,\n\t\trootClientId,\n\t\tisFirst,\n\t\tisLast,\n\t\torientation,\n\t\tisManualGrid,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockIndex,\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tcanMoveBlocks,\n\t\t\t\tgetBlockOrder,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockAttributes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst normalizedClientIds = Array.isArray( clientIds )\n\t\t\t\t? clientIds\n\t\t\t\t: [ clientIds ];\n\t\t\tconst firstClientId = normalizedClientIds[ 0 ];\n\t\t\tconst _rootClientId = getBlockRootClientId( firstClientId );\n\t\t\tconst firstIndex = getBlockIndex( firstClientId );\n\t\t\tconst lastIndex = getBlockIndex(\n\t\t\t\tnormalizedClientIds[ normalizedClientIds.length - 1 ]\n\t\t\t);\n\t\t\tconst blockOrder = getBlockOrder( _rootClientId );\n\t\t\tconst { layout = {} } = getBlockAttributes( _rootClientId ) ?? {};\n\n\t\t\treturn {\n\t\t\t\tcanMove: canMoveBlocks( clientIds ),\n\t\t\t\trootClientId: _rootClientId,\n\t\t\t\tisFirst: firstIndex === 0,\n\t\t\t\tisLast: lastIndex === blockOrder.length - 1,\n\t\t\t\torientation: getBlockListSettings( _rootClientId )?.orientation,\n\t\t\t\tisManualGrid:\n\t\t\t\t\tlayout.type === 'grid' &&\n\t\t\t\t\tlayout.isManualPlacement &&\n\t\t\t\t\twindow.__experimentalEnableGridInteractivity,\n\t\t\t};\n\t\t},\n\t\t[ clientIds ]\n\t);\n\n\tif (\n\t\t! canMove ||\n\t\t( isFirst && isLast && ! rootClientId ) ||\n\t\t( hideDragHandle && isManualGrid )\n\t) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ToolbarGroup\n\t\t\tclassName={ clsx( 'block-editor-block-mover', {\n\t\t\t\t'is-horizontal': orientation === 'horizontal',\n\t\t\t} ) }\n\t\t>\n\t\t\t{ ! hideDragHandle && (\n\t\t\t\t<BlockDraggable clientIds={ clientIds } fadeWhenDisabled>\n\t\t\t\t\t{ ( draggableProps ) => (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\ticon={ dragHandle }\n\t\t\t\t\t\t\tclassName=\"block-editor-block-mover__drag-handle\"\n\t\t\t\t\t\t\tlabel={ __( 'Drag' ) }\n\t\t\t\t\t\t\t// Should not be able to tab to drag handle as this\n\t\t\t\t\t\t\t// button can only be used with a pointer device.\n\t\t\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t\t\t\t{ ...draggableProps }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</BlockDraggable>\n\t\t\t) }\n\t\t\t{ ! isManualGrid && (\n\t\t\t\t<div className=\"block-editor-block-mover__move-button-container\">\n\t\t\t\t\t<ToolbarItem>\n\t\t\t\t\t\t{ ( itemProps ) => (\n\t\t\t\t\t\t\t<BlockMoverUpButton\n\t\t\t\t\t\t\t\tclientIds={ clientIds }\n\t\t\t\t\t\t\t\t{ ...itemProps }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ToolbarItem>\n\t\t\t\t\t<ToolbarItem>\n\t\t\t\t\t\t{ ( itemProps ) => (\n\t\t\t\t\t\t\t<BlockMoverDownButton\n\t\t\t\t\t\t\t\tclientIds={ clientIds }\n\t\t\t\t\t\t\t\t{ ...itemProps }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ToolbarItem>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</ToolbarGroup>\n\t);\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-mover/README.md\n */\nexport default BlockMover;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAMjB,mBAA2B;AAC3B,wBAAkD;AAClD,kBAA0B;AAC1B,kBAAmB;AAKnB,6BAA2B;AAC3B,oBAAyD;AACzD,mBAA0C;AAgEpC;AA9DN,SAAS,WAAY,EAAE,WAAW,eAAe,GAAI;AACpD,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI;AAAA,IACH,CAAE,WAAY;AACb,YAAM;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD,IAAI,OAAQ,aAAAA,KAAiB;AAC7B,YAAM,sB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AAAA;AAAA,cACA;AAAA,cACE,GAAG;AAAA;AAAA,UACN,GAEF;AAAA,WACD;AAAA;AAAA;AAAA,EAEF;AAEF;AAKA,IAAO,sBAAQ;",
|
|
6
6
|
"names": ["blockEditorStore", "clsx", "BlockDraggable"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/iframe/get-compatibility-styles.js"],
|
|
4
|
-
"sourcesContent": ["let compatibilityStyles = null;\n\n/**\n * Returns a list of stylesheets that target the editor canvas. A stylesheet is\n * considered targeting 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 */\nexport function getCompatibilityStyles() {\n\tif ( compatibilityStyles ) {\n\t\treturn compatibilityStyles;\n\t}\n\n\t// Only memoize the result once on load, since these stylesheets should not\n\t// change.\n\tcompatibilityStyles = Array.from( document.styleSheets ).reduce(\n\t\t( accumulator, styleSheet ) => {\n\t\t\ttry {\n\t\t\t\t// May fail for external styles.\n\t\t\t\t// eslint-disable-next-line no-unused-expressions\n\t\t\t\tstyleSheet.cssRules;\n\t\t\t} catch
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAI,sBAAsB;AAUnB,SAAS,yBAAyB;AACxC,MAAK,qBAAsB;AAC1B,WAAO;AAAA,EACR;AAIA,wBAAsB,MAAM,KAAM,SAAS,WAAY,EAAE;AAAA,IACxD,CAAE,aAAa,eAAgB;AAC9B,UAAI;AAGH,mBAAW;AAAA,MACZ,
|
|
4
|
+
"sourcesContent": ["let compatibilityStyles = null;\n\n/**\n * Returns a list of stylesheets that target the editor canvas. A stylesheet is\n * considered targeting 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 */\nexport function getCompatibilityStyles() {\n\tif ( compatibilityStyles ) {\n\t\treturn compatibilityStyles;\n\t}\n\n\t// Only memoize the result once on load, since these stylesheets should not\n\t// change.\n\tcompatibilityStyles = Array.from( document.styleSheets ).reduce(\n\t\t( accumulator, styleSheet ) => {\n\t\t\ttry {\n\t\t\t\t// May fail for external styles.\n\t\t\t\t// eslint-disable-next-line no-unused-expressions\n\t\t\t\tstyleSheet.cssRules;\n\t\t\t} catch {\n\t\t\t\treturn accumulator;\n\t\t\t}\n\n\t\t\tconst { ownerNode, cssRules } = styleSheet;\n\n\t\t\t// Stylesheet is added by another stylesheet. See\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/StyleSheet/ownerNode#notes.\n\t\t\tif ( ownerNode === null ) {\n\t\t\t\treturn accumulator;\n\t\t\t}\n\n\t\t\tif ( ! cssRules ) {\n\t\t\t\treturn accumulator;\n\t\t\t}\n\n\t\t\t// Don't try to add core WP styles. We are responsible for adding\n\t\t\t// them. This compatibility layer is only meant to add styles added\n\t\t\t// by plugins or themes.\n\t\t\tif ( ownerNode.id.startsWith( 'wp-' ) ) {\n\t\t\t\treturn accumulator;\n\t\t\t}\n\n\t\t\t// Don't try to add styles without ID. Styles enqueued via the WP dependency system will always have IDs.\n\t\t\tif ( ! ownerNode.id ) {\n\t\t\t\treturn accumulator;\n\t\t\t}\n\n\t\t\tfunction matchFromRules( _cssRules ) {\n\t\t\t\treturn Array.from( _cssRules ).find(\n\t\t\t\t\t( {\n\t\t\t\t\t\tselectorText,\n\t\t\t\t\t\tconditionText,\n\t\t\t\t\t\tcssRules: __cssRules,\n\t\t\t\t\t} ) => {\n\t\t\t\t\t\t// If the rule is conditional then it will not have selector text.\n\t\t\t\t\t\t// Recurse into child CSS ruleset to determine selector eligibility.\n\t\t\t\t\t\tif ( conditionText ) {\n\t\t\t\t\t\t\treturn matchFromRules( __cssRules );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\tselectorText &&\n\t\t\t\t\t\t\t( selectorText.includes(\n\t\t\t\t\t\t\t\t'.editor-styles-wrapper'\n\t\t\t\t\t\t\t) ||\n\t\t\t\t\t\t\t\tselectorText.includes( '.wp-block' ) )\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif ( matchFromRules( cssRules ) ) {\n\t\t\t\tconst isInline = ownerNode.tagName === 'STYLE';\n\n\t\t\t\tif ( isInline ) {\n\t\t\t\t\t// If the current target is inline,\n\t\t\t\t\t// it could be a dependency of an existing stylesheet.\n\t\t\t\t\t// Look for that dependency and add it BEFORE the current target.\n\t\t\t\t\tconst mainStylesCssId = ownerNode.id.replace(\n\t\t\t\t\t\t'-inline-css',\n\t\t\t\t\t\t'-css'\n\t\t\t\t\t);\n\t\t\t\t\tconst mainStylesElement =\n\t\t\t\t\t\tdocument.getElementById( mainStylesCssId );\n\t\t\t\t\tif ( mainStylesElement ) {\n\t\t\t\t\t\taccumulator.push( mainStylesElement.cloneNode( true ) );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\taccumulator.push( ownerNode.cloneNode( true ) );\n\n\t\t\t\tif ( ! isInline ) {\n\t\t\t\t\t// If the current target is not inline,\n\t\t\t\t\t// we still look for inline styles that could be relevant for the current target.\n\t\t\t\t\t// If they exist, add them AFTER the current target.\n\t\t\t\t\tconst inlineStylesCssId = ownerNode.id.replace(\n\t\t\t\t\t\t'-css',\n\t\t\t\t\t\t'-inline-css'\n\t\t\t\t\t);\n\t\t\t\t\tconst inlineStylesElement =\n\t\t\t\t\t\tdocument.getElementById( inlineStylesCssId );\n\t\t\t\t\tif ( inlineStylesElement ) {\n\t\t\t\t\t\taccumulator.push(\n\t\t\t\t\t\t\tinlineStylesElement.cloneNode( true )\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn accumulator;\n\t\t},\n\t\t[]\n\t);\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gBAAM,oBAAoB,UAAU,GAAG;AAAA,YACtC;AAAA,YACA;AAAA,UACD;AACA,gBAAM,sBACL,SAAS,eAAgB,iBAAkB;AAC5C,cAAK,qBAAsB;AAC1B,wBAAY;AAAA,cACX,oBAAoB,UAAW,IAAK;AAAA,YACrC;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAEA,aAAO;AAAA,IACR;AAAA,IACA,CAAC;AAAA,EACF;AAEA,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/inserter/media-tab/hooks.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect, useState, useRef } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\n/** @typedef {import('../../../store/actions').InserterMediaRequest} InserterMediaRequest */\n/** @typedef {import('../../../store/actions').InserterMediaItem} InserterMediaItem */\n\n/**\n * Fetches media items based on the provided category.\n * Each media category is responsible for providing a `fetch` function.\n *\n * @param {Object} category The media category to fetch results for.\n * @param {InserterMediaRequest} query The query args to use for the request.\n * @return {InserterMediaItem[]} The media results.\n */\nexport function useMediaResults( category, query = {} ) {\n\tconst [ mediaList, setMediaList ] = useState();\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\t// We need to keep track of the last request made because\n\t// multiple request can be fired without knowing the order\n\t// of resolution, and we need to ensure we are showing\n\t// the results of the last request.\n\t// In the future we could use AbortController to cancel previous\n\t// requests, but we don't for now as it involves adding support\n\t// for this to `core-data` package.\n\tconst lastRequestRef = useRef();\n\tuseEffect( () => {\n\t\t( async () => {\n\t\t\tconst key = JSON.stringify( {\n\t\t\t\tcategory: category.name,\n\t\t\t\t...query,\n\t\t\t} );\n\t\t\tlastRequestRef.current = key;\n\t\t\tsetIsLoading( true );\n\t\t\tsetMediaList( [] ); // Empty the previous results.\n\t\t\tconst _media = await category.fetch?.( query );\n\t\t\tif ( key === lastRequestRef.current ) {\n\t\t\t\tsetMediaList( _media );\n\t\t\t\tsetIsLoading( false );\n\t\t\t}\n\t\t} )();\n\t}, [ category.name, ...Object.values( query ) ] );\n\treturn { mediaList, isLoading };\n}\n\nexport function useMediaCategories( rootClientId ) {\n\tconst [ categories, setCategories ] = useState( [] );\n\n\tconst inserterMediaCategories = useSelect(\n\t\t( select ) =>\n\t\t\tunlock( select( blockEditorStore ) ).getInserterMediaCategories(),\n\t\t[]\n\t);\n\tconst { canInsertImage, canInsertVideo, canInsertAudio } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canInsertBlockType } = select( blockEditorStore );\n\t\t\treturn {\n\t\t\t\tcanInsertImage: canInsertBlockType(\n\t\t\t\t\t'core/image',\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t\tcanInsertVideo: canInsertBlockType(\n\t\t\t\t\t'core/video',\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t\tcanInsertAudio: canInsertBlockType(\n\t\t\t\t\t'core/audio',\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\tuseEffect( () => {\n\t\t( async () => {\n\t\t\tconst _categories = [];\n\t\t\t// If `inserterMediaCategories` is not defined in\n\t\t\t// block editor settings, do not show any media categories.\n\t\t\tif ( ! inserterMediaCategories ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Loop through categories to check if they have at least one media item.\n\t\t\tconst categoriesHaveMedia = new Map(\n\t\t\t\tawait Promise.all(\n\t\t\t\t\tinserterMediaCategories.map( async ( category ) => {\n\t\t\t\t\t\t// Some sources are external and we don't need to make a request.\n\t\t\t\t\t\tif ( category.isExternalResource ) {\n\t\t\t\t\t\t\treturn [ category.name, true ];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlet results = [];\n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AAgB;AAAA,UACf;AAAA,UACA;AAAA,QACD;AAAA,QACA,gBAAgB;AAAA,UACf;AAAA,UACA;AAAA,QACD;AAAA,QACA,gBAAgB;AAAA,UACf;AAAA,UACA;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAE,YAAa;AAAA,EAChB;AACA,gCAAW,MAAM;AAChB,KAAE,YAAY;AACb,YAAM,cAAc,CAAC;AAGrB,UAAK,CAAE,yBAA0B;AAChC;AAAA,MACD;AAEA,YAAM,sBAAsB,IAAI;AAAA,QAC/B,MAAM,QAAQ;AAAA,UACb,wBAAwB,IAAK,OAAQ,aAAc;AAElD,gBAAK,SAAS,oBAAqB;AAClC,qBAAO,CAAE,SAAS,MAAM,IAAK;AAAA,YAC9B;AACA,gBAAI,UAAU,CAAC;AACf,gBAAI;AACH,wBAAU,MAAM,SAAS,MAAO;AAAA,gBAC/B,UAAU;AAAA,cACX,CAAE;AAAA,YACH,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect, useState, useRef } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\n/** @typedef {import('../../../store/actions').InserterMediaRequest} InserterMediaRequest */\n/** @typedef {import('../../../store/actions').InserterMediaItem} InserterMediaItem */\n\n/**\n * Fetches media items based on the provided category.\n * Each media category is responsible for providing a `fetch` function.\n *\n * @param {Object} category The media category to fetch results for.\n * @param {InserterMediaRequest} query The query args to use for the request.\n * @return {InserterMediaItem[]} The media results.\n */\nexport function useMediaResults( category, query = {} ) {\n\tconst [ mediaList, setMediaList ] = useState();\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\t// We need to keep track of the last request made because\n\t// multiple request can be fired without knowing the order\n\t// of resolution, and we need to ensure we are showing\n\t// the results of the last request.\n\t// In the future we could use AbortController to cancel previous\n\t// requests, but we don't for now as it involves adding support\n\t// for this to `core-data` package.\n\tconst lastRequestRef = useRef();\n\tuseEffect( () => {\n\t\t( async () => {\n\t\t\tconst key = JSON.stringify( {\n\t\t\t\tcategory: category.name,\n\t\t\t\t...query,\n\t\t\t} );\n\t\t\tlastRequestRef.current = key;\n\t\t\tsetIsLoading( true );\n\t\t\tsetMediaList( [] ); // Empty the previous results.\n\t\t\tconst _media = await category.fetch?.( query );\n\t\t\tif ( key === lastRequestRef.current ) {\n\t\t\t\tsetMediaList( _media );\n\t\t\t\tsetIsLoading( false );\n\t\t\t}\n\t\t} )();\n\t}, [ category.name, ...Object.values( query ) ] );\n\treturn { mediaList, isLoading };\n}\n\nexport function useMediaCategories( rootClientId ) {\n\tconst [ categories, setCategories ] = useState( [] );\n\n\tconst inserterMediaCategories = useSelect(\n\t\t( select ) =>\n\t\t\tunlock( select( blockEditorStore ) ).getInserterMediaCategories(),\n\t\t[]\n\t);\n\tconst { canInsertImage, canInsertVideo, canInsertAudio } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canInsertBlockType } = select( blockEditorStore );\n\t\t\treturn {\n\t\t\t\tcanInsertImage: canInsertBlockType(\n\t\t\t\t\t'core/image',\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t\tcanInsertVideo: canInsertBlockType(\n\t\t\t\t\t'core/video',\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t\tcanInsertAudio: canInsertBlockType(\n\t\t\t\t\t'core/audio',\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\tuseEffect( () => {\n\t\t( async () => {\n\t\t\tconst _categories = [];\n\t\t\t// If `inserterMediaCategories` is not defined in\n\t\t\t// block editor settings, do not show any media categories.\n\t\t\tif ( ! inserterMediaCategories ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Loop through categories to check if they have at least one media item.\n\t\t\tconst categoriesHaveMedia = new Map(\n\t\t\t\tawait Promise.all(\n\t\t\t\t\tinserterMediaCategories.map( async ( category ) => {\n\t\t\t\t\t\t// Some sources are external and we don't need to make a request.\n\t\t\t\t\t\tif ( category.isExternalResource ) {\n\t\t\t\t\t\t\treturn [ category.name, true ];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlet results = [];\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tresults = await category.fetch( {\n\t\t\t\t\t\t\t\tper_page: 1,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t// If the request fails, we shallow the error and just don't show\n\t\t\t\t\t\t\t// the category, in order to not break the media tab.\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn [ category.name, !! results.length ];\n\t\t\t\t\t} )\n\t\t\t\t)\n\t\t\t);\n\t\t\t// We need to filter out categories that don't have any media items or\n\t\t\t// whose corresponding block type is not allowed to be inserted, based\n\t\t\t// on the category's `mediaType`.\n\t\t\tconst canInsertMediaType = {\n\t\t\t\timage: canInsertImage,\n\t\t\t\tvideo: canInsertVideo,\n\t\t\t\taudio: canInsertAudio,\n\t\t\t};\n\t\t\tinserterMediaCategories.forEach( ( category ) => {\n\t\t\t\tif (\n\t\t\t\t\tcanInsertMediaType[ category.mediaType ] &&\n\t\t\t\t\tcategoriesHaveMedia.get( category.name )\n\t\t\t\t) {\n\t\t\t\t\t_categories.push( category );\n\t\t\t\t}\n\t\t\t} );\n\t\t\tif ( !! _categories.length ) {\n\t\t\t\tsetCategories( _categories );\n\t\t\t}\n\t\t} )();\n\t}, [\n\t\tcanInsertImage,\n\t\tcanInsertVideo,\n\t\tcanInsertAudio,\n\t\tinserterMediaCategories,\n\t] );\n\treturn categories;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA4C;AAC5C,kBAA0B;AAK1B,mBAA0C;AAC1C,yBAAuB;AAahB,SAAS,gBAAiB,UAAU,QAAQ,CAAC,GAAI;AACvD,QAAM,CAAE,WAAW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,QAC/B,MAAM,QAAQ;AAAA,UACb,wBAAwB,IAAK,OAAQ,aAAc;AAElD,gBAAK,SAAS,oBAAqB;AAClC,qBAAO,CAAE,SAAS,MAAM,IAAK;AAAA,YAC9B;AACA,gBAAI,UAAU,CAAC;AACf,gBAAI;AACH,wBAAU,MAAM,SAAS,MAAO;AAAA,gBAC/B,UAAU;AAAA,cACX,CAAE;AAAA,YACH,QAAQ;AAAA,YAGR;AACA,mBAAO,CAAE,SAAS,MAAM,CAAC,CAAE,QAAQ,MAAO;AAAA,UAC3C,CAAE;AAAA,QACH;AAAA,MACD;AAIA,YAAM,qBAAqB;AAAA,QAC1B,OAAO;AAAA,QACP,OAAO;AAAA,QACP,OAAO;AAAA,MACR;AACA,8BAAwB,QAAS,CAAE,aAAc;AAChD,YACC,mBAAoB,SAAS,SAAU,KACvC,oBAAoB,IAAK,SAAS,IAAK,GACtC;AACD,sBAAY,KAAM,QAAS;AAAA,QAC5B;AAAA,MACD,CAAE;AACF,UAAK,CAAC,CAAE,YAAY,QAAS;AAC5B,sBAAe,WAAY;AAAA,MAC5B;AAAA,IACD,GAAI;AAAA,EACL,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AACF,SAAO;AACR;",
|
|
6
6
|
"names": ["blockEditorStore"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/link-control/search-input.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { forwardRef, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { URLInput } from '../';\nimport LinkControlSearchResults from './search-results';\nimport { CREATE_TYPE } from './constants';\nimport useSearchHandler from './use-search-handler';\n\n// Must be a function as otherwise URLInput will default\n// to the fetchLinkSuggestions passed in block editor settings\n// which will cause an unintended http request.\nconst noopSearchHandler = () => Promise.resolve( [] );\n\nconst noop = () => {};\n\nconst LinkControlSearchInput = forwardRef(\n\t(\n\t\t{\n\t\t\tvalue,\n\t\t\tchildren,\n\t\t\tcurrentLink = {},\n\t\t\tclassName = null,\n\t\t\tplaceholder = null,\n\t\t\twithCreateSuggestion = false,\n\t\t\tonCreateSuggestion = noop,\n\t\t\tonChange = noop,\n\t\t\tonSelect = noop,\n\t\t\tshowSuggestions = true,\n\t\t\trenderSuggestions = ( props ) => (\n\t\t\t\t<LinkControlSearchResults { ...props } />\n\t\t\t),\n\t\t\tfetchSuggestions = null,\n\t\t\tallowDirectEntry = true,\n\t\t\tshowInitialSuggestions = false,\n\t\t\tsuggestionsQuery = {},\n\t\t\twithURLSuggestion = true,\n\t\t\tcreateSuggestionButtonText,\n\t\t\thideLabelFromVision = false,\n\t\t\tsuffix,\n\t\t\tisEntity = false,\n\t\t\tcustomValidity: customValidityProp,\n\t\t},\n\t\tref\n\t) => {\n\t\tconst genericSearchHandler = useSearchHandler(\n\t\t\tsuggestionsQuery,\n\t\t\tallowDirectEntry,\n\t\t\twithCreateSuggestion,\n\t\t\twithURLSuggestion\n\t\t);\n\n\t\tconst searchHandler = showSuggestions\n\t\t\t? fetchSuggestions || genericSearchHandler\n\t\t\t: noopSearchHandler;\n\n\t\tconst [ focusedSuggestion, setFocusedSuggestion ] = useState();\n\n\t\t/**\n\t\t * Handles the user moving between different suggestions. Does not handle\n\t\t * choosing an individual item.\n\t\t *\n\t\t * @param {string} selection the url of the selected suggestion.\n\t\t * @param {Object} suggestion the suggestion object.\n\t\t */\n\t\tconst onInputChange = ( selection, suggestion ) => {\n\t\t\tonChange( selection );\n\t\t\tsetFocusedSuggestion( suggestion );\n\t\t};\n\n\t\tconst handleRenderSuggestions = ( props ) =>\n\t\t\trenderSuggestions( {\n\t\t\t\t...props,\n\t\t\t\twithCreateSuggestion,\n\t\t\t\tcreateSuggestionButtonText,\n\t\t\t\tsuggestionsQuery,\n\t\t\t\thandleSuggestionClick: ( suggestion ) => {\n\t\t\t\t\tif ( props.handleSuggestionClick ) {\n\t\t\t\t\t\tprops.handleSuggestionClick( suggestion );\n\t\t\t\t\t}\n\t\t\t\t\tonSuggestionSelected( suggestion );\n\t\t\t\t},\n\t\t\t} );\n\n\t\tconst onSuggestionSelected = async ( selectedSuggestion ) => {\n\t\t\tlet suggestion = selectedSuggestion;\n\t\t\tif ( CREATE_TYPE === selectedSuggestion.type ) {\n\t\t\t\t// Create a new page and call onSelect with the output from the onCreateSuggestion callback.\n\t\t\t\ttry {\n\t\t\t\t\tsuggestion = await onCreateSuggestion(\n\t\t\t\t\t\tselectedSuggestion.title\n\t\t\t\t\t);\n\t\t\t\t\tif ( suggestion?.url ) {\n\t\t\t\t\t\tonSelect( suggestion );\n\t\t\t\t\t}\n\t\t\t\t} catch
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAqC;AACrC,kBAAmB;AACnB,wBAAuB;AAKvB,eAAyB;AACzB,4BAAqC;AACrC,uBAA4B;AAC5B,gCAA6B;AAuBzB;AAlBJ,IAAM,oBAAoB,MAAM,QAAQ,QAAS,CAAC,CAAE;AAEpD,IAAM,OAAO,MAAM;AAAC;AAEpB,IAAM,6BAAyB;AAAA,EAC9B,CACC;AAAA,IACC;AAAA,IACA;AAAA,IACA,cAAc,CAAC;AAAA,IACf,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,uBAAuB;AAAA,IACvB,qBAAqB;AAAA,IACrB,WAAW;AAAA,IACX,WAAW;AAAA,IACX,kBAAkB;AAAA,IAClB,oBAAoB,CAAE,UACrB,4CAAC,sBAAAA,SAAA,EAA2B,GAAG,OAAQ;AAAA,IAExC,mBAAmB;AAAA,IACnB,mBAAmB;AAAA,IACnB,yBAAyB;AAAA,IACzB,mBAAmB,CAAC;AAAA,IACpB,oBAAoB;AAAA,IACpB;AAAA,IACA,sBAAsB;AAAA,IACtB;AAAA,IACA,WAAW;AAAA,IACX,gBAAgB;AAAA,EACjB,GACA,QACI;AACJ,UAAM,2BAAuB,0BAAAC;AAAA,MAC5B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAEA,UAAM,gBAAgB,kBACnB,oBAAoB,uBACpB;AAEH,UAAM,CAAE,mBAAmB,oBAAqB,QAAI,yBAAS;AAS7D,UAAM,gBAAgB,CAAE,WAAW,eAAgB;AAClD,eAAU,SAAU;AACpB,2BAAsB,UAAW;AAAA,IAClC;AAEA,UAAM,0BAA0B,CAAE,UACjC,kBAAmB;AAAA,MAClB,GAAG;AAAA,MACH;AAAA,MACA;AAAA,MACA;AAAA,MACA,uBAAuB,CAAE,eAAgB;AACxC,YAAK,MAAM,uBAAwB;AAClC,gBAAM,sBAAuB,UAAW;AAAA,QACzC;AACA,6BAAsB,UAAW;AAAA,MAClC;AAAA,IACD,CAAE;AAEH,UAAM,uBAAuB,OAAQ,uBAAwB;AAC5D,UAAI,aAAa;AACjB,UAAK,iCAAgB,mBAAmB,MAAO;AAE9C,YAAI;AACH,uBAAa,MAAM;AAAA,YAClB,mBAAmB;AAAA,UACpB;AACA,cAAK,YAAY,KAAM;AACtB,qBAAU,UAAW;AAAA,UACtB;AAAA,QACD,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { forwardRef, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { URLInput } from '../';\nimport LinkControlSearchResults from './search-results';\nimport { CREATE_TYPE } from './constants';\nimport useSearchHandler from './use-search-handler';\n\n// Must be a function as otherwise URLInput will default\n// to the fetchLinkSuggestions passed in block editor settings\n// which will cause an unintended http request.\nconst noopSearchHandler = () => Promise.resolve( [] );\n\nconst noop = () => {};\n\nconst LinkControlSearchInput = forwardRef(\n\t(\n\t\t{\n\t\t\tvalue,\n\t\t\tchildren,\n\t\t\tcurrentLink = {},\n\t\t\tclassName = null,\n\t\t\tplaceholder = null,\n\t\t\twithCreateSuggestion = false,\n\t\t\tonCreateSuggestion = noop,\n\t\t\tonChange = noop,\n\t\t\tonSelect = noop,\n\t\t\tshowSuggestions = true,\n\t\t\trenderSuggestions = ( props ) => (\n\t\t\t\t<LinkControlSearchResults { ...props } />\n\t\t\t),\n\t\t\tfetchSuggestions = null,\n\t\t\tallowDirectEntry = true,\n\t\t\tshowInitialSuggestions = false,\n\t\t\tsuggestionsQuery = {},\n\t\t\twithURLSuggestion = true,\n\t\t\tcreateSuggestionButtonText,\n\t\t\thideLabelFromVision = false,\n\t\t\tsuffix,\n\t\t\tisEntity = false,\n\t\t\tcustomValidity: customValidityProp,\n\t\t},\n\t\tref\n\t) => {\n\t\tconst genericSearchHandler = useSearchHandler(\n\t\t\tsuggestionsQuery,\n\t\t\tallowDirectEntry,\n\t\t\twithCreateSuggestion,\n\t\t\twithURLSuggestion\n\t\t);\n\n\t\tconst searchHandler = showSuggestions\n\t\t\t? fetchSuggestions || genericSearchHandler\n\t\t\t: noopSearchHandler;\n\n\t\tconst [ focusedSuggestion, setFocusedSuggestion ] = useState();\n\n\t\t/**\n\t\t * Handles the user moving between different suggestions. Does not handle\n\t\t * choosing an individual item.\n\t\t *\n\t\t * @param {string} selection the url of the selected suggestion.\n\t\t * @param {Object} suggestion the suggestion object.\n\t\t */\n\t\tconst onInputChange = ( selection, suggestion ) => {\n\t\t\tonChange( selection );\n\t\t\tsetFocusedSuggestion( suggestion );\n\t\t};\n\n\t\tconst handleRenderSuggestions = ( props ) =>\n\t\t\trenderSuggestions( {\n\t\t\t\t...props,\n\t\t\t\twithCreateSuggestion,\n\t\t\t\tcreateSuggestionButtonText,\n\t\t\t\tsuggestionsQuery,\n\t\t\t\thandleSuggestionClick: ( suggestion ) => {\n\t\t\t\t\tif ( props.handleSuggestionClick ) {\n\t\t\t\t\t\tprops.handleSuggestionClick( suggestion );\n\t\t\t\t\t}\n\t\t\t\t\tonSuggestionSelected( suggestion );\n\t\t\t\t},\n\t\t\t} );\n\n\t\tconst onSuggestionSelected = async ( selectedSuggestion ) => {\n\t\t\tlet suggestion = selectedSuggestion;\n\t\t\tif ( CREATE_TYPE === selectedSuggestion.type ) {\n\t\t\t\t// Create a new page and call onSelect with the output from the onCreateSuggestion callback.\n\t\t\t\ttry {\n\t\t\t\t\tsuggestion = await onCreateSuggestion(\n\t\t\t\t\t\tselectedSuggestion.title\n\t\t\t\t\t);\n\t\t\t\t\tif ( suggestion?.url ) {\n\t\t\t\t\t\tonSelect( suggestion );\n\t\t\t\t\t}\n\t\t\t\t} catch {}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tallowDirectEntry ||\n\t\t\t\t( suggestion && Object.keys( suggestion ).length >= 1 )\n\t\t\t) {\n\t\t\t\t// Strip out id, url, kind, and type from the current link to prevent\n\t\t\t\t// entity metadata from persisting when switching to a different link type.\n\t\t\t\t// For example, when changing from an entity link (kind: 'post-type', type: 'page')\n\t\t\t\t// to a custom URL (type: 'link', no kind), we need to ensure the old 'kind'\n\t\t\t\t// doesn't carry over. We do want to preserve other properites like title, though.\n\t\t\t\tconst { id, url, kind, type, ...restLinkProps } =\n\t\t\t\t\tcurrentLink ?? {};\n\t\t\t\tonSelect(\n\t\t\t\t\t// Some direct entries don't have types or IDs, and we still need to clear the previous ones.\n\t\t\t\t\t{ ...restLinkProps, ...suggestion },\n\t\t\t\t\tsuggestion\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst _placeholder = placeholder ?? __( 'Search or type URL' );\n\n\t\tconst label =\n\t\t\thideLabelFromVision && placeholder !== ''\n\t\t\t\t? _placeholder\n\t\t\t\t: __( 'Link' );\n\n\t\treturn (\n\t\t\t<div className=\"block-editor-link-control__search-input-container\">\n\t\t\t\t<URLInput\n\t\t\t\t\tdisableSuggestions={ currentLink?.url === value }\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t\t\tclassName={ className }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onInputChange }\n\t\t\t\t\tplaceholder={ _placeholder }\n\t\t\t\t\t__experimentalRenderSuggestions={\n\t\t\t\t\t\tshowSuggestions ? handleRenderSuggestions : null\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalFetchLinkSuggestions={ searchHandler }\n\t\t\t\t\t__experimentalHandleURLSuggestions\n\t\t\t\t\t__experimentalShowInitialSuggestions={\n\t\t\t\t\t\tshowInitialSuggestions\n\t\t\t\t\t}\n\t\t\t\t\tcustomValidity={ customValidityProp }\n\t\t\t\t\t// Validation is handled manually via onSubmit and handleSubmit. We may be able to rely\n\t\t\t\t\t// on browser validation when enhancements land to base level components:\n\t\t\t\t\t// https://github.com/WordPress/gutenberg/pull/75188#issuecomment-3861757260\n\t\t\t\t\trequired={ false }\n\t\t\t\t\tonSubmit={ ( suggestion, event ) => {\n\t\t\t\t\t\tconst hasSuggestion = suggestion || focusedSuggestion;\n\n\t\t\t\t\t\t// If there is no suggestion and the value (ie: any manually entered URL) is empty\n\t\t\t\t\t\t// then don't allow submission otherwise we get empty links.\n\t\t\t\t\t\tif ( ! hasSuggestion && ! value?.trim()?.length ) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tonSuggestionSelected(\n\t\t\t\t\t\t\t\thasSuggestion || { url: value }\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tinputRef={ ref }\n\t\t\t\t\tsuffix={ suffix }\n\t\t\t\t\tdisabled={ isEntity }\n\t\t\t\t/>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t);\n\t}\n);\n\nexport default LinkControlSearchInput;\n\nexport const __experimentalLinkControlSearchInput = ( props ) => {\n\tdeprecated( 'wp.blockEditor.__experimentalLinkControlSearchInput', {\n\t\tsince: '6.8',\n\t} );\n\n\treturn <L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AAAA,UACX;AAAA,UACA,UAAW;AAAA;AAAA,MACZ;AAAA,MACE;AAAA,OACH;AAAA,EAEF;AACD;AAEA,IAAO,uBAAQ;AAER,IAAM,uCAAuC,CAAE,UAAW;AAChE,wBAAAC,SAAY,uDAAuD;AAAA,IAClE,OAAO;AAAA,EACR,CAAE;AAEF,SAAO,4CAAC,0BAAyB,GAAG,OAAQ;AAC7C;",
|
|
6
6
|
"names": ["LinkControlSearchResults", "useSearchHandler", "deprecated"]
|
|
7
7
|
}
|
|
@@ -25,6 +25,7 @@ __export(link_preview_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(link_preview_exports);
|
|
26
26
|
var import_components = require("@wordpress/components");
|
|
27
27
|
var import_icons = require("@wordpress/icons");
|
|
28
|
+
var import_dom = require("@wordpress/dom");
|
|
28
29
|
var import_lock_unlock = require("../../lock-unlock.cjs");
|
|
29
30
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
31
|
var { Badge } = (0, import_lock_unlock.unlock)(import_components.privateApis);
|
|
@@ -50,7 +51,7 @@ function LinkPreview({ title, url, image, badges }) {
|
|
|
50
51
|
{
|
|
51
52
|
numberOfLines: 1,
|
|
52
53
|
className: "link-preview-button__title",
|
|
53
|
-
children: title
|
|
54
|
+
children: (0, import_dom.__unstableStripHTML)(title)
|
|
54
55
|
}
|
|
55
56
|
),
|
|
56
57
|
url && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/link-picker/link-preview.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalTruncate as Truncate,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tFlexItem,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { Icon, chevronDown } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { Badge } = unlock( componentsPrivateApis );\n\n/**\n * Link preview component that displays the current link information.\n * This is a presentational component meant to be wrapped in a button.\n *\n * @param {Object} props - Component props\n * @param {string} props.title - Display title for the link\n * @param {string} props.url - Display URL for the link\n * @param {string} props.image - Optional image URL for the link preview\n * @param {Array<Object>} props.badges - Optional array of badge objects with label and intent\n */\nexport function LinkPreview( { title, url, image, badges } ) {\n\treturn (\n\t\t<HStack justify=\"space-between\" alignment=\"top\">\n\t\t\t<FlexItem className=\"link-preview-button__content\">\n\t\t\t\t<HStack alignment=\"top\">\n\t\t\t\t\t{ image && (\n\t\t\t\t\t\t<FlexItem className=\"link-preview-button__image-container\">\n\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\tclassName=\"link-preview-button__image\"\n\t\t\t\t\t\t\t\tsrc={ image }\n\t\t\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<VStack\n\t\t\t\t\t\tclassName=\"link-preview-button__details\"\n\t\t\t\t\t\talignment=\"topLeft\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<Truncate\n\t\t\t\t\t\t\tnumberOfLines={ 1 }\n\t\t\t\t\t\t\tclassName=\"link-preview-button__title\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t{ url && (\n\t\t\t\t\t\t\t<Truncate\n\t\t\t\t\t\t\t\tnumberOfLines={ 1 }\n\t\t\t\t\t\t\t\tclassName=\"link-preview-button__hint\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ url }\n\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ badges && badges.length > 0 && (\n\t\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\t\tclassName=\"link-preview-button__badges\"\n\t\t\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ badges.map( ( badge ) => (\n\t\t\t\t\t\t\t\t\t<Badge\n\t\t\t\t\t\t\t\t\t\tkey={ `${ badge.label }|${ badge.intent }` }\n\t\t\t\t\t\t\t\t\t\tintent={ badge.intent }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ badge.label }\n\t\t\t\t\t\t\t\t\t</Badge>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</VStack>\n\t\t\t\t</HStack>\n\t\t\t</FlexItem>\n\t\t\t<Icon icon={ chevronDown } className=\"link-preview-button__icon\" />\n\t\t</HStack>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAMO;AACP,mBAAkC;
|
|
6
|
-
"names": ["componentsPrivateApis", "HStack", "VStack", "Truncate"]
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalTruncate as Truncate,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tFlexItem,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { Icon, chevronDown } from '@wordpress/icons';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { Badge } = unlock( componentsPrivateApis );\n\n/**\n * Link preview component that displays the current link information.\n * This is a presentational component meant to be wrapped in a button.\n *\n * @param {Object} props - Component props\n * @param {string} props.title - Display title for the link\n * @param {string} props.url - Display URL for the link\n * @param {string} props.image - Optional image URL for the link preview\n * @param {Array<Object>} props.badges - Optional array of badge objects with label and intent\n */\nexport function LinkPreview( { title, url, image, badges } ) {\n\treturn (\n\t\t<HStack justify=\"space-between\" alignment=\"top\">\n\t\t\t<FlexItem className=\"link-preview-button__content\">\n\t\t\t\t<HStack alignment=\"top\">\n\t\t\t\t\t{ image && (\n\t\t\t\t\t\t<FlexItem className=\"link-preview-button__image-container\">\n\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\tclassName=\"link-preview-button__image\"\n\t\t\t\t\t\t\t\tsrc={ image }\n\t\t\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<VStack\n\t\t\t\t\t\tclassName=\"link-preview-button__details\"\n\t\t\t\t\t\talignment=\"topLeft\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<Truncate\n\t\t\t\t\t\t\tnumberOfLines={ 1 }\n\t\t\t\t\t\t\tclassName=\"link-preview-button__title\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ stripHTML( title ) }\n\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t{ url && (\n\t\t\t\t\t\t\t<Truncate\n\t\t\t\t\t\t\t\tnumberOfLines={ 1 }\n\t\t\t\t\t\t\t\tclassName=\"link-preview-button__hint\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ url }\n\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ badges && badges.length > 0 && (\n\t\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\t\tclassName=\"link-preview-button__badges\"\n\t\t\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ badges.map( ( badge ) => (\n\t\t\t\t\t\t\t\t\t<Badge\n\t\t\t\t\t\t\t\t\t\tkey={ `${ badge.label }|${ badge.intent }` }\n\t\t\t\t\t\t\t\t\t\tintent={ badge.intent }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ badge.label }\n\t\t\t\t\t\t\t\t\t</Badge>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t</HStack>\n\t\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AAM,KAAM,IAAK,MAAM,MAAO;AAAA,gBAIzC,CACC;AAAA;AAAA,YACH;AAAA;AAAA;AAAA,MAEF;AAAA,OACD,GACD;AAAA,IACA,4CAAC,qBAAK,MAAO,0BAAc,WAAU,6BAA4B;AAAA,KAClE;AAEF;",
|
|
6
|
+
"names": ["componentsPrivateApis", "HStack", "VStack", "Truncate", "stripHTML"]
|
|
7
7
|
}
|
|
@@ -34,7 +34,7 @@ __export(rich_text_exports, {
|
|
|
34
34
|
RichTextShortcut: () => import_shortcut.RichTextShortcut,
|
|
35
35
|
RichTextToolbarButton: () => import_toolbar_button.RichTextToolbarButton,
|
|
36
36
|
RichTextWrapper: () => RichTextWrapper,
|
|
37
|
-
__unstableRichTextInputEvent: () => import_input_event.
|
|
37
|
+
__unstableRichTextInputEvent: () => import_input_event.RichTextInputEvent,
|
|
38
38
|
default: () => rich_text_default,
|
|
39
39
|
inputEventContext: () => inputEventContext,
|
|
40
40
|
keyboardShortcutContext: () => keyboardShortcutContext
|