@wordpress/block-library 10.4.0 → 10.5.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 +36 -0
- package/build/accordion/view.cjs +2 -5
- package/build/accordion/view.cjs.map +2 -2
- package/build/accordion-heading/block.json +1 -0
- package/build/audio/edit.cjs.map +2 -2
- package/build/avatar/edit.cjs.map +2 -2
- package/build/block/block.json +2 -1
- package/build/column/edit.cjs +1 -1
- package/build/column/edit.cjs.map +2 -2
- package/build/columns/edit.cjs.map +2 -2
- package/build/columns/transforms.cjs +161 -2
- package/build/columns/transforms.cjs.map +2 -2
- package/build/cover/edit/block-controls.cjs +1 -1
- package/build/cover/edit/block-controls.cjs.map +2 -2
- package/build/cover/edit/index.cjs +1 -1
- package/build/cover/edit/index.cjs.map +2 -2
- package/build/cover/edit/inspector-controls.cjs.map +3 -3
- package/build/embed/embed-placeholder.cjs.map +2 -2
- package/build/gallery/transforms.cjs +8 -0
- package/build/gallery/transforms.cjs.map +2 -2
- package/build/group/block.json +1 -1
- package/build/heading/transforms.cjs +36 -0
- package/build/heading/transforms.cjs.map +2 -2
- package/build/heading/variations.cjs +13 -1
- package/build/heading/variations.cjs.map +2 -2
- package/build/home-link/edit.cjs.map +3 -3
- package/build/icon/edit.cjs +7 -1
- package/build/icon/edit.cjs.map +2 -2
- package/build/image/image.cjs +1 -1
- package/build/image/image.cjs.map +3 -3
- package/build/list/block.json +1 -0
- package/build/math/edit.cjs +4 -5
- package/build/math/edit.cjs.map +3 -3
- package/build/media-text/edit.cjs.map +3 -3
- package/build/more/block.json +1 -1
- package/build/navigation-link/shared/controls.cjs.map +3 -3
- package/build/playlist/block.json +0 -1
- package/build/playlist/edit.cjs +46 -22
- package/build/playlist/edit.cjs.map +2 -2
- package/build/playlist-track/block.json +16 -8
- package/build/playlist-track/edit.cjs +74 -67
- package/build/playlist-track/edit.cjs.map +3 -3
- package/build/post-template/edit.cjs +5 -1
- package/build/post-template/edit.cjs.map +2 -2
- package/build/post-title/edit.cjs +3 -8
- package/build/post-title/edit.cjs.map +2 -2
- package/build/private-apis.cjs +0 -12
- package/build/private-apis.cjs.map +3 -3
- package/build/query/block.json +3 -0
- package/build/query-no-results/block.json +16 -1
- package/build/rss/edit.cjs.map +2 -2
- package/build/site-logo/edit.cjs +1 -1
- package/build/site-logo/edit.cjs.map +2 -2
- package/build/site-title/edit.cjs +2 -6
- package/build/site-title/edit.cjs.map +2 -2
- package/build/table-of-contents/block.json +2 -1
- package/build/table-of-contents/deprecated.cjs +165 -0
- package/build/table-of-contents/deprecated.cjs.map +7 -0
- package/build/table-of-contents/index.cjs +2 -2
- package/build/table-of-contents/index.cjs.map +3 -3
- package/build/tabs/view.cjs +32 -2
- package/build/tabs/view.cjs.map +2 -2
- package/build/term-template/edit.cjs +5 -1
- package/build/term-template/edit.cjs.map +2 -2
- package/build-module/accordion/view.mjs +2 -5
- package/build-module/accordion/view.mjs.map +2 -2
- package/build-module/accordion-heading/block.json +1 -0
- package/build-module/audio/edit.mjs.map +2 -2
- package/build-module/avatar/edit.mjs.map +2 -2
- package/build-module/block/block.json +2 -1
- package/build-module/column/edit.mjs +1 -1
- package/build-module/column/edit.mjs.map +2 -2
- package/build-module/columns/edit.mjs.map +2 -2
- package/build-module/columns/transforms.mjs +164 -3
- package/build-module/columns/transforms.mjs.map +2 -2
- package/build-module/cover/edit/block-controls.mjs +1 -1
- package/build-module/cover/edit/block-controls.mjs.map +2 -2
- package/build-module/cover/edit/index.mjs +1 -1
- package/build-module/cover/edit/index.mjs.map +2 -2
- package/build-module/cover/edit/inspector-controls.mjs +2 -2
- package/build-module/cover/edit/inspector-controls.mjs.map +2 -2
- package/build-module/embed/embed-placeholder.mjs +2 -2
- package/build-module/embed/embed-placeholder.mjs.map +1 -1
- package/build-module/gallery/transforms.mjs +8 -0
- package/build-module/gallery/transforms.mjs.map +2 -2
- package/build-module/group/block.json +1 -1
- package/build-module/heading/transforms.mjs +36 -0
- package/build-module/heading/transforms.mjs.map +2 -2
- package/build-module/heading/variations.mjs +13 -1
- package/build-module/heading/variations.mjs.map +2 -2
- package/build-module/home-link/edit.mjs +2 -2
- package/build-module/home-link/edit.mjs.map +2 -2
- package/build-module/icon/edit.mjs +7 -1
- package/build-module/icon/edit.mjs.map +2 -2
- package/build-module/image/image.mjs +4 -4
- package/build-module/image/image.mjs.map +2 -2
- package/build-module/list/block.json +1 -0
- package/build-module/math/edit.mjs +4 -8
- package/build-module/math/edit.mjs.map +2 -2
- package/build-module/media-text/edit.mjs +2 -2
- package/build-module/media-text/edit.mjs.map +2 -2
- package/build-module/more/block.json +1 -1
- package/build-module/navigation-link/shared/controls.mjs +2 -2
- package/build-module/navigation-link/shared/controls.mjs.map +2 -2
- package/build-module/playlist/block.json +0 -1
- package/build-module/playlist/edit.mjs +46 -22
- package/build-module/playlist/edit.mjs.map +2 -2
- package/build-module/playlist-track/block.json +16 -8
- package/build-module/playlist-track/edit.mjs +76 -69
- package/build-module/playlist-track/edit.mjs.map +2 -2
- package/build-module/post-template/edit.mjs +5 -1
- package/build-module/post-template/edit.mjs.map +2 -2
- package/build-module/post-title/edit.mjs +3 -8
- package/build-module/post-title/edit.mjs.map +2 -2
- package/build-module/private-apis.mjs +0 -2
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/query/block.json +3 -0
- package/build-module/query-no-results/block.json +16 -1
- package/build-module/rss/edit.mjs +2 -2
- package/build-module/rss/edit.mjs.map +1 -1
- package/build-module/site-logo/edit.mjs +1 -1
- package/build-module/site-logo/edit.mjs.map +2 -2
- package/build-module/site-title/edit.mjs +2 -6
- package/build-module/site-title/edit.mjs.map +2 -2
- package/build-module/table-of-contents/block.json +2 -1
- package/build-module/table-of-contents/deprecated.mjs +144 -0
- package/build-module/table-of-contents/deprecated.mjs.map +7 -0
- package/build-module/table-of-contents/index.mjs +2 -2
- package/build-module/table-of-contents/index.mjs.map +2 -2
- package/build-module/tabs/view.mjs +32 -2
- package/build-module/tabs/view.mjs.map +2 -2
- package/build-module/term-template/edit.mjs +5 -1
- package/build-module/term-template/edit.mjs.map +2 -2
- package/build-style/categories/style-rtl.css +2 -1
- package/build-style/categories/style.css +2 -1
- package/build-style/comments/editor-rtl.css +8 -10
- package/build-style/comments/editor.css +8 -10
- package/build-style/comments/style-rtl.css +8 -7
- package/build-style/comments/style.css +8 -7
- package/build-style/editor-rtl.css +8 -10
- package/build-style/editor.css +8 -10
- package/build-style/form-input/style-rtl.css +7 -7
- package/build-style/form-input/style.css +7 -7
- package/build-style/post-comments-form/style-rtl.css +7 -6
- package/build-style/post-comments-form/style.css +7 -6
- package/build-style/query-no-results/style-rtl.css +3 -0
- package/build-style/query-no-results/style.css +3 -0
- package/build-style/search/style-rtl.css +1 -1
- package/build-style/search/style.css +1 -1
- package/build-style/search/theme-rtl.css +1 -1
- package/build-style/search/theme.css +1 -1
- package/build-style/style-rtl.css +34 -23
- package/build-style/style.css +34 -23
- package/build-style/tab-panel/style-rtl.css +5 -1
- package/build-style/tab-panel/style.css +5 -1
- package/build-style/theme-rtl.css +1 -1
- package/build-style/theme.css +1 -1
- package/package.json +43 -43
- package/src/accordion/view.js +2 -5
- package/src/accordion-heading/README.md +1 -0
- package/src/accordion-heading/block.json +1 -0
- package/src/audio/edit.js +13 -0
- package/src/avatar/edit.js +78 -0
- package/src/block/README.md +1 -0
- package/src/block/block.json +2 -1
- package/src/categories/style.scss +4 -4
- package/src/column/edit.js +15 -1
- package/src/columns/edit.js +18 -0
- package/src/columns/test/transforms.js +517 -1
- package/src/columns/transforms.js +207 -2
- package/src/comments/style.scss +7 -10
- package/src/cover/edit/block-controls.js +1 -1
- package/src/cover/edit/index.js +1 -1
- package/src/cover/edit/inspector-controls.js +2 -2
- package/src/embed/embed-placeholder.js +2 -2
- package/src/form-input/style.scss +2 -2
- package/src/gallery/test/edit.js +57 -0
- package/src/gallery/test/transforms.js +57 -0
- package/src/gallery/transforms.js +8 -0
- package/src/group/README.md +1 -1
- package/src/group/block.json +1 -1
- package/src/heading/transforms.js +36 -0
- package/src/heading/variations.js +12 -0
- package/src/home-link/edit.js +2 -2
- package/src/icon/edit.js +9 -1
- package/src/image/image.js +4 -4
- package/src/list/README.md +1 -0
- package/src/list/block.json +1 -0
- package/src/math/edit.js +4 -9
- package/src/media-text/edit.js +2 -2
- package/src/more/README.md +1 -1
- package/src/more/block.json +1 -1
- package/src/navigation/index.php +8 -2
- package/src/navigation-link/shared/controls.js +2 -2
- package/src/playlist/block.json +0 -1
- package/src/playlist/edit.js +54 -21
- package/src/playlist/test/edit-component.js +78 -27
- package/src/playlist-track/README.md +8 -8
- package/src/playlist-track/block.json +16 -8
- package/src/playlist-track/edit.js +56 -27
- package/src/playlist-track/test/edit.js +145 -41
- package/src/post-comments-form/style.scss +7 -9
- package/src/post-template/edit.js +10 -1
- package/src/post-title/edit.js +2 -9
- package/src/private-apis.js +0 -2
- package/src/query/README.md +2 -0
- package/src/query/block.json +3 -0
- package/src/query-no-results/README.md +3 -0
- package/src/query-no-results/block.json +16 -1
- package/src/query-no-results/style.scss +5 -0
- package/src/rss/edit.js +2 -2
- package/src/search/style.scss +1 -1
- package/src/search/theme.scss +2 -4
- package/src/site-logo/edit.js +1 -1
- package/src/site-title/edit.js +1 -10
- package/src/social-link/index.php +6 -13
- package/src/style.scss +1 -0
- package/src/tab-panel/index.php +14 -5
- package/src/tab-panel/style.scss +7 -1
- package/src/table-of-contents/README.md +6 -6
- package/src/table-of-contents/block.json +2 -1
- package/src/table-of-contents/deprecated.js +173 -0
- package/src/table-of-contents/index.js +2 -2
- package/src/table-of-contents/index.php +16 -3
- package/src/tabs/index.php +5 -5
- package/src/tabs/view.js +32 -2
- package/src/term-description/index.php +1 -1
- package/src/term-template/edit.js +10 -1
- package/src/utils/test/waveform-player-dependency.js +0 -74
- package/build/block-keyboard-shortcuts/index.cjs +0 -131
- package/build/block-keyboard-shortcuts/index.cjs.map +0 -7
- package/build/table-of-contents/save.cjs +0 -55
- package/build/table-of-contents/save.cjs.map +0 -7
- package/build-module/block-keyboard-shortcuts/index.mjs +0 -113
- package/build-module/block-keyboard-shortcuts/index.mjs.map +0 -7
- package/build-module/table-of-contents/save.mjs +0 -24
- package/build-module/table-of-contents/save.mjs.map +0 -7
- package/src/block-keyboard-shortcuts/index.js +0 -135
- package/src/table-of-contents/save.js +0 -22
|
@@ -1,55 +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-library/src/table-of-contents/save.js
|
|
31
|
-
var save_exports = {};
|
|
32
|
-
__export(save_exports, {
|
|
33
|
-
default: () => save
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(save_exports);
|
|
36
|
-
var import_block_editor = require("@wordpress/block-editor");
|
|
37
|
-
var import_list = __toESM(require("./list.cjs"));
|
|
38
|
-
var import_utils = require("./utils.cjs");
|
|
39
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
40
|
-
function save({
|
|
41
|
-
attributes: { headings = [], ordered = true }
|
|
42
|
-
}) {
|
|
43
|
-
if (headings.length === 0) {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
const ListTag = ordered ? "ol" : "ul";
|
|
47
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("nav", { ...import_block_editor.useBlockProps.save(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ListTag, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
48
|
-
import_list.default,
|
|
49
|
-
{
|
|
50
|
-
nestedHeadingList: (0, import_utils.linearToNestedHeadingList)(headings),
|
|
51
|
-
ordered
|
|
52
|
-
}
|
|
53
|
-
) }) });
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=save.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/table-of-contents/save.js"],
|
|
4
|
-
"sourcesContent": ["import { useBlockProps } from '@wordpress/block-editor';\nimport TableOfContentsList from './list';\nimport { linearToNestedHeadingList } from './utils';\n\nexport default function save( {\n\tattributes: { headings = [], ordered = true },\n} ) {\n\tif ( headings.length === 0 ) {\n\t\treturn null;\n\t}\n\tconst ListTag = ordered ? 'ol' : 'ul';\n\treturn (\n\t\t<nav { ...useBlockProps.save() }>\n\t\t\t<ListTag>\n\t\t\t\t<TableOfContentsList\n\t\t\t\t\tnestedHeadingList={ linearToNestedHeadingList( headings ) }\n\t\t\t\t\tordered={ ordered }\n\t\t\t\t/>\n\t\t\t</ListTag>\n\t\t</nav>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA8B;AAC9B,kBAAgC;AAChC,mBAA0C;AAYtC;AAVW,SAAR,KAAuB;AAAA,EAC7B,YAAY,EAAE,WAAW,CAAC,GAAG,UAAU,KAAK;AAC7C,GAAI;AACH,MAAK,SAAS,WAAW,GAAI;AAC5B,WAAO;AAAA,EACR;AACA,QAAM,UAAU,UAAU,OAAO;AACjC,SACC,4CAAC,SAAM,GAAG,kCAAc,KAAK,GAC5B,sDAAC,WACA;AAAA,IAAC,YAAAA;AAAA,IAAA;AAAA,MACA,uBAAoB,wCAA2B,QAAS;AAAA,MACxD;AAAA;AAAA,EACD,GACD,GACD;AAEF;",
|
|
6
|
-
"names": ["TableOfContentsList"]
|
|
7
|
-
}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
// packages/block-library/src/block-keyboard-shortcuts/index.js
|
|
2
|
-
import { useEffect } from "@wordpress/element";
|
|
3
|
-
import { useSelect, useDispatch } from "@wordpress/data";
|
|
4
|
-
import {
|
|
5
|
-
useShortcut,
|
|
6
|
-
store as keyboardShortcutsStore
|
|
7
|
-
} from "@wordpress/keyboard-shortcuts";
|
|
8
|
-
import { __ } from "@wordpress/i18n";
|
|
9
|
-
import { createBlock } from "@wordpress/blocks";
|
|
10
|
-
import { store as blockEditorStore } from "@wordpress/block-editor";
|
|
11
|
-
function BlockKeyboardShortcuts() {
|
|
12
|
-
const { registerShortcut } = useDispatch(keyboardShortcutsStore);
|
|
13
|
-
const { replaceBlocks } = useDispatch(blockEditorStore);
|
|
14
|
-
const { getBlockName, getSelectedBlockClientId, getBlockAttributes } = useSelect(blockEditorStore);
|
|
15
|
-
const handleTransformHeadingAndParagraph = (event, level) => {
|
|
16
|
-
event.preventDefault();
|
|
17
|
-
const currentClientId = getSelectedBlockClientId();
|
|
18
|
-
if (currentClientId === null) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const blockName = getBlockName(currentClientId);
|
|
22
|
-
const isParagraph = blockName === "core/paragraph";
|
|
23
|
-
const isHeading = blockName === "core/heading";
|
|
24
|
-
if (!isParagraph && !isHeading) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const destinationBlockName = level === 0 ? "core/paragraph" : "core/heading";
|
|
28
|
-
const attributes = getBlockAttributes(currentClientId);
|
|
29
|
-
if (isParagraph && level === 0 || isHeading && attributes.level === level) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const newAttributes = {
|
|
33
|
-
content: attributes.content
|
|
34
|
-
};
|
|
35
|
-
const sourceTextAlign = attributes.textAlign || attributes.style?.typography?.textAlign;
|
|
36
|
-
if (destinationBlockName === "core/heading") {
|
|
37
|
-
newAttributes.level = level;
|
|
38
|
-
}
|
|
39
|
-
if (sourceTextAlign) {
|
|
40
|
-
newAttributes.style = {
|
|
41
|
-
typography: {
|
|
42
|
-
textAlign: sourceTextAlign
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
replaceBlocks(
|
|
47
|
-
currentClientId,
|
|
48
|
-
createBlock(destinationBlockName, newAttributes)
|
|
49
|
-
);
|
|
50
|
-
};
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
registerShortcut({
|
|
53
|
-
name: "core/block-editor/transform-heading-to-paragraph",
|
|
54
|
-
category: "block-library",
|
|
55
|
-
description: __("Transform heading to paragraph."),
|
|
56
|
-
keyCombination: {
|
|
57
|
-
modifier: "access",
|
|
58
|
-
character: "0"
|
|
59
|
-
},
|
|
60
|
-
aliases: [
|
|
61
|
-
{
|
|
62
|
-
modifier: "access",
|
|
63
|
-
character: "7"
|
|
64
|
-
}
|
|
65
|
-
]
|
|
66
|
-
});
|
|
67
|
-
[1, 2, 3, 4, 5, 6].forEach((level) => {
|
|
68
|
-
registerShortcut({
|
|
69
|
-
name: `core/block-editor/transform-paragraph-to-heading-${level}`,
|
|
70
|
-
category: "block-library",
|
|
71
|
-
description: __("Transform paragraph to heading."),
|
|
72
|
-
keyCombination: {
|
|
73
|
-
modifier: "access",
|
|
74
|
-
character: `${level}`
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
}, [registerShortcut]);
|
|
79
|
-
useShortcut(
|
|
80
|
-
"core/block-editor/transform-heading-to-paragraph",
|
|
81
|
-
(event) => handleTransformHeadingAndParagraph(event, 0)
|
|
82
|
-
);
|
|
83
|
-
useShortcut(
|
|
84
|
-
"core/block-editor/transform-paragraph-to-heading-1",
|
|
85
|
-
(event) => handleTransformHeadingAndParagraph(event, 1)
|
|
86
|
-
);
|
|
87
|
-
useShortcut(
|
|
88
|
-
"core/block-editor/transform-paragraph-to-heading-2",
|
|
89
|
-
(event) => handleTransformHeadingAndParagraph(event, 2)
|
|
90
|
-
);
|
|
91
|
-
useShortcut(
|
|
92
|
-
"core/block-editor/transform-paragraph-to-heading-3",
|
|
93
|
-
(event) => handleTransformHeadingAndParagraph(event, 3)
|
|
94
|
-
);
|
|
95
|
-
useShortcut(
|
|
96
|
-
"core/block-editor/transform-paragraph-to-heading-4",
|
|
97
|
-
(event) => handleTransformHeadingAndParagraph(event, 4)
|
|
98
|
-
);
|
|
99
|
-
useShortcut(
|
|
100
|
-
"core/block-editor/transform-paragraph-to-heading-5",
|
|
101
|
-
(event) => handleTransformHeadingAndParagraph(event, 5)
|
|
102
|
-
);
|
|
103
|
-
useShortcut(
|
|
104
|
-
"core/block-editor/transform-paragraph-to-heading-6",
|
|
105
|
-
(event) => handleTransformHeadingAndParagraph(event, 6)
|
|
106
|
-
);
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
var block_keyboard_shortcuts_default = BlockKeyboardShortcuts;
|
|
110
|
-
export {
|
|
111
|
-
block_keyboard_shortcuts_default as default
|
|
112
|
-
};
|
|
113
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/block-keyboard-shortcuts/index.js"],
|
|
4
|
-
"sourcesContent": ["import { useEffect } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseShortcut,\n\tstore as keyboardShortcutsStore,\n} from '@wordpress/keyboard-shortcuts';\nimport { __ } from '@wordpress/i18n';\nimport { createBlock } from '@wordpress/blocks';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nfunction BlockKeyboardShortcuts() {\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst { getBlockName, getSelectedBlockClientId, getBlockAttributes } =\n\t\tuseSelect( blockEditorStore );\n\n\tconst handleTransformHeadingAndParagraph = ( event, level ) => {\n\t\tevent.preventDefault();\n\n\t\tconst currentClientId = getSelectedBlockClientId();\n\t\tif ( currentClientId === null ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst blockName = getBlockName( currentClientId );\n\t\tconst isParagraph = blockName === 'core/paragraph';\n\t\tconst isHeading = blockName === 'core/heading';\n\n\t\tif ( ! isParagraph && ! isHeading ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst destinationBlockName =\n\t\t\tlevel === 0 ? 'core/paragraph' : 'core/heading';\n\n\t\tconst attributes = getBlockAttributes( currentClientId );\n\n\t\t// Avoid unnecessary block transform when attempting to transform to\n\t\t// the same block type and/or same level.\n\t\tif (\n\t\t\t( isParagraph && level === 0 ) ||\n\t\t\t( isHeading && attributes.level === level )\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst newAttributes = {\n\t\t\tcontent: attributes.content,\n\t\t};\n\n\t\t// Read textAlign from source block (could be in old or new format)\n\t\tconst sourceTextAlign =\n\t\t\tattributes.textAlign || attributes.style?.typography?.textAlign;\n\n\t\t// When destination is heading, set the level\n\t\tif ( destinationBlockName === 'core/heading' ) {\n\t\t\tnewAttributes.level = level;\n\t\t}\n\n\t\tif ( sourceTextAlign ) {\n\t\t\tnewAttributes.style = {\n\t\t\t\ttypography: {\n\t\t\t\t\ttextAlign: sourceTextAlign,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\treplaceBlocks(\n\t\t\tcurrentClientId,\n\t\t\tcreateBlock( destinationBlockName, newAttributes )\n\t\t);\n\t};\n\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/block-editor/transform-heading-to-paragraph',\n\t\t\tcategory: 'block-library',\n\t\t\tdescription: __( 'Transform heading to paragraph.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'access',\n\t\t\t\tcharacter: '0',\n\t\t\t},\n\t\t\taliases: [\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: '7',\n\t\t\t\t},\n\t\t\t],\n\t\t} );\n\n\t\t[ 1, 2, 3, 4, 5, 6 ].forEach( ( level ) => {\n\t\t\tregisterShortcut( {\n\t\t\t\tname: `core/block-editor/transform-paragraph-to-heading-${ level }`,\n\t\t\t\tcategory: 'block-library',\n\t\t\t\tdescription: __( 'Transform paragraph to heading.' ),\n\t\t\t\tkeyCombination: {\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: `${ level }`,\n\t\t\t\t},\n\t\t\t} );\n\t\t} );\n\t}, [ registerShortcut ] );\n\n\tuseShortcut(\n\t\t'core/block-editor/transform-heading-to-paragraph',\n\t\t( event ) => handleTransformHeadingAndParagraph( event, 0 )\n\t);\n\tuseShortcut(\n\t\t'core/block-editor/transform-paragraph-to-heading-1',\n\t\t( event ) => handleTransformHeadingAndParagraph( event, 1 )\n\t);\n\tuseShortcut(\n\t\t'core/block-editor/transform-paragraph-to-heading-2',\n\t\t( event ) => handleTransformHeadingAndParagraph( event, 2 )\n\t);\n\tuseShortcut(\n\t\t'core/block-editor/transform-paragraph-to-heading-3',\n\t\t( event ) => handleTransformHeadingAndParagraph( event, 3 )\n\t);\n\tuseShortcut(\n\t\t'core/block-editor/transform-paragraph-to-heading-4',\n\t\t( event ) => handleTransformHeadingAndParagraph( event, 4 )\n\t);\n\tuseShortcut(\n\t\t'core/block-editor/transform-paragraph-to-heading-5',\n\t\t( event ) => handleTransformHeadingAndParagraph( event, 5 )\n\t);\n\tuseShortcut(\n\t\t'core/block-editor/transform-paragraph-to-heading-6',\n\t\t( event ) => handleTransformHeadingAndParagraph( event, 6 )\n\t);\n\n\treturn null;\n}\n\nexport default BlockKeyboardShortcuts;\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,WAAW,mBAAmB;AACvC;AAAA,EACC;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,SAAS,wBAAwB;AAE1C,SAAS,yBAAyB;AACjC,QAAM,EAAE,iBAAiB,IAAI,YAAa,sBAAuB;AACjE,QAAM,EAAE,cAAc,IAAI,YAAa,gBAAiB;AACxD,QAAM,EAAE,cAAc,0BAA0B,mBAAmB,IAClE,UAAW,gBAAiB;AAE7B,QAAM,qCAAqC,CAAE,OAAO,UAAW;AAC9D,UAAM,eAAe;AAErB,UAAM,kBAAkB,yBAAyB;AACjD,QAAK,oBAAoB,MAAO;AAC/B;AAAA,IACD;AAEA,UAAM,YAAY,aAAc,eAAgB;AAChD,UAAM,cAAc,cAAc;AAClC,UAAM,YAAY,cAAc;AAEhC,QAAK,CAAE,eAAe,CAAE,WAAY;AACnC;AAAA,IACD;AAEA,UAAM,uBACL,UAAU,IAAI,mBAAmB;AAElC,UAAM,aAAa,mBAAoB,eAAgB;AAIvD,QACG,eAAe,UAAU,KACzB,aAAa,WAAW,UAAU,OACnC;AACD;AAAA,IACD;AACA,UAAM,gBAAgB;AAAA,MACrB,SAAS,WAAW;AAAA,IACrB;AAGA,UAAM,kBACL,WAAW,aAAa,WAAW,OAAO,YAAY;AAGvD,QAAK,yBAAyB,gBAAiB;AAC9C,oBAAc,QAAQ;AAAA,IACvB;AAEA,QAAK,iBAAkB;AACtB,oBAAc,QAAQ;AAAA,QACrB,YAAY;AAAA,UACX,WAAW;AAAA,QACZ;AAAA,MACD;AAAA,IACD;AAEA;AAAA,MACC;AAAA,MACA,YAAa,sBAAsB,aAAc;AAAA,IAClD;AAAA,EACD;AAEA,YAAW,MAAM;AAChB,qBAAkB;AAAA,MACjB,MAAM;AAAA,MACN,UAAU;AAAA,MACV,aAAa,GAAI,iCAAkC;AAAA,MACnD,gBAAgB;AAAA,QACf,UAAU;AAAA,QACV,WAAW;AAAA,MACZ;AAAA,MACA,SAAS;AAAA,QACR;AAAA,UACC,UAAU;AAAA,UACV,WAAW;AAAA,QACZ;AAAA,MACD;AAAA,IACD,CAAE;AAEF,KAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAE,EAAE,QAAS,CAAE,UAAW;AAC1C,uBAAkB;AAAA,QACjB,MAAM,oDAAqD,KAAM;AAAA,QACjE,UAAU;AAAA,QACV,aAAa,GAAI,iCAAkC;AAAA,QACnD,gBAAgB;AAAA,UACf,UAAU;AAAA,UACV,WAAW,GAAI,KAAM;AAAA,QACtB;AAAA,MACD,CAAE;AAAA,IACH,CAAE;AAAA,EACH,GAAG,CAAE,gBAAiB,CAAE;AAExB;AAAA,IACC;AAAA,IACA,CAAE,UAAW,mCAAoC,OAAO,CAAE;AAAA,EAC3D;AACA;AAAA,IACC;AAAA,IACA,CAAE,UAAW,mCAAoC,OAAO,CAAE;AAAA,EAC3D;AACA;AAAA,IACC;AAAA,IACA,CAAE,UAAW,mCAAoC,OAAO,CAAE;AAAA,EAC3D;AACA;AAAA,IACC;AAAA,IACA,CAAE,UAAW,mCAAoC,OAAO,CAAE;AAAA,EAC3D;AACA;AAAA,IACC;AAAA,IACA,CAAE,UAAW,mCAAoC,OAAO,CAAE;AAAA,EAC3D;AACA;AAAA,IACC;AAAA,IACA,CAAE,UAAW,mCAAoC,OAAO,CAAE;AAAA,EAC3D;AACA;AAAA,IACC;AAAA,IACA,CAAE,UAAW,mCAAoC,OAAO,CAAE;AAAA,EAC3D;AAEA,SAAO;AACR;AAEA,IAAO,mCAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// packages/block-library/src/table-of-contents/save.js
|
|
2
|
-
import { useBlockProps } from "@wordpress/block-editor";
|
|
3
|
-
import TableOfContentsList from "./list.mjs";
|
|
4
|
-
import { linearToNestedHeadingList } from "./utils.mjs";
|
|
5
|
-
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
function save({
|
|
7
|
-
attributes: { headings = [], ordered = true }
|
|
8
|
-
}) {
|
|
9
|
-
if (headings.length === 0) {
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
const ListTag = ordered ? "ol" : "ul";
|
|
13
|
-
return /* @__PURE__ */ jsx("nav", { ...useBlockProps.save(), children: /* @__PURE__ */ jsx(ListTag, { children: /* @__PURE__ */ jsx(
|
|
14
|
-
TableOfContentsList,
|
|
15
|
-
{
|
|
16
|
-
nestedHeadingList: linearToNestedHeadingList(headings),
|
|
17
|
-
ordered
|
|
18
|
-
}
|
|
19
|
-
) }) });
|
|
20
|
-
}
|
|
21
|
-
export {
|
|
22
|
-
save as default
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=save.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/table-of-contents/save.js"],
|
|
4
|
-
"sourcesContent": ["import { useBlockProps } from '@wordpress/block-editor';\nimport TableOfContentsList from './list';\nimport { linearToNestedHeadingList } from './utils';\n\nexport default function save( {\n\tattributes: { headings = [], ordered = true },\n} ) {\n\tif ( headings.length === 0 ) {\n\t\treturn null;\n\t}\n\tconst ListTag = ordered ? 'ol' : 'ul';\n\treturn (\n\t\t<nav { ...useBlockProps.save() }>\n\t\t\t<ListTag>\n\t\t\t\t<TableOfContentsList\n\t\t\t\t\tnestedHeadingList={ linearToNestedHeadingList( headings ) }\n\t\t\t\t\tordered={ ordered }\n\t\t\t\t/>\n\t\t\t</ListTag>\n\t\t</nav>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,qBAAqB;AAC9B,OAAO,yBAAyB;AAChC,SAAS,iCAAiC;AAYtC;AAVW,SAAR,KAAuB;AAAA,EAC7B,YAAY,EAAE,WAAW,CAAC,GAAG,UAAU,KAAK;AAC7C,GAAI;AACH,MAAK,SAAS,WAAW,GAAI;AAC5B,WAAO;AAAA,EACR;AACA,QAAM,UAAU,UAAU,OAAO;AACjC,SACC,oBAAC,SAAM,GAAG,cAAc,KAAK,GAC5B,8BAAC,WACA;AAAA,IAAC;AAAA;AAAA,MACA,mBAAoB,0BAA2B,QAAS;AAAA,MACxD;AAAA;AAAA,EACD,GACD,GACD;AAEF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { useEffect } from '@wordpress/element';
|
|
2
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
3
|
-
import {
|
|
4
|
-
useShortcut,
|
|
5
|
-
store as keyboardShortcutsStore,
|
|
6
|
-
} from '@wordpress/keyboard-shortcuts';
|
|
7
|
-
import { __ } from '@wordpress/i18n';
|
|
8
|
-
import { createBlock } from '@wordpress/blocks';
|
|
9
|
-
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
10
|
-
|
|
11
|
-
function BlockKeyboardShortcuts() {
|
|
12
|
-
const { registerShortcut } = useDispatch( keyboardShortcutsStore );
|
|
13
|
-
const { replaceBlocks } = useDispatch( blockEditorStore );
|
|
14
|
-
const { getBlockName, getSelectedBlockClientId, getBlockAttributes } =
|
|
15
|
-
useSelect( blockEditorStore );
|
|
16
|
-
|
|
17
|
-
const handleTransformHeadingAndParagraph = ( event, level ) => {
|
|
18
|
-
event.preventDefault();
|
|
19
|
-
|
|
20
|
-
const currentClientId = getSelectedBlockClientId();
|
|
21
|
-
if ( currentClientId === null ) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const blockName = getBlockName( currentClientId );
|
|
26
|
-
const isParagraph = blockName === 'core/paragraph';
|
|
27
|
-
const isHeading = blockName === 'core/heading';
|
|
28
|
-
|
|
29
|
-
if ( ! isParagraph && ! isHeading ) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const destinationBlockName =
|
|
34
|
-
level === 0 ? 'core/paragraph' : 'core/heading';
|
|
35
|
-
|
|
36
|
-
const attributes = getBlockAttributes( currentClientId );
|
|
37
|
-
|
|
38
|
-
// Avoid unnecessary block transform when attempting to transform to
|
|
39
|
-
// the same block type and/or same level.
|
|
40
|
-
if (
|
|
41
|
-
( isParagraph && level === 0 ) ||
|
|
42
|
-
( isHeading && attributes.level === level )
|
|
43
|
-
) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const newAttributes = {
|
|
47
|
-
content: attributes.content,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// Read textAlign from source block (could be in old or new format)
|
|
51
|
-
const sourceTextAlign =
|
|
52
|
-
attributes.textAlign || attributes.style?.typography?.textAlign;
|
|
53
|
-
|
|
54
|
-
// When destination is heading, set the level
|
|
55
|
-
if ( destinationBlockName === 'core/heading' ) {
|
|
56
|
-
newAttributes.level = level;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if ( sourceTextAlign ) {
|
|
60
|
-
newAttributes.style = {
|
|
61
|
-
typography: {
|
|
62
|
-
textAlign: sourceTextAlign,
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
replaceBlocks(
|
|
68
|
-
currentClientId,
|
|
69
|
-
createBlock( destinationBlockName, newAttributes )
|
|
70
|
-
);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
useEffect( () => {
|
|
74
|
-
registerShortcut( {
|
|
75
|
-
name: 'core/block-editor/transform-heading-to-paragraph',
|
|
76
|
-
category: 'block-library',
|
|
77
|
-
description: __( 'Transform heading to paragraph.' ),
|
|
78
|
-
keyCombination: {
|
|
79
|
-
modifier: 'access',
|
|
80
|
-
character: '0',
|
|
81
|
-
},
|
|
82
|
-
aliases: [
|
|
83
|
-
{
|
|
84
|
-
modifier: 'access',
|
|
85
|
-
character: '7',
|
|
86
|
-
},
|
|
87
|
-
],
|
|
88
|
-
} );
|
|
89
|
-
|
|
90
|
-
[ 1, 2, 3, 4, 5, 6 ].forEach( ( level ) => {
|
|
91
|
-
registerShortcut( {
|
|
92
|
-
name: `core/block-editor/transform-paragraph-to-heading-${ level }`,
|
|
93
|
-
category: 'block-library',
|
|
94
|
-
description: __( 'Transform paragraph to heading.' ),
|
|
95
|
-
keyCombination: {
|
|
96
|
-
modifier: 'access',
|
|
97
|
-
character: `${ level }`,
|
|
98
|
-
},
|
|
99
|
-
} );
|
|
100
|
-
} );
|
|
101
|
-
}, [ registerShortcut ] );
|
|
102
|
-
|
|
103
|
-
useShortcut(
|
|
104
|
-
'core/block-editor/transform-heading-to-paragraph',
|
|
105
|
-
( event ) => handleTransformHeadingAndParagraph( event, 0 )
|
|
106
|
-
);
|
|
107
|
-
useShortcut(
|
|
108
|
-
'core/block-editor/transform-paragraph-to-heading-1',
|
|
109
|
-
( event ) => handleTransformHeadingAndParagraph( event, 1 )
|
|
110
|
-
);
|
|
111
|
-
useShortcut(
|
|
112
|
-
'core/block-editor/transform-paragraph-to-heading-2',
|
|
113
|
-
( event ) => handleTransformHeadingAndParagraph( event, 2 )
|
|
114
|
-
);
|
|
115
|
-
useShortcut(
|
|
116
|
-
'core/block-editor/transform-paragraph-to-heading-3',
|
|
117
|
-
( event ) => handleTransformHeadingAndParagraph( event, 3 )
|
|
118
|
-
);
|
|
119
|
-
useShortcut(
|
|
120
|
-
'core/block-editor/transform-paragraph-to-heading-4',
|
|
121
|
-
( event ) => handleTransformHeadingAndParagraph( event, 4 )
|
|
122
|
-
);
|
|
123
|
-
useShortcut(
|
|
124
|
-
'core/block-editor/transform-paragraph-to-heading-5',
|
|
125
|
-
( event ) => handleTransformHeadingAndParagraph( event, 5 )
|
|
126
|
-
);
|
|
127
|
-
useShortcut(
|
|
128
|
-
'core/block-editor/transform-paragraph-to-heading-6',
|
|
129
|
-
( event ) => handleTransformHeadingAndParagraph( event, 6 )
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
return null;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export default BlockKeyboardShortcuts;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { useBlockProps } from '@wordpress/block-editor';
|
|
2
|
-
import TableOfContentsList from './list';
|
|
3
|
-
import { linearToNestedHeadingList } from './utils';
|
|
4
|
-
|
|
5
|
-
export default function save( {
|
|
6
|
-
attributes: { headings = [], ordered = true },
|
|
7
|
-
} ) {
|
|
8
|
-
if ( headings.length === 0 ) {
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
const ListTag = ordered ? 'ol' : 'ul';
|
|
12
|
-
return (
|
|
13
|
-
<nav { ...useBlockProps.save() }>
|
|
14
|
-
<ListTag>
|
|
15
|
-
<TableOfContentsList
|
|
16
|
-
nestedHeadingList={ linearToNestedHeadingList( headings ) }
|
|
17
|
-
ordered={ ordered }
|
|
18
|
-
/>
|
|
19
|
-
</ListTag>
|
|
20
|
-
</nav>
|
|
21
|
-
);
|
|
22
|
-
}
|