@wordpress/block-library 8.15.0 → 8.16.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/avatar/index.js +3 -0
- package/build/avatar/index.js.map +1 -1
- package/build/block/edit.js +2 -30
- package/build/block/edit.js.map +1 -1
- package/build/cover/index.js +2 -1
- package/build/cover/index.js.map +1 -1
- package/build/footnotes/edit.js +11 -0
- package/build/footnotes/edit.js.map +1 -1
- package/build/footnotes/format.js +101 -8
- package/build/footnotes/format.js.map +1 -1
- package/build/footnotes/index.js +45 -3
- package/build/footnotes/index.js.map +1 -1
- package/build/gallery/edit.js +7 -5
- package/build/gallery/edit.js.map +1 -1
- package/build/image/deprecated.js +106 -2
- package/build/image/deprecated.js.map +1 -1
- package/build/image/image.js +2 -2
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +2 -1
- package/build/image/index.js.map +1 -1
- package/build/index.js +3 -1
- package/build/index.js.map +1 -1
- package/build/list-item/hooks/use-merge.js +10 -1
- package/build/list-item/hooks/use-merge.js.map +1 -1
- package/build/navigation/edit/menu-inspector-controls.js +1 -1
- package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +4 -4
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/view-modal.js +93 -32
- package/build/navigation/view-modal.js.map +1 -1
- package/build/navigation/view.js +63 -31
- package/build/navigation/view.js.map +1 -1
- package/build/pattern/edit.js +28 -4
- package/build/pattern/edit.js.map +1 -1
- package/build/preformatted/index.js +4 -0
- package/build/preformatted/index.js.map +1 -1
- package/build/search/view.js +166 -62
- package/build/search/view.js.map +1 -1
- package/build/social-link/icons/index.js +13 -0
- package/build/social-link/icons/index.js.map +1 -1
- package/build/social-link/icons/threads.js +25 -0
- package/build/social-link/icons/threads.js.map +1 -0
- package/build/social-link/variations.js +7 -0
- package/build/social-link/variations.js.map +1 -1
- package/build/template-part/edit/import-controls.js +1 -1
- package/build/template-part/edit/import-controls.js.map +1 -1
- package/build-module/avatar/index.js +3 -0
- package/build-module/avatar/index.js.map +1 -1
- package/build-module/block/edit.js +4 -29
- package/build-module/block/edit.js.map +1 -1
- package/build-module/cover/index.js +2 -1
- package/build-module/cover/index.js.map +1 -1
- package/build-module/footnotes/edit.js +11 -0
- package/build-module/footnotes/edit.js.map +1 -1
- package/build-module/footnotes/format.js +102 -10
- package/build-module/footnotes/format.js.map +1 -1
- package/build-module/footnotes/index.js +45 -3
- package/build-module/footnotes/index.js.map +1 -1
- package/build-module/gallery/edit.js +7 -5
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/image/deprecated.js +107 -3
- package/build-module/image/deprecated.js.map +1 -1
- package/build-module/image/image.js +2 -2
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +2 -1
- package/build-module/image/index.js.map +1 -1
- package/build-module/index.js +3 -1
- package/build-module/index.js.map +1 -1
- package/build-module/list-item/hooks/use-merge.js +10 -1
- package/build-module/list-item/hooks/use-merge.js.map +1 -1
- package/build-module/navigation/edit/menu-inspector-controls.js +1 -1
- package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +4 -4
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/view-modal.js +93 -31
- package/build-module/navigation/view-modal.js.map +1 -1
- package/build-module/navigation/view.js +63 -31
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/pattern/edit.js +27 -4
- package/build-module/pattern/edit.js.map +1 -1
- package/build-module/preformatted/index.js +4 -0
- package/build-module/preformatted/index.js.map +1 -1
- package/build-module/search/view.js +166 -62
- package/build-module/search/view.js.map +1 -1
- package/build-module/social-link/icons/index.js +1 -0
- package/build-module/social-link/icons/index.js.map +1 -1
- package/build-module/social-link/icons/threads.js +15 -0
- package/build-module/social-link/icons/threads.js.map +1 -0
- package/build-module/social-link/variations.js +8 -1
- package/build-module/social-link/variations.js.map +1 -1
- package/build-module/template-part/edit/import-controls.js +2 -2
- package/build-module/template-part/edit/import-controls.js.map +1 -1
- package/build-style/preformatted/style-rtl.css +2 -1
- package/build-style/preformatted/style.css +2 -1
- package/build-style/social-links/style-rtl.css +7 -0
- package/build-style/social-links/style.css +7 -0
- package/build-style/style-rtl.css +10 -1
- package/build-style/style.css +10 -1
- package/build-style/video/style-rtl.css +1 -0
- package/build-style/video/style.css +1 -0
- package/package.json +32 -32
- package/src/audio/test/__snapshots__/edit.native.js.snap +60 -0
- package/src/avatar/block.json +3 -0
- package/src/block/edit.js +1 -39
- package/src/buttons/test/edit.native.js +4 -0
- package/src/columns/test/edit.native.js +5 -0
- package/src/comment-template/index.php +2 -0
- package/src/cover/block.json +2 -1
- package/src/cover/test/edit.native.js +8 -0
- package/src/embed/test/index.native.js +8 -0
- package/src/file/index.php +1 -1
- package/src/file/test/__snapshots__/edit.native.js.snap +61 -0
- package/src/footnotes/block.json +44 -1
- package/src/footnotes/edit.js +12 -0
- package/src/footnotes/format.js +70 -7
- package/src/footnotes/index.js +0 -1
- package/src/footnotes/index.php +207 -0
- package/src/gallery/edit.js +41 -37
- package/src/gallery/test/index.native.js +15 -3
- package/src/heading/test/index.native.js +4 -0
- package/src/image/block.json +2 -1
- package/src/image/deprecated.js +109 -3
- package/src/image/image.js +2 -2
- package/src/image/index.php +1 -3
- package/src/image/test/edit.native.js +0 -1
- package/src/index.js +5 -1
- package/src/list/test/edit.native.js +5 -0
- package/src/list-item/hooks/use-merge.js +12 -5
- package/src/missing/test/__snapshots__/edit.native.js.snap +21 -0
- package/src/navigation/edit/menu-inspector-controls.js +1 -1
- package/src/navigation/edit/navigation-menu-selector.js +8 -4
- package/src/navigation/index.php +27 -13
- package/src/navigation/view-modal.js +88 -39
- package/src/navigation/view.js +69 -36
- package/src/paragraph/test/edit.native.js +55 -35
- package/src/pattern/edit.js +21 -0
- package/src/pattern/index.php +13 -1
- package/src/post-template/index.php +2 -0
- package/src/post-title/index.php +2 -0
- package/src/preformatted/block.json +4 -0
- package/src/preformatted/style.scss +4 -1
- package/src/pullquote/test/edit.native.js +12 -4
- package/src/quote/test/edit.native.js +12 -4
- package/src/search/index.php +4 -0
- package/src/search/test/__snapshots__/edit.native.js.snap +63 -0
- package/src/search/view.js +171 -67
- package/src/social-link/icons/index.js +1 -0
- package/src/social-link/icons/threads.js +10 -0
- package/src/social-link/index.php +4 -0
- package/src/social-link/socials-with-bg.scss +5 -0
- package/src/social-link/socials-without-bg.scss +4 -0
- package/src/social-link/variations.js +7 -0
- package/src/template-part/edit/import-controls.js +2 -2
- package/src/template-part/index.php +6 -9
- package/src/video/style.scss +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/block/edit.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/block/edit.js"],"names":["useEntityBlockEditor","useEntityProp","useEntityRecord","Placeholder","Spinner","TextControl","PanelBody","__","useInnerBlocksProps","__experimentalRecursionProvider","RecursionProvider","__experimentalUseHasRecursion","useHasRecursion","InnerBlocks","InspectorControls","useBlockProps","Warning","ReusableBlockEdit","attributes","ref","hasAlreadyRendered","record","hasResolved","isMissing","blocks","onInput","onChange","id","title","setTitle","blockProps","className","innerBlocksProps","value","renderAppender","length","undefined","ButtonBlockAppender"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,oBADD,EAECC,aAFD,EAGCC,eAHD,QAIO,sBAJP;AAKA,SACCC,WADD,EAECC,OAFD,EAGCC,WAHD,EAICC,SAJD,QAKO,uBALP;AAMA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,mBADD,EAECC,+BAA+B,IAAIC,iBAFpC,EAGCC,6BAA6B,IAAIC,eAHlC,EAICC,WAJD,EAKCC,iBALD,EAMCC,aAND,EAOCC,OAPD,QAQO,yBARP;AAUA,eAAe,SAASC,iBAAT,CAA4B;AAAEC,EAAAA,UAAU,EAAE;AAAEC,IAAAA;AAAF;A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,EAAGX;AAA9B,KACC,cAAC,iBAAD,QACC,cAAC,SAAD,QACC,cAAC,WAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,KAAK,EAAGZ,EAAE,CAAE,MAAF,CAFX;AAGC,IAAA,KAAK,EAAGqB,KAHT;AAIC,IAAA,QAAQ,EAAGC;AAJZ,IADD,CADD,CADD,EAWC,0BAAUG;AAAV,IAXD,CADD;AAeA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseEntityBlockEditor,\n\tuseEntityProp,\n\tuseEntityRecord,\n} from '@wordpress/core-data';\nimport {\n\tPlaceholder,\n\tSpinner,\n\tTextControl,\n\tPanelBody,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseInnerBlocksProps,\n\t__experimentalRecursionProvider as RecursionProvider,\n\t__experimentalUseHasRecursion as useHasRecursion,\n\tInnerBlocks,\n\tInspectorControls,\n\tuseBlockProps,\n\tWarning,\n} from '@wordpress/block-editor';\n\nexport default function ReusableBlockEdit( { attributes: { ref } } ) {\n\tconst hasAlreadyRendered = useHasRecursion( ref );\n\tconst { record, hasResolved } = useEntityRecord(\n\t\t'postType',\n\t\t'wp_block',\n\t\tref\n\t);\n\tconst isMissing = hasResolved && ! record;\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\t'wp_block',\n\t\t{ id: ref }\n\t);\n\n\tconst [ title, setTitle ] = useEntityProp(\n\t\t'postType',\n\t\t'wp_block',\n\t\t'title',\n\t\tref\n\t);\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: 'block-library-block__reusable-block-container',\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tvalue: blocks,\n\t\tonInput,\n\t\tonChange,\n\t\trenderAppender: blocks?.length\n\t\t\t? undefined\n\t\t\t: InnerBlocks.ButtonBlockAppender,\n\t} );\n\n\tif ( hasAlreadyRendered ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t\t</Warning>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif ( isMissing ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ __( 'Block has been deleted or is unavailable.' ) }\n\t\t\t\t</Warning>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif ( ! hasResolved ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Placeholder>\n\t\t\t\t\t<Spinner />\n\t\t\t\t</Placeholder>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<RecursionProvider uniqueId={ ref }>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</RecursionProvider>\n\t);\n}\n"]}
|
|
@@ -123,7 +123,8 @@ const metadata = {
|
|
|
123
123
|
heading: true,
|
|
124
124
|
text: true,
|
|
125
125
|
background: false,
|
|
126
|
-
__experimentalSkipSerialization: ["gradients"]
|
|
126
|
+
__experimentalSkipSerialization: ["gradients"],
|
|
127
|
+
enableContrastChecker: false
|
|
127
128
|
},
|
|
128
129
|
typography: {
|
|
129
130
|
fontSize: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/cover/index.js"],"names":["__","cover","icon","initBlock","deprecated","edit","save","transforms","variations","name","metadata","settings","example","attributes","customOverlayColor","dimRatio","url","innerBlocks","content","align","style","typography","fontSize","color","text","init"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAK,IAAIC,IAAlB,QAA8B,kBAA9B;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,qBAAtB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,IAAP,MAAiB,QAAjB
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/cover/index.js"],"names":["__","cover","icon","initBlock","deprecated","edit","save","transforms","variations","name","metadata","settings","example","attributes","customOverlayColor","dimRatio","url","innerBlocks","content","align","style","typography","fontSize","color","text","init"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAK,IAAIC,IAAlB,QAA8B,kBAA9B;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,qBAAtB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,IAAP,MAAiB,QAAjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AAEA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBT,EAAAA,IADuB;AAEvBU,EAAAA,OAAO,EAAE;AACRC,IAAAA,UAAU,EAAE;AACXC,MAAAA,kBAAkB,EAAE,SADT;AAEXC,MAAAA,QAAQ,EAAE,EAFC;AAGXC,MAAAA,GAAG,EAAE;AAHM,KADJ;AAMRC,IAAAA,WAAW,EAAE,CACZ;AACCR,MAAAA,IAAI,EAAE,gBADP;AAECI,MAAAA,UAAU,EAAE;AACXK,QAAAA,OAAO,EAAElB,EAAE,CAAE,8BAAF,CADA;AAEXmB,QAAAA,KAAK,EAAE,QAFI;AAGXC,QAAAA,KAAK,EAAE;AACNC,UAAAA,UAAU,EAAE;AACXC,YAAAA,QAAQ,EAAE;AADC,WADN;AAINC,UAAAA,KAAK,EAAE;AACNC,YAAAA,IAAI,EAAE;AADA;AAJD;AAHI;AAFb,KADY;AANL,GAFc;AA0BvBjB,EAAAA,UA1BuB;AA2BvBD,EAAAA,IA3BuB;AA4BvBD,EAAAA,IA5BuB;AA6BvBD,EAAAA,UA7BuB;AA8BvBI,EAAAA;AA9BuB,CAAjB;AAiCP,OAAO,MAAMiB,IAAI,GAAG,MAAMtB,SAAS,CAAE;AAAEM,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAF,CAA5B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { cover 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';\nimport variations from './variations';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tcustomOverlayColor: '#065174',\n\t\t\tdimRatio: 40,\n\t\t\turl: 'https://s.w.org/images/core/5.3/Windbuchencom.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: __( '<strong>Snow Patrol</strong>' ),\n\t\t\t\t\talign: 'center',\n\t\t\t\t\tstyle: {\n\t\t\t\t\t\ttypography: {\n\t\t\t\t\t\t\tfontSize: 48,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\ttext: 'white',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n\ttransforms,\n\tsave,\n\tedit,\n\tdeprecated,\n\tvariations,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
|
|
@@ -18,6 +18,17 @@ export default function FootnotesEdit({
|
|
|
18
18
|
const footnotes = meta?.footnotes ? JSON.parse(meta.footnotes) : [];
|
|
19
19
|
const blockProps = useBlockProps();
|
|
20
20
|
|
|
21
|
+
if (postType !== 'post' && postType !== 'page') {
|
|
22
|
+
return createElement("div", { ...blockProps
|
|
23
|
+
}, createElement(Placeholder, {
|
|
24
|
+
icon: createElement(BlockIcon, {
|
|
25
|
+
icon: icon
|
|
26
|
+
}),
|
|
27
|
+
label: __('Footnotes') // To do: add instructions. We can't add new string in RC.
|
|
28
|
+
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
|
|
21
32
|
if (!footnotes.length) {
|
|
22
33
|
return createElement("div", { ...blockProps
|
|
23
34
|
}, createElement(Placeholder, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/footnotes/edit.js"],"names":["BlockIcon","RichText","useBlockProps","useEntityProp","__","Placeholder","formatListNumbered","icon","FootnotesEdit","context","postType","postId","meta","updateMeta","footnotes","JSON","parse","blockProps","length","map","id","content","event","target","textContent","trim","scrollIntoView","nextFootnote","stringify","footnote"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,QAApB,EAA8BC,aAA9B,QAAmD,yBAAnD;AACA,SAASC,aAAT,QAA8B,sBAA9B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAT,QAA4B,uBAA5B;AACA,SAASC,kBAAkB,IAAIC,IAA/B,QAA2C,kBAA3C;AAEA,eAAe,SAASC,aAAT,CAAwB;AAAEC,EAAAA,OAAO,EAAE;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ;AAAX,CAAxB,EAA4D;AAC1E,QAAM,CAAEC,IAAF,EAAQC,UAAR,IAAuBV,aAAa,CACzC,UADyC,EAEzCO,QAFyC,EAGzC,MAHyC,EAIzCC,MAJyC,CAA1C;AAMA,QAAMG,SAAS,GAAGF,IAAI,EAAEE,SAAN,GAAkBC,IAAI,CAACC,KAAL,CAAYJ,IAAI,CAACE,SAAjB,CAAlB,GAAiD,EAAnE;AACA,QAAMG,UAAU,GAAGf,aAAa,EAAhC;;AAEA,MAAK,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/footnotes/edit.js"],"names":["BlockIcon","RichText","useBlockProps","useEntityProp","__","Placeholder","formatListNumbered","icon","FootnotesEdit","context","postType","postId","meta","updateMeta","footnotes","JSON","parse","blockProps","length","map","id","content","event","target","textContent","trim","scrollIntoView","nextFootnote","stringify","footnote"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,QAApB,EAA8BC,aAA9B,QAAmD,yBAAnD;AACA,SAASC,aAAT,QAA8B,sBAA9B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAT,QAA4B,uBAA5B;AACA,SAASC,kBAAkB,IAAIC,IAA/B,QAA2C,kBAA3C;AAEA,eAAe,SAASC,aAAT,CAAwB;AAAEC,EAAAA,OAAO,EAAE;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ;AAAX,CAAxB,EAA4D;AAC1E,QAAM,CAAEC,IAAF,EAAQC,UAAR,IAAuBV,aAAa,CACzC,UADyC,EAEzCO,QAFyC,EAGzC,MAHyC,EAIzCC,MAJyC,CAA1C;AAMA,QAAMG,SAAS,GAAGF,IAAI,EAAEE,SAAN,GAAkBC,IAAI,CAACC,KAAL,CAAYJ,IAAI,CAACE,SAAjB,CAAlB,GAAiD,EAAnE;AACA,QAAMG,UAAU,GAAGf,aAAa,EAAhC;;AAEA,MAAKQ,QAAQ,KAAK,MAAb,IAAuBA,QAAQ,KAAK,MAAzC,EAAkD;AACjD,WACC,0BAAUO;AAAV,OACC,cAAC,WAAD;AACC,MAAA,IAAI,EAAG,cAAC,SAAD;AAAW,Q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A6BC;AAAG,IAAA,IAAI,EAAI,IAAIT,EAAI;AAAnB,oBA7BD,CADC,CADH,CADD;AAqCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { BlockIcon, RichText, useBlockProps } from '@wordpress/block-editor';\nimport { useEntityProp } from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\nimport { Placeholder } from '@wordpress/components';\nimport { formatListNumbered as icon } from '@wordpress/icons';\n\nexport default function FootnotesEdit( { context: { postType, postId } } ) {\n\tconst [ meta, updateMeta ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'meta',\n\t\tpostId\n\t);\n\tconst footnotes = meta?.footnotes ? JSON.parse( meta.footnotes ) : [];\n\tconst blockProps = useBlockProps();\n\n\tif ( postType !== 'post' && postType !== 'page' ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Placeholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tlabel={ __( 'Footnotes' ) }\n\t\t\t\t\t// To do: add instructions. We can't add new string in RC.\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif ( ! footnotes.length ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Placeholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tlabel={ __( 'Footnotes' ) }\n\t\t\t\t\tinstructions={ __(\n\t\t\t\t\t\t'Footnotes found in blocks within this document will be displayed here.'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<ol { ...blockProps }>\n\t\t\t{ footnotes.map( ( { id, content } ) => (\n\t\t\t\t<li key={ id }>\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tid={ id }\n\t\t\t\t\t\ttagName=\"span\"\n\t\t\t\t\t\tvalue={ content }\n\t\t\t\t\t\tidentifier={ id }\n\t\t\t\t\t\t// To do: figure out why the browser is not scrolling\n\t\t\t\t\t\t// into view when it receives focus.\n\t\t\t\t\t\tonFocus={ ( event ) => {\n\t\t\t\t\t\t\tif ( ! event.target.textContent.trim() ) {\n\t\t\t\t\t\t\t\tevent.target.scrollIntoView();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonChange={ ( nextFootnote ) => {\n\t\t\t\t\t\t\tupdateMeta( {\n\t\t\t\t\t\t\t\t...meta,\n\t\t\t\t\t\t\t\tfootnotes: JSON.stringify(\n\t\t\t\t\t\t\t\t\tfootnotes.map( ( footnote ) => {\n\t\t\t\t\t\t\t\t\t\treturn footnote.id === id\n\t\t\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\t\t\tcontent: nextFootnote,\n\t\t\t\t\t\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t\t\t\t: footnote;\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} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>{ ' ' }\n\t\t\t\t\t<a href={ `#${ id }-link` }>↩︎</a>\n\t\t\t\t</li>\n\t\t\t) ) }\n\t\t</ol>\n\t);\n}\n"]}
|
|
@@ -11,9 +11,9 @@ import { v4 as createId } from 'uuid';
|
|
|
11
11
|
import { __ } from '@wordpress/i18n';
|
|
12
12
|
import { formatListNumbered as icon } from '@wordpress/icons';
|
|
13
13
|
import { insertObject } from '@wordpress/rich-text';
|
|
14
|
-
import { RichTextToolbarButton, store as blockEditorStore } from '@wordpress/block-editor';
|
|
14
|
+
import { RichTextToolbarButton, store as blockEditorStore, privateApis } from '@wordpress/block-editor';
|
|
15
15
|
import { useSelect, useDispatch, useRegistry } from '@wordpress/data';
|
|
16
|
-
import { createBlock } from '@wordpress/blocks';
|
|
16
|
+
import { createBlock, store as blocksStore } from '@wordpress/blocks';
|
|
17
17
|
/**
|
|
18
18
|
* Internal dependencies
|
|
19
19
|
*/
|
|
@@ -31,13 +31,62 @@ const {
|
|
|
31
31
|
textdomain: "default",
|
|
32
32
|
usesContext: ["postId", "postType"],
|
|
33
33
|
supports: {
|
|
34
|
+
__experimentalBorder: {
|
|
35
|
+
radius: true,
|
|
36
|
+
color: true,
|
|
37
|
+
width: true,
|
|
38
|
+
style: true,
|
|
39
|
+
__experimentalDefaultControls: {
|
|
40
|
+
radius: false,
|
|
41
|
+
color: false,
|
|
42
|
+
width: false,
|
|
43
|
+
style: false
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
color: {
|
|
47
|
+
background: true,
|
|
48
|
+
link: true,
|
|
49
|
+
text: true,
|
|
50
|
+
__experimentalDefaultControls: {
|
|
51
|
+
link: true,
|
|
52
|
+
text: true
|
|
53
|
+
}
|
|
54
|
+
},
|
|
34
55
|
html: false,
|
|
35
56
|
multiple: false,
|
|
36
|
-
reusable: false
|
|
57
|
+
reusable: false,
|
|
58
|
+
spacing: {
|
|
59
|
+
margin: true,
|
|
60
|
+
padding: true,
|
|
61
|
+
__experimentalDefaultControls: {
|
|
62
|
+
margin: false,
|
|
63
|
+
padding: false
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
typography: {
|
|
67
|
+
fontSize: true,
|
|
68
|
+
lineHeight: true,
|
|
69
|
+
__experimentalFontFamily: true,
|
|
70
|
+
__experimentalTextDecoration: true,
|
|
71
|
+
__experimentalFontStyle: true,
|
|
72
|
+
__experimentalFontWeight: true,
|
|
73
|
+
__experimentalLetterSpacing: true,
|
|
74
|
+
__experimentalTextTransform: true,
|
|
75
|
+
__experimentalWritingMode: true,
|
|
76
|
+
__experimentalDefaultControls: {
|
|
77
|
+
fontSize: true
|
|
78
|
+
}
|
|
79
|
+
}
|
|
37
80
|
},
|
|
38
81
|
style: "wp-block-footnotes"
|
|
39
82
|
};
|
|
83
|
+
import { unlock } from '../lock-unlock';
|
|
84
|
+
const {
|
|
85
|
+
usesContextKey
|
|
86
|
+
} = unlock(privateApis);
|
|
40
87
|
export const formatName = 'core/footnote';
|
|
88
|
+
const POST_CONTENT_BLOCK_NAME = 'core/post-content';
|
|
89
|
+
const SYNCED_PATTERN_BLOCK_NAME = 'core/block';
|
|
41
90
|
export const format = {
|
|
42
91
|
title: __('Footnote'),
|
|
43
92
|
tagName: 'sup',
|
|
@@ -46,23 +95,57 @@ export const format = {
|
|
|
46
95
|
'data-fn': 'data-fn'
|
|
47
96
|
},
|
|
48
97
|
contentEditable: false,
|
|
98
|
+
[usesContextKey]: ['postType'],
|
|
49
99
|
edit: function Edit({
|
|
50
100
|
value,
|
|
51
101
|
onChange,
|
|
52
|
-
isObjectActive
|
|
102
|
+
isObjectActive,
|
|
103
|
+
context: {
|
|
104
|
+
postType
|
|
105
|
+
}
|
|
53
106
|
}) {
|
|
54
107
|
const registry = useRegistry();
|
|
55
108
|
const {
|
|
56
109
|
getSelectedBlockClientId,
|
|
110
|
+
getBlocks,
|
|
57
111
|
getBlockRootClientId,
|
|
58
112
|
getBlockName,
|
|
59
|
-
|
|
113
|
+
getBlockParentsByBlockName
|
|
60
114
|
} = useSelect(blockEditorStore);
|
|
115
|
+
const footnotesBlockType = useSelect(select => select(blocksStore).getBlockType(name));
|
|
116
|
+
/*
|
|
117
|
+
* This useSelect exists because we need to use its return value
|
|
118
|
+
* outside the event callback.
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
const isBlockWithinPattern = useSelect(select => {
|
|
122
|
+
const {
|
|
123
|
+
getBlockParentsByBlockName: _getBlockParentsByBlockName,
|
|
124
|
+
getSelectedBlockClientId: _getSelectedBlockClientId
|
|
125
|
+
} = select(blockEditorStore);
|
|
126
|
+
|
|
127
|
+
const parentCoreBlocks = _getBlockParentsByBlockName(_getSelectedBlockClientId(), SYNCED_PATTERN_BLOCK_NAME);
|
|
128
|
+
|
|
129
|
+
return parentCoreBlocks && parentCoreBlocks.length > 0;
|
|
130
|
+
}, []);
|
|
61
131
|
const {
|
|
62
132
|
selectionChange,
|
|
63
133
|
insertBlock
|
|
64
134
|
} = useDispatch(blockEditorStore);
|
|
65
135
|
|
|
136
|
+
if (!footnotesBlockType) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (postType !== 'post' && postType !== 'page') {
|
|
141
|
+
return null;
|
|
142
|
+
} // Checks if the selected block lives within a pattern.
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
if (isBlockWithinPattern) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
|
|
66
149
|
function onClick() {
|
|
67
150
|
registry.batch(() => {
|
|
68
151
|
let id;
|
|
@@ -81,12 +164,22 @@ export const format = {
|
|
|
81
164
|
}, value.end, value.end);
|
|
82
165
|
newValue.start = newValue.end - 1;
|
|
83
166
|
onChange(newValue);
|
|
84
|
-
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const selectedClientId = getSelectedBlockClientId();
|
|
170
|
+
/*
|
|
171
|
+
* Attempts to find a common parent post content block.
|
|
172
|
+
* This allows for locating blocks within a page edited in the site editor.
|
|
173
|
+
*/
|
|
174
|
+
|
|
175
|
+
const parentPostContent = getBlockParentsByBlockName(selectedClientId, POST_CONTENT_BLOCK_NAME); // When called with a post content block, getBlocks will return
|
|
176
|
+
// the block with controlled inner blocks included.
|
|
85
177
|
|
|
178
|
+
const blocks = parentPostContent.length ? getBlocks(parentPostContent[0]) : getBlocks(); // BFS search to find the first footnote block.
|
|
86
179
|
|
|
87
180
|
let fnBlock = null;
|
|
88
181
|
{
|
|
89
|
-
const queue = [...
|
|
182
|
+
const queue = [...blocks];
|
|
90
183
|
|
|
91
184
|
while (queue.length) {
|
|
92
185
|
const block = queue.shift();
|
|
@@ -103,10 +196,9 @@ export const format = {
|
|
|
103
196
|
// insert it at the bottom.
|
|
104
197
|
|
|
105
198
|
if (!fnBlock) {
|
|
106
|
-
|
|
107
|
-
let rootClientId = getBlockRootClientId(clientId);
|
|
199
|
+
let rootClientId = getBlockRootClientId(selectedClientId);
|
|
108
200
|
|
|
109
|
-
while (rootClientId && getBlockName(rootClientId) !==
|
|
201
|
+
while (rootClientId && getBlockName(rootClientId) !== POST_CONTENT_BLOCK_NAME) {
|
|
110
202
|
rootClientId = getBlockRootClientId(rootClientId);
|
|
111
203
|
}
|
|
112
204
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/footnotes/format.js"],"names":["v4","createId","__","formatListNumbered","icon","insertObject","RichTextToolbarButton","store","blockEditorStore","useSelect","useDispatch","useRegistry","createBlock","formatName","format","title","tagName","className","attributes","contentEditable","edit","Edit","value","onChange","isObjectActive","registry","getSelectedBlockClientId","getBlockRootClientId","getBlockName","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/footnotes/format.js"],"names":["v4","createId","__","formatListNumbered","icon","insertObject","RichTextToolbarButton","store","blockEditorStore","privateApis","useSelect","useDispatch","useRegistry","createBlock","blocksStore","unlock","usesContextKey","formatName","POST_CONTENT_BLOCK_NAME","SYNCED_PATTERN_BLOCK_NAME","format","title","tagName","className","attributes","contentEditable","edit","Edit","value","onChange","isObjectActive","context","postType","registry","getSelectedBlockClientId","getBlocks","getBlockRootClientId","getBlockName","getBlockParentsByBlockName","footnotesBlockType","select","getBlockType","name","isBlockWithinPattern","_getBlockParentsByBlockName","_getSelectedBlockClientId","parentCoreBlocks","length","selectionChange","insertBlock","onClick","batch","id","object","replacements","start","newValue","type","innerHTML","end","selectedClientId","parentPostContent","blocks","fnBlock","queue","block","shift","push","innerBlocks","rootClientId","undefined","clientId"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAE,IAAIC,QAAf,QAA+B,MAA/B;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,kBAAkB,IAAIC,IAA/B,QAA2C,kBAA3C;AACA,SAASC,YAAT,QAA6B,sBAA7B;AACA,SACCC,qBADD,EAECC,KAAK,IAAIC,gBAFV,EAGCC,WAHD,QAIO,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A,eAAe,CAAEe,OAAO,CAACQ,QAAV,EAAoBnB,EAApB,EAAwB,CAAxB,EAA2B,CAA3B,CAAf;AACA,OAzED;AA0EA;;AAED,WACC,cAAC,qBAAD;AACC,MAAA,IAAI,EAAGhD,IADR;AAEC,MAAA,KAAK,EAAGF,EAAE,CAAE,UAAF,CAFX;AAGC,MAAA,OAAO,EAAGgD,OAHX;AAIC,MAAA,QAAQ,EAAGpB;AAJZ,MADD;AAQA;AA/IoB,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { v4 as createId } from 'uuid';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { formatListNumbered as icon } from '@wordpress/icons';\nimport { insertObject } from '@wordpress/rich-text';\nimport {\n\tRichTextToolbarButton,\n\tstore as blockEditorStore,\n\tprivateApis,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch, useRegistry } from '@wordpress/data';\nimport { createBlock, store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { name } from './block.json';\nimport { unlock } from '../lock-unlock';\n\nconst { usesContextKey } = unlock( privateApis );\n\nexport const formatName = 'core/footnote';\n\nconst POST_CONTENT_BLOCK_NAME = 'core/post-content';\nconst SYNCED_PATTERN_BLOCK_NAME = 'core/block';\n\nexport const format = {\n\ttitle: __( 'Footnote' ),\n\ttagName: 'sup',\n\tclassName: 'fn',\n\tattributes: {\n\t\t'data-fn': 'data-fn',\n\t},\n\tcontentEditable: false,\n\t[ usesContextKey ]: [ 'postType' ],\n\tedit: function Edit( {\n\t\tvalue,\n\t\tonChange,\n\t\tisObjectActive,\n\t\tcontext: { postType },\n\t} ) {\n\t\tconst registry = useRegistry();\n\t\tconst {\n\t\t\tgetSelectedBlockClientId,\n\t\t\tgetBlocks,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlockName,\n\t\t\tgetBlockParentsByBlockName,\n\t\t} = useSelect( blockEditorStore );\n\t\tconst footnotesBlockType = useSelect( ( select ) =>\n\t\t\tselect( blocksStore ).getBlockType( name )\n\t\t);\n\t\t/*\n\t\t * This useSelect exists because we need to use its return value\n\t\t * outside the event callback.\n\t\t */\n\t\tconst isBlockWithinPattern = useSelect( ( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockParentsByBlockName: _getBlockParentsByBlockName,\n\t\t\t\tgetSelectedBlockClientId: _getSelectedBlockClientId,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst parentCoreBlocks = _getBlockParentsByBlockName(\n\t\t\t\t_getSelectedBlockClientId(),\n\t\t\t\tSYNCED_PATTERN_BLOCK_NAME\n\t\t\t);\n\t\t\treturn parentCoreBlocks && parentCoreBlocks.length > 0;\n\t\t}, [] );\n\n\t\tconst { selectionChange, insertBlock } =\n\t\t\tuseDispatch( blockEditorStore );\n\n\t\tif ( ! footnotesBlockType ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif ( postType !== 'post' && postType !== 'page' ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Checks if the selected block lives within a pattern.\n\t\tif ( isBlockWithinPattern ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tregistry.batch( () => {\n\t\t\t\tlet id;\n\t\t\t\tif ( isObjectActive ) {\n\t\t\t\t\tconst object = value.replacements[ value.start ];\n\t\t\t\t\tid = object?.attributes?.[ 'data-fn' ];\n\t\t\t\t} else {\n\t\t\t\t\tid = createId();\n\t\t\t\t\tconst newValue = insertObject(\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: formatName,\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t'data-fn': id,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tinnerHTML: `<a href=\"#${ id }\" id=\"${ id }-link\">*</a>`,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tvalue.end,\n\t\t\t\t\t\tvalue.end\n\t\t\t\t\t);\n\t\t\t\t\tnewValue.start = newValue.end - 1;\n\t\t\t\t\tonChange( newValue );\n\t\t\t\t}\n\n\t\t\t\tconst selectedClientId = getSelectedBlockClientId();\n\n\t\t\t\t/*\n\t\t\t\t * Attempts to find a common parent post content block.\n\t\t\t\t * This allows for locating blocks within a page edited in the site editor.\n\t\t\t\t */\n\t\t\t\tconst parentPostContent = getBlockParentsByBlockName(\n\t\t\t\t\tselectedClientId,\n\t\t\t\t\tPOST_CONTENT_BLOCK_NAME\n\t\t\t\t);\n\n\t\t\t\t// When called with a post content block, getBlocks will return\n\t\t\t\t// the block with controlled inner blocks included.\n\t\t\t\tconst blocks = parentPostContent.length\n\t\t\t\t\t? getBlocks( parentPostContent[ 0 ] )\n\t\t\t\t\t: getBlocks();\n\n\t\t\t\t// BFS search to find the first footnote block.\n\t\t\t\tlet fnBlock = null;\n\t\t\t\t{\n\t\t\t\t\tconst queue = [ ...blocks ];\n\t\t\t\t\twhile ( queue.length ) {\n\t\t\t\t\t\tconst block = queue.shift();\n\t\t\t\t\t\tif ( block.name === name ) {\n\t\t\t\t\t\t\tfnBlock = block;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tqueue.push( ...block.innerBlocks );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Maybe this should all also be moved to the entity provider.\n\t\t\t\t// When there is no footnotes block in the post, create one and\n\t\t\t\t// insert it at the bottom.\n\t\t\t\tif ( ! fnBlock ) {\n\t\t\t\t\tlet rootClientId = getBlockRootClientId( selectedClientId );\n\n\t\t\t\t\twhile (\n\t\t\t\t\t\trootClientId &&\n\t\t\t\t\t\tgetBlockName( rootClientId ) !== POST_CONTENT_BLOCK_NAME\n\t\t\t\t\t) {\n\t\t\t\t\t\trootClientId = getBlockRootClientId( rootClientId );\n\t\t\t\t\t}\n\n\t\t\t\t\tfnBlock = createBlock( name );\n\n\t\t\t\t\tinsertBlock( fnBlock, undefined, rootClientId );\n\t\t\t\t}\n\n\t\t\t\tselectionChange( fnBlock.clientId, id, 0, 0 );\n\t\t\t} );\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ icon }\n\t\t\t\ttitle={ __( 'Footnote' ) }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isObjectActive }\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
|
|
@@ -20,9 +20,52 @@ const metadata = {
|
|
|
20
20
|
textdomain: "default",
|
|
21
21
|
usesContext: ["postId", "postType"],
|
|
22
22
|
supports: {
|
|
23
|
+
__experimentalBorder: {
|
|
24
|
+
radius: true,
|
|
25
|
+
color: true,
|
|
26
|
+
width: true,
|
|
27
|
+
style: true,
|
|
28
|
+
__experimentalDefaultControls: {
|
|
29
|
+
radius: false,
|
|
30
|
+
color: false,
|
|
31
|
+
width: false,
|
|
32
|
+
style: false
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
color: {
|
|
36
|
+
background: true,
|
|
37
|
+
link: true,
|
|
38
|
+
text: true,
|
|
39
|
+
__experimentalDefaultControls: {
|
|
40
|
+
link: true,
|
|
41
|
+
text: true
|
|
42
|
+
}
|
|
43
|
+
},
|
|
23
44
|
html: false,
|
|
24
45
|
multiple: false,
|
|
25
|
-
reusable: false
|
|
46
|
+
reusable: false,
|
|
47
|
+
spacing: {
|
|
48
|
+
margin: true,
|
|
49
|
+
padding: true,
|
|
50
|
+
__experimentalDefaultControls: {
|
|
51
|
+
margin: false,
|
|
52
|
+
padding: false
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
typography: {
|
|
56
|
+
fontSize: true,
|
|
57
|
+
lineHeight: true,
|
|
58
|
+
__experimentalFontFamily: true,
|
|
59
|
+
__experimentalTextDecoration: true,
|
|
60
|
+
__experimentalFontStyle: true,
|
|
61
|
+
__experimentalFontWeight: true,
|
|
62
|
+
__experimentalLetterSpacing: true,
|
|
63
|
+
__experimentalTextTransform: true,
|
|
64
|
+
__experimentalWritingMode: true,
|
|
65
|
+
__experimentalDefaultControls: {
|
|
66
|
+
fontSize: true
|
|
67
|
+
}
|
|
68
|
+
}
|
|
26
69
|
},
|
|
27
70
|
style: "wp-block-footnotes"
|
|
28
71
|
};
|
|
@@ -34,8 +77,7 @@ export { metadata, name };
|
|
|
34
77
|
export const settings = {
|
|
35
78
|
icon,
|
|
36
79
|
edit
|
|
37
|
-
};
|
|
38
|
-
|
|
80
|
+
};
|
|
39
81
|
registerFormatType(formatName, format);
|
|
40
82
|
export const init = () => {
|
|
41
83
|
initBlock({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/footnotes/index.js"],"names":["formatListNumbered","icon","registerFormatType","initBlock","edit","formatName","format","name","metadata","settings","init"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,kBAAkB,IAAIC,IAA/B,QAA2C,kBAA3C;AACA,SAASC,kBAAT,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,qBAAtB;AACA,OAAOC,IAAP,MAAiB,QAAjB
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/footnotes/index.js"],"names":["formatListNumbered","icon","registerFormatType","initBlock","edit","formatName","format","name","metadata","settings","init"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,kBAAkB,IAAIC,IAA/B,QAA2C,kBAA3C;AACA,SAASC,kBAAT,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,qBAAtB;AACA,OAAOC,IAAP,MAAiB,QAAjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAASC,UAAT,EAAqBC,MAArB,QAAmC,UAAnC;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AAEA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBR,EAAAA,IADuB;AAEvBG,EAAAA;AAFuB,CAAjB;AAKPF,kBAAkB,CAAEG,UAAF,EAAcC,MAAd,CAAlB;AAEA,OAAO,MAAMI,IAAI,GAAG,MAAM;AACzBP,EAAAA,SAAS,CAAE;AAAEI,IAAAA,IAAF;AAAQC,IAAAA,QAAR;AAAkBC,IAAAA;AAAlB,GAAF,CAAT;AACA,CAFM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { formatListNumbered as icon } from '@wordpress/icons';\nimport { registerFormatType } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport edit from './edit';\nimport metadata from './block.json';\nimport { formatName, format } from './format';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n\nregisterFormatType( formatName, format );\n\nexport const init = () => {\n\tinitBlock( { name, metadata, settings } );\n};\n"]}
|
|
@@ -60,7 +60,8 @@ function GalleryEdit(props) {
|
|
|
60
60
|
clientId,
|
|
61
61
|
isSelected,
|
|
62
62
|
insertBlocksAfter,
|
|
63
|
-
isContentLocked
|
|
63
|
+
isContentLocked,
|
|
64
|
+
onFocus
|
|
64
65
|
} = props;
|
|
65
66
|
const {
|
|
66
67
|
columns,
|
|
@@ -361,7 +362,8 @@ function GalleryEdit(props) {
|
|
|
361
362
|
isAppender: hasImages,
|
|
362
363
|
disableMediaButtons: hasImages && !isSelected || imagesUploading,
|
|
363
364
|
value: hasImageIds ? images : {},
|
|
364
|
-
autoOpenMediaUpload: !hasImages && isSelected && wasBlockJustInserted
|
|
365
|
+
autoOpenMediaUpload: !hasImages && isSelected && wasBlockJustInserted,
|
|
366
|
+
onFocus
|
|
365
367
|
}
|
|
366
368
|
});
|
|
367
369
|
const mediaPlaceholder = createElement(MediaPlaceholder, {
|
|
@@ -442,7 +444,7 @@ function GalleryEdit(props) {
|
|
|
442
444
|
className: 'gallery-image-sizes'
|
|
443
445
|
}, createElement(BaseControl.VisualLabel, null, __('Resolution')), createElement(View, {
|
|
444
446
|
className: 'gallery-image-sizes__loading'
|
|
445
|
-
}, createElement(Spinner, null), __('Loading options…'))))), createElement(BlockControls, {
|
|
447
|
+
}, createElement(Spinner, null), __('Loading options…'))))), Platform.isWeb && createElement(Fragment, null, createElement(BlockControls, {
|
|
446
448
|
group: "block"
|
|
447
449
|
}, !isContentLocked && createElement(ToolbarButton, {
|
|
448
450
|
onClick: () => {
|
|
@@ -468,10 +470,10 @@ function GalleryEdit(props) {
|
|
|
468
470
|
multiple: true,
|
|
469
471
|
mediaIds: images.filter(image => image.id).map(image => image.id),
|
|
470
472
|
addToGallery: hasImageIds
|
|
471
|
-
})),
|
|
473
|
+
})), createElement(GapStyles, {
|
|
472
474
|
blockGap: attributes.style?.spacing?.blockGap,
|
|
473
475
|
clientId: clientId
|
|
474
|
-
}), createElement(Gallery, { ...props,
|
|
476
|
+
})), createElement(Gallery, { ...props,
|
|
475
477
|
showCaption: showCaption,
|
|
476
478
|
ref: Platform.isWeb ? captionRef : undefined,
|
|
477
479
|
images: images,
|