@wordpress/block-library 9.35.1-next.dc3f6d3c1.0 → 9.36.1-next.8b30e05b0.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/accordion/view.js +46 -4
- package/build/accordion/view.js.map +2 -2
- package/build/accordion-heading/block.json +1 -1
- package/build/accordion-heading/deprecated.js +1 -1
- package/build/accordion-heading/deprecated.js.map +2 -2
- package/build/accordion-panel/block.json +1 -1
- package/build/audio/index.js +12 -9
- package/build/audio/index.js.map +3 -3
- package/build/button/index.js +13 -10
- package/build/button/index.js.map +3 -3
- package/build/code/index.js +9 -6
- package/build/code/index.js.map +3 -3
- package/build/cover/edit/block-controls.js +37 -3
- package/build/cover/edit/block-controls.js.map +3 -3
- package/build/cover/edit/cover-placeholder.js +0 -1
- package/build/cover/edit/cover-placeholder.js.map +2 -2
- package/build/cover/edit/embed-video-url-input.js +83 -0
- package/build/cover/edit/embed-video-url-input.js.map +7 -0
- package/build/cover/edit/index.js +60 -0
- package/build/cover/edit/index.js.map +2 -2
- package/build/cover/embed-video-utils.js +151 -0
- package/build/cover/embed-video-utils.js.map +7 -0
- package/build/cover/index.js +10 -4
- package/build/cover/index.js.map +3 -3
- package/build/cover/save.js +12 -0
- package/build/cover/save.js.map +2 -2
- package/build/cover/shared.js +3 -0
- package/build/cover/shared.js.map +2 -2
- package/build/details/index.js +9 -6
- package/build/details/index.js.map +3 -3
- package/build/file/index.js +14 -14
- package/build/file/index.js.map +3 -3
- package/build/freeform/block.json +1 -1
- package/build/gallery/edit.js +0 -2
- package/build/gallery/edit.js.map +2 -2
- package/build/heading/index.js +9 -6
- package/build/heading/index.js.map +3 -3
- package/build/html/modal.js +127 -118
- package/build/html/modal.js.map +3 -3
- package/build/image/edit.js +0 -1
- package/build/image/edit.js.map +2 -2
- package/build/image/image.js +0 -1
- package/build/image/image.js.map +2 -2
- package/build/image/index.js +18 -18
- package/build/image/index.js.map +3 -3
- package/build/list-item/index.js +8 -6
- package/build/list-item/index.js.map +3 -3
- package/build/math/block.json +28 -1
- package/build/math/edit.js +4 -1
- package/build/math/edit.js.map +2 -2
- package/build/media-text/index.js +15 -8
- package/build/media-text/index.js.map +3 -3
- package/build/media-text/media-container.js +0 -2
- package/build/media-text/media-container.js.map +2 -2
- package/build/missing/block.json +1 -1
- package/build/missing/edit.js +2 -2
- package/build/missing/edit.js.map +1 -1
- package/build/more/index.js +9 -6
- package/build/more/index.js.map +3 -3
- package/build/navigation-link/edit.js +36 -11
- package/build/navigation-link/edit.js.map +2 -2
- package/build/navigation-link/index.js +11 -8
- package/build/navigation-link/index.js.map +3 -3
- package/build/navigation-submenu/index.js +11 -8
- package/build/navigation-submenu/index.js.map +3 -3
- package/build/paragraph/deprecated-attributes.js +68 -0
- package/build/paragraph/deprecated-attributes.js.map +7 -0
- package/build/paragraph/edit.js +2 -0
- package/build/paragraph/edit.js.map +3 -3
- package/build/paragraph/index.js +9 -6
- package/build/paragraph/index.js.map +3 -3
- package/build/pattern/block.json +1 -1
- package/build/preformatted/index.js +9 -6
- package/build/preformatted/index.js.map +3 -3
- package/build/pullquote/index.js +11 -11
- package/build/pullquote/index.js.map +3 -3
- package/build/search/index.js +14 -16
- package/build/search/index.js.map +3 -3
- package/build/social-link/index.js +11 -8
- package/build/social-link/index.js.map +3 -3
- package/build/template-part/edit/index.js +37 -7
- package/build/template-part/edit/index.js.map +2 -2
- package/build/template-part/edit/utils/hooks.js +2 -3
- package/build/template-part/edit/utils/hooks.js.map +2 -2
- package/build/term-count/index.js +1 -0
- package/build/term-count/index.js.map +2 -2
- package/build/term-name/index.js +1 -0
- package/build/term-name/index.js.map +2 -2
- package/build/verse/index.js +9 -6
- package/build/verse/index.js.map +3 -3
- package/build/video/index.js +12 -9
- package/build/video/index.js.map +3 -3
- package/build-module/accordion/view.js +46 -4
- package/build-module/accordion/view.js.map +2 -2
- package/build-module/accordion-heading/block.json +1 -1
- package/build-module/accordion-heading/deprecated.js +1 -1
- package/build-module/accordion-heading/deprecated.js.map +2 -2
- package/build-module/accordion-panel/block.json +1 -1
- package/build-module/audio/index.js +12 -9
- package/build-module/audio/index.js.map +2 -2
- package/build-module/button/index.js +13 -10
- package/build-module/button/index.js.map +2 -2
- package/build-module/code/index.js +9 -6
- package/build-module/code/index.js.map +2 -2
- package/build-module/cover/edit/block-controls.js +27 -3
- package/build-module/cover/edit/block-controls.js.map +2 -2
- package/build-module/cover/edit/cover-placeholder.js +0 -1
- package/build-module/cover/edit/cover-placeholder.js.map +2 -2
- package/build-module/cover/edit/embed-video-url-input.js +67 -0
- package/build-module/cover/edit/embed-video-url-input.js.map +7 -0
- package/build-module/cover/edit/index.js +61 -0
- package/build-module/cover/edit/index.js.map +2 -2
- package/build-module/cover/embed-video-utils.js +122 -0
- package/build-module/cover/embed-video-utils.js.map +7 -0
- package/build-module/cover/index.js +10 -4
- package/build-module/cover/index.js.map +2 -2
- package/build-module/cover/save.js +13 -0
- package/build-module/cover/save.js.map +2 -2
- package/build-module/cover/shared.js +2 -0
- package/build-module/cover/shared.js.map +2 -2
- package/build-module/details/index.js +9 -6
- package/build-module/details/index.js.map +2 -2
- package/build-module/file/index.js +14 -14
- package/build-module/file/index.js.map +2 -2
- package/build-module/freeform/block.json +1 -1
- package/build-module/gallery/edit.js +0 -2
- package/build-module/gallery/edit.js.map +2 -2
- package/build-module/heading/index.js +9 -6
- package/build-module/heading/index.js.map +2 -2
- package/build-module/html/modal.js +128 -119
- package/build-module/html/modal.js.map +2 -2
- package/build-module/image/edit.js +0 -1
- package/build-module/image/edit.js.map +2 -2
- package/build-module/image/image.js +0 -1
- package/build-module/image/image.js.map +2 -2
- package/build-module/image/index.js +18 -18
- package/build-module/image/index.js.map +2 -2
- package/build-module/list-item/index.js +8 -6
- package/build-module/list-item/index.js.map +2 -2
- package/build-module/math/block.json +28 -1
- package/build-module/math/edit.js +4 -1
- package/build-module/math/edit.js.map +2 -2
- package/build-module/media-text/index.js +15 -8
- package/build-module/media-text/index.js.map +2 -2
- package/build-module/media-text/media-container.js +0 -2
- package/build-module/media-text/media-container.js.map +2 -2
- package/build-module/missing/block.json +1 -1
- package/build-module/missing/edit.js +2 -2
- package/build-module/missing/edit.js.map +1 -1
- package/build-module/more/index.js +9 -6
- package/build-module/more/index.js.map +2 -2
- package/build-module/navigation-link/edit.js +37 -12
- package/build-module/navigation-link/edit.js.map +2 -2
- package/build-module/navigation-link/index.js +11 -8
- package/build-module/navigation-link/index.js.map +2 -2
- package/build-module/navigation-submenu/index.js +11 -8
- package/build-module/navigation-submenu/index.js.map +2 -2
- package/build-module/paragraph/deprecated-attributes.js +37 -0
- package/build-module/paragraph/deprecated-attributes.js.map +7 -0
- package/build-module/paragraph/edit.js +2 -0
- package/build-module/paragraph/edit.js.map +2 -2
- package/build-module/paragraph/index.js +9 -6
- package/build-module/paragraph/index.js.map +2 -2
- package/build-module/pattern/block.json +1 -1
- package/build-module/preformatted/index.js +9 -6
- package/build-module/preformatted/index.js.map +2 -2
- package/build-module/pullquote/index.js +11 -11
- package/build-module/pullquote/index.js.map +2 -2
- package/build-module/search/index.js +14 -16
- package/build-module/search/index.js.map +2 -2
- package/build-module/social-link/index.js +11 -8
- package/build-module/social-link/index.js.map +2 -2
- package/build-module/template-part/edit/index.js +37 -7
- package/build-module/template-part/edit/index.js.map +2 -2
- package/build-module/template-part/edit/utils/hooks.js +2 -3
- package/build-module/template-part/edit/utils/hooks.js.map +2 -2
- package/build-module/term-count/index.js +1 -0
- package/build-module/term-count/index.js.map +2 -2
- package/build-module/term-name/index.js +1 -0
- package/build-module/term-name/index.js.map +2 -2
- package/build-module/verse/index.js +9 -6
- package/build-module/verse/index.js.map +2 -2
- package/build-module/video/index.js +12 -9
- package/build-module/video/index.js.map +2 -2
- package/build-style/accordion/style-rtl.css +3 -0
- package/build-style/accordion/style.css +3 -0
- package/build-style/accordion-heading/style-rtl.css +1 -2
- package/build-style/accordion-heading/style.css +1 -2
- package/build-style/accordion-item/style-rtl.css +0 -7
- package/build-style/accordion-item/style.css +0 -7
- package/build-style/accordion-panel/style-rtl.css +1 -4
- package/build-style/accordion-panel/style.css +1 -4
- package/build-style/cover/style-rtl.css +47 -0
- package/build-style/cover/style.css +47 -0
- package/build-style/editor-rtl.css +11 -13
- package/build-style/editor.css +11 -13
- package/build-style/html/editor-rtl.css +11 -13
- package/build-style/html/editor.css +11 -13
- package/build-style/style-rtl.css +52 -12
- package/build-style/style.css +52 -12
- package/package.json +37 -37
- package/src/accordion/style.scss +4 -0
- package/src/accordion/view.js +60 -3
- package/src/accordion-heading/block.json +1 -1
- package/src/accordion-heading/deprecated.js +1 -1
- package/src/accordion-heading/style.scss +1 -9
- package/src/accordion-item/index.php +1 -0
- package/src/accordion-item/style.scss +2 -9
- package/src/accordion-panel/block.json +1 -1
- package/src/accordion-panel/style.scss +1 -5
- package/src/audio/index.js +13 -9
- package/src/breadcrumbs/index.php +71 -82
- package/src/button/index.js +14 -10
- package/src/code/index.js +10 -6
- package/src/cover/edit/block-controls.js +26 -2
- package/src/cover/edit/cover-placeholder.js +0 -1
- package/src/cover/edit/embed-video-url-input.js +74 -0
- package/src/cover/edit/index.js +81 -0
- package/src/cover/embed-video-utils.js +196 -0
- package/src/cover/index.js +11 -4
- package/src/cover/index.php +106 -0
- package/src/cover/save.js +14 -0
- package/src/cover/shared.js +1 -0
- package/src/cover/style.scss +47 -0
- package/src/details/index.js +10 -6
- package/src/file/index.js +15 -14
- package/src/freeform/block.json +1 -1
- package/src/gallery/edit.js +0 -2
- package/src/heading/index.js +10 -6
- package/src/html/editor.scss +10 -15
- package/src/html/modal.js +15 -10
- package/src/image/edit.js +0 -1
- package/src/image/image.js +0 -1
- package/src/image/index.js +19 -18
- package/src/image/index.php +1 -0
- package/src/list-item/index.js +9 -6
- package/src/math/block.json +28 -1
- package/src/math/edit.js +4 -1
- package/src/media-text/index.js +16 -8
- package/src/media-text/media-container.js +0 -2
- package/src/missing/block.json +1 -1
- package/src/missing/edit.js +2 -2
- package/src/more/index.js +10 -6
- package/src/navigation-link/edit.js +72 -26
- package/src/navigation-link/index.js +12 -8
- package/src/navigation-submenu/index.js +12 -8
- package/src/paragraph/deprecated-attributes.js +45 -0
- package/src/paragraph/edit.js +2 -0
- package/src/paragraph/index.js +10 -6
- package/src/pattern/block.json +1 -1
- package/src/preformatted/index.js +10 -6
- package/src/pullquote/index.js +12 -11
- package/src/search/index.js +14 -15
- package/src/social-link/index.js +12 -8
- package/src/style.scss +1 -0
- package/src/template-part/edit/index.js +44 -6
- package/src/template-part/edit/utils/hooks.js +2 -4
- package/src/term-count/index.js +1 -0
- package/src/term-name/index.js +1 -0
- package/src/verse/index.js +10 -6
- package/src/video/index.js +13 -9
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
import { __ } from "@wordpress/i18n";
|
|
3
3
|
import { listItem as icon } from "@wordpress/icons";
|
|
4
4
|
import { privateApis } from "@wordpress/block-editor";
|
|
5
|
+
import { privateApis as blocksPrivateApis } from "@wordpress/blocks";
|
|
5
6
|
import initBlock from "../utils/init-block";
|
|
6
7
|
import metadata from "./block.json";
|
|
7
8
|
import edit from "./edit";
|
|
8
9
|
import save from "./save";
|
|
9
10
|
import transforms from "./transforms";
|
|
10
11
|
import { unlock } from "../lock-unlock";
|
|
12
|
+
var { fieldsKey, formKey } = unlock(blocksPrivateApis);
|
|
11
13
|
var { name } = metadata;
|
|
12
14
|
var settings = {
|
|
13
15
|
icon,
|
|
@@ -23,16 +25,16 @@ var settings = {
|
|
|
23
25
|
[unlock(privateApis).requiresWrapperOnCopy]: true
|
|
24
26
|
};
|
|
25
27
|
if (window.__experimentalContentOnlyPatternInsertion) {
|
|
26
|
-
settings
|
|
28
|
+
settings[fieldsKey] = [
|
|
27
29
|
{
|
|
30
|
+
id: "content",
|
|
28
31
|
label: __("Content"),
|
|
29
|
-
type: "
|
|
30
|
-
shownByDefault: true,
|
|
31
|
-
mapping: {
|
|
32
|
-
value: "content"
|
|
33
|
-
}
|
|
32
|
+
type: "richtext"
|
|
34
33
|
}
|
|
35
34
|
];
|
|
35
|
+
settings[formKey] = {
|
|
36
|
+
fields: ["content"]
|
|
37
|
+
};
|
|
36
38
|
}
|
|
37
39
|
var init = () => initBlock({ name, metadata, settings });
|
|
38
40
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/list-item/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { listItem as icon } from '@wordpress/icons';\nimport { privateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport save from './save';\nimport transforms from './transforms';\nimport { unlock } from '../lock-unlock';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\t...attributes,\n\t\t\tcontent: attributes.content + attributesToMerge.content,\n\t\t};\n\t},\n\ttransforms,\n\t[ unlock( privateApis ).requiresWrapperOnCopy ]: true,\n};\n\nif ( window.__experimentalContentOnlyPatternInsertion ) {\n\tsettings
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,YAAY,YAAY;AACjC,SAAS,mBAAmB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { listItem as icon } from '@wordpress/icons';\nimport { privateApis } from '@wordpress/block-editor';\nimport { privateApis as blocksPrivateApis } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport save from './save';\nimport transforms from './transforms';\nimport { unlock } from '../lock-unlock';\n\nconst { fieldsKey, formKey } = unlock( blocksPrivateApis );\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\t...attributes,\n\t\t\tcontent: attributes.content + attributesToMerge.content,\n\t\t};\n\t},\n\ttransforms,\n\t[ unlock( privateApis ).requiresWrapperOnCopy ]: true,\n};\n\nif ( window.__experimentalContentOnlyPatternInsertion ) {\n\tsettings[ fieldsKey ] = [\n\t\t{\n\t\t\tid: 'content',\n\t\t\tlabel: __( 'Content' ),\n\t\t\ttype: 'richtext',\n\t\t},\n\t];\n\tsettings[ formKey ] = {\n\t\tfields: [ 'content' ],\n\t};\n}\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,YAAY,YAAY;AACjC,SAAS,mBAAmB;AAC5B,SAAS,eAAe,yBAAyB;AAKjD,OAAO,eAAe;AACtB,OAAO,cAAc;AACrB,OAAO,UAAU;AACjB,OAAO,UAAU;AACjB,OAAO,gBAAgB;AACvB,SAAS,cAAc;AAEvB,IAAM,EAAE,WAAW,QAAQ,IAAI,OAAQ,iBAAkB;AAEzD,IAAM,EAAE,KAAK,IAAI;AAIV,IAAM,WAAW;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA,MAAO,YAAY,mBAAoB;AACtC,WAAO;AAAA,MACN,GAAG;AAAA,MACH,SAAS,WAAW,UAAU,kBAAkB;AAAA,IACjD;AAAA,EACD;AAAA,EACA;AAAA,EACA,CAAE,OAAQ,WAAY,EAAE,qBAAsB,GAAG;AAClD;AAEA,IAAK,OAAO,2CAA4C;AACvD,WAAU,SAAU,IAAI;AAAA,IACvB;AAAA,MACC,IAAI;AAAA,MACJ,OAAO,GAAI,SAAU;AAAA,MACrB,MAAM;AAAA,IACP;AAAA,EACD;AACA,WAAU,OAAQ,IAAI;AAAA,IACrB,QAAQ,CAAE,SAAU;AAAA,EACrB;AACD;AAEO,IAAM,OAAO,MAAM,UAAW,EAAE,MAAM,UAAU,SAAS,CAAE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -8,7 +8,34 @@
|
|
|
8
8
|
"keywords": [ "equation", "formula", "latex", "mathematics" ],
|
|
9
9
|
"textdomain": "default",
|
|
10
10
|
"supports": {
|
|
11
|
-
"html": false
|
|
11
|
+
"html": false,
|
|
12
|
+
"__experimentalBorder": {
|
|
13
|
+
"color": true,
|
|
14
|
+
"radius": true,
|
|
15
|
+
"style": true,
|
|
16
|
+
"width": true
|
|
17
|
+
},
|
|
18
|
+
"color": {
|
|
19
|
+
"gradients": true,
|
|
20
|
+
"__experimentalDefaultControls": {
|
|
21
|
+
"background": true,
|
|
22
|
+
"text": true
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"spacing": {
|
|
26
|
+
"margin": true,
|
|
27
|
+
"padding": true,
|
|
28
|
+
"__experimentalDefaultControls": {
|
|
29
|
+
"margin": false,
|
|
30
|
+
"padding": false
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"typography": {
|
|
34
|
+
"fontSize": true,
|
|
35
|
+
"__experimentalDefaultControls": {
|
|
36
|
+
"fontSize": true
|
|
37
|
+
}
|
|
38
|
+
}
|
|
12
39
|
},
|
|
13
40
|
"attributes": {
|
|
14
41
|
"latex": {
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
} from "@wordpress/components";
|
|
13
13
|
import { useState, useEffect, useRef } from "@wordpress/element";
|
|
14
14
|
import { useDispatch } from "@wordpress/data";
|
|
15
|
+
import { speak } from "@wordpress/a11y";
|
|
15
16
|
import { unlock } from "../lock-unlock";
|
|
16
17
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
17
18
|
var { Badge } = unlock(componentsPrivateApis);
|
|
@@ -57,7 +58,8 @@ function MathEdit({ attributes, setAttributes, isSelected }) {
|
|
|
57
58
|
placement: "bottom-start",
|
|
58
59
|
offset: 8,
|
|
59
60
|
anchor: blockRef,
|
|
60
|
-
focusOnMount:
|
|
61
|
+
focusOnMount: false,
|
|
62
|
+
__unstableSlotName: "__unstable-block-tools-after",
|
|
61
63
|
children: /* @__PURE__ */ jsx("div", { style: { padding: "4px", minWidth: "300px" }, children: /* @__PURE__ */ jsxs(VStack, { spacing: 1, children: [
|
|
62
64
|
/* @__PURE__ */ jsx(
|
|
63
65
|
TextareaControl,
|
|
@@ -81,6 +83,7 @@ function MathEdit({ attributes, setAttributes, isSelected }) {
|
|
|
81
83
|
setError(null);
|
|
82
84
|
} catch (err) {
|
|
83
85
|
setError(err.message);
|
|
86
|
+
speak(err.message);
|
|
84
87
|
}
|
|
85
88
|
setAttributes({
|
|
86
89
|
mathML: newMathML,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/math/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tTextareaControl,\n\tPopover,\n\t__experimentalVStack as VStack,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst { Badge } = unlock( componentsPrivateApis );\n\nexport default function MathEdit( { attributes, setAttributes, isSelected } ) {\n\tconst { latex, mathML } = attributes;\n\tconst [ blockRef, setBlockRef ] = useState();\n\tconst [ error, setError ] = useState( null );\n\tconst [ latexToMathML, setLatexToMathML ] = useState();\n\tconst initialLatex = useRef( latex );\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\timport( '@wordpress/latex-to-mathml' ).then( ( module ) => {\n\t\t\tsetLatexToMathML( () => module.default );\n\t\t\tif ( initialLatex.current ) {\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tmathML: module.default( initialLatex.current, {\n\t\t\t\t\t\tdisplayMode: true,\n\t\t\t\t\t} ),\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t}, [\n\t\tinitialLatex,\n\t\tsetAttributes,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t] );\n\n\tconst blockProps = useBlockProps( {\n\t\tref: setBlockRef,\n\t\tposition: 'relative',\n\t} );\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t{ mathML ? (\n\t\t\t\t<math\n\t\t\t\t\t// We can't spread block props on the math element because\n\t\t\t\t\t// it only supports a limited amount of global attributes.\n\t\t\t\t\t// For example, draggable will have no effect.\n\t\t\t\t\tdisplay=\"block\"\n\t\t\t\t\tdangerouslySetInnerHTML={ { __html: mathML } }\n\t\t\t\t/>\n\t\t\t) : (\n\t\t\t\t'\\u200B'\n\t\t\t) }\n\t\t\t{ isSelected && (\n\t\t\t\t<Popover\n\t\t\t\t\tplacement=\"bottom-start\"\n\t\t\t\t\toffset={ 8 }\n\t\t\t\t\tanchor={ blockRef }\n\t\t\t\t\tfocusOnMount=\"
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA,SAAS;AAAA,OACH;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,EACxB,eAAe;AAAA,OACT;AACP,SAAS,UAAU,WAAW,cAAc;AAC5C,SAAS,mBAAmB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tTextareaControl,\n\tPopover,\n\t__experimentalVStack as VStack,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst { Badge } = unlock( componentsPrivateApis );\n\nexport default function MathEdit( { attributes, setAttributes, isSelected } ) {\n\tconst { latex, mathML } = attributes;\n\tconst [ blockRef, setBlockRef ] = useState();\n\tconst [ error, setError ] = useState( null );\n\tconst [ latexToMathML, setLatexToMathML ] = useState();\n\tconst initialLatex = useRef( latex );\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\timport( '@wordpress/latex-to-mathml' ).then( ( module ) => {\n\t\t\tsetLatexToMathML( () => module.default );\n\t\t\tif ( initialLatex.current ) {\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tmathML: module.default( initialLatex.current, {\n\t\t\t\t\t\tdisplayMode: true,\n\t\t\t\t\t} ),\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t}, [\n\t\tinitialLatex,\n\t\tsetAttributes,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t] );\n\n\tconst blockProps = useBlockProps( {\n\t\tref: setBlockRef,\n\t\tposition: 'relative',\n\t} );\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t{ mathML ? (\n\t\t\t\t<math\n\t\t\t\t\t// We can't spread block props on the math element because\n\t\t\t\t\t// it only supports a limited amount of global attributes.\n\t\t\t\t\t// For example, draggable will have no effect.\n\t\t\t\t\tdisplay=\"block\"\n\t\t\t\t\tdangerouslySetInnerHTML={ { __html: mathML } }\n\t\t\t\t/>\n\t\t\t) : (\n\t\t\t\t'\\u200B'\n\t\t\t) }\n\t\t\t{ isSelected && (\n\t\t\t\t<Popover\n\t\t\t\t\tplacement=\"bottom-start\"\n\t\t\t\t\toffset={ 8 }\n\t\t\t\t\tanchor={ blockRef }\n\t\t\t\t\tfocusOnMount={ false }\n\t\t\t\t\t__unstableSlotName=\"__unstable-block-tools-after\"\n\t\t\t\t>\n\t\t\t\t\t<div style={ { padding: '4px', minWidth: '300px' } }>\n\t\t\t\t\t\t<VStack spacing={ 1 }>\n\t\t\t\t\t\t\t<TextareaControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tlabel={ __( 'LaTeX math syntax' ) }\n\t\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\t\tvalue={ latex }\n\t\t\t\t\t\t\t\tclassName=\"wp-block-math__textarea-control\"\n\t\t\t\t\t\t\t\tonChange={ ( newLatex ) => {\n\t\t\t\t\t\t\t\t\tif ( ! latexToMathML ) {\n\t\t\t\t\t\t\t\t\t\tsetAttributes( { latex: newLatex } );\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tlet newMathML = '';\n\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\tnewMathML = latexToMathML( newLatex, {\n\t\t\t\t\t\t\t\t\t\t\tdisplayMode: true,\n\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\tsetError( null );\n\t\t\t\t\t\t\t\t\t} catch ( err ) {\n\t\t\t\t\t\t\t\t\t\tsetError( err.message );\n\t\t\t\t\t\t\t\t\t\tspeak( err.message );\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tmathML: newMathML,\n\t\t\t\t\t\t\t\t\t\tlatex: newLatex,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tplaceholder={ __( 'e.g., x^2, \\\\frac{a}{b}' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{ error && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<Badge\n\t\t\t\t\t\t\t\t\t\tintent=\"error\"\n\t\t\t\t\t\t\t\t\t\tclassName=\"wp-block-math__error\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ error }\n\t\t\t\t\t\t\t\t\t</Badge>\n\t\t\t\t\t\t\t\t\t<style children=\".wp-block-math__error .components-badge__content{white-space:normal}\" />\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</VStack>\n\t\t\t\t\t</div>\n\t\t\t\t</Popover>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA,SAAS;AAAA,OACH;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,EACxB,eAAe;AAAA,OACT;AACP,SAAS,UAAU,WAAW,cAAc;AAC5C,SAAS,mBAAmB;AAC5B,SAAS,aAAa;AAKtB,SAAS,cAAc;AAuCnB,SAkDI,UAlDJ,KAkDI,YAlDJ;AArCJ,IAAM,EAAE,MAAM,IAAI,OAAQ,qBAAsB;AAEjC,SAAR,SAA2B,EAAE,YAAY,eAAe,WAAW,GAAI;AAC7E,QAAM,EAAE,OAAO,OAAO,IAAI;AAC1B,QAAM,CAAE,UAAU,WAAY,IAAI,SAAS;AAC3C,QAAM,CAAE,OAAO,QAAS,IAAI,SAAU,IAAK;AAC3C,QAAM,CAAE,eAAe,gBAAiB,IAAI,SAAS;AACrD,QAAM,eAAe,OAAQ,KAAM;AACnC,QAAM,EAAE,wCAAwC,IAC/C,YAAa,gBAAiB;AAE/B,YAAW,MAAM;AAChB,WAAQ,4BAA6B,EAAE,KAAM,CAAE,WAAY;AAC1D,uBAAkB,MAAM,OAAO,OAAQ;AACvC,UAAK,aAAa,SAAU;AAC3B,gDAAwC;AACxC,sBAAe;AAAA,UACd,QAAQ,OAAO,QAAS,aAAa,SAAS;AAAA,YAC7C,aAAa;AAAA,UACd,CAAE;AAAA,QACH,CAAE;AA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,YACH;AAAA,YACA,oBAAC,WAAM,UAAS,wEAAuE;AAAA,aACxF;AAAA,WAEF,GACD;AAAA;AAAA,IACD;AAAA,KAEF;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
// packages/block-library/src/media-text/index.js
|
|
2
2
|
import { __ } from "@wordpress/i18n";
|
|
3
3
|
import { mediaAndText as icon } from "@wordpress/icons";
|
|
4
|
+
import { privateApis as blocksPrivateApis } from "@wordpress/blocks";
|
|
4
5
|
import initBlock from "../utils/init-block";
|
|
5
6
|
import deprecated from "./deprecated";
|
|
6
7
|
import edit from "./edit";
|
|
7
8
|
import metadata from "./block.json";
|
|
8
9
|
import save from "./save";
|
|
9
10
|
import transforms from "./transforms";
|
|
11
|
+
import { unlock } from "../lock-unlock";
|
|
12
|
+
var { fieldsKey, formKey } = unlock(blocksPrivateApis);
|
|
10
13
|
var { name } = metadata;
|
|
11
14
|
var settings = {
|
|
12
15
|
icon,
|
|
@@ -40,15 +43,16 @@ var settings = {
|
|
|
40
43
|
deprecated
|
|
41
44
|
};
|
|
42
45
|
if (window.__experimentalContentOnlyPatternInsertion) {
|
|
43
|
-
settings
|
|
46
|
+
settings[fieldsKey] = [
|
|
44
47
|
{
|
|
48
|
+
id: "media",
|
|
45
49
|
label: __("Media"),
|
|
46
|
-
type: "
|
|
47
|
-
shownByDefault: true,
|
|
50
|
+
type: "media",
|
|
48
51
|
mapping: {
|
|
49
52
|
id: "mediaId",
|
|
50
53
|
type: "mediaType",
|
|
51
|
-
|
|
54
|
+
url: "mediaUrl",
|
|
55
|
+
link: "mediaLink"
|
|
52
56
|
},
|
|
53
57
|
args: {
|
|
54
58
|
allowedTypes: ["image", "video"],
|
|
@@ -56,16 +60,19 @@ if (window.__experimentalContentOnlyPatternInsertion) {
|
|
|
56
60
|
}
|
|
57
61
|
},
|
|
58
62
|
{
|
|
63
|
+
id: "link",
|
|
59
64
|
label: __("Link"),
|
|
60
|
-
type: "
|
|
61
|
-
shownByDefault: false,
|
|
65
|
+
type: "link",
|
|
62
66
|
mapping: {
|
|
63
|
-
|
|
67
|
+
url: "href",
|
|
64
68
|
rel: "rel",
|
|
65
|
-
|
|
69
|
+
linkTarget: "linkTarget"
|
|
66
70
|
}
|
|
67
71
|
}
|
|
68
72
|
];
|
|
73
|
+
settings[formKey] = {
|
|
74
|
+
fields: ["media"]
|
|
75
|
+
};
|
|
69
76
|
}
|
|
70
77
|
var init = () => initBlock({ name, metadata, settings });
|
|
71
78
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/media-text/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { mediaAndText as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tviewportWidth: 601, // Columns collapse \"@media (max-width: 600px)\".\n\t\tattributes: {\n\t\t\tmediaType: 'image',\n\t\t\tmediaUrl:\n\t\t\t\t'https://s.w.org/images/core/5.3/Biologia_Centrali-Americana_-_Cantorchilus_semibadius_1902.jpg',\n\t\t},\n\t\tinnerBlocks: [\n\t\t\t{\n\t\t\t\tname: 'core/paragraph',\n\t\t\t\tattributes: {\n\t\t\t\t\tcontent: __(\n\t\t\t\t\t\t'The wren<br>Earns his living<br>Noiselessly.'\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'core/paragraph',\n\t\t\t\tattributes: {\n\t\t\t\t\tcontent: __( '\u2014 Kobayashi Issa (\u4E00\u8336)' ),\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n\ttransforms,\n\tedit,\n\tsave,\n\tdeprecated,\n};\n\nif ( window.__experimentalContentOnlyPatternInsertion ) {\n\tsettings
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,gBAAgB,YAAY;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { mediaAndText as icon } from '@wordpress/icons';\nimport { privateApis as blocksPrivateApis } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\nimport { unlock } from '../lock-unlock';\n\nconst { fieldsKey, formKey } = unlock( blocksPrivateApis );\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tviewportWidth: 601, // Columns collapse \"@media (max-width: 600px)\".\n\t\tattributes: {\n\t\t\tmediaType: 'image',\n\t\t\tmediaUrl:\n\t\t\t\t'https://s.w.org/images/core/5.3/Biologia_Centrali-Americana_-_Cantorchilus_semibadius_1902.jpg',\n\t\t},\n\t\tinnerBlocks: [\n\t\t\t{\n\t\t\t\tname: 'core/paragraph',\n\t\t\t\tattributes: {\n\t\t\t\t\tcontent: __(\n\t\t\t\t\t\t'The wren<br>Earns his living<br>Noiselessly.'\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'core/paragraph',\n\t\t\t\tattributes: {\n\t\t\t\t\tcontent: __( '\u2014 Kobayashi Issa (\u4E00\u8336)' ),\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n\ttransforms,\n\tedit,\n\tsave,\n\tdeprecated,\n};\n\nif ( window.__experimentalContentOnlyPatternInsertion ) {\n\tsettings[ fieldsKey ] = [\n\t\t{\n\t\t\tid: 'media',\n\t\t\tlabel: __( 'Media' ),\n\t\t\ttype: 'media',\n\t\t\tmapping: {\n\t\t\t\tid: 'mediaId',\n\t\t\t\ttype: 'mediaType',\n\t\t\t\turl: 'mediaUrl',\n\t\t\t\tlink: 'mediaLink',\n\t\t\t},\n\t\t\targs: {\n\t\t\t\tallowedTypes: [ 'image', 'video' ],\n\t\t\t\tmultiple: false,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: 'link',\n\t\t\tlabel: __( 'Link' ),\n\t\t\ttype: 'link',\n\t\t\tmapping: {\n\t\t\t\turl: 'href',\n\t\t\t\trel: 'rel',\n\t\t\t\tlinkTarget: 'linkTarget',\n\t\t\t},\n\t\t},\n\t];\n\tsettings[ formKey ] = {\n\t\tfields: [ 'media' ],\n\t};\n}\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,gBAAgB,YAAY;AACrC,SAAS,eAAe,yBAAyB;AAKjD,OAAO,eAAe;AACtB,OAAO,gBAAgB;AACvB,OAAO,UAAU;AACjB,OAAO,cAAc;AACrB,OAAO,UAAU;AACjB,OAAO,gBAAgB;AACvB,SAAS,cAAc;AAEvB,IAAM,EAAE,WAAW,QAAQ,IAAI,OAAQ,iBAAkB;AAEzD,IAAM,EAAE,KAAK,IAAI;AAIV,IAAM,WAAW;AAAA,EACvB;AAAA,EACA,SAAS;AAAA,IACR,eAAe;AAAA;AAAA,IACf,YAAY;AAAA,MACX,WAAW;AAAA,MACX,UACC;AAAA,IACF;AAAA,IACA,aAAa;AAAA,MACZ;AAAA,QACC,MAAM;AAAA,QACN,YAAY;AAAA,UACX,SAAS;AAAA,YACR;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,MACA;AAAA,QACC,MAAM;AAAA,QACN,YAAY;AAAA,UACX,SAAS,GAAI,sCAAwB;AAAA,QACtC;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEA,IAAK,OAAO,2CAA4C;AACvD,WAAU,SAAU,IAAI;AAAA,IACvB;AAAA,MACC,IAAI;AAAA,MACJ,OAAO,GAAI,OAAQ;AAAA,MACnB,MAAM;AAAA,MACN,SAAS;AAAA,QACR,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,KAAK;AAAA,QACL,MAAM;AAAA,MACP;AAAA,MACA,MAAM;AAAA,QACL,cAAc,CAAE,SAAS,OAAQ;AAAA,QACjC,UAAU;AAAA,MACX;AAAA,IACD;AAAA,IACA;AAAA,MACC,IAAI;AAAA,MACJ,OAAO,GAAI,MAAO;AAAA,MAClB,MAAM;AAAA,MACN,SAAS;AAAA,QACR,KAAK;AAAA,QACL,KAAK;AAAA,QACL,YAAY;AAAA,MACb;AAAA,IACD;AAAA,EACD;AACA,WAAU,OAAQ,IAAI;AAAA,IACrB,QAAQ,CAAE,OAAQ;AAAA,EACnB;AACD;AAEO,IAAM,OAAO,MAAM,UAAW,EAAE,MAAM,UAAU,SAAS,CAAE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -46,7 +46,6 @@ function ToolbarEditButton({
|
|
|
46
46
|
mediaId,
|
|
47
47
|
mediaURL: mediaUrl,
|
|
48
48
|
allowedTypes: ALLOWED_MEDIA_TYPES,
|
|
49
|
-
accept: "image/*,video/*",
|
|
50
49
|
onSelect: onSelectMedia,
|
|
51
50
|
onToggleFeaturedImage: toggleUseFeaturedImage,
|
|
52
51
|
useFeaturedImage,
|
|
@@ -73,7 +72,6 @@ function PlaceholderContainer({
|
|
|
73
72
|
},
|
|
74
73
|
className,
|
|
75
74
|
onSelect: onSelectMedia,
|
|
76
|
-
accept: "image/*,video/*",
|
|
77
75
|
onToggleFeaturedImage: toggleUseFeaturedImage,
|
|
78
76
|
allowedTypes: ALLOWED_MEDIA_TYPES,
|
|
79
77
|
onError: onUploadError,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/media-text/media-container.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { ResizableBox, Spinner, Placeholder } from '@wordpress/components';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useDispatch } from '@wordpress/data';\nimport { forwardRef } from '@wordpress/element';\nimport { isBlobURL } from '@wordpress/blob';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { media as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { imageFillStyles } from './image-fill';\n\n/**\n * Constants\n */\nconst ALLOWED_MEDIA_TYPES = [ 'image', 'video' ];\nconst noop = () => {};\n\nconst ResizableBoxContainer = forwardRef(\n\t( { isSelected, isStackedOnMobile, ...props }, ref ) => {\n\t\tconst isMobile = useViewportMatch( 'small', '<' );\n\t\treturn (\n\t\t\t<ResizableBox\n\t\t\t\tref={ ref }\n\t\t\t\tshowHandle={\n\t\t\t\t\tisSelected && ( ! isMobile || ! isStackedOnMobile )\n\t\t\t\t}\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t);\n\t}\n);\n\nfunction ToolbarEditButton( {\n\tmediaId,\n\tmediaUrl,\n\tonSelectMedia,\n\ttoggleUseFeaturedImage,\n\tuseFeaturedImage,\n} ) {\n\treturn (\n\t\t<BlockControls group=\"other\">\n\t\t\t<MediaReplaceFlow\n\t\t\t\tmediaId={ mediaId }\n\t\t\t\tmediaURL={ mediaUrl }\n\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,cAAc,SAAS,mBAAmB;AACnD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,UAAU;AACnB,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAC1B,SAAS,SAAS,oBAAoB;AACtC,SAAS,SAAS,YAAY;AAK9B,SAAS,uBAAuB;AAY7B,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { ResizableBox, Spinner, Placeholder } from '@wordpress/components';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useDispatch } from '@wordpress/data';\nimport { forwardRef } from '@wordpress/element';\nimport { isBlobURL } from '@wordpress/blob';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { media as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { imageFillStyles } from './image-fill';\n\n/**\n * Constants\n */\nconst ALLOWED_MEDIA_TYPES = [ 'image', 'video' ];\nconst noop = () => {};\n\nconst ResizableBoxContainer = forwardRef(\n\t( { isSelected, isStackedOnMobile, ...props }, ref ) => {\n\t\tconst isMobile = useViewportMatch( 'small', '<' );\n\t\treturn (\n\t\t\t<ResizableBox\n\t\t\t\tref={ ref }\n\t\t\t\tshowHandle={\n\t\t\t\t\tisSelected && ( ! isMobile || ! isStackedOnMobile )\n\t\t\t\t}\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t);\n\t}\n);\n\nfunction ToolbarEditButton( {\n\tmediaId,\n\tmediaUrl,\n\tonSelectMedia,\n\ttoggleUseFeaturedImage,\n\tuseFeaturedImage,\n} ) {\n\treturn (\n\t\t<BlockControls group=\"other\">\n\t\t\t<MediaReplaceFlow\n\t\t\t\tmediaId={ mediaId }\n\t\t\t\tmediaURL={ mediaUrl }\n\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\tonSelect={ onSelectMedia }\n\t\t\t\tonToggleFeaturedImage={ toggleUseFeaturedImage }\n\t\t\t\tuseFeaturedImage={ useFeaturedImage }\n\t\t\t\tonReset={ () => onSelectMedia( undefined ) }\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n}\n\nfunction PlaceholderContainer( {\n\tclassName,\n\tmediaUrl,\n\tonSelectMedia,\n\ttoggleUseFeaturedImage,\n} ) {\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t};\n\n\treturn (\n\t\t<MediaPlaceholder\n\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\tlabels={ {\n\t\t\t\ttitle: __( 'Media area' ),\n\t\t\t} }\n\t\t\tclassName={ className }\n\t\t\tonSelect={ onSelectMedia }\n\t\t\tonToggleFeaturedImage={ toggleUseFeaturedImage }\n\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\tonError={ onUploadError }\n\t\t\tdisableMediaButtons={ mediaUrl }\n\t\t/>\n\t);\n}\n\nfunction MediaContainer( props, ref ) {\n\tconst {\n\t\tclassName,\n\t\tcommitWidthChange,\n\t\tfocalPoint,\n\t\timageFill,\n\t\tisSelected,\n\t\tisStackedOnMobile,\n\t\tmediaAlt,\n\t\tmediaId,\n\t\tmediaPosition,\n\t\tmediaType,\n\t\tmediaUrl,\n\t\tmediaWidth,\n\t\tonSelectMedia,\n\t\tonWidthChange,\n\t\tenableResize,\n\t\ttoggleUseFeaturedImage,\n\t\tuseFeaturedImage,\n\t\tfeaturedImageURL,\n\t\tfeaturedImageAlt,\n\t\trefMedia,\n\t} = props;\n\n\tconst isTemporaryMedia = ! mediaId && isBlobURL( mediaUrl );\n\n\tconst { toggleSelection } = useDispatch( blockEditorStore );\n\n\tif ( mediaUrl || featuredImageURL || useFeaturedImage ) {\n\t\tconst onResizeStart = () => {\n\t\t\ttoggleSelection( false );\n\t\t};\n\t\tconst onResize = ( event, direction, elt ) => {\n\t\t\tonWidthChange( parseInt( elt.style.width ) );\n\t\t};\n\t\tconst onResizeStop = ( event, direction, elt ) => {\n\t\t\ttoggleSelection( true );\n\t\t\tcommitWidthChange( parseInt( elt.style.width ) );\n\t\t};\n\t\tconst enablePositions = {\n\t\t\tright: enableResize && mediaPosition === 'left',\n\t\t\tleft: enableResize && mediaPosition === 'right',\n\t\t};\n\n\t\tconst positionStyles =\n\t\t\tmediaType === 'image' && imageFill\n\t\t\t\t? imageFillStyles( mediaUrl || featuredImageURL, focalPoint )\n\t\t\t\t: {};\n\n\t\tconst mediaTypeRenderers = {\n\t\t\timage: () =>\n\t\t\t\tuseFeaturedImage && featuredImageURL ? (\n\t\t\t\t\t<img\n\t\t\t\t\t\tref={ refMedia }\n\t\t\t\t\t\tsrc={ featuredImageURL }\n\t\t\t\t\t\talt={ featuredImageAlt }\n\t\t\t\t\t\tstyle={ positionStyles }\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\tmediaUrl && (\n\t\t\t\t\t\t<img\n\t\t\t\t\t\t\tref={ refMedia }\n\t\t\t\t\t\t\tsrc={ mediaUrl }\n\t\t\t\t\t\t\talt={ mediaAlt }\n\t\t\t\t\t\t\tstyle={ positionStyles }\n\t\t\t\t\t\t/>\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\tvideo: () => <video controls ref={ refMedia } src={ mediaUrl } />,\n\t\t};\n\n\t\treturn (\n\t\t\t<ResizableBoxContainer\n\t\t\t\tas=\"figure\"\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\tclassName,\n\t\t\t\t\t'editor-media-container__resizer',\n\t\t\t\t\t{ 'is-transient': isTemporaryMedia }\n\t\t\t\t) }\n\t\t\t\tsize={ { width: mediaWidth + '%' } }\n\t\t\t\tminWidth=\"10%\"\n\t\t\t\tmaxWidth=\"100%\"\n\t\t\t\tenable={ enablePositions }\n\t\t\t\tonResizeStart={ onResizeStart }\n\t\t\t\tonResize={ onResize }\n\t\t\t\tonResizeStop={ onResizeStop }\n\t\t\t\taxis=\"x\"\n\t\t\t\tisSelected={ isSelected }\n\t\t\t\tisStackedOnMobile={ isStackedOnMobile }\n\t\t\t\tref={ ref }\n\t\t\t>\n\t\t\t\t<ToolbarEditButton\n\t\t\t\t\tonSelectMedia={ onSelectMedia }\n\t\t\t\t\tmediaUrl={\n\t\t\t\t\t\tuseFeaturedImage && featuredImageURL\n\t\t\t\t\t\t\t? featuredImageURL\n\t\t\t\t\t\t\t: mediaUrl\n\t\t\t\t\t}\n\t\t\t\t\tmediaId={ mediaId }\n\t\t\t\t\ttoggleUseFeaturedImage={ toggleUseFeaturedImage }\n\t\t\t\t\tuseFeaturedImage={ useFeaturedImage }\n\t\t\t\t/>\n\t\t\t\t{ ( mediaTypeRenderers[ mediaType ] || noop )() }\n\t\t\t\t{ isTemporaryMedia && <Spinner /> }\n\t\t\t\t{ ! useFeaturedImage && <PlaceholderContainer { ...props } /> }\n\t\t\t\t{ ! featuredImageURL && useFeaturedImage && (\n\t\t\t\t\t<Placeholder\n\t\t\t\t\t\tclassName=\"wp-block-media-text--placeholder-image\"\n\t\t\t\t\t\tstyle={ positionStyles }\n\t\t\t\t\t\twithIllustration\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</ResizableBoxContainer>\n\t\t);\n\t}\n\n\treturn <PlaceholderContainer { ...props } />;\n}\n\nexport default forwardRef( MediaContainer );\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,cAAc,SAAS,mBAAmB;AACnD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,UAAU;AACnB,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAC1B,SAAS,SAAS,oBAAoB;AACtC,SAAS,SAAS,YAAY;AAK9B,SAAS,uBAAuB;AAY7B,cAqIA,YArIA;AAPH,IAA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AAa,IAAI;AAAA,QACjC,UAAS;AAAA,QACT,UAAS;AAAA,QACT,QAAS;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACA,MAAK;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QAEA;AAAA;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA,UACC,oBAAoB,mBACjB,mBACA;AAAA,cAEJ;AAAA,cACA;AAAA,cACA;AAAA;AAAA,UACD;AAAA,WACI,mBAAoB,SAAU,KAAK,MAAO;AAAA,UAC5C,oBAAoB,oBAAC,WAAQ;AAAA,UAC7B,CAAE,oBAAoB,oBAAC,wBAAuB,GAAG,OAAQ;AAAA,UACzD,CAAE,oBAAoB,oBACvB;AAAA,YAAC;AAAA;AAAA,cACA,WAAU;AAAA,cACV,OAAQ;AAAA,cACR,kBAAgB;AAAA;AAAA,UACjB;AAAA;AAAA;AAAA,IAEF;AAAA,EAEF;AAEA,SAAO,oBAAC,wBAAuB,GAAG,OAAQ;AAC3C;AAEA,IAAO,0BAAQ,WAAY,cAAe;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -54,12 +54,12 @@ function MissingEdit({ attributes, clientId }) {
|
|
|
54
54
|
if (hasContent && !hasFreeformBlock && (!originalName || originalName === "core/freeform")) {
|
|
55
55
|
if (hasHTMLBlock) {
|
|
56
56
|
messageHTML = __(
|
|
57
|
-
"It appears you are trying to use the deprecated Classic block. You can leave this block intact, convert its content to a Custom HTML block, or remove it entirely. Alternatively, you can
|
|
57
|
+
"It appears you are trying to use the deprecated Classic block. You can leave this block intact, convert its content to a Custom HTML block, or remove it entirely. Alternatively, if you have unsaved changes, you can save them and refresh to use the Classic block."
|
|
58
58
|
);
|
|
59
59
|
actions.push(convertToHtmlButton);
|
|
60
60
|
} else {
|
|
61
61
|
messageHTML = __(
|
|
62
|
-
"It appears you are trying to use the deprecated Classic block. You can leave this block intact, or remove it entirely. Alternatively, you can
|
|
62
|
+
"It appears you are trying to use the deprecated Classic block. You can leave this block intact, or remove it entirely. Alternatively, if you have unsaved changes, you can save them and refresh to use the Classic block."
|
|
63
63
|
);
|
|
64
64
|
}
|
|
65
65
|
} else if (hasContent && hasHTMLBlock) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/missing/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { RawHTML } from '@wordpress/element';\nimport { Button } from '@wordpress/components';\nimport { createBlock } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tWarning,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { safeHTML } from '@wordpress/dom';\n\nexport default function MissingEdit( { attributes, clientId } ) {\n\tconst { originalName, originalUndelimitedContent } = attributes;\n\tconst hasContent = !! originalUndelimitedContent;\n\tconst { hasFreeformBlock, hasHTMLBlock } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canInsertBlockType, getBlockRootClientId } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\thasFreeformBlock: canInsertBlockType(\n\t\t\t\t\t'core/freeform',\n\t\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t\t),\n\t\t\t\thasHTMLBlock: canInsertBlockType(\n\t\t\t\t\t'core/html',\n\t\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { replaceBlock } = useDispatch( blockEditorStore );\n\n\tfunction convertToHTML() {\n\t\treplaceBlock(\n\t\t\tclientId,\n\t\t\tcreateBlock( 'core/html', {\n\t\t\t\tcontent: originalUndelimitedContent,\n\t\t\t} )\n\t\t);\n\t}\n\n\tconst actions = [];\n\tlet messageHTML;\n\n\tconst convertToHtmlButton = (\n\t\t<Button\n\t\t\t__next40pxDefaultSize\n\t\t\tkey=\"convert\"\n\t\t\tonClick={ convertToHTML }\n\t\t\tvariant=\"primary\"\n\t\t>\n\t\t\t{ __( 'Keep as HTML' ) }\n\t\t</Button>\n\t);\n\n\tif (\n\t\thasContent &&\n\t\t! hasFreeformBlock &&\n\t\t( ! originalName || originalName === 'core/freeform' )\n\t) {\n\t\tif ( hasHTMLBlock ) {\n\t\t\tmessageHTML = __(\n\t\t\t\t'It appears you are trying to use the deprecated Classic block. You can leave this block intact, convert its content to a Custom HTML block, or remove it entirely. Alternatively, you can
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { RawHTML } from '@wordpress/element';\nimport { Button } from '@wordpress/components';\nimport { createBlock } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tWarning,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { safeHTML } from '@wordpress/dom';\n\nexport default function MissingEdit( { attributes, clientId } ) {\n\tconst { originalName, originalUndelimitedContent } = attributes;\n\tconst hasContent = !! originalUndelimitedContent;\n\tconst { hasFreeformBlock, hasHTMLBlock } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canInsertBlockType, getBlockRootClientId } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\thasFreeformBlock: canInsertBlockType(\n\t\t\t\t\t'core/freeform',\n\t\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t\t),\n\t\t\t\thasHTMLBlock: canInsertBlockType(\n\t\t\t\t\t'core/html',\n\t\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { replaceBlock } = useDispatch( blockEditorStore );\n\n\tfunction convertToHTML() {\n\t\treplaceBlock(\n\t\t\tclientId,\n\t\t\tcreateBlock( 'core/html', {\n\t\t\t\tcontent: originalUndelimitedContent,\n\t\t\t} )\n\t\t);\n\t}\n\n\tconst actions = [];\n\tlet messageHTML;\n\n\tconst convertToHtmlButton = (\n\t\t<Button\n\t\t\t__next40pxDefaultSize\n\t\t\tkey=\"convert\"\n\t\t\tonClick={ convertToHTML }\n\t\t\tvariant=\"primary\"\n\t\t>\n\t\t\t{ __( 'Keep as HTML' ) }\n\t\t</Button>\n\t);\n\n\tif (\n\t\thasContent &&\n\t\t! hasFreeformBlock &&\n\t\t( ! originalName || originalName === 'core/freeform' )\n\t) {\n\t\tif ( hasHTMLBlock ) {\n\t\t\tmessageHTML = __(\n\t\t\t\t'It appears you are trying to use the deprecated Classic block. You can leave this block intact, convert its content to a Custom HTML block, or remove it entirely. Alternatively, if you have unsaved changes, you can save them and refresh to use the Classic block.'\n\t\t\t);\n\t\t\tactions.push( convertToHtmlButton );\n\t\t} else {\n\t\t\tmessageHTML = __(\n\t\t\t\t'It appears you are trying to use the deprecated Classic block. You can leave this block intact, or remove it entirely. Alternatively, if you have unsaved changes, you can save them and refresh to use the Classic block.'\n\t\t\t);\n\t\t}\n\t} else if ( hasContent && hasHTMLBlock ) {\n\t\tmessageHTML = sprintf(\n\t\t\t/* translators: %s: block name */\n\t\t\t__(\n\t\t\t\t'Your site doesn\u2019t include support for the \"%s\" block. You can leave it as-is, convert it to custom HTML, or remove it.'\n\t\t\t),\n\t\t\toriginalName\n\t\t);\n\t\tactions.push( convertToHtmlButton );\n\t} else {\n\t\tmessageHTML = sprintf(\n\t\t\t/* translators: %s: block name */\n\t\t\t__(\n\t\t\t\t'Your site doesn\u2019t include support for the \"%s\" block. You can leave it as-is or remove it.'\n\t\t\t),\n\t\t\toriginalName\n\t\t);\n\t}\n\n\treturn (\n\t\t<div { ...useBlockProps( { className: 'has-warning' } ) }>\n\t\t\t<Warning actions={ actions }>{ messageHTML }</Warning>\n\t\t\t<RawHTML>{ safeHTML( originalUndelimitedContent ) }</RawHTML>\n\t\t</div>\n\t);\n}\n"],
|
|
5
5
|
"mappings": ";AAGA,SAAS,IAAI,eAAe;AAC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AA,MACD;AAAA,MACA;AAAA,IACD;AACA,YAAQ,KAAM,mBAAoB;AAAA,EACnC,OAAO;AACN,kBAAc;AAAA;AAAA,MAEb;AAAA,QACC;AAAA,MACD;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAEA,SACC,qBAAC,SAAM,GAAG,cAAe,EAAE,WAAW,cAAc,CAAE,GACrD;AAAA,wBAAC,WAAQ,SAAsB,uBAAa;AAAA,IAC5C,oBAAC,WAAU,mBAAU,0BAA2B,GAAG;AAAA,KACpD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
// packages/block-library/src/more/index.js
|
|
2
2
|
import { more as icon } from "@wordpress/icons";
|
|
3
3
|
import { __ } from "@wordpress/i18n";
|
|
4
|
+
import { privateApis as blocksPrivateApis } from "@wordpress/blocks";
|
|
4
5
|
import initBlock from "../utils/init-block";
|
|
5
6
|
import edit from "./edit";
|
|
6
7
|
import metadata from "./block.json";
|
|
7
8
|
import save from "./save";
|
|
8
9
|
import transforms from "./transforms";
|
|
10
|
+
import { unlock } from "../lock-unlock";
|
|
11
|
+
var { fieldsKey, formKey } = unlock(blocksPrivateApis);
|
|
9
12
|
var { name } = metadata;
|
|
10
13
|
var settings = {
|
|
11
14
|
icon,
|
|
@@ -24,16 +27,16 @@ var settings = {
|
|
|
24
27
|
save
|
|
25
28
|
};
|
|
26
29
|
if (window.__experimentalContentOnlyPatternInsertion) {
|
|
27
|
-
settings
|
|
30
|
+
settings[fieldsKey] = [
|
|
28
31
|
{
|
|
32
|
+
id: "customText",
|
|
29
33
|
label: __("Content"),
|
|
30
|
-
type: "
|
|
31
|
-
shownByDefault: true,
|
|
32
|
-
mapping: {
|
|
33
|
-
value: "customText"
|
|
34
|
-
}
|
|
34
|
+
type: "richtext"
|
|
35
35
|
}
|
|
36
36
|
];
|
|
37
|
+
settings[formKey] = {
|
|
38
|
+
fields: ["customText"]
|
|
39
|
+
};
|
|
37
40
|
}
|
|
38
41
|
var init = () => initBlock({ name, metadata, settings });
|
|
39
42
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/more/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { more as icon } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {},\n\t__experimentalLabel( attributes, { context } ) {\n\t\tconst customName = attributes?.metadata?.name;\n\n\t\tif ( context === 'list-view' && customName ) {\n\t\t\treturn customName;\n\t\t}\n\n\t\tif ( context === 'accessibility' ) {\n\t\t\treturn attributes.customText;\n\t\t}\n\t},\n\ttransforms,\n\tedit,\n\tsave,\n};\n\nif ( window.__experimentalContentOnlyPatternInsertion ) {\n\tsettings
|
|
5
|
-
"mappings": ";AAGA,SAAS,QAAQ,YAAY;AAC7B,SAAS,UAAU;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { more as icon } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport { privateApis as blocksPrivateApis } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\nimport { unlock } from '../lock-unlock';\n\nconst { fieldsKey, formKey } = unlock( blocksPrivateApis );\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {},\n\t__experimentalLabel( attributes, { context } ) {\n\t\tconst customName = attributes?.metadata?.name;\n\n\t\tif ( context === 'list-view' && customName ) {\n\t\t\treturn customName;\n\t\t}\n\n\t\tif ( context === 'accessibility' ) {\n\t\t\treturn attributes.customText;\n\t\t}\n\t},\n\ttransforms,\n\tedit,\n\tsave,\n};\n\nif ( window.__experimentalContentOnlyPatternInsertion ) {\n\tsettings[ fieldsKey ] = [\n\t\t{\n\t\t\tid: 'customText',\n\t\t\tlabel: __( 'Content' ),\n\t\t\ttype: 'richtext',\n\t\t},\n\t];\n\tsettings[ formKey ] = {\n\t\tfields: [ 'customText' ],\n\t};\n}\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,QAAQ,YAAY;AAC7B,SAAS,UAAU;AACnB,SAAS,eAAe,yBAAyB;AAKjD,OAAO,eAAe;AACtB,OAAO,UAAU;AACjB,OAAO,cAAc;AACrB,OAAO,UAAU;AACjB,OAAO,gBAAgB;AACvB,SAAS,cAAc;AAEvB,IAAM,EAAE,WAAW,QAAQ,IAAI,OAAQ,iBAAkB;AAEzD,IAAM,EAAE,KAAK,IAAI;AAIV,IAAM,WAAW;AAAA,EACvB;AAAA,EACA,SAAS,CAAC;AAAA,EACV,oBAAqB,YAAY,EAAE,QAAQ,GAAI;AAC9C,UAAM,aAAa,YAAY,UAAU;AAEzC,QAAK,YAAY,eAAe,YAAa;AAC5C,aAAO;AAAA,IACR;AAEA,QAAK,YAAY,iBAAkB;AAClC,aAAO,WAAW;AAAA,IACnB;AAAA,EACD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEA,IAAK,OAAO,2CAA4C;AACvD,WAAU,SAAU,IAAI;AAAA,IACvB;AAAA,MACC,IAAI;AAAA,MACJ,OAAO,GAAI,SAAU;AAAA,MACrB,MAAM;AAAA,IACP;AAAA,EACD;AACA,WAAU,OAAQ,IAAI;AAAA,IACrB,QAAQ,CAAE,YAAa;AAAA,EACxB;AACD;AAEO,IAAM,OAAO,MAAM,UAAW,EAAE,MAAM,UAAU,SAAS,CAAE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -24,7 +24,7 @@ import { useState, useEffect, useRef, useCallback } from "@wordpress/element";
|
|
|
24
24
|
import { decodeEntities } from "@wordpress/html-entities";
|
|
25
25
|
import { link as linkIcon, addSubmenu } from "@wordpress/icons";
|
|
26
26
|
import { store as coreStore } from "@wordpress/core-data";
|
|
27
|
-
import { useMergeRefs,
|
|
27
|
+
import { useMergeRefs, useInstanceId } from "@wordpress/compose";
|
|
28
28
|
import { getColors } from "../navigation/edit/utils";
|
|
29
29
|
import {
|
|
30
30
|
Controls,
|
|
@@ -142,15 +142,16 @@ function NavigationLinkEdit({
|
|
|
142
142
|
const itemLabelPlaceholder = __("Add label\u2026");
|
|
143
143
|
const ref = useRef();
|
|
144
144
|
const linkUIref = useRef();
|
|
145
|
-
const
|
|
146
|
-
const
|
|
145
|
+
const isNewLink = useRef(label === void 0);
|
|
146
|
+
const shouldSelectSubmenuAppenderOnClose = useRef(false);
|
|
147
147
|
const {
|
|
148
148
|
isAtMaxNesting,
|
|
149
149
|
isTopLevelLink,
|
|
150
150
|
isParentOfSelectedBlock,
|
|
151
151
|
hasChildren,
|
|
152
152
|
validateLinkStatus,
|
|
153
|
-
parentBlockClientId
|
|
153
|
+
parentBlockClientId,
|
|
154
|
+
isSubmenu
|
|
154
155
|
} = useSelect(
|
|
155
156
|
(select) => {
|
|
156
157
|
const {
|
|
@@ -180,7 +181,8 @@ function NavigationLinkEdit({
|
|
|
180
181
|
),
|
|
181
182
|
hasChildren: !!getBlockCount(clientId),
|
|
182
183
|
validateLinkStatus: enableLinkStatusValidation,
|
|
183
|
-
parentBlockClientId: parentBlockId
|
|
184
|
+
parentBlockClientId: parentBlockId,
|
|
185
|
+
isSubmenu: parentBlockName === "core/navigation-submenu"
|
|
184
186
|
};
|
|
185
187
|
},
|
|
186
188
|
[clientId, maxNestingLevel]
|
|
@@ -215,7 +217,7 @@ function NavigationLinkEdit({
|
|
|
215
217
|
replaceBlock(clientId, newSubmenu);
|
|
216
218
|
}, [getBlocks, clientId, selectBlock, replaceBlock, attributes]);
|
|
217
219
|
useEffect(() => {
|
|
218
|
-
if (isNewLink.current && isSelected
|
|
220
|
+
if (isNewLink.current && isSelected) {
|
|
219
221
|
selectBlock(parentBlockClientId);
|
|
220
222
|
}
|
|
221
223
|
}, []);
|
|
@@ -230,10 +232,22 @@ function NavigationLinkEdit({
|
|
|
230
232
|
transformToSubmenu
|
|
231
233
|
]);
|
|
232
234
|
useEffect(() => {
|
|
233
|
-
if (!
|
|
235
|
+
if (!isNewLink.current || !url || !isLinkOpen) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
isNewLink.current = false;
|
|
239
|
+
if (isURL(prependHTTP(label)) && /^.+\.[a-z]+/.test(label)) {
|
|
234
240
|
selectLabelText();
|
|
241
|
+
} else {
|
|
242
|
+
selectBlock(clientId, null);
|
|
243
|
+
if (isSubmenu) {
|
|
244
|
+
const parentBlocks = getBlocks(parentBlockClientId);
|
|
245
|
+
if (parentBlocks.length === 1 && parentBlocks[0].clientId === clientId) {
|
|
246
|
+
shouldSelectSubmenuAppenderOnClose.current = true;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
235
249
|
}
|
|
236
|
-
}, [
|
|
250
|
+
}, [url, isLinkOpen, isNewLink, label]);
|
|
237
251
|
function selectLabelText() {
|
|
238
252
|
ref.current.focus();
|
|
239
253
|
const { ownerDocument } = ref.current;
|
|
@@ -303,13 +317,14 @@ function NavigationLinkEdit({
|
|
|
303
317
|
renderAppender: false
|
|
304
318
|
}
|
|
305
319
|
);
|
|
306
|
-
|
|
320
|
+
const needsValidLink = !url && !(hasUrlBinding && isBoundEntityAvailable) || isInvalid || isDraft || hasUrlBinding && !isBoundEntityAvailable;
|
|
321
|
+
if (needsValidLink) {
|
|
307
322
|
blockProps.onClick = () => {
|
|
308
323
|
setIsLinkOpen(true);
|
|
309
324
|
};
|
|
310
325
|
}
|
|
311
326
|
const classes = clsx("wp-block-navigation-item__content", {
|
|
312
|
-
"wp-block-navigation-link__placeholder":
|
|
327
|
+
"wp-block-navigation-link__placeholder": needsValidLink
|
|
313
328
|
});
|
|
314
329
|
const missingText = getMissingText(type);
|
|
315
330
|
const placeholderText = `(${isInvalid ? __("Invalid") : __("Draft")})`;
|
|
@@ -408,8 +423,18 @@ function NavigationLinkEdit({
|
|
|
408
423
|
setIsLinkOpen(false);
|
|
409
424
|
if (!url && !hasUrlBinding) {
|
|
410
425
|
onReplace([]);
|
|
411
|
-
|
|
412
|
-
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
if (shouldSelectSubmenuAppenderOnClose.current) {
|
|
429
|
+
shouldSelectSubmenuAppenderOnClose.current = false;
|
|
430
|
+
if (listItemRef.current?.nextElementSibling) {
|
|
431
|
+
const appenderButton = listItemRef.current.nextElementSibling.querySelector(
|
|
432
|
+
".block-editor-button-block-appender"
|
|
433
|
+
);
|
|
434
|
+
if (appenderButton) {
|
|
435
|
+
appenderButton.focus();
|
|
436
|
+
}
|
|
437
|
+
}
|
|
413
438
|
}
|
|
414
439
|
},
|
|
415
440
|
anchor: popoverAnchor,
|