@wordpress/block-editor 12.3.13 → 12.3.14
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/components/block-controls/use-has-block-controls.js +52 -0
- package/build/components/block-controls/use-has-block-controls.js.map +1 -0
- package/build/components/block-tools/block-contextual-toolbar.js +50 -5
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +3 -2
- package/build/components/global-styles/typography-utils.js.map +1 -1
- package/build/components/link-control/index.js +47 -6
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/rich-text/use-format-types.js +3 -2
- package/build/components/rich-text/use-format-types.js.map +1 -1
- package/build-module/components/block-controls/use-has-block-controls.js +38 -0
- package/build-module/components/block-controls/use-has-block-controls.js.map +1 -0
- package/build-module/components/block-tools/block-contextual-toolbar.js +49 -5
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +4 -3
- package/build-module/components/global-styles/typography-utils.js.map +1 -1
- package/build-module/components/link-control/index.js +45 -6
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/rich-text/use-format-types.js +3 -2
- package/build-module/components/rich-text/use-format-types.js.map +1 -1
- package/build-style/content-rtl.css +5 -7
- package/build-style/content.css +5 -7
- package/build-style/style-rtl.css +28 -6
- package/build-style/style.css +28 -6
- package/package.json +5 -5
- package/src/components/block-controls/use-has-block-controls.js +35 -0
- package/src/components/block-list/content.scss +2 -3
- package/src/components/block-toolbar/style.scss +10 -0
- package/src/components/block-tools/block-contextual-toolbar.js +86 -7
- package/src/components/block-tools/style.scss +34 -10
- package/src/components/global-styles/test/typography-utils.js +10 -0
- package/src/components/global-styles/typography-utils.js +11 -3
- package/src/components/link-control/README.md +12 -3
- package/src/components/link-control/index.js +43 -6
- package/src/components/link-control/test/index.js +2 -1
- package/src/components/rich-text/use-format-types.js +3 -3
|
@@ -9,7 +9,7 @@ import classnames from 'classnames';
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { __ } from '@wordpress/i18n';
|
|
12
|
-
import { useEffect, useRef, useState } from '@wordpress/element';
|
|
12
|
+
import { useLayoutEffect, useEffect, useRef, useState } from '@wordpress/element';
|
|
13
13
|
import { hasBlockSupport, store as blocksStore } from '@wordpress/blocks';
|
|
14
14
|
import { useSelect } from '@wordpress/data';
|
|
15
15
|
import { ToolbarItem, ToolbarButton, ToolbarGroup } from '@wordpress/components';
|
|
@@ -23,6 +23,7 @@ import NavigableToolbar from '../navigable-toolbar';
|
|
|
23
23
|
import BlockToolbar from '../block-toolbar';
|
|
24
24
|
import { store as blockEditorStore } from '../../store';
|
|
25
25
|
import { unlock } from '../../lock-unlock';
|
|
26
|
+
import { useHasAnyBlockControls } from '../block-controls/use-has-block-controls';
|
|
26
27
|
|
|
27
28
|
function BlockContextualToolbar({
|
|
28
29
|
focusOnMount,
|
|
@@ -35,10 +36,10 @@ function BlockContextualToolbar({
|
|
|
35
36
|
const isLargeViewport = useViewportMatch('medium');
|
|
36
37
|
const {
|
|
37
38
|
blockType,
|
|
39
|
+
blockEditingMode,
|
|
38
40
|
hasParents,
|
|
39
41
|
showParentSelector,
|
|
40
|
-
selectedBlockClientId
|
|
41
|
-
isContentOnly
|
|
42
|
+
selectedBlockClientId
|
|
42
43
|
} = useSelect(select => {
|
|
43
44
|
const {
|
|
44
45
|
getBlockName,
|
|
@@ -58,16 +59,59 @@ function BlockContextualToolbar({
|
|
|
58
59
|
return {
|
|
59
60
|
selectedBlockClientId: _selectedBlockClientId,
|
|
60
61
|
blockType: _selectedBlockClientId && getBlockType(getBlockName(_selectedBlockClientId)),
|
|
62
|
+
blockEditingMode: getBlockEditingMode(_selectedBlockClientId),
|
|
61
63
|
hasParents: parents.length,
|
|
62
|
-
isContentOnly: getBlockEditingMode(_selectedBlockClientId) === 'contentOnly',
|
|
63
64
|
showParentSelector: parentBlockType && getBlockEditingMode(firstParentClientId) === 'default' && hasBlockSupport(parentBlockType, '__experimentalParentSelector', true) && selectedBlockClientIds.length <= 1 && getBlockEditingMode(_selectedBlockClientId) === 'default'
|
|
64
65
|
};
|
|
65
66
|
}, []);
|
|
66
67
|
useEffect(() => {
|
|
67
68
|
setIsCollapsed(false);
|
|
68
69
|
}, [selectedBlockClientId]);
|
|
70
|
+
const isLargerThanTabletViewport = useViewportMatch('large', '>=');
|
|
71
|
+
const isFullscreen = document.body.classList.contains('is-fullscreen-mode');
|
|
72
|
+
useLayoutEffect(() => {
|
|
73
|
+
// don't do anything if not fixed toolbar
|
|
74
|
+
if (!isFixed || !blockType) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
69
77
|
|
|
70
|
-
|
|
78
|
+
const blockToolbar = document.querySelector('.block-editor-block-contextual-toolbar');
|
|
79
|
+
|
|
80
|
+
if (!blockToolbar) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (!isLargerThanTabletViewport) {
|
|
85
|
+
// set the width of the toolbar to auto
|
|
86
|
+
blockToolbar.style = {};
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (isCollapsed) {
|
|
91
|
+
// set the width of the toolbar to auto
|
|
92
|
+
blockToolbar.style.width = 'auto';
|
|
93
|
+
return;
|
|
94
|
+
} // get the width of the pinned items in the post editor
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
const pinnedItems = document.querySelector('.edit-post-header__settings'); // get the width of the left header in the site editor
|
|
98
|
+
|
|
99
|
+
const leftHeader = document.querySelector('.edit-site-header-edit-mode__end');
|
|
100
|
+
const computedToolbarStyle = window.getComputedStyle(blockToolbar);
|
|
101
|
+
const computedPinnedItemsStyle = pinnedItems ? window.getComputedStyle(pinnedItems) : false;
|
|
102
|
+
const computedLeftHeaderStyle = leftHeader ? window.getComputedStyle(leftHeader) : false;
|
|
103
|
+
const marginLeft = parseFloat(computedToolbarStyle.marginLeft);
|
|
104
|
+
const pinnedItemsWidth = computedPinnedItemsStyle ? parseFloat(computedPinnedItemsStyle.width) + 10 // 10 is the pinned items padding
|
|
105
|
+
: 0;
|
|
106
|
+
const leftHeaderWidth = computedLeftHeaderStyle ? parseFloat(computedLeftHeaderStyle.width) : 0; // set the new witdth of the toolbar
|
|
107
|
+
|
|
108
|
+
blockToolbar.style.width = `calc(100% - ${leftHeaderWidth + pinnedItemsWidth + marginLeft + (isFullscreen ? 0 : 160) // the width of the admin sidebar expanded
|
|
109
|
+
}px)`;
|
|
110
|
+
}, [isFixed, isLargerThanTabletViewport, isCollapsed, isFullscreen, blockType]);
|
|
111
|
+
const isToolbarEnabled = !blockType || hasBlockSupport(blockType, '__experimentalToolbar', true);
|
|
112
|
+
const hasAnyBlockControls = useHasAnyBlockControls();
|
|
113
|
+
|
|
114
|
+
if (!isToolbarEnabled || blockEditingMode !== 'default' && !hasAnyBlockControls) {
|
|
71
115
|
return null;
|
|
72
116
|
} // Shifts the toolbar to make room for the parent block selector.
|
|
73
117
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/block-contextual-toolbar.js"],"names":["classnames","__","useEffect","useRef","useState","hasBlockSupport","store","blocksStore","useSelect","ToolbarItem","ToolbarButton","ToolbarGroup","next","previous","useViewportMatch","NavigableToolbar","BlockToolbar","blockEditorStore","unlock","BlockContextualToolbar","focusOnMount","isFixed","props","isCollapsed","setIsCollapsed","toolbarButtonRef","isLargeViewport","blockType","hasParents","showParentSelector","selectedBlockClientId","isContentOnly","select","getBlockName","getBlockParents","getSelectedBlockClientIds","getBlockEditingMode","getBlockType","selectedBlockClientIds","_selectedBlockClientId","parents","firstParentClientId","length","parentBlockName","parentBlockType","classes","collapsed","current","focus"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,EAAoBC,MAApB,EAA4BC,QAA5B,QAA4C,oBAA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KMqB;AALN,KAOG,CAAEC,WAAF,IAAiB,cAAC,YAAD;AAAc,IAAA,cAAc,EAAGF;AAA/B,IAPpB,EAQGA,OAAO,IAAIK,eAAX,IAA8BC,SAA9B,IACD,cAAC,YAAD;AACC,IAAA,SAAS,EACRJ,WAAW,GACR,wDADQ,GAER;AAJL,KAOC,cAAC,WAAD;AACC,IAAA,EAAE,EAAGb,aADN;AAEC,IAAA,GAAG,EAAGe,gBAFP;AAGC,IAAA,IAAI,EAAGF,WAAW,GAAGX,IAAH,GAAUC,QAH7B;AAIC,IAAA,OAAO,EAAG,MAAM;AACfW,MAAAA,cAAc,CAAIsB,SAAF,IAAiB,CAAEA,SAArB,CAAd;AACArB,MAAAA,gBAAgB,CAACsB,OAAjB,CAAyBC,KAAzB;AACA,KAPF;AAQC,IAAA,KAAK,EACJzB,WAAW,GACRtB,EAAE,CAAE,kBAAF,CADM,GAERA,EAAE,CAAE,kBAAF;AAXP,IAPD,CATF,CADD;AAmCA;;AAED,eAAekB,sBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport { hasBlockSupport, store as blocksStore } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tToolbarItem,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { next, previous } from '@wordpress/icons';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport NavigableToolbar from '../navigable-toolbar';\nimport BlockToolbar from '../block-toolbar';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nfunction BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {\n\t// When the toolbar is fixed it can be collapsed\n\tconst [ isCollapsed, setIsCollapsed ] = useState( false );\n\tconst toolbarButtonRef = useRef();\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\tblockType,\n\t\thasParents,\n\t\tshowParentSelector,\n\t\tselectedBlockClientId,\n\t\tisContentOnly,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetBlockName,\n\t\t\tgetBlockParents,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\tgetBlockEditingMode,\n\t\t} = unlock( select( blockEditorStore ) );\n\t\tconst { getBlockType } = select( blocksStore );\n\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\tconst _selectedBlockClientId = selectedBlockClientIds[ 0 ];\n\t\tconst parents = getBlockParents( _selectedBlockClientId );\n\t\tconst firstParentClientId = parents[ parents.length - 1 ];\n\t\tconst parentBlockName = getBlockName( firstParentClientId );\n\t\tconst parentBlockType = getBlockType( parentBlockName );\n\n\t\treturn {\n\t\t\tselectedBlockClientId: _selectedBlockClientId,\n\t\t\tblockType:\n\t\t\t\t_selectedBlockClientId &&\n\t\t\t\tgetBlockType( getBlockName( _selectedBlockClientId ) ),\n\t\t\thasParents: parents.length,\n\t\t\tisContentOnly:\n\t\t\t\tgetBlockEditingMode( _selectedBlockClientId ) === 'contentOnly',\n\t\t\tshowParentSelector:\n\t\t\t\tparentBlockType &&\n\t\t\t\tgetBlockEditingMode( firstParentClientId ) === 'default' &&\n\t\t\t\thasBlockSupport(\n\t\t\t\t\tparentBlockType,\n\t\t\t\t\t'__experimentalParentSelector',\n\t\t\t\t\ttrue\n\t\t\t\t) &&\n\t\t\t\tselectedBlockClientIds.length <= 1 &&\n\t\t\t\tgetBlockEditingMode( _selectedBlockClientId ) === 'default',\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tsetIsCollapsed( false );\n\t}, [ selectedBlockClientId ] );\n\n\tif (\n\t\tisContentOnly ||\n\t\t( blockType &&\n\t\t\t! hasBlockSupport( blockType, '__experimentalToolbar', true ) )\n\t) {\n\t\treturn null;\n\t}\n\n\t// Shifts the toolbar to make room for the parent block selector.\n\tconst classes = classnames( 'block-editor-block-contextual-toolbar', {\n\t\t'has-parent': hasParents && showParentSelector,\n\t\t'is-fixed': isFixed,\n\t\t'is-collapsed': isCollapsed,\n\t} );\n\n\treturn (\n\t\t<NavigableToolbar\n\t\t\tfocusOnMount={ focusOnMount }\n\t\t\tclassName={ classes }\n\t\t\t/* translators: accessibility text for the block toolbar */\n\t\t\taria-label={ __( 'Block tools' ) }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ ! isCollapsed && <BlockToolbar hideDragHandle={ isFixed } /> }\n\t\t\t{ isFixed && isLargeViewport && blockType && (\n\t\t\t\t<ToolbarGroup\n\t\t\t\t\tclassName={\n\t\t\t\t\t\tisCollapsed\n\t\t\t\t\t\t\t? 'block-editor-block-toolbar__group-expand-fixed-toolbar'\n\t\t\t\t\t\t\t: 'block-editor-block-toolbar__group-collapse-fixed-toolbar'\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\tas={ ToolbarButton }\n\t\t\t\t\t\tref={ toolbarButtonRef }\n\t\t\t\t\t\ticon={ isCollapsed ? next : previous }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetIsCollapsed( ( collapsed ) => ! collapsed );\n\t\t\t\t\t\t\ttoolbarButtonRef.current.focus();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\tisCollapsed\n\t\t\t\t\t\t\t\t? __( 'Show block tools' )\n\t\t\t\t\t\t\t\t: __( 'Hide block tools' )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t) }\n\t\t</NavigableToolbar>\n\t);\n}\n\nexport default BlockContextualToolbar;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/block-contextual-toolbar.js"],"names":["classnames","__","useLayoutEffect","useEffect","useRef","useState","hasBlockSupport","store","blocksStore","useSelect","ToolbarItem","ToolbarButton","ToolbarGroup","next","previous","useViewportMatch","NavigableToolbar","BlockToolbar","blockEditorStore","unlock","useHasAnyBlockControls","BlockContextualToolbar","focusOnMount","isFixed","props","isCollapsed","setIsCollapsed","toolbarButtonRef","isLargeViewport","blockType","blockEditingMode","hasParents","showParentSelector","selectedBlockClientId","select","getBlockName","getBlockParents","getSelectedBlockClientIds","getBlockEditingMode","getBlockType","selectedBlockClientIds","_selectedBlockClientId","parents","firstParentClientId","length","parentBlockName","parentBlockType","isLargerThanTabletViewport","isFullscreen","document","body","classList","contains","blockToolbar","querySelector","style","width","pinnedItems","leftHeader","computedToolbarStyle","window","getComputedStyle","computedPinnedItemsStyle","computedLeftHeaderStyle","marginLeft","parseFloat","pinnedItemsWidth","leftHeaderWidth","isToolbarEnabled","hasAnyBlockControls","classes","collapsed","current","focus"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,eADD,EAECC,SAFD,EAGCC,MAHD,EAICC,QAJD,QAKO,oBALP;AAMA,SAASC,eAAT,EAA0BC,KAAK,IAAIC,WAAnC,QAAsD,mBAAtD;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,WADD,EAECC,aAFD,EAGCC,YAHD,QAIO,uBAJP;AAKA,SAASC,IAAT,EAAeC,QAAf,QAA+B,kBAA/B;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AAEA;AACA;AACA;;AACA,OAAOC,gBAAP,MAA6B,sBAA7B;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,SAASV,KAAK,IAAIW,gBAAlB,QAA0C,aAA1C;AACA,SAASC,MAAT,QAAuB,mBAAvB;AACA,SAASC,sBAAT,QAAuC,0CAAvC;;AAEA,SAASC,sBAAT,CAAiC;AAAEC,EAAAA,YAAF;AAAgBC,EAAAA,OAAhB;AAAyB,KAAGC;AAA5B,CAAjC,EAAuE;AACtE;AACA,QAAM,CAAEC,WAAF,EAAeC,cAAf,IA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/B,IAPpB,EAQGA,OAAO,IAAIK,eAAX,IAA8BC,SAA9B,IACD,cAAC,YAAD;AACC,IAAA,SAAS,EACRJ,WAAW,GACR,wDADQ,GAER;AAJL,KAOC,cAAC,WAAD;AACC,IAAA,EAAE,EAAGd,aADN;AAEC,IAAA,GAAG,EAAGgB,gBAFP;AAGC,IAAA,IAAI,EAAGF,WAAW,GAAGZ,IAAH,GAAUC,QAH7B;AAIC,IAAA,OAAO,EAAG,MAAM;AACfY,MAAAA,cAAc,CAAI6C,SAAF,IAAiB,CAAEA,SAArB,CAAd;AACA5C,MAAAA,gBAAgB,CAAC6C,OAAjB,CAAyBC,KAAzB;AACA,KAPF;AAQC,IAAA,KAAK,EACJhD,WAAW,GACRxB,EAAE,CAAE,kBAAF,CADM,GAERA,EAAE,CAAE,kBAAF;AAXP,IAPD,CATF,CADD;AAmCA;;AAED,eAAeoB,sBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseLayoutEffect,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { hasBlockSupport, store as blocksStore } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tToolbarItem,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { next, previous } from '@wordpress/icons';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport NavigableToolbar from '../navigable-toolbar';\nimport BlockToolbar from '../block-toolbar';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { useHasAnyBlockControls } from '../block-controls/use-has-block-controls';\n\nfunction BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {\n\t// When the toolbar is fixed it can be collapsed\n\tconst [ isCollapsed, setIsCollapsed ] = useState( false );\n\tconst toolbarButtonRef = useRef();\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\tblockType,\n\t\tblockEditingMode,\n\t\thasParents,\n\t\tshowParentSelector,\n\t\tselectedBlockClientId,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetBlockName,\n\t\t\tgetBlockParents,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\tgetBlockEditingMode,\n\t\t} = unlock( select( blockEditorStore ) );\n\t\tconst { getBlockType } = select( blocksStore );\n\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\tconst _selectedBlockClientId = selectedBlockClientIds[ 0 ];\n\t\tconst parents = getBlockParents( _selectedBlockClientId );\n\t\tconst firstParentClientId = parents[ parents.length - 1 ];\n\t\tconst parentBlockName = getBlockName( firstParentClientId );\n\t\tconst parentBlockType = getBlockType( parentBlockName );\n\n\t\treturn {\n\t\t\tselectedBlockClientId: _selectedBlockClientId,\n\t\t\tblockType:\n\t\t\t\t_selectedBlockClientId &&\n\t\t\t\tgetBlockType( getBlockName( _selectedBlockClientId ) ),\n\t\t\tblockEditingMode: getBlockEditingMode( _selectedBlockClientId ),\n\t\t\thasParents: parents.length,\n\t\t\tshowParentSelector:\n\t\t\t\tparentBlockType &&\n\t\t\t\tgetBlockEditingMode( firstParentClientId ) === 'default' &&\n\t\t\t\thasBlockSupport(\n\t\t\t\t\tparentBlockType,\n\t\t\t\t\t'__experimentalParentSelector',\n\t\t\t\t\ttrue\n\t\t\t\t) &&\n\t\t\t\tselectedBlockClientIds.length <= 1 &&\n\t\t\t\tgetBlockEditingMode( _selectedBlockClientId ) === 'default',\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tsetIsCollapsed( false );\n\t}, [ selectedBlockClientId ] );\n\n\tconst isLargerThanTabletViewport = useViewportMatch( 'large', '>=' );\n\tconst isFullscreen =\n\t\tdocument.body.classList.contains( 'is-fullscreen-mode' );\n\n\tuseLayoutEffect( () => {\n\t\t// don't do anything if not fixed toolbar\n\t\tif ( ! isFixed || ! blockType ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst blockToolbar = document.querySelector(\n\t\t\t'.block-editor-block-contextual-toolbar'\n\t\t);\n\n\t\tif ( ! blockToolbar ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! isLargerThanTabletViewport ) {\n\t\t\t// set the width of the toolbar to auto\n\t\t\tblockToolbar.style = {};\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isCollapsed ) {\n\t\t\t// set the width of the toolbar to auto\n\t\t\tblockToolbar.style.width = 'auto';\n\t\t\treturn;\n\t\t}\n\n\t\t// get the width of the pinned items in the post editor\n\t\tconst pinnedItems = document.querySelector(\n\t\t\t'.edit-post-header__settings'\n\t\t);\n\n\t\t// get the width of the left header in the site editor\n\t\tconst leftHeader = document.querySelector(\n\t\t\t'.edit-site-header-edit-mode__end'\n\t\t);\n\n\t\tconst computedToolbarStyle = window.getComputedStyle( blockToolbar );\n\t\tconst computedPinnedItemsStyle = pinnedItems\n\t\t\t? window.getComputedStyle( pinnedItems )\n\t\t\t: false;\n\t\tconst computedLeftHeaderStyle = leftHeader\n\t\t\t? window.getComputedStyle( leftHeader )\n\t\t\t: false;\n\n\t\tconst marginLeft = parseFloat( computedToolbarStyle.marginLeft );\n\t\tconst pinnedItemsWidth = computedPinnedItemsStyle\n\t\t\t? parseFloat( computedPinnedItemsStyle.width ) + 10 // 10 is the pinned items padding\n\t\t\t: 0;\n\t\tconst leftHeaderWidth = computedLeftHeaderStyle\n\t\t\t? parseFloat( computedLeftHeaderStyle.width )\n\t\t\t: 0;\n\n\t\t// set the new witdth of the toolbar\n\t\tblockToolbar.style.width = `calc(100% - ${\n\t\t\tleftHeaderWidth +\n\t\t\tpinnedItemsWidth +\n\t\t\tmarginLeft +\n\t\t\t( isFullscreen ? 0 : 160 ) // the width of the admin sidebar expanded\n\t\t}px)`;\n\t}, [\n\t\tisFixed,\n\t\tisLargerThanTabletViewport,\n\t\tisCollapsed,\n\t\tisFullscreen,\n\t\tblockType,\n\t] );\n\n\tconst isToolbarEnabled =\n\t\t! blockType ||\n\t\thasBlockSupport( blockType, '__experimentalToolbar', true );\n\tconst hasAnyBlockControls = useHasAnyBlockControls();\n\tif (\n\t\t! isToolbarEnabled ||\n\t\t( blockEditingMode !== 'default' && ! hasAnyBlockControls )\n\t) {\n\t\treturn null;\n\t}\n\n\t// Shifts the toolbar to make room for the parent block selector.\n\tconst classes = classnames( 'block-editor-block-contextual-toolbar', {\n\t\t'has-parent': hasParents && showParentSelector,\n\t\t'is-fixed': isFixed,\n\t\t'is-collapsed': isCollapsed,\n\t} );\n\n\treturn (\n\t\t<NavigableToolbar\n\t\t\tfocusOnMount={ focusOnMount }\n\t\t\tclassName={ classes }\n\t\t\t/* translators: accessibility text for the block toolbar */\n\t\t\taria-label={ __( 'Block tools' ) }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ ! isCollapsed && <BlockToolbar hideDragHandle={ isFixed } /> }\n\t\t\t{ isFixed && isLargeViewport && blockType && (\n\t\t\t\t<ToolbarGroup\n\t\t\t\t\tclassName={\n\t\t\t\t\t\tisCollapsed\n\t\t\t\t\t\t\t? 'block-editor-block-toolbar__group-expand-fixed-toolbar'\n\t\t\t\t\t\t\t: 'block-editor-block-toolbar__group-collapse-fixed-toolbar'\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\tas={ ToolbarButton }\n\t\t\t\t\t\tref={ toolbarButtonRef }\n\t\t\t\t\t\ticon={ isCollapsed ? next : previous }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetIsCollapsed( ( collapsed ) => ! collapsed );\n\t\t\t\t\t\t\ttoolbarButtonRef.current.focus();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\tisCollapsed\n\t\t\t\t\t\t\t\t? __( 'Show block tools' )\n\t\t\t\t\t\t\t\t: __( 'Hide block tools' )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t) }\n\t\t</NavigableToolbar>\n\t);\n}\n\nexport default BlockContextualToolbar;\n"]}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
|
-
import { getComputedFluidTypographyValue } from '../font-sizes/fluid-utils';
|
|
10
|
+
import { getComputedFluidTypographyValue, getTypographyValueAndUnit } from '../font-sizes/fluid-utils';
|
|
11
11
|
/**
|
|
12
12
|
* @typedef {Object} FluidPreset
|
|
13
13
|
* @property {string|undefined} max A maximum font size value.
|
|
@@ -94,9 +94,10 @@ function isFluidTypographyEnabled(typographySettings) {
|
|
|
94
94
|
export function getFluidTypographyOptionsFromSettings(settings) {
|
|
95
95
|
const typographySettings = settings?.typography;
|
|
96
96
|
const layoutSettings = settings?.layout;
|
|
97
|
-
|
|
97
|
+
const defaultMaxViewportWidth = getTypographyValueAndUnit(layoutSettings?.wideSize) ? layoutSettings?.wideSize : null;
|
|
98
|
+
return isFluidTypographyEnabled(typographySettings) && defaultMaxViewportWidth ? {
|
|
98
99
|
fluid: {
|
|
99
|
-
maxViewPortWidth:
|
|
100
|
+
maxViewPortWidth: defaultMaxViewportWidth,
|
|
100
101
|
...typographySettings.fluid
|
|
101
102
|
}
|
|
102
103
|
} : {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/global-styles/typography-utils.js"],"names":["getComputedFluidTypographyValue","getTypographyFontSizeValue","preset","typographyOptions","size","defaultSize","isFluidTypographyEnabled","fluid","fluidTypographySettings","fluidFontSizeValue","minimumFontSize","min","maximumFontSize","max","fontSize","minimumFontSizeLimit","minFontSize","maximumViewPortWidth","maxViewPortWidth","typographySettings","fluidSettings","Object","keys","length","getFluidTypographyOptionsFromSettings","settings","typography","layoutSettings","layout","wideSize"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/global-styles/typography-utils.js"],"names":["getComputedFluidTypographyValue","getTypographyValueAndUnit","getTypographyFontSizeValue","preset","typographyOptions","size","defaultSize","isFluidTypographyEnabled","fluid","fluidTypographySettings","fluidFontSizeValue","minimumFontSize","min","maximumFontSize","max","fontSize","minimumFontSizeLimit","minFontSize","maximumViewPortWidth","maxViewPortWidth","typographySettings","fluidSettings","Object","keys","length","getFluidTypographyOptionsFromSettings","settings","typography","layoutSettings","layout","defaultMaxViewportWidth","wideSize"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SACCA,+BADD,EAECC,yBAFD,QAGO,2BAHP;AAKA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,0BAAT,CAAqCC,MAArC,EAA6CC,iBAA7C,EAAiE;AACvE,QAAM;AAAEC,IAAAA,IAAI,EAAEC;AAAR,MAAwBH,MAA9B;;AAEA,MAAK,CAAEI,wBAAwB,CAAEH,iBAAF,CAA/B,EAAuD;AACtD,WAAOE,WAAP;AACA;AACD;AACD;AACA;AACA;AACA;;;AACC,MAAK,CAAEA,WAAF,IAAiB,QAAQA,WAAzB,IAAwC,UAAUH,MAAM,EAAEK,KAA/D,EAAuE;AACtE,WAAOF,WAAP;AACA;;AAED,QAAMG,uBAAuB,GAC5B,OAAOL,iBAAiB,EAAEI,KAA1B,KAAoC,QAApC,GACGJ,iBAAiB,EAAEI,KADtB,GAEG,EAHJ;AAKA,QAAME,kBAAkB,GAAGV,+BAA+B,CAAE;AAC3DW,IAAAA,eAAe,EAAER,MAAM,EAAEK,KAAR,EAAeI,GAD2B;AAE3DC,IAAAA,eAAe,EAAEV,MAAM,EAAEK,KAAR,EAAeM,GAF2B;AAG3DC,IAAAA,QAAQ,EAAET,WAHiD;AAI3DU,IAAAA,oBAAoB,EAAEP,uBAAuB,EAAEQ,WAJY;AAK3DC,IAAAA,oBAAoB,EAAET,uBAAuB,EAAEU;AALY,GAAF,CAA1D;;AAQA,MAAK,CAAC,CAAET,kBAAR,EAA6B;AAC5B,WAAOA,kBAAP;AACA;;AAED,SAAOJ,WAAP;AACA;;AAED,SAASC,wBAAT,CAAmCa,kBAAnC,EAAwD;AACvD,QAAMC,aAAa,GAAGD,kBAAkB,EAAEZ,KAA1C;AACA,SACC,SAASa,aAAT,IACEA,aAAa,IACd,OAAOA,aAAP,KAAyB,QADxB,IAEDC,MAAM,CAACC,IAAP,CAAaF,aAAb,EAA6BG,MAA7B,GAAsC,CAJxC;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASC,qCAAT,CAAgDC,QAAhD,EAA2D;AACjE,QAAMN,kBAAkB,GAAGM,QAAQ,EAAEC,UAArC;AACA,QAAMC,cAAc,GAAGF,QAAQ,EAAEG,MAAjC;AACA,QAAMC,uBAAuB,GAAG7B,yBAAyB,CACxD2B,cAAc,EAAEG,QADwC,CAAzB,GAG7BH,cAAc,EAAEG,QAHa,GAI7B,IAJH;AAKA,SAAOxB,wBAAwB,CAAEa,kBAAF,CAAxB,IACNU,uBADM,GAEJ;AACAtB,IAAAA,KAAK,EAAE;AACNW,MAAAA,gBAAgB,EAAEW,uBADZ;AAEN,SAAGV,kBAAkB,CAACZ;AAFhB;AADP,GAFI,GAQJ;AACAA,IAAAA,KAAK,EAAEY,kBAAkB,EAAEZ;AAD3B,GARH;AAWA","sourcesContent":["/**\n * The fluid utilities must match the backend equivalent.\n * See: gutenberg_get_typography_font_size_value() in lib/block-supports/typography.php\n * ---------------------------------------------------------------\n */\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetComputedFluidTypographyValue,\n\tgetTypographyValueAndUnit,\n} from '../font-sizes/fluid-utils';\n\n/**\n * @typedef {Object} FluidPreset\n * @property {string|undefined} max A maximum font size value.\n * @property {?string|undefined} min A minimum font size value.\n */\n\n/**\n * @typedef {Object} Preset\n * @property {?string|?number} size A default font size.\n * @property {string} name A font size name, displayed in the UI.\n * @property {string} slug A font size slug\n * @property {boolean|FluidPreset|undefined} fluid Specifies the minimum and maximum font size value of a fluid font size.\n */\n\n/**\n * @typedef {Object} TypographySettings\n * @property {?string} minViewPortWidth Minimum viewport size from which type will have fluidity. Optional if size is specified.\n * @property {?string} maxViewPortWidth Maximum size up to which type will have fluidity. Optional if size is specified.\n * @property {?number} scaleFactor A scale factor to determine how fast a font scales within boundaries. Optional.\n * @property {?number} minFontSizeFactor How much to scale defaultFontSize by to derive minimumFontSize. Optional.\n * @property {?string} minFontSize The smallest a calculated font size may be. Optional.\n */\n\n/**\n * Returns a font-size value based on a given font-size preset.\n * Takes into account fluid typography parameters and attempts to return a css formula depending on available, valid values.\n *\n * @param {Preset} preset\n * @param {Object} typographyOptions\n * @param {boolean|TypographySettings} typographyOptions.fluid Whether fluid typography is enabled, and, optionally, fluid font size options.\n *\n * @return {string|*} A font-size value or the value of preset.size.\n */\nexport function getTypographyFontSizeValue( preset, typographyOptions ) {\n\tconst { size: defaultSize } = preset;\n\n\tif ( ! isFluidTypographyEnabled( typographyOptions ) ) {\n\t\treturn defaultSize;\n\t}\n\t/*\n\t * Checks whether a font size has explicitly bypassed fluid calculations.\n\t * Also catches falsy values and 0/'0'.\n\t * Fluid calculations cannot be performed on `0`.\n\t */\n\tif ( ! defaultSize || '0' === defaultSize || false === preset?.fluid ) {\n\t\treturn defaultSize;\n\t}\n\n\tconst fluidTypographySettings =\n\t\ttypeof typographyOptions?.fluid === 'object'\n\t\t\t? typographyOptions?.fluid\n\t\t\t: {};\n\n\tconst fluidFontSizeValue = getComputedFluidTypographyValue( {\n\t\tminimumFontSize: preset?.fluid?.min,\n\t\tmaximumFontSize: preset?.fluid?.max,\n\t\tfontSize: defaultSize,\n\t\tminimumFontSizeLimit: fluidTypographySettings?.minFontSize,\n\t\tmaximumViewPortWidth: fluidTypographySettings?.maxViewPortWidth,\n\t} );\n\n\tif ( !! fluidFontSizeValue ) {\n\t\treturn fluidFontSizeValue;\n\t}\n\n\treturn defaultSize;\n}\n\nfunction isFluidTypographyEnabled( typographySettings ) {\n\tconst fluidSettings = typographySettings?.fluid;\n\treturn (\n\t\ttrue === fluidSettings ||\n\t\t( fluidSettings &&\n\t\t\ttypeof fluidSettings === 'object' &&\n\t\t\tObject.keys( fluidSettings ).length > 0 )\n\t);\n}\n\n/**\n * Returns fluid typography settings from theme.json setting object.\n *\n * @param {Object} settings Theme.json settings\n * @param {Object} settings.typography Theme.json typography settings\n * @param {Object} settings.layout Theme.json layout settings\n * @return {TypographySettings} Fluid typography settings\n */\nexport function getFluidTypographyOptionsFromSettings( settings ) {\n\tconst typographySettings = settings?.typography;\n\tconst layoutSettings = settings?.layout;\n\tconst defaultMaxViewportWidth = getTypographyValueAndUnit(\n\t\tlayoutSettings?.wideSize\n\t)\n\t\t? layoutSettings?.wideSize\n\t\t: null;\n\treturn isFluidTypographyEnabled( typographySettings ) &&\n\t\tdefaultMaxViewportWidth\n\t\t? {\n\t\t\t\tfluid: {\n\t\t\t\t\tmaxViewPortWidth: defaultMaxViewportWidth,\n\t\t\t\t\t...typographySettings.fluid,\n\t\t\t\t},\n\t\t }\n\t\t: {\n\t\t\t\tfluid: typographySettings?.fluid,\n\t\t };\n}\n"]}
|
|
@@ -14,6 +14,8 @@ import { useRef, useState, useEffect } from '@wordpress/element';
|
|
|
14
14
|
import { focus } from '@wordpress/dom';
|
|
15
15
|
import { ENTER } from '@wordpress/keycodes';
|
|
16
16
|
import { isShallowEqualObjects } from '@wordpress/is-shallow-equal';
|
|
17
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
18
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
17
19
|
/**
|
|
18
20
|
* Internal dependencies
|
|
19
21
|
*/
|
|
@@ -103,6 +105,9 @@ import { DEFAULT_LINK_SETTINGS } from './constants';
|
|
|
103
105
|
*/
|
|
104
106
|
|
|
105
107
|
const noop = () => {};
|
|
108
|
+
|
|
109
|
+
const PREFERENCE_SCOPE = 'core/block-editor';
|
|
110
|
+
const PREFERENCE_KEY = 'linkControlSettingsDrawer';
|
|
106
111
|
/**
|
|
107
112
|
* Renders a link control. A link control is a controlled input which maintains
|
|
108
113
|
* a value associated with a link (HTML anchor element) and relevant settings
|
|
@@ -111,7 +116,6 @@ const noop = () => {};
|
|
|
111
116
|
* @param {WPLinkControlProps} props Component props.
|
|
112
117
|
*/
|
|
113
118
|
|
|
114
|
-
|
|
115
119
|
function LinkControl({
|
|
116
120
|
searchInputPlaceholder,
|
|
117
121
|
value,
|
|
@@ -137,6 +141,43 @@ function LinkControl({
|
|
|
137
141
|
withCreateSuggestion = true;
|
|
138
142
|
}
|
|
139
143
|
|
|
144
|
+
const [settingsOpen, setSettingsOpen] = useState(false);
|
|
145
|
+
const {
|
|
146
|
+
advancedSettingsPreference
|
|
147
|
+
} = useSelect(select => {
|
|
148
|
+
var _prefsStore$get;
|
|
149
|
+
|
|
150
|
+
const prefsStore = select(preferencesStore);
|
|
151
|
+
return {
|
|
152
|
+
advancedSettingsPreference: (_prefsStore$get = prefsStore.get(PREFERENCE_SCOPE, PREFERENCE_KEY)) !== null && _prefsStore$get !== void 0 ? _prefsStore$get : false
|
|
153
|
+
};
|
|
154
|
+
}, []);
|
|
155
|
+
const {
|
|
156
|
+
set: setPreference
|
|
157
|
+
} = useDispatch(preferencesStore);
|
|
158
|
+
/**
|
|
159
|
+
* Sets the open/closed state of the Advanced Settings Drawer,
|
|
160
|
+
* optionlly persisting the state to the user's preferences.
|
|
161
|
+
*
|
|
162
|
+
* Note that Block Editor components can be consumed by non-WordPress
|
|
163
|
+
* environments which may not have preferences setup.
|
|
164
|
+
* Therefore a local state is also used as a fallback.
|
|
165
|
+
*
|
|
166
|
+
* @param {boolean} prefVal the open/closed state of the Advanced Settings Drawer.
|
|
167
|
+
*/
|
|
168
|
+
|
|
169
|
+
const setSettingsOpenWithPreference = prefVal => {
|
|
170
|
+
if (setPreference) {
|
|
171
|
+
setPreference(PREFERENCE_SCOPE, PREFERENCE_KEY, prefVal);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
setSettingsOpen(prefVal);
|
|
175
|
+
}; // Block Editor components can be consumed by non-WordPress environments
|
|
176
|
+
// which may not have these preferences setup.
|
|
177
|
+
// Therefore a local state is used as a fallback.
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
const isSettingsOpen = advancedSettingsPreference || settingsOpen;
|
|
140
181
|
const isMounting = useRef(true);
|
|
141
182
|
const wrapperNode = useRef();
|
|
142
183
|
const textInputRef = useRef();
|
|
@@ -144,7 +185,6 @@ function LinkControl({
|
|
|
144
185
|
const settingsKeys = settings.map(({
|
|
145
186
|
id
|
|
146
187
|
}) => id);
|
|
147
|
-
const [settingsOpen, setSettingsOpen] = useState(false);
|
|
148
188
|
const [internalControlValue, setInternalControlValue, setInternalURLInputValue, setInternalTextInputValue, createSetInternalSettingValueHandler] = useInternalValue(value);
|
|
149
189
|
const valueHasChanges = value && !isShallowEqualObjects(internalControlValue, value);
|
|
150
190
|
const [isEditingLink, setIsEditingLink] = useState(forceIsEditingLink !== undefined ? forceIsEditingLink : !value || !value.url);
|
|
@@ -186,7 +226,6 @@ function LinkControl({
|
|
|
186
226
|
|
|
187
227
|
const stopEditing = () => {
|
|
188
228
|
isEndingEditWithFocus.current = !!wrapperNode.current?.contains(wrapperNode.current.ownerDocument.activeElement);
|
|
189
|
-
setSettingsOpen(false);
|
|
190
229
|
setIsEditingLink(false);
|
|
191
230
|
};
|
|
192
231
|
|
|
@@ -260,7 +299,6 @@ function LinkControl({
|
|
|
260
299
|
const currentUrlInputValue = propInputValue || internalControlValue?.url || '';
|
|
261
300
|
const currentInputIsEmpty = !currentUrlInputValue?.trim()?.length;
|
|
262
301
|
const shownUnlinkControl = onRemove && value && !isEditingLink && !isCreatingPage;
|
|
263
|
-
const showSettings = !!settings?.length && isEditingLink && hasLinkValue;
|
|
264
302
|
const showActions = isEditingLink && hasLinkValue; // Only show text control once a URL value has been committed
|
|
265
303
|
// and it isn't just empty whitespace.
|
|
266
304
|
// See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.
|
|
@@ -268,6 +306,7 @@ function LinkControl({
|
|
|
268
306
|
const showTextControl = hasLinkValue && hasTextControl;
|
|
269
307
|
const isEditing = (isEditingLink || !value) && !isCreatingPage;
|
|
270
308
|
const isDisabled = !valueHasChanges || currentInputIsEmpty;
|
|
309
|
+
const showSettings = !!settings?.length && isEditingLink && hasLinkValue;
|
|
271
310
|
return createElement("div", {
|
|
272
311
|
tabIndex: -1,
|
|
273
312
|
ref: wrapperNode,
|
|
@@ -319,8 +358,8 @@ function LinkControl({
|
|
|
319
358
|
}), showSettings && createElement("div", {
|
|
320
359
|
className: "block-editor-link-control__tools"
|
|
321
360
|
}, !currentInputIsEmpty && createElement(LinkControlSettingsDrawer, {
|
|
322
|
-
settingsOpen:
|
|
323
|
-
setSettingsOpen:
|
|
361
|
+
settingsOpen: isSettingsOpen,
|
|
362
|
+
setSettingsOpen: setSettingsOpenWithPreference
|
|
324
363
|
}, createElement(LinkSettings, {
|
|
325
364
|
value: internalControlValue,
|
|
326
365
|
settings: settings,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/index.js"],"names":["classnames","Button","Spinner","Notice","TextControl","__","useRef","useState","useEffect","focus","ENTER","isShallowEqualObjects","LinkControlSettingsDrawer","LinkControlSearchInput","LinkPreview","LinkSettings","useCreatePage","useInternalValue","ViewerFill","DEFAULT_LINK_SETTINGS","noop","LinkControl","searchInputPlaceholder","value","settings","onChange","onRemove","onCancel","noDirectEntry","showSuggestions","showInitialSuggestions","forceIsEditingLink","createSuggestion","withCreateSuggestion","inputValue","propInputValue","suggestionsQuery","noURLSuggestion","createSuggestionButtonText","hasRichPreviews","hasTextControl","renderControlBottom","undefined","isMounting","wrapperNode","textInputRef","isEndingEditWithFocus","settingsKeys","map","id","settingsOpen","setSettingsOpen","internalControlValue","setInternalControlValue","setInternalURLInputValue","setInternalTextInputValue","createSetInternalSettingValueHandler","valueHasChanges","isEditingLink","setIsEditingLink","url","createPage","isCreatingPage","errorMessage","current","nextFocusTarget","focusable","find","hasLinkValue","trim","length","stopEditing","contains","ownerDocument","activeElement","handleSelectSuggestion","updatedValue","nonSettingsChanges","Object","keys","reduce","acc","key","includes","title","handleSubmit","currentUrlInputValue","handleSubmitWithEnter","event","keyCode","currentInputIsEmpty","preventDefault","resetInternalValues","handleCancel","stopPropagation","shownUnlinkControl","showSettings","showActions","showTextControl","isEditing","isDisabled"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,EAAiBC,OAAjB,EAA0BC,MAA1B,EAAkCC,WAAlC,QAAqD,uBAArD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,EAAiBC,QAAjB,EAA2BC,SAA3B,QAA4C,oBAA5C;AACA,SAASC,KAAT,QAAsB,gBAAtB;AACA,SAASC,KAAT,QAAsB,qBAAtB;AACA,SAASC,qBAAT,QAAsC,6BAAtC;AAEA;AACA;AACA;;AACA,OAAOC,yBAAP,MAAsC,mBAAtC;AACA,OAAOC,sBAAP,MAAmC,gBAAnC;AACA,OAAOC,WAAP,MAAwB,gBAAxB;AACA,OAAOC,YAAP,MAAyB,YAAzB;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,OAAOC,gBAAP,MAA6B,sBAA7B;AACA,SAASC,UAAT,QAA2B,eAA3B;AACA,SAASC,qBAAT,QAAsC,aAAtC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AACA;AACA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;A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AAEA,eAAeG,WAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button, Spinner, Notice, TextControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useState, useEffect } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport { ENTER } from '@wordpress/keycodes';\nimport { isShallowEqualObjects } from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport LinkControlSettingsDrawer from './settings-drawer';\nimport LinkControlSearchInput from './search-input';\nimport LinkPreview from './link-preview';\nimport LinkSettings from './settings';\nimport useCreatePage from './use-create-page';\nimport useInternalValue from './use-internal-value';\nimport { ViewerFill } from './viewer-slot';\nimport { DEFAULT_LINK_SETTINGS } from './constants';\n\n/**\n * Default properties associated with a link control value.\n *\n * @typedef WPLinkControlDefaultValue\n *\n * @property {string} url Link URL.\n * @property {string=} title Link title.\n * @property {boolean=} opensInNewTab Whether link should open in a new browser\n * tab. This value is only assigned if not\n * providing a custom `settings` prop.\n */\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Custom settings values associated with a link.\n *\n * @typedef {{[setting:string]:any}} WPLinkControlSettingsValue\n */\n/* eslint-enable */\n\n/**\n * Custom settings values associated with a link.\n *\n * @typedef WPLinkControlSetting\n *\n * @property {string} id Identifier to use as property for setting value.\n * @property {string} title Human-readable label to show in user interface.\n */\n\n/**\n * Properties associated with a link control value, composed as a union of the\n * default properties and any custom settings values.\n *\n * @typedef {WPLinkControlDefaultValue&WPLinkControlSettingsValue} WPLinkControlValue\n */\n\n/** @typedef {(nextValue:WPLinkControlValue)=>void} WPLinkControlOnChangeProp */\n\n/**\n * Properties associated with a search suggestion used within the LinkControl.\n *\n * @typedef WPLinkControlSuggestion\n *\n * @property {string} id Identifier to use to uniquely identify the suggestion.\n * @property {string} type Identifies the type of the suggestion (eg: `post`,\n * `page`, `url`...etc)\n * @property {string} title Human-readable label to show in user interface.\n * @property {string} url A URL for the suggestion.\n */\n\n/** @typedef {(title:string)=>WPLinkControlSuggestion} WPLinkControlCreateSuggestionProp */\n\n/**\n * @typedef WPLinkControlProps\n *\n * @property {(WPLinkControlSetting[])=} settings An array of settings objects. Each object will used to\n * render a `ToggleControl` for that setting.\n * @property {boolean=} forceIsEditingLink If passed as either `true` or `false`, controls the\n * internal editing state of the component to respective\n * show or not show the URL input field.\n * @property {WPLinkControlValue=} value Current link value.\n * @property {WPLinkControlOnChangeProp=} onChange Value change handler, called with the updated value if\n * the user selects a new link or updates settings.\n * @property {boolean=} noDirectEntry Whether to allow turning a URL-like search query directly into a link.\n * @property {boolean=} showSuggestions Whether to present suggestions when typing the URL.\n * @property {boolean=} showInitialSuggestions Whether to present initial suggestions immediately.\n * @property {boolean=} withCreateSuggestion Whether to allow creation of link value from suggestion.\n * @property {Object=} suggestionsQuery Query parameters to pass along to wp.blockEditor.__experimentalFetchLinkSuggestions.\n * @property {boolean=} noURLSuggestion Whether to add a fallback suggestion which treats the search query as a URL.\n * @property {boolean=} hasTextControl Whether to add a text field to the UI to update the value.title.\n * @property {string|Function|undefined} createSuggestionButtonText The text to use in the button that calls createSuggestion.\n * @property {Function} renderControlBottom Optional controls to be rendered at the bottom of the component.\n */\n\nconst noop = () => {};\n\n/**\n * Renders a link control. A link control is a controlled input which maintains\n * a value associated with a link (HTML anchor element) and relevant settings\n * for how that link is expected to behave.\n *\n * @param {WPLinkControlProps} props Component props.\n */\nfunction LinkControl( {\n\tsearchInputPlaceholder,\n\tvalue,\n\tsettings = DEFAULT_LINK_SETTINGS,\n\tonChange = noop,\n\tonRemove,\n\tonCancel,\n\tnoDirectEntry = false,\n\tshowSuggestions = true,\n\tshowInitialSuggestions,\n\tforceIsEditingLink,\n\tcreateSuggestion,\n\twithCreateSuggestion,\n\tinputValue: propInputValue = '',\n\tsuggestionsQuery = {},\n\tnoURLSuggestion = false,\n\tcreateSuggestionButtonText,\n\thasRichPreviews = false,\n\thasTextControl = false,\n\trenderControlBottom = null,\n} ) {\n\tif ( withCreateSuggestion === undefined && createSuggestion ) {\n\t\twithCreateSuggestion = true;\n\t}\n\n\tconst isMounting = useRef( true );\n\tconst wrapperNode = useRef();\n\tconst textInputRef = useRef();\n\tconst isEndingEditWithFocus = useRef( false );\n\n\tconst settingsKeys = settings.map( ( { id } ) => id );\n\n\tconst [ settingsOpen, setSettingsOpen ] = useState( false );\n\n\tconst [\n\t\tinternalControlValue,\n\t\tsetInternalControlValue,\n\t\tsetInternalURLInputValue,\n\t\tsetInternalTextInputValue,\n\t\tcreateSetInternalSettingValueHandler,\n\t] = useInternalValue( value );\n\n\tconst valueHasChanges =\n\t\tvalue && ! isShallowEqualObjects( internalControlValue, value );\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState(\n\t\tforceIsEditingLink !== undefined\n\t\t\t? forceIsEditingLink\n\t\t\t: ! value || ! value.url\n\t);\n\n\tconst { createPage, isCreatingPage, errorMessage } =\n\t\tuseCreatePage( createSuggestion );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tforceIsEditingLink !== undefined &&\n\t\t\tforceIsEditingLink !== isEditingLink\n\t\t) {\n\t\t\tsetIsEditingLink( forceIsEditingLink );\n\t\t}\n\t\t// Todo: bug if the missing dep is introduced. Will need a fix.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ forceIsEditingLink ] );\n\n\tuseEffect( () => {\n\t\t// We don't auto focus into the Link UI on mount\n\t\t// because otherwise using the keyboard to select text\n\t\t// *within* the link format is not possible.\n\t\tif ( isMounting.current ) {\n\t\t\tisMounting.current = false;\n\t\t\treturn;\n\t\t}\n\n\t\t// Scenario - when:\n\t\t// - switching between editable and non editable LinkControl\n\t\t// - clicking on a link\n\t\t// ...then move focus to the *first* element to avoid focus loss\n\t\t// and to ensure focus is *within* the Link UI.\n\t\tconst nextFocusTarget =\n\t\t\tfocus.focusable.find( wrapperNode.current )[ 0 ] ||\n\t\t\twrapperNode.current;\n\n\t\tnextFocusTarget.focus();\n\n\t\tisEndingEditWithFocus.current = false;\n\t}, [ isEditingLink, isCreatingPage ] );\n\n\tconst hasLinkValue = value?.url?.trim()?.length > 0;\n\n\t/**\n\t * Cancels editing state and marks that focus may need to be restored after\n\t * the next render, if focus was within the wrapper when editing finished.\n\t */\n\tconst stopEditing = () => {\n\t\tisEndingEditWithFocus.current = !! wrapperNode.current?.contains(\n\t\t\twrapperNode.current.ownerDocument.activeElement\n\t\t);\n\n\t\tsetSettingsOpen( false );\n\t\tsetIsEditingLink( false );\n\t};\n\n\tconst handleSelectSuggestion = ( updatedValue ) => {\n\t\t// Suggestions may contains \"settings\" values (e.g. `opensInNewTab`)\n\t\t// which should not overide any existing settings values set by the\n\t\t// user. This filters out any settings values from the suggestion.\n\t\tconst nonSettingsChanges = Object.keys( updatedValue ).reduce(\n\t\t\t( acc, key ) => {\n\t\t\t\tif ( ! settingsKeys.includes( key ) ) {\n\t\t\t\t\tacc[ key ] = updatedValue[ key ];\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\tonChange( {\n\t\t\t...internalControlValue,\n\t\t\t...nonSettingsChanges,\n\t\t\t// As title is not a setting, it must be manually applied\n\t\t\t// in such a way as to preserve the users changes over\n\t\t\t// any \"title\" value provided by the \"suggestion\".\n\t\t\ttitle: internalControlValue?.title || updatedValue?.title,\n\t\t} );\n\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmit = () => {\n\t\tif ( valueHasChanges ) {\n\t\t\t// Submit the original value with new stored values applied\n\t\t\t// on top. URL is a special case as it may also be a prop.\n\t\t\tonChange( {\n\t\t\t\t...value,\n\t\t\t\t...internalControlValue,\n\t\t\t\turl: currentUrlInputValue,\n\t\t\t} );\n\t\t}\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmitWithEnter = ( event ) => {\n\t\tconst { keyCode } = event;\n\n\t\tif (\n\t\t\tkeyCode === ENTER &&\n\t\t\t! currentInputIsEmpty // Disallow submitting empty values.\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t\thandleSubmit();\n\t\t}\n\t};\n\n\tconst resetInternalValues = () => {\n\t\tsetInternalControlValue( value );\n\t};\n\n\tconst handleCancel = ( event ) => {\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\n\t\t// Ensure that any unsubmitted input changes are reset.\n\t\tresetInternalValues();\n\n\t\tif ( hasLinkValue ) {\n\t\t\t// If there is a link then exist editing mode and show preview.\n\t\t\tstopEditing();\n\t\t} else {\n\t\t\t// If there is no link value, then remove the link entirely.\n\t\t\tonRemove?.();\n\t\t}\n\n\t\tonCancel?.();\n\t};\n\n\tconst currentUrlInputValue =\n\t\tpropInputValue || internalControlValue?.url || '';\n\n\tconst currentInputIsEmpty = ! currentUrlInputValue?.trim()?.length;\n\n\tconst shownUnlinkControl =\n\t\tonRemove && value && ! isEditingLink && ! isCreatingPage;\n\n\tconst showSettings = !! settings?.length && isEditingLink && hasLinkValue;\n\tconst showActions = isEditingLink && hasLinkValue;\n\n\t// Only show text control once a URL value has been committed\n\t// and it isn't just empty whitespace.\n\t// See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.\n\tconst showTextControl = hasLinkValue && hasTextControl;\n\n\tconst isEditing = ( isEditingLink || ! value ) && ! isCreatingPage;\n\tconst isDisabled = ! valueHasChanges || currentInputIsEmpty;\n\n\treturn (\n\t\t<div\n\t\t\ttabIndex={ -1 }\n\t\t\tref={ wrapperNode }\n\t\t\tclassName=\"block-editor-link-control\"\n\t\t>\n\t\t\t{ isCreatingPage && (\n\t\t\t\t<div className=\"block-editor-link-control__loading\">\n\t\t\t\t\t<Spinner /> { __( 'Creating' ) }…\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ isEditing && (\n\t\t\t\t<>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames( {\n\t\t\t\t\t\t\t'block-editor-link-control__search-input-wrapper': true,\n\t\t\t\t\t\t\t'has-text-control': showTextControl,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ showTextControl && (\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\tref={ textInputRef }\n\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__text-content\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\t\t\t\t\tvalue={ internalControlValue?.title }\n\t\t\t\t\t\t\t\tonChange={ setInternalTextInputValue }\n\t\t\t\t\t\t\t\tonKeyDown={ handleSubmitWithEnter }\n\t\t\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<LinkControlSearchInput\n\t\t\t\t\t\t\tcurrentLink={ value }\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__search-input\"\n\t\t\t\t\t\t\tplaceholder={ searchInputPlaceholder }\n\t\t\t\t\t\t\tvalue={ currentUrlInputValue }\n\t\t\t\t\t\t\twithCreateSuggestion={ withCreateSuggestion }\n\t\t\t\t\t\t\tonCreateSuggestion={ createPage }\n\t\t\t\t\t\t\tonChange={ setInternalURLInputValue }\n\t\t\t\t\t\t\tonSelect={ handleSelectSuggestion }\n\t\t\t\t\t\t\tshowInitialSuggestions={ showInitialSuggestions }\n\t\t\t\t\t\t\tallowDirectEntry={ ! noDirectEntry }\n\t\t\t\t\t\t\tshowSuggestions={ showSuggestions }\n\t\t\t\t\t\t\tsuggestionsQuery={ suggestionsQuery }\n\t\t\t\t\t\t\twithURLSuggestion={ ! noURLSuggestion }\n\t\t\t\t\t\t\tcreateSuggestionButtonText={\n\t\t\t\t\t\t\t\tcreateSuggestionButtonText\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\thideLabelFromVision={ ! showTextControl }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t{ errorMessage && (\n\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-error\"\n\t\t\t\t\t\t\tstatus=\"error\"\n\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ errorMessage }\n\t\t\t\t\t\t</Notice>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ value && ! isEditingLink && ! isCreatingPage && (\n\t\t\t\t<LinkPreview\n\t\t\t\t\tkey={ value?.url } // force remount when URL changes to avoid race conditions for rich previews\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonEditClick={ () => setIsEditingLink( true ) }\n\t\t\t\t\thasRichPreviews={ hasRichPreviews }\n\t\t\t\t\thasUnlinkControl={ shownUnlinkControl }\n\t\t\t\t\tonRemove={ onRemove }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ showSettings && (\n\t\t\t\t<div className=\"block-editor-link-control__tools\">\n\t\t\t\t\t{ ! currentInputIsEmpty && (\n\t\t\t\t\t\t<LinkControlSettingsDrawer\n\t\t\t\t\t\t\tsettingsOpen={ settingsOpen }\n\t\t\t\t\t\t\tsetSettingsOpen={ setSettingsOpen }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<LinkSettings\n\t\t\t\t\t\t\t\tvalue={ internalControlValue }\n\t\t\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\t\t\tonChange={ createSetInternalSettingValueHandler(\n\t\t\t\t\t\t\t\t\tsettingsKeys\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</LinkControlSettingsDrawer>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ showActions && (\n\t\t\t\t<div className=\"block-editor-link-control__search-actions\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ isDisabled ? noop : handleSubmit }\n\t\t\t\t\t\tclassName=\"block-editor-link-control__search-submit\"\n\t\t\t\t\t\taria-disabled={ isDisabled }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button variant=\"tertiary\" onClick={ handleCancel }>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ renderControlBottom && renderControlBottom() }\n\t\t</div>\n\t);\n}\n\nLinkControl.ViewerFill = ViewerFill;\n\nexport default LinkControl;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/index.js"],"names":["classnames","Button","Spinner","Notice","TextControl","__","useRef","useState","useEffect","focus","ENTER","isShallowEqualObjects","useSelect","useDispatch","store","preferencesStore","LinkControlSettingsDrawer","LinkControlSearchInput","LinkPreview","LinkSettings","useCreatePage","useInternalValue","ViewerFill","DEFAULT_LINK_SETTINGS","noop","PREFERENCE_SCOPE","PREFERENCE_KEY","LinkControl","searchInputPlaceholder","value","settings","onChange","onRemove","onCancel","noDirectEntry","showSuggestions","showInitialSuggestions","forceIsEditingLink","createSuggestion","withCreateSuggestion","inputValue","propInputValue","suggestionsQuery","noURLSuggestion","createSuggestionButtonText","hasRichPreviews","hasTextControl","renderControlBottom","undefined","settingsOpen","setSettingsOpen","advancedSettingsPreference","select","prefsStore","get","set","setPreference","setSettingsOpenWithPreference","prefVal","isSettingsOpen","isMounting","wrapperNode","textInputRef","isEndingEditWithFocus","settingsKeys","map","id","internalControlValue","setInternalControlValue","setInternalURLInputValue","setInternalTextInputValue","createSetInternalSettingValueHandler","valueHasChanges","isEditingLink","setIsEditingLink","url","createPage","isCreatingPage","errorMessage","current","nextFocusTarget","focusable","find","hasLinkValue","trim","length","stopEditing","contains","ownerDocument","activeElement","handleSelectSuggestion","updatedValue","nonSettingsChanges","Object","keys","reduce","acc","key","includes","title","handleSubmit","currentUrlInputValue","handleSubmitWithEnter","event","keyCode","currentInputIsEmpty","preventDefault","resetInternalValues","handleCancel","stopPropagation","shownUnlinkControl","showActions","showTextControl","isEditing","isDisabled","showSettings"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,EAAiBC,OAAjB,EAA0BC,MAA1B,EAAkCC,WAAlC,QAAqD,uBAArD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,EAAiBC,QAAjB,EAA2BC,SAA3B,QAA4C,oBAA5C;AACA,SAASC,KAAT,QAAsB,gBAAtB;AACA,SAASC,KAAT,QAAsB,qBAAtB;AACA,SAASC,qBAAT,QAAsC,6BAAtC;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,wBAA1C;AAEA;AACA;AACA;;AACA,OAAOC,yBAAP,MAAsC,mBAAtC;AACA,OAAOC,sBAAP,MAAmC,gBAAnC;AACA,OAAOC,WAAP,MAAwB,gBAAxB;AACA,OAAOC,YAAP,MAAyB,YAAzB;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,OAAOC,gBAAP,MAA6B,sBAA7B;AACA,SAASC,UAAT,QAA2B,eAA3B;AACA,SAASC,qBAAT,QAAsC,aAAtC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AACA;AACA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,MAAMC,gBAAgB,GAAG,mBAAzB;AACA,MAAMC,c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EA6FG+C,WAAW,IACZ;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,OAAO,EAAGG,UAAU,GAAG1F,IAAH,GAAU4E,YAF/B;AAGC,IAAA,SAAS,EAAC,0CAHX;AAIC,qBAAgBc;AAJjB,KAMG7G,EAAE,CAAE,MAAF,CANL,CADD,EASC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,UAAhB;AAA2B,IAAA,OAAO,EAAGuG;AAArC,KACGvG,EAAE,CAAE,QAAF,CADL,CATD,CA9FF,EA6GG0C,mBAAmB,IAAIA,mBAAmB,EA7G7C,CADD;AAiHA;;AAEDpB,WAAW,CAACL,UAAZ,GAAyBA,UAAzB;AAEA,eAAeK,WAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button, Spinner, Notice, TextControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useState, useEffect } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport { ENTER } from '@wordpress/keycodes';\nimport { isShallowEqualObjects } from '@wordpress/is-shallow-equal';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport LinkControlSettingsDrawer from './settings-drawer';\nimport LinkControlSearchInput from './search-input';\nimport LinkPreview from './link-preview';\nimport LinkSettings from './settings';\nimport useCreatePage from './use-create-page';\nimport useInternalValue from './use-internal-value';\nimport { ViewerFill } from './viewer-slot';\nimport { DEFAULT_LINK_SETTINGS } from './constants';\n\n/**\n * Default properties associated with a link control value.\n *\n * @typedef WPLinkControlDefaultValue\n *\n * @property {string} url Link URL.\n * @property {string=} title Link title.\n * @property {boolean=} opensInNewTab Whether link should open in a new browser\n * tab. This value is only assigned if not\n * providing a custom `settings` prop.\n */\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Custom settings values associated with a link.\n *\n * @typedef {{[setting:string]:any}} WPLinkControlSettingsValue\n */\n/* eslint-enable */\n\n/**\n * Custom settings values associated with a link.\n *\n * @typedef WPLinkControlSetting\n *\n * @property {string} id Identifier to use as property for setting value.\n * @property {string} title Human-readable label to show in user interface.\n */\n\n/**\n * Properties associated with a link control value, composed as a union of the\n * default properties and any custom settings values.\n *\n * @typedef {WPLinkControlDefaultValue&WPLinkControlSettingsValue} WPLinkControlValue\n */\n\n/** @typedef {(nextValue:WPLinkControlValue)=>void} WPLinkControlOnChangeProp */\n\n/**\n * Properties associated with a search suggestion used within the LinkControl.\n *\n * @typedef WPLinkControlSuggestion\n *\n * @property {string} id Identifier to use to uniquely identify the suggestion.\n * @property {string} type Identifies the type of the suggestion (eg: `post`,\n * `page`, `url`...etc)\n * @property {string} title Human-readable label to show in user interface.\n * @property {string} url A URL for the suggestion.\n */\n\n/** @typedef {(title:string)=>WPLinkControlSuggestion} WPLinkControlCreateSuggestionProp */\n\n/**\n * @typedef WPLinkControlProps\n *\n * @property {(WPLinkControlSetting[])=} settings An array of settings objects. Each object will used to\n * render a `ToggleControl` for that setting.\n * @property {boolean=} forceIsEditingLink If passed as either `true` or `false`, controls the\n * internal editing state of the component to respective\n * show or not show the URL input field.\n * @property {WPLinkControlValue=} value Current link value.\n * @property {WPLinkControlOnChangeProp=} onChange Value change handler, called with the updated value if\n * the user selects a new link or updates settings.\n * @property {boolean=} noDirectEntry Whether to allow turning a URL-like search query directly into a link.\n * @property {boolean=} showSuggestions Whether to present suggestions when typing the URL.\n * @property {boolean=} showInitialSuggestions Whether to present initial suggestions immediately.\n * @property {boolean=} withCreateSuggestion Whether to allow creation of link value from suggestion.\n * @property {Object=} suggestionsQuery Query parameters to pass along to wp.blockEditor.__experimentalFetchLinkSuggestions.\n * @property {boolean=} noURLSuggestion Whether to add a fallback suggestion which treats the search query as a URL.\n * @property {boolean=} hasTextControl Whether to add a text field to the UI to update the value.title.\n * @property {string|Function|undefined} createSuggestionButtonText The text to use in the button that calls createSuggestion.\n * @property {Function} renderControlBottom Optional controls to be rendered at the bottom of the component.\n */\n\nconst noop = () => {};\n\nconst PREFERENCE_SCOPE = 'core/block-editor';\nconst PREFERENCE_KEY = 'linkControlSettingsDrawer';\n\n/**\n * Renders a link control. A link control is a controlled input which maintains\n * a value associated with a link (HTML anchor element) and relevant settings\n * for how that link is expected to behave.\n *\n * @param {WPLinkControlProps} props Component props.\n */\nfunction LinkControl( {\n\tsearchInputPlaceholder,\n\tvalue,\n\tsettings = DEFAULT_LINK_SETTINGS,\n\tonChange = noop,\n\tonRemove,\n\tonCancel,\n\tnoDirectEntry = false,\n\tshowSuggestions = true,\n\tshowInitialSuggestions,\n\tforceIsEditingLink,\n\tcreateSuggestion,\n\twithCreateSuggestion,\n\tinputValue: propInputValue = '',\n\tsuggestionsQuery = {},\n\tnoURLSuggestion = false,\n\tcreateSuggestionButtonText,\n\thasRichPreviews = false,\n\thasTextControl = false,\n\trenderControlBottom = null,\n} ) {\n\tif ( withCreateSuggestion === undefined && createSuggestion ) {\n\t\twithCreateSuggestion = true;\n\t}\n\n\tconst [ settingsOpen, setSettingsOpen ] = useState( false );\n\n\tconst { advancedSettingsPreference } = useSelect( ( select ) => {\n\t\tconst prefsStore = select( preferencesStore );\n\n\t\treturn {\n\t\t\tadvancedSettingsPreference:\n\t\t\t\tprefsStore.get( PREFERENCE_SCOPE, PREFERENCE_KEY ) ?? false,\n\t\t};\n\t}, [] );\n\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\n\t/**\n\t * Sets the open/closed state of the Advanced Settings Drawer,\n\t * optionlly persisting the state to the user's preferences.\n\t *\n\t * Note that Block Editor components can be consumed by non-WordPress\n\t * environments which may not have preferences setup.\n\t * Therefore a local state is also used as a fallback.\n\t *\n\t * @param {boolean} prefVal the open/closed state of the Advanced Settings Drawer.\n\t */\n\tconst setSettingsOpenWithPreference = ( prefVal ) => {\n\t\tif ( setPreference ) {\n\t\t\tsetPreference( PREFERENCE_SCOPE, PREFERENCE_KEY, prefVal );\n\t\t}\n\t\tsetSettingsOpen( prefVal );\n\t};\n\n\t// Block Editor components can be consumed by non-WordPress environments\n\t// which may not have these preferences setup.\n\t// Therefore a local state is used as a fallback.\n\tconst isSettingsOpen = advancedSettingsPreference || settingsOpen;\n\n\tconst isMounting = useRef( true );\n\tconst wrapperNode = useRef();\n\tconst textInputRef = useRef();\n\tconst isEndingEditWithFocus = useRef( false );\n\n\tconst settingsKeys = settings.map( ( { id } ) => id );\n\n\tconst [\n\t\tinternalControlValue,\n\t\tsetInternalControlValue,\n\t\tsetInternalURLInputValue,\n\t\tsetInternalTextInputValue,\n\t\tcreateSetInternalSettingValueHandler,\n\t] = useInternalValue( value );\n\n\tconst valueHasChanges =\n\t\tvalue && ! isShallowEqualObjects( internalControlValue, value );\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState(\n\t\tforceIsEditingLink !== undefined\n\t\t\t? forceIsEditingLink\n\t\t\t: ! value || ! value.url\n\t);\n\n\tconst { createPage, isCreatingPage, errorMessage } =\n\t\tuseCreatePage( createSuggestion );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tforceIsEditingLink !== undefined &&\n\t\t\tforceIsEditingLink !== isEditingLink\n\t\t) {\n\t\t\tsetIsEditingLink( forceIsEditingLink );\n\t\t}\n\t\t// Todo: bug if the missing dep is introduced. Will need a fix.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ forceIsEditingLink ] );\n\n\tuseEffect( () => {\n\t\t// We don't auto focus into the Link UI on mount\n\t\t// because otherwise using the keyboard to select text\n\t\t// *within* the link format is not possible.\n\t\tif ( isMounting.current ) {\n\t\t\tisMounting.current = false;\n\t\t\treturn;\n\t\t}\n\n\t\t// Scenario - when:\n\t\t// - switching between editable and non editable LinkControl\n\t\t// - clicking on a link\n\t\t// ...then move focus to the *first* element to avoid focus loss\n\t\t// and to ensure focus is *within* the Link UI.\n\t\tconst nextFocusTarget =\n\t\t\tfocus.focusable.find( wrapperNode.current )[ 0 ] ||\n\t\t\twrapperNode.current;\n\n\t\tnextFocusTarget.focus();\n\n\t\tisEndingEditWithFocus.current = false;\n\t}, [ isEditingLink, isCreatingPage ] );\n\n\tconst hasLinkValue = value?.url?.trim()?.length > 0;\n\n\t/**\n\t * Cancels editing state and marks that focus may need to be restored after\n\t * the next render, if focus was within the wrapper when editing finished.\n\t */\n\tconst stopEditing = () => {\n\t\tisEndingEditWithFocus.current = !! wrapperNode.current?.contains(\n\t\t\twrapperNode.current.ownerDocument.activeElement\n\t\t);\n\n\t\tsetIsEditingLink( false );\n\t};\n\n\tconst handleSelectSuggestion = ( updatedValue ) => {\n\t\t// Suggestions may contains \"settings\" values (e.g. `opensInNewTab`)\n\t\t// which should not overide any existing settings values set by the\n\t\t// user. This filters out any settings values from the suggestion.\n\t\tconst nonSettingsChanges = Object.keys( updatedValue ).reduce(\n\t\t\t( acc, key ) => {\n\t\t\t\tif ( ! settingsKeys.includes( key ) ) {\n\t\t\t\t\tacc[ key ] = updatedValue[ key ];\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\tonChange( {\n\t\t\t...internalControlValue,\n\t\t\t...nonSettingsChanges,\n\t\t\t// As title is not a setting, it must be manually applied\n\t\t\t// in such a way as to preserve the users changes over\n\t\t\t// any \"title\" value provided by the \"suggestion\".\n\t\t\ttitle: internalControlValue?.title || updatedValue?.title,\n\t\t} );\n\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmit = () => {\n\t\tif ( valueHasChanges ) {\n\t\t\t// Submit the original value with new stored values applied\n\t\t\t// on top. URL is a special case as it may also be a prop.\n\t\t\tonChange( {\n\t\t\t\t...value,\n\t\t\t\t...internalControlValue,\n\t\t\t\turl: currentUrlInputValue,\n\t\t\t} );\n\t\t}\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmitWithEnter = ( event ) => {\n\t\tconst { keyCode } = event;\n\n\t\tif (\n\t\t\tkeyCode === ENTER &&\n\t\t\t! currentInputIsEmpty // Disallow submitting empty values.\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t\thandleSubmit();\n\t\t}\n\t};\n\n\tconst resetInternalValues = () => {\n\t\tsetInternalControlValue( value );\n\t};\n\n\tconst handleCancel = ( event ) => {\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\n\t\t// Ensure that any unsubmitted input changes are reset.\n\t\tresetInternalValues();\n\n\t\tif ( hasLinkValue ) {\n\t\t\t// If there is a link then exist editing mode and show preview.\n\t\t\tstopEditing();\n\t\t} else {\n\t\t\t// If there is no link value, then remove the link entirely.\n\t\t\tonRemove?.();\n\t\t}\n\n\t\tonCancel?.();\n\t};\n\n\tconst currentUrlInputValue =\n\t\tpropInputValue || internalControlValue?.url || '';\n\n\tconst currentInputIsEmpty = ! currentUrlInputValue?.trim()?.length;\n\n\tconst shownUnlinkControl =\n\t\tonRemove && value && ! isEditingLink && ! isCreatingPage;\n\n\tconst showActions = isEditingLink && hasLinkValue;\n\n\t// Only show text control once a URL value has been committed\n\t// and it isn't just empty whitespace.\n\t// See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.\n\tconst showTextControl = hasLinkValue && hasTextControl;\n\n\tconst isEditing = ( isEditingLink || ! value ) && ! isCreatingPage;\n\tconst isDisabled = ! valueHasChanges || currentInputIsEmpty;\n\tconst showSettings = !! settings?.length && isEditingLink && hasLinkValue;\n\n\treturn (\n\t\t<div\n\t\t\ttabIndex={ -1 }\n\t\t\tref={ wrapperNode }\n\t\t\tclassName=\"block-editor-link-control\"\n\t\t>\n\t\t\t{ isCreatingPage && (\n\t\t\t\t<div className=\"block-editor-link-control__loading\">\n\t\t\t\t\t<Spinner /> { __( 'Creating' ) }…\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ isEditing && (\n\t\t\t\t<>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames( {\n\t\t\t\t\t\t\t'block-editor-link-control__search-input-wrapper': true,\n\t\t\t\t\t\t\t'has-text-control': showTextControl,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ showTextControl && (\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\tref={ textInputRef }\n\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__text-content\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\t\t\t\t\tvalue={ internalControlValue?.title }\n\t\t\t\t\t\t\t\tonChange={ setInternalTextInputValue }\n\t\t\t\t\t\t\t\tonKeyDown={ handleSubmitWithEnter }\n\t\t\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<LinkControlSearchInput\n\t\t\t\t\t\t\tcurrentLink={ value }\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__search-input\"\n\t\t\t\t\t\t\tplaceholder={ searchInputPlaceholder }\n\t\t\t\t\t\t\tvalue={ currentUrlInputValue }\n\t\t\t\t\t\t\twithCreateSuggestion={ withCreateSuggestion }\n\t\t\t\t\t\t\tonCreateSuggestion={ createPage }\n\t\t\t\t\t\t\tonChange={ setInternalURLInputValue }\n\t\t\t\t\t\t\tonSelect={ handleSelectSuggestion }\n\t\t\t\t\t\t\tshowInitialSuggestions={ showInitialSuggestions }\n\t\t\t\t\t\t\tallowDirectEntry={ ! noDirectEntry }\n\t\t\t\t\t\t\tshowSuggestions={ showSuggestions }\n\t\t\t\t\t\t\tsuggestionsQuery={ suggestionsQuery }\n\t\t\t\t\t\t\twithURLSuggestion={ ! noURLSuggestion }\n\t\t\t\t\t\t\tcreateSuggestionButtonText={\n\t\t\t\t\t\t\t\tcreateSuggestionButtonText\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\thideLabelFromVision={ ! showTextControl }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t{ errorMessage && (\n\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-error\"\n\t\t\t\t\t\t\tstatus=\"error\"\n\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ errorMessage }\n\t\t\t\t\t\t</Notice>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ value && ! isEditingLink && ! isCreatingPage && (\n\t\t\t\t<LinkPreview\n\t\t\t\t\tkey={ value?.url } // force remount when URL changes to avoid race conditions for rich previews\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonEditClick={ () => setIsEditingLink( true ) }\n\t\t\t\t\thasRichPreviews={ hasRichPreviews }\n\t\t\t\t\thasUnlinkControl={ shownUnlinkControl }\n\t\t\t\t\tonRemove={ onRemove }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ showSettings && (\n\t\t\t\t<div className=\"block-editor-link-control__tools\">\n\t\t\t\t\t{ ! currentInputIsEmpty && (\n\t\t\t\t\t\t<LinkControlSettingsDrawer\n\t\t\t\t\t\t\tsettingsOpen={ isSettingsOpen }\n\t\t\t\t\t\t\tsetSettingsOpen={ setSettingsOpenWithPreference }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<LinkSettings\n\t\t\t\t\t\t\t\tvalue={ internalControlValue }\n\t\t\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\t\t\tonChange={ createSetInternalSettingValueHandler(\n\t\t\t\t\t\t\t\t\tsettingsKeys\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</LinkControlSettingsDrawer>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ showActions && (\n\t\t\t\t<div className=\"block-editor-link-control__search-actions\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ isDisabled ? noop : handleSubmit }\n\t\t\t\t\t\tclassName=\"block-editor-link-control__search-submit\"\n\t\t\t\t\t\taria-disabled={ isDisabled }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button variant=\"tertiary\" onClick={ handleCancel }>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ renderControlBottom && renderControlBottom() }\n\t\t</div>\n\t);\n}\n\nLinkControl.ViewerFill = ViewerFill;\n\nexport default LinkControl;\n"]}
|
|
@@ -53,19 +53,20 @@ export function useFormatTypes({
|
|
|
53
53
|
const formatTypes = useMemo(() => {
|
|
54
54
|
return allFormatTypes.filter(({
|
|
55
55
|
name,
|
|
56
|
+
interactive,
|
|
56
57
|
tagName
|
|
57
58
|
}) => {
|
|
58
59
|
if (allowedFormats && !allowedFormats.includes(name)) {
|
|
59
60
|
return false;
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
if (withoutInteractiveFormatting && interactiveContentTags.has(tagName)) {
|
|
63
|
+
if (withoutInteractiveFormatting && (interactive || interactiveContentTags.has(tagName))) {
|
|
63
64
|
return false;
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
return true;
|
|
67
68
|
});
|
|
68
|
-
}, [allFormatTypes, allowedFormats,
|
|
69
|
+
}, [allFormatTypes, allowedFormats, withoutInteractiveFormatting]);
|
|
69
70
|
const keyedSelected = useSelect(select => formatTypes.reduce((accumulator, type) => {
|
|
70
71
|
if (!type.__experimentalGetPropsForEditableTreePreparation) {
|
|
71
72
|
return accumulator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/use-format-types.js"],"names":["useMemo","useSelect","useDispatch","store","richTextStore","formatTypesSelector","select","getFormatTypes","interactiveContentTags","Set","prefixSelectKeys","selected","prefix","Object","fromEntries","entries","map","key","value","getPrefixedSelectKeys","keys","filter","startsWith","reduce","accumulator","slice","length","useFormatTypes","clientId","identifier","withoutInteractiveFormatting","allowedFormats","allFormatTypes","formatTypes","name","tagName","includes","has","keyedSelected","type","__experimentalGetPropsForEditableTreePreparation","richTextIdentifier","blockClientId","dispatch","prepareHandlers","valueHandlers","changeHandlers","dependencies","push","forEach","__experimentalCreatePrepareEditableTree","handler","__experimentalCreateOnChangeEditableValue","dispatchers","__experimentalGetPropsForEditableTreeChangeHandler"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,sBAAvC;;AAEA,SAASC,mBAAT,CAA8BC,MAA9B,EAAuC;AACtC,SAAOA,MAAM,CAAEF,aAAF,CAAN,CAAwBG,cAAxB,EAAP;AACA;AAED;AACA;AACA;AACA;AACA;;;AACA,MAAMC,sBAAsB,GAAG,IAAIC,GAAJ,CAAS,CACvC,GADuC,EAEvC,OAFuC,EAGvC,QAHuC,EAIvC,SAJuC,EAKvC,OALuC,EAMvC,QANuC,EAOvC,OAPuC,EAQvC,OARuC,EASvC,QATuC,EAUvC,UAVuC,EAWvC,OAXuC,CAAT,CAA/B;;AAcA,SAASC,gBAAT,CAA2BC,QAA3B,EAAqCC,MAArC,EAA8C;AAC7C,MAAK,OAAOD,QAAP,KAAoB,QAAzB,EAAoC,OAAO;AAAE,KAAEC,MAAF,GAAYD;AAAd,GAAP;AACpC,SAAOE,MAAM,CAACC,WAAP,CACND,MAAM,CAACE,OAAP,CAAgBJ,QAAhB,EAA2BK,GAA3B,CAAgC,CAAE,CAAEC,GAAF,EAAOC,KAAP,CAAF,KAAsB,CACpD,GAAGN,MAAQ,IAAIK,GAAK,EADgC,EAErDC,KAFqD,CAAtD,CADM,CAAP;AAMA;;AAED,SAASC,qBAAT,CAAgCR,QAAhC,EAA0CC,MAA1C,EAAmD;AAClD,MAAKD,QAAQ,CAAEC,MAAF,CAAb,EAA0B,OAAOD,QAAQ,CAAEC,MAAF,CAAf;AAC1B,SAAOC,MAAM,CAACO,IAAP,CAAaT,QAAb,EACLU,MADK,CACKJ,GAAF,IAAWA,GAAG,CAACK,UAAJ,CAAgBV,MAAM,GAAG,GAAzB,CADd,EAELW,MAFK,CAEG,CAAEC,WAAF,EAAeP,GAAf,KAAwB;AAChCO,IAAAA,WAAW,CAAEP,GAAG,CAACQ,KAAJ,CAAWb,MAAM,CAACc,MAAP,GAAgB,CAA3B,CAAF,CAAX,GAAgDf,QAAQ,CAAEM,GAAF,CAAxD;AACA,WAAOO,WAAP;AACA,GALK,EAKH,EALG,CAAP;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASG,cAAT,CAAyB;AAC/BC,EAAAA,QAD+B;AAE/BC,EAAAA,UAF+B;AAG/BC,EAAAA,4BAH+B;AAI/BC,EAAAA;AAJ+B,CAAzB,EAKH;AACH,QAAMC,cAAc,GAAG/B,SAAS,CAAEI,mBAAF,EAAuB,EAAvB,CAAhC;AACA,QAAM4B,WAAW,GAAGjC,OAAO,CAAE,MAAM;AAClC,WAAOgC,cAAc,CAACX,MAAf,CAAuB,CAAE;AAAEa,MAAAA,IAAF;AAAQC,MAAAA;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/use-format-types.js"],"names":["useMemo","useSelect","useDispatch","store","richTextStore","formatTypesSelector","select","getFormatTypes","interactiveContentTags","Set","prefixSelectKeys","selected","prefix","Object","fromEntries","entries","map","key","value","getPrefixedSelectKeys","keys","filter","startsWith","reduce","accumulator","slice","length","useFormatTypes","clientId","identifier","withoutInteractiveFormatting","allowedFormats","allFormatTypes","formatTypes","name","interactive","tagName","includes","has","keyedSelected","type","__experimentalGetPropsForEditableTreePreparation","richTextIdentifier","blockClientId","dispatch","prepareHandlers","valueHandlers","changeHandlers","dependencies","push","forEach","__experimentalCreatePrepareEditableTree","handler","__experimentalCreateOnChangeEditableValue","dispatchers","__experimentalGetPropsForEditableTreeChangeHandler"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,sBAAvC;;AAEA,SAASC,mBAAT,CAA8BC,MAA9B,EAAuC;AACtC,SAAOA,MAAM,CAAEF,aAAF,CAAN,CAAwBG,cAAxB,EAAP;AACA;AAED;AACA;AACA;AACA;AACA;;;AACA,MAAMC,sBAAsB,GAAG,IAAIC,GAAJ,CAAS,CACvC,GADuC,EAEvC,OAFuC,EAGvC,QAHuC,EAIvC,SAJuC,EAKvC,OALuC,EAMvC,QANuC,EAOvC,OAPuC,EAQvC,OARuC,EASvC,QATuC,EAUvC,UAVuC,EAWvC,OAXuC,CAAT,CAA/B;;AAcA,SAASC,gBAAT,CAA2BC,QAA3B,EAAqCC,MAArC,EAA8C;AAC7C,MAAK,OAAOD,QAAP,KAAoB,QAAzB,EAAoC,OAAO;AAAE,KAAEC,MAAF,GAAYD;AAAd,GAAP;AACpC,SAAOE,MAAM,CAACC,WAAP,CACND,MAAM,CAACE,OAAP,CAAgBJ,QAAhB,EAA2BK,GAA3B,CAAgC,CAAE,CAAEC,GAAF,EAAOC,KAAP,CAAF,KAAsB,CACpD,GAAGN,MAAQ,IAAIK,GAAK,EADgC,EAErDC,KAFqD,CAAtD,CADM,CAAP;AAMA;;AAED,SAASC,qBAAT,CAAgCR,QAAhC,EAA0CC,MAA1C,EAAmD;AAClD,MAAKD,QAAQ,CAAEC,MAAF,CAAb,EAA0B,OAAOD,QAAQ,CAAEC,MAAF,CAAf;AAC1B,SAAOC,MAAM,CAACO,IAAP,CAAaT,QAAb,EACLU,MADK,CACKJ,GAAF,IAAWA,GAAG,CAACK,UAAJ,CAAgBV,MAAM,GAAG,GAAzB,CADd,EAELW,MAFK,CAEG,CAAEC,WAAF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a,EAAEf;AAFhB,SAFD,CADD;AAQA;;AAED,YAAMjB,QAAQ,GAAGQ,qBAAqB,CAAEoB,aAAF,EAAiBC,IAAI,CAACN,IAAtB,CAAtC;AACAa,MAAAA,cAAc,CAACE,IAAf,CACCT,IAAI,CAACa,yCAAL,CACC,EACC,IAAK,OAAO1C,QAAP,KAAoB,QAApB,GAA+BA,QAA/B,GAA0C,EAA/C,CADD;AAEC,WAAG2C;AAFJ,OADD,EAKC;AACCZ,QAAAA,kBAAkB,EAAEb,UADrB;AAECc,QAAAA,aAAa,EAAEf;AAFhB,OALD,CADD;AAYA;AACD,GA7CD;AA+CA,SAAO;AACNK,IAAAA,WADM;AAENY,IAAAA,eAFM;AAGNC,IAAAA,aAHM;AAINC,IAAAA,cAJM;AAKNC,IAAAA;AALM,GAAP;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as richTextStore } from '@wordpress/rich-text';\n\nfunction formatTypesSelector( select ) {\n\treturn select( richTextStore ).getFormatTypes();\n}\n\n/**\n * Set of all interactive content tags.\n *\n * @see https://html.spec.whatwg.org/multipage/dom.html#interactive-content\n */\nconst interactiveContentTags = new Set( [\n\t'a',\n\t'audio',\n\t'button',\n\t'details',\n\t'embed',\n\t'iframe',\n\t'input',\n\t'label',\n\t'select',\n\t'textarea',\n\t'video',\n] );\n\nfunction prefixSelectKeys( selected, prefix ) {\n\tif ( typeof selected !== 'object' ) return { [ prefix ]: selected };\n\treturn Object.fromEntries(\n\t\tObject.entries( selected ).map( ( [ key, value ] ) => [\n\t\t\t`${ prefix }.${ key }`,\n\t\t\tvalue,\n\t\t] )\n\t);\n}\n\nfunction getPrefixedSelectKeys( selected, prefix ) {\n\tif ( selected[ prefix ] ) return selected[ prefix ];\n\treturn Object.keys( selected )\n\t\t.filter( ( key ) => key.startsWith( prefix + '.' ) )\n\t\t.reduce( ( accumulator, key ) => {\n\t\t\taccumulator[ key.slice( prefix.length + 1 ) ] = selected[ key ];\n\t\t\treturn accumulator;\n\t\t}, {} );\n}\n\n/**\n * This hook provides RichText with the `formatTypes` and its derived props from\n * experimental format type settings.\n *\n * @param {Object} $0 Options\n * @param {string} $0.clientId Block client ID.\n * @param {string} $0.identifier Block attribute.\n * @param {boolean} $0.withoutInteractiveFormatting Whether to clean the interactive formattings or not.\n * @param {Array} $0.allowedFormats Allowed formats\n */\nexport function useFormatTypes( {\n\tclientId,\n\tidentifier,\n\twithoutInteractiveFormatting,\n\tallowedFormats,\n} ) {\n\tconst allFormatTypes = useSelect( formatTypesSelector, [] );\n\tconst formatTypes = useMemo( () => {\n\t\treturn allFormatTypes.filter( ( { name, interactive, tagName } ) => {\n\t\t\tif ( allowedFormats && ! allowedFormats.includes( name ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\twithoutInteractiveFormatting &&\n\t\t\t\t( interactive || interactiveContentTags.has( tagName ) )\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t} );\n\t}, [ allFormatTypes, allowedFormats, withoutInteractiveFormatting ] );\n\tconst keyedSelected = useSelect(\n\t\t( select ) =>\n\t\t\tformatTypes.reduce( ( accumulator, type ) => {\n\t\t\t\tif ( ! type.__experimentalGetPropsForEditableTreePreparation ) {\n\t\t\t\t\treturn accumulator;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...accumulator,\n\t\t\t\t\t...prefixSelectKeys(\n\t\t\t\t\t\ttype.__experimentalGetPropsForEditableTreePreparation(\n\t\t\t\t\t\t\tselect,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t),\n\t\t\t\t\t\ttype.name\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t}, {} ),\n\t\t[ formatTypes, clientId, identifier ]\n\t);\n\tconst dispatch = useDispatch();\n\tconst prepareHandlers = [];\n\tconst valueHandlers = [];\n\tconst changeHandlers = [];\n\tconst dependencies = [];\n\n\tfor ( const key in keyedSelected ) {\n\t\tdependencies.push( keyedSelected[ key ] );\n\t}\n\n\tformatTypes.forEach( ( type ) => {\n\t\tif ( type.__experimentalCreatePrepareEditableTree ) {\n\t\t\tconst handler = type.__experimentalCreatePrepareEditableTree(\n\t\t\t\tgetPrefixedSelectKeys( keyedSelected, type.name ),\n\t\t\t\t{\n\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( type.__experimentalCreateOnChangeEditableValue ) {\n\t\t\t\tvalueHandlers.push( handler );\n\t\t\t} else {\n\t\t\t\tprepareHandlers.push( handler );\n\t\t\t}\n\t\t}\n\n\t\tif ( type.__experimentalCreateOnChangeEditableValue ) {\n\t\t\tlet dispatchers = {};\n\n\t\t\tif ( type.__experimentalGetPropsForEditableTreeChangeHandler ) {\n\t\t\t\tdispatchers =\n\t\t\t\t\ttype.__experimentalGetPropsForEditableTreeChangeHandler(\n\t\t\t\t\t\tdispatch,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst selected = getPrefixedSelectKeys( keyedSelected, type.name );\n\t\t\tchangeHandlers.push(\n\t\t\t\ttype.__experimentalCreateOnChangeEditableValue(\n\t\t\t\t\t{\n\t\t\t\t\t\t...( typeof selected === 'object' ? selected : {} ),\n\t\t\t\t\t\t...dispatchers,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t} );\n\n\treturn {\n\t\tformatTypes,\n\t\tprepareHandlers,\n\t\tvalueHandlers,\n\t\tchangeHandlers,\n\t\tdependencies,\n\t};\n}\n"]}
|
|
@@ -181,12 +181,12 @@
|
|
|
181
181
|
box-shadow: none;
|
|
182
182
|
}
|
|
183
183
|
.block-editor-block-list__layout .block-editor-block-list__block.is-highlighted,
|
|
184
|
-
.block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected, .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected,
|
|
184
|
+
.block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected, .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected,
|
|
185
185
|
.block-editor-block-list__layout .block-editor-block-list__block:not([contenteditable]):focus {
|
|
186
186
|
outline: none;
|
|
187
187
|
}
|
|
188
188
|
.block-editor-block-list__layout .block-editor-block-list__block.is-highlighted::after,
|
|
189
|
-
.block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected::after, .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected::after,
|
|
189
|
+
.block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected::after, .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected::after,
|
|
190
190
|
.block-editor-block-list__layout .block-editor-block-list__block:not([contenteditable]):focus::after {
|
|
191
191
|
content: "";
|
|
192
192
|
position: absolute;
|
|
@@ -201,14 +201,10 @@
|
|
|
201
201
|
outline: 2px solid transparent;
|
|
202
202
|
}
|
|
203
203
|
.is-dark-theme .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted::after,
|
|
204
|
-
.is-dark-theme .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected::after, .is-dark-theme .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected::after,
|
|
204
|
+
.is-dark-theme .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected::after, .is-dark-theme .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected::after,
|
|
205
205
|
.is-dark-theme .block-editor-block-list__layout .block-editor-block-list__block:not([contenteditable]):focus::after {
|
|
206
206
|
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) #fff;
|
|
207
207
|
}
|
|
208
|
-
.block-editor-block-list__layout .is-block-moving-mode.block-editor-block-list__block.is-selected {
|
|
209
|
-
box-shadow: none;
|
|
210
|
-
outline: none;
|
|
211
|
-
}
|
|
212
208
|
.block-editor-block-list__layout .is-block-moving-mode.block-editor-block-list__block.is-selected::after {
|
|
213
209
|
content: "";
|
|
214
210
|
position: absolute;
|
|
@@ -220,6 +216,8 @@
|
|
|
220
216
|
top: -14px;
|
|
221
217
|
border-radius: 2px;
|
|
222
218
|
border-top: 4px solid #ccc;
|
|
219
|
+
bottom: auto;
|
|
220
|
+
box-shadow: none;
|
|
223
221
|
}
|
|
224
222
|
.block-editor-block-list__layout .is-block-moving-mode.can-insert-moving-block.block-editor-block-list__block.is-selected::after {
|
|
225
223
|
border-color: var(--wp-admin-theme-color);
|
package/build-style/content.css
CHANGED
|
@@ -181,12 +181,12 @@
|
|
|
181
181
|
box-shadow: none;
|
|
182
182
|
}
|
|
183
183
|
.block-editor-block-list__layout .block-editor-block-list__block.is-highlighted,
|
|
184
|
-
.block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected, .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected,
|
|
184
|
+
.block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected, .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected,
|
|
185
185
|
.block-editor-block-list__layout .block-editor-block-list__block:not([contenteditable]):focus {
|
|
186
186
|
outline: none;
|
|
187
187
|
}
|
|
188
188
|
.block-editor-block-list__layout .block-editor-block-list__block.is-highlighted::after,
|
|
189
|
-
.block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected::after, .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected::after,
|
|
189
|
+
.block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected::after, .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected::after,
|
|
190
190
|
.block-editor-block-list__layout .block-editor-block-list__block:not([contenteditable]):focus::after {
|
|
191
191
|
content: "";
|
|
192
192
|
position: absolute;
|
|
@@ -201,14 +201,10 @@
|
|
|
201
201
|
outline: 2px solid transparent;
|
|
202
202
|
}
|
|
203
203
|
.is-dark-theme .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted::after,
|
|
204
|
-
.is-dark-theme .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected::after, .is-dark-theme .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected::after,
|
|
204
|
+
.is-dark-theme .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected::after, .is-dark-theme .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected::after,
|
|
205
205
|
.is-dark-theme .block-editor-block-list__layout .block-editor-block-list__block:not([contenteditable]):focus::after {
|
|
206
206
|
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) #fff;
|
|
207
207
|
}
|
|
208
|
-
.block-editor-block-list__layout .is-block-moving-mode.block-editor-block-list__block.is-selected {
|
|
209
|
-
box-shadow: none;
|
|
210
|
-
outline: none;
|
|
211
|
-
}
|
|
212
208
|
.block-editor-block-list__layout .is-block-moving-mode.block-editor-block-list__block.is-selected::after {
|
|
213
209
|
content: "";
|
|
214
210
|
position: absolute;
|
|
@@ -220,6 +216,8 @@
|
|
|
220
216
|
top: -14px;
|
|
221
217
|
border-radius: 2px;
|
|
222
218
|
border-top: 4px solid #ccc;
|
|
219
|
+
bottom: auto;
|
|
220
|
+
box-shadow: none;
|
|
223
221
|
}
|
|
224
222
|
.block-editor-block-list__layout .is-block-moving-mode.can-insert-moving-block.block-editor-block-list__block.is-selected::after {
|
|
225
223
|
border-color: var(--wp-admin-theme-color);
|