@wordpress/block-editor 15.16.0 → 15.17.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/CHANGELOG.md +2 -0
- 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/copy-handler/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/link-preview.cjs +3 -1
- package/build/components/link-control/link-preview.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/preset-input-control/index.cjs +7 -4
- package/build/components/preset-input-control/index.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/index.cjs.map +2 -2
- 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/spacing-sizes-control/utils.cjs +1 -1
- package/build/components/spacing-sizes-control/utils.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/components/writing-flow/use-selection-observer.cjs +23 -1
- package/build/components/writing-flow/use-selection-observer.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/hooks/style.cjs +54 -52
- package/build/hooks/style.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/copy-handler/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/link-preview.mjs +3 -1
- package/build-module/components/link-control/link-preview.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/preset-input-control/index.mjs +7 -4
- package/build-module/components/preset-input-control/index.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/index.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/spacing-sizes-control/utils.mjs +1 -1
- package/build-module/components/spacing-sizes-control/utils.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/components/writing-flow/use-selection-observer.mjs +23 -1
- package/build-module/components/writing-flow/use-selection-observer.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/hooks/style.mjs +54 -52
- package/build-module/hooks/style.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/copy-handler/index.js +1 -0
- 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/link-preview.js +3 -1
- package/src/components/link-control/search-input.js +1 -1
- package/src/components/link-picker/link-preview.js +2 -1
- package/src/components/preset-input-control/index.js +10 -4
- package/src/components/preset-input-control/test/index.js +70 -0
- package/src/components/rich-text/event-listeners/index.js +1 -0
- 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/spacing-sizes-control/utils.js +1 -1
- package/src/components/use-on-block-drop/index.js +1 -1
- package/src/components/use-paste-styles/index.js +2 -2
- package/src/components/writing-flow/use-selection-observer.js +39 -1
- package/src/hooks/block-style-variation.js +3 -4
- package/src/hooks/index.js +1 -1
- package/src/hooks/style.js +75 -61
- 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
package/src/store/utils.js
CHANGED
|
@@ -138,7 +138,7 @@ export const getAllPatternsDependants = ( select ) => ( state ) => {
|
|
|
138
138
|
|
|
139
139
|
export const getInsertBlockTypeDependants = () => ( state, rootClientId ) => {
|
|
140
140
|
return [
|
|
141
|
-
state.blockListSettings
|
|
141
|
+
state.blockListSettings.get( rootClientId ),
|
|
142
142
|
state.blocks.byClientId.get( rootClientId ),
|
|
143
143
|
state.blocks.order.get( rootClientId || '' ),
|
|
144
144
|
state.settings.allowedBlockTypes,
|
package/src/utils/pasting.js
CHANGED
|
@@ -55,7 +55,7 @@ export function getPasteEventData( { clipboardData } ) {
|
|
|
55
55
|
try {
|
|
56
56
|
plainText = clipboardData.getData( 'text/plain' );
|
|
57
57
|
html = clipboardData.getData( 'text/html' );
|
|
58
|
-
} catch
|
|
58
|
+
} catch {
|
|
59
59
|
// Some browsers like UC Browser paste plain text by default and
|
|
60
60
|
// don't support clipboardData at all, so allow default
|
|
61
61
|
// behaviour.
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// packages/block-editor/src/autocompleters/link.js
|
|
31
|
-
var link_exports = {};
|
|
32
|
-
__export(link_exports, {
|
|
33
|
-
default: () => link_default
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(link_exports);
|
|
36
|
-
var import_api_fetch = __toESM(require("@wordpress/api-fetch"));
|
|
37
|
-
var import_url = require("@wordpress/url");
|
|
38
|
-
var import_icons = require("@wordpress/icons");
|
|
39
|
-
var import_html_entities = require("@wordpress/html-entities");
|
|
40
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
41
|
-
var SHOWN_SUGGESTIONS = 10;
|
|
42
|
-
function createLinkCompleter() {
|
|
43
|
-
return {
|
|
44
|
-
name: "links",
|
|
45
|
-
className: "block-editor-autocompleters__link",
|
|
46
|
-
triggerPrefix: "[[",
|
|
47
|
-
options: async (letters) => {
|
|
48
|
-
let options = await (0, import_api_fetch.default)({
|
|
49
|
-
path: (0, import_url.addQueryArgs)("/wp/v2/search", {
|
|
50
|
-
per_page: SHOWN_SUGGESTIONS,
|
|
51
|
-
search: letters,
|
|
52
|
-
type: "post",
|
|
53
|
-
order_by: "menu_order"
|
|
54
|
-
})
|
|
55
|
-
});
|
|
56
|
-
options = options.filter((option) => option.title !== "");
|
|
57
|
-
return options;
|
|
58
|
-
},
|
|
59
|
-
getOptionKeywords(item) {
|
|
60
|
-
const expansionWords = item.title.split(/\s+/);
|
|
61
|
-
return [...expansionWords];
|
|
62
|
-
},
|
|
63
|
-
getOptionLabel(item) {
|
|
64
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
65
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
66
|
-
import_icons.Icon,
|
|
67
|
-
{
|
|
68
|
-
icon: item.subtype === "page" ? import_icons.page : import_icons.post
|
|
69
|
-
},
|
|
70
|
-
"icon"
|
|
71
|
-
),
|
|
72
|
-
(0, import_html_entities.decodeEntities)(item.title)
|
|
73
|
-
] });
|
|
74
|
-
},
|
|
75
|
-
getOptionCompletion(item) {
|
|
76
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href: item.url, children: item.title });
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
var link_default = createLinkCompleter();
|
|
81
|
-
//# sourceMappingURL=link.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/autocompleters/link.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\n// Disable Reason: Needs to be refactored.\n// eslint-disable-next-line no-restricted-imports\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\nimport { Icon, page, post } from '@wordpress/icons';\nimport { decodeEntities } from '@wordpress/html-entities';\n\nconst SHOWN_SUGGESTIONS = 10;\n\n/**\n * Creates a suggestion list for links to posts or pages.\n *\n * @return {Object} A links completer.\n */\nfunction createLinkCompleter() {\n\treturn {\n\t\tname: 'links',\n\t\tclassName: 'block-editor-autocompleters__link',\n\t\ttriggerPrefix: '[[',\n\t\toptions: async ( letters ) => {\n\t\t\tlet options = await apiFetch( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/search', {\n\t\t\t\t\tper_page: SHOWN_SUGGESTIONS,\n\t\t\t\t\tsearch: letters,\n\t\t\t\t\ttype: 'post',\n\t\t\t\t\torder_by: 'menu_order',\n\t\t\t\t} ),\n\t\t\t} );\n\n\t\t\toptions = options.filter( ( option ) => option.title !== '' );\n\n\t\t\treturn options;\n\t\t},\n\t\tgetOptionKeywords( item ) {\n\t\t\tconst expansionWords = item.title.split( /\\s+/ );\n\t\t\treturn [ ...expansionWords ];\n\t\t},\n\t\tgetOptionLabel( item ) {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tkey=\"icon\"\n\t\t\t\t\t\ticon={ item.subtype === 'page' ? page : post }\n\t\t\t\t\t/>\n\t\t\t\t\t{ decodeEntities( item.title ) }\n\t\t\t\t</>\n\t\t\t);\n\t\t},\n\t\tgetOptionCompletion( item ) {\n\t\t\treturn <a href={ item.url }>{ item.title }</a>;\n\t\t},\n\t};\n}\n\n/**\n * Creates a suggestion list for links to posts or pages..\n *\n * @return {Object} A link completer.\n */\nexport default createLinkCompleter();\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,uBAAqB;AACrB,iBAA6B;AAC7B,mBAAiC;AACjC,2BAA+B;AAkC3B;AAhCJ,IAAM,oBAAoB;AAO1B,SAAS,sBAAsB;AAC9B,SAAO;AAAA,IACN,MAAM;AAAA,IACN,WAAW;AAAA,IACX,eAAe;AAAA,IACf,SAAS,OAAQ,YAAa;AAC7B,UAAI,UAAU,UAAM,iBAAAA,SAAU;AAAA,QAC7B,UAAM,yBAAc,iBAAiB;AAAA,UACpC,UAAU;AAAA,UACV,QAAQ;AAAA,UACR,MAAM;AAAA,UACN,UAAU;AAAA,QACX,CAAE;AAAA,MACH,CAAE;AAEF,gBAAU,QAAQ,OAAQ,CAAE,WAAY,OAAO,UAAU,EAAG;AAE5D,aAAO;AAAA,IACR;AAAA,IACA,kBAAmB,MAAO;AACzB,YAAM,iBAAiB,KAAK,MAAM,MAAO,KAAM;AAC/C,aAAO,CAAE,GAAG,cAAe;AAAA,IAC5B;AAAA,IACA,eAAgB,MAAO;AACtB,aACC,4EACC;AAAA;AAAA,UAAC;AAAA;AAAA,YAEA,MAAO,KAAK,YAAY,SAAS,oBAAO;AAAA;AAAA,UADpC;AAAA,QAEL;AAAA,YACE,qCAAgB,KAAK,KAAM;AAAA,SAC9B;AAAA,IAEF;AAAA,IACA,oBAAqB,MAAO;AAC3B,aAAO,4CAAC,OAAE,MAAO,KAAK,KAAQ,eAAK,OAAO;AAAA,IAC3C;AAAA,EACD;AACD;AAOA,IAAO,eAAQ,oBAAoB;",
|
|
6
|
-
"names": ["apiFetch"]
|
|
7
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// packages/block-editor/src/autocompleters/link.js
|
|
2
|
-
import apiFetch from "@wordpress/api-fetch";
|
|
3
|
-
import { addQueryArgs } from "@wordpress/url";
|
|
4
|
-
import { Icon, page, post } from "@wordpress/icons";
|
|
5
|
-
import { decodeEntities } from "@wordpress/html-entities";
|
|
6
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
var SHOWN_SUGGESTIONS = 10;
|
|
8
|
-
function createLinkCompleter() {
|
|
9
|
-
return {
|
|
10
|
-
name: "links",
|
|
11
|
-
className: "block-editor-autocompleters__link",
|
|
12
|
-
triggerPrefix: "[[",
|
|
13
|
-
options: async (letters) => {
|
|
14
|
-
let options = await apiFetch({
|
|
15
|
-
path: addQueryArgs("/wp/v2/search", {
|
|
16
|
-
per_page: SHOWN_SUGGESTIONS,
|
|
17
|
-
search: letters,
|
|
18
|
-
type: "post",
|
|
19
|
-
order_by: "menu_order"
|
|
20
|
-
})
|
|
21
|
-
});
|
|
22
|
-
options = options.filter((option) => option.title !== "");
|
|
23
|
-
return options;
|
|
24
|
-
},
|
|
25
|
-
getOptionKeywords(item) {
|
|
26
|
-
const expansionWords = item.title.split(/\s+/);
|
|
27
|
-
return [...expansionWords];
|
|
28
|
-
},
|
|
29
|
-
getOptionLabel(item) {
|
|
30
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
31
|
-
/* @__PURE__ */ jsx(
|
|
32
|
-
Icon,
|
|
33
|
-
{
|
|
34
|
-
icon: item.subtype === "page" ? page : post
|
|
35
|
-
},
|
|
36
|
-
"icon"
|
|
37
|
-
),
|
|
38
|
-
decodeEntities(item.title)
|
|
39
|
-
] });
|
|
40
|
-
},
|
|
41
|
-
getOptionCompletion(item) {
|
|
42
|
-
return /* @__PURE__ */ jsx("a", { href: item.url, children: item.title });
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
var link_default = createLinkCompleter();
|
|
47
|
-
export {
|
|
48
|
-
link_default as default
|
|
49
|
-
};
|
|
50
|
-
//# sourceMappingURL=link.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/autocompleters/link.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\n// Disable Reason: Needs to be refactored.\n// eslint-disable-next-line no-restricted-imports\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\nimport { Icon, page, post } from '@wordpress/icons';\nimport { decodeEntities } from '@wordpress/html-entities';\n\nconst SHOWN_SUGGESTIONS = 10;\n\n/**\n * Creates a suggestion list for links to posts or pages.\n *\n * @return {Object} A links completer.\n */\nfunction createLinkCompleter() {\n\treturn {\n\t\tname: 'links',\n\t\tclassName: 'block-editor-autocompleters__link',\n\t\ttriggerPrefix: '[[',\n\t\toptions: async ( letters ) => {\n\t\t\tlet options = await apiFetch( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/search', {\n\t\t\t\t\tper_page: SHOWN_SUGGESTIONS,\n\t\t\t\t\tsearch: letters,\n\t\t\t\t\ttype: 'post',\n\t\t\t\t\torder_by: 'menu_order',\n\t\t\t\t} ),\n\t\t\t} );\n\n\t\t\toptions = options.filter( ( option ) => option.title !== '' );\n\n\t\t\treturn options;\n\t\t},\n\t\tgetOptionKeywords( item ) {\n\t\t\tconst expansionWords = item.title.split( /\\s+/ );\n\t\t\treturn [ ...expansionWords ];\n\t\t},\n\t\tgetOptionLabel( item ) {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tkey=\"icon\"\n\t\t\t\t\t\ticon={ item.subtype === 'page' ? page : post }\n\t\t\t\t\t/>\n\t\t\t\t\t{ decodeEntities( item.title ) }\n\t\t\t\t</>\n\t\t\t);\n\t\t},\n\t\tgetOptionCompletion( item ) {\n\t\t\treturn <a href={ item.url }>{ item.title }</a>;\n\t\t},\n\t};\n}\n\n/**\n * Creates a suggestion list for links to posts or pages..\n *\n * @return {Object} A link completer.\n */\nexport default createLinkCompleter();\n"],
|
|
5
|
-
"mappings": ";AAKA,OAAO,cAAc;AACrB,SAAS,oBAAoB;AAC7B,SAAS,MAAM,MAAM,YAAY;AACjC,SAAS,sBAAsB;AAkC3B,mBACC,KADD;AAhCJ,IAAM,oBAAoB;AAO1B,SAAS,sBAAsB;AAC9B,SAAO;AAAA,IACN,MAAM;AAAA,IACN,WAAW;AAAA,IACX,eAAe;AAAA,IACf,SAAS,OAAQ,YAAa;AAC7B,UAAI,UAAU,MAAM,SAAU;AAAA,QAC7B,MAAM,aAAc,iBAAiB;AAAA,UACpC,UAAU;AAAA,UACV,QAAQ;AAAA,UACR,MAAM;AAAA,UACN,UAAU;AAAA,QACX,CAAE;AAAA,MACH,CAAE;AAEF,gBAAU,QAAQ,OAAQ,CAAE,WAAY,OAAO,UAAU,EAAG;AAE5D,aAAO;AAAA,IACR;AAAA,IACA,kBAAmB,MAAO;AACzB,YAAM,iBAAiB,KAAK,MAAM,MAAO,KAAM;AAC/C,aAAO,CAAE,GAAG,cAAe;AAAA,IAC5B;AAAA,IACA,eAAgB,MAAO;AACtB,aACC,iCACC;AAAA;AAAA,UAAC;AAAA;AAAA,YAEA,MAAO,KAAK,YAAY,SAAS,OAAO;AAAA;AAAA,UADpC;AAAA,QAEL;AAAA,QACE,eAAgB,KAAK,KAAM;AAAA,SAC9B;AAAA,IAEF;AAAA,IACA,oBAAqB,MAAO;AAC3B,aAAO,oBAAC,OAAE,MAAO,KAAK,KAAQ,eAAK,OAAO;AAAA,IAC3C;AAAA,EACD;AACD;AAOA,IAAO,eAAQ,oBAAoB;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
// Disable Reason: Needs to be refactored.
|
|
5
|
-
// eslint-disable-next-line no-restricted-imports
|
|
6
|
-
import apiFetch from '@wordpress/api-fetch';
|
|
7
|
-
import { addQueryArgs } from '@wordpress/url';
|
|
8
|
-
import { Icon, page, post } from '@wordpress/icons';
|
|
9
|
-
import { decodeEntities } from '@wordpress/html-entities';
|
|
10
|
-
|
|
11
|
-
const SHOWN_SUGGESTIONS = 10;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Creates a suggestion list for links to posts or pages.
|
|
15
|
-
*
|
|
16
|
-
* @return {Object} A links completer.
|
|
17
|
-
*/
|
|
18
|
-
function createLinkCompleter() {
|
|
19
|
-
return {
|
|
20
|
-
name: 'links',
|
|
21
|
-
className: 'block-editor-autocompleters__link',
|
|
22
|
-
triggerPrefix: '[[',
|
|
23
|
-
options: async ( letters ) => {
|
|
24
|
-
let options = await apiFetch( {
|
|
25
|
-
path: addQueryArgs( '/wp/v2/search', {
|
|
26
|
-
per_page: SHOWN_SUGGESTIONS,
|
|
27
|
-
search: letters,
|
|
28
|
-
type: 'post',
|
|
29
|
-
order_by: 'menu_order',
|
|
30
|
-
} ),
|
|
31
|
-
} );
|
|
32
|
-
|
|
33
|
-
options = options.filter( ( option ) => option.title !== '' );
|
|
34
|
-
|
|
35
|
-
return options;
|
|
36
|
-
},
|
|
37
|
-
getOptionKeywords( item ) {
|
|
38
|
-
const expansionWords = item.title.split( /\s+/ );
|
|
39
|
-
return [ ...expansionWords ];
|
|
40
|
-
},
|
|
41
|
-
getOptionLabel( item ) {
|
|
42
|
-
return (
|
|
43
|
-
<>
|
|
44
|
-
<Icon
|
|
45
|
-
key="icon"
|
|
46
|
-
icon={ item.subtype === 'page' ? page : post }
|
|
47
|
-
/>
|
|
48
|
-
{ decodeEntities( item.title ) }
|
|
49
|
-
</>
|
|
50
|
-
);
|
|
51
|
-
},
|
|
52
|
-
getOptionCompletion( item ) {
|
|
53
|
-
return <a href={ item.url }>{ item.title }</a>;
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Creates a suggestion list for links to posts or pages..
|
|
60
|
-
*
|
|
61
|
-
* @return {Object} A link completer.
|
|
62
|
-
*/
|
|
63
|
-
export default createLinkCompleter();
|