@wordpress/block-editor 12.19.3 → 12.19.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/block-edit/context.js +2 -1
- package/build/components/block-edit/context.js.map +1 -1
- package/build/components/block-edit/index.js +8 -3
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-inspector/index.js +5 -4
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-preview/index.js +4 -0
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +21 -8
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/index.js +6 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/shadow-panel-components.js +80 -23
- package/build/components/global-styles/shadow-panel-components.js.map +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.js +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build/components/link-control/link-preview.js +4 -1
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/rich-text/index.js +45 -25
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/use-enter.js +3 -0
- package/build/components/rich-text/use-enter.js.map +1 -1
- package/build/hooks/block-hooks.js +8 -6
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/border.js +6 -4
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +2 -4
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/private-apis.js +3 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/private-actions.js +0 -10
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +0 -8
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +1 -16
- package/build/store/reducer.js.map +1 -1
- package/build-module/components/block-edit/context.js +1 -0
- package/build-module/components/block-edit/context.js.map +1 -1
- package/build-module/components/block-edit/index.js +9 -4
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +6 -5
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-preview/index.js +4 -0
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +22 -10
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/index.js +1 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/shadow-panel-components.js +82 -24
- package/build-module/components/global-styles/shadow-panel-components.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.js +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +5 -2
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/rich-text/index.js +45 -26
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/use-enter.js +3 -0
- package/build-module/components/rich-text/use-enter.js.map +1 -1
- package/build-module/hooks/block-hooks.js +8 -6
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/border.js +7 -5
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +3 -5
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/private-apis.js +3 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/private-actions.js +0 -9
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +0 -6
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +1 -16
- package/build-module/store/reducer.js.map +1 -1
- package/build-style/style-rtl.css +47 -14
- package/build-style/style.css +47 -14
- package/package.json +7 -7
- package/src/components/block-edit/context.js +1 -0
- package/src/components/block-edit/index.js +5 -1
- package/src/components/block-inspector/index.js +7 -5
- package/src/components/block-preview/index.js +6 -1
- package/src/components/block-toolbar/style.scss +11 -6
- package/src/components/global-styles/border-panel.js +33 -22
- package/src/components/global-styles/index.js +5 -1
- package/src/components/global-styles/shadow-panel-components.js +92 -23
- package/src/components/global-styles/style.scss +33 -10
- package/src/components/inspector-controls-tabs/styles-tab.js +2 -2
- package/src/components/link-control/link-preview.js +9 -2
- package/src/components/link-control/style.scss +9 -0
- package/src/components/rich-text/index.js +74 -51
- package/src/components/rich-text/use-enter.js +4 -0
- package/src/components/url-popover/style.scss +1 -0
- package/src/hooks/block-hooks.js +10 -5
- package/src/hooks/block-hooks.scss +6 -0
- package/src/hooks/border.js +16 -4
- package/src/hooks/use-bindings-attributes.js +5 -7
- package/src/private-apis.js +2 -0
- package/src/store/private-actions.js +0 -10
- package/src/store/private-selectors.js +0 -8
- package/src/store/reducer.js +0 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","__experimentalVStack","VStack","__experimentalHeading","Heading","__experimentalGrid","Grid","__experimentalHStack","HStack","__experimentalDropdownContentWrapper","DropdownContentWrapper","Button","FlexItem","Dropdown","shadow","shadowIcon","Icon","check","classNames","ShadowPopoverContainer","onShadowChange","settings","defaultShadows","presets","default","themeShadows","theme","defaultPresetsEnabled","defaultPresets","shadows","createElement","className","spacing","level","ShadowPresets","activeShadow","onSelect","columns","gap","align","justify","map","name","slug","ShadowIndicator","key","label","isActive","undefined","onClick","style","boxShadow","showTooltip","icon","ShadowPopover","popoverProps","placement","offset","shift","renderToggle","renderShadowToggle","renderContent","paddingSize","onToggle","isOpen","toggleProps","size"],"sources":["@wordpress/block-editor/src/components/global-styles/shadow-panel-components.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\t__experimentalVStack as VStack,\n\t__experimentalHeading as Heading,\n\t__experimentalGrid as Grid,\n\t__experimentalHStack as HStack,\n\t__experimentalDropdownContentWrapper as DropdownContentWrapper,\n\tButton,\n\tFlexItem,\n\tDropdown,\n} from '@wordpress/components';\nimport { shadow as shadowIcon, Icon, check } from '@wordpress/icons';\n/**\n * External dependencies\n */\nimport classNames from 'classnames';\n\nexport function ShadowPopoverContainer( { shadow, onShadowChange, settings } ) {\n\tconst defaultShadows = settings?.shadow?.presets?.default || [];\n\tconst themeShadows = settings?.shadow?.presets?.theme || [];\n\tconst defaultPresetsEnabled = settings?.shadow?.defaultPresets;\n\n\tconst shadows = [\n\t\t...( defaultPresetsEnabled ? defaultShadows : [] ),\n\t\t...themeShadows,\n\t];\n\n\treturn (\n\t\t<div className=\"block-editor-global-styles__shadow-popover-container\">\n\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t<Heading level={ 5 }>{ __( 'Drop shadow' ) }</Heading>\n\t\t\t\t<ShadowPresets\n\t\t\t\t\tpresets={ shadows }\n\t\t\t\t\tactiveShadow={ shadow }\n\t\t\t\t\tonSelect={ onShadowChange }\n\t\t\t\t/>\n\t\t\t</VStack>\n\t\t</div>\n\t);\n}\n\nexport function ShadowPresets( { presets, activeShadow, onSelect } ) {\n\treturn ! presets ? null : (\n\t\t<Grid columns={ 6 } gap={ 0 } align=\"center\" justify=\"center\">\n\t\t\t{ presets.map( ( { name, slug, shadow } ) => (\n\t\t\t\t<ShadowIndicator\n\t\t\t\t\tkey={ slug }\n\t\t\t\t\tlabel={ name }\n\t\t\t\t\tisActive={ shadow === activeShadow }\n\t\t\t\t\tonSelect={ () =>\n\t\t\t\t\t\tonSelect( shadow === activeShadow ? undefined : shadow )\n\t\t\t\t\t}\n\t\t\t\t\tshadow={ shadow }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</Grid>\n\t);\n}\n\nexport function ShadowIndicator( { label, isActive, onSelect, shadow } ) {\n\treturn (\n\t\t<div className=\"block-editor-global-styles__shadow-indicator-wrapper\">\n\t\t\t<Button\n\t\t\t\tclassName=\"block-editor-global-styles__shadow-indicator\"\n\t\t\t\tonClick={ onSelect }\n\t\t\t\tlabel={ label }\n\t\t\t\tstyle={ { boxShadow: shadow } }\n\t\t\t\tshowTooltip\n\t\t\t>\n\t\t\t\t{ isActive && <Icon icon={ check } /> }\n\t\t\t</Button>\n\t\t</div>\n\t);\n}\n\nexport function ShadowPopover( { shadow, onShadowChange, settings } ) {\n\tconst popoverProps = {\n\t\tplacement: 'left-start',\n\t\toffset: 36,\n\t\tshift: true,\n\t};\n\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ popoverProps }\n\t\t\tclassName=\"block-editor-global-styles__shadow-dropdown\"\n\t\t\trenderToggle={ renderShadowToggle() }\n\t\t\trenderContent={ () => (\n\t\t\t\t<DropdownContentWrapper paddingSize=\"medium\">\n\t\t\t\t\t<ShadowPopoverContainer\n\t\t\t\t\t\tshadow={ shadow }\n\t\t\t\t\t\tonShadowChange={ onShadowChange }\n\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t/>\n\t\t\t\t</DropdownContentWrapper>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nfunction renderShadowToggle() {\n\treturn ( { onToggle, isOpen } ) => {\n\t\tconst toggleProps = {\n\t\t\tonClick: onToggle,\n\t\t\tclassName: classNames( { 'is-open': isOpen } ),\n\t\t\t'aria-expanded': isOpen,\n\t\t};\n\n\t\treturn (\n\t\t\t<Button { ...toggleProps }>\n\t\t\t\t<HStack justify=\"flex-start\">\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tclassName=\"block-editor-global-styles__toggle-icon\"\n\t\t\t\t\t\ticon={ shadowIcon }\n\t\t\t\t\t\tsize={ 24 }\n\t\t\t\t\t/>\n\t\t\t\t\t<FlexItem>{ __( 'Drop shadow' ) }</FlexItem>\n\t\t\t\t</HStack>\n\t\t\t</Button>\n\t\t);\n\t};\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SACCC,oBAAoB,IAAIC,MAAM,EAC9BC,qBAAqB,IAAIC,OAAO,EAChCC,kBAAkB,IAAIC,IAAI,EAC1BC,oBAAoB,IAAIC,MAAM,EAC9BC,oCAAoC,IAAIC,sBAAsB,EAC9DC,MAAM,EACNC,QAAQ,EACRC,QAAQ,QACF,uBAAuB;AAC9B,SAASC,MAAM,IAA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AAA,EAAG;EAC7B,OAAO,CAAE;IAAEG,QAAQ;IAAEC;EAAO,CAAC,KAAM;IAClC,MAAMC,WAAW,GAAG;MACnBhB,OAAO,EAAEc,QAAQ;MACjBhC,SAAS,EAAEb,UAAU,CAAE;QAAE,SAAS,EAAE8C;MAAO,CAAE,CAAC;MAC9C,eAAe,EAAEA;IAClB,CAAC;IAED,OACClC,aAAA,CAACnB,MAAM;MAAA,GAAMsD;IAAW,GACvBnC,aAAA,CAACtB,MAAM;MAACgC,OAAO,EAAC;IAAY,GAC3BV,aAAA,CAACd,IAAI;MACJe,SAAS,EAAC,yCAAyC;MACnDsB,IAAI,EAAGtC,UAAY;MACnBmD,IAAI,EAAG;IAAI,CACX,CAAC,EACFpC,aAAA,CAAClB,QAAQ,QAAGZ,EAAE,CAAE,aAAc,CAAa,CACpC,CACD,CAAC;EAEX,CAAC;AACF"}
|
|
1
|
+
{"version":3,"names":["__","__experimentalVStack","VStack","__experimentalHeading","Heading","__experimentalHStack","HStack","__experimentalDropdownContentWrapper","DropdownContentWrapper","Button","FlexItem","Dropdown","privateApis","componentsPrivateApis","useMemo","shadow","shadowIcon","Icon","check","classNames","unlock","EMPTY_ARRAY","ShadowPopoverContainer","onShadowChange","settings","shadows","useShadowPresets","createElement","className","spacing","level","ShadowPresets","presets","activeShadow","onSelect","variant","onClick","undefined","CompositeV2","Composite","useCompositeStoreV2","useCompositeStore","compositeStore","store","role","map","name","slug","ShadowIndicator","key","label","isActive","type","CompositeItemV2","CompositeItem","render","unset","style","boxShadow","showTooltip","icon","ShadowPopover","popoverProps","placement","offset","shift","renderToggle","renderShadowToggle","renderContent","paddingSize","onToggle","isOpen","toggleProps","justify","size","_settings$shadow$pres","defaultPresetsEnabled","defaultPresets","default","defaultShadows","theme","themeShadows","unsetShadow","shadowPresets","length","unshift"],"sources":["@wordpress/block-editor/src/components/global-styles/shadow-panel-components.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\t__experimentalVStack as VStack,\n\t__experimentalHeading as Heading,\n\t__experimentalHStack as HStack,\n\t__experimentalDropdownContentWrapper as DropdownContentWrapper,\n\tButton,\n\tFlexItem,\n\tDropdown,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useMemo } from '@wordpress/element';\nimport { shadow as shadowIcon, Icon, check } from '@wordpress/icons';\n\n/**\n * External dependencies\n */\nimport classNames from 'classnames';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation.\n *\n * @type {Array}\n */\nconst EMPTY_ARRAY = [];\n\nexport function ShadowPopoverContainer( { shadow, onShadowChange, settings } ) {\n\tconst shadows = useShadowPresets( settings );\n\n\treturn (\n\t\t<div className=\"block-editor-global-styles__shadow-popover-container\">\n\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t<Heading level={ 5 }>{ __( 'Drop shadow' ) }</Heading>\n\t\t\t\t<ShadowPresets\n\t\t\t\t\tpresets={ shadows }\n\t\t\t\t\tactiveShadow={ shadow }\n\t\t\t\t\tonSelect={ onShadowChange }\n\t\t\t\t/>\n\t\t\t\t<div className=\"block-editor-global-styles__clear-shadow\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => onShadowChange( undefined ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Clear' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t</VStack>\n\t\t</div>\n\t);\n}\n\nexport function ShadowPresets( { presets, activeShadow, onSelect } ) {\n\tconst { CompositeV2: Composite, useCompositeStoreV2: useCompositeStore } =\n\t\tunlock( componentsPrivateApis );\n\tconst compositeStore = useCompositeStore();\n\treturn ! presets ? null : (\n\t\t<Composite\n\t\t\tstore={ compositeStore }\n\t\t\trole=\"listbox\"\n\t\t\tclassName=\"block-editor-global-styles__shadow__list\"\n\t\t\taria-label={ __( 'Drop shadows' ) }\n\t\t>\n\t\t\t{ presets.map( ( { name, slug, shadow } ) => (\n\t\t\t\t<ShadowIndicator\n\t\t\t\t\tkey={ slug }\n\t\t\t\t\tlabel={ name }\n\t\t\t\t\tisActive={ shadow === activeShadow }\n\t\t\t\t\ttype={ slug === 'unset' ? 'unset' : 'preset' }\n\t\t\t\t\tonSelect={ () =>\n\t\t\t\t\t\tonSelect( shadow === activeShadow ? undefined : shadow )\n\t\t\t\t\t}\n\t\t\t\t\tshadow={ shadow }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</Composite>\n\t);\n}\n\nexport function ShadowIndicator( { type, label, isActive, onSelect, shadow } ) {\n\tconst { CompositeItemV2: CompositeItem } = unlock( componentsPrivateApis );\n\treturn (\n\t\t<CompositeItem\n\t\t\trole=\"option\"\n\t\t\taria-label={ label }\n\t\t\taria-selected={ isActive }\n\t\t\tclassName={ classNames(\n\t\t\t\t'block-editor-global-styles__shadow__item',\n\t\t\t\t{\n\t\t\t\t\t'is-active': isActive,\n\t\t\t\t}\n\t\t\t) }\n\t\t\trender={\n\t\t\t\t<Button\n\t\t\t\t\tclassName={ classNames(\n\t\t\t\t\t\t'block-editor-global-styles__shadow-indicator',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tunset: type === 'unset',\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\tonClick={ onSelect }\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tstyle={ { boxShadow: shadow } }\n\t\t\t\t\tshowTooltip\n\t\t\t\t>\n\t\t\t\t\t{ isActive && <Icon icon={ check } /> }\n\t\t\t\t</Button>\n\t\t\t}\n\t\t/>\n\t);\n}\n\nexport function ShadowPopover( { shadow, onShadowChange, settings } ) {\n\tconst popoverProps = {\n\t\tplacement: 'left-start',\n\t\toffset: 36,\n\t\tshift: true,\n\t};\n\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ popoverProps }\n\t\t\tclassName=\"block-editor-global-styles__shadow-dropdown\"\n\t\t\trenderToggle={ renderShadowToggle() }\n\t\t\trenderContent={ () => (\n\t\t\t\t<DropdownContentWrapper paddingSize=\"medium\">\n\t\t\t\t\t<ShadowPopoverContainer\n\t\t\t\t\t\tshadow={ shadow }\n\t\t\t\t\t\tonShadowChange={ onShadowChange }\n\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t/>\n\t\t\t\t</DropdownContentWrapper>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nfunction renderShadowToggle() {\n\treturn ( { onToggle, isOpen } ) => {\n\t\tconst toggleProps = {\n\t\t\tonClick: onToggle,\n\t\t\tclassName: classNames( { 'is-open': isOpen } ),\n\t\t\t'aria-expanded': isOpen,\n\t\t};\n\n\t\treturn (\n\t\t\t<Button { ...toggleProps }>\n\t\t\t\t<HStack justify=\"flex-start\">\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tclassName=\"block-editor-global-styles__toggle-icon\"\n\t\t\t\t\t\ticon={ shadowIcon }\n\t\t\t\t\t\tsize={ 24 }\n\t\t\t\t\t/>\n\t\t\t\t\t<FlexItem>{ __( 'Drop shadow' ) }</FlexItem>\n\t\t\t\t</HStack>\n\t\t\t</Button>\n\t\t);\n\t};\n}\n\nexport function useShadowPresets( settings ) {\n\treturn useMemo( () => {\n\t\tif ( ! settings?.shadow ) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\n\t\tconst defaultPresetsEnabled = settings?.shadow?.defaultPresets;\n\t\tconst { default: defaultShadows, theme: themeShadows } =\n\t\t\tsettings?.shadow?.presets ?? {};\n\t\tconst unsetShadow = {\n\t\t\tname: __( 'Unset' ),\n\t\t\tslug: 'unset',\n\t\t\tshadow: 'none',\n\t\t};\n\n\t\tconst shadowPresets = [\n\t\t\t...( ( defaultPresetsEnabled && defaultShadows ) || EMPTY_ARRAY ),\n\t\t\t...( themeShadows || EMPTY_ARRAY ),\n\t\t];\n\t\tif ( shadowPresets.length ) {\n\t\t\tshadowPresets.unshift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
import DefaultStylePicker from '../default-style-picker';
|
|
14
14
|
import InspectorControls from '../inspector-controls';
|
|
15
|
-
import {
|
|
15
|
+
import { useBorderPanelLabel } from '../../hooks/border';
|
|
16
16
|
const StylesTab = ({
|
|
17
17
|
blockName,
|
|
18
18
|
clientId,
|
|
19
19
|
hasBlockStyles
|
|
20
20
|
}) => {
|
|
21
|
-
const borderPanelLabel =
|
|
21
|
+
const borderPanelLabel = useBorderPanelLabel({
|
|
22
22
|
blockName
|
|
23
23
|
});
|
|
24
24
|
return createElement(Fragment, null, hasBlockStyles && createElement("div", null, createElement(PanelBody, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["hasBlockSupport","PanelBody","__","BlockStyles","DefaultStylePicker","InspectorControls","
|
|
1
|
+
{"version":3,"names":["hasBlockSupport","PanelBody","__","BlockStyles","DefaultStylePicker","InspectorControls","useBorderPanelLabel","StylesTab","blockName","clientId","hasBlockStyles","borderPanelLabel","createElement","Fragment","title","Slot","group","label","className"],"sources":["@wordpress/block-editor/src/components/inspector-controls-tabs/styles-tab.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { PanelBody } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockStyles from '../block-styles';\nimport DefaultStylePicker from '../default-style-picker';\nimport InspectorControls from '../inspector-controls';\nimport { useBorderPanelLabel } from '../../hooks/border';\n\nconst StylesTab = ( { blockName, clientId, hasBlockStyles } ) => {\n\tconst borderPanelLabel = useBorderPanelLabel( { blockName } );\n\n\treturn (\n\t\t<>\n\t\t\t{ hasBlockStyles && (\n\t\t\t\t<div>\n\t\t\t\t\t<PanelBody title={ __( 'Styles' ) }>\n\t\t\t\t\t\t<BlockStyles clientId={ clientId } />\n\t\t\t\t\t\t{ hasBlockSupport(\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\t'defaultStylePicker',\n\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t) && <DefaultStylePicker blockName={ blockName } /> }\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<InspectorControls.Slot\n\t\t\t\tgroup=\"color\"\n\t\t\t\tlabel={ __( 'Color' ) }\n\t\t\t\tclassName=\"color-block-support-panel__inner-wrapper\"\n\t\t\t/>\n\t\t\t<InspectorControls.Slot\n\t\t\t\tgroup=\"background\"\n\t\t\t\tlabel={ __( 'Background' ) }\n\t\t\t/>\n\t\t\t<InspectorControls.Slot group=\"filter\" />\n\t\t\t<InspectorControls.Slot\n\t\t\t\tgroup=\"typography\"\n\t\t\t\tlabel={ __( 'Typography' ) }\n\t\t\t/>\n\t\t\t<InspectorControls.Slot\n\t\t\t\tgroup=\"dimensions\"\n\t\t\t\tlabel={ __( 'Dimensions' ) }\n\t\t\t/>\n\t\t\t<InspectorControls.Slot group=\"border\" label={ borderPanelLabel } />\n\t\t\t<InspectorControls.Slot group=\"styles\" />\n\t\t</>\n\t);\n};\n\nexport default StylesTab;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,SAASC,SAAS,QAAQ,uBAAuB;AACjD,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,WAAW,MAAM,iBAAiB;AACzC,OAAOC,kBAAkB,MAAM,yBAAyB;AACxD,OAAOC,iBAAiB,MAAM,uBAAuB;AACrD,SAASC,mBAAmB,QAAQ,oBAAoB;AAExD,MAAMC,SAAS,GAAGA,CAAE;EAAEC,SAAS;EAAEC,QAAQ;EAAEC;AAAe,CAAC,KAAM;EAChE,MAAMC,gBAAgB,GAAGL,mBAAmB,CAAE;IAAEE;EAAU,CAAE,CAAC;EAE7D,OACCI,aAAA,CAAAC,QAAA,QACGH,cAAc,IACfE,aAAA,cACCA,aAAA,CAACX,SAAS;IAACa,KAAK,EAAGZ,EAAE,CAAE,QAAS;EAAG,GAClCU,aAAA,CAACT,WAAW;IAACM,QAAQ,EAAGA;EAAU,CAAE,CAAC,EACnCT,eAAe,CAChBQ,SAAS,EACT,oBAAoB,EACpB,IACD,CAAC,IAAII,aAAA,CAACR,kBAAkB;IAACI,SAAS,EAAGA;EAAW,CAAE,CACxC,CACP,CACL,EACDI,aAAA,CAACP,iBAAiB,CAACU,IAAI;IACtBC,KAAK,EAAC,OAAO;IACbC,KAAK,EAAGf,EAAE,CAAE,OAAQ,CAAG;IACvBgB,SAAS,EAAC;EAA0C,CACpD,CAAC,EACFN,aAAA,CAACP,iBAAiB,CAACU,IAAI;IACtBC,KAAK,EAAC,YAAY;IAClBC,KAAK,EAAGf,EAAE,CAAE,YAAa;EAAG,CAC5B,CAAC,EACFU,aAAA,CAACP,iBAAiB,CAACU,IAAI;IAACC,KAAK,EAAC;EAAQ,CAAE,CAAC,EACzCJ,aAAA,CAACP,iBAAiB,CAACU,IAAI;IACtBC,KAAK,EAAC,YAAY;IAClBC,KAAK,EAAGf,EAAE,CAAE,YAAa;EAAG,CAC5B,CAAC,EACFU,aAAA,CAACP,iBAAiB,CAACU,IAAI;IACtBC,KAAK,EAAC,YAAY;IAClBC,KAAK,EAAGf,EAAE,CAAE,YAAa;EAAG,CAC5B,CAAC,EACFU,aAAA,CAACP,iBAAiB,CAACU,IAAI;IAACC,KAAK,EAAC,QAAQ;IAACC,KAAK,EAAGN;EAAkB,CAAE,CAAC,EACpEC,aAAA,CAACP,iBAAiB,CAACU,IAAI;IAACC,KAAK,EAAC;EAAQ,CAAE,CACvC,CAAC;AAEL,CAAC;AAED,eAAeT,SAAS"}
|
|
@@ -13,8 +13,9 @@ import { useCopyToClipboard } from '@wordpress/compose';
|
|
|
13
13
|
import { filterURLForDisplay, safeDecodeURI } from '@wordpress/url';
|
|
14
14
|
import { Icon, globe, info, linkOff, edit, copySmall } from '@wordpress/icons';
|
|
15
15
|
import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
|
|
16
|
-
import { useDispatch } from '@wordpress/data';
|
|
16
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
17
17
|
import { store as noticesStore } from '@wordpress/notices';
|
|
18
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Internal dependencies
|
|
@@ -28,6 +29,8 @@ export default function LinkPreview({
|
|
|
28
29
|
hasUnlinkControl = false,
|
|
29
30
|
onRemove
|
|
30
31
|
}) {
|
|
32
|
+
const showIconLabels = useSelect(select => select(preferencesStore).get('core', 'showIconLabels'), []);
|
|
33
|
+
|
|
31
34
|
// Avoid fetching if rich previews are not desired.
|
|
32
35
|
const showRichPreviews = hasRichPreviews ? value?.url : null;
|
|
33
36
|
const {
|
|
@@ -114,7 +117,7 @@ export default function LinkPreview({
|
|
|
114
117
|
// Translators: %s is a placeholder for the link URL and an optional colon, (if a Link URL is present).
|
|
115
118
|
__('Copy link%s'),
|
|
116
119
|
// Ends up looking like "Copy link: https://example.com".
|
|
117
|
-
isEmptyURL ? '' : ': ' + value.url),
|
|
120
|
+
isEmptyURL || showIconLabels ? '' : ': ' + value.url),
|
|
118
121
|
ref: ref,
|
|
119
122
|
disabled: isEmptyURL,
|
|
120
123
|
size: "compact"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","__","sprintf","Button","ExternalLink","__experimentalTruncate","Truncate","useCopyToClipboard","filterURLForDisplay","safeDecodeURI","Icon","globe","info","linkOff","edit","copySmall","__unstableStripHTML","stripHTML","useDispatch","store","noticesStore","ViewerSlot","useRichUrlData","LinkPreview","value","onEditClick","hasRichPreviews","hasUnlinkControl","onRemove","showRichPreviews","url","richData","isFetching","hasRichData","Object","keys","length","displayURL","isEmptyURL","displayTitle","title","icon","createElement","src","alt","size","createNotice","ref","isDismissible","type","className","Fragment","href","numberOfLines","label","onClick","disabled","fillProps"],"sources":["@wordpress/block-editor/src/components/link-control/link-preview.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tExternalLink,\n\t__experimentalTruncate as Truncate,\n} from '@wordpress/components';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { filterURLForDisplay, safeDecodeURI } from '@wordpress/url';\nimport { Icon, globe, info, linkOff, edit, copySmall } from '@wordpress/icons';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { ViewerSlot } from './viewer-slot';\n\nimport useRichUrlData from './use-rich-url-data';\n\nexport default function LinkPreview( {\n\tvalue,\n\tonEditClick,\n\thasRichPreviews = false,\n\thasUnlinkControl = false,\n\tonRemove,\n} ) {\n\t// Avoid fetching if rich previews are not desired.\n\tconst showRichPreviews = hasRichPreviews ? value?.url : null;\n\n\tconst { richData, isFetching } = useRichUrlData( showRichPreviews );\n\n\t// Rich data may be an empty object so test for that.\n\tconst hasRichData = richData && Object.keys( richData ).length;\n\n\tconst displayURL =\n\t\t( value && filterURLForDisplay( safeDecodeURI( value.url ), 24 ) ) ||\n\t\t'';\n\n\t// url can be undefined if the href attribute is unset\n\tconst isEmptyURL = ! value?.url?.length;\n\n\tconst displayTitle =\n\t\t! isEmptyURL &&\n\t\tstripHTML( richData?.title || value?.title || displayURL );\n\n\tlet icon;\n\n\tif ( richData?.icon ) {\n\t\ticon = <img src={ richData?.icon } alt=\"\" />;\n\t} else if ( isEmptyURL ) {\n\t\ticon = <Icon icon={ info } size={ 32 } />;\n\t} else {\n\t\ticon = <Icon icon={ globe } />;\n\t}\n\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst ref = useCopyToClipboard( value.url, () => {\n\t\tcreateNotice( 'info', __( 'Link copied to clipboard.' ), {\n\t\t\tisDismissible: true,\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t} );\n\n\treturn (\n\t\t<div\n\t\t\taria-label={ __( 'Currently selected' ) }\n\t\t\tclassName={ classnames( 'block-editor-link-control__search-item', {\n\t\t\t\t'is-current': true,\n\t\t\t\t'is-rich': hasRichData,\n\t\t\t\t'is-fetching': !! isFetching,\n\t\t\t\t'is-preview': true,\n\t\t\t\t'is-error': isEmptyURL,\n\t\t\t\t'is-url-title': displayTitle === displayURL,\n\t\t\t} ) }\n\t\t>\n\t\t\t<div className=\"block-editor-link-control__search-item-top\">\n\t\t\t\t<span className=\"block-editor-link-control__search-item-header\">\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-link-control__search-item-icon',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-image': richData?.icon,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ icon }\n\t\t\t\t\t</span>\n\t\t\t\t\t<span className=\"block-editor-link-control__search-item-details\">\n\t\t\t\t\t\t{ ! isEmptyURL ? (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-item-title\"\n\t\t\t\t\t\t\t\t\thref={ value.url }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<Truncate numberOfLines={ 1 }>\n\t\t\t\t\t\t\t\t\t\t{ displayTitle }\n\t\t\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t{ value?.url && displayTitle !== displayURL && (\n\t\t\t\t\t\t\t\t\t<span className=\"block-editor-link-control__search-item-info\">\n\t\t\t\t\t\t\t\t\t\t<Truncate numberOfLines={ 1 }>\n\t\t\t\t\t\t\t\t\t\t\t{ displayURL }\n\t\t\t\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<span className=\"block-editor-link-control__search-item-error-notice\">\n\t\t\t\t\t\t\t\t{ __( 'Link is empty' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t</span>\n\t\t\t\t<Button\n\t\t\t\t\ticon={ edit }\n\t\t\t\t\tlabel={ __( 'Edit link' ) }\n\t\t\t\t\tonClick={ onEditClick }\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t/>\n\t\t\t\t{ hasUnlinkControl && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\tlabel={ __( 'Remove link' ) }\n\t\t\t\t\t\tonClick={ onRemove }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<Button\n\t\t\t\t\ticon={ copySmall }\n\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t// Translators: %s is a placeholder for the link URL and an optional colon, (if a Link URL is present).\n\t\t\t\t\t\t__( 'Copy link%s' ), // Ends up looking like \"Copy link: https://example.com\".\n\t\t\t\t\t\tisEmptyURL ? '' : ': ' + value.url\n\t\t\t\t\t) }\n\t\t\t\t\tref={ ref }\n\t\t\t\t\tdisabled={ isEmptyURL }\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t/>\n\t\t\t\t<ViewerSlot fillProps={ value } />\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SACCC,MAAM,EACNC,YAAY,EACZC,sBAAsB,IAAIC,QAAQ,QAC5B,uBAAuB;AAC9B,SAASC,kBAAkB,QAAQ,oBAAoB;AACvD,SAASC,mBAAmB,EAAEC,aAAa,QAAQ,gBAAgB;AACnE,SAASC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,OAAO,EAAEC,IAAI,EAAEC,SAAS,QAAQ,kBAAkB;AAC9E,SAASC,mBAAmB,IAAIC,SAAS,QAAQ,gBAAgB;AACjE,SAASC,WAAW,QAAQ,iBAAiB;
|
|
1
|
+
{"version":3,"names":["classnames","__","sprintf","Button","ExternalLink","__experimentalTruncate","Truncate","useCopyToClipboard","filterURLForDisplay","safeDecodeURI","Icon","globe","info","linkOff","edit","copySmall","__unstableStripHTML","stripHTML","useDispatch","useSelect","store","noticesStore","preferencesStore","ViewerSlot","useRichUrlData","LinkPreview","value","onEditClick","hasRichPreviews","hasUnlinkControl","onRemove","showIconLabels","select","get","showRichPreviews","url","richData","isFetching","hasRichData","Object","keys","length","displayURL","isEmptyURL","displayTitle","title","icon","createElement","src","alt","size","createNotice","ref","isDismissible","type","className","Fragment","href","numberOfLines","label","onClick","disabled","fillProps"],"sources":["@wordpress/block-editor/src/components/link-control/link-preview.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tExternalLink,\n\t__experimentalTruncate as Truncate,\n} from '@wordpress/components';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { filterURLForDisplay, safeDecodeURI } from '@wordpress/url';\nimport { Icon, globe, info, linkOff, edit, copySmall } from '@wordpress/icons';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { ViewerSlot } from './viewer-slot';\n\nimport useRichUrlData from './use-rich-url-data';\n\nexport default function LinkPreview( {\n\tvalue,\n\tonEditClick,\n\thasRichPreviews = false,\n\thasUnlinkControl = false,\n\tonRemove,\n} ) {\n\tconst showIconLabels = useSelect(\n\t\t( select ) =>\n\t\t\tselect( preferencesStore ).get( 'core', 'showIconLabels' ),\n\t\t[]\n\t);\n\n\t// Avoid fetching if rich previews are not desired.\n\tconst showRichPreviews = hasRichPreviews ? value?.url : null;\n\n\tconst { richData, isFetching } = useRichUrlData( showRichPreviews );\n\n\t// Rich data may be an empty object so test for that.\n\tconst hasRichData = richData && Object.keys( richData ).length;\n\n\tconst displayURL =\n\t\t( value && filterURLForDisplay( safeDecodeURI( value.url ), 24 ) ) ||\n\t\t'';\n\n\t// url can be undefined if the href attribute is unset\n\tconst isEmptyURL = ! value?.url?.length;\n\n\tconst displayTitle =\n\t\t! isEmptyURL &&\n\t\tstripHTML( richData?.title || value?.title || displayURL );\n\n\tlet icon;\n\n\tif ( richData?.icon ) {\n\t\ticon = <img src={ richData?.icon } alt=\"\" />;\n\t} else if ( isEmptyURL ) {\n\t\ticon = <Icon icon={ info } size={ 32 } />;\n\t} else {\n\t\ticon = <Icon icon={ globe } />;\n\t}\n\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst ref = useCopyToClipboard( value.url, () => {\n\t\tcreateNotice( 'info', __( 'Link copied to clipboard.' ), {\n\t\t\tisDismissible: true,\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t} );\n\n\treturn (\n\t\t<div\n\t\t\taria-label={ __( 'Currently selected' ) }\n\t\t\tclassName={ classnames( 'block-editor-link-control__search-item', {\n\t\t\t\t'is-current': true,\n\t\t\t\t'is-rich': hasRichData,\n\t\t\t\t'is-fetching': !! isFetching,\n\t\t\t\t'is-preview': true,\n\t\t\t\t'is-error': isEmptyURL,\n\t\t\t\t'is-url-title': displayTitle === displayURL,\n\t\t\t} ) }\n\t\t>\n\t\t\t<div className=\"block-editor-link-control__search-item-top\">\n\t\t\t\t<span className=\"block-editor-link-control__search-item-header\">\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-link-control__search-item-icon',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-image': richData?.icon,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ icon }\n\t\t\t\t\t</span>\n\t\t\t\t\t<span className=\"block-editor-link-control__search-item-details\">\n\t\t\t\t\t\t{ ! isEmptyURL ? (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-item-title\"\n\t\t\t\t\t\t\t\t\thref={ value.url }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<Truncate numberOfLines={ 1 }>\n\t\t\t\t\t\t\t\t\t\t{ displayTitle }\n\t\t\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t{ value?.url && displayTitle !== displayURL && (\n\t\t\t\t\t\t\t\t\t<span className=\"block-editor-link-control__search-item-info\">\n\t\t\t\t\t\t\t\t\t\t<Truncate numberOfLines={ 1 }>\n\t\t\t\t\t\t\t\t\t\t\t{ displayURL }\n\t\t\t\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<span className=\"block-editor-link-control__search-item-error-notice\">\n\t\t\t\t\t\t\t\t{ __( 'Link is empty' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t</span>\n\t\t\t\t<Button\n\t\t\t\t\ticon={ edit }\n\t\t\t\t\tlabel={ __( 'Edit link' ) }\n\t\t\t\t\tonClick={ onEditClick }\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t/>\n\t\t\t\t{ hasUnlinkControl && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\tlabel={ __( 'Remove link' ) }\n\t\t\t\t\t\tonClick={ onRemove }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<Button\n\t\t\t\t\ticon={ copySmall }\n\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t// Translators: %s is a placeholder for the link URL and an optional colon, (if a Link URL is present).\n\t\t\t\t\t\t__( 'Copy link%s' ), // Ends up looking like \"Copy link: https://example.com\".\n\t\t\t\t\t\tisEmptyURL || showIconLabels ? '' : ': ' + value.url\n\t\t\t\t\t) }\n\t\t\t\t\tref={ ref }\n\t\t\t\t\tdisabled={ isEmptyURL }\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t/>\n\t\t\t\t<ViewerSlot fillProps={ value } />\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SACCC,MAAM,EACNC,YAAY,EACZC,sBAAsB,IAAIC,QAAQ,QAC5B,uBAAuB;AAC9B,SAASC,kBAAkB,QAAQ,oBAAoB;AACvD,SAASC,mBAAmB,EAAEC,aAAa,QAAQ,gBAAgB;AACnE,SAASC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,OAAO,EAAEC,IAAI,EAAEC,SAAS,QAAQ,kBAAkB;AAC9E,SAASC,mBAAmB,IAAIC,SAAS,QAAQ,gBAAgB;AACjE,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SAASD,KAAK,IAAIE,gBAAgB,QAAQ,wBAAwB;;AAElE;AACA;AACA;AACA,SAASC,UAAU,QAAQ,eAAe;AAE1C,OAAOC,cAAc,MAAM,qBAAqB;AAEhD,eAAe,SAASC,WAAWA,CAAE;EACpCC,KAAK;EACLC,WAAW;EACXC,eAAe,GAAG,KAAK;EACvBC,gBAAgB,GAAG,KAAK;EACxBC;AACD,CAAC,EAA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AC,EACP8C,aAAA,CAAC5C,MAAM;IACN2C,IAAI,EAAGhC,IAAM;IACb6C,KAAK,EAAG1D,EAAE,CAAE,WAAY,CAAG;IAC3B2D,OAAO,EAAGjC,WAAa;IACvBuB,IAAI,EAAC;EAAS,CACd,CAAC,EACArB,gBAAgB,IACjBkB,aAAA,CAAC5C,MAAM;IACN2C,IAAI,EAAGjC,OAAS;IAChB8C,KAAK,EAAG1D,EAAE,CAAE,aAAc,CAAG;IAC7B2D,OAAO,EAAG9B,QAAU;IACpBoB,IAAI,EAAC;EAAS,CACd,CACD,EACDH,aAAA,CAAC5C,MAAM;IACN2C,IAAI,EAAG/B,SAAW;IAClB4C,KAAK,EAAGzD,OAAO;IACd;IACAD,EAAE,CAAE,aAAc,CAAC;IAAE;IACrB0C,UAAU,IAAIZ,cAAc,GAAG,EAAE,GAAG,IAAI,GAAGL,KAAK,CAACS,GAClD,CAAG;IACHiB,GAAG,EAAGA,GAAK;IACXS,QAAQ,EAAGlB,UAAY;IACvBO,IAAI,EAAC;EAAS,CACd,CAAC,EACFH,aAAA,CAACxB,UAAU;IAACuC,SAAS,EAAGpC;EAAO,CAAE,CAC7B,CACD,CAAC;AAER"}
|
|
@@ -12,13 +12,14 @@ import { useDispatch, useSelect } from '@wordpress/data';
|
|
|
12
12
|
import { useMergeRefs } from '@wordpress/compose';
|
|
13
13
|
import { __unstableUseRichText as useRichText, removeFormat } from '@wordpress/rich-text';
|
|
14
14
|
import { Popover } from '@wordpress/components';
|
|
15
|
-
import { getBlockType } from '@wordpress/blocks';
|
|
15
|
+
import { getBlockType, store as blocksStore } from '@wordpress/blocks';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Internal dependencies
|
|
19
19
|
*/
|
|
20
20
|
import { useBlockEditorAutocompleteProps } from '../autocomplete';
|
|
21
21
|
import { useBlockEditContext } from '../block-edit';
|
|
22
|
+
import { blockBindingsKey } from '../block-edit/context';
|
|
22
23
|
import FormatToolbarContainer from './format-toolbar-container';
|
|
23
24
|
import { store as blockEditorStore } from '../../store';
|
|
24
25
|
import { useUndoAutomaticChange } from './use-undo-automatic-change';
|
|
@@ -99,15 +100,18 @@ export function RichTextWrapper({
|
|
|
99
100
|
__unstableDisableFormats: disableFormats,
|
|
100
101
|
disableLineBreaks,
|
|
101
102
|
__unstableAllowPrefixTransformations,
|
|
103
|
+
disableEditing,
|
|
102
104
|
...props
|
|
103
105
|
}, forwardedRef) {
|
|
104
106
|
props = removeNativeProps(props);
|
|
105
107
|
const anchorRef = useRef();
|
|
108
|
+
const context = useBlockEditContext();
|
|
106
109
|
const {
|
|
107
110
|
clientId,
|
|
108
111
|
isSelected: isBlockSelected,
|
|
109
112
|
name: blockName
|
|
110
|
-
} =
|
|
113
|
+
} = context;
|
|
114
|
+
const blockBindings = context[blockBindingsKey];
|
|
111
115
|
const selector = select => {
|
|
112
116
|
// Avoid subscribing to the block editor store if the block is not
|
|
113
117
|
// selected.
|
|
@@ -118,26 +122,35 @@ export function RichTextWrapper({
|
|
|
118
122
|
}
|
|
119
123
|
const {
|
|
120
124
|
getSelectionStart,
|
|
121
|
-
getSelectionEnd
|
|
122
|
-
getBlockAttributes
|
|
125
|
+
getSelectionEnd
|
|
123
126
|
} = select(blockEditorStore);
|
|
124
127
|
const selectionStart = getSelectionStart();
|
|
125
128
|
const selectionEnd = getSelectionEnd();
|
|
126
|
-
const blockBindings = getBlockAttributes(clientId)?.metadata?.bindings;
|
|
127
129
|
let isSelected;
|
|
128
130
|
if (originalIsSelected === undefined) {
|
|
129
131
|
isSelected = selectionStart.clientId === clientId && selectionEnd.clientId === clientId && selectionStart.attributeKey === identifier;
|
|
130
132
|
} else if (originalIsSelected) {
|
|
131
133
|
isSelected = selectionStart.clientId === clientId;
|
|
132
134
|
}
|
|
133
|
-
|
|
135
|
+
return {
|
|
136
|
+
selectionStart: isSelected ? selectionStart.offset : undefined,
|
|
137
|
+
selectionEnd: isSelected ? selectionEnd.offset : undefined,
|
|
138
|
+
isSelected
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
const {
|
|
142
|
+
selectionStart,
|
|
143
|
+
selectionEnd,
|
|
144
|
+
isSelected
|
|
145
|
+
} = useSelect(selector, [clientId, identifier, originalIsSelected, isBlockSelected]);
|
|
146
|
+
const disableBoundBlocks = useSelect(select => {
|
|
134
147
|
// Disable Rich Text editing if block bindings specify that.
|
|
135
|
-
let
|
|
148
|
+
let _disableBoundBlocks = false;
|
|
136
149
|
if (blockBindings && blockName in BLOCK_BINDINGS_ALLOWED_BLOCKS) {
|
|
137
150
|
const blockTypeAttributes = getBlockType(blockName).attributes;
|
|
138
151
|
const {
|
|
139
152
|
getBlockBindingsSource
|
|
140
|
-
} = unlock(select(
|
|
153
|
+
} = unlock(select(blocksStore));
|
|
141
154
|
for (const [attribute, args] of Object.entries(blockBindings)) {
|
|
142
155
|
if (blockTypeAttributes?.[attribute]?.source !== 'rich-text') {
|
|
143
156
|
break;
|
|
@@ -146,24 +159,14 @@ export function RichTextWrapper({
|
|
|
146
159
|
// If the source is not defined, or if its value of `lockAttributesEditing` is `true`, disable it.
|
|
147
160
|
const blockBindingsSource = getBlockBindingsSource(args.source);
|
|
148
161
|
if (!blockBindingsSource || blockBindingsSource.lockAttributesEditing) {
|
|
149
|
-
|
|
162
|
+
_disableBoundBlocks = true;
|
|
150
163
|
break;
|
|
151
164
|
}
|
|
152
165
|
}
|
|
153
166
|
}
|
|
154
|
-
return
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
isSelected,
|
|
158
|
-
shouldDisableEditing
|
|
159
|
-
};
|
|
160
|
-
};
|
|
161
|
-
const {
|
|
162
|
-
selectionStart,
|
|
163
|
-
selectionEnd,
|
|
164
|
-
isSelected,
|
|
165
|
-
shouldDisableEditing
|
|
166
|
-
} = useSelect(selector, [clientId, identifier, originalIsSelected, isBlockSelected]);
|
|
167
|
+
return _disableBoundBlocks;
|
|
168
|
+
}, [blockBindings, blockName]);
|
|
169
|
+
const shouldDisableEditing = disableEditing || disableBoundBlocks;
|
|
167
170
|
const {
|
|
168
171
|
getSelectionStart,
|
|
169
172
|
getSelectionEnd,
|
|
@@ -359,16 +362,32 @@ export function RichTextWrapper({
|
|
|
359
362
|
"data-wp-block-attribute-key": identifier
|
|
360
363
|
}));
|
|
361
364
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
+
|
|
366
|
+
// This is the private API for the RichText component.
|
|
367
|
+
// It allows access to all props, not just the public ones.
|
|
368
|
+
export const PrivateRichText = withDeprecations(forwardRef(RichTextWrapper));
|
|
369
|
+
PrivateRichText.Content = Content;
|
|
370
|
+
PrivateRichText.isEmpty = value => {
|
|
365
371
|
return !value || value.length === 0;
|
|
366
372
|
};
|
|
367
373
|
|
|
374
|
+
// This is the public API for the RichText component.
|
|
375
|
+
// We wrap the PrivateRichText component to hide some props from the public API.
|
|
368
376
|
/**
|
|
369
377
|
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md
|
|
370
378
|
*/
|
|
371
|
-
|
|
379
|
+
const PublicForwardedRichTextContainer = forwardRef((props, ref) => {
|
|
380
|
+
return createElement(PrivateRichText, {
|
|
381
|
+
ref: ref,
|
|
382
|
+
...props,
|
|
383
|
+
disableEditing: false
|
|
384
|
+
});
|
|
385
|
+
});
|
|
386
|
+
PublicForwardedRichTextContainer.Content = Content;
|
|
387
|
+
PublicForwardedRichTextContainer.isEmpty = value => {
|
|
388
|
+
return !value || value.length === 0;
|
|
389
|
+
};
|
|
390
|
+
export default PublicForwardedRichTextContainer;
|
|
372
391
|
export { RichTextShortcut } from './shortcut';
|
|
373
392
|
export { RichTextToolbarButton } from './toolbar-button';
|
|
374
393
|
export { __unstableRichTextInputEvent } from './input-event';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","useRef","useCallback","forwardRef","createContext","useDispatch","useSelect","useMergeRefs","__unstableUseRichText","useRichText","removeFormat","Popover","getBlockType","useBlockEditorAutocompleteProps","useBlockEditContext","FormatToolbarContainer","store","blockEditorStore","useUndoAutomaticChange","useMarkPersistent","usePasteHandler","useBeforeInputRules","useInputRules","useDelete","useEnter","useFormatTypes","useRemoveBrowserShortcuts","useShortcuts","useInputEvents","useInsertReplacementText","useFirefoxCompat","FormatEdit","getAllowedFormats","Content","withDeprecations","unlock","BLOCK_BINDINGS_ALLOWED_BLOCKS","keyboardShortcutContext","inputEventContext","removeNativeProps","props","__unstableMobileNoFocusOnMount","deleteEnter","placeholderTextColor","textAlign","selectionColor","tagsToEliminate","disableEditingMenu","fontSize","fontFamily","fontWeight","fontStyle","minWidth","maxWidth","setRef","disableSuggestions","disableAutocorrection","restProps","RichTextWrapper","children","tagName","value","adjustedValue","onChange","adjustedOnChange","isSelected","originalIsSelected","multiline","inlineToolbar","wrapperClassName","autocompleters","onReplace","placeholder","allowedFormats","withoutInteractiveFormatting","onRemove","onMerge","onSplit","__unstableOnSplitAtEnd","onSplitAtEnd","__unstableOnSplitAtDoubleLineEnd","onSplitAtDoubleLineEnd","identifier","preserveWhiteSpace","__unstablePastePlainText","pastePlainText","__unstableEmbedURLOnPaste","__unstableDisableFormats","disableFormats","disableLineBreaks","__unstableAllowPrefixTransformations","forwardedRef","anchorRef","clientId","isBlockSelected","name","blockName","selector","select","getSelectionStart","getSelectionEnd","getBlockAttributes","selectionStart","selectionEnd","blockBindings","metadata","bindings","undefined","attributeKey","shouldDisableEditing","blockTypeAttributes","attributes","getBlockBindingsSource","attribute","args","Object","entries","source","blockBindingsSource","lockAttributesEditing","offset","getBlockRootClientId","selectionChange","adjustedAllowedFormats","hasFormats","length","onSelectionChange","start","end","selection","unset","formatTypes","prepareHandlers","valueHandlers","changeHandlers","dependencies","addEditorOnlyFormats","reduce","accumulator","fn","text","formats","removeEditorOnlyFormats","forEach","formatType","__experimentalCreatePrepareEditableTree","addInvisibleFormats","getValue","ref","richTextRef","html","__unstableFormats","__unstableText","values","changeHandler","__unstableIsSelected","__unstableDependencies","__unstableAfterParse","__unstableBeforeSerialize","__unstableAddInvisibleFormats","autocompleteProps","completers","record","keyboardShortcuts","Set","inputEvents","onFocus","current","focus","TagName","createElement","Fragment","Provider","__unstableSlotNameProvider","inline","editableContentElement","role","contentEditable","suppressContentEditableWarning","className","tabIndex","ForwardedRichTextContainer","isEmpty","RichTextShortcut","RichTextToolbarButton","__unstableRichTextInputEvent"],"sources":["@wordpress/block-editor/src/components/rich-text/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseRef,\n\tuseCallback,\n\tforwardRef,\n\tcreateContext,\n} from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useMergeRefs } from '@wordpress/compose';\nimport {\n\t__unstableUseRichText as useRichText,\n\tremoveFormat,\n} from '@wordpress/rich-text';\nimport { Popover } from '@wordpress/components';\nimport { getBlockType } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditorAutocompleteProps } from '../autocomplete';\nimport { useBlockEditContext } from '../block-edit';\nimport FormatToolbarContainer from './format-toolbar-container';\nimport { store as blockEditorStore } from '../../store';\nimport { useUndoAutomaticChange } from './use-undo-automatic-change';\nimport { useMarkPersistent } from './use-mark-persistent';\nimport { usePasteHandler } from './use-paste-handler';\nimport { useBeforeInputRules } from './use-before-input-rules';\nimport { useInputRules } from './use-input-rules';\nimport { useDelete } from './use-delete';\nimport { useEnter } from './use-enter';\nimport { useFormatTypes } from './use-format-types';\nimport { useRemoveBrowserShortcuts } from './use-remove-browser-shortcuts';\nimport { useShortcuts } from './use-shortcuts';\nimport { useInputEvents } from './use-input-events';\nimport { useInsertReplacementText } from './use-insert-replacement-text';\nimport { useFirefoxCompat } from './use-firefox-compat';\nimport FormatEdit from './format-edit';\nimport { getAllowedFormats } from './utils';\nimport { Content } from './content';\nimport { withDeprecations } from './with-deprecations';\nimport { unlock } from '../../lock-unlock';\nimport { BLOCK_BINDINGS_ALLOWED_BLOCKS } from '../../hooks/use-bindings-attributes';\n\nexport const keyboardShortcutContext = createContext();\nexport const inputEventContext = createContext();\n\n/**\n * Removes props used for the native version of RichText so that they are not\n * passed to the DOM element and log warnings.\n *\n * @param {Object} props Props to filter.\n *\n * @return {Object} Filtered props.\n */\nfunction removeNativeProps( props ) {\n\tconst {\n\t\t__unstableMobileNoFocusOnMount,\n\t\tdeleteEnter,\n\t\tplaceholderTextColor,\n\t\ttextAlign,\n\t\tselectionColor,\n\t\ttagsToEliminate,\n\t\tdisableEditingMenu,\n\t\tfontSize,\n\t\tfontFamily,\n\t\tfontWeight,\n\t\tfontStyle,\n\t\tminWidth,\n\t\tmaxWidth,\n\t\tsetRef,\n\t\tdisableSuggestions,\n\t\tdisableAutocorrection,\n\t\t...restProps\n\t} = props;\n\treturn restProps;\n}\n\nexport function RichTextWrapper(\n\t{\n\t\tchildren,\n\t\ttagName = 'div',\n\t\tvalue: adjustedValue = '',\n\t\tonChange: adjustedOnChange,\n\t\tisSelected: originalIsSelected,\n\t\tmultiline,\n\t\tinlineToolbar,\n\t\twrapperClassName,\n\t\tautocompleters,\n\t\tonReplace,\n\t\tplaceholder,\n\t\tallowedFormats,\n\t\twithoutInteractiveFormatting,\n\t\tonRemove,\n\t\tonMerge,\n\t\tonSplit,\n\t\t__unstableOnSplitAtEnd: onSplitAtEnd,\n\t\t__unstableOnSplitAtDoubleLineEnd: onSplitAtDoubleLineEnd,\n\t\tidentifier,\n\t\tpreserveWhiteSpace,\n\t\t__unstablePastePlainText: pastePlainText,\n\t\t__unstableEmbedURLOnPaste,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tdisableLineBreaks,\n\t\t__unstableAllowPrefixTransformations,\n\t\t...props\n\t},\n\tforwardedRef\n) {\n\tprops = removeNativeProps( props );\n\n\tconst anchorRef = useRef();\n\tconst {\n\t\tclientId,\n\t\tisSelected: isBlockSelected,\n\t\tname: blockName,\n\t} = useBlockEditContext();\n\tconst selector = ( select ) => {\n\t\t// Avoid subscribing to the block editor store if the block is not\n\t\t// selected.\n\t\tif ( ! isBlockSelected ) {\n\t\t\treturn { isSelected: false };\n\t\t}\n\n\t\tconst { getSelectionStart, getSelectionEnd, getBlockAttributes } =\n\t\t\tselect( blockEditorStore );\n\t\tconst selectionStart = getSelectionStart();\n\t\tconst selectionEnd = getSelectionEnd();\n\t\tconst blockBindings =\n\t\t\tgetBlockAttributes( clientId )?.metadata?.bindings;\n\n\t\tlet isSelected;\n\n\t\tif ( originalIsSelected === undefined ) {\n\t\t\tisSelected =\n\t\t\t\tselectionStart.clientId === clientId &&\n\t\t\t\tselectionEnd.clientId === clientId &&\n\t\t\t\tselectionStart.attributeKey === identifier;\n\t\t} else if ( originalIsSelected ) {\n\t\t\tisSelected = selectionStart.clientId === clientId;\n\t\t}\n\n\t\t// Disable Rich Text editing if block bindings specify that.\n\t\tlet shouldDisableEditing = false;\n\t\tif ( blockBindings && blockName in BLOCK_BINDINGS_ALLOWED_BLOCKS ) {\n\t\t\tconst blockTypeAttributes = getBlockType( blockName ).attributes;\n\t\t\tconst { getBlockBindingsSource } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\t\t\tfor ( const [ attribute, args ] of Object.entries(\n\t\t\t\tblockBindings\n\t\t\t) ) {\n\t\t\t\tif (\n\t\t\t\t\tblockTypeAttributes?.[ attribute ]?.source !== 'rich-text'\n\t\t\t\t) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t// If the source is not defined, or if its value of `lockAttributesEditing` is `true`, disable it.\n\t\t\t\tconst blockBindingsSource = getBlockBindingsSource(\n\t\t\t\t\targs.source\n\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\t! blockBindingsSource ||\n\t\t\t\t\tblockBindingsSource.lockAttributesEditing\n\t\t\t\t) {\n\t\t\t\t\tshouldDisableEditing = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tselectionStart: isSelected ? selectionStart.offset : undefined,\n\t\t\tselectionEnd: isSelected ? selectionEnd.offset : undefined,\n\t\t\tisSelected,\n\t\t\tshouldDisableEditing,\n\t\t};\n\t};\n\tconst { selectionStart, selectionEnd, isSelected, shouldDisableEditing } =\n\t\tuseSelect( selector, [\n\t\t\tclientId,\n\t\t\tidentifier,\n\t\t\toriginalIsSelected,\n\t\t\tisBlockSelected,\n\t\t] );\n\tconst { getSelectionStart, getSelectionEnd, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\tconst { selectionChange } = useDispatch( blockEditorStore );\n\tconst adjustedAllowedFormats = getAllowedFormats( {\n\t\tallowedFormats,\n\t\tdisableFormats,\n\t} );\n\tconst hasFormats =\n\t\t! adjustedAllowedFormats || adjustedAllowedFormats.length > 0;\n\n\tconst onSelectionChange = useCallback(\n\t\t( start, end ) => {\n\t\t\tconst selection = {};\n\t\t\tconst unset = start === undefined && end === undefined;\n\n\t\t\tif ( typeof start === 'number' || unset ) {\n\t\t\t\t// If we are only setting the start (or the end below), which\n\t\t\t\t// means a partial selection, and we're not updating a selection\n\t\t\t\t// with the same client ID, abort. This means the selected block\n\t\t\t\t// is a parent block.\n\t\t\t\tif (\n\t\t\t\t\tend === undefined &&\n\t\t\t\t\tgetBlockRootClientId( clientId ) !==\n\t\t\t\t\t\tgetBlockRootClientId( getSelectionEnd().clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tselection.start = {\n\t\t\t\t\tclientId,\n\t\t\t\t\tattributeKey: identifier,\n\t\t\t\t\toffset: start,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif ( typeof end === 'number' || unset ) {\n\t\t\t\tif (\n\t\t\t\t\tstart === undefined &&\n\t\t\t\t\tgetBlockRootClientId( clientId ) !==\n\t\t\t\t\t\tgetBlockRootClientId( getSelectionStart().clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tselection.end = {\n\t\t\t\t\tclientId,\n\t\t\t\t\tattributeKey: identifier,\n\t\t\t\t\toffset: end,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tselectionChange( selection );\n\t\t},\n\t\t[ clientId, identifier ]\n\t);\n\n\tconst {\n\t\tformatTypes,\n\t\tprepareHandlers,\n\t\tvalueHandlers,\n\t\tchangeHandlers,\n\t\tdependencies,\n\t} = useFormatTypes( {\n\t\tclientId,\n\t\tidentifier,\n\t\twithoutInteractiveFormatting,\n\t\tallowedFormats: adjustedAllowedFormats,\n\t} );\n\n\tfunction addEditorOnlyFormats( value ) {\n\t\treturn valueHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tfunction removeEditorOnlyFormats( value ) {\n\t\tformatTypes.forEach( ( formatType ) => {\n\t\t\t// Remove formats created by prepareEditableTree, because they are editor only.\n\t\t\tif ( formatType.__experimentalCreatePrepareEditableTree ) {\n\t\t\t\tvalue = removeFormat(\n\t\t\t\t\tvalue,\n\t\t\t\t\tformatType.name,\n\t\t\t\t\t0,\n\t\t\t\t\tvalue.text.length\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t\treturn value.formats;\n\t}\n\n\tfunction addInvisibleFormats( value ) {\n\t\treturn prepareHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tconst {\n\t\tvalue,\n\t\tgetValue,\n\t\tonChange,\n\t\tref: richTextRef,\n\t} = useRichText( {\n\t\tvalue: adjustedValue,\n\t\tonChange( html, { __unstableFormats, __unstableText } ) {\n\t\t\tadjustedOnChange( html );\n\t\t\tObject.values( changeHandlers ).forEach( ( changeHandler ) => {\n\t\t\t\tchangeHandler( __unstableFormats, __unstableText );\n\t\t\t} );\n\t\t},\n\t\tselectionStart,\n\t\tselectionEnd,\n\t\tonSelectionChange,\n\t\tplaceholder,\n\t\t__unstableIsSelected: isSelected,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tpreserveWhiteSpace,\n\t\t__unstableDependencies: [ ...dependencies, tagName ],\n\t\t__unstableAfterParse: addEditorOnlyFormats,\n\t\t__unstableBeforeSerialize: removeEditorOnlyFormats,\n\t\t__unstableAddInvisibleFormats: addInvisibleFormats,\n\t} );\n\tconst autocompleteProps = useBlockEditorAutocompleteProps( {\n\t\tonReplace,\n\t\tcompleters: autocompleters,\n\t\trecord: value,\n\t\tonChange,\n\t} );\n\n\tuseMarkPersistent( { html: adjustedValue, value } );\n\n\tconst keyboardShortcuts = useRef( new Set() );\n\tconst inputEvents = useRef( new Set() );\n\n\tfunction onFocus() {\n\t\tanchorRef.current?.focus();\n\t}\n\n\tconst TagName = tagName;\n\treturn (\n\t\t<>\n\t\t\t{ isSelected && (\n\t\t\t\t<keyboardShortcutContext.Provider value={ keyboardShortcuts }>\n\t\t\t\t\t<inputEventContext.Provider value={ inputEvents }>\n\t\t\t\t\t\t<Popover.__unstableSlotNameProvider value=\"__unstable-block-tools-after\">\n\t\t\t\t\t\t\t{ children &&\n\t\t\t\t\t\t\t\tchildren( { value, onChange, onFocus } ) }\n\n\t\t\t\t\t\t\t<FormatEdit\n\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\tformatTypes={ formatTypes }\n\t\t\t\t\t\t\t\tforwardedRef={ anchorRef }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Popover.__unstableSlotNameProvider>\n\t\t\t\t\t</inputEventContext.Provider>\n\t\t\t\t</keyboardShortcutContext.Provider>\n\t\t\t) }\n\t\t\t{ isSelected && hasFormats && (\n\t\t\t\t<FormatToolbarContainer\n\t\t\t\t\tinline={ inlineToolbar }\n\t\t\t\t\teditableContentElement={ anchorRef.current }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<TagName\n\t\t\t\t// Overridable props.\n\t\t\t\trole=\"textbox\"\n\t\t\t\taria-multiline={ ! disableLineBreaks }\n\t\t\t\taria-label={ placeholder }\n\t\t\t\taria-readonly={ shouldDisableEditing }\n\t\t\t\t{ ...props }\n\t\t\t\t{ ...autocompleteProps }\n\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\t// Rich text ref must be first because its focus listener\n\t\t\t\t\t// must be set up before any other ref calls .focus() on\n\t\t\t\t\t// mount.\n\t\t\t\t\trichTextRef,\n\t\t\t\t\tforwardedRef,\n\t\t\t\t\tautocompleteProps.ref,\n\t\t\t\t\tprops.ref,\n\t\t\t\t\tuseBeforeInputRules( { value, onChange } ),\n\t\t\t\t\tuseInputRules( {\n\t\t\t\t\t\tgetValue,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\t__unstableAllowPrefixTransformations,\n\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tselectionChange,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseInsertReplacementText(),\n\t\t\t\t\tuseRemoveBrowserShortcuts(),\n\t\t\t\t\tuseShortcuts( keyboardShortcuts ),\n\t\t\t\t\tuseInputEvents( inputEvents ),\n\t\t\t\t\tuseUndoAutomaticChange(),\n\t\t\t\t\tusePasteHandler( {\n\t\t\t\t\t\tisSelected,\n\t\t\t\t\t\tdisableFormats,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\ttagName,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\t__unstableEmbedURLOnPaste,\n\t\t\t\t\t\tpastePlainText,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseDelete( {\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tonMerge,\n\t\t\t\t\t\tonRemove,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseEnter( {\n\t\t\t\t\t\tremoveEditorOnlyFormats,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\tdisableLineBreaks,\n\t\t\t\t\t\tonSplitAtEnd,\n\t\t\t\t\t\tonSplitAtDoubleLineEnd,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseFirefoxCompat(),\n\t\t\t\t\tanchorRef,\n\t\t\t\t] ) }\n\t\t\t\tcontentEditable={ ! shouldDisableEditing }\n\t\t\t\tsuppressContentEditableWarning={ true }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-rich-text__editable',\n\t\t\t\t\tprops.className,\n\t\t\t\t\t'rich-text'\n\t\t\t\t) }\n\t\t\t\t// Setting tabIndex to 0 is unnecessary, the element is already\n\t\t\t\t// focusable because it's contentEditable. This also fixes a\n\t\t\t\t// Safari bug where it's not possible to Shift+Click multi\n\t\t\t\t// select blocks when Shift Clicking into an element with\n\t\t\t\t// tabIndex because Safari will focus the element. However,\n\t\t\t\t// Safari will correctly ignore nested contentEditable elements.\n\t\t\t\ttabIndex={\n\t\t\t\t\tprops.tabIndex === 0 && ! shouldDisableEditing\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: props.tabIndex\n\t\t\t\t}\n\t\t\t\tdata-wp-block-attribute-key={ identifier }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nconst ForwardedRichTextContainer = withDeprecations(\n\tforwardRef( RichTextWrapper )\n);\n\nForwardedRichTextContainer.Content = Content;\nForwardedRichTextContainer.isEmpty = ( value ) => {\n\treturn ! value || value.length === 0;\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md\n */\nexport default ForwardedRichTextContainer;\nexport { RichTextShortcut } from './shortcut';\nexport { RichTextToolbarButton } from './toolbar-button';\nexport { __unstableRichTextInputEvent } from './input-event';\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,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C,SAASE,gBAAgB,QAAQ,YAAY;AAC7C,SAASC,qBAAqB,QAAQ,kBAAkB;AACxD,SAASC,4BAA4B,QAAQ,eAAe"}
|
|
1
|
+
{"version":3,"names":["classnames","useRef","useCallback","forwardRef","createContext","useDispatch","useSelect","useMergeRefs","__unstableUseRichText","useRichText","removeFormat","Popover","getBlockType","store","blocksStore","useBlockEditorAutocompleteProps","useBlockEditContext","blockBindingsKey","FormatToolbarContainer","blockEditorStore","useUndoAutomaticChange","useMarkPersistent","usePasteHandler","useBeforeInputRules","useInputRules","useDelete","useEnter","useFormatTypes","useRemoveBrowserShortcuts","useShortcuts","useInputEvents","useInsertReplacementText","useFirefoxCompat","FormatEdit","getAllowedFormats","Content","withDeprecations","unlock","BLOCK_BINDINGS_ALLOWED_BLOCKS","keyboardShortcutContext","inputEventContext","removeNativeProps","props","__unstableMobileNoFocusOnMount","deleteEnter","placeholderTextColor","textAlign","selectionColor","tagsToEliminate","disableEditingMenu","fontSize","fontFamily","fontWeight","fontStyle","minWidth","maxWidth","setRef","disableSuggestions","disableAutocorrection","restProps","RichTextWrapper","children","tagName","value","adjustedValue","onChange","adjustedOnChange","isSelected","originalIsSelected","multiline","inlineToolbar","wrapperClassName","autocompleters","onReplace","placeholder","allowedFormats","withoutInteractiveFormatting","onRemove","onMerge","onSplit","__unstableOnSplitAtEnd","onSplitAtEnd","__unstableOnSplitAtDoubleLineEnd","onSplitAtDoubleLineEnd","identifier","preserveWhiteSpace","__unstablePastePlainText","pastePlainText","__unstableEmbedURLOnPaste","__unstableDisableFormats","disableFormats","disableLineBreaks","__unstableAllowPrefixTransformations","disableEditing","forwardedRef","anchorRef","context","clientId","isBlockSelected","name","blockName","blockBindings","selector","select","getSelectionStart","getSelectionEnd","selectionStart","selectionEnd","undefined","attributeKey","offset","disableBoundBlocks","_disableBoundBlocks","blockTypeAttributes","attributes","getBlockBindingsSource","attribute","args","Object","entries","source","blockBindingsSource","lockAttributesEditing","shouldDisableEditing","getBlockRootClientId","selectionChange","adjustedAllowedFormats","hasFormats","length","onSelectionChange","start","end","selection","unset","formatTypes","prepareHandlers","valueHandlers","changeHandlers","dependencies","addEditorOnlyFormats","reduce","accumulator","fn","text","formats","removeEditorOnlyFormats","forEach","formatType","__experimentalCreatePrepareEditableTree","addInvisibleFormats","getValue","ref","richTextRef","html","__unstableFormats","__unstableText","values","changeHandler","__unstableIsSelected","__unstableDependencies","__unstableAfterParse","__unstableBeforeSerialize","__unstableAddInvisibleFormats","autocompleteProps","completers","record","keyboardShortcuts","Set","inputEvents","onFocus","current","focus","TagName","createElement","Fragment","Provider","__unstableSlotNameProvider","inline","editableContentElement","role","contentEditable","suppressContentEditableWarning","className","tabIndex","PrivateRichText","isEmpty","PublicForwardedRichTextContainer","RichTextShortcut","RichTextToolbarButton","__unstableRichTextInputEvent"],"sources":["@wordpress/block-editor/src/components/rich-text/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseRef,\n\tuseCallback,\n\tforwardRef,\n\tcreateContext,\n} from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useMergeRefs } from '@wordpress/compose';\nimport {\n\t__unstableUseRichText as useRichText,\n\tremoveFormat,\n} from '@wordpress/rich-text';\nimport { Popover } from '@wordpress/components';\nimport { getBlockType, store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditorAutocompleteProps } from '../autocomplete';\nimport { useBlockEditContext } from '../block-edit';\nimport { blockBindingsKey } from '../block-edit/context';\nimport FormatToolbarContainer from './format-toolbar-container';\nimport { store as blockEditorStore } from '../../store';\nimport { useUndoAutomaticChange } from './use-undo-automatic-change';\nimport { useMarkPersistent } from './use-mark-persistent';\nimport { usePasteHandler } from './use-paste-handler';\nimport { useBeforeInputRules } from './use-before-input-rules';\nimport { useInputRules } from './use-input-rules';\nimport { useDelete } from './use-delete';\nimport { useEnter } from './use-enter';\nimport { useFormatTypes } from './use-format-types';\nimport { useRemoveBrowserShortcuts } from './use-remove-browser-shortcuts';\nimport { useShortcuts } from './use-shortcuts';\nimport { useInputEvents } from './use-input-events';\nimport { useInsertReplacementText } from './use-insert-replacement-text';\nimport { useFirefoxCompat } from './use-firefox-compat';\nimport FormatEdit from './format-edit';\nimport { getAllowedFormats } from './utils';\nimport { Content } from './content';\nimport { withDeprecations } from './with-deprecations';\nimport { unlock } from '../../lock-unlock';\nimport { BLOCK_BINDINGS_ALLOWED_BLOCKS } from '../../hooks/use-bindings-attributes';\n\nexport const keyboardShortcutContext = createContext();\nexport const inputEventContext = createContext();\n\n/**\n * Removes props used for the native version of RichText so that they are not\n * passed to the DOM element and log warnings.\n *\n * @param {Object} props Props to filter.\n *\n * @return {Object} Filtered props.\n */\nfunction removeNativeProps( props ) {\n\tconst {\n\t\t__unstableMobileNoFocusOnMount,\n\t\tdeleteEnter,\n\t\tplaceholderTextColor,\n\t\ttextAlign,\n\t\tselectionColor,\n\t\ttagsToEliminate,\n\t\tdisableEditingMenu,\n\t\tfontSize,\n\t\tfontFamily,\n\t\tfontWeight,\n\t\tfontStyle,\n\t\tminWidth,\n\t\tmaxWidth,\n\t\tsetRef,\n\t\tdisableSuggestions,\n\t\tdisableAutocorrection,\n\t\t...restProps\n\t} = props;\n\treturn restProps;\n}\n\nexport function RichTextWrapper(\n\t{\n\t\tchildren,\n\t\ttagName = 'div',\n\t\tvalue: adjustedValue = '',\n\t\tonChange: adjustedOnChange,\n\t\tisSelected: originalIsSelected,\n\t\tmultiline,\n\t\tinlineToolbar,\n\t\twrapperClassName,\n\t\tautocompleters,\n\t\tonReplace,\n\t\tplaceholder,\n\t\tallowedFormats,\n\t\twithoutInteractiveFormatting,\n\t\tonRemove,\n\t\tonMerge,\n\t\tonSplit,\n\t\t__unstableOnSplitAtEnd: onSplitAtEnd,\n\t\t__unstableOnSplitAtDoubleLineEnd: onSplitAtDoubleLineEnd,\n\t\tidentifier,\n\t\tpreserveWhiteSpace,\n\t\t__unstablePastePlainText: pastePlainText,\n\t\t__unstableEmbedURLOnPaste,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tdisableLineBreaks,\n\t\t__unstableAllowPrefixTransformations,\n\t\tdisableEditing,\n\t\t...props\n\t},\n\tforwardedRef\n) {\n\tprops = removeNativeProps( props );\n\n\tconst anchorRef = useRef();\n\tconst context = useBlockEditContext();\n\tconst { clientId, isSelected: isBlockSelected, name: blockName } = context;\n\tconst blockBindings = context[ blockBindingsKey ];\n\tconst selector = ( select ) => {\n\t\t// Avoid subscribing to the block editor store if the block is not\n\t\t// selected.\n\t\tif ( ! isBlockSelected ) {\n\t\t\treturn { isSelected: false };\n\t\t}\n\n\t\tconst { getSelectionStart, getSelectionEnd } =\n\t\t\tselect( blockEditorStore );\n\t\tconst selectionStart = getSelectionStart();\n\t\tconst selectionEnd = getSelectionEnd();\n\n\t\tlet isSelected;\n\n\t\tif ( originalIsSelected === undefined ) {\n\t\t\tisSelected =\n\t\t\t\tselectionStart.clientId === clientId &&\n\t\t\t\tselectionEnd.clientId === clientId &&\n\t\t\t\tselectionStart.attributeKey === identifier;\n\t\t} else if ( originalIsSelected ) {\n\t\t\tisSelected = selectionStart.clientId === clientId;\n\t\t}\n\n\t\treturn {\n\t\t\tselectionStart: isSelected ? selectionStart.offset : undefined,\n\t\t\tselectionEnd: isSelected ? selectionEnd.offset : undefined,\n\t\t\tisSelected,\n\t\t};\n\t};\n\tconst { selectionStart, selectionEnd, isSelected } = useSelect( selector, [\n\t\tclientId,\n\t\tidentifier,\n\t\toriginalIsSelected,\n\t\tisBlockSelected,\n\t] );\n\n\tconst disableBoundBlocks = useSelect(\n\t\t( select ) => {\n\t\t\t// Disable Rich Text editing if block bindings specify that.\n\t\t\tlet _disableBoundBlocks = false;\n\t\t\tif ( blockBindings && blockName in BLOCK_BINDINGS_ALLOWED_BLOCKS ) {\n\t\t\t\tconst blockTypeAttributes =\n\t\t\t\t\tgetBlockType( blockName ).attributes;\n\t\t\t\tconst { getBlockBindingsSource } = unlock(\n\t\t\t\t\tselect( blocksStore )\n\t\t\t\t);\n\t\t\t\tfor ( const [ attribute, args ] of Object.entries(\n\t\t\t\t\tblockBindings\n\t\t\t\t) ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tblockTypeAttributes?.[ attribute ]?.source !==\n\t\t\t\t\t\t'rich-text'\n\t\t\t\t\t) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\t// If the source is not defined, or if its value of `lockAttributesEditing` is `true`, disable it.\n\t\t\t\t\tconst blockBindingsSource = getBlockBindingsSource(\n\t\t\t\t\t\targs.source\n\t\t\t\t\t);\n\t\t\t\t\tif (\n\t\t\t\t\t\t! blockBindingsSource ||\n\t\t\t\t\t\tblockBindingsSource.lockAttributesEditing\n\t\t\t\t\t) {\n\t\t\t\t\t\t_disableBoundBlocks = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn _disableBoundBlocks;\n\t\t},\n\t\t[ blockBindings, blockName ]\n\t);\n\n\tconst shouldDisableEditing = disableEditing || disableBoundBlocks;\n\n\tconst { getSelectionStart, getSelectionEnd, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\tconst { selectionChange } = useDispatch( blockEditorStore );\n\tconst adjustedAllowedFormats = getAllowedFormats( {\n\t\tallowedFormats,\n\t\tdisableFormats,\n\t} );\n\tconst hasFormats =\n\t\t! adjustedAllowedFormats || adjustedAllowedFormats.length > 0;\n\n\tconst onSelectionChange = useCallback(\n\t\t( start, end ) => {\n\t\t\tconst selection = {};\n\t\t\tconst unset = start === undefined && end === undefined;\n\n\t\t\tif ( typeof start === 'number' || unset ) {\n\t\t\t\t// If we are only setting the start (or the end below), which\n\t\t\t\t// means a partial selection, and we're not updating a selection\n\t\t\t\t// with the same client ID, abort. This means the selected block\n\t\t\t\t// is a parent block.\n\t\t\t\tif (\n\t\t\t\t\tend === undefined &&\n\t\t\t\t\tgetBlockRootClientId( clientId ) !==\n\t\t\t\t\t\tgetBlockRootClientId( getSelectionEnd().clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tselection.start = {\n\t\t\t\t\tclientId,\n\t\t\t\t\tattributeKey: identifier,\n\t\t\t\t\toffset: start,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif ( typeof end === 'number' || unset ) {\n\t\t\t\tif (\n\t\t\t\t\tstart === undefined &&\n\t\t\t\t\tgetBlockRootClientId( clientId ) !==\n\t\t\t\t\t\tgetBlockRootClientId( getSelectionStart().clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tselection.end = {\n\t\t\t\t\tclientId,\n\t\t\t\t\tattributeKey: identifier,\n\t\t\t\t\toffset: end,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tselectionChange( selection );\n\t\t},\n\t\t[ clientId, identifier ]\n\t);\n\n\tconst {\n\t\tformatTypes,\n\t\tprepareHandlers,\n\t\tvalueHandlers,\n\t\tchangeHandlers,\n\t\tdependencies,\n\t} = useFormatTypes( {\n\t\tclientId,\n\t\tidentifier,\n\t\twithoutInteractiveFormatting,\n\t\tallowedFormats: adjustedAllowedFormats,\n\t} );\n\n\tfunction addEditorOnlyFormats( value ) {\n\t\treturn valueHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tfunction removeEditorOnlyFormats( value ) {\n\t\tformatTypes.forEach( ( formatType ) => {\n\t\t\t// Remove formats created by prepareEditableTree, because they are editor only.\n\t\t\tif ( formatType.__experimentalCreatePrepareEditableTree ) {\n\t\t\t\tvalue = removeFormat(\n\t\t\t\t\tvalue,\n\t\t\t\t\tformatType.name,\n\t\t\t\t\t0,\n\t\t\t\t\tvalue.text.length\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t\treturn value.formats;\n\t}\n\n\tfunction addInvisibleFormats( value ) {\n\t\treturn prepareHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tconst {\n\t\tvalue,\n\t\tgetValue,\n\t\tonChange,\n\t\tref: richTextRef,\n\t} = useRichText( {\n\t\tvalue: adjustedValue,\n\t\tonChange( html, { __unstableFormats, __unstableText } ) {\n\t\t\tadjustedOnChange( html );\n\t\t\tObject.values( changeHandlers ).forEach( ( changeHandler ) => {\n\t\t\t\tchangeHandler( __unstableFormats, __unstableText );\n\t\t\t} );\n\t\t},\n\t\tselectionStart,\n\t\tselectionEnd,\n\t\tonSelectionChange,\n\t\tplaceholder,\n\t\t__unstableIsSelected: isSelected,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tpreserveWhiteSpace,\n\t\t__unstableDependencies: [ ...dependencies, tagName ],\n\t\t__unstableAfterParse: addEditorOnlyFormats,\n\t\t__unstableBeforeSerialize: removeEditorOnlyFormats,\n\t\t__unstableAddInvisibleFormats: addInvisibleFormats,\n\t} );\n\tconst autocompleteProps = useBlockEditorAutocompleteProps( {\n\t\tonReplace,\n\t\tcompleters: autocompleters,\n\t\trecord: value,\n\t\tonChange,\n\t} );\n\n\tuseMarkPersistent( { html: adjustedValue, value } );\n\n\tconst keyboardShortcuts = useRef( new Set() );\n\tconst inputEvents = useRef( new Set() );\n\n\tfunction onFocus() {\n\t\tanchorRef.current?.focus();\n\t}\n\n\tconst TagName = tagName;\n\treturn (\n\t\t<>\n\t\t\t{ isSelected && (\n\t\t\t\t<keyboardShortcutContext.Provider value={ keyboardShortcuts }>\n\t\t\t\t\t<inputEventContext.Provider value={ inputEvents }>\n\t\t\t\t\t\t<Popover.__unstableSlotNameProvider value=\"__unstable-block-tools-after\">\n\t\t\t\t\t\t\t{ children &&\n\t\t\t\t\t\t\t\tchildren( { value, onChange, onFocus } ) }\n\n\t\t\t\t\t\t\t<FormatEdit\n\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\tformatTypes={ formatTypes }\n\t\t\t\t\t\t\t\tforwardedRef={ anchorRef }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Popover.__unstableSlotNameProvider>\n\t\t\t\t\t</inputEventContext.Provider>\n\t\t\t\t</keyboardShortcutContext.Provider>\n\t\t\t) }\n\t\t\t{ isSelected && hasFormats && (\n\t\t\t\t<FormatToolbarContainer\n\t\t\t\t\tinline={ inlineToolbar }\n\t\t\t\t\teditableContentElement={ anchorRef.current }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<TagName\n\t\t\t\t// Overridable props.\n\t\t\t\trole=\"textbox\"\n\t\t\t\taria-multiline={ ! disableLineBreaks }\n\t\t\t\taria-label={ placeholder }\n\t\t\t\taria-readonly={ shouldDisableEditing }\n\t\t\t\t{ ...props }\n\t\t\t\t{ ...autocompleteProps }\n\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\t// Rich text ref must be first because its focus listener\n\t\t\t\t\t// must be set up before any other ref calls .focus() on\n\t\t\t\t\t// mount.\n\t\t\t\t\trichTextRef,\n\t\t\t\t\tforwardedRef,\n\t\t\t\t\tautocompleteProps.ref,\n\t\t\t\t\tprops.ref,\n\t\t\t\t\tuseBeforeInputRules( { value, onChange } ),\n\t\t\t\t\tuseInputRules( {\n\t\t\t\t\t\tgetValue,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\t__unstableAllowPrefixTransformations,\n\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tselectionChange,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseInsertReplacementText(),\n\t\t\t\t\tuseRemoveBrowserShortcuts(),\n\t\t\t\t\tuseShortcuts( keyboardShortcuts ),\n\t\t\t\t\tuseInputEvents( inputEvents ),\n\t\t\t\t\tuseUndoAutomaticChange(),\n\t\t\t\t\tusePasteHandler( {\n\t\t\t\t\t\tisSelected,\n\t\t\t\t\t\tdisableFormats,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\ttagName,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\t__unstableEmbedURLOnPaste,\n\t\t\t\t\t\tpastePlainText,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseDelete( {\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tonMerge,\n\t\t\t\t\t\tonRemove,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseEnter( {\n\t\t\t\t\t\tremoveEditorOnlyFormats,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\tdisableLineBreaks,\n\t\t\t\t\t\tonSplitAtEnd,\n\t\t\t\t\t\tonSplitAtDoubleLineEnd,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseFirefoxCompat(),\n\t\t\t\t\tanchorRef,\n\t\t\t\t] ) }\n\t\t\t\tcontentEditable={ ! shouldDisableEditing }\n\t\t\t\tsuppressContentEditableWarning={ true }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-rich-text__editable',\n\t\t\t\t\tprops.className,\n\t\t\t\t\t'rich-text'\n\t\t\t\t) }\n\t\t\t\t// Setting tabIndex to 0 is unnecessary, the element is already\n\t\t\t\t// focusable because it's contentEditable. This also fixes a\n\t\t\t\t// Safari bug where it's not possible to Shift+Click multi\n\t\t\t\t// select blocks when Shift Clicking into an element with\n\t\t\t\t// tabIndex because Safari will focus the element. However,\n\t\t\t\t// Safari will correctly ignore nested contentEditable elements.\n\t\t\t\ttabIndex={\n\t\t\t\t\tprops.tabIndex === 0 && ! shouldDisableEditing\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: props.tabIndex\n\t\t\t\t}\n\t\t\t\tdata-wp-block-attribute-key={ identifier }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\n// This is the private API for the RichText component.\n// It allows access to all props, not just the public ones.\nexport const PrivateRichText = withDeprecations(\n\tforwardRef( RichTextWrapper )\n);\n\nPrivateRichText.Content = Content;\nPrivateRichText.isEmpty = ( value ) => {\n\treturn ! value || value.length === 0;\n};\n\n// This is the public API for the RichText component.\n// We wrap the PrivateRichText component to hide some props from the public API.\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md\n */\nconst PublicForwardedRichTextContainer = forwardRef( ( props, ref ) => {\n\treturn (\n\t\t<PrivateRichText ref={ ref } { ...props } disableEditing={ false } />\n\t);\n} );\n\nPublicForwardedRichTextContainer.Content = Content;\nPublicForwardedRichTextContainer.isEmpty = ( value ) => {\n\treturn ! value || value.length === 0;\n};\n\nexport default PublicForwardedRichTextContainer;\nexport { RichTextShortcut } from './shortcut';\nexport { RichTextToolbarButton } from './toolbar-button';\nexport { __unstableRichTextInputEvent } from './input-event';\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SACCC,MAAM,EACNC,WAAW,EACXC,UAAU,EACVC,aAAa,QACP,oBAAoB;AAC3B,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SACCC,qBAAqB,IAAIC,WAAW,EACpCC,YAAY,QACN,sBAAsB;AAC7B,SAASC,OAAO,QAAQ,uBAAuB;AAC/C,SAASC,YAAY,EAAEC,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;;AAEtE;AACA;AACA;AACA,SAASC,+BAA+B,QAAQ,iBAAiB;AACjE,SAASC,mBAAmB,QAAQ,eAAe;AACnD,SAASC,gBAAgB,QAAQ,uBAAuB;AACxD,OAAOC,sBAAsB,MAAM,4BAA4B;AAC/D,SAASL,KAAK,IAAIM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CAAgC,CAACD,OAAO,GAAK1H,KAAK,IAAM;EACvD,OAAO,CAAEA,KAAK,IAAIA,KAAK,CAACiE,MAAM,KAAK,CAAC;AACrC,CAAC;AAED,eAAe0D,gCAAgC;AAC/C,SAASC,gBAAgB,QAAQ,YAAY;AAC7C,SAASC,qBAAqB,QAAQ,kBAAkB;AACxD,SAASC,4BAA4B,QAAQ,eAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useRef","useRefEffect","ENTER","insert","remove","getBlockTransforms","findTransform","useDispatch","useRegistry","store","blockEditorStore","splitValue","useEnter","props","registry","__unstableMarkAutomaticChange","propsRef","current","element","onKeyDown","event","defaultPrevented","keyCode","removeEditorOnlyFormats","value","onReplace","onSplit","onChange","disableLineBreaks","onSplitAtEnd","onSplitAtDoubleLineEnd","preventDefault","_value","formats","canSplit","transforms","filter","type","transformation","item","regExp","test","text","transform","content","start","end","shiftKey","length","slice","batch","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/rich-text/use-enter.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { ENTER } from '@wordpress/keycodes';\nimport { insert, remove } from '@wordpress/rich-text';\nimport { getBlockTransforms, findTransform } from '@wordpress/blocks';\nimport { useDispatch, useRegistry } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { splitValue } from './split-value';\n\nexport function useEnter( props ) {\n\tconst registry = useRegistry();\n\tconst { __unstableMarkAutomaticChange } = useDispatch( blockEditorStore );\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\treturn useRefEffect( ( element ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode !== ENTER ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tremoveEditorOnlyFormats,\n\t\t\t\tvalue,\n\t\t\t\tonReplace,\n\t\t\t\tonSplit,\n\t\t\t\tonChange,\n\t\t\t\tdisableLineBreaks,\n\t\t\t\tonSplitAtEnd,\n\t\t\t\tonSplitAtDoubleLineEnd,\n\t\t\t} = propsRef.current;\n\n\t\t\tevent.preventDefault();\n\n\t\t\tconst _value = { ...value };\n\t\t\t_value.formats = removeEditorOnlyFormats( value );\n\t\t\tconst canSplit = onReplace && onSplit;\n\n\t\t\tif ( onReplace ) {\n\t\t\t\tconst transforms = getBlockTransforms( 'from' ).filter(\n\t\t\t\t\t( { type } ) => type === 'enter'\n\t\t\t\t);\n\t\t\t\tconst transformation = findTransform( transforms, ( item ) => {\n\t\t\t\t\treturn item.regExp.test( _value.text );\n\t\t\t\t} );\n\n\t\t\t\tif ( transformation ) {\n\t\t\t\t\tonReplace( [\n\t\t\t\t\t\ttransformation.transform( {\n\t\t\t\t\t\t\tcontent: _value.text,\n\t\t\t\t\t\t} ),\n\t\t\t\t\t] );\n\t\t\t\t\t__unstableMarkAutomaticChange();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst { text, start, end } = _value;\n\n\t\t\tif ( event.shiftKey ) {\n\t\t\t\tif ( ! disableLineBreaks ) {\n\t\t\t\t\tonChange( insert( _value, '\\n' ) );\n\t\t\t\t}\n\t\t\t} else if ( canSplit ) {\n\t\t\t\tsplitValue( {\n\t\t\t\t\tvalue: _value,\n\t\t\t\t\tonReplace,\n\t\t\t\t\tonSplit,\n\t\t\t\t} );\n\t\t\t} else if ( onSplitAtEnd && start === end && end === text.length ) {\n\t\t\t\tonSplitAtEnd();\n\t\t\t} else if (\n\t\t\t\t// For some blocks it's desirable to split at the end of the\n\t\t\t\t// block when there are two line breaks at the end of the\n\t\t\t\t// block, so triple Enter exits the block.\n\t\t\t\tonSplitAtDoubleLineEnd &&\n\t\t\t\tstart === end &&\n\t\t\t\tend === text.length &&\n\t\t\t\ttext.slice( -2 ) === '\\n\\n'\n\t\t\t) {\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t_value.start = _value.end - 2;\n\t\t\t\t\tonChange( remove( _value ) );\n\t\t\t\t\tonSplitAtDoubleLineEnd();\n\t\t\t\t} );\n\t\t\t} else if ( ! disableLineBreaks ) {\n\t\t\t\tonChange( insert( _value, '\\n' ) );\n\t\t\t}\n\t\t}\n\n\t\telement.addEventListener( 'keydown', onKeyDown );\n\t\treturn () => {\n\t\t\telement.removeEventListener( 'keydown', onKeyDown );\n\t\t};\n\t}, [] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,KAAK,QAAQ,qBAAqB;AAC3C,SAASC,MAAM,EAAEC,MAAM,QAAQ,sBAAsB;AACrD,SAASC,kBAAkB,EAAEC,aAAa,QAAQ,mBAAmB;AACrE,SAASC,WAAW,EAAEC,WAAW,QAAQ,iBAAiB;;AAE1D;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,UAAU,QAAQ,eAAe;AAE1C,OAAO,SAASC,QAAQA,CAAEC,KAAK,EAAG;EACjC,MAAMC,QAAQ,GAAGN,WAAW,CAAC,CAAC;EAC9B,MAAM;IAAEO;EAA8B,CAAC,GAAGR,WAAW,CAAEG,gBAAiB,CAAC;EACzE,MAAMM,QAAQ,GAAGhB,MAAM,CAAEa,KAAM,CAAC;EAChCG,QAAQ,CAACC,OAAO,GAAGJ,KAAK;EACxB,OAAOZ,YAAY,CAAIiB,OAAO,IAAM;IACnC,SAASC,SAASA,CAAEC,KAAK,EAAG;MAC3B,IAAKA,KAAK,CAACC,gBAAgB,EAAG;QAC7B;MACD;MAEA,
|
|
1
|
+
{"version":3,"names":["useRef","useRefEffect","ENTER","insert","remove","getBlockTransforms","findTransform","useDispatch","useRegistry","store","blockEditorStore","splitValue","useEnter","props","registry","__unstableMarkAutomaticChange","propsRef","current","element","onKeyDown","event","target","contentEditable","defaultPrevented","keyCode","removeEditorOnlyFormats","value","onReplace","onSplit","onChange","disableLineBreaks","onSplitAtEnd","onSplitAtDoubleLineEnd","preventDefault","_value","formats","canSplit","transforms","filter","type","transformation","item","regExp","test","text","transform","content","start","end","shiftKey","length","slice","batch","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/rich-text/use-enter.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { ENTER } from '@wordpress/keycodes';\nimport { insert, remove } from '@wordpress/rich-text';\nimport { getBlockTransforms, findTransform } from '@wordpress/blocks';\nimport { useDispatch, useRegistry } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { splitValue } from './split-value';\n\nexport function useEnter( props ) {\n\tconst registry = useRegistry();\n\tconst { __unstableMarkAutomaticChange } = useDispatch( blockEditorStore );\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\treturn useRefEffect( ( element ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.target.contentEditable !== 'true' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode !== ENTER ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tremoveEditorOnlyFormats,\n\t\t\t\tvalue,\n\t\t\t\tonReplace,\n\t\t\t\tonSplit,\n\t\t\t\tonChange,\n\t\t\t\tdisableLineBreaks,\n\t\t\t\tonSplitAtEnd,\n\t\t\t\tonSplitAtDoubleLineEnd,\n\t\t\t} = propsRef.current;\n\n\t\t\tevent.preventDefault();\n\n\t\t\tconst _value = { ...value };\n\t\t\t_value.formats = removeEditorOnlyFormats( value );\n\t\t\tconst canSplit = onReplace && onSplit;\n\n\t\t\tif ( onReplace ) {\n\t\t\t\tconst transforms = getBlockTransforms( 'from' ).filter(\n\t\t\t\t\t( { type } ) => type === 'enter'\n\t\t\t\t);\n\t\t\t\tconst transformation = findTransform( transforms, ( item ) => {\n\t\t\t\t\treturn item.regExp.test( _value.text );\n\t\t\t\t} );\n\n\t\t\t\tif ( transformation ) {\n\t\t\t\t\tonReplace( [\n\t\t\t\t\t\ttransformation.transform( {\n\t\t\t\t\t\t\tcontent: _value.text,\n\t\t\t\t\t\t} ),\n\t\t\t\t\t] );\n\t\t\t\t\t__unstableMarkAutomaticChange();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst { text, start, end } = _value;\n\n\t\t\tif ( event.shiftKey ) {\n\t\t\t\tif ( ! disableLineBreaks ) {\n\t\t\t\t\tonChange( insert( _value, '\\n' ) );\n\t\t\t\t}\n\t\t\t} else if ( canSplit ) {\n\t\t\t\tsplitValue( {\n\t\t\t\t\tvalue: _value,\n\t\t\t\t\tonReplace,\n\t\t\t\t\tonSplit,\n\t\t\t\t} );\n\t\t\t} else if ( onSplitAtEnd && start === end && end === text.length ) {\n\t\t\t\tonSplitAtEnd();\n\t\t\t} else if (\n\t\t\t\t// For some blocks it's desirable to split at the end of the\n\t\t\t\t// block when there are two line breaks at the end of the\n\t\t\t\t// block, so triple Enter exits the block.\n\t\t\t\tonSplitAtDoubleLineEnd &&\n\t\t\t\tstart === end &&\n\t\t\t\tend === text.length &&\n\t\t\t\ttext.slice( -2 ) === '\\n\\n'\n\t\t\t) {\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t_value.start = _value.end - 2;\n\t\t\t\t\tonChange( remove( _value ) );\n\t\t\t\t\tonSplitAtDoubleLineEnd();\n\t\t\t\t} );\n\t\t\t} else if ( ! disableLineBreaks ) {\n\t\t\t\tonChange( insert( _value, '\\n' ) );\n\t\t\t}\n\t\t}\n\n\t\telement.addEventListener( 'keydown', onKeyDown );\n\t\treturn () => {\n\t\t\telement.removeEventListener( 'keydown',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ACrBlB,MAAM,CAACa,KAAK,GAAGb,MAAM,CAACc,GAAG,GAAG,CAAC;UAC7BnB,QAAQ,CAAEzB,MAAM,CAAE8B,MAAO,CAAE,CAAC;UAC5BF,sBAAsB,CAAC,CAAC;QACzB,CAAE,CAAC;MACJ,CAAC,MAAM,IAAK,CAAEF,iBAAiB,EAAG;QACjCD,QAAQ,CAAE1B,MAAM,CAAE+B,MAAM,EAAE,IAAK,CAAE,CAAC;MACnC;IACD;IAEAhB,OAAO,CAACmC,gBAAgB,CAAE,SAAS,EAAElC,SAAU,CAAC;IAChD,OAAO,MAAM;MACZD,OAAO,CAACoC,mBAAmB,CAAE,SAAS,EAAEnC,SAAU,CAAC;IACpD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR"}
|
|
@@ -28,19 +28,19 @@ function BlockHooksControlPure({
|
|
|
28
28
|
innerBlocksLength
|
|
29
29
|
} = useSelect(select => {
|
|
30
30
|
const {
|
|
31
|
-
|
|
31
|
+
getBlocks,
|
|
32
32
|
getBlockIndex,
|
|
33
33
|
getBlockRootClientId
|
|
34
34
|
} = select(blockEditorStore);
|
|
35
35
|
return {
|
|
36
36
|
blockIndex: getBlockIndex(clientId),
|
|
37
|
-
innerBlocksLength:
|
|
37
|
+
innerBlocksLength: getBlocks(clientId)?.length,
|
|
38
38
|
rootClientId: getBlockRootClientId(clientId)
|
|
39
39
|
};
|
|
40
40
|
}, [clientId]);
|
|
41
41
|
const hookedBlockClientIds = useSelect(select => {
|
|
42
42
|
const {
|
|
43
|
-
|
|
43
|
+
getBlocks,
|
|
44
44
|
getGlobalBlockCount
|
|
45
45
|
} = select(blockEditorStore);
|
|
46
46
|
const _hookedBlockClientIds = hookedBlocksForCurrentBlock.reduce((clientIds, block) => {
|
|
@@ -57,14 +57,14 @@ function BlockHooksControlPure({
|
|
|
57
57
|
// Any of the current block's siblings (with the right block type) qualifies
|
|
58
58
|
// as a hooked block (inserted `before` or `after` the current one), as the block
|
|
59
59
|
// might've been automatically inserted and then moved around a bit by the user.
|
|
60
|
-
candidates =
|
|
60
|
+
candidates = getBlocks(rootClientId);
|
|
61
61
|
break;
|
|
62
62
|
case 'first_child':
|
|
63
63
|
case 'last_child':
|
|
64
64
|
// Any of the current block's child blocks (with the right block type) qualifies
|
|
65
65
|
// as a hooked first or last child block, as the block might've been automatically
|
|
66
66
|
// inserted and then moved around a bit by the user.
|
|
67
|
-
candidates =
|
|
67
|
+
candidates = getBlocks(clientId);
|
|
68
68
|
break;
|
|
69
69
|
}
|
|
70
70
|
const hookedBlock = candidates?.find(candidate => candidate.name === block.name);
|
|
@@ -126,7 +126,9 @@ function BlockHooksControlPure({
|
|
|
126
126
|
className: "block-editor-hooks__block-hooks",
|
|
127
127
|
title: __('Plugins'),
|
|
128
128
|
initialOpen: true
|
|
129
|
-
},
|
|
129
|
+
}, createElement("p", {
|
|
130
|
+
className: "block-editor-hooks__block-hooks-helptext"
|
|
131
|
+
}, __('Manage the inclusion of blocks added automatically by plugins.')), Object.keys(groupedHookedBlocks).map(vendor => {
|
|
130
132
|
return createElement(Fragment, {
|
|
131
133
|
key: vendor
|
|
132
134
|
}, createElement("h3", null, vendor), groupedHookedBlocks[vendor].map(block => {
|