@wordpress/block-library 8.25.1-next.79a6196f.0 → 8.27.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 +4 -0
- package/build/avatar/edit.js +2 -2
- package/build/avatar/edit.js.map +1 -1
- package/build/block/edit.js +75 -12
- package/build/block/edit.js.map +1 -1
- package/build/block/{v1/edit.native.js → edit.native.js} +4 -4
- package/build/block/edit.native.js.map +1 -0
- package/build/block/index.js +5 -3
- package/build/block/index.js.map +1 -1
- package/build/button/edit.js +24 -6
- package/build/button/edit.js.map +1 -1
- package/build/button/index.js +1 -0
- package/build/button/index.js.map +1 -1
- package/build/button/save.js +3 -1
- package/build/button/save.js.map +1 -1
- package/build/embed/edit.js +3 -2
- package/build/embed/edit.js.map +1 -1
- package/build/file/index.js +0 -1
- package/build/file/index.js.map +1 -1
- package/build/footnotes/edit.js +2 -1
- package/build/footnotes/edit.js.map +1 -1
- package/build/footnotes/format.js +17 -19
- package/build/footnotes/format.js.map +1 -1
- package/build/heading/edit.js +2 -1
- package/build/heading/edit.js.map +1 -1
- package/build/heading/edit.native.js +141 -0
- package/build/heading/edit.native.js.map +1 -0
- package/build/heading/index.js +1 -0
- package/build/heading/index.js.map +1 -1
- package/build/image/edit.js +8 -4
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +33 -7
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +6 -3
- package/build/image/index.js.map +1 -1
- package/build/more/index.js +4 -0
- package/build/more/index.js.map +1 -1
- package/build/navigation/edit/index.js +2 -2
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/index.js +0 -1
- package/build/navigation/index.js.map +1 -1
- package/build/paragraph/edit.js +2 -1
- package/build/paragraph/edit.js.map +1 -1
- package/build/paragraph/index.js +1 -1
- package/build/paragraph/transforms.js +1 -1
- package/build/post-content/edit.js +2 -2
- package/build/post-content/edit.js.map +1 -1
- package/build/post-date/edit.js +1 -1
- package/build/post-date/edit.js.map +1 -1
- package/build/post-navigation-link/edit.js +43 -2
- package/build/post-navigation-link/edit.js.map +1 -1
- package/build/post-navigation-link/index.js +8 -0
- package/build/post-navigation-link/index.js.map +1 -1
- package/build/pullquote/index.js +4 -0
- package/build/pullquote/index.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +3 -3
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/query-content.js +2 -2
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/edit/query-placeholder.js +6 -7
- package/build/query/edit/query-placeholder.js.map +1 -1
- package/build/query/index.js +1 -2
- package/build/query/index.js.map +1 -1
- package/build/query/variations.js +8 -1
- package/build/query/variations.js.map +1 -1
- package/build/query/view.js +31 -12
- package/build/query/view.js.map +1 -1
- package/build/search/index.js +0 -1
- package/build/search/index.js.map +1 -1
- package/build/table-of-contents/hooks.js +2 -2
- package/build/table-of-contents/hooks.js.map +1 -1
- package/build/template-part/edit/advanced-controls.js +1 -4
- package/build/template-part/edit/advanced-controls.js.map +1 -1
- package/build/template-part/edit/index.js +39 -17
- package/build/template-part/edit/index.js.map +1 -1
- package/build/video/edit.native.js +7 -2
- package/build/video/edit.native.js.map +1 -1
- package/build/video/transforms.js +17 -0
- package/build/video/transforms.js.map +1 -1
- package/build-module/avatar/edit.js +2 -2
- package/build-module/avatar/edit.js.map +1 -1
- package/build-module/block/edit.js +74 -11
- package/build-module/block/edit.js.map +1 -1
- package/build-module/block/{v1/edit.native.js → edit.native.js} +3 -3
- package/build-module/block/edit.native.js.map +1 -0
- package/build-module/block/index.js +5 -3
- package/build-module/block/index.js.map +1 -1
- package/build-module/button/edit.js +25 -7
- package/build-module/button/edit.js.map +1 -1
- package/build-module/button/index.js +1 -0
- package/build-module/button/index.js.map +1 -1
- package/build-module/button/save.js +4 -2
- package/build-module/button/save.js.map +1 -1
- package/build-module/embed/edit.js +3 -2
- package/build-module/embed/edit.js.map +1 -1
- package/build-module/file/index.js +0 -1
- package/build-module/file/index.js.map +1 -1
- package/build-module/footnotes/edit.js +2 -1
- package/build-module/footnotes/edit.js.map +1 -1
- package/build-module/footnotes/format.js +17 -19
- package/build-module/footnotes/format.js.map +1 -1
- package/build-module/heading/edit.js +3 -2
- package/build-module/heading/edit.js.map +1 -1
- package/build-module/heading/edit.native.js +132 -0
- package/build-module/heading/edit.native.js.map +1 -0
- package/build-module/heading/index.js +1 -0
- package/build-module/heading/index.js.map +1 -1
- package/build-module/image/edit.js +9 -5
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +33 -7
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +6 -3
- package/build-module/image/index.js.map +1 -1
- package/build-module/more/index.js +4 -0
- package/build-module/more/index.js.map +1 -1
- package/build-module/navigation/edit/index.js +1 -1
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/index.js +0 -1
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/paragraph/edit.js +3 -2
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/paragraph/index.js +1 -1
- package/build-module/paragraph/transforms.js +1 -1
- package/build-module/post-content/edit.js +1 -1
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/post-date/edit.js +1 -1
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-navigation-link/edit.js +44 -3
- package/build-module/post-navigation-link/edit.js.map +1 -1
- package/build-module/post-navigation-link/index.js +8 -0
- package/build-module/post-navigation-link/index.js.map +1 -1
- package/build-module/pullquote/index.js +4 -0
- package/build-module/pullquote/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +4 -4
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/query-content.js +2 -2
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/edit/query-placeholder.js +7 -8
- package/build-module/query/edit/query-placeholder.js.map +1 -1
- package/build-module/query/index.js +1 -2
- package/build-module/query/index.js.map +1 -1
- package/build-module/query/variations.js +8 -1
- package/build-module/query/variations.js.map +1 -1
- package/build-module/query/view.js +30 -9
- package/build-module/query/view.js.map +1 -1
- package/build-module/search/index.js +0 -1
- package/build-module/search/index.js.map +1 -1
- package/build-module/table-of-contents/hooks.js +2 -2
- package/build-module/table-of-contents/hooks.js.map +1 -1
- package/build-module/template-part/edit/advanced-controls.js +1 -4
- package/build-module/template-part/edit/advanced-controls.js.map +1 -1
- package/build-module/template-part/edit/index.js +38 -16
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/video/edit.native.js +7 -2
- package/build-module/video/edit.native.js.map +1 -1
- package/build-module/video/transforms.js +17 -0
- package/build-module/video/transforms.js.map +1 -1
- package/build-style/common-rtl.css +4 -2
- package/build-style/common.css +4 -2
- package/build-style/cover/style-rtl.css +1 -2
- package/build-style/cover/style.css +1 -2
- package/build-style/editor-rtl.css +6 -4
- package/build-style/editor.css +6 -4
- package/build-style/gallery/style-rtl.css +2 -4
- package/build-style/gallery/style.css +2 -4
- package/build-style/image/editor-rtl.css +6 -0
- package/build-style/image/editor.css +6 -0
- package/build-style/page-list/editor-rtl.css +0 -4
- package/build-style/page-list/editor.css +0 -4
- package/build-style/pullquote/style-rtl.css +10 -1
- package/build-style/pullquote/style.css +10 -1
- package/build-style/search/style-rtl.css +2 -1
- package/build-style/search/style.css +2 -1
- package/build-style/style-rtl.css +19 -11
- package/build-style/style.css +19 -11
- package/build-style/video/style-rtl.css +1 -2
- package/build-style/video/style.css +1 -2
- package/package.json +34 -32
- package/src/avatar/edit.js +16 -18
- package/src/block/block.json +3 -0
- package/src/block/edit.js +96 -14
- package/src/block/{v1/edit.native.js → edit.native.js} +4 -4
- package/src/block/index.js +2 -3
- package/src/block/index.php +3 -31
- package/src/button/block.json +1 -0
- package/src/button/edit.js +76 -43
- package/src/button/save.js +3 -0
- package/src/embed/edit.js +3 -2
- package/src/file/block.json +0 -1
- package/src/file/index.php +11 -57
- package/src/footnotes/edit.js +2 -1
- package/src/footnotes/format.js +34 -31
- package/src/footnotes/index.php +20 -11
- package/src/heading/block.json +1 -0
- package/src/heading/edit.js +18 -14
- package/src/heading/edit.native.js +144 -0
- package/src/image/block.json +7 -3
- package/src/image/edit.js +19 -6
- package/src/image/editor.scss +6 -1
- package/src/image/image.js +101 -42
- package/src/image/index.js +6 -0
- package/src/image/index.php +14 -51
- package/src/more/index.js +6 -0
- package/src/navigation/block.json +0 -1
- package/src/navigation/edit/index.js +2 -2
- package/src/navigation/index.php +777 -28
- package/src/navigation-link/index.php +78 -16
- package/src/page-list/editor.scss +0 -4
- package/src/paragraph/block.json +1 -1
- package/src/paragraph/edit.js +23 -19
- package/src/post-content/edit.js +2 -2
- package/src/post-date/edit.js +38 -33
- package/src/post-navigation-link/block.json +8 -0
- package/src/post-navigation-link/edit.js +63 -1
- package/src/post-navigation-link/index.php +17 -3
- package/src/post-terms/index.php +13 -4
- package/src/pullquote/block.json +4 -0
- package/src/pullquote/style.scss +13 -1
- package/src/query/block.json +1 -2
- package/src/query/edit/inspector-controls/index.js +137 -146
- package/src/query/edit/query-content.js +9 -7
- package/src/query/edit/query-placeholder.js +11 -11
- package/src/query/index.php +33 -71
- package/src/query/variations.js +4 -0
- package/src/query/view.js +24 -19
- package/src/search/block.json +0 -1
- package/src/search/index.php +18 -36
- package/src/table-of-contents/hooks.js +2 -2
- package/src/template-part/edit/advanced-controls.js +2 -3
- package/src/template-part/edit/index.js +77 -50
- package/src/template-part/index.php +2 -2
- package/src/video/edit.native.js +5 -2
- package/src/video/test/edit.native.js +38 -0
- package/src/video/transforms.js +32 -0
- package/tsconfig.json +1 -0
- package/build/block/v1/edit.js +0 -116
- package/build/block/v1/edit.js.map +0 -1
- package/build/block/v1/edit.native.js.map +0 -1
- package/build-module/block/v1/edit.js +0 -108
- package/build-module/block/v1/edit.js.map +0 -1
- package/build-module/block/v1/edit.native.js.map +0 -1
- package/src/block/v1/edit.js +0 -163
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"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","interactive","contentEditable","edit","Edit","value","onChange","isObjectActive","context","postType","registry","getSelectedBlockClientId","getBlocks","getBlockRootClientId","getBlockName","getBlockParentsByBlockName","select","
|
|
1
|
+
{"version":3,"names":["v4","createId","__","formatListNumbered","icon","insertObject","RichTextToolbarButton","store","blockEditorStore","privateApis","useSelect","useDispatch","useRegistry","coreDataStore","createBlock","blocksStore","unlock","usesContextKey","formatName","POST_CONTENT_BLOCK_NAME","SYNCED_PATTERN_BLOCK_NAME","format","title","tagName","className","attributes","interactive","contentEditable","edit","Edit","value","onChange","isObjectActive","context","postType","postId","registry","getSelectedBlockClientId","getBlocks","getBlockRootClientId","getBlockName","getBlockParentsByBlockName","select","isFootnotesSupported","getBlockType","entityRecord","getEntityRecord","meta","footnotes","_getBlockParentsByBlockName","_getSelectedBlockClientId","parentCoreBlocks","length","selectionChange","insertBlock","onClick","batch","id","object","replacements","start","newValue","type","innerHTML","end","selectedClientId","parentPostContent","blocks","fnBlock","queue","block","shift","name","push","innerBlocks","rootClientId","undefined","clientId","createElement","isActive"],"sources":["@wordpress/block-library/src/footnotes/format.js"],"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 { store as coreDataStore } from '@wordpress/core-data';\nimport { createBlock, store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\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\tinteractive: true,\n\tcontentEditable: false,\n\t[ usesContextKey ]: [ 'postType', 'postId' ],\n\tedit: function Edit( {\n\t\tvalue,\n\t\tonChange,\n\t\tisObjectActive,\n\t\tcontext: { postType, postId },\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} = registry.select( blockEditorStore );\n\t\tconst isFootnotesSupported = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tif (\n\t\t\t\t\t! select( blocksStore ).getBlockType( 'core/footnotes' )\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tconst entityRecord = select( coreDataStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId\n\t\t\t\t);\n\n\t\t\t\tif ( 'string' !== typeof entityRecord?.meta?.footnotes ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Checks if the selected block lives within a pattern.\n\t\t\t\tconst {\n\t\t\t\t\tgetBlockParentsByBlockName: _getBlockParentsByBlockName,\n\t\t\t\t\tgetSelectedBlockClientId: _getSelectedBlockClientId,\n\t\t\t\t} = select( blockEditorStore );\n\t\t\t\tconst parentCoreBlocks = _getBlockParentsByBlockName(\n\t\t\t\t\t_getSelectedBlockClientId(),\n\t\t\t\t\tSYNCED_PATTERN_BLOCK_NAME\n\t\t\t\t);\n\t\t\t\treturn ! parentCoreBlocks || parentCoreBlocks.length === 0;\n\t\t\t},\n\t\t\t[ postType, postId ]\n\t\t);\n\n\t\tconst { selectionChange, insertBlock } =\n\t\t\tuseDispatch( blockEditorStore );\n\n\t\tif ( ! isFootnotesSupported ) {\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 === 'core/footnotes' ) {\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( 'core/footnotes' );\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"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,IAAIC,QAAQ,QAAQ,MAAM;;AAErC;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,kBAAkB,IAAIC,IAAI,QAAQ,kBAAkB;AAC7D,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SACCC,qBAAqB,EACrBC,KAAK,IAAIC,gBAAgB,EACzBC,WAAW,QACL,yBAAyB;AAChC,SAASC,SAAS,EAAEC,WAAW,EAAEC,WAAW,QAAQ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AAGA,OAAS;MACnBwB,QAAQ,EAAG/C;IAAgB,CAC3B,CAAC;EAEJ;AACD,CAAC"}
|
|
@@ -11,7 +11,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
11
11
|
import { useEffect, Platform } from '@wordpress/element';
|
|
12
12
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
13
13
|
import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
|
|
14
|
-
import { AlignmentControl, BlockControls, RichText, useBlockProps, store as blockEditorStore, HeadingLevelDropdown } from '@wordpress/block-editor';
|
|
14
|
+
import { AlignmentControl, BlockControls, RichText, useBlockProps, store as blockEditorStore, HeadingLevelDropdown, useBlockEditingMode } from '@wordpress/block-editor';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Internal dependencies
|
|
@@ -39,6 +39,7 @@ function HeadingEdit({
|
|
|
39
39
|
}),
|
|
40
40
|
style
|
|
41
41
|
});
|
|
42
|
+
const blockEditingMode = useBlockEditingMode();
|
|
42
43
|
const {
|
|
43
44
|
canGenerateAnchors
|
|
44
45
|
} = useSelect(select => {
|
|
@@ -82,7 +83,7 @@ function HeadingEdit({
|
|
|
82
83
|
}
|
|
83
84
|
setAttributes(newAttrs);
|
|
84
85
|
};
|
|
85
|
-
return createElement(Fragment, null, createElement(BlockControls, {
|
|
86
|
+
return createElement(Fragment, null, blockEditingMode === 'default' && createElement(BlockControls, {
|
|
86
87
|
group: "block"
|
|
87
88
|
}, createElement(HeadingLevelDropdown, {
|
|
88
89
|
value: level,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","__","useEffect","Platform","useDispatch","useSelect","createBlock","getDefaultBlockName","AlignmentControl","BlockControls","RichText","useBlockProps","store","blockEditorStore","HeadingLevelDropdown","generateAnchor","setAnchor","HeadingEdit","attributes","setAttributes","mergeBlocks","onReplace","style","clientId","textAlign","content","level","placeholder","anchor","tagName","blockProps","className","canGenerateAnchors","select","getGlobalBlockCount","getSettings","settings","generateAnchors","__unstableMarkNextChangeAsNotPersistent","onContentChange","value","newAttrs","createElement","Fragment","group","onChange","newLevel","nextAlign","identifier","onMerge","onSplit","isOriginal","block","_getDefaultBlockName","onRemove","isNative","deleteEnter"],"sources":["@wordpress/block-library/src/heading/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useEffect, Platform } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { createBlock, getDefaultBlockName } from '@wordpress/blocks';\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tHeadingLevelDropdown,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { generateAnchor, setAnchor } from './autogenerate-anchors';\n\nfunction HeadingEdit( {\n\tattributes,\n\tsetAttributes,\n\tmergeBlocks,\n\tonReplace,\n\tstyle,\n\tclientId,\n} ) {\n\tconst { textAlign, content, level, placeholder, anchor } = attributes;\n\tconst tagName = 'h' + level;\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t\tstyle,\n\t} );\n\n\tconst { canGenerateAnchors } = useSelect( ( select ) => {\n\t\tconst { getGlobalBlockCount, getSettings } = select( blockEditorStore );\n\t\tconst settings = getSettings();\n\n\t\treturn {\n\t\t\tcanGenerateAnchors:\n\t\t\t\t!! settings.generateAnchors ||\n\t\t\t\tgetGlobalBlockCount( 'core/table-of-contents' ) > 0,\n\t\t};\n\t}, [] );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Initially set anchor for headings that have content but no anchor set.\n\t// This is used when transforming a block to heading, or for legacy anchors.\n\tuseEffect( () => {\n\t\tif ( ! canGenerateAnchors ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! anchor && content ) {\n\t\t\t// This side-effect should not create an undo level.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( {\n\t\t\t\tanchor: generateAnchor( clientId, content ),\n\t\t\t} );\n\t\t}\n\t\tsetAnchor( clientId, anchor );\n\n\t\t// Remove anchor map when block unmounts.\n\t\treturn () => setAnchor( clientId, null );\n\t}, [ anchor, content, clientId, canGenerateAnchors ] );\n\n\tconst onContentChange = ( value ) => {\n\t\tconst newAttrs = { content: value };\n\t\tif (\n\t\t\tcanGenerateAnchors &&\n\t\t\t( ! anchor ||\n\t\t\t\t! value ||\n\t\t\t\tgenerateAnchor( clientId, content ) === anchor )\n\t\t) {\n\t\t\tnewAttrs.anchor = generateAnchor( clientId, value );\n\t\t}\n\t\tsetAttributes( newAttrs );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<HeadingLevelDropdown\n\t\t\t\t\tvalue={ level }\n\t\t\t\t\tonChange={ ( newLevel ) =>\n\t\t\t\t\t\tsetAttributes( { level: newLevel } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<AlignmentControl\n\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\tonChange={ ( nextAlign ) => {\n\t\t\t\t\t\tsetAttributes( { textAlign: nextAlign } );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<RichText\n\t\t\t\tidentifier=\"content\"\n\t\t\t\ttagName={ tagName }\n\t\t\t\tvalue={ content }\n\t\t\t\tonChange={ onContentChange }\n\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\tonSplit={ ( value, isOriginal ) => {\n\t\t\t\t\tlet block;\n\n\t\t\t\t\tif ( isOriginal || value ) {\n\t\t\t\t\t\tblock = createBlock( 'core/heading', {\n\t\t\t\t\t\t\t...attributes,\n\t\t\t\t\t\t\tcontent: value,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tblock = createBlock(\n\t\t\t\t\t\t\tgetDefaultBlockName() ?? 'core/heading'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( isOriginal ) {\n\t\t\t\t\t\tblock.clientId = clientId;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn block;\n\t\t\t\t} }\n\t\t\t\tonReplace={ onReplace }\n\t\t\t\tonRemove={ () => onReplace( [] ) }\n\t\t\t\tplaceholder={ placeholder || __( 'Heading' ) }\n\t\t\t\ttextAlign={ textAlign }\n\t\t\t\t{ ...( Platform.isNative && { deleteEnter: true } ) } // setup RichText on native mobile to delete the \"Enter\" key as it's handled by the JS/RN side\n\t\t\t\t{ ...blockProps }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default HeadingEdit;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,oBAAoB;AACxD,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,mBAAmB;AACpE,SACCC,gBAAgB,EAChBC,aAAa,EACbC,QAAQ,EACRC,aAAa,EACbC,KAAK,IAAIC,gBAAgB,EACzBC,oBAAoB,
|
|
1
|
+
{"version":3,"names":["classnames","__","useEffect","Platform","useDispatch","useSelect","createBlock","getDefaultBlockName","AlignmentControl","BlockControls","RichText","useBlockProps","store","blockEditorStore","HeadingLevelDropdown","useBlockEditingMode","generateAnchor","setAnchor","HeadingEdit","attributes","setAttributes","mergeBlocks","onReplace","style","clientId","textAlign","content","level","placeholder","anchor","tagName","blockProps","className","blockEditingMode","canGenerateAnchors","select","getGlobalBlockCount","getSettings","settings","generateAnchors","__unstableMarkNextChangeAsNotPersistent","onContentChange","value","newAttrs","createElement","Fragment","group","onChange","newLevel","nextAlign","identifier","onMerge","onSplit","isOriginal","block","_getDefaultBlockName","onRemove","isNative","deleteEnter"],"sources":["@wordpress/block-library/src/heading/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useEffect, Platform } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { createBlock, getDefaultBlockName } from '@wordpress/blocks';\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tHeadingLevelDropdown,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { generateAnchor, setAnchor } from './autogenerate-anchors';\n\nfunction HeadingEdit( {\n\tattributes,\n\tsetAttributes,\n\tmergeBlocks,\n\tonReplace,\n\tstyle,\n\tclientId,\n} ) {\n\tconst { textAlign, content, level, placeholder, anchor } = attributes;\n\tconst tagName = 'h' + level;\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t\tstyle,\n\t} );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst { canGenerateAnchors } = useSelect( ( select ) => {\n\t\tconst { getGlobalBlockCount, getSettings } = select( blockEditorStore );\n\t\tconst settings = getSettings();\n\n\t\treturn {\n\t\t\tcanGenerateAnchors:\n\t\t\t\t!! settings.generateAnchors ||\n\t\t\t\tgetGlobalBlockCount( 'core/table-of-contents' ) > 0,\n\t\t};\n\t}, [] );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Initially set anchor for headings that have content but no anchor set.\n\t// This is used when transforming a block to heading, or for legacy anchors.\n\tuseEffect( () => {\n\t\tif ( ! canGenerateAnchors ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! anchor && content ) {\n\t\t\t// This side-effect should not create an undo level.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( {\n\t\t\t\tanchor: generateAnchor( clientId, content ),\n\t\t\t} );\n\t\t}\n\t\tsetAnchor( clientId, anchor );\n\n\t\t// Remove anchor map when block unmounts.\n\t\treturn () => setAnchor( clientId, null );\n\t}, [ anchor, content, clientId, canGenerateAnchors ] );\n\n\tconst onContentChange = ( value ) => {\n\t\tconst newAttrs = { content: value };\n\t\tif (\n\t\t\tcanGenerateAnchors &&\n\t\t\t( ! anchor ||\n\t\t\t\t! value ||\n\t\t\t\tgenerateAnchor( clientId, content ) === anchor )\n\t\t) {\n\t\t\tnewAttrs.anchor = generateAnchor( clientId, value );\n\t\t}\n\t\tsetAttributes( newAttrs );\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<RichText\n\t\t\t\tidentifier=\"content\"\n\t\t\t\ttagName={ tagName }\n\t\t\t\tvalue={ content }\n\t\t\t\tonChange={ onContentChange }\n\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\tonSplit={ ( value, isOriginal ) => {\n\t\t\t\t\tlet block;\n\n\t\t\t\t\tif ( isOriginal || value ) {\n\t\t\t\t\t\tblock = createBlock( 'core/heading', {\n\t\t\t\t\t\t\t...attributes,\n\t\t\t\t\t\t\tcontent: value,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tblock = createBlock(\n\t\t\t\t\t\t\tgetDefaultBlockName() ?? 'core/heading'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( isOriginal ) {\n\t\t\t\t\t\tblock.clientId = clientId;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn block;\n\t\t\t\t} }\n\t\t\t\tonReplace={ onReplace }\n\t\t\t\tonRemove={ () => onReplace( [] ) }\n\t\t\t\tplaceholder={ placeholder || __( 'Heading' ) }\n\t\t\t\ttextAlign={ textAlign }\n\t\t\t\t{ ...( Platform.isNative && { deleteEnter: true } ) } // setup RichText on native mobile to delete the \"Enter\" key as it's handled by the JS/RN side\n\t\t\t\t{ ...blockProps }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default HeadingEdit;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,oBAAoB;AACxD,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,mBAAmB;AACpE,SACCC,gBAAgB,EAChBC,aAAa,EACbC,QAAQ,EACRC,aAAa,EACbC,KAAK,IAAIC,gBAAgB,EACzBC,oBAAoB,EACpBC,mBAAmB,QACb,yBAAyB;;AAEhC;AACA;AACA;AACA,SAASC,cAAc,EAAEC,SAAS,QAAQ,wBAAwB;AAElE,SAASC,WAAWA,CAAE;EACrBC,UAAU;EACVC,aAAa;EACbC,WAAW;EACXC,SAAS;EACTC,KAAK;EACLC;AACD,CAAC,EAAG;EACH,MAAM;IAAEC,SAAS;IAAEC,OAAO;IAAEC,KAAK;IAAEC,WAAW;IAAEC;EAAO,CAAC,GAAGV,UAAU;EACrE,MAAMW,OAAO,GAAG,GAAG,GAAGH,KAAK;EAC3B,MAAMI,UAAU,GAAGpB,aAAa,CAAE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AAQ;MAC1B;MAEA,OAAO8B,KAAK;IACb,CAAG;IACHhC,SAAS,EAAGA,SAAW;IACvBkC,QAAQ,EAAGA,CAAA,KAAMlC,SAAS,CAAE,EAAG,CAAG;IAClCM,WAAW,EAAGA,WAAW,IAAI3B,EAAE,CAAE,SAAU,CAAG;IAC9CwB,SAAS,EAAGA,SAAW;IAAA,IAChBtB,QAAQ,CAACsD,QAAQ,IAAI;MAAEC,WAAW,EAAE;IAAK,CAAC;IAAA,GAC5C3B;EAAU,CACf,CACA,CAAC;AAEL;AAEA,eAAeb,WAAW"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { createElement, Fragment } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* External dependencies
|
|
4
|
+
*/
|
|
5
|
+
import classnames from 'classnames';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { __ } from '@wordpress/i18n';
|
|
11
|
+
import { useEffect, Platform } from '@wordpress/element';
|
|
12
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
13
|
+
import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
|
|
14
|
+
import { AlignmentControl, BlockControls, RichText, useBlockProps, store as blockEditorStore, HeadingLevelDropdown } from '@wordpress/block-editor';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Internal dependencies
|
|
18
|
+
*/
|
|
19
|
+
import { generateAnchor, setAnchor } from './autogenerate-anchors';
|
|
20
|
+
function HeadingEdit({
|
|
21
|
+
attributes,
|
|
22
|
+
setAttributes,
|
|
23
|
+
mergeBlocks,
|
|
24
|
+
onReplace,
|
|
25
|
+
style,
|
|
26
|
+
clientId
|
|
27
|
+
}) {
|
|
28
|
+
const {
|
|
29
|
+
textAlign,
|
|
30
|
+
content,
|
|
31
|
+
level,
|
|
32
|
+
placeholder,
|
|
33
|
+
anchor
|
|
34
|
+
} = attributes;
|
|
35
|
+
const tagName = 'h' + level;
|
|
36
|
+
const blockProps = useBlockProps({
|
|
37
|
+
className: classnames({
|
|
38
|
+
[`has-text-align-${textAlign}`]: textAlign
|
|
39
|
+
}),
|
|
40
|
+
style
|
|
41
|
+
});
|
|
42
|
+
const {
|
|
43
|
+
canGenerateAnchors
|
|
44
|
+
} = useSelect(select => {
|
|
45
|
+
const {
|
|
46
|
+
getGlobalBlockCount,
|
|
47
|
+
getSettings
|
|
48
|
+
} = select(blockEditorStore);
|
|
49
|
+
const settings = getSettings();
|
|
50
|
+
return {
|
|
51
|
+
canGenerateAnchors: !!settings.generateAnchors || getGlobalBlockCount('core/table-of-contents') > 0
|
|
52
|
+
};
|
|
53
|
+
}, []);
|
|
54
|
+
const {
|
|
55
|
+
__unstableMarkNextChangeAsNotPersistent
|
|
56
|
+
} = useDispatch(blockEditorStore);
|
|
57
|
+
|
|
58
|
+
// Initially set anchor for headings that have content but no anchor set.
|
|
59
|
+
// This is used when transforming a block to heading, or for legacy anchors.
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (!canGenerateAnchors) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (!anchor && content) {
|
|
65
|
+
// This side-effect should not create an undo level.
|
|
66
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
67
|
+
setAttributes({
|
|
68
|
+
anchor: generateAnchor(clientId, content)
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
setAnchor(clientId, anchor);
|
|
72
|
+
|
|
73
|
+
// Remove anchor map when block unmounts.
|
|
74
|
+
return () => setAnchor(clientId, null);
|
|
75
|
+
}, [anchor, content, clientId, canGenerateAnchors]);
|
|
76
|
+
const onContentChange = value => {
|
|
77
|
+
const newAttrs = {
|
|
78
|
+
content: value
|
|
79
|
+
};
|
|
80
|
+
if (canGenerateAnchors && (!anchor || !value || generateAnchor(clientId, content) === anchor)) {
|
|
81
|
+
newAttrs.anchor = generateAnchor(clientId, value);
|
|
82
|
+
}
|
|
83
|
+
setAttributes(newAttrs);
|
|
84
|
+
};
|
|
85
|
+
return createElement(Fragment, null, createElement(BlockControls, {
|
|
86
|
+
group: "block"
|
|
87
|
+
}, createElement(HeadingLevelDropdown, {
|
|
88
|
+
value: level,
|
|
89
|
+
onChange: newLevel => setAttributes({
|
|
90
|
+
level: newLevel
|
|
91
|
+
})
|
|
92
|
+
}), createElement(AlignmentControl, {
|
|
93
|
+
value: textAlign,
|
|
94
|
+
onChange: nextAlign => {
|
|
95
|
+
setAttributes({
|
|
96
|
+
textAlign: nextAlign
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
})), createElement(RichText, {
|
|
100
|
+
identifier: "content",
|
|
101
|
+
tagName: tagName,
|
|
102
|
+
value: content,
|
|
103
|
+
onChange: onContentChange,
|
|
104
|
+
onMerge: mergeBlocks,
|
|
105
|
+
onSplit: (value, isOriginal) => {
|
|
106
|
+
let block;
|
|
107
|
+
if (isOriginal || value) {
|
|
108
|
+
block = createBlock('core/heading', {
|
|
109
|
+
...attributes,
|
|
110
|
+
content: value
|
|
111
|
+
});
|
|
112
|
+
} else {
|
|
113
|
+
var _getDefaultBlockName;
|
|
114
|
+
block = createBlock((_getDefaultBlockName = getDefaultBlockName()) !== null && _getDefaultBlockName !== void 0 ? _getDefaultBlockName : 'core/heading');
|
|
115
|
+
}
|
|
116
|
+
if (isOriginal) {
|
|
117
|
+
block.clientId = clientId;
|
|
118
|
+
}
|
|
119
|
+
return block;
|
|
120
|
+
},
|
|
121
|
+
onReplace: onReplace,
|
|
122
|
+
onRemove: () => onReplace([]),
|
|
123
|
+
placeholder: placeholder || __('Heading'),
|
|
124
|
+
textAlign: textAlign,
|
|
125
|
+
...(Platform.isNative && {
|
|
126
|
+
deleteEnter: true
|
|
127
|
+
}),
|
|
128
|
+
...blockProps
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
131
|
+
export default HeadingEdit;
|
|
132
|
+
//# sourceMappingURL=edit.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["classnames","__","useEffect","Platform","useDispatch","useSelect","createBlock","getDefaultBlockName","AlignmentControl","BlockControls","RichText","useBlockProps","store","blockEditorStore","HeadingLevelDropdown","generateAnchor","setAnchor","HeadingEdit","attributes","setAttributes","mergeBlocks","onReplace","style","clientId","textAlign","content","level","placeholder","anchor","tagName","blockProps","className","canGenerateAnchors","select","getGlobalBlockCount","getSettings","settings","generateAnchors","__unstableMarkNextChangeAsNotPersistent","onContentChange","value","newAttrs","createElement","Fragment","group","onChange","newLevel","nextAlign","identifier","onMerge","onSplit","isOriginal","block","_getDefaultBlockName","onRemove","isNative","deleteEnter"],"sources":["@wordpress/block-library/src/heading/edit.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useEffect, Platform } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { createBlock, getDefaultBlockName } from '@wordpress/blocks';\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tHeadingLevelDropdown,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { generateAnchor, setAnchor } from './autogenerate-anchors';\n\nfunction HeadingEdit( {\n\tattributes,\n\tsetAttributes,\n\tmergeBlocks,\n\tonReplace,\n\tstyle,\n\tclientId,\n} ) {\n\tconst { textAlign, content, level, placeholder, anchor } = attributes;\n\tconst tagName = 'h' + level;\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t\tstyle,\n\t} );\n\n\tconst { canGenerateAnchors } = useSelect( ( select ) => {\n\t\tconst { getGlobalBlockCount, getSettings } = select( blockEditorStore );\n\t\tconst settings = getSettings();\n\n\t\treturn {\n\t\t\tcanGenerateAnchors:\n\t\t\t\t!! settings.generateAnchors ||\n\t\t\t\tgetGlobalBlockCount( 'core/table-of-contents' ) > 0,\n\t\t};\n\t}, [] );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Initially set anchor for headings that have content but no anchor set.\n\t// This is used when transforming a block to heading, or for legacy anchors.\n\tuseEffect( () => {\n\t\tif ( ! canGenerateAnchors ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! anchor && content ) {\n\t\t\t// This side-effect should not create an undo level.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( {\n\t\t\t\tanchor: generateAnchor( clientId, content ),\n\t\t\t} );\n\t\t}\n\t\tsetAnchor( clientId, anchor );\n\n\t\t// Remove anchor map when block unmounts.\n\t\treturn () => setAnchor( clientId, null );\n\t}, [ anchor, content, clientId, canGenerateAnchors ] );\n\n\tconst onContentChange = ( value ) => {\n\t\tconst newAttrs = { content: value };\n\t\tif (\n\t\t\tcanGenerateAnchors &&\n\t\t\t( ! anchor ||\n\t\t\t\t! value ||\n\t\t\t\tgenerateAnchor( clientId, content ) === anchor )\n\t\t) {\n\t\t\tnewAttrs.anchor = generateAnchor( clientId, value );\n\t\t}\n\t\tsetAttributes( newAttrs );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<HeadingLevelDropdown\n\t\t\t\t\tvalue={ level }\n\t\t\t\t\tonChange={ ( newLevel ) =>\n\t\t\t\t\t\tsetAttributes( { level: newLevel } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<AlignmentControl\n\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\tonChange={ ( nextAlign ) => {\n\t\t\t\t\t\tsetAttributes( { textAlign: nextAlign } );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<RichText\n\t\t\t\tidentifier=\"content\"\n\t\t\t\ttagName={ tagName }\n\t\t\t\tvalue={ content }\n\t\t\t\tonChange={ onContentChange }\n\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\tonSplit={ ( value, isOriginal ) => {\n\t\t\t\t\tlet block;\n\n\t\t\t\t\tif ( isOriginal || value ) {\n\t\t\t\t\t\tblock = createBlock( 'core/heading', {\n\t\t\t\t\t\t\t...attributes,\n\t\t\t\t\t\t\tcontent: value,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tblock = createBlock(\n\t\t\t\t\t\t\tgetDefaultBlockName() ?? 'core/heading'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( isOriginal ) {\n\t\t\t\t\t\tblock.clientId = clientId;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn block;\n\t\t\t\t} }\n\t\t\t\tonReplace={ onReplace }\n\t\t\t\tonRemove={ () => onReplace( [] ) }\n\t\t\t\tplaceholder={ placeholder || __( 'Heading' ) }\n\t\t\t\ttextAlign={ textAlign }\n\t\t\t\t{ ...( Platform.isNative && { deleteEnter: true } ) } // setup RichText on native mobile to delete the \"Enter\" key as it's handled by the JS/RN side\n\t\t\t\t{ ...blockProps }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default HeadingEdit;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,oBAAoB;AACxD,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,mBAAmB;AACpE,SACCC,gBAAgB,EAChBC,aAAa,EACbC,QAAQ,EACRC,aAAa,EACbC,KAAK,IAAIC,gBAAgB,EACzBC,oBAAoB,QACd,yBAAyB;;AAEhC;AACA;AACA;AACA,SAASC,cAAc,EAAEC,SAAS,QAAQ,wBAAwB;AAElE,SAASC,WAAWA,CAAE;EACrBC,UAAU;EACVC,aAAa;EACbC,WAAW;EACXC,SAAS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AAmB,CAAC,CAAC,cAAA8C,oBAAA,cAAAA,oBAAA,GAAI,cAC1B,CAAC;MACF;MAEA,IAAKF,UAAU,EAAG;QACjBC,KAAK,CAAC7B,QAAQ,GAAGA,QAAQ;MAC1B;MAEA,OAAO6B,KAAK;IACb,CAAG;IACH/B,SAAS,EAAGA,SAAW;IACvBiC,QAAQ,EAAGA,CAAA,KAAMjC,SAAS,CAAE,EAAG,CAAG;IAClCM,WAAW,EAAGA,WAAW,IAAI1B,EAAE,CAAE,SAAU,CAAG;IAC9CuB,SAAS,EAAGA,SAAW;IAAA,IAChBrB,QAAQ,CAACoD,QAAQ,IAAI;MAAEC,WAAW,EAAE;IAAK,CAAC;IAAA,GAC5C1B;EAAU,CACf,CACA,CAAC;AAEL;AAEA,eAAeb,WAAW"}
|
|
@@ -19,6 +19,7 @@ const metadata = {
|
|
|
19
19
|
description: "Introduce new sections and organize content to help visitors (and search engines) understand the structure of your content.",
|
|
20
20
|
keywords: ["title", "subtitle"],
|
|
21
21
|
textdomain: "default",
|
|
22
|
+
usesContext: ["pattern/overrides"],
|
|
22
23
|
attributes: {
|
|
23
24
|
textAlign: {
|
|
24
25
|
type: "string"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["heading","icon","__","sprintf","initBlock","deprecated","edit","metadata","$schema","apiVersion","name","title","category","description","keywords","textdomain","attributes","textAlign","type","content","source","selector","__experimentalRole","level","placeholder","supports","align","anchor","className","color","gradients","link","__experimentalDefaultControls","background","text","spacing","margin","padding","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontStyle","__experimentalFontWeight","__experimentalLetterSpacing","__experimentalTextTransform","__experimentalTextDecoration","__experimentalWritingMode","__unstablePasteTextInline","__experimentalSlashInserter","editorStyle","style","save","transforms","settings","example","__experimentalLabel","context","customName","length","merge","attributesToMerge","init"],"sources":["@wordpress/block-library/src/heading/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { heading as icon } from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tcontent: __( 'Code is Poetry' ),\n\t\t\tlevel: 2,\n\t\t},\n\t},\n\t__experimentalLabel( attributes, { context } ) {\n\t\tconst { content, level } = attributes;\n\n\t\tconst customName = attributes?.metadata?.name;\n\n\t\t// In the list view, use the block's content as the label.\n\t\t// If the content is empty, fall back to the default label.\n\t\tif ( context === 'list-view' && ( customName || content ) ) {\n\t\t\treturn attributes?.metadata?.name || content;\n\t\t}\n\n\t\tif ( context === 'accessibility' ) {\n\t\t\treturn ! content || content.length === 0\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t/* translators: accessibility text. %s: heading level. */\n\t\t\t\t\t\t__( 'Level %s. Empty.' ),\n\t\t\t\t\t\tlevel\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: accessibility text. 1: heading level. 2: heading content. */\n\t\t\t\t\t\t__( 'Level %1$s. %2$s' ),\n\t\t\t\t\t\tlevel,\n\t\t\t\t\t\tcontent\n\t\t\t\t );\n\t\t}\n\t},\n\ttransforms,\n\tdeprecated,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\tcontent:\n\t\t\t\t( attributes.content || '' ) +\n\t\t\t\t( attributesToMerge.content || '' ),\n\t\t};\n\t},\n\tedit,\n\tsave,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,IAAIC,IAAI,QAAQ,kBAAkB;AAClD,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA,OAAOC,SAAS,MAAM,qBAAqB;AAC3C,OAAOC,UAAU,MAAM,cAAc;AACrC,OAAOC,IAAI,MAAM,QAAQ;AAAC,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,QAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,SAAA;MAAAC,IAAA;IAAA;IAAAC,OAAA;MAAAD,IAAA;MAAAE,MAAA;MAAAC,QAAA;MAAAC,kBAAA;IAAA;IAAAC,KAAA;MAAAL,IAAA;MAAA;IAAA;IAAAM,WAAA;MAAAN,IAAA;IAAA;EAAA;EAAAO,QAAA;IAAAC,KAAA;IAAAC,MAAA;IAAAC,SAAA;IAAAC,KAAA;MAAAC,SAAA;MAAAC,IAAA;MAAAC,6BAAA;QAAAC,UAAA;QAAAC,IAAA;MAAA;IAAA;IAAAC,OAAA;MAAAC,MAAA;MAAAC,OAAA;MAAAL,6BAAA;QAAAI,MAAA;QAAAC,OAAA;MAAA;IAAA;IAAAC,UAAA;MAAAC,QAAA;MAAAC,UAAA;MAAAC,wBAAA;MAAAC,uBAAA;MAAAC,wBAAA;MAAAC,2BAAA;MAAAC,2BAAA;MAAAC,4BAAA;MAAAC,yBAAA;MAAAf,6BAAA;QAAAO,QAAA;MAAA;IAAA;IAAAS,yBAAA;IAAAC,2BAAA;EAAA;EAAAC,WAAA;EAAAC,KAAA;AAAA;AAE1B,OAAOC,IAAI,MAAM,QAAQ;AACzB,OAAOC,UAAU,MAAM,cAAc;AAErC,MAAM;
|
|
1
|
+
{"version":3,"names":["heading","icon","__","sprintf","initBlock","deprecated","edit","metadata","$schema","apiVersion","name","title","category","description","keywords","textdomain","usesContext","attributes","textAlign","type","content","source","selector","__experimentalRole","level","placeholder","supports","align","anchor","className","color","gradients","link","__experimentalDefaultControls","background","text","spacing","margin","padding","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontStyle","__experimentalFontWeight","__experimentalLetterSpacing","__experimentalTextTransform","__experimentalTextDecoration","__experimentalWritingMode","__unstablePasteTextInline","__experimentalSlashInserter","editorStyle","style","save","transforms","settings","example","__experimentalLabel","context","customName","length","merge","attributesToMerge","init"],"sources":["@wordpress/block-library/src/heading/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { heading as icon } from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tcontent: __( 'Code is Poetry' ),\n\t\t\tlevel: 2,\n\t\t},\n\t},\n\t__experimentalLabel( attributes, { context } ) {\n\t\tconst { content, level } = attributes;\n\n\t\tconst customName = attributes?.metadata?.name;\n\n\t\t// In the list view, use the block's content as the label.\n\t\t// If the content is empty, fall back to the default label.\n\t\tif ( context === 'list-view' && ( customName || content ) ) {\n\t\t\treturn attributes?.metadata?.name || content;\n\t\t}\n\n\t\tif ( context === 'accessibility' ) {\n\t\t\treturn ! content || content.length === 0\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t/* translators: accessibility text. %s: heading level. */\n\t\t\t\t\t\t__( 'Level %s. Empty.' ),\n\t\t\t\t\t\tlevel\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: accessibility text. 1: heading level. 2: heading content. */\n\t\t\t\t\t\t__( 'Level %1$s. %2$s' ),\n\t\t\t\t\t\tlevel,\n\t\t\t\t\t\tcontent\n\t\t\t\t );\n\t\t}\n\t},\n\ttransforms,\n\tdeprecated,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\tcontent:\n\t\t\t\t( attributes.content || '' ) +\n\t\t\t\t( attributesToMerge.content || '' ),\n\t\t};\n\t},\n\tedit,\n\tsave,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mapp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BtD,IAAI;EACJuD,OAAO,EAAE;IACRvC,UAAU,EAAE;MACXG,OAAO,EAAElB,EAAE,CAAE,gBAAiB,CAAC;MAC/BsB,KAAK,EAAE;IACR;EACD,CAAC;EACDiC,mBAAmBA,CAAExC,UAAU,EAAE;IAAEyC;EAAQ,CAAC,EAAG;IAC9C,MAAM;MAAEtC,OAAO;MAAEI;IAAM,CAAC,GAAGP,UAAU;IAErC,MAAM0C,UAAU,GAAG1C,UAAU,EAAEV,QAAQ,EAAEG,IAAI;;IAE7C;IACA;IACA,IAAKgD,OAAO,KAAK,WAAW,KAAMC,UAAU,IAAIvC,OAAO,CAAE,EAAG;MAC3D,OAAOH,UAAU,EAAEV,QAAQ,EAAEG,IAAI,IAAIU,OAAO;IAC7C;IAEA,IAAKsC,OAAO,KAAK,eAAe,EAAG;MAClC,OAAO,CAAEtC,OAAO,IAAIA,OAAO,CAACwC,MAAM,KAAK,CAAC,GACrCzD,OAAO,EACP;MACAD,EAAE,CAAE,kBAAmB,CAAC,EACxBsB,KACA,CAAC,GACDrB,OAAO,EACP;MACAD,EAAE,CAAE,kBAAmB,CAAC,EACxBsB,KAAK,EACLJ,OACA,CAAC;IACL;EACD,CAAC;EACDkC,UAAU;EACVjD,UAAU;EACVwD,KAAKA,CAAE5C,UAAU,EAAE6C,iBAAiB,EAAG;IACtC,OAAO;MACN1C,OAAO,EACN,CAAEH,UAAU,CAACG,OAAO,IAAI,EAAE,KACxB0C,iBAAiB,CAAC1C,OAAO,IAAI,EAAE;IACnC,CAAC;EACF,CAAC;EACDd,IAAI;EACJ+C;AACD,CAAC;AAED,OAAO,MAAMU,IAAI,GAAGA,CAAA,KAAM3D,SAAS,CAAE;EAAEM,IAAI;EAAEH,QAAQ;EAAEgD;AAAS,CAAE,CAAC"}
|
|
@@ -13,7 +13,7 @@ import { useDispatch, useSelect } from '@wordpress/data';
|
|
|
13
13
|
import { BlockIcon, MediaPlaceholder, useBlockProps, store as blockEditorStore, __experimentalUseBorderProps as useBorderProps, useBlockEditingMode } from '@wordpress/block-editor';
|
|
14
14
|
import { useEffect, useRef, useState } from '@wordpress/element';
|
|
15
15
|
import { __ } from '@wordpress/i18n';
|
|
16
|
-
import { image as icon } from '@wordpress/icons';
|
|
16
|
+
import { image as icon, plugins as pluginsIcon } from '@wordpress/icons';
|
|
17
17
|
import { store as noticesStore } from '@wordpress/notices';
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -86,7 +86,8 @@ export function ImageEdit({
|
|
|
86
86
|
sizeSlug,
|
|
87
87
|
aspectRatio,
|
|
88
88
|
scale,
|
|
89
|
-
align
|
|
89
|
+
align,
|
|
90
|
+
metadata
|
|
90
91
|
} = attributes;
|
|
91
92
|
const [temporaryURL, setTemporaryURL] = useState();
|
|
92
93
|
const altRef = useRef();
|
|
@@ -293,15 +294,16 @@ export function ImageEdit({
|
|
|
293
294
|
});
|
|
294
295
|
|
|
295
296
|
// Much of this description is duplicated from MediaPlaceholder.
|
|
297
|
+
const isUrlAttributeConnected = !!metadata?.bindings?.url;
|
|
296
298
|
const placeholder = content => {
|
|
297
299
|
return createElement(Placeholder, {
|
|
298
300
|
className: classnames('block-editor-media-placeholder', {
|
|
299
301
|
[borderProps.className]: !!borderProps.className && !isSelected
|
|
300
302
|
}),
|
|
301
303
|
withIllustration: true,
|
|
302
|
-
icon: icon,
|
|
304
|
+
icon: isUrlAttributeConnected ? pluginsIcon : icon,
|
|
303
305
|
label: __('Image'),
|
|
304
|
-
instructions: __('Upload an image file, pick one from your media library, or add one with a URL.'),
|
|
306
|
+
instructions: !isUrlAttributeConnected && __('Upload an image file, pick one from your media library, or add one with a URL.'),
|
|
305
307
|
style: {
|
|
306
308
|
aspectRatio: !(width && height) && aspectRatio ? aspectRatio : undefined,
|
|
307
309
|
width: height && aspectRatio ? '100%' : width,
|
|
@@ -309,7 +311,9 @@ export function ImageEdit({
|
|
|
309
311
|
objectFit: scale,
|
|
310
312
|
...borderProps.style
|
|
311
313
|
}
|
|
312
|
-
},
|
|
314
|
+
}, isUrlAttributeConnected ? createElement("span", {
|
|
315
|
+
className: 'block-bindings-media-placeholder-message'
|
|
316
|
+
}, __('Connected to a custom field')) : content);
|
|
313
317
|
};
|
|
314
318
|
return createElement("figure", {
|
|
315
319
|
...blockProps
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","getBlobByURL","isBlobURL","revokeBlobURL","Placeholder","useDispatch","useSelect","BlockIcon","MediaPlaceholder","useBlockProps","store","blockEditorStore","__experimentalUseBorderProps","useBorderProps","useBlockEditingMode","useEffect","useRef","useState","__","image","icon","noticesStore","Image","LINK_DESTINATION_ATTACHMENT","LINK_DESTINATION_CUSTOM","LINK_DESTINATION_MEDIA","LINK_DESTINATION_NONE","ALLOWED_MEDIA_TYPES","pickRelevantMediaFiles","size","imageProps","Object","fromEntries","entries","filter","key","includes","url","sizes","media_details","source_url","isTemporaryImage","id","isExternalImage","hasSize","_image$sizes$size","_image$media_details$","ImageEdit","attributes","setAttributes","isSelected","className","insertBlocksAfter","onReplace","context","clientId","alt","caption","width","height","sizeSlug","aspectRatio","scale","align","temporaryURL","setTemporaryURL","altRef","current","captionRef","__unstableMarkNextChangeAsNotPersistent","undefined","ref","imageDefaultSize","mediaUpload","select","getSettings","settings","blockEditingMode","createErrorNotice","onUploadError","message","type","src","onSelectImage","media","title","newSize","mediaAttributes","omittedCaption","restMediaAttributes","additionalAttributes","linkDestination","window","wp","view","defaultProps","link","href","onSelectURL","newURL","isTemp","file","filesList","onFileChange","img","allowedTypes","onError","isExternal","mediaPreview","createElement","borderProps","classes","style","keys","length","blockProps","placeholder","content","withIllustration","label","instructions","objectFit","containerRef","onSelect","accept","value","disableMediaButtons"],"sources":["@wordpress/block-library/src/image/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlobByURL, isBlobURL, revokeBlobURL } from '@wordpress/blob';\nimport { Placeholder } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tBlockIcon,\n\tMediaPlaceholder,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalUseBorderProps as useBorderProps,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { image as icon } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport Image from './image';\n\n/**\n * Module constants\n */\nimport {\n\tLINK_DESTINATION_ATTACHMENT,\n\tLINK_DESTINATION_CUSTOM,\n\tLINK_DESTINATION_MEDIA,\n\tLINK_DESTINATION_NONE,\n\tALLOWED_MEDIA_TYPES,\n} from './constants';\n\nexport const pickRelevantMediaFiles = ( image, size ) => {\n\tconst imageProps = Object.fromEntries(\n\t\tObject.entries( image ?? {} ).filter( ( [ key ] ) =>\n\t\t\t[ 'alt', 'id', 'link', 'caption' ].includes( key )\n\t\t)\n\t);\n\n\timageProps.url =\n\t\timage?.sizes?.[ size ]?.url ||\n\t\timage?.media_details?.sizes?.[ size ]?.source_url ||\n\t\timage.url;\n\treturn imageProps;\n};\n\n/**\n * Is the URL a temporary blob URL? A blob URL is one that is used temporarily\n * while the image is being uploaded and will not have an id yet allocated.\n *\n * @param {number=} id The id of the image.\n * @param {string=} url The url of the image.\n *\n * @return {boolean} Is the URL a Blob URL\n */\nconst isTemporaryImage = ( id, url ) => ! id && isBlobURL( url );\n\n/**\n * Is the url for the image hosted externally. An externally hosted image has no\n * id and is not a blob url.\n *\n * @param {number=} id The id of the image.\n * @param {string=} url The url of the image.\n *\n * @return {boolean} Is the url an externally hosted url?\n */\nexport const isExternalImage = ( id, url ) => url && ! id && ! isBlobURL( url );\n\n/**\n * Checks if WP generated the specified image size. Size generation is skipped\n * when the image is smaller than the said size.\n *\n * @param {Object} image\n * @param {string} size\n *\n * @return {boolean} Whether or not it has default image size.\n */\nfunction hasSize( image, size ) {\n\treturn (\n\t\t'url' in ( image?.sizes?.[ size ] ?? {} ) ||\n\t\t'source_url' in ( image?.media_details?.sizes?.[ size ] ?? {} )\n\t);\n}\n\nexport function ImageEdit( {\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tclassName,\n\tinsertBlocksAfter,\n\tonReplace,\n\tcontext,\n\tclientId,\n} ) {\n\tconst {\n\t\turl = '',\n\t\talt,\n\t\tcaption,\n\t\tid,\n\t\twidth,\n\t\theight,\n\t\tsizeSlug,\n\t\taspectRatio,\n\t\tscale,\n\t\talign,\n\t} = attributes;\n\tconst [ temporaryURL, setTemporaryURL ] = useState();\n\n\tconst altRef = useRef();\n\tuseEffect( () => {\n\t\taltRef.current = alt;\n\t}, [ alt ] );\n\n\tconst captionRef = useRef();\n\tuseEffect( () => {\n\t\tcaptionRef.current = caption;\n\t}, [ caption ] );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tif ( [ 'wide', 'full' ].includes( align ) ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( {\n\t\t\t\twidth: undefined,\n\t\t\t\theight: undefined,\n\t\t\t\taspectRatio: undefined,\n\t\t\t\tscale: undefined,\n\t\t\t} );\n\t\t}\n\t}, [ align ] );\n\n\tconst ref = useRef();\n\tconst { imageDefaultSize, mediaUpload } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst settings = getSettings();\n\t\treturn {\n\t\t\timageDefaultSize: settings.imageDefaultSize,\n\t\t\tmediaUpload: settings.mediaUpload,\n\t\t};\n\t}, [] );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tfunction onUploadError( message ) {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t\tsetAttributes( {\n\t\t\tsrc: undefined,\n\t\t\tid: undefined,\n\t\t\turl: undefined,\n\t\t} );\n\t\tsetTemporaryURL( undefined );\n\t}\n\n\tfunction onSelectImage( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\tsetAttributes( {\n\t\t\t\turl: undefined,\n\t\t\t\talt: undefined,\n\t\t\t\tid: undefined,\n\t\t\t\ttitle: undefined,\n\t\t\t\tcaption: undefined,\n\t\t\t} );\n\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( media.url ) ) {\n\t\t\tsetTemporaryURL( media.url );\n\t\t\treturn;\n\t\t}\n\n\t\tsetTemporaryURL();\n\n\t\t// Try to use the previous selected image size if its available\n\t\t// otherwise try the default image size or fallback to \"full\"\n\t\tlet newSize = 'full';\n\t\tif ( sizeSlug && hasSize( media, sizeSlug ) ) {\n\t\t\tnewSize = sizeSlug;\n\t\t} else if ( hasSize( media, imageDefaultSize ) ) {\n\t\t\tnewSize = imageDefaultSize;\n\t\t}\n\n\t\tlet mediaAttributes = pickRelevantMediaFiles( media, newSize );\n\n\t\t// If a caption text was meanwhile written by the user,\n\t\t// make sure the text is not overwritten by empty captions.\n\t\tif ( captionRef.current && ! mediaAttributes.caption ) {\n\t\t\tconst { caption: omittedCaption, ...restMediaAttributes } =\n\t\t\t\tmediaAttributes;\n\t\t\tmediaAttributes = restMediaAttributes;\n\t\t}\n\n\t\tlet additionalAttributes;\n\t\t// Reset the dimension attributes if changing to a different image.\n\t\tif ( ! media.id || media.id !== id ) {\n\t\t\tadditionalAttributes = {\n\t\t\t\tsizeSlug: newSize,\n\t\t\t};\n\t\t} else {\n\t\t\t// Keep the same url when selecting the same file, so \"Resolution\"\n\t\t\t// option is not changed.\n\t\t\tadditionalAttributes = { url };\n\t\t}\n\n\t\t// Check if default link setting should be used.\n\t\tlet linkDestination = attributes.linkDestination;\n\t\tif ( ! linkDestination ) {\n\t\t\t// Use the WordPress option to determine the proper default.\n\t\t\t// The constants used in Gutenberg do not match WP options so a little more complicated than ideal.\n\t\t\t// TODO: fix this in a follow up PR, requires updating media-text and ui component.\n\t\t\tswitch (\n\t\t\t\twindow?.wp?.media?.view?.settings?.defaultProps?.link ||\n\t\t\t\tLINK_DESTINATION_NONE\n\t\t\t) {\n\t\t\t\tcase 'file':\n\t\t\t\tcase LINK_DESTINATION_MEDIA:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_MEDIA;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'post':\n\t\t\t\tcase LINK_DESTINATION_ATTACHMENT:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_ATTACHMENT;\n\t\t\t\t\tbreak;\n\t\t\t\tcase LINK_DESTINATION_CUSTOM:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_CUSTOM;\n\t\t\t\t\tbreak;\n\t\t\t\tcase LINK_DESTINATION_NONE:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_NONE;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// Check if the image is linked to it's media.\n\t\tlet href;\n\t\tswitch ( linkDestination ) {\n\t\t\tcase LINK_DESTINATION_MEDIA:\n\t\t\t\thref = media.url;\n\t\t\t\tbreak;\n\t\t\tcase LINK_DESTINATION_ATTACHMENT:\n\t\t\t\thref = media.link;\n\t\t\t\tbreak;\n\t\t}\n\t\tmediaAttributes.href = href;\n\n\t\tsetAttributes( {\n\t\t\t...mediaAttributes,\n\t\t\t...additionalAttributes,\n\t\t\tlinkDestination,\n\t\t} );\n\t}\n\n\tfunction onSelectURL( newURL ) {\n\t\tif ( newURL !== url ) {\n\t\t\tsetAttributes( {\n\t\t\t\turl: newURL,\n\t\t\t\tid: undefined,\n\t\t\t\tsizeSlug: imageDefaultSize,\n\t\t\t} );\n\t\t}\n\t}\n\n\tlet isTemp = isTemporaryImage( id, url );\n\n\t// Upload a temporary image on mount.\n\tuseEffect( () => {\n\t\tif ( ! isTemp ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst file = getBlobByURL( url );\n\n\t\tif ( file ) {\n\t\t\tmediaUpload( {\n\t\t\t\tfilesList: [ file ],\n\t\t\t\tonFileChange: ( [ img ] ) => {\n\t\t\t\t\tonSelectImage( img );\n\t\t\t\t},\n\t\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\t\tonError: ( message ) => {\n\t\t\t\t\tisTemp = false;\n\t\t\t\t\tonUploadError( message );\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\t}, [] );\n\n\t// If an image is temporary, revoke the Blob url when it is uploaded (and is\n\t// no longer temporary).\n\tuseEffect( () => {\n\t\tif ( isTemp ) {\n\t\t\tsetTemporaryURL( url );\n\t\t\treturn;\n\t\t}\n\t\trevokeBlobURL( temporaryURL );\n\t}, [ isTemp, url ] );\n\n\tconst isExternal = isExternalImage( id, url );\n\tconst src = isExternal ? url : undefined;\n\tconst mediaPreview = !! url && (\n\t\t<img\n\t\t\talt={ __( 'Edit image' ) }\n\t\t\ttitle={ __( 'Edit image' ) }\n\t\t\tclassName={ 'edit-image-preview' }\n\t\t\tsrc={ url }\n\t\t/>\n\t);\n\n\tconst borderProps = useBorderProps( attributes );\n\n\tconst classes = classnames( className, {\n\t\t'is-transient': temporaryURL,\n\t\t'is-resized': !! width || !! height,\n\t\t[ `size-${ sizeSlug }` ]: sizeSlug,\n\t\t'has-custom-border':\n\t\t\t!! borderProps.className ||\n\t\t\t( borderProps.style &&\n\t\t\t\tObject.keys( borderProps.style ).length > 0 ),\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tref,\n\t\tclassName: classes,\n\t} );\n\n\t// Much of this description is duplicated from MediaPlaceholder.\n\tconst placeholder = ( content ) => {\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\tclassName={ classnames( 'block-editor-media-placeholder', {\n\t\t\t\t\t[ borderProps.className ]:\n\t\t\t\t\t\t!! borderProps.className && ! isSelected,\n\t\t\t\t} ) }\n\t\t\t\twithIllustration={ true }\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ __( 'Image' ) }\n\t\t\t\tinstructions={ __(\n\t\t\t\t\t'Upload an image file, pick one from your media library, or add one with a URL.'\n\t\t\t\t) }\n\t\t\t\tstyle={ {\n\t\t\t\t\taspectRatio:\n\t\t\t\t\t\t! ( width && height ) && aspectRatio\n\t\t\t\t\t\t\t? aspectRatio\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\twidth: height && aspectRatio ? '100%' : width,\n\t\t\t\t\theight: width && aspectRatio ? '100%' : height,\n\t\t\t\t\tobjectFit: scale,\n\t\t\t\t\t...borderProps.style,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ content }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\n\treturn (\n\t\t<figure { ...blockProps }>\n\t\t\t<Image\n\t\t\t\ttemporaryURL={ temporaryURL }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\tisSelected={ isSelected }\n\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\tonReplace={ onReplace }\n\t\t\t\tonSelectImage={ onSelectImage }\n\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\tonUploadError={ onUploadError }\n\t\t\t\tcontainerRef={ ref }\n\t\t\t\tcontext={ context }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tblockEditingMode={ blockEditingMode }\n\t\t\t/>\n\t\t\t<MediaPlaceholder\n\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\tonError={ onUploadError }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t\taccept=\"image/*\"\n\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\tvalue={ { id, src } }\n\t\t\t\tmediaPreview={ mediaPreview }\n\t\t\t\tdisableMediaButtons={ temporaryURL || url }\n\t\t\t/>\n\t\t</figure>\n\t);\n}\n\nexport default ImageEdit;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA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IAC/Be,WAAW,EAAGA,WAAa;IAC3BnB,aAAa,EAAGA,aAAe;IAC/B2C,YAAY,EAAGnD,GAAK;IACpBjB,OAAO,EAAGA,OAAS;IACnBC,QAAQ,EAAGA,QAAU;IACrBsB,gBAAgB,EAAGA;EAAkB,CACrC,CAAC,EACFgC,aAAA,CAACrG,gBAAgB;IAChBY,IAAI,EAAGyF,aAAA,CAACtG,SAAS;MAACa,IAAI,EAAGA;IAAM,CAAE,CAAG;IACpCuG,QAAQ,EAAGxC,aAAe;IAC1Be,WAAW,EAAGA,WAAa;IAC3BQ,OAAO,EAAG3B,aAAe;IACzBqC,WAAW,EAAGA,WAAa;IAC3BQ,MAAM,EAAC,SAAS;IAChBnB,YAAY,EAAG9E,mBAAqB;IACpCkG,KAAK,EAAG;MAAEnF,EAAE;MAAEwC;IAAI,CAAG;IACrB0B,YAAY,EAAGA,YAAc;IAC7BkB,mBAAmB,EAAG9D,YAAY,IAAI3B;EAAK,CAC3C,CACM,CAAC;AAEX;AAEA,eAAeU,SAAS"}
|
|
1
|
+
{"version":3,"names":["classnames","getBlobByURL","isBlobURL","revokeBlobURL","Placeholder","useDispatch","useSelect","BlockIcon","MediaPlaceholder","useBlockProps","store","blockEditorStore","__experimentalUseBorderProps","useBorderProps","useBlockEditingMode","useEffect","useRef","useState","__","image","icon","plugins","pluginsIcon","noticesStore","Image","LINK_DESTINATION_ATTACHMENT","LINK_DESTINATION_CUSTOM","LINK_DESTINATION_MEDIA","LINK_DESTINATION_NONE","ALLOWED_MEDIA_TYPES","pickRelevantMediaFiles","size","imageProps","Object","fromEntries","entries","filter","key","includes","url","sizes","media_details","source_url","isTemporaryImage","id","isExternalImage","hasSize","_image$sizes$size","_image$media_details$","ImageEdit","attributes","setAttributes","isSelected","className","insertBlocksAfter","onReplace","context","clientId","alt","caption","width","height","sizeSlug","aspectRatio","scale","align","metadata","temporaryURL","setTemporaryURL","altRef","current","captionRef","__unstableMarkNextChangeAsNotPersistent","undefined","ref","imageDefaultSize","mediaUpload","select","getSettings","settings","blockEditingMode","createErrorNotice","onUploadError","message","type","src","onSelectImage","media","title","newSize","mediaAttributes","omittedCaption","restMediaAttributes","additionalAttributes","linkDestination","window","wp","view","defaultProps","link","href","onSelectURL","newURL","isTemp","file","filesList","onFileChange","img","allowedTypes","onError","isExternal","mediaPreview","createElement","borderProps","classes","style","keys","length","blockProps","isUrlAttributeConnected","bindings","placeholder","content","withIllustration","label","instructions","objectFit","containerRef","onSelect","accept","value","disableMediaButtons"],"sources":["@wordpress/block-library/src/image/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlobByURL, isBlobURL, revokeBlobURL } from '@wordpress/blob';\nimport { Placeholder } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tBlockIcon,\n\tMediaPlaceholder,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalUseBorderProps as useBorderProps,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { image as icon, plugins as pluginsIcon } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport Image from './image';\n\n/**\n * Module constants\n */\nimport {\n\tLINK_DESTINATION_ATTACHMENT,\n\tLINK_DESTINATION_CUSTOM,\n\tLINK_DESTINATION_MEDIA,\n\tLINK_DESTINATION_NONE,\n\tALLOWED_MEDIA_TYPES,\n} from './constants';\n\nexport const pickRelevantMediaFiles = ( image, size ) => {\n\tconst imageProps = Object.fromEntries(\n\t\tObject.entries( image ?? {} ).filter( ( [ key ] ) =>\n\t\t\t[ 'alt', 'id', 'link', 'caption' ].includes( key )\n\t\t)\n\t);\n\n\timageProps.url =\n\t\timage?.sizes?.[ size ]?.url ||\n\t\timage?.media_details?.sizes?.[ size ]?.source_url ||\n\t\timage.url;\n\treturn imageProps;\n};\n\n/**\n * Is the URL a temporary blob URL? A blob URL is one that is used temporarily\n * while the image is being uploaded and will not have an id yet allocated.\n *\n * @param {number=} id The id of the image.\n * @param {string=} url The url of the image.\n *\n * @return {boolean} Is the URL a Blob URL\n */\nconst isTemporaryImage = ( id, url ) => ! id && isBlobURL( url );\n\n/**\n * Is the url for the image hosted externally. An externally hosted image has no\n * id and is not a blob url.\n *\n * @param {number=} id The id of the image.\n * @param {string=} url The url of the image.\n *\n * @return {boolean} Is the url an externally hosted url?\n */\nexport const isExternalImage = ( id, url ) => url && ! id && ! isBlobURL( url );\n\n/**\n * Checks if WP generated the specified image size. Size generation is skipped\n * when the image is smaller than the said size.\n *\n * @param {Object} image\n * @param {string} size\n *\n * @return {boolean} Whether or not it has default image size.\n */\nfunction hasSize( image, size ) {\n\treturn (\n\t\t'url' in ( image?.sizes?.[ size ] ?? {} ) ||\n\t\t'source_url' in ( image?.media_details?.sizes?.[ size ] ?? {} )\n\t);\n}\n\nexport function ImageEdit( {\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tclassName,\n\tinsertBlocksAfter,\n\tonReplace,\n\tcontext,\n\tclientId,\n} ) {\n\tconst {\n\t\turl = '',\n\t\talt,\n\t\tcaption,\n\t\tid,\n\t\twidth,\n\t\theight,\n\t\tsizeSlug,\n\t\taspectRatio,\n\t\tscale,\n\t\talign,\n\t\tmetadata,\n\t} = attributes;\n\tconst [ temporaryURL, setTemporaryURL ] = useState();\n\n\tconst altRef = useRef();\n\tuseEffect( () => {\n\t\taltRef.current = alt;\n\t}, [ alt ] );\n\n\tconst captionRef = useRef();\n\tuseEffect( () => {\n\t\tcaptionRef.current = caption;\n\t}, [ caption ] );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tif ( [ 'wide', 'full' ].includes( align ) ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( {\n\t\t\t\twidth: undefined,\n\t\t\t\theight: undefined,\n\t\t\t\taspectRatio: undefined,\n\t\t\t\tscale: undefined,\n\t\t\t} );\n\t\t}\n\t}, [ align ] );\n\n\tconst ref = useRef();\n\tconst { imageDefaultSize, mediaUpload } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst settings = getSettings();\n\t\treturn {\n\t\t\timageDefaultSize: settings.imageDefaultSize,\n\t\t\tmediaUpload: settings.mediaUpload,\n\t\t};\n\t}, [] );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tfunction onUploadError( message ) {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t\tsetAttributes( {\n\t\t\tsrc: undefined,\n\t\t\tid: undefined,\n\t\t\turl: undefined,\n\t\t} );\n\t\tsetTemporaryURL( undefined );\n\t}\n\n\tfunction onSelectImage( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\tsetAttributes( {\n\t\t\t\turl: undefined,\n\t\t\t\talt: undefined,\n\t\t\t\tid: undefined,\n\t\t\t\ttitle: undefined,\n\t\t\t\tcaption: undefined,\n\t\t\t} );\n\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( media.url ) ) {\n\t\t\tsetTemporaryURL( media.url );\n\t\t\treturn;\n\t\t}\n\n\t\tsetTemporaryURL();\n\n\t\t// Try to use the previous selected image size if its available\n\t\t// otherwise try the default image size or fallback to \"full\"\n\t\tlet newSize = 'full';\n\t\tif ( sizeSlug && hasSize( media, sizeSlug ) ) {\n\t\t\tnewSize = sizeSlug;\n\t\t} else if ( hasSize( media, imageDefaultSize ) ) {\n\t\t\tnewSize = imageDefaultSize;\n\t\t}\n\n\t\tlet mediaAttributes = pickRelevantMediaFiles( media, newSize );\n\n\t\t// If a caption text was meanwhile written by the user,\n\t\t// make sure the text is not overwritten by empty captions.\n\t\tif ( captionRef.current && ! mediaAttributes.caption ) {\n\t\t\tconst { caption: omittedCaption, ...restMediaAttributes } =\n\t\t\t\tmediaAttributes;\n\t\t\tmediaAttributes = restMediaAttributes;\n\t\t}\n\n\t\tlet additionalAttributes;\n\t\t// Reset the dimension attributes if changing to a different image.\n\t\tif ( ! media.id || media.id !== id ) {\n\t\t\tadditionalAttributes = {\n\t\t\t\tsizeSlug: newSize,\n\t\t\t};\n\t\t} else {\n\t\t\t// Keep the same url when selecting the same file, so \"Resolution\"\n\t\t\t// option is not changed.\n\t\t\tadditionalAttributes = { url };\n\t\t}\n\n\t\t// Check if default link setting should be used.\n\t\tlet linkDestination = attributes.linkDestination;\n\t\tif ( ! linkDestination ) {\n\t\t\t// Use the WordPress option to determine the proper default.\n\t\t\t// The constants used in Gutenberg do not match WP options so a little more complicated than ideal.\n\t\t\t// TODO: fix this in a follow up PR, requires updating media-text and ui component.\n\t\t\tswitch (\n\t\t\t\twindow?.wp?.media?.view?.settings?.defaultProps?.link ||\n\t\t\t\tLINK_DESTINATION_NONE\n\t\t\t) {\n\t\t\t\tcase 'file':\n\t\t\t\tcase LINK_DESTINATION_MEDIA:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_MEDIA;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'post':\n\t\t\t\tcase LINK_DESTINATION_ATTACHMENT:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_ATTACHMENT;\n\t\t\t\t\tbreak;\n\t\t\t\tcase LINK_DESTINATION_CUSTOM:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_CUSTOM;\n\t\t\t\t\tbreak;\n\t\t\t\tcase LINK_DESTINATION_NONE:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_NONE;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// Check if the image is linked to it's media.\n\t\tlet href;\n\t\tswitch ( linkDestination ) {\n\t\t\tcase LINK_DESTINATION_MEDIA:\n\t\t\t\thref = media.url;\n\t\t\t\tbreak;\n\t\t\tcase LINK_DESTINATION_ATTACHMENT:\n\t\t\t\thref = media.link;\n\t\t\t\tbreak;\n\t\t}\n\t\tmediaAttributes.href = href;\n\n\t\tsetAttributes( {\n\t\t\t...mediaAttributes,\n\t\t\t...additionalAttributes,\n\t\t\tlinkDestination,\n\t\t} );\n\t}\n\n\tfunction onSelectURL( newURL ) {\n\t\tif ( newURL !== url ) {\n\t\t\tsetAttributes( {\n\t\t\t\turl: newURL,\n\t\t\t\tid: undefined,\n\t\t\t\tsizeSlug: imageDefaultSize,\n\t\t\t} );\n\t\t}\n\t}\n\n\tlet isTemp = isTemporaryImage( id, url );\n\n\t// Upload a temporary image on mount.\n\tuseEffect( () => {\n\t\tif ( ! isTemp ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst file = getBlobByURL( url );\n\n\t\tif ( file ) {\n\t\t\tmediaUpload( {\n\t\t\t\tfilesList: [ file ],\n\t\t\t\tonFileChange: ( [ img ] ) => {\n\t\t\t\t\tonSelectImage( img );\n\t\t\t\t},\n\t\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\t\tonError: ( message ) => {\n\t\t\t\t\tisTemp = false;\n\t\t\t\t\tonUploadError( message );\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\t}, [] );\n\n\t// If an image is temporary, revoke the Blob url when it is uploaded (and is\n\t// no longer temporary).\n\tuseEffect( () => {\n\t\tif ( isTemp ) {\n\t\t\tsetTemporaryURL( url );\n\t\t\treturn;\n\t\t}\n\t\trevokeBlobURL( temporaryURL );\n\t}, [ isTemp, url ] );\n\n\tconst isExternal = isExternalImage( id, url );\n\tconst src = isExternal ? url : undefined;\n\tconst mediaPreview = !! url && (\n\t\t<img\n\t\t\talt={ __( 'Edit image' ) }\n\t\t\ttitle={ __( 'Edit image' ) }\n\t\t\tclassName={ 'edit-image-preview' }\n\t\t\tsrc={ url }\n\t\t/>\n\t);\n\n\tconst borderProps = useBorderProps( attributes );\n\n\tconst classes = classnames( className, {\n\t\t'is-transient': temporaryURL,\n\t\t'is-resized': !! width || !! height,\n\t\t[ `size-${ sizeSlug }` ]: sizeSlug,\n\t\t'has-custom-border':\n\t\t\t!! borderProps.className ||\n\t\t\t( borderProps.style &&\n\t\t\t\tObject.keys( borderProps.style ).length > 0 ),\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tref,\n\t\tclassName: classes,\n\t} );\n\n\t// Much of this description is duplicated from MediaPlaceholder.\n\tconst isUrlAttributeConnected = !! metadata?.bindings?.url;\n\tconst placeholder = ( content ) => {\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\tclassName={ classnames( 'block-editor-media-placeholder', {\n\t\t\t\t\t[ borderProps.className ]:\n\t\t\t\t\t\t!! borderProps.className && ! isSelected,\n\t\t\t\t} ) }\n\t\t\t\twithIllustration={ true }\n\t\t\t\ticon={ isUrlAttributeConnected ? pluginsIcon : icon }\n\t\t\t\tlabel={ __( 'Image' ) }\n\t\t\t\tinstructions={\n\t\t\t\t\t! isUrlAttributeConnected &&\n\t\t\t\t\t__(\n\t\t\t\t\t\t'Upload an image file, pick one from your media library, or add one with a URL.'\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tstyle={ {\n\t\t\t\t\taspectRatio:\n\t\t\t\t\t\t! ( width && height ) && aspectRatio\n\t\t\t\t\t\t\t? aspectRatio\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\twidth: height && aspectRatio ? '100%' : width,\n\t\t\t\t\theight: width && aspectRatio ? '100%' : height,\n\t\t\t\t\tobjectFit: scale,\n\t\t\t\t\t...borderProps.style,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ isUrlAttributeConnected ? (\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName={ 'block-bindings-media-placeholder-message' }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Connected to a custom field' ) }\n\t\t\t\t\t</span>\n\t\t\t\t) : (\n\t\t\t\t\tcontent\n\t\t\t\t) }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\n\treturn (\n\t\t<figure { ...blockProps }>\n\t\t\t<Image\n\t\t\t\ttemporaryURL={ temporaryURL }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\tisSelected={ isSelected }\n\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\tonReplace={ onReplace }\n\t\t\t\tonSelectImage={ onSelectImage }\n\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\tonUploadError={ onUploadError }\n\t\t\t\tcontainerRef={ ref }\n\t\t\t\tcontext={ context }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tblockEditingMode={ blockEditingMode }\n\t\t\t/>\n\t\t\t<MediaPlaceholder\n\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\tonError={ onUploadError }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t\taccept=\"image/*\"\n\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\tvalue={ { id, src } }\n\t\t\t\tmediaPreview={ mediaPreview }\n\t\t\t\tdisableMediaButtons={ temporaryURL || url }\n\t\t\t/>\n\t\t</figure>\n\t);\n}\n\nexport default ImageEdit;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,YAAY,EAAEC,SAAS,EAAEC,aAAa,QAAQ,iBAAiB;AACxE,SAASC,WAAW,QAAQ,uBAAuB;AACnD,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SACCC,SAAS,EACTC,gBAAgB,EAChBC,aAAa,EACbC,KAAK,IAAIC,gBAAgB,EACzBC,4BAA4B,IAAIC,cAAc,EAC9CC,mBAAmB,QACb,yBAAyB;AAChC,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,oBAAoB;AAChE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,KAAK,IAA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,QAAQ,EAAGA,QAAU;IACrBuB,gBAAgB,EAAGA;EAAkB,CACrC,CAAC,EACFgC,aAAA,CAACxG,gBAAgB;IAChBY,IAAI,EAAG4F,aAAA,CAACzG,SAAS;MAACa,IAAI,EAAGA;IAAM,CAAE,CAAG;IACpC4G,QAAQ,EAAG1C,aAAe;IAC1Be,WAAW,EAAGA,WAAa;IAC3BQ,OAAO,EAAG3B,aAAe;IACzBuC,WAAW,EAAGA,WAAa;IAC3BQ,MAAM,EAAC,SAAS;IAChBrB,YAAY,EAAG/E,mBAAqB;IACpCqG,KAAK,EAAG;MAAEtF,EAAE;MAAEyC;IAAI,CAAG;IACrB0B,YAAY,EAAGA,YAAc;IAC7BoB,mBAAmB,EAAGhE,YAAY,IAAI5B;EAAK,CAC3C,CACM,CAAC;AAEX;AAEA,eAAeU,SAAS"}
|
|
@@ -98,7 +98,8 @@ export default function Image({
|
|
|
98
98
|
scale,
|
|
99
99
|
linkTarget,
|
|
100
100
|
sizeSlug,
|
|
101
|
-
lightbox
|
|
101
|
+
lightbox,
|
|
102
|
+
metadata
|
|
102
103
|
} = attributes;
|
|
103
104
|
|
|
104
105
|
// The only supported unit is px, so we can parseInt to strip the px here.
|
|
@@ -293,7 +294,7 @@ export default function Image({
|
|
|
293
294
|
const [lightboxSetting] = useSettings('lightbox');
|
|
294
295
|
const showLightboxToggle = !!lightbox || lightboxSetting?.allowEditing === true;
|
|
295
296
|
const lightboxChecked = !!lightbox?.enabled || !lightbox && !!lightboxSetting?.enabled;
|
|
296
|
-
const lightboxToggleDisabled = linkDestination !== 'none';
|
|
297
|
+
const lightboxToggleDisabled = linkDestination && linkDestination !== 'none';
|
|
297
298
|
const dimensionsControl = createElement(DimensionsTool, {
|
|
298
299
|
value: {
|
|
299
300
|
width,
|
|
@@ -341,9 +342,31 @@ export default function Image({
|
|
|
341
342
|
resetAll: resetAll,
|
|
342
343
|
dropdownMenuProps: TOOLSPANEL_DROPDOWNMENU_PROPS
|
|
343
344
|
}, isResizable && dimensionsControl));
|
|
345
|
+
const {
|
|
346
|
+
lockUrlControls = false,
|
|
347
|
+
lockAltControls = false,
|
|
348
|
+
lockTitleControls = false
|
|
349
|
+
} = useSelect(select => {
|
|
350
|
+
if (!isSelected) {
|
|
351
|
+
return {};
|
|
352
|
+
}
|
|
353
|
+
const {
|
|
354
|
+
getBlockBindingsSource
|
|
355
|
+
} = unlock(select(blockEditorStore));
|
|
356
|
+
const {
|
|
357
|
+
url: urlBinding,
|
|
358
|
+
alt: altBinding,
|
|
359
|
+
title: titleBinding
|
|
360
|
+
} = metadata?.bindings || {};
|
|
361
|
+
return {
|
|
362
|
+
lockUrlControls: !!urlBinding && getBlockBindingsSource(urlBinding?.source?.name)?.lockAttributesEditing === true,
|
|
363
|
+
lockAltControls: !!altBinding && getBlockBindingsSource(altBinding?.source?.name)?.lockAttributesEditing === true,
|
|
364
|
+
lockTitleControls: !!titleBinding && getBlockBindingsSource(titleBinding?.source?.name)?.lockAttributesEditing === true
|
|
365
|
+
};
|
|
366
|
+
}, [isSelected]);
|
|
344
367
|
const controls = createElement(Fragment, null, createElement(BlockControls, {
|
|
345
368
|
group: "block"
|
|
346
|
-
}, !multiImageSelection && !isEditingImage && createElement(ImageURLInputUI, {
|
|
369
|
+
}, !multiImageSelection && !isEditingImage && !lockUrlControls && createElement(ImageURLInputUI, {
|
|
347
370
|
url: href || '',
|
|
348
371
|
onChangeUrl: onSetHref,
|
|
349
372
|
linkDestination: linkDestination,
|
|
@@ -360,7 +383,7 @@ export default function Image({
|
|
|
360
383
|
icon: overlayText,
|
|
361
384
|
label: __('Add text over image'),
|
|
362
385
|
onClick: switchToCover
|
|
363
|
-
})), !multiImageSelection && !isEditingImage && createElement(BlockControls, {
|
|
386
|
+
})), !multiImageSelection && !isEditingImage && !lockUrlControls && createElement(BlockControls, {
|
|
364
387
|
group: "other"
|
|
365
388
|
}, createElement(MediaReplaceFlow, {
|
|
366
389
|
mediaId: id,
|
|
@@ -389,7 +412,8 @@ export default function Image({
|
|
|
389
412
|
label: __('Alternative text'),
|
|
390
413
|
value: alt || '',
|
|
391
414
|
onChange: updateAlt,
|
|
392
|
-
|
|
415
|
+
disabled: lockAltControls,
|
|
416
|
+
help: lockAltControls ? createElement(Fragment, null, __('Connected to a custom field')) : createElement(Fragment, null, createElement(ExternalLink, {
|
|
393
417
|
href: "https://www.w3.org/WAI/tutorials/images/decision-tree"
|
|
394
418
|
}, __('Describe the purpose of the image.')), createElement("br", null), __('Leave empty if decorative.')),
|
|
395
419
|
__nextHasNoMarginBottom: true
|
|
@@ -425,7 +449,8 @@ export default function Image({
|
|
|
425
449
|
label: __('Title attribute'),
|
|
426
450
|
value: title || '',
|
|
427
451
|
onChange: onSetTitle,
|
|
428
|
-
|
|
452
|
+
disabled: lockTitleControls,
|
|
453
|
+
help: lockTitleControls ? createElement(Fragment, null, __('Connected to a custom field')) : createElement(Fragment, null, __('Describe the role of this image on the page.'), createElement(ExternalLink, {
|
|
429
454
|
href: "https://www.w3.org/TR/html52/dom.html#the-title-attribute"
|
|
430
455
|
}, __('(Note: many devices and browsers do not display this text.)')))
|
|
431
456
|
})));
|
|
@@ -585,7 +610,8 @@ export default function Image({
|
|
|
585
610
|
}, img));
|
|
586
611
|
}
|
|
587
612
|
if (!url && !temporaryURL) {
|
|
588
|
-
|
|
613
|
+
// Add all controls if the image attributes are connected.
|
|
614
|
+
return metadata?.bindings ? controls : sizeControls;
|
|
589
615
|
}
|
|
590
616
|
return createElement(Fragment, null, !temporaryURL && controls, img, createElement(Caption, {
|
|
591
617
|
attributes: attributes,
|