@wordpress/block-library 8.28.3 → 8.28.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/button/edit.js +1 -1
- package/build/button/edit.js.map +1 -1
- package/build/buttons/transforms.js +16 -2
- package/build/buttons/transforms.js.map +1 -1
- package/build/code/transforms.js +17 -6
- package/build/code/transforms.js.map +1 -1
- package/build/cover/edit/block-controls.js +14 -3
- package/build/cover/edit/block-controls.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +1 -1
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/heading/transforms.js +17 -4
- package/build/heading/transforms.js.map +1 -1
- package/build/image/edit.js +2 -1
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +11 -3
- package/build/image/image.js.map +1 -1
- package/build/post-featured-image/edit.js +8 -11
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-title/edit.js +2 -2
- package/build/post-title/edit.js.map +1 -1
- package/build/utils/caption.js +15 -5
- package/build/utils/caption.js.map +1 -1
- package/build/utils/get-transformed-metadata.js +57 -0
- package/build/utils/get-transformed-metadata.js.map +1 -0
- package/build-module/button/edit.js +2 -2
- package/build-module/button/edit.js.map +1 -1
- package/build-module/buttons/transforms.js +16 -2
- package/build-module/buttons/transforms.js.map +1 -1
- package/build-module/code/transforms.js +17 -6
- package/build-module/code/transforms.js.map +1 -1
- package/build-module/cover/edit/block-controls.js +15 -4
- package/build-module/cover/edit/block-controls.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +1 -1
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/heading/transforms.js +17 -4
- package/build-module/heading/transforms.js.map +1 -1
- package/build-module/image/edit.js +2 -1
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +12 -4
- package/build-module/image/image.js.map +1 -1
- package/build-module/post-featured-image/edit.js +9 -12
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-title/edit.js +2 -2
- package/build-module/post-title/edit.js.map +1 -1
- package/build-module/utils/caption.js +13 -3
- package/build-module/utils/caption.js.map +1 -1
- package/build-module/utils/get-transformed-metadata.js +51 -0
- package/build-module/utils/get-transformed-metadata.js.map +1 -0
- package/build-style/cover/style-rtl.css +2 -1
- package/build-style/cover/style.css +2 -1
- package/build-style/search/style-rtl.css +2 -0
- package/build-style/search/style.css +2 -0
- package/build-style/style-rtl.css +4 -1
- package/build-style/style.css +4 -1
- package/package.json +12 -12
- package/src/button/edit.js +2 -1
- package/src/buttons/transforms.js +14 -4
- package/src/code/transforms.js +20 -5
- package/src/cover/edit/block-controls.js +16 -2
- package/src/cover/edit/inspector-controls.js +5 -1
- package/src/cover/style.scss +3 -2
- package/src/footnotes/index.php +1 -1
- package/src/heading/transforms.js +27 -8
- package/src/image/edit.js +2 -1
- package/src/image/image.js +12 -4
- package/src/navigation/index.php +7 -3
- package/src/post-featured-image/edit.js +9 -11
- package/src/post-title/edit.js +49 -43
- package/src/search/style.scss +2 -0
- package/src/utils/caption.js +10 -1
- package/src/utils/get-transformed-metadata.js +65 -0
package/build/post-title/edit.js
CHANGED
|
@@ -105,7 +105,7 @@ function PostTitleEdit({
|
|
|
105
105
|
}
|
|
106
106
|
}));
|
|
107
107
|
}
|
|
108
|
-
return (0, _react.createElement)(_react.Fragment, null, blockEditingMode === 'default' && (0, _react.createElement)(_blockEditor.BlockControls, {
|
|
108
|
+
return (0, _react.createElement)(_react.Fragment, null, blockEditingMode === 'default' && (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_blockEditor.BlockControls, {
|
|
109
109
|
group: "block"
|
|
110
110
|
}, (0, _react.createElement)(_blockEditor.HeadingLevelDropdown, {
|
|
111
111
|
value: level,
|
|
@@ -142,6 +142,6 @@ function PostTitleEdit({
|
|
|
142
142
|
onChange: newRel => setAttributes({
|
|
143
143
|
rel: newRel
|
|
144
144
|
})
|
|
145
|
-
})))), titleElement);
|
|
145
|
+
}))))), titleElement);
|
|
146
146
|
}
|
|
147
147
|
//# sourceMappingURL=edit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_classnames","_interopRequireDefault","require","_blockEditor","_components","_i18n","_blocks","_coreData","_hooks","PostTitleEdit","attributes","level","textAlign","isLink","rel","linkTarget","setAttributes","context","postType","postId","queryId","insertBlocksAfter","TagName","isDescendentOfQueryLoop","Number","isFinite","userCanEdit","useCanEditEntity","rawTitle","setTitle","fullTitle","useEntityProp","link","onSplitAtEnd","createBlock","getDefaultBlockName","blockProps","useBlockProps","className","classnames","blockEditingMode","useBlockEditingMode","titleElement","_react","createElement","__","PlainText","tagName","placeholder","value","onChange","__experimentalVersion","__unstableOnSplitAtEnd","dangerouslySetInnerHTML","__html","rendered","href","target","length","onClick","event","preventDefault","Fragment","BlockControls","group","HeadingLevelDropdown","newLevel","AlignmentControl","nextAlign","InspectorControls","PanelBody","title","ToggleControl","__nextHasNoMarginBottom","label","checked","TextControl","newRel"],"sources":["@wordpress/block-library/src/post-title/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tInspectorControls,\n\tuseBlockProps,\n\tPlainText,\n\tHeadingLevelDropdown,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { ToggleControl, TextControl, PanelBody } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { createBlock, getDefaultBlockName } from '@wordpress/blocks';\nimport { useEntityProp } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useCanEditEntity } from '../utils/hooks';\n\nexport default function PostTitleEdit( {\n\tattributes: { level, textAlign, isLink, rel, linkTarget },\n\tsetAttributes,\n\tcontext: { postType, postId, queryId },\n\tinsertBlocksAfter,\n} ) {\n\tconst TagName = 'h' + level;\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\t/**\n\t * Hack: useCanEditEntity may trigger an OPTIONS request to the REST API via the canUser resolver.\n\t * However, when the Post Title is a descendant of a Query Loop block, the title cannot be edited.\n\t * In order to avoid these unnecessary requests, we call the hook without\n\t * the proper data, resulting in returning early without making them.\n\t */\n\tconst userCanEdit = useCanEditEntity(\n\t\t'postType',\n\t\t! isDescendentOfQueryLoop && postType,\n\t\tpostId\n\t);\n\tconst [ rawTitle = '', setTitle, fullTitle ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'title',\n\t\tpostId\n\t);\n\tconst [ link ] = useEntityProp( 'postType', postType, 'link', postId );\n\tconst onSplitAtEnd = () => {\n\t\tinsertBlocksAfter( createBlock( getDefaultBlockName() ) );\n\t};\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t} );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tlet titleElement = <TagName { ...blockProps }>{ __( 'Title' ) }</TagName>;\n\n\tif ( postType && postId ) {\n\t\ttitleElement = userCanEdit ? (\n\t\t\t<PlainText\n\t\t\t\ttagName={ TagName }\n\t\t\t\tplaceholder={ __( 'No Title' ) }\n\t\t\t\tvalue={ rawTitle }\n\t\t\t\tonChange={ setTitle }\n\t\t\t\t__experimentalVersion={ 2 }\n\t\t\t\t__unstableOnSplitAtEnd={ onSplitAtEnd }\n\t\t\t\t{ ...blockProps }\n\t\t\t/>\n\t\t) : (\n\t\t\t<TagName\n\t\t\t\t{ ...blockProps }\n\t\t\t\tdangerouslySetInnerHTML={ { __html: fullTitle?.rendered } }\n\t\t\t/>\n\t\t);\n\t}\n\n\tif ( isLink && postType && postId ) {\n\t\ttitleElement = userCanEdit ? (\n\t\t\t<TagName { ...blockProps }>\n\t\t\t\t<PlainText\n\t\t\t\t\ttagName=\"a\"\n\t\t\t\t\thref={ link }\n\t\t\t\t\ttarget={ linkTarget }\n\t\t\t\t\trel={ rel }\n\t\t\t\t\tplaceholder={ ! rawTitle.length ? __( 'No Title' ) : null }\n\t\t\t\t\tvalue={ rawTitle }\n\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t__experimentalVersion={ 2 }\n\t\t\t\t\t__unstableOnSplitAtEnd={ onSplitAtEnd }\n\t\t\t\t/>\n\t\t\t</TagName>\n\t\t) : (\n\t\t\t<TagName { ...blockProps }>\n\t\t\t\t<a\n\t\t\t\t\thref={ link }\n\t\t\t\t\ttarget={ linkTarget }\n\t\t\t\t\trel={ rel }\n\t\t\t\t\tonClick={ ( event ) => event.preventDefault() }\n\t\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t\t\t\t\t__html: fullTitle?.rendered,\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</TagName>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ blockEditingMode === 'default' && (\n\t\t\t\t<BlockControls group=\"block\">\n\t\t\t\t\t<HeadingLevelDropdown\n\t\t\t\t\t\tvalue={ level }\n\t\t\t\t\t\tonChange={ ( newLevel ) =>\n\t\t\t\t\t\t\tsetAttributes( { level: newLevel } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t<AlignmentControl\n\t\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\t\tonChange={ ( nextAlign ) => {\n\t\t\t\t\t\t\tsetAttributes( { textAlign: nextAlign } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Make title a link' ) }\n\t\t\t\t\t\tonChange={ () => setAttributes( { isLink: ! isLink } ) }\n\t\t\t\t\t\tchecked={ isLink }\n\t\t\t\t\t/>\n\t\t\t\t\t{ isLink && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tlinkTarget: value ? '_blank' : '_self',\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\tchecked={ linkTarget === '_blank' }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\t\t\t\t\tvalue={ rel }\n\t\t\t\t\t\t\t\tonChange={ ( newRel ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( { rel: newRel } )\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</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t{ titleElement }\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,YAAA,GAAAD,OAAA;AASA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAKA,IAAAM,MAAA,GAAAN,OAAA;AAzBA;AACA;AACA;;AAGA;AACA;AACA;;AAeA;AACA;AACA;;AAGe,SAASO,aAAaA,CAAE;EACtCC,UAAU,EAAE;IAAEC,KAAK;IAAEC,SAAS;IAAEC,MAAM;IAAEC,GAAG;IAAEC;EAAW,CAAC;EACzDC,aAAa;EACbC,OAAO,EAAE;IAAEC,QAAQ;IAAEC,MAAM;IAAEC;EAAQ,CAAC;EACtCC;AACD,CAAC,EAAG;EACH,MAAMC,OAAO,GAAG,GAAG,GAAGX,KAAK;E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EAAU,CACnC,CAAC,EACF,IAAA4B,MAAA,CAAAC,aAAA,EAACxC,WAAA,CAAAwE,WAAW;IACXH,uBAAuB;IACvBC,KAAK,EAAG,IAAA7B,QAAE,EAAE,UAAW,CAAG;IAC1BI,KAAK,EAAGnC,GAAK;IACboC,QAAQ,EAAK2B,MAAM,IAClB7D,aAAa,CAAE;MAAEF,GAAG,EAAE+D;IAAO,CAAE;EAC/B,CACD,CACA,CAEO,CACO,CAAC,EAClBnC,YACD,CAAC;AAEL"}
|
|
1
|
+
{"version":3,"names":["_classnames","_interopRequireDefault","require","_blockEditor","_components","_i18n","_blocks","_coreData","_hooks","PostTitleEdit","attributes","level","textAlign","isLink","rel","linkTarget","setAttributes","context","postType","postId","queryId","insertBlocksAfter","TagName","isDescendentOfQueryLoop","Number","isFinite","userCanEdit","useCanEditEntity","rawTitle","setTitle","fullTitle","useEntityProp","link","onSplitAtEnd","createBlock","getDefaultBlockName","blockProps","useBlockProps","className","classnames","blockEditingMode","useBlockEditingMode","titleElement","_react","createElement","__","PlainText","tagName","placeholder","value","onChange","__experimentalVersion","__unstableOnSplitAtEnd","dangerouslySetInnerHTML","__html","rendered","href","target","length","onClick","event","preventDefault","Fragment","BlockControls","group","HeadingLevelDropdown","newLevel","AlignmentControl","nextAlign","InspectorControls","PanelBody","title","ToggleControl","__nextHasNoMarginBottom","label","checked","TextControl","newRel"],"sources":["@wordpress/block-library/src/post-title/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tInspectorControls,\n\tuseBlockProps,\n\tPlainText,\n\tHeadingLevelDropdown,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { ToggleControl, TextControl, PanelBody } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { createBlock, getDefaultBlockName } from '@wordpress/blocks';\nimport { useEntityProp } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useCanEditEntity } from '../utils/hooks';\n\nexport default function PostTitleEdit( {\n\tattributes: { level, textAlign, isLink, rel, linkTarget },\n\tsetAttributes,\n\tcontext: { postType, postId, queryId },\n\tinsertBlocksAfter,\n} ) {\n\tconst TagName = 'h' + level;\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\t/**\n\t * Hack: useCanEditEntity may trigger an OPTIONS request to the REST API via the canUser resolver.\n\t * However, when the Post Title is a descendant of a Query Loop block, the title cannot be edited.\n\t * In order to avoid these unnecessary requests, we call the hook without\n\t * the proper data, resulting in returning early without making them.\n\t */\n\tconst userCanEdit = useCanEditEntity(\n\t\t'postType',\n\t\t! isDescendentOfQueryLoop && postType,\n\t\tpostId\n\t);\n\tconst [ rawTitle = '', setTitle, fullTitle ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'title',\n\t\tpostId\n\t);\n\tconst [ link ] = useEntityProp( 'postType', postType, 'link', postId );\n\tconst onSplitAtEnd = () => {\n\t\tinsertBlocksAfter( createBlock( getDefaultBlockName() ) );\n\t};\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t} );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tlet titleElement = <TagName { ...blockProps }>{ __( 'Title' ) }</TagName>;\n\n\tif ( postType && postId ) {\n\t\ttitleElement = userCanEdit ? (\n\t\t\t<PlainText\n\t\t\t\ttagName={ TagName }\n\t\t\t\tplaceholder={ __( 'No Title' ) }\n\t\t\t\tvalue={ rawTitle }\n\t\t\t\tonChange={ setTitle }\n\t\t\t\t__experimentalVersion={ 2 }\n\t\t\t\t__unstableOnSplitAtEnd={ onSplitAtEnd }\n\t\t\t\t{ ...blockProps }\n\t\t\t/>\n\t\t) : (\n\t\t\t<TagName\n\t\t\t\t{ ...blockProps }\n\t\t\t\tdangerouslySetInnerHTML={ { __html: fullTitle?.rendered } }\n\t\t\t/>\n\t\t);\n\t}\n\n\tif ( isLink && postType && postId ) {\n\t\ttitleElement = userCanEdit ? (\n\t\t\t<TagName { ...blockProps }>\n\t\t\t\t<PlainText\n\t\t\t\t\ttagName=\"a\"\n\t\t\t\t\thref={ link }\n\t\t\t\t\ttarget={ linkTarget }\n\t\t\t\t\trel={ rel }\n\t\t\t\t\tplaceholder={ ! rawTitle.length ? __( 'No Title' ) : null }\n\t\t\t\t\tvalue={ rawTitle }\n\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t__experimentalVersion={ 2 }\n\t\t\t\t\t__unstableOnSplitAtEnd={ onSplitAtEnd }\n\t\t\t\t/>\n\t\t\t</TagName>\n\t\t) : (\n\t\t\t<TagName { ...blockProps }>\n\t\t\t\t<a\n\t\t\t\t\thref={ link }\n\t\t\t\t\ttarget={ linkTarget }\n\t\t\t\t\trel={ rel }\n\t\t\t\t\tonClick={ ( event ) => event.preventDefault() }\n\t\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t\t\t\t\t__html: fullTitle?.rendered,\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</TagName>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ blockEditingMode === 'default' && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls group=\"block\">\n\t\t\t\t\t\t<HeadingLevelDropdown\n\t\t\t\t\t\t\tvalue={ level }\n\t\t\t\t\t\t\tonChange={ ( newLevel ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { level: newLevel } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<AlignmentControl\n\t\t\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\t\t\tonChange={ ( nextAlign ) => {\n\t\t\t\t\t\t\t\tsetAttributes( { textAlign: nextAlign } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t\t<InspectorControls>\n\t\t\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Make title a link' ) }\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( { isLink: ! isLink } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tchecked={ isLink }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{ isLink && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\t\t\tlinkTarget: value\n\t\t\t\t\t\t\t\t\t\t\t\t\t? '_blank'\n\t\t\t\t\t\t\t\t\t\t\t\t\t: '_self',\n\t\t\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tchecked={ linkTarget === '_blank' }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\t\t\t\t\t\t\tvalue={ rel }\n\t\t\t\t\t\t\t\t\t\tonChange={ ( newRel ) =>\n\t\t\t\t\t\t\t\t\t\t\tsetAttributes( { rel: newRel } )\n\t\t\t\t\t\t\t\t\t\t}\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</PanelBody>\n\t\t\t\t\t</InspectorControls>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ titleElement }\n\t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AAK,EAAG,IAAA1B,QAAE,EAAE,UAAW;EAAG,GACpC,IAAAF,MAAA,CAAAC,aAAA,EAACxC,WAAA,CAAAoE,aAAa;IACbC,uBAAuB;IACvBC,KAAK,EAAG,IAAA7B,QAAE,EAAE,mBAAoB,CAAG;IACnCK,QAAQ,EAAGA,CAAA,KACVlC,aAAa,CAAE;MAAEH,MAAM,EAAE,CAAEA;IAAO,CAAE,CACpC;IACD8D,OAAO,EAAG9D;EAAQ,CAClB,CAAC,EACAA,MAAM,IACP,IAAA8B,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAmB,QAAA,QACC,IAAAnB,MAAA,CAAAC,aAAA,EAACxC,WAAA,CAAAoE,aAAa;IACbC,uBAAuB;IACvBC,KAAK,EAAG,IAAA7B,QAAE,EAAE,iBAAkB,CAAG;IACjCK,QAAQ,EAAKD,KAAK,IACjBjC,aAAa,CAAE;MACdD,UAAU,EAAEkC,KAAK,GACd,QAAQ,GACR;IACJ,CAAE,CACF;IACD0B,OAAO,EAAG5D,UAAU,KAAK;EAAU,CACnC,CAAC,EACF,IAAA4B,MAAA,CAAAC,aAAA,EAACxC,WAAA,CAAAwE,WAAW;IACXH,uBAAuB;IACvBC,KAAK,EAAG,IAAA7B,QAAE,EAAE,UAAW,CAAG;IAC1BI,KAAK,EAAGnC,GAAK;IACboC,QAAQ,EAAK2B,MAAM,IAClB7D,aAAa,CAAE;MAAEF,GAAG,EAAE+D;IAAO,CAAE;EAC/B,CACD,CACA,CAEO,CACO,CAClB,CACF,EACCnC,YACD,CAAC;AAEL"}
|
package/build/utils/caption.js
CHANGED
|
@@ -14,6 +14,7 @@ var _blockEditor = require("@wordpress/block-editor");
|
|
|
14
14
|
var _components = require("@wordpress/components");
|
|
15
15
|
var _icons = require("@wordpress/icons");
|
|
16
16
|
var _blocks = require("@wordpress/blocks");
|
|
17
|
+
var _lockUnlock = require("../lock-unlock");
|
|
17
18
|
/**
|
|
18
19
|
* External dependencies
|
|
19
20
|
*/
|
|
@@ -22,6 +23,13 @@ var _blocks = require("@wordpress/blocks");
|
|
|
22
23
|
* WordPress dependencies
|
|
23
24
|
*/
|
|
24
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Internal dependencies
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
const {
|
|
31
|
+
PrivateRichText: RichText
|
|
32
|
+
} = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
|
|
25
33
|
function Caption({
|
|
26
34
|
key = 'caption',
|
|
27
35
|
attributes,
|
|
@@ -31,12 +39,13 @@ function Caption({
|
|
|
31
39
|
placeholder = (0, _i18n.__)('Add caption'),
|
|
32
40
|
label = (0, _i18n.__)('Caption text'),
|
|
33
41
|
showToolbarButton = true,
|
|
34
|
-
className
|
|
42
|
+
className,
|
|
43
|
+
disableEditing
|
|
35
44
|
}) {
|
|
36
45
|
const caption = attributes[key];
|
|
37
46
|
const prevCaption = (0, _compose.usePrevious)(caption);
|
|
38
|
-
const isCaptionEmpty =
|
|
39
|
-
const isPrevCaptionEmpty =
|
|
47
|
+
const isCaptionEmpty = RichText.isEmpty(caption);
|
|
48
|
+
const isPrevCaptionEmpty = RichText.isEmpty(prevCaption);
|
|
40
49
|
const [showCaption, setShowCaption] = (0, _element.useState)(!isCaptionEmpty);
|
|
41
50
|
|
|
42
51
|
// We need to show the caption when changes come from
|
|
@@ -72,7 +81,7 @@ function Caption({
|
|
|
72
81
|
icon: _icons.caption,
|
|
73
82
|
isPressed: showCaption,
|
|
74
83
|
label: showCaption ? (0, _i18n.__)('Remove caption') : (0, _i18n.__)('Add caption')
|
|
75
|
-
})), showCaption && (!
|
|
84
|
+
})), showCaption && (!RichText.isEmpty(caption) || isSelected) && (0, _react.createElement)(RichText, {
|
|
76
85
|
identifier: key,
|
|
77
86
|
tagName: "figcaption",
|
|
78
87
|
className: (0, _classnames.default)(className, (0, _blockEditor.__experimentalGetElementClassName)('caption')),
|
|
@@ -84,7 +93,8 @@ function Caption({
|
|
|
84
93
|
caption: value
|
|
85
94
|
}),
|
|
86
95
|
inlineToolbar: true,
|
|
87
|
-
__unstableOnSplitAtEnd: () => insertBlocksAfter((0, _blocks.createBlock)((0, _blocks.getDefaultBlockName)()))
|
|
96
|
+
__unstableOnSplitAtEnd: () => insertBlocksAfter((0, _blocks.createBlock)((0, _blocks.getDefaultBlockName)())),
|
|
97
|
+
disableEditing: disableEditing
|
|
88
98
|
}));
|
|
89
99
|
}
|
|
90
100
|
//# sourceMappingURL=caption.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_classnames","_interopRequireDefault","require","_element","_compose","_i18n","_blockEditor","_components","_icons","_blocks","Caption","key","attributes","setAttributes","isSelected","insertBlocksAfter","placeholder","__","label","showToolbarButton","className","caption","prevCaption","usePrevious","isCaptionEmpty","
|
|
1
|
+
{"version":3,"names":["_classnames","_interopRequireDefault","require","_element","_compose","_i18n","_blockEditor","_components","_icons","_blocks","_lockUnlock","PrivateRichText","RichText","unlock","blockEditorPrivateApis","Caption","key","attributes","setAttributes","isSelected","insertBlocksAfter","placeholder","__","label","showToolbarButton","className","disableEditing","caption","prevCaption","usePrevious","isCaptionEmpty","isEmpty","isPrevCaptionEmpty","showCaption","setShowCaption","useState","useEffect","ref","useCallback","node","focus","_react","createElement","Fragment","BlockControls","group","ToolbarButton","onClick","undefined","icon","captionIcon","isPressed","identifier","tagName","classnames","__experimentalGetElementClassName","value","onChange","inlineToolbar","__unstableOnSplitAtEnd","createBlock","getDefaultBlockName"],"sources":["@wordpress/block-library/src/utils/caption.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useCallback } from '@wordpress/element';\nimport { usePrevious } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\t__experimentalGetElementClassName,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { ToolbarButton } from '@wordpress/components';\nimport { caption as captionIcon } from '@wordpress/icons';\nimport { createBlock, getDefaultBlockName } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst { PrivateRichText: RichText } = unlock( blockEditorPrivateApis );\n\nexport function Caption( {\n\tkey = 'caption',\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tinsertBlocksAfter,\n\tplaceholder = __( 'Add caption' ),\n\tlabel = __( 'Caption text' ),\n\tshowToolbarButton = true,\n\tclassName,\n\tdisableEditing,\n} ) {\n\tconst caption = attributes[ key ];\n\tconst prevCaption = usePrevious( caption );\n\tconst isCaptionEmpty = RichText.isEmpty( caption );\n\tconst isPrevCaptionEmpty = RichText.isEmpty( prevCaption );\n\tconst [ showCaption, setShowCaption ] = useState( ! isCaptionEmpty );\n\n\t// We need to show the caption when changes come from\n\t// history navigation(undo/redo).\n\tuseEffect( () => {\n\t\tif ( ! isCaptionEmpty && isPrevCaptionEmpty ) {\n\t\t\tsetShowCaption( true );\n\t\t}\n\t}, [ isCaptionEmpty, isPrevCaptionEmpty ] );\n\n\tuseEffect( () => {\n\t\tif ( ! isSelected && isCaptionEmpty ) {\n\t\t\tsetShowCaption( false );\n\t\t}\n\t}, [ isSelected, isCaptionEmpty ] );\n\n\t// Focus the caption when we click to add one.\n\tconst ref = useCallback(\n\t\t( node ) => {\n\t\t\tif ( node && isCaptionEmpty ) {\n\t\t\t\tnode.focus();\n\t\t\t}\n\t\t},\n\t\t[ isCaptionEmpty ]\n\t);\n\treturn (\n\t\t<>\n\t\t\t{ showToolbarButton && (\n\t\t\t\t<BlockControls group=\"block\">\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetShowCaption( ! showCaption );\n\t\t\t\t\t\t\tif ( showCaption && caption ) {\n\t\t\t\t\t\t\t\tsetAttributes( { caption: undefined } );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\ticon={ captionIcon }\n\t\t\t\t\t\tisPressed={ showCaption }\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\tshowCaption\n\t\t\t\t\t\t\t\t? __( 'Remove caption' )\n\t\t\t\t\t\t\t\t: __( 'Add caption' )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ showCaption &&\n\t\t\t\t( ! RichText.isEmpty( caption ) || isSelected ) && (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tidentifier={ key }\n\t\t\t\t\t\ttagName=\"figcaption\"\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t\t__experimentalGetElementClassName( 'caption' )\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\taria-label={ label }\n\t\t\t\t\t\tplaceholder={ placeholder }\n\t\t\t\t\t\tvalue={ caption }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tinlineToolbar\n\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\tinsertBlocksAfter(\n\t\t\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdisableEditing={ disableEditing }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAKA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AAKA,IAAAQ,WAAA,GAAAR,O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E,CACpC,CACA;IACDnC,cAAc,EAAGA;EAAgB,CACjC,CAEF,CAAC;AAEL"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getTransformedMetadata = getTransformedMetadata;
|
|
7
|
+
var _blocks = require("@wordpress/blocks");
|
|
8
|
+
/**
|
|
9
|
+
* WordPress dependencies
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Transform the metadata attribute with only the values and bindings specified by each transform.
|
|
14
|
+
* Returns `undefined` if the input metadata is falsy.
|
|
15
|
+
*
|
|
16
|
+
* @param {Object} metadata Original metadata attribute from the block that is being transformed.
|
|
17
|
+
* @param {Object} newBlockName Name of the final block after the transformation.
|
|
18
|
+
* @param {Function} bindingsCallback Optional callback to transform the `bindings` property object.
|
|
19
|
+
* @return {Object|undefined} New metadata object only with the relevant properties.
|
|
20
|
+
*/
|
|
21
|
+
function getTransformedMetadata(metadata, newBlockName, bindingsCallback) {
|
|
22
|
+
if (!metadata) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const {
|
|
26
|
+
supports
|
|
27
|
+
} = (0, _blocks.getBlockType)(newBlockName);
|
|
28
|
+
// Fixed until an opt-in mechanism is implemented.
|
|
29
|
+
const BLOCK_BINDINGS_SUPPORTED_BLOCKS = ['core/paragraph', 'core/heading', 'core/image', 'core/button'];
|
|
30
|
+
// The metadata properties that should be preserved after the transform.
|
|
31
|
+
const transformSupportedProps = [];
|
|
32
|
+
// If it support bindings, and there is a transform bindings callback, add the `id` and `bindings` properties.
|
|
33
|
+
if (BLOCK_BINDINGS_SUPPORTED_BLOCKS.includes(newBlockName) && bindingsCallback) {
|
|
34
|
+
transformSupportedProps.push('id', 'bindings');
|
|
35
|
+
}
|
|
36
|
+
// If it support block naming (true by default), add the `name` property.
|
|
37
|
+
if (supports.renaming !== false) {
|
|
38
|
+
transformSupportedProps.push('name');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Return early if no supported properties.
|
|
42
|
+
if (!transformSupportedProps.length) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const newMetadata = Object.entries(metadata).reduce((obj, [prop, value]) => {
|
|
46
|
+
// If prop is not supported, don't add it to the new metadata object.
|
|
47
|
+
if (!transformSupportedProps.includes(prop)) {
|
|
48
|
+
return obj;
|
|
49
|
+
}
|
|
50
|
+
obj[prop] = prop === 'bindings' ? bindingsCallback(value) : value;
|
|
51
|
+
return obj;
|
|
52
|
+
}, {});
|
|
53
|
+
|
|
54
|
+
// Return undefined if object is empty.
|
|
55
|
+
return Object.keys(newMetadata).length ? newMetadata : undefined;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=get-transformed-metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_blocks","require","getTransformedMetadata","metadata","newBlockName","bindingsCallback","supports","getBlockType","BLOCK_BINDINGS_SUPPORTED_BLOCKS","transformSupportedProps","includes","push","renaming","length","newMetadata","Object","entries","reduce","obj","prop","value","keys","undefined"],"sources":["@wordpress/block-library/src/utils/get-transformed-metadata.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockType } from '@wordpress/blocks';\n\n/**\n * Transform the metadata attribute with only the values and bindings specified by each transform.\n * Returns `undefined` if the input metadata is falsy.\n *\n * @param {Object} metadata Original metadata attribute from the block that is being transformed.\n * @param {Object} newBlockName Name of the final block after the transformation.\n * @param {Function} bindingsCallback Optional callback to transform the `bindings` property object.\n * @return {Object|undefined} New metadata object only with the relevant properties.\n */\nexport function getTransformedMetadata(\n\tmetadata,\n\tnewBlockName,\n\tbindingsCallback\n) {\n\tif ( ! metadata ) {\n\t\treturn;\n\t}\n\tconst { supports } = getBlockType( newBlockName );\n\t// Fixed until an opt-in mechanism is implemented.\n\tconst BLOCK_BINDINGS_SUPPORTED_BLOCKS = [\n\t\t'core/paragraph',\n\t\t'core/heading',\n\t\t'core/image',\n\t\t'core/button',\n\t];\n\t// The metadata properties that should be preserved after the transform.\n\tconst transformSupportedProps = [];\n\t// If it support bindings, and there is a transform bindings callback, add the `id` and `bindings` properties.\n\tif (\n\t\tBLOCK_BINDINGS_SUPPORTED_BLOCKS.includes( newBlockName ) &&\n\t\tbindingsCallback\n\t) {\n\t\ttransformSupportedProps.push( 'id', 'bindings' );\n\t}\n\t// If it support block naming (true by default), add the `name` property.\n\tif ( supports.renaming !== false ) {\n\t\ttransformSupportedProps.push( 'name' );\n\t}\n\n\t// Return early if no supported properties.\n\tif ( ! transformSupportedProps.length ) {\n\t\treturn;\n\t}\n\n\tconst newMetadata = Object.entries( metadata ).reduce(\n\t\t( obj, [ prop, value ] ) => {\n\t\t\t// If prop is not supported, don't add it to the new metadata object.\n\t\t\tif ( ! transformSupportedProps.includes( prop ) ) {\n\t\t\t\treturn obj;\n\t\t\t}\n\t\t\tobj[ prop ] =\n\t\t\t\tprop === 'bindings' ? bindingsCallback( value ) : value;\n\t\t\treturn obj;\n\t\t},\n\t\t{}\n\t);\n\n\t// Return undefined if object is empty.\n\treturn Object.keys( newMetadata ).length ? newMetadata : undefined;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,sBAAsBA,CACrCC,QAAQ,EACRC,YAAY,EACZC,gBAAgB,EACf;EACD,IAAK,CAAEF,QAAQ,EAAG;IACjB;EACD;EACA,MAAM;IAAEG;EAAS,CAAC,GAAG,IAAAC,oBAAY,EAAEH,YAAa,CAAC;EACjD;EACA,MAAMI,+BAA+B,GAAG,CACvC,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,aAAa,CACb;EACD;EACA,MAAMC,uBAAuB,GAAG,EAAE;EAClC;EACA,IACCD,+BAA+B,CAACE,QAAQ,CAAEN,YAAa,CAAC,IACxDC,gBAAgB,EACf;IACDI,uBAAuB,CAACE,IAAI,CAAE,IAAI,EAAE,UAAW,CAAC;EACjD;EACA;EACA,IAAKL,QAAQ,CAACM,QAAQ,KAAK,KAAK,EAAG;IAClCH,uBAAuB,CAACE,IAAI,CAAE,MAAO,CAAC;EACvC;;EAEA;EACA,IAAK,CAAEF,uBAAuB,CAACI,MAAM,EAAG;IACvC;EACD;EAEA,MAAMC,WAAW,GAAGC,MAAM,CAACC,OAAO,CAAEb,QAAS,CAAC,CAACc,MAAM,CACpD,CAAEC,GAAG,EAAE,CAAEC,IAAI,EAAEC,KAAK,CAAE,KAAM;IAC3B;IACA,IAAK,CAAEX,uBAAuB,CAACC,QAAQ,CAAES,IAAK,CAAC,EAAG;MACjD,OAAOD,GAAG;IACX;IACAA,GAAG,CAAEC,IAAI,CAAE,GACVA,IAAI,KAAK,UAAU,GAAGd,gBAAgB,CAAEe,KAAM,CAAC,GAAGA,KAAK;IACxD,OAAOF,GAAG;EACX,CAAC,EACD,CAAC,CACF,CAAC;;EAED;EACA,OAAOH,MAAM,CAACM,IAAI,CAAEP,WAAY,CAAC,CAACD,MAAM,GAAGC,WAAW,GAAGQ,SAAS;AACnE"}
|
|
@@ -21,7 +21,7 @@ import { Button, ButtonGroup, PanelBody, TextControl, ToolbarButton, Popover } f
|
|
|
21
21
|
import { AlignmentControl, BlockControls, InspectorControls, RichText, useBlockProps, __experimentalUseBorderProps as useBorderProps, __experimentalUseColorProps as useColorProps, __experimentalGetSpacingClassesAndStyles as useSpacingProps, __experimentalGetShadowClassesAndStyles as useShadowProps, __experimentalLinkControl as LinkControl, __experimentalGetElementClassName, store as blockEditorStore, useBlockEditingMode } from '@wordpress/block-editor';
|
|
22
22
|
import { displayShortcut, isKeyboardEvent, ENTER } from '@wordpress/keycodes';
|
|
23
23
|
import { link, linkOff } from '@wordpress/icons';
|
|
24
|
-
import { createBlock, cloneBlock, getDefaultBlockName } from '@wordpress/blocks';
|
|
24
|
+
import { createBlock, cloneBlock, getDefaultBlockName, store as blocksStore } from '@wordpress/blocks';
|
|
25
25
|
import { useMergeRefs, useRefEffect } from '@wordpress/compose';
|
|
26
26
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
27
27
|
const LINK_SETTINGS = [...LinkControl.DEFAULT_LINK_SETTINGS, {
|
|
@@ -189,7 +189,7 @@ function ButtonEdit(props) {
|
|
|
189
189
|
if (!isSelected) {
|
|
190
190
|
return {};
|
|
191
191
|
}
|
|
192
|
-
const blockBindingsSource = unlock(select(
|
|
192
|
+
const blockBindingsSource = unlock(select(blocksStore)).getBlockBindingsSource(metadata?.bindings?.url?.source);
|
|
193
193
|
return {
|
|
194
194
|
lockUrlControls: !!metadata?.bindings?.url && (!blockBindingsSource || blockBindingsSource?.lockAttributesEditing)
|
|
195
195
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","NEW_TAB_TARGET","NOFOLLOW_REL","getUpdatedLinkAttributes","removeAnchorTag","unlock","__","useEffect","useState","useRef","useMemo","Button","ButtonGroup","PanelBody","TextControl","ToolbarButton","Popover","AlignmentControl","BlockControls","InspectorControls","RichText","useBlockProps","__experimentalUseBorderProps","useBorderProps","__experimentalUseColorProps","useColorProps","__experimentalGetSpacingClassesAndStyles","useSpacingProps","__experimentalGetShadowClassesAndStyles","useShadowProps","__experimentalLinkControl","LinkControl","__experimentalGetElementClassName","store","blockEditorStore","useBlockEditingMode","displayShortcut","isKeyboardEvent","ENTER","link","linkOff","createBlock","cloneBlock","getDefaultBlockName","useMergeRefs","useRefEffect","useSelect","useDispatch","LINK_SETTINGS","DEFAULT_LINK_SETTINGS","id","title","useEnter","props","replaceBlocks","selectionChange","getBlock","getBlockRootClientId","getBlockIndex","propsRef","current","element","onKeyDown","event","defaultPrevented","keyCode","content","clientId","length","preventDefault","topParentListBlock","blockIndex","head","innerBlocks","slice","middle","after","tail","addEventListener","removeEventListener","WidthPanel","selectedWidth","setAttributes","handleChange","newWidth","width","undefined","createElement","map","widthValue","key","size","variant","onClick","ButtonEdit","attributes","className","isSelected","onReplace","mergeBlocks","tagName","textAlign","linkTarget","placeholder","rel","style","text","url","metadata","TagName","primary","startEditing","primaryShift","unlink","richTextRef","focus","popoverAnchor","setPopoverAnchor","borderProps","colorProps","spacingProps","shadowProps","ref","blockProps","blockEditingMode","isEditingURL","setIsEditingURL","isURLSet","opensInNewTab","nofollow","includes","isLinkTag","linkValue","useEnterRef","mergedRef","lockUrlControls","select","blockBindingsSource","getBlockBindingsSource","bindings","source","lockAttributesEditing","Fragment","fontSize","value","onChange","withoutInteractiveFormatting","border","radius","onSplit","onMerge","identifier","group","nextAlign","name","icon","shortcut","isActive","placement","onClose","anchor","focusOnMount","__unstableSlotName","shift","newURL","newOpensInNewTab","newNofollow","onRemove","forceIsEditingLink","settings","__nextHasNoMarginBottom","label","newRel"],"sources":["@wordpress/block-library/src/button/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * Internal dependencies\n */\nimport { NEW_TAB_TARGET, NOFOLLOW_REL } from './constants';\nimport { getUpdatedLinkAttributes } from './get-updated-link-attributes';\nimport removeAnchorTag from '../utils/remove-anchor-tag';\nimport { unlock } from '../lock-unlock';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useEffect, useState, useRef, useMemo } from '@wordpress/element';\nimport {\n\tButton,\n\tButtonGroup,\n\tPanelBody,\n\tTextControl,\n\tToolbarButton,\n\tPopover,\n} from '@wordpress/components';\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\t__experimentalUseBorderProps as useBorderProps,\n\t__experimentalUseColorProps as useColorProps,\n\t__experimentalGetSpacingClassesAndStyles as useSpacingProps,\n\t__experimentalGetShadowClassesAndStyles as useShadowProps,\n\t__experimentalLinkControl as LinkControl,\n\t__experimentalGetElementClassName,\n\tstore as blockEditorStore,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { displayShortcut, isKeyboardEvent, ENTER } from '@wordpress/keycodes';\nimport { link, linkOff } from '@wordpress/icons';\nimport {\n\tcreateBlock,\n\tcloneBlock,\n\tgetDefaultBlockName,\n} from '@wordpress/blocks';\nimport { useMergeRefs, useRefEffect } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\nconst LINK_SETTINGS = [\n\t...LinkControl.DEFAULT_LINK_SETTINGS,\n\t{\n\t\tid: 'nofollow',\n\t\ttitle: __( 'Mark as nofollow' ),\n\t},\n];\n\nfunction useEnter( props ) {\n\tconst { replaceBlocks, selectionChange } = useDispatch( blockEditorStore );\n\tconst { getBlock, getBlockRootClientId, getBlockIndex } =\n\t\tuseSelect( blockEditorStore );\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\treturn useRefEffect( ( element ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented || event.keyCode !== ENTER ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst { content, clientId } = propsRef.current;\n\t\t\tif ( content.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tevent.preventDefault();\n\t\t\tconst topParentListBlock = getBlock(\n\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t);\n\t\t\tconst blockIndex = getBlockIndex( clientId );\n\t\t\tconst head = cloneBlock( {\n\t\t\t\t...topParentListBlock,\n\t\t\t\tinnerBlocks: topParentListBlock.innerBlocks.slice(\n\t\t\t\t\t0,\n\t\t\t\t\tblockIndex\n\t\t\t\t),\n\t\t\t} );\n\t\t\tconst middle = createBlock( getDefaultBlockName() );\n\t\t\tconst after = topParentListBlock.innerBlocks.slice(\n\t\t\t\tblockIndex + 1\n\t\t\t);\n\t\t\tconst tail = after.length\n\t\t\t\t? [\n\t\t\t\t\t\tcloneBlock( {\n\t\t\t\t\t\t\t...topParentListBlock,\n\t\t\t\t\t\t\tinnerBlocks: after,\n\t\t\t\t\t\t} ),\n\t\t\t\t ]\n\t\t\t\t: [];\n\t\t\treplaceBlocks(\n\t\t\t\ttopParentListBlock.clientId,\n\t\t\t\t[ head, middle, ...tail ],\n\t\t\t\t1\n\t\t\t);\n\t\t\t// We manually change the selection here because we are replacing\n\t\t\t// a different block than the selected one.\n\t\t\tselectionChange( middle.clientId );\n\t\t}\n\n\t\telement.addEventListener( 'keydown', onKeyDown );\n\t\treturn () => {\n\t\t\telement.removeEventListener( 'keydown', onKeyDown );\n\t\t};\n\t}, [] );\n}\n\nfunction WidthPanel( { selectedWidth, setAttributes } ) {\n\tfunction handleChange( newWidth ) {\n\t\t// Check if we are toggling the width off\n\t\tconst width = selectedWidth === newWidth ? undefined : newWidth;\n\n\t\t// Update attributes.\n\t\tsetAttributes( { width } );\n\t}\n\n\treturn (\n\t\t<PanelBody title={ __( 'Width settings' ) }>\n\t\t\t<ButtonGroup aria-label={ __( 'Button width' ) }>\n\t\t\t\t{ [ 25, 50, 75, 100 ].map( ( widthValue ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ widthValue }\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\twidthValue === selectedWidth\n\t\t\t\t\t\t\t\t\t? 'primary'\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonClick={ () => handleChange( widthValue ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ widthValue }%\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</ButtonGroup>\n\t\t</PanelBody>\n\t);\n}\n\nfunction ButtonEdit( props ) {\n\tconst {\n\t\tattributes,\n\t\tsetAttributes,\n\t\tclassName,\n\t\tisSelected,\n\t\tonReplace,\n\t\tmergeBlocks,\n\t\tclientId,\n\t} = props;\n\tconst {\n\t\ttagName,\n\t\ttextAlign,\n\t\tlinkTarget,\n\t\tplaceholder,\n\t\trel,\n\t\tstyle,\n\t\ttext,\n\t\turl,\n\t\twidth,\n\t\tmetadata,\n\t} = attributes;\n\n\tconst TagName = tagName || 'a';\n\n\tfunction onKeyDown( event ) {\n\t\tif ( isKeyboardEvent.primary( event, 'k' ) ) {\n\t\t\tstartEditing( event );\n\t\t} else if ( isKeyboardEvent.primaryShift( event, 'k' ) ) {\n\t\t\tunlink();\n\t\t\trichTextRef.current?.focus();\n\t\t}\n\t}\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\n\tconst borderProps = useBorderProps( attributes );\n\tconst colorProps = useColorProps( attributes );\n\tconst spacingProps = useSpacingProps( attributes );\n\tconst shadowProps = useShadowProps( attributes );\n\tconst ref = useRef();\n\tconst richTextRef = useRef();\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, ref ] ),\n\t\tonKeyDown,\n\t} );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst [ isEditingURL, setIsEditingURL ] = useState( false );\n\tconst isURLSet = !! url;\n\tconst opensInNewTab = linkTarget === NEW_TAB_TARGET;\n\tconst nofollow = !! rel?.includes( NOFOLLOW_REL );\n\tconst isLinkTag = 'a' === TagName;\n\n\tfunction startEditing( event ) {\n\t\tevent.preventDefault();\n\t\tsetIsEditingURL( true );\n\t}\n\n\tfunction unlink() {\n\t\tsetAttributes( {\n\t\t\turl: undefined,\n\t\t\tlinkTarget: undefined,\n\t\t\trel: undefined,\n\t\t} );\n\t\tsetIsEditingURL( false );\n\t}\n\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsEditingURL( false );\n\t\t}\n\t}, [ isSelected ] );\n\n\t// Memoize link value to avoid overriding the LinkControl's internal state.\n\t// This is a temporary fix. See https://github.com/WordPress/gutenberg/issues/51256.\n\tconst linkValue = useMemo(\n\t\t() => ( { url, opensInNewTab, nofollow } ),\n\t\t[ url, opensInNewTab, nofollow ]\n\t);\n\n\tconst useEnterRef = useEnter( { content: text, clientId } );\n\tconst mergedRef = useMergeRefs( [ useEnterRef, richTextRef ] );\n\n\tconst { lockUrlControls = false } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! isSelected ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst blockBindingsSource = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t).getBlockBindingsSource( metadata?.bindings?.url?.source );\n\n\t\t\treturn {\n\t\t\t\tlockUrlControls:\n\t\t\t\t\t!! metadata?.bindings?.url &&\n\t\t\t\t\t( ! blockBindingsSource ||\n\t\t\t\t\t\tblockBindingsSource?.lockAttributesEditing ),\n\t\t\t};\n\t\t},\n\t\t[ isSelected ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\t{ ...blockProps }\n\t\t\t\tclassName={ classnames( blockProps.className, {\n\t\t\t\t\t[ `has-custom-width wp-block-button__width-${ width }` ]:\n\t\t\t\t\t\twidth,\n\t\t\t\t\t[ `has-custom-font-size` ]: blockProps.style.fontSize,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<RichText\n\t\t\t\t\tref={ mergedRef }\n\t\t\t\t\taria-label={ __( 'Button text' ) }\n\t\t\t\t\tplaceholder={ placeholder || __( 'Add text…' ) }\n\t\t\t\t\tvalue={ text }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\ttext: removeAnchorTag( value ),\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t'wp-block-button__link',\n\t\t\t\t\t\tcolorProps.className,\n\t\t\t\t\t\tborderProps.className,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t\t\t\t\t\t// For backwards compatibility add style that isn't\n\t\t\t\t\t\t\t// provided via block support.\n\t\t\t\t\t\t\t'no-border-radius': style?.border?.radius === 0,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t__experimentalGetElementClassName( 'button' )\n\t\t\t\t\t) }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t...borderProps.style,\n\t\t\t\t\t\t...colorProps.style,\n\t\t\t\t\t\t...spacingProps.style,\n\t\t\t\t\t\t...shadowProps.style,\n\t\t\t\t\t} }\n\t\t\t\t\tonSplit={ ( value ) =>\n\t\t\t\t\t\tcreateBlock( 'core/button', {\n\t\t\t\t\t\t\t...attributes,\n\t\t\t\t\t\t\ttext: value,\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\tidentifier=\"text\"\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t{ blockEditingMode === 'default' && (\n\t\t\t\t\t<AlignmentControl\n\t\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\t\tonChange={ ( nextAlign ) => {\n\t\t\t\t\t\t\tsetAttributes( { textAlign: nextAlign } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ! isURLSet && isLinkTag && ! lockUrlControls && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\ticon={ link }\n\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\tonClick={ startEditing }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ isURLSet && isLinkTag && ! lockUrlControls && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\ttitle={ __( 'Unlink' ) }\n\t\t\t\t\t\tshortcut={ displayShortcut.primaryShift( 'k' ) }\n\t\t\t\t\t\tonClick={ unlink }\n\t\t\t\t\t\tisActive={ true }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockControls>\n\t\t\t{ isLinkTag &&\n\t\t\t\tisSelected &&\n\t\t\t\t( isEditingURL || isURLSet ) &&\n\t\t\t\t! lockUrlControls && (\n\t\t\t\t\t<Popover\n\t\t\t\t\t\tplacement=\"bottom\"\n\t\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\t\tsetIsEditingURL( false );\n\t\t\t\t\t\t\trichTextRef.current?.focus();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\t\tfocusOnMount={ isEditingURL ? 'firstElement' : false }\n\t\t\t\t\t\t__unstableSlotName={ '__unstable-block-tools-after' }\n\t\t\t\t\t\tshift\n\t\t\t\t\t>\n\t\t\t\t\t\t<LinkControl\n\t\t\t\t\t\t\tvalue={ linkValue }\n\t\t\t\t\t\t\tonChange={ ( {\n\t\t\t\t\t\t\t\turl: newURL,\n\t\t\t\t\t\t\t\topensInNewTab: newOpensInNewTab,\n\t\t\t\t\t\t\t\tnofollow: newNofollow,\n\t\t\t\t\t\t\t} ) =>\n\t\t\t\t\t\t\t\tsetAttributes(\n\t\t\t\t\t\t\t\t\tgetUpdatedLinkAttributes( {\n\t\t\t\t\t\t\t\t\t\trel,\n\t\t\t\t\t\t\t\t\t\turl: newURL,\n\t\t\t\t\t\t\t\t\t\topensInNewTab: newOpensInNewTab,\n\t\t\t\t\t\t\t\t\t\tnofollow: newNofollow,\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\tonRemove={ () => {\n\t\t\t\t\t\t\t\tunlink();\n\t\t\t\t\t\t\t\trichTextRef.current?.focus();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tforceIsEditingLink={ isEditingURL }\n\t\t\t\t\t\t\tsettings={ LINK_SETTINGS }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Popover>\n\t\t\t\t) }\n\t\t\t<InspectorControls>\n\t\t\t\t<WidthPanel\n\t\t\t\t\tselectedWidth={ width }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t{ isLinkTag && (\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\t\t\tvalue={ rel || '' }\n\t\t\t\t\t\tonChange={ ( newRel ) =>\n\t\t\t\t\t\t\tsetAttributes( { rel: newRel } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n}\n\nexport default ButtonEdit;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,cAAc,EAAEC,YAAY,QAAQ,aAAa;AAC1D,SAASC,wBAAwB,QAAQ,+BAA+B;AACxE,OAAOC,eAAe,MAAM,4BAA4B;AACxD,SAASC,MAAM,QAAQ,gBAAgB;;AAEvC;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,OAAO,QAAQ,oBAAoB;AACzE,SACCC,MAAM,EACNC,WAAW,EACXC,SAAS,EACTC,WAAW,EACXC,aAAa,EACbC,OAAO,QACD,uBAAuB;AAC9B,SACCC,gBAAgB,EAChBC,aAAa,EACbC,iBAAiB,EACjBC,QAAQ,EACRC,aAAa,EACbC,4BAA4B,IAAIC,cAAc,EAC9CC,2BAA2B,IAAIC,aAAa,EAC5CC,wCAAwC,IAAIC,eAAe,EAC3DC,uCAAuC,IAAIC,cAAc,EACzDC,yBAAyB,IAA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C;IAC7B,CAAG;IACHqD,kBAAkB,EAAG3C,YAAc;IACnC4C,QAAQ,EAAGzH;EAAe,CAC1B,CACO,CACT,EACFuC,aAAA,CAACpE,iBAAiB,QACjBoE,aAAA,CAACP,UAAU;IACVC,aAAa,EAAGI,KAAO;IACvBH,aAAa,EAAGA;EAAe,CAC/B,CACiB,CAAC,EACpBK,aAAA,CAACpE,iBAAiB;IAACqI,KAAK,EAAC;EAAU,GAChCrB,SAAS,IACV5C,aAAA,CAACzE,WAAW;IACX4J,uBAAuB;IACvBC,KAAK,EAAGrK,EAAE,CAAE,UAAW,CAAG;IAC1B0I,KAAK,EAAGxC,GAAG,IAAI,EAAI;IACnByC,QAAQ,EAAK2B,MAAM,IAClB1F,aAAa,CAAE;MAAEsB,GAAG,EAAEoE;IAAO,CAAE;EAC/B,CACD,CAEgB,CAClB,CAAC;AAEL;AAEA,eAAe9E,UAAU"}
|
|
1
|
+
{"version":3,"names":["classnames","NEW_TAB_TARGET","NOFOLLOW_REL","getUpdatedLinkAttributes","removeAnchorTag","unlock","__","useEffect","useState","useRef","useMemo","Button","ButtonGroup","PanelBody","TextControl","ToolbarButton","Popover","AlignmentControl","BlockControls","InspectorControls","RichText","useBlockProps","__experimentalUseBorderProps","useBorderProps","__experimentalUseColorProps","useColorProps","__experimentalGetSpacingClassesAndStyles","useSpacingProps","__experimentalGetShadowClassesAndStyles","useShadowProps","__experimentalLinkControl","LinkControl","__experimentalGetElementClassName","store","blockEditorStore","useBlockEditingMode","displayShortcut","isKeyboardEvent","ENTER","link","linkOff","createBlock","cloneBlock","getDefaultBlockName","blocksStore","useMergeRefs","useRefEffect","useSelect","useDispatch","LINK_SETTINGS","DEFAULT_LINK_SETTINGS","id","title","useEnter","props","replaceBlocks","selectionChange","getBlock","getBlockRootClientId","getBlockIndex","propsRef","current","element","onKeyDown","event","defaultPrevented","keyCode","content","clientId","length","preventDefault","topParentListBlock","blockIndex","head","innerBlocks","slice","middle","after","tail","addEventListener","removeEventListener","WidthPanel","selectedWidth","setAttributes","handleChange","newWidth","width","undefined","createElement","map","widthValue","key","size","variant","onClick","ButtonEdit","attributes","className","isSelected","onReplace","mergeBlocks","tagName","textAlign","linkTarget","placeholder","rel","style","text","url","metadata","TagName","primary","startEditing","primaryShift","unlink","richTextRef","focus","popoverAnchor","setPopoverAnchor","borderProps","colorProps","spacingProps","shadowProps","ref","blockProps","blockEditingMode","isEditingURL","setIsEditingURL","isURLSet","opensInNewTab","nofollow","includes","isLinkTag","linkValue","useEnterRef","mergedRef","lockUrlControls","select","blockBindingsSource","getBlockBindingsSource","bindings","source","lockAttributesEditing","Fragment","fontSize","value","onChange","withoutInteractiveFormatting","border","radius","onSplit","onMerge","identifier","group","nextAlign","name","icon","shortcut","isActive","placement","onClose","anchor","focusOnMount","__unstableSlotName","shift","newURL","newOpensInNewTab","newNofollow","onRemove","forceIsEditingLink","settings","__nextHasNoMarginBottom","label","newRel"],"sources":["@wordpress/block-library/src/button/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * Internal dependencies\n */\nimport { NEW_TAB_TARGET, NOFOLLOW_REL } from './constants';\nimport { getUpdatedLinkAttributes } from './get-updated-link-attributes';\nimport removeAnchorTag from '../utils/remove-anchor-tag';\nimport { unlock } from '../lock-unlock';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useEffect, useState, useRef, useMemo } from '@wordpress/element';\nimport {\n\tButton,\n\tButtonGroup,\n\tPanelBody,\n\tTextControl,\n\tToolbarButton,\n\tPopover,\n} from '@wordpress/components';\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\t__experimentalUseBorderProps as useBorderProps,\n\t__experimentalUseColorProps as useColorProps,\n\t__experimentalGetSpacingClassesAndStyles as useSpacingProps,\n\t__experimentalGetShadowClassesAndStyles as useShadowProps,\n\t__experimentalLinkControl as LinkControl,\n\t__experimentalGetElementClassName,\n\tstore as blockEditorStore,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { displayShortcut, isKeyboardEvent, ENTER } from '@wordpress/keycodes';\nimport { link, linkOff } from '@wordpress/icons';\nimport {\n\tcreateBlock,\n\tcloneBlock,\n\tgetDefaultBlockName,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useMergeRefs, useRefEffect } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\nconst LINK_SETTINGS = [\n\t...LinkControl.DEFAULT_LINK_SETTINGS,\n\t{\n\t\tid: 'nofollow',\n\t\ttitle: __( 'Mark as nofollow' ),\n\t},\n];\n\nfunction useEnter( props ) {\n\tconst { replaceBlocks, selectionChange } = useDispatch( blockEditorStore );\n\tconst { getBlock, getBlockRootClientId, getBlockIndex } =\n\t\tuseSelect( blockEditorStore );\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\treturn useRefEffect( ( element ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented || event.keyCode !== ENTER ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst { content, clientId } = propsRef.current;\n\t\t\tif ( content.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tevent.preventDefault();\n\t\t\tconst topParentListBlock = getBlock(\n\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t);\n\t\t\tconst blockIndex = getBlockIndex( clientId );\n\t\t\tconst head = cloneBlock( {\n\t\t\t\t...topParentListBlock,\n\t\t\t\tinnerBlocks: topParentListBlock.innerBlocks.slice(\n\t\t\t\t\t0,\n\t\t\t\t\tblockIndex\n\t\t\t\t),\n\t\t\t} );\n\t\t\tconst middle = createBlock( getDefaultBlockName() );\n\t\t\tconst after = topParentListBlock.innerBlocks.slice(\n\t\t\t\tblockIndex + 1\n\t\t\t);\n\t\t\tconst tail = after.length\n\t\t\t\t? [\n\t\t\t\t\t\tcloneBlock( {\n\t\t\t\t\t\t\t...topParentListBlock,\n\t\t\t\t\t\t\tinnerBlocks: after,\n\t\t\t\t\t\t} ),\n\t\t\t\t ]\n\t\t\t\t: [];\n\t\t\treplaceBlocks(\n\t\t\t\ttopParentListBlock.clientId,\n\t\t\t\t[ head, middle, ...tail ],\n\t\t\t\t1\n\t\t\t);\n\t\t\t// We manually change the selection here because we are replacing\n\t\t\t// a different block than the selected one.\n\t\t\tselectionChange( middle.clientId );\n\t\t}\n\n\t\telement.addEventListener( 'keydown', onKeyDown );\n\t\treturn () => {\n\t\t\telement.removeEventListener( 'keydown', onKeyDown );\n\t\t};\n\t}, [] );\n}\n\nfunction WidthPanel( { selectedWidth, setAttributes } ) {\n\tfunction handleChange( newWidth ) {\n\t\t// Check if we are toggling the width off\n\t\tconst width = selectedWidth === newWidth ? undefined : newWidth;\n\n\t\t// Update attributes.\n\t\tsetAttributes( { width } );\n\t}\n\n\treturn (\n\t\t<PanelBody title={ __( 'Width settings' ) }>\n\t\t\t<ButtonGroup aria-label={ __( 'Button width' ) }>\n\t\t\t\t{ [ 25, 50, 75, 100 ].map( ( widthValue ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ widthValue }\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\twidthValue === selectedWidth\n\t\t\t\t\t\t\t\t\t? 'primary'\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonClick={ () => handleChange( widthValue ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ widthValue }%\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</ButtonGroup>\n\t\t</PanelBody>\n\t);\n}\n\nfunction ButtonEdit( props ) {\n\tconst {\n\t\tattributes,\n\t\tsetAttributes,\n\t\tclassName,\n\t\tisSelected,\n\t\tonReplace,\n\t\tmergeBlocks,\n\t\tclientId,\n\t} = props;\n\tconst {\n\t\ttagName,\n\t\ttextAlign,\n\t\tlinkTarget,\n\t\tplaceholder,\n\t\trel,\n\t\tstyle,\n\t\ttext,\n\t\turl,\n\t\twidth,\n\t\tmetadata,\n\t} = attributes;\n\n\tconst TagName = tagName || 'a';\n\n\tfunction onKeyDown( event ) {\n\t\tif ( isKeyboardEvent.primary( event, 'k' ) ) {\n\t\t\tstartEditing( event );\n\t\t} else if ( isKeyboardEvent.primaryShift( event, 'k' ) ) {\n\t\t\tunlink();\n\t\t\trichTextRef.current?.focus();\n\t\t}\n\t}\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\n\tconst borderProps = useBorderProps( attributes );\n\tconst colorProps = useColorProps( attributes );\n\tconst spacingProps = useSpacingProps( attributes );\n\tconst shadowProps = useShadowProps( attributes );\n\tconst ref = useRef();\n\tconst richTextRef = useRef();\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, ref ] ),\n\t\tonKeyDown,\n\t} );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst [ isEditingURL, setIsEditingURL ] = useState( false );\n\tconst isURLSet = !! url;\n\tconst opensInNewTab = linkTarget === NEW_TAB_TARGET;\n\tconst nofollow = !! rel?.includes( NOFOLLOW_REL );\n\tconst isLinkTag = 'a' === TagName;\n\n\tfunction startEditing( event ) {\n\t\tevent.preventDefault();\n\t\tsetIsEditingURL( true );\n\t}\n\n\tfunction unlink() {\n\t\tsetAttributes( {\n\t\t\turl: undefined,\n\t\t\tlinkTarget: undefined,\n\t\t\trel: undefined,\n\t\t} );\n\t\tsetIsEditingURL( false );\n\t}\n\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsEditingURL( false );\n\t\t}\n\t}, [ isSelected ] );\n\n\t// Memoize link value to avoid overriding the LinkControl's internal state.\n\t// This is a temporary fix. See https://github.com/WordPress/gutenberg/issues/51256.\n\tconst linkValue = useMemo(\n\t\t() => ( { url, opensInNewTab, nofollow } ),\n\t\t[ url, opensInNewTab, nofollow ]\n\t);\n\n\tconst useEnterRef = useEnter( { content: text, clientId } );\n\tconst mergedRef = useMergeRefs( [ useEnterRef, richTextRef ] );\n\n\tconst { lockUrlControls = false } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! isSelected ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst blockBindingsSource = unlock(\n\t\t\t\tselect( blocksStore )\n\t\t\t).getBlockBindingsSource( metadata?.bindings?.url?.source );\n\n\t\t\treturn {\n\t\t\t\tlockUrlControls:\n\t\t\t\t\t!! metadata?.bindings?.url &&\n\t\t\t\t\t( ! blockBindingsSource ||\n\t\t\t\t\t\tblockBindingsSource?.lockAttributesEditing ),\n\t\t\t};\n\t\t},\n\t\t[ isSelected ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\t{ ...blockProps }\n\t\t\t\tclassName={ classnames( blockProps.className, {\n\t\t\t\t\t[ `has-custom-width wp-block-button__width-${ width }` ]:\n\t\t\t\t\t\twidth,\n\t\t\t\t\t[ `has-custom-font-size` ]: blockProps.style.fontSize,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<RichText\n\t\t\t\t\tref={ mergedRef }\n\t\t\t\t\taria-label={ __( 'Button text' ) }\n\t\t\t\t\tplaceholder={ placeholder || __( 'Add text…' ) }\n\t\t\t\t\tvalue={ text }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\ttext: removeAnchorTag( value ),\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t'wp-block-button__link',\n\t\t\t\t\t\tcolorProps.className,\n\t\t\t\t\t\tborderProps.className,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t\t\t\t\t\t// For backwards compatibility add style that isn't\n\t\t\t\t\t\t\t// provided via block support.\n\t\t\t\t\t\t\t'no-border-radius': style?.border?.radius === 0,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t__experimentalGetElementClassName( 'button' )\n\t\t\t\t\t) }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t...borderProps.style,\n\t\t\t\t\t\t...colorProps.style,\n\t\t\t\t\t\t...spacingProps.style,\n\t\t\t\t\t\t...shadowProps.style,\n\t\t\t\t\t} }\n\t\t\t\t\tonSplit={ ( value ) =>\n\t\t\t\t\t\tcreateBlock( 'core/button', {\n\t\t\t\t\t\t\t...attributes,\n\t\t\t\t\t\t\ttext: value,\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\tidentifier=\"text\"\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t{ blockEditingMode === 'default' && (\n\t\t\t\t\t<AlignmentControl\n\t\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\t\tonChange={ ( nextAlign ) => {\n\t\t\t\t\t\t\tsetAttributes( { textAlign: nextAlign } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ! isURLSet && isLinkTag && ! lockUrlControls && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\ticon={ link }\n\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\tonClick={ startEditing }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ isURLSet && isLinkTag && ! lockUrlControls && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\ttitle={ __( 'Unlink' ) }\n\t\t\t\t\t\tshortcut={ displayShortcut.primaryShift( 'k' ) }\n\t\t\t\t\t\tonClick={ unlink }\n\t\t\t\t\t\tisActive={ true }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockControls>\n\t\t\t{ isLinkTag &&\n\t\t\t\tisSelected &&\n\t\t\t\t( isEditingURL || isURLSet ) &&\n\t\t\t\t! lockUrlControls && (\n\t\t\t\t\t<Popover\n\t\t\t\t\t\tplacement=\"bottom\"\n\t\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\t\tsetIsEditingURL( false );\n\t\t\t\t\t\t\trichTextRef.current?.focus();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\t\tfocusOnMount={ isEditingURL ? 'firstElement' : false }\n\t\t\t\t\t\t__unstableSlotName={ '__unstable-block-tools-after' }\n\t\t\t\t\t\tshift\n\t\t\t\t\t>\n\t\t\t\t\t\t<LinkControl\n\t\t\t\t\t\t\tvalue={ linkValue }\n\t\t\t\t\t\t\tonChange={ ( {\n\t\t\t\t\t\t\t\turl: newURL,\n\t\t\t\t\t\t\t\topensInNewTab: newOpensInNewTab,\n\t\t\t\t\t\t\t\tnofollow: newNofollow,\n\t\t\t\t\t\t\t} ) =>\n\t\t\t\t\t\t\t\tsetAttributes(\n\t\t\t\t\t\t\t\t\tgetUpdatedLinkAttributes( {\n\t\t\t\t\t\t\t\t\t\trel,\n\t\t\t\t\t\t\t\t\t\turl: newURL,\n\t\t\t\t\t\t\t\t\t\topensInNewTab: newOpensInNewTab,\n\t\t\t\t\t\t\t\t\t\tnofollow: newNofollow,\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\tonRemove={ () => {\n\t\t\t\t\t\t\t\tunlink();\n\t\t\t\t\t\t\t\trichTextRef.current?.focus();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tforceIsEditingLink={ isEditingURL }\n\t\t\t\t\t\t\tsettings={ LINK_SETTINGS }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Popover>\n\t\t\t\t) }\n\t\t\t<InspectorControls>\n\t\t\t\t<WidthPanel\n\t\t\t\t\tselectedWidth={ width }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t{ isLinkTag && (\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\t\t\tvalue={ rel || '' }\n\t\t\t\t\t\tonChange={ ( newRel ) =>\n\t\t\t\t\t\t\tsetAttributes( { rel: newRel } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n}\n\nexport default ButtonEdit;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,cAAc,EAAEC,YAAY,QAAQ,aAAa;AAC1D,SAASC,wBAAwB,QAAQ,+BAA+B;AACxE,OAAOC,eAAe,MAAM,4BAA4B;AACxD,SAASC,MAAM,QAAQ,gBAAgB;;AAEvC;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,OAAO,QAAQ,oBAAoB;AACzE,SACCC,MAAM,EACNC,WAAW,EACXC,SAAS,EACTC,WAAW,EACXC,aAAa,EACbC,OAAO,QACD,uBAAuB;AAC9B,SACCC,gBAAgB,EAChBC,aAAa,EACbC,iBAAiB,EACjBC,QAAQ,EACRC,aAAa,EACbC,4BAA4B,IAAIC,cAAc,EAC9CC,2BAA2B,IAAIC,aAAa,EAC5CC,wCAAwC,IAAIC,eAAe,EAC3D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AM,CAAC,CAAC;MACRC,WAAW,CAACtD,OAAO,EAAEuD,KAAK,CAAC,CAAC;IAC7B,CAAG;IACHqD,kBAAkB,EAAG3C,YAAc;IACnC4C,QAAQ,EAAGzH;EAAe,CAC1B,CACO,CACT,EACFuC,aAAA,CAACrE,iBAAiB,QACjBqE,aAAA,CAACP,UAAU;IACVC,aAAa,EAAGI,KAAO;IACvBH,aAAa,EAAGA;EAAe,CAC/B,CACiB,CAAC,EACpBK,aAAA,CAACrE,iBAAiB;IAACsI,KAAK,EAAC;EAAU,GAChCrB,SAAS,IACV5C,aAAA,CAAC1E,WAAW;IACX6J,uBAAuB;IACvBC,KAAK,EAAGtK,EAAE,CAAE,UAAW,CAAG;IAC1B2I,KAAK,EAAGxC,GAAG,IAAI,EAAI;IACnByC,QAAQ,EAAK2B,MAAM,IAClB1F,aAAa,CAAE;MAAEsB,GAAG,EAAEoE;IAAO,CAAE;EAC/B,CACD,CAEgB,CAClB,CAAC;AAEL;AAEA,eAAe9E,UAAU"}
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { createBlock } from '@wordpress/blocks';
|
|
5
5
|
import { __unstableCreateElement as createElement } from '@wordpress/rich-text';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { getTransformedMetadata } from '../utils/get-transformed-metadata';
|
|
6
11
|
const transforms = {
|
|
7
12
|
from: [{
|
|
8
13
|
type: 'block',
|
|
@@ -24,7 +29,11 @@ const transforms = {
|
|
|
24
29
|
createBlock('core/buttons', {},
|
|
25
30
|
// Loop the selected buttons.
|
|
26
31
|
buttons.map(attributes => {
|
|
27
|
-
const
|
|
32
|
+
const {
|
|
33
|
+
content,
|
|
34
|
+
metadata
|
|
35
|
+
} = attributes;
|
|
36
|
+
const element = createElement(document, content);
|
|
28
37
|
// Remove any HTML tags.
|
|
29
38
|
const text = element.innerText || '';
|
|
30
39
|
// Get first url.
|
|
@@ -33,7 +42,12 @@ const transforms = {
|
|
|
33
42
|
// Create singular button in the buttons block.
|
|
34
43
|
return createBlock('core/button', {
|
|
35
44
|
text,
|
|
36
|
-
url
|
|
45
|
+
url,
|
|
46
|
+
metadata: getTransformedMetadata(metadata, 'core/button', ({
|
|
47
|
+
content: contentBinding
|
|
48
|
+
}) => ({
|
|
49
|
+
text: contentBinding
|
|
50
|
+
}))
|
|
37
51
|
});
|
|
38
52
|
})),
|
|
39
53
|
isMatch: paragraphs => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createBlock","__unstableCreateElement","createElement","transforms","from","type","isMultiBlock","blocks","transform","buttons","map","attributes","
|
|
1
|
+
{"version":3,"names":["createBlock","__unstableCreateElement","createElement","getTransformedMetadata","transforms","from","type","isMultiBlock","blocks","transform","buttons","map","attributes","content","metadata","element","document","text","innerText","link","querySelector","url","getAttribute","contentBinding","isMatch","paragraphs","every","links","querySelectorAll","length"],"sources":["@wordpress/block-library/src/buttons/transforms.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { __unstableCreateElement as createElement } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { getTransformedMetadata } from '../utils/get-transformed-metadata';\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tisMultiBlock: true,\n\t\t\tblocks: [ 'core/button' ],\n\t\t\ttransform: ( buttons ) =>\n\t\t\t\t// Creates the buttons block.\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/buttons',\n\t\t\t\t\t{},\n\t\t\t\t\t// Loop the selected buttons.\n\t\t\t\t\tbuttons.map( ( attributes ) =>\n\t\t\t\t\t\t// Create singular button in the buttons block.\n\t\t\t\t\t\tcreateBlock( 'core/button', attributes )\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tisMultiBlock: true,\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\ttransform: ( buttons ) =>\n\t\t\t\t// Creates the buttons block.\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/buttons',\n\t\t\t\t\t{},\n\t\t\t\t\t// Loop the selected buttons.\n\t\t\t\t\tbuttons.map( ( attributes ) => {\n\t\t\t\t\t\tconst { content, metadata } = attributes;\n\t\t\t\t\t\tconst element = createElement( document, content );\n\t\t\t\t\t\t// Remove any HTML tags.\n\t\t\t\t\t\tconst text = element.innerText || '';\n\t\t\t\t\t\t// Get first url.\n\t\t\t\t\t\tconst link = element.querySelector( 'a' );\n\t\t\t\t\t\tconst url = link?.getAttribute( 'href' );\n\t\t\t\t\t\t// Create singular button in the buttons block.\n\t\t\t\t\t\treturn createBlock( 'core/button', {\n\t\t\t\t\t\t\ttext,\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\tmetadata: getTransformedMetadata(\n\t\t\t\t\t\t\t\tmetadata,\n\t\t\t\t\t\t\t\t'core/button',\n\t\t\t\t\t\t\t\t( { content: contentBinding } ) => ( {\n\t\t\t\t\t\t\t\t\ttext: contentBinding,\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),\n\t\t\tisMatch: ( paragraphs ) => {\n\t\t\t\treturn paragraphs.every( ( attributes ) => {\n\t\t\t\t\tconst element = createElement(\n\t\t\t\t\t\tdocument,\n\t\t\t\t\t\tattributes.content\n\t\t\t\t\t);\n\t\t\t\t\tconst text = element.innerText || '';\n\t\t\t\t\tconst links = element.querySelectorAll( 'a' );\n\t\t\t\t\treturn text.length <= 30 && links.length <= 1;\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default transforms;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,uBAAuB,IAAIC,aAAa,QAAQ,sBAAsB;;AAE/E;AACA;AACA;AACA,SAASC,sBAAsB,Q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AC5Bc,QAAQ,EACRJ,UAAU,CAACC,OACZ,CAAC;QACD,MAAMI,IAAI,GAAGF,OAAO,CAACG,SAAS,IAAI,EAAE;QACpC,MAAMS,KAAK,GAAGZ,OAAO,CAACa,gBAAgB,CAAE,GAAI,CAAC;QAC7C,OAAOX,IAAI,CAACY,MAAM,IAAI,EAAE,IAAIF,KAAK,CAACE,MAAM,IAAI,CAAC;MAC9C,CAAE,CAAC;IACJ;EACD,CAAC;AAEH,CAAC;AAED,eAAezB,UAAU"}
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { createBlock } from '@wordpress/blocks';
|
|
5
5
|
import { create, toHTMLString } from '@wordpress/rich-text';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { getTransformedMetadata } from '../utils/get-transformed-metadata';
|
|
6
11
|
const transforms = {
|
|
7
12
|
from: [{
|
|
8
13
|
type: 'enter',
|
|
@@ -12,15 +17,18 @@ const transforms = {
|
|
|
12
17
|
type: 'block',
|
|
13
18
|
blocks: ['core/paragraph'],
|
|
14
19
|
transform: ({
|
|
15
|
-
content
|
|
20
|
+
content,
|
|
21
|
+
metadata
|
|
16
22
|
}) => createBlock('core/code', {
|
|
17
|
-
content
|
|
23
|
+
content,
|
|
24
|
+
metadata: getTransformedMetadata(metadata, 'core/code')
|
|
18
25
|
})
|
|
19
26
|
}, {
|
|
20
27
|
type: 'block',
|
|
21
28
|
blocks: ['core/html'],
|
|
22
29
|
transform: ({
|
|
23
|
-
content: text
|
|
30
|
+
content: text,
|
|
31
|
+
metadata
|
|
24
32
|
}) => {
|
|
25
33
|
return createBlock('core/code', {
|
|
26
34
|
// The HTML is plain text (with plain line breaks), so
|
|
@@ -29,7 +37,8 @@ const transforms = {
|
|
|
29
37
|
value: create({
|
|
30
38
|
text
|
|
31
39
|
})
|
|
32
|
-
})
|
|
40
|
+
}),
|
|
41
|
+
metadata: getTransformedMetadata(metadata, 'core/code')
|
|
33
42
|
});
|
|
34
43
|
}
|
|
35
44
|
}, {
|
|
@@ -51,9 +60,11 @@ const transforms = {
|
|
|
51
60
|
type: 'block',
|
|
52
61
|
blocks: ['core/paragraph'],
|
|
53
62
|
transform: ({
|
|
54
|
-
content
|
|
63
|
+
content,
|
|
64
|
+
metadata
|
|
55
65
|
}) => createBlock('core/paragraph', {
|
|
56
|
-
content
|
|
66
|
+
content,
|
|
67
|
+
metadata: getTransformedMetadata(metadata, 'core/paragraph')
|
|
57
68
|
})
|
|
58
69
|
}]
|
|
59
70
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createBlock","create","toHTMLString","transforms","from","type","regExp","transform","blocks","content","text","value","isMatch","node","nodeName","children","length","firstChild","schema","pre","code","to"],"sources":["@wordpress/block-library/src/code/transforms.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { create, toHTMLString } from '@wordpress/rich-text';\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'enter',\n\t\t\tregExp: /^```$/,\n\t\t\ttransform: () => createBlock( 'core/code' ),\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\ttransform: ( { content } ) =>\n\t\t\t\tcreateBlock( 'core/code', {
|
|
1
|
+
{"version":3,"names":["createBlock","create","toHTMLString","getTransformedMetadata","transforms","from","type","regExp","transform","blocks","content","metadata","text","value","isMatch","node","nodeName","children","length","firstChild","schema","pre","code","to"],"sources":["@wordpress/block-library/src/code/transforms.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { create, toHTMLString } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { getTransformedMetadata } from '../utils/get-transformed-metadata';\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'enter',\n\t\t\tregExp: /^```$/,\n\t\t\ttransform: () => createBlock( 'core/code' ),\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\ttransform: ( { content, metadata } ) =>\n\t\t\t\tcreateBlock( 'core/code', {\n\t\t\t\t\tcontent,\n\t\t\t\t\tmetadata: getTransformedMetadata( metadata, 'core/code' ),\n\t\t\t\t} ),\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/html' ],\n\t\t\ttransform: ( { content: text, metadata } ) => {\n\t\t\t\treturn createBlock( 'core/code', {\n\t\t\t\t\t// The HTML is plain text (with plain line breaks), so\n\t\t\t\t\t// convert it to rich text.\n\t\t\t\t\tcontent: toHTMLString( { value: create( { text } ) } ),\n\t\t\t\t\tmetadata: getTransformedMetadata( metadata, 'core/code' ),\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'raw',\n\t\t\tisMatch: ( node ) =>\n\t\t\t\tnode.nodeName === 'PRE' &&\n\t\t\t\tnode.children.length === 1 &&\n\t\t\t\tnode.firstChild.nodeName === 'CODE',\n\t\t\tschema: {\n\t\t\t\tpre: {\n\t\t\t\t\tchildren: {\n\t\t\t\t\t\tcode: {\n\t\t\t\t\t\t\tchildren: {\n\t\t\t\t\t\t\t\t'#text': {},\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},\n\t\t\t},\n\t\t},\n\t],\n\tto: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\ttransform: ( { content, metadata } ) =>\n\t\t\t\tcreateBlock( 'core/paragraph', {\n\t\t\t\t\tcontent,\n\t\t\t\t\tmetadata: getTransformedMetadata(\n\t\t\t\t\t\tmetadata,\n\t\t\t\t\t\t'core/paragraph'\n\t\t\t\t\t),\n\t\t\t\t} ),\n\t\t},\n\t],\n};\n\nexport default transforms;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAAS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AC;YACX;UACD;QACD;MACD;IACD;EACD,CAAC,CACD;EACDM,EAAE,EAAE,CACH;IACCjB,IAAI,EAAE,OAAO;IACbG,MAAM,EAAE,CAAE,gBAAgB,CAAE;IAC5BD,SAAS,EAAEA,CAAE;MAAEE,OAAO;MAAEC;IAAS,CAAC,KACjCX,WAAW,CAAE,gBAAgB,EAAE;MAC9BU,OAAO;MACPC,QAAQ,EAAER,sBAAsB,CAC/BQ,QAAQ,EACR,gBACD;IACD,CAAE;EACJ,CAAC;AAEH,CAAC;AAED,eAAeP,UAAU"}
|
|
@@ -3,13 +3,17 @@ import { createElement, Fragment } from "react";
|
|
|
3
3
|
* WordPress dependencies
|
|
4
4
|
*/
|
|
5
5
|
import { useState } from '@wordpress/element';
|
|
6
|
-
import { BlockControls, MediaReplaceFlow, __experimentalBlockAlignmentMatrixControl as BlockAlignmentMatrixControl, __experimentalBlockFullHeightAligmentControl as FullHeightAlignmentControl } from '@wordpress/block-editor';
|
|
6
|
+
import { BlockControls, MediaReplaceFlow, __experimentalBlockAlignmentMatrixControl as BlockAlignmentMatrixControl, __experimentalBlockFullHeightAligmentControl as FullHeightAlignmentControl, privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
7
7
|
import { __ } from '@wordpress/i18n';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Internal dependencies
|
|
11
11
|
*/
|
|
12
12
|
import { ALLOWED_MEDIA_TYPES } from '../shared';
|
|
13
|
+
import { unlock } from '../../lock-unlock';
|
|
14
|
+
const {
|
|
15
|
+
cleanEmptyObject
|
|
16
|
+
} = unlock(blockEditorPrivateApis);
|
|
13
17
|
export default function CoverBlockControls({
|
|
14
18
|
attributes,
|
|
15
19
|
setAttributes,
|
|
@@ -30,7 +34,7 @@ export default function CoverBlockControls({
|
|
|
30
34
|
} = currentSettings;
|
|
31
35
|
const [prevMinHeightValue, setPrevMinHeightValue] = useState(minHeight);
|
|
32
36
|
const [prevMinHeightUnit, setPrevMinHeightUnit] = useState(minHeightUnit);
|
|
33
|
-
const isMinFullHeight = minHeightUnit === 'vh' && minHeight === 100;
|
|
37
|
+
const isMinFullHeight = minHeightUnit === 'vh' && minHeight === 100 && !attributes?.style?.dimensions?.aspectRatio;
|
|
34
38
|
const toggleMinFullHeight = () => {
|
|
35
39
|
if (isMinFullHeight) {
|
|
36
40
|
// If there aren't previous values, take the default ones.
|
|
@@ -50,10 +54,17 @@ export default function CoverBlockControls({
|
|
|
50
54
|
setPrevMinHeightValue(minHeight);
|
|
51
55
|
setPrevMinHeightUnit(minHeightUnit);
|
|
52
56
|
|
|
53
|
-
// Set full height.
|
|
57
|
+
// Set full height, and clear any aspect ratio value.
|
|
54
58
|
return setAttributes({
|
|
55
59
|
minHeight: 100,
|
|
56
|
-
minHeightUnit: 'vh'
|
|
60
|
+
minHeightUnit: 'vh',
|
|
61
|
+
style: cleanEmptyObject({
|
|
62
|
+
...attributes?.style,
|
|
63
|
+
dimensions: {
|
|
64
|
+
...attributes?.style?.dimensions,
|
|
65
|
+
aspectRatio: undefined // Reset aspect ratio when minHeight is set.
|
|
66
|
+
}
|
|
67
|
+
})
|
|
57
68
|
});
|
|
58
69
|
};
|
|
59
70
|
return createElement(Fragment, null, createElement(BlockControls, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useState","BlockControls","MediaReplaceFlow","__experimentalBlockAlignmentMatrixControl","BlockAlignmentMatrixControl","__experimentalBlockFullHeightAligmentControl","FullHeightAlignmentControl","__","ALLOWED_MEDIA_TYPES","CoverBlockControls","attributes","setAttributes","onSelectMedia","currentSettings","toggleUseFeaturedImage","contentPosition","id","useFeaturedImage","minHeight","minHeightUnit","hasInnerBlocks","url","prevMinHeightValue","setPrevMinHeightValue","prevMinHeightUnit","setPrevMinHeightUnit","isMinFullHeight","toggleMinFullHeight","undefined","createElement","Fragment","group","label","value","onChange","nextPosition","isDisabled","isActive","onToggle","mediaId","mediaURL","allowedTypes","accept","onSelect","onToggleFeaturedImage","name"],"sources":["@wordpress/block-library/src/cover/edit/block-controls.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\n\nimport {\n\tBlockControls,\n\tMediaReplaceFlow,\n\t__experimentalBlockAlignmentMatrixControl as BlockAlignmentMatrixControl,\n\t__experimentalBlockFullHeightAligmentControl as FullHeightAlignmentControl,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { ALLOWED_MEDIA_TYPES } from '../shared';\n\nexport default function CoverBlockControls( {\n\tattributes,\n\tsetAttributes,\n\tonSelectMedia,\n\tcurrentSettings,\n\ttoggleUseFeaturedImage,\n} ) {\n\tconst { contentPosition, id, useFeaturedImage, minHeight, minHeightUnit } =\n\t\tattributes;\n\tconst { hasInnerBlocks, url } = currentSettings;\n\n\tconst [ prevMinHeightValue, setPrevMinHeightValue ] = useState( minHeight );\n\tconst [ prevMinHeightUnit, setPrevMinHeightUnit ] =\n\t\tuseState( minHeightUnit );\n\tconst isMinFullHeight
|
|
1
|
+
{"version":3,"names":["useState","BlockControls","MediaReplaceFlow","__experimentalBlockAlignmentMatrixControl","BlockAlignmentMatrixControl","__experimentalBlockFullHeightAligmentControl","FullHeightAlignmentControl","privateApis","blockEditorPrivateApis","__","ALLOWED_MEDIA_TYPES","unlock","cleanEmptyObject","CoverBlockControls","attributes","setAttributes","onSelectMedia","currentSettings","toggleUseFeaturedImage","contentPosition","id","useFeaturedImage","minHeight","minHeightUnit","hasInnerBlocks","url","prevMinHeightValue","setPrevMinHeightValue","prevMinHeightUnit","setPrevMinHeightUnit","isMinFullHeight","style","dimensions","aspectRatio","toggleMinFullHeight","undefined","createElement","Fragment","group","label","value","onChange","nextPosition","isDisabled","isActive","onToggle","mediaId","mediaURL","allowedTypes","accept","onSelect","onToggleFeaturedImage","name"],"sources":["@wordpress/block-library/src/cover/edit/block-controls.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\n\nimport {\n\tBlockControls,\n\tMediaReplaceFlow,\n\t__experimentalBlockAlignmentMatrixControl as BlockAlignmentMatrixControl,\n\t__experimentalBlockFullHeightAligmentControl as FullHeightAlignmentControl,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { ALLOWED_MEDIA_TYPES } from '../shared';\nimport { unlock } from '../../lock-unlock';\n\nconst { cleanEmptyObject } = unlock( blockEditorPrivateApis );\n\nexport default function CoverBlockControls( {\n\tattributes,\n\tsetAttributes,\n\tonSelectMedia,\n\tcurrentSettings,\n\ttoggleUseFeaturedImage,\n} ) {\n\tconst { contentPosition, id, useFeaturedImage, minHeight, minHeightUnit } =\n\t\tattributes;\n\tconst { hasInnerBlocks, url } = currentSettings;\n\n\tconst [ prevMinHeightValue, setPrevMinHeightValue ] = useState( minHeight );\n\tconst [ prevMinHeightUnit, setPrevMinHeightUnit ] =\n\t\tuseState( minHeightUnit );\n\tconst isMinFullHeight =\n\t\tminHeightUnit === 'vh' &&\n\t\tminHeight === 100 &&\n\t\t! attributes?.style?.dimensions?.aspectRatio;\n\tconst toggleMinFullHeight = () => {\n\t\tif ( isMinFullHeight ) {\n\t\t\t// If there aren't previous values, take the default ones.\n\t\t\tif ( prevMinHeightUnit === 'vh' && prevMinHeightValue === 100 ) {\n\t\t\t\treturn setAttributes( {\n\t\t\t\t\tminHeight: undefined,\n\t\t\t\t\tminHeightUnit: undefined,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\t// Set the previous values of height.\n\t\t\treturn setAttributes( {\n\t\t\t\tminHeight: prevMinHeightValue,\n\t\t\t\tminHeightUnit: prevMinHeightUnit,\n\t\t\t} );\n\t\t}\n\n\t\tsetPrevMinHeightValue( minHeight );\n\t\tsetPrevMinHeightUnit( minHeightUnit );\n\n\t\t// Set full height, and clear any aspect ratio value.\n\t\treturn setAttributes( {\n\t\t\tminHeight: 100,\n\t\t\tminHeightUnit: 'vh',\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...attributes?.style,\n\t\t\t\tdimensions: {\n\t\t\t\t\t...attributes?.style?.dimensions,\n\t\t\t\t\taspectRatio: undefined, // Reset aspect ratio when minHeight is set.\n\t\t\t\t},\n\t\t\t} ),\n\t\t} );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<BlockAlignmentMatrixControl\n\t\t\t\t\tlabel={ __( 'Change content position' ) }\n\t\t\t\t\tvalue={ contentPosition }\n\t\t\t\t\tonChange={ ( nextPosition ) =>\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tcontentPosition: nextPosition,\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t\tisDisabled={ ! hasInnerBlocks }\n\t\t\t\t/>\n\t\t\t\t<FullHeightAlignmentControl\n\t\t\t\t\tisActive={ isMinFullHeight }\n\t\t\t\t\tonToggle={ toggleMinFullHeight }\n\t\t\t\t\tisDisabled={ ! hasInnerBlocks }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ url }\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\taccept=\"image/*,video/*\"\n\t\t\t\t\tonSelect={ onSelectMedia }\n\t\t\t\t\tonToggleFeaturedImage={ toggleUseFeaturedImage }\n\t\t\t\t\tuseFeaturedImage={ useFeaturedImage }\n\t\t\t\t\tname={ ! url ? __( 'Add Media' ) : __( 'Replace' ) }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,oBAAoB;AAE7C,SACCC,aAAa,EACbC,gBAAgB,EAChBC,yCAAyC,IAAIC,2BAA2B,EACxEC,4CAA4C,IAAIC,0BAA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ownByDefault: true,
|
|
218
218
|
panelId: clientId
|
|
219
219
|
}, createElement(CoverHeightInput, {
|
|
220
|
-
value: minHeight,
|
|
220
|
+
value: attributes?.style?.dimensions?.aspectRatio ? '' : minHeight,
|
|
221
221
|
unit: minHeightUnit,
|
|
222
222
|
onChange: newMinHeight => setAttributes({
|
|
223
223
|
minHeight: newMinHeight,
|