@wordpress/block-editor 12.3.10 → 12.3.11
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/editor-styles/index.js +2 -2
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/global-styles/hooks.js +2 -2
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js +6 -1
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/rich-text/format-edit.js +57 -28
- package/build/components/rich-text/format-edit.js.map +1 -1
- package/build/components/spacing-sizes-control/utils.js +2 -2
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/private-apis.js +4 -1
- package/build/private-apis.js.map +1 -1
- package/build-module/components/editor-styles/index.js +2 -2
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +2 -2
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js +6 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/rich-text/format-edit.js +51 -26
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- package/build-module/components/spacing-sizes-control/utils.js +2 -2
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- package/build-module/private-apis.js +3 -1
- package/build-module/private-apis.js.map +1 -1
- package/package.json +5 -5
- package/src/components/editor-styles/index.js +2 -2
- package/src/components/global-styles/hooks.js +2 -1
- package/src/components/list-view/use-list-view-drop-zone.js +5 -1
- package/src/components/rich-text/format-edit.js +62 -38
- package/src/components/spacing-sizes-control/test/utils.js +9 -1
- package/src/components/spacing-sizes-control/utils.js +2 -2
- package/src/private-apis.js +2 -0
package/build/private-apis.js
CHANGED
|
@@ -43,6 +43,8 @@ var _resolutionTool = _interopRequireDefault(require("./components/resolution-to
|
|
|
43
43
|
|
|
44
44
|
var _reusableBlockRenameHint = _interopRequireWildcard(require("./components/inserter/reusable-block-rename-hint"));
|
|
45
45
|
|
|
46
|
+
var _formatEdit = require("./components/rich-text/format-edit");
|
|
47
|
+
|
|
46
48
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
47
49
|
|
|
48
50
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -74,6 +76,7 @@ exports.privateApis = privateApis;
|
|
|
74
76
|
DimensionsTool: _dimensionsTool.default,
|
|
75
77
|
ResolutionTool: _resolutionTool.default,
|
|
76
78
|
ReusableBlocksRenameHint: _reusableBlockRenameHint.default,
|
|
77
|
-
useReusableBlocksRenameHint: _reusableBlockRenameHint.useReusableBlocksRenameHint
|
|
79
|
+
useReusableBlocksRenameHint: _reusableBlockRenameHint.useReusableBlocksRenameHint,
|
|
80
|
+
usesContextKey: _formatEdit.usesContextKey
|
|
78
81
|
});
|
|
79
82
|
//# sourceMappingURL=private-apis.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/private-apis.js"],"names":["privateApis","globalStyles","ExperimentalBlockEditorProvider","getRichTextValues","PrivateInserter","PrivateListView","ResizableBoxPopover","BlockInfo","useShouldContextualToolbarShow","cleanEmptyObject","useBlockEditingMode","BlockQuickNavigation","LayoutStyle","BlockRemovalWarningModal","useLayoutClasses","useLayoutStyles","DimensionsTool","ResolutionTool","ReusableBlocksRenameHint","useReusableBlocksRenameHint"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/private-apis.js"],"names":["privateApis","globalStyles","ExperimentalBlockEditorProvider","getRichTextValues","PrivateInserter","PrivateListView","ResizableBoxPopover","BlockInfo","useShouldContextualToolbarShow","cleanEmptyObject","useBlockEditingMode","BlockQuickNavigation","LayoutStyle","BlockRemovalWarningModal","useLayoutClasses","useLayoutStyles","DimensionsTool","ResolutionTool","ReusableBlocksRenameHint","useReusableBlocksRenameHint","usesContextKey"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAIA;;;;;;AAxBA;AACA;AACA;;AAwBA;AACA;AACA;AACO,MAAMA,WAAW,GAAG,EAApB;;AACP,sBAAMA,WAAN,EAAmB,EAClB,GAAGC,YADe;AAElBC,EAAAA,+BAA+B,EAA/BA,yCAFkB;AAGlBC,EAAAA,iBAAiB,EAAjBA,oCAHkB;AAIlBC,EAAAA,eAAe,EAAfA,iCAJkB;AAKlBC,EAAAA,eAAe,EAAfA,yBALkB;AAMlBC,EAAAA,mBAAmB,EAAnBA,4BANkB;AAOlBC,EAAAA,SAAS,EAATA,0BAPkB;AAQlBC,EAAAA,8BAA8B,EAA9BA,8DARkB;AASlBC,EAAAA,gBAAgB,EAAhBA,uBATkB;AAUlBC,EAAAA,mBAAmB,EAAnBA,qCAVkB;AAWlBC,EAAAA,oBAAoB,EAApBA,6BAXkB;AAYlBC,EAAAA,WAAW,EAAXA,mBAZkB;AAalBC,EAAAA,wBAAwB,EAAxBA,kDAbkB;AAclBC,EAAAA,gBAAgB,EAAhBA,uBAdkB;AAelBC,EAAAA,eAAe,EAAfA,sBAfkB;AAgBlBC,EAAAA,cAAc,EAAdA,uBAhBkB;AAiBlBC,EAAAA,cAAc,EAAdA,uBAjBkB;AAkBlBC,EAAAA,wBAAwB,EAAxBA,gCAlBkB;AAmBlBC,EAAAA,2BAA2B,EAA3BA,oDAnBkB;AAoBlBC,EAAAA,cAAc,EAAdA;AApBkB,CAAnB","sourcesContent":["/**\n * Internal dependencies\n */\nimport * as globalStyles from './components/global-styles';\nimport { ExperimentalBlockEditorProvider } from './components/provider';\nimport { lock } from './lock-unlock';\nimport { getRichTextValues } from './components/rich-text/get-rich-text-values';\nimport ResizableBoxPopover from './components/resizable-box-popover';\nimport { ComposedPrivateInserter as PrivateInserter } from './components/inserter';\nimport { PrivateListView } from './components/list-view';\nimport BlockInfo from './components/block-info-slot-fill';\nimport { useShouldContextualToolbarShow } from './utils/use-should-contextual-toolbar-show';\nimport { cleanEmptyObject } from './hooks/utils';\nimport { useBlockEditingMode } from './components/block-editing-mode';\nimport BlockQuickNavigation from './components/block-quick-navigation';\nimport { LayoutStyle } from './components/block-list/layout';\nimport { BlockRemovalWarningModal } from './components/block-removal-warning-modal';\nimport { useLayoutClasses, useLayoutStyles } from './hooks';\nimport DimensionsTool from './components/dimensions-tool';\nimport ResolutionTool from './components/resolution-tool';\nimport {\n\tdefault as ReusableBlocksRenameHint,\n\tuseReusableBlocksRenameHint,\n} from './components/inserter/reusable-block-rename-hint';\nimport { usesContextKey } from './components/rich-text/format-edit';\n\n/**\n * Private @wordpress/block-editor APIs.\n */\nexport const privateApis = {};\nlock( privateApis, {\n\t...globalStyles,\n\tExperimentalBlockEditorProvider,\n\tgetRichTextValues,\n\tPrivateInserter,\n\tPrivateListView,\n\tResizableBoxPopover,\n\tBlockInfo,\n\tuseShouldContextualToolbarShow,\n\tcleanEmptyObject,\n\tuseBlockEditingMode,\n\tBlockQuickNavigation,\n\tLayoutStyle,\n\tBlockRemovalWarningModal,\n\tuseLayoutClasses,\n\tuseLayoutStyles,\n\tDimensionsTool,\n\tResolutionTool,\n\tReusableBlocksRenameHint,\n\tuseReusableBlocksRenameHint,\n\tusesContextKey,\n} );\n"]}
|
|
@@ -43,10 +43,10 @@ function useDarkThemeBodyClassName(styles) {
|
|
|
43
43
|
const tempCanvas = ownerDocument.createElement('div');
|
|
44
44
|
tempCanvas.classList.add('editor-styles-wrapper');
|
|
45
45
|
body.appendChild(tempCanvas);
|
|
46
|
-
backgroundColor = defaultView
|
|
46
|
+
backgroundColor = defaultView?.getComputedStyle(tempCanvas, null).getPropertyValue('background-color');
|
|
47
47
|
body.removeChild(tempCanvas);
|
|
48
48
|
} else {
|
|
49
|
-
backgroundColor = defaultView
|
|
49
|
+
backgroundColor = defaultView?.getComputedStyle(canvas, null).getPropertyValue('background-color');
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
const colordBackgroundColor = colord(backgroundColor); // If background is transparent, it should be treated as light color.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/editor-styles/index.js"],"names":["colord","extend","namesPlugin","a11yPlugin","SVG","useCallback","useMemo","transformStyles","EDITOR_STYLES_SELECTOR","useDarkThemeBodyClassName","styles","node","ownerDocument","defaultView","body","canvas","querySelector","backgroundColor","tempCanvas","createElement","classList","add","appendChild","getComputedStyle","getPropertyValue","removeChild","colordBackgroundColor","luminance","alpha","remove","EditorStyles","stylesArray","Object","values","transformedStyles","filter","style","css","transformedSvgs","__unstableType","map","assets","join","index","visibility","position","left","overflow","__html"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,MAAjB,QAA+B,QAA/B;AACA,OAAOC,WAAP,MAAwB,sBAAxB;AACA,OAAOC,UAAP,MAAuB,qBAAvB;AAEA;AACA;AACA;;AACA,SAASC,GAAT,QAAoB,uBAApB;AACA,SAASC,WAAT,EAAsBC,OAAtB,QAAqC,oBAArC;AAEA;AACA;AACA;;AACA,OAAOC,eAAP,MAA4B,8BAA5B;AAEA,MAAMC,sBAAsB,GAAG,wBAA/B;AACAP,MAAM,CAAE,CAAEC,WAAF,EAAeC,UAAf,CAAF,CAAN;;AAEA,SAASM,yBAAT,CAAoCC,MAApC,EAA6C;AAC5C,SAAOL,WAAW,CACfM,IAAF,IAAY;AACX,QAAK,CAAEA,IAAP,EAAc;AACb;AACA;;AAED,UAAM;AAAEC,MAAAA;AAAF,QAAoBD,IAA1B;AACA,UAAM;AAAEE,MAAAA,WAAF;AAAeC,MAAAA;AAAf,QAAwBF,aAA9B;AACA,UAAMG,MAAM,GAAGH,aAAa,CAACI,aAAd,CACdR,sBADc,CAAf;AAIA,QAAIS,eAAJ;;AAEA,QAAK,CAAEF,MAAP,EAAgB;AACf;AACA;AACA;AACA,YAAMG,UAAU,GAAGN,aAAa,CAACO,aAAd,CAA6B,KAA7B,CAAnB;AACAD,MAAAA,UAAU,CAACE,SAAX,CAAqBC,GAArB,CAA0B,uBAA1B;AACAP,MAAAA,IAAI,CAACQ,WAAL,CAAkBJ,UAAlB;AAEAD,MAAAA,eAAe,GAAGJ,WAAW,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/editor-styles/index.js"],"names":["colord","extend","namesPlugin","a11yPlugin","SVG","useCallback","useMemo","transformStyles","EDITOR_STYLES_SELECTOR","useDarkThemeBodyClassName","styles","node","ownerDocument","defaultView","body","canvas","querySelector","backgroundColor","tempCanvas","createElement","classList","add","appendChild","getComputedStyle","getPropertyValue","removeChild","colordBackgroundColor","luminance","alpha","remove","EditorStyles","stylesArray","Object","values","transformedStyles","filter","style","css","transformedSvgs","__unstableType","map","assets","join","index","visibility","position","left","overflow","__html"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,MAAjB,QAA+B,QAA/B;AACA,OAAOC,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AAC,GAJR;AAKC,IAAA,IAAI,EAAC,MALN;AAMC,IAAA,KAAK,EAAG;AACPO,MAAAA,UAAU,EAAE,QADL;AAEPC,MAAAA,QAAQ,EAAE,UAFH;AAGPC,MAAAA,IAAI,EAAE,SAHC;AAIPC,MAAAA,QAAQ,EAAE;AAJH,KANT;AAYC,IAAA,uBAAuB,EAAG;AAAEC,MAAAA,MAAM,EAAEV;AAAV;AAZ3B,IAPD,CADD;AAwBA","sourcesContent":["/**\n * External dependencies\n */\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\nimport a11yPlugin from 'colord/plugins/a11y';\n\n/**\n * WordPress dependencies\n */\nimport { SVG } from '@wordpress/components';\nimport { useCallback, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport transformStyles from '../../utils/transform-styles';\n\nconst EDITOR_STYLES_SELECTOR = '.editor-styles-wrapper';\nextend( [ namesPlugin, a11yPlugin ] );\n\nfunction useDarkThemeBodyClassName( styles ) {\n\treturn useCallback(\n\t\t( node ) => {\n\t\t\tif ( ! node ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView, body } = ownerDocument;\n\t\t\tconst canvas = ownerDocument.querySelector(\n\t\t\t\tEDITOR_STYLES_SELECTOR\n\t\t\t);\n\n\t\t\tlet backgroundColor;\n\n\t\t\tif ( ! canvas ) {\n\t\t\t\t// The real .editor-styles-wrapper element might not exist in the\n\t\t\t\t// DOM, so calculate the background color by creating a fake\n\t\t\t\t// wrapper.\n\t\t\t\tconst tempCanvas = ownerDocument.createElement( 'div' );\n\t\t\t\ttempCanvas.classList.add( 'editor-styles-wrapper' );\n\t\t\t\tbody.appendChild( tempCanvas );\n\n\t\t\t\tbackgroundColor = defaultView\n\t\t\t\t\t?.getComputedStyle( tempCanvas, null )\n\t\t\t\t\t.getPropertyValue( 'background-color' );\n\n\t\t\t\tbody.removeChild( tempCanvas );\n\t\t\t} else {\n\t\t\t\tbackgroundColor = defaultView\n\t\t\t\t\t?.getComputedStyle( canvas, null )\n\t\t\t\t\t.getPropertyValue( 'background-color' );\n\t\t\t}\n\t\t\tconst colordBackgroundColor = colord( backgroundColor );\n\t\t\t// If background is transparent, it should be treated as light color.\n\t\t\tif (\n\t\t\t\tcolordBackgroundColor.luminance() > 0.5 ||\n\t\t\t\tcolordBackgroundColor.alpha() === 0\n\t\t\t) {\n\t\t\t\tbody.classList.remove( 'is-dark-theme' );\n\t\t\t} else {\n\t\t\t\tbody.classList.add( 'is-dark-theme' );\n\t\t\t}\n\t\t},\n\t\t[ styles ]\n\t);\n}\n\nexport default function EditorStyles( { styles } ) {\n\tconst stylesArray = useMemo(\n\t\t() => Object.values( styles ?? [] ),\n\t\t[ styles ]\n\t);\n\tconst transformedStyles = useMemo(\n\t\t() =>\n\t\t\ttransformStyles(\n\t\t\t\tstylesArray.filter( ( style ) => style?.css ),\n\t\t\t\tEDITOR_STYLES_SELECTOR\n\t\t\t),\n\t\t[ stylesArray ]\n\t);\n\n\tconst transformedSvgs = useMemo(\n\t\t() =>\n\t\t\tstylesArray\n\t\t\t\t.filter( ( style ) => style.__unstableType === 'svgs' )\n\t\t\t\t.map( ( style ) => style.assets )\n\t\t\t\t.join( '' ),\n\t\t[ stylesArray ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ /* Use an empty style element to have a document reference,\n\t\t\t but this could be any element. */ }\n\t\t\t<style ref={ useDarkThemeBodyClassName( stylesArray ) } />\n\t\t\t{ transformedStyles.map( ( css, index ) => (\n\t\t\t\t<style key={ index }>{ css }</style>\n\t\t\t) ) }\n\t\t\t<SVG\n\t\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t\tviewBox=\"0 0 0 0\"\n\t\t\t\twidth=\"0\"\n\t\t\t\theight=\"0\"\n\t\t\t\trole=\"none\"\n\t\t\t\tstyle={ {\n\t\t\t\t\tvisibility: 'hidden',\n\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\tleft: '-9999px',\n\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t} }\n\t\t\t\tdangerouslySetInnerHTML={ { __html: transformedSvgs } }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -210,9 +210,9 @@ export function useSettingsForBlockElement(parentSettings, blockName, element) {
|
|
|
210
210
|
};
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
const sides = Array.isArray(supports?.spacing?.[key]) ? supports?.spacing?.[key] : supports?.spacing?.[key]?.sides;
|
|
213
|
+
const sides = Array.isArray(supports?.spacing?.[key]) ? supports?.spacing?.[key] : supports?.spacing?.[key]?.sides; // Check if spacing type is supported before adding sides.
|
|
214
214
|
|
|
215
|
-
if (sides?.length) {
|
|
215
|
+
if (sides?.length && updatedSettings.spacing?.[key]) {
|
|
216
216
|
updatedSettings.spacing = { ...updatedSettings.spacing,
|
|
217
217
|
[key]: { ...updatedSettings.spacing?.[key],
|
|
218
218
|
sides
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/global-styles/hooks.js"],"names":["fastDeepEqual","get","set","useContext","useCallback","useMemo","useSelect","store","blocksStore","_x","getValueFromVariable","getPresetVariableFromValue","GlobalStylesContext","unlock","EMPTY_CONFIG","settings","styles","VALID_SETTINGS","useGlobalStylesReset","user","config","setUserConfig","canReset","useGlobalSetting","propertyPath","blockName","source","configs","appendedBlockPath","appendedPropertyPath","contextualPath","globalPath","sourceKey","settingValue","configToUse","result","forEach","setting","value","setSetting","newValue","currentConfig","newUserConfig","JSON","parse","stringify","useGlobalStyle","path","shouldDecodeEncode","merged","mergedConfig","base","baseConfig","userConfig","appendedPath","finalPath","setStyle","rawResult","useSettingsForBlockElement","parentSettings","element","supportedStyles","supports","select","getSupportedStyles","getBlockType","updatedSettings","includes","typography","fontSizes","customFontSize","fontFamilies","color","text","background","button","heading","link","caption","gradients","customGradient","defaultDuotone","customDuotone","key","textColumns","layout","spacing","sides","Array","isArray","length","dimensions","minHeight","charAt","toUpperCase","slice","border","shadow","useColorsPerOrigin","customColors","palette","custom","themeColors","theme","defaultColors","default","shouldDisplayDefaultColors","defaultPalette","push","name","colors","useGradientsPerOrigin","customGradients","themeGradients","defaultGradients","shouldDisplayDefaultGradients"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAP,MAA0B,qBAA1B;AACA,SAASC,GAAT,EAAcC,GAAd,QAAyB,QAAzB;AAEA;AACA;AACA;;AACA,SAASC,UAAT,EAAqBC,WAArB,EAAkCC,OAAlC,QAAiD,oBAAjD;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SAASC,oBAAT,EAA+BC,0BAA/B,QAAiE,SAAjE;AACA,SAASC,mBAAT,QAAoC,WAApC;AACA,SAASC,MAAT,QAAuB,mBAAvB;AAEA,MAAMC,YAAY,GAAG;AAAEC,EAAAA,QAAQ,EAAE,EAAZ;AAAgBC,EAAAA,MAAM,EAAE;AAAxB,CAArB;AAEA,MAAMC,cAAc,GAAG,CACtB,iBADsB,EAEtB,+BAFsB,EAGtB,cAHsB,EAItB,eAJsB,EAKtB,cALsB,EAMtB,cANsB,EAOtB,gBAPsB,EAQtB,uBARsB,EAStB,kBATsB,EAUtB,cAVsB,EAWtB,eAXsB,EAYtB,cAZsB,EAatB,qBAbsB,EActB,sBAdsB,EAetB,sBAfsB,EAgBtB,wBAhBsB,EAiBtB,sBAjBsB,EAkBtB,eAlBsB,EAmBtB,iBAnBsB,EAoBtB,eApBsB,EAqBtB,YArBsB,EAsBtB,eAtBsB,EAuBtB,YAvBsB,EAwBtB,QAxBsB,EAyBtB,sBAzBsB,EA0BtB,oBA1BsB,EA2BtB,oBA3BsB,EA4BtB,iBA5BsB,EA6BtB,gBA7BsB,EA8BtB,iBA9BsB,EA+BtB,2BA/BsB,EAgCtB,sBAhCsB,EAi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AGlG,QAAQ,EAAEyD,KAAV,EAAiBO,SAAjB,EAA4BwB,KAAnD;AACA,QAAMW,gBAAgB,GAAGnG,QAAQ,EAAEyD,KAAV,EAAiBO,SAAjB,EAA4B0B,OAArD;AACA,QAAMU,6BAA6B,GAAGpG,QAAQ,EAAEyD,KAAV,EAAiB0C,gBAAvD;AAEA,SAAO7G,OAAO,CAAE,MAAM;AACrB,UAAM8B,MAAM,GAAG,EAAf;;AACA,QAAK8E,cAAc,IAAIA,cAAc,CAACvB,MAAtC,EAA+C;AAC9CvD,MAAAA,MAAM,CAACyE,IAAP,CAAa;AACZC,QAAAA,IAAI,EAAEpG,EAAE,CACP,OADO,EAEP,8CAFO,CADI;AAKZsE,QAAAA,SAAS,EAAEkC;AALC,OAAb;AAOA;;AACD,QACCE,6BAA6B,IAC7BD,gBADA,IAEAA,gBAAgB,CAACxB,MAHlB,EAIE;AACDvD,MAAAA,MAAM,CAACyE,IAAP,CAAa;AACZC,QAAAA,IAAI,EAAEpG,EAAE,CACP,SADO,EAEP,8CAFO,CADI;AAKZsE,QAAAA,SAAS,EAAEmC;AALC,OAAb;AAOA;;AACD,QAAKF,eAAe,IAAIA,eAAe,CAACtB,MAAxC,EAAiD;AAChDvD,MAAAA,MAAM,CAACyE,IAAP,CAAa;AACZC,QAAAA,IAAI,EAAEpG,EAAE,CACP,QADO,EAEP,gDAFO,CADI;AAKZsE,QAAAA,SAAS,EAAEiC;AALC,OAAb;AAOA;;AACD,WAAO7E,MAAP;AACA,GAlCa,EAkCX,CACF6E,eADE,EAEFC,cAFE,EAGFC,gBAHE,EAIFC,6BAJE,CAlCW,CAAd;AAwCA","sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\nimport { get, set } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useContext, useCallback, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getValueFromVariable, getPresetVariableFromValue } from './utils';\nimport { GlobalStylesContext } from './context';\nimport { unlock } from '../../lock-unlock';\n\nconst EMPTY_CONFIG = { settings: {}, styles: {} };\n\nconst VALID_SETTINGS = [\n\t'appearanceTools',\n\t'useRootPaddingAwareAlignments',\n\t'border.color',\n\t'border.radius',\n\t'border.style',\n\t'border.width',\n\t'shadow.presets',\n\t'shadow.defaultPresets',\n\t'color.background',\n\t'color.button',\n\t'color.caption',\n\t'color.custom',\n\t'color.customDuotone',\n\t'color.customGradient',\n\t'color.defaultDuotone',\n\t'color.defaultGradients',\n\t'color.defaultPalette',\n\t'color.duotone',\n\t'color.gradients',\n\t'color.heading',\n\t'color.link',\n\t'color.palette',\n\t'color.text',\n\t'custom',\n\t'dimensions.minHeight',\n\t'layout.contentSize',\n\t'layout.definitions',\n\t'layout.wideSize',\n\t'position.fixed',\n\t'position.sticky',\n\t'spacing.customSpacingSize',\n\t'spacing.spacingSizes',\n\t'spacing.spacingScale',\n\t'spacing.blockGap',\n\t'spacing.margin',\n\t'spacing.padding',\n\t'spacing.units',\n\t'typography.fluid',\n\t'typography.customFontSize',\n\t'typography.dropCap',\n\t'typography.fontFamilies',\n\t'typography.fontSizes',\n\t'typography.fontStyle',\n\t'typography.fontWeight',\n\t'typography.letterSpacing',\n\t'typography.lineHeight',\n\t'typography.textColumns',\n\t'typography.textDecoration',\n\t'typography.textTransform',\n];\n\nexport const useGlobalStylesReset = () => {\n\tconst { user: config, setUserConfig } = useContext( GlobalStylesContext );\n\tconst canReset = !! config && ! fastDeepEqual( config, EMPTY_CONFIG );\n\treturn [\n\t\tcanReset,\n\t\tuseCallback(\n\t\t\t() => setUserConfig( () => EMPTY_CONFIG ),\n\t\t\t[ setUserConfig ]\n\t\t),\n\t];\n};\n\nexport function useGlobalSetting( propertyPath, blockName, source = 'all' ) {\n\tconst { setUserConfig, ...configs } = useContext( GlobalStylesContext );\n\n\tconst appendedBlockPath = blockName ? '.blocks.' + blockName : '';\n\tconst appendedPropertyPath = propertyPath ? '.' + propertyPath : '';\n\tconst contextualPath = `settings${ appendedBlockPath }${ appendedPropertyPath }`;\n\tconst globalPath = `settings${ appendedPropertyPath }`;\n\tconst sourceKey = source === 'all' ? 'merged' : source;\n\n\tconst settingValue = useMemo( () => {\n\t\tconst configToUse = configs[ sourceKey ];\n\t\tif ( ! configToUse ) {\n\t\t\tthrow 'Unsupported source';\n\t\t}\n\n\t\tif ( propertyPath ) {\n\t\t\treturn (\n\t\t\t\tget( configToUse, contextualPath ) ??\n\t\t\t\tget( configToUse, globalPath )\n\t\t\t);\n\t\t}\n\n\t\tconst result = {};\n\t\tVALID_SETTINGS.forEach( ( setting ) => {\n\t\t\tconst value =\n\t\t\t\tget(\n\t\t\t\t\tconfigToUse,\n\t\t\t\t\t`settings${ appendedBlockPath }.${ setting }`\n\t\t\t\t) ?? get( configToUse, `settings.${ setting }` );\n\t\t\tif ( value ) {\n\t\t\t\tset( result, setting, value );\n\t\t\t}\n\t\t} );\n\t\treturn result;\n\t}, [\n\t\tconfigs,\n\t\tsourceKey,\n\t\tpropertyPath,\n\t\tcontextualPath,\n\t\tglobalPath,\n\t\tappendedBlockPath,\n\t] );\n\n\tconst setSetting = ( newValue ) => {\n\t\tsetUserConfig( ( currentConfig ) => {\n\t\t\t// Deep clone `currentConfig` to avoid mutating it later.\n\t\t\tconst newUserConfig = JSON.parse( JSON.stringify( currentConfig ) );\n\t\t\tset( newUserConfig, contextualPath, newValue );\n\n\t\t\treturn newUserConfig;\n\t\t} );\n\t};\n\n\treturn [ settingValue, setSetting ];\n}\n\nexport function useGlobalStyle(\n\tpath,\n\tblockName,\n\tsource = 'all',\n\t{ shouldDecodeEncode = true } = {}\n) {\n\tconst {\n\t\tmerged: mergedConfig,\n\t\tbase: baseConfig,\n\t\tuser: userConfig,\n\t\tsetUserConfig,\n\t} = useContext( GlobalStylesContext );\n\tconst appendedPath = path ? '.' + path : '';\n\tconst finalPath = ! blockName\n\t\t? `styles${ appendedPath }`\n\t\t: `styles.blocks.${ blockName }${ appendedPath }`;\n\n\tconst setStyle = ( newValue ) => {\n\t\tsetUserConfig( ( currentConfig ) => {\n\t\t\t// Deep clone `currentConfig` to avoid mutating it later.\n\t\t\tconst newUserConfig = JSON.parse( JSON.stringify( currentConfig ) );\n\t\t\tset(\n\t\t\t\tnewUserConfig,\n\t\t\t\tfinalPath,\n\t\t\t\tshouldDecodeEncode\n\t\t\t\t\t? getPresetVariableFromValue(\n\t\t\t\t\t\t\tmergedConfig.settings,\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tnewValue\n\t\t\t\t\t )\n\t\t\t\t\t: newValue\n\t\t\t);\n\t\t\treturn newUserConfig;\n\t\t} );\n\t};\n\n\tlet rawResult, result;\n\tswitch ( source ) {\n\t\tcase 'all':\n\t\t\trawResult = get( mergedConfig, finalPath );\n\t\t\tresult = shouldDecodeEncode\n\t\t\t\t? getValueFromVariable( mergedConfig, blockName, rawResult )\n\t\t\t\t: rawResult;\n\t\t\tbreak;\n\t\tcase 'user':\n\t\t\trawResult = get( userConfig, finalPath );\n\t\t\tresult = shouldDecodeEncode\n\t\t\t\t? getValueFromVariable( mergedConfig, blockName, rawResult )\n\t\t\t\t: rawResult;\n\t\t\tbreak;\n\t\tcase 'base':\n\t\t\trawResult = get( baseConfig, finalPath );\n\t\t\tresult = shouldDecodeEncode\n\t\t\t\t? getValueFromVariable( baseConfig, blockName, rawResult )\n\t\t\t\t: rawResult;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow 'Unsupported source';\n\t}\n\n\treturn [ result, setStyle ];\n}\n\n/**\n * React hook that overrides a global settings object with block and element specific settings.\n *\n * @param {Object} parentSettings Settings object.\n * @param {blockName?} blockName Block name.\n * @param {element?} element Element name.\n *\n * @return {Object} Merge of settings and supports.\n */\nexport function useSettingsForBlockElement(\n\tparentSettings,\n\tblockName,\n\telement\n) {\n\tconst { supportedStyles, supports } = useSelect(\n\t\t( select ) => {\n\t\t\treturn {\n\t\t\t\tsupportedStyles: unlock(\n\t\t\t\t\tselect( blocksStore )\n\t\t\t\t).getSupportedStyles( blockName, element ),\n\t\t\t\tsupports:\n\t\t\t\t\tselect( blocksStore ).getBlockType( blockName )?.supports,\n\t\t\t};\n\t\t},\n\t\t[ blockName, element ]\n\t);\n\n\treturn useMemo( () => {\n\t\tconst updatedSettings = { ...parentSettings };\n\n\t\tif ( ! supportedStyles.includes( 'fontSize' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\tfontSizes: {},\n\t\t\t\tcustomFontSize: false,\n\t\t\t};\n\t\t}\n\n\t\tif ( ! supportedStyles.includes( 'fontFamily' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\tfontFamilies: {},\n\t\t\t};\n\t\t}\n\n\t\tupdatedSettings.color = {\n\t\t\t...updatedSettings.color,\n\t\t\ttext:\n\t\t\t\tupdatedSettings.color?.text &&\n\t\t\t\tsupportedStyles.includes( 'color' ),\n\t\t\tbackground:\n\t\t\t\tupdatedSettings.color?.background &&\n\t\t\t\t( supportedStyles.includes( 'background' ) ||\n\t\t\t\t\tsupportedStyles.includes( 'backgroundColor' ) ),\n\t\t\tbutton:\n\t\t\t\tupdatedSettings.color?.button &&\n\t\t\t\tsupportedStyles.includes( 'buttonColor' ),\n\t\t\theading:\n\t\t\t\tupdatedSettings.color?.heading &&\n\t\t\t\tsupportedStyles.includes( 'headingColor' ),\n\t\t\tlink:\n\t\t\t\tupdatedSettings.color?.link &&\n\t\t\t\tsupportedStyles.includes( 'linkColor' ),\n\t\t\tcaption:\n\t\t\t\tupdatedSettings.color?.caption &&\n\t\t\t\tsupportedStyles.includes( 'captionColor' ),\n\t\t};\n\n\t\t// Some blocks can enable background colors but disable gradients.\n\t\tif ( ! supportedStyles.includes( 'background' ) ) {\n\t\t\tupdatedSettings.color.gradients = [];\n\t\t\tupdatedSettings.color.customGradient = false;\n\t\t}\n\n\t\t// If filters are not supported by the block/element, disable duotone.\n\t\tif ( ! supportedStyles.includes( 'filter' ) ) {\n\t\t\tupdatedSettings.color.defaultDuotone = false;\n\t\t\tupdatedSettings.color.customDuotone = false;\n\t\t}\n\n\t\t[\n\t\t\t'lineHeight',\n\t\t\t'fontStyle',\n\t\t\t'fontWeight',\n\t\t\t'letterSpacing',\n\t\t\t'textTransform',\n\t\t\t'textDecoration',\n\t\t].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.typography = {\n\t\t\t\t\t...updatedSettings.typography,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t// The column-count style is named text column to reduce confusion with\n\t\t// the columns block and manage expectations from the support.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/33587\n\t\tif ( ! supportedStyles.includes( 'columnCount' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\ttextColumns: false,\n\t\t\t};\n\t\t}\n\n\t\t[ 'contentSize', 'wideSize' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.layout = {\n\t\t\t\t\t...updatedSettings.layout,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'padding', 'margin', 'blockGap' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.spacing = {\n\t\t\t\t\t...updatedSettings.spacing,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst sides = Array.isArray( supports?.spacing?.[ key ] )\n\t\t\t\t? supports?.spacing?.[ key ]\n\t\t\t\t: supports?.spacing?.[ key ]?.sides;\n\t\t\tif ( sides?.length ) {\n\t\t\t\tupdatedSettings.spacing = {\n\t\t\t\t\t...updatedSettings.spacing,\n\t\t\t\t\t[ key ]: {\n\t\t\t\t\t\t...updatedSettings.spacing?.[ key ],\n\t\t\t\t\t\tsides,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\tif ( ! supportedStyles.includes( 'minHeight' ) ) {\n\t\t\tupdatedSettings.dimensions = {\n\t\t\t\t...updatedSettings.dimensions,\n\t\t\t\tminHeight: false,\n\t\t\t};\n\t\t}\n\n\t\t[ 'radius', 'color', 'style', 'width' ].forEach( ( key ) => {\n\t\t\tif (\n\t\t\t\t! supportedStyles.includes(\n\t\t\t\t\t'border' + key.charAt( 0 ).toUpperCase() + key.slice( 1 )\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tupdatedSettings.border = {\n\t\t\t\t\t...updatedSettings.border,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\tupdatedSettings.shadow = supportedStyles.includes( 'shadow' )\n\t\t\t? updatedSettings.shadow\n\t\t\t: false;\n\n\t\treturn updatedSettings;\n\t}, [ parentSettings, supportedStyles, supports ] );\n}\n\nexport function useColorsPerOrigin( settings ) {\n\tconst customColors = settings?.color?.palette?.custom;\n\tconst themeColors = settings?.color?.palette?.theme;\n\tconst defaultColors = settings?.color?.palette?.default;\n\tconst shouldDisplayDefaultColors = settings?.color?.defaultPalette;\n\n\treturn useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeColors && themeColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tcolors: themeColors,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultColors &&\n\t\t\tdefaultColors &&\n\t\t\tdefaultColors.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tcolors: defaultColors,\n\t\t\t} );\n\t\t}\n\t\tif ( customColors && customColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tcolors: customColors,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [\n\t\tcustomColors,\n\t\tthemeColors,\n\t\tdefaultColors,\n\t\tshouldDisplayDefaultColors,\n\t] );\n}\n\nexport function useGradientsPerOrigin( settings ) {\n\tconst customGradients = settings?.color?.gradients?.custom;\n\tconst themeGradients = settings?.color?.gradients?.theme;\n\tconst defaultGradients = settings?.color?.gradients?.default;\n\tconst shouldDisplayDefaultGradients = settings?.color?.defaultGradients;\n\n\treturn useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeGradients && themeGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tgradients: themeGradients,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultGradients &&\n\t\t\tdefaultGradients &&\n\t\t\tdefaultGradients.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tgradients: defaultGradients,\n\t\t\t} );\n\t\t}\n\t\tif ( customGradients && customGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tgradients: customGradients,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [\n\t\tcustomGradients,\n\t\tthemeGradients,\n\t\tdefaultGradients,\n\t\tshouldDisplayDefaultGradients,\n\t] );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/global-styles/hooks.js"],"names":["fastDeepEqual","get","set","useContext","useCallback","useMemo","useSelect","store","blocksStore","_x","getValueFromVariable","getPresetVariableFromValue","GlobalStylesContext","unlock","EMPTY_CONFIG","settings","styles","VALID_SETTINGS","useGlobalStylesReset","user","config","setUserConfig","canReset","useGlobalSetting","propertyPath","blockName","source","configs","appendedBlockPath","appendedPropertyPath","contextualPath","globalPath","sourceKey","settingValue","configToUse","result","forEach","setting","value","setSetting","newValue","currentConfig","newUserConfig","JSON","parse","stringify","useGlobalStyle","path","shouldDecodeEncode","merged","mergedConfig","base","baseConfig","userConfig","appendedPath","finalPath","setStyle","rawResult","useSettingsForBlockElement","parentSettings","element","supportedStyles","supports","select","getSupportedStyles","getBlockType","updatedSettings","includes","typography","fontSizes","customFontSize","fontFamilies","color","text","background","button","heading","link","caption","gradients","customGradient","defaultDuotone","customDuotone","key","textColumns","layout","spacing","sides","Array","isArray","length","dimensions","minHeight","charAt","toUpperCase","slice","border","shadow","useColorsPerOrigin","customColors","palette","custom","themeColors","theme","defaultColors","default","shouldDisplayDefaultColors","defaultPalette","push","name","colors","useGradientsPerOrigin","customGradients","themeGradients","defaultGradients","shouldDisplayDefaultGradients"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAP,MAA0B,qBAA1B;AACA,SAASC,GAAT,EAAcC,GAAd,QAAyB,QAAzB;AAEA;AACA;AACA;;AACA,SAASC,UAAT,EAAqBC,WAArB,EAAkCC,OAAlC,QAAiD,oBAAjD;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SAASC,oBAAT,EAA+BC,0BAA/B,QAAiE,SAAjE;AACA,SAASC,mBAAT,QAAoC,WAApC;AACA,SAASC,MAAT,QAAuB,mBAAvB;AAEA,MAAMC,Y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B,EAIE;AACDvD,MAAAA,MAAM,CAACyE,IAAP,CAAa;AACZC,QAAAA,IAAI,EAAEpG,EAAE,CACP,SADO,EAEP,8CAFO,CADI;AAKZsE,QAAAA,SAAS,EAAEmC;AALC,OAAb;AAOA;;AACD,QAAKF,eAAe,IAAIA,eAAe,CAACtB,MAAxC,EAAiD;AAChDvD,MAAAA,MAAM,CAACyE,IAAP,CAAa;AACZC,QAAAA,IAAI,EAAEpG,EAAE,CACP,QADO,EAEP,gDAFO,CADI;AAKZsE,QAAAA,SAAS,EAAEiC;AALC,OAAb;AAOA;;AACD,WAAO7E,MAAP;AACA,GAlCa,EAkCX,CACF6E,eADE,EAEFC,cAFE,EAGFC,gBAHE,EAIFC,6BAJE,CAlCW,CAAd;AAwCA","sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\nimport { get, set } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useContext, useCallback, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getValueFromVariable, getPresetVariableFromValue } from './utils';\nimport { GlobalStylesContext } from './context';\nimport { unlock } from '../../lock-unlock';\n\nconst EMPTY_CONFIG = { settings: {}, styles: {} };\n\nconst VALID_SETTINGS = [\n\t'appearanceTools',\n\t'useRootPaddingAwareAlignments',\n\t'border.color',\n\t'border.radius',\n\t'border.style',\n\t'border.width',\n\t'shadow.presets',\n\t'shadow.defaultPresets',\n\t'color.background',\n\t'color.button',\n\t'color.caption',\n\t'color.custom',\n\t'color.customDuotone',\n\t'color.customGradient',\n\t'color.defaultDuotone',\n\t'color.defaultGradients',\n\t'color.defaultPalette',\n\t'color.duotone',\n\t'color.gradients',\n\t'color.heading',\n\t'color.link',\n\t'color.palette',\n\t'color.text',\n\t'custom',\n\t'dimensions.minHeight',\n\t'layout.contentSize',\n\t'layout.definitions',\n\t'layout.wideSize',\n\t'position.fixed',\n\t'position.sticky',\n\t'spacing.customSpacingSize',\n\t'spacing.spacingSizes',\n\t'spacing.spacingScale',\n\t'spacing.blockGap',\n\t'spacing.margin',\n\t'spacing.padding',\n\t'spacing.units',\n\t'typography.fluid',\n\t'typography.customFontSize',\n\t'typography.dropCap',\n\t'typography.fontFamilies',\n\t'typography.fontSizes',\n\t'typography.fontStyle',\n\t'typography.fontWeight',\n\t'typography.letterSpacing',\n\t'typography.lineHeight',\n\t'typography.textColumns',\n\t'typography.textDecoration',\n\t'typography.textTransform',\n];\n\nexport const useGlobalStylesReset = () => {\n\tconst { user: config, setUserConfig } = useContext( GlobalStylesContext );\n\tconst canReset = !! config && ! fastDeepEqual( config, EMPTY_CONFIG );\n\treturn [\n\t\tcanReset,\n\t\tuseCallback(\n\t\t\t() => setUserConfig( () => EMPTY_CONFIG ),\n\t\t\t[ setUserConfig ]\n\t\t),\n\t];\n};\n\nexport function useGlobalSetting( propertyPath, blockName, source = 'all' ) {\n\tconst { setUserConfig, ...configs } = useContext( GlobalStylesContext );\n\n\tconst appendedBlockPath = blockName ? '.blocks.' + blockName : '';\n\tconst appendedPropertyPath = propertyPath ? '.' + propertyPath : '';\n\tconst contextualPath = `settings${ appendedBlockPath }${ appendedPropertyPath }`;\n\tconst globalPath = `settings${ appendedPropertyPath }`;\n\tconst sourceKey = source === 'all' ? 'merged' : source;\n\n\tconst settingValue = useMemo( () => {\n\t\tconst configToUse = configs[ sourceKey ];\n\t\tif ( ! configToUse ) {\n\t\t\tthrow 'Unsupported source';\n\t\t}\n\n\t\tif ( propertyPath ) {\n\t\t\treturn (\n\t\t\t\tget( configToUse, contextualPath ) ??\n\t\t\t\tget( configToUse, globalPath )\n\t\t\t);\n\t\t}\n\n\t\tconst result = {};\n\t\tVALID_SETTINGS.forEach( ( setting ) => {\n\t\t\tconst value =\n\t\t\t\tget(\n\t\t\t\t\tconfigToUse,\n\t\t\t\t\t`settings${ appendedBlockPath }.${ setting }`\n\t\t\t\t) ?? get( configToUse, `settings.${ setting }` );\n\t\t\tif ( value ) {\n\t\t\t\tset( result, setting, value );\n\t\t\t}\n\t\t} );\n\t\treturn result;\n\t}, [\n\t\tconfigs,\n\t\tsourceKey,\n\t\tpropertyPath,\n\t\tcontextualPath,\n\t\tglobalPath,\n\t\tappendedBlockPath,\n\t] );\n\n\tconst setSetting = ( newValue ) => {\n\t\tsetUserConfig( ( currentConfig ) => {\n\t\t\t// Deep clone `currentConfig` to avoid mutating it later.\n\t\t\tconst newUserConfig = JSON.parse( JSON.stringify( currentConfig ) );\n\t\t\tset( newUserConfig, contextualPath, newValue );\n\n\t\t\treturn newUserConfig;\n\t\t} );\n\t};\n\n\treturn [ settingValue, setSetting ];\n}\n\nexport function useGlobalStyle(\n\tpath,\n\tblockName,\n\tsource = 'all',\n\t{ shouldDecodeEncode = true } = {}\n) {\n\tconst {\n\t\tmerged: mergedConfig,\n\t\tbase: baseConfig,\n\t\tuser: userConfig,\n\t\tsetUserConfig,\n\t} = useContext( GlobalStylesContext );\n\tconst appendedPath = path ? '.' + path : '';\n\tconst finalPath = ! blockName\n\t\t? `styles${ appendedPath }`\n\t\t: `styles.blocks.${ blockName }${ appendedPath }`;\n\n\tconst setStyle = ( newValue ) => {\n\t\tsetUserConfig( ( currentConfig ) => {\n\t\t\t// Deep clone `currentConfig` to avoid mutating it later.\n\t\t\tconst newUserConfig = JSON.parse( JSON.stringify( currentConfig ) );\n\t\t\tset(\n\t\t\t\tnewUserConfig,\n\t\t\t\tfinalPath,\n\t\t\t\tshouldDecodeEncode\n\t\t\t\t\t? getPresetVariableFromValue(\n\t\t\t\t\t\t\tmergedConfig.settings,\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tnewValue\n\t\t\t\t\t )\n\t\t\t\t\t: newValue\n\t\t\t);\n\t\t\treturn newUserConfig;\n\t\t} );\n\t};\n\n\tlet rawResult, result;\n\tswitch ( source ) {\n\t\tcase 'all':\n\t\t\trawResult = get( mergedConfig, finalPath );\n\t\t\tresult = shouldDecodeEncode\n\t\t\t\t? getValueFromVariable( mergedConfig, blockName, rawResult )\n\t\t\t\t: rawResult;\n\t\t\tbreak;\n\t\tcase 'user':\n\t\t\trawResult = get( userConfig, finalPath );\n\t\t\tresult = shouldDecodeEncode\n\t\t\t\t? getValueFromVariable( mergedConfig, blockName, rawResult )\n\t\t\t\t: rawResult;\n\t\t\tbreak;\n\t\tcase 'base':\n\t\t\trawResult = get( baseConfig, finalPath );\n\t\t\tresult = shouldDecodeEncode\n\t\t\t\t? getValueFromVariable( baseConfig, blockName, rawResult )\n\t\t\t\t: rawResult;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow 'Unsupported source';\n\t}\n\n\treturn [ result, setStyle ];\n}\n\n/**\n * React hook that overrides a global settings object with block and element specific settings.\n *\n * @param {Object} parentSettings Settings object.\n * @param {blockName?} blockName Block name.\n * @param {element?} element Element name.\n *\n * @return {Object} Merge of settings and supports.\n */\nexport function useSettingsForBlockElement(\n\tparentSettings,\n\tblockName,\n\telement\n) {\n\tconst { supportedStyles, supports } = useSelect(\n\t\t( select ) => {\n\t\t\treturn {\n\t\t\t\tsupportedStyles: unlock(\n\t\t\t\t\tselect( blocksStore )\n\t\t\t\t).getSupportedStyles( blockName, element ),\n\t\t\t\tsupports:\n\t\t\t\t\tselect( blocksStore ).getBlockType( blockName )?.supports,\n\t\t\t};\n\t\t},\n\t\t[ blockName, element ]\n\t);\n\n\treturn useMemo( () => {\n\t\tconst updatedSettings = { ...parentSettings };\n\n\t\tif ( ! supportedStyles.includes( 'fontSize' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\tfontSizes: {},\n\t\t\t\tcustomFontSize: false,\n\t\t\t};\n\t\t}\n\n\t\tif ( ! supportedStyles.includes( 'fontFamily' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\tfontFamilies: {},\n\t\t\t};\n\t\t}\n\n\t\tupdatedSettings.color = {\n\t\t\t...updatedSettings.color,\n\t\t\ttext:\n\t\t\t\tupdatedSettings.color?.text &&\n\t\t\t\tsupportedStyles.includes( 'color' ),\n\t\t\tbackground:\n\t\t\t\tupdatedSettings.color?.background &&\n\t\t\t\t( supportedStyles.includes( 'background' ) ||\n\t\t\t\t\tsupportedStyles.includes( 'backgroundColor' ) ),\n\t\t\tbutton:\n\t\t\t\tupdatedSettings.color?.button &&\n\t\t\t\tsupportedStyles.includes( 'buttonColor' ),\n\t\t\theading:\n\t\t\t\tupdatedSettings.color?.heading &&\n\t\t\t\tsupportedStyles.includes( 'headingColor' ),\n\t\t\tlink:\n\t\t\t\tupdatedSettings.color?.link &&\n\t\t\t\tsupportedStyles.includes( 'linkColor' ),\n\t\t\tcaption:\n\t\t\t\tupdatedSettings.color?.caption &&\n\t\t\t\tsupportedStyles.includes( 'captionColor' ),\n\t\t};\n\n\t\t// Some blocks can enable background colors but disable gradients.\n\t\tif ( ! supportedStyles.includes( 'background' ) ) {\n\t\t\tupdatedSettings.color.gradients = [];\n\t\t\tupdatedSettings.color.customGradient = false;\n\t\t}\n\n\t\t// If filters are not supported by the block/element, disable duotone.\n\t\tif ( ! supportedStyles.includes( 'filter' ) ) {\n\t\t\tupdatedSettings.color.defaultDuotone = false;\n\t\t\tupdatedSettings.color.customDuotone = false;\n\t\t}\n\n\t\t[\n\t\t\t'lineHeight',\n\t\t\t'fontStyle',\n\t\t\t'fontWeight',\n\t\t\t'letterSpacing',\n\t\t\t'textTransform',\n\t\t\t'textDecoration',\n\t\t].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.typography = {\n\t\t\t\t\t...updatedSettings.typography,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t// The column-count style is named text column to reduce confusion with\n\t\t// the columns block and manage expectations from the support.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/33587\n\t\tif ( ! supportedStyles.includes( 'columnCount' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\ttextColumns: false,\n\t\t\t};\n\t\t}\n\n\t\t[ 'contentSize', 'wideSize' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.layout = {\n\t\t\t\t\t...updatedSettings.layout,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'padding', 'margin', 'blockGap' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.spacing = {\n\t\t\t\t\t...updatedSettings.spacing,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst sides = Array.isArray( supports?.spacing?.[ key ] )\n\t\t\t\t? supports?.spacing?.[ key ]\n\t\t\t\t: supports?.spacing?.[ key ]?.sides;\n\t\t\t// Check if spacing type is supported before adding sides.\n\t\t\tif ( sides?.length && updatedSettings.spacing?.[ key ] ) {\n\t\t\t\tupdatedSettings.spacing = {\n\t\t\t\t\t...updatedSettings.spacing,\n\t\t\t\t\t[ key ]: {\n\t\t\t\t\t\t...updatedSettings.spacing?.[ key ],\n\t\t\t\t\t\tsides,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\tif ( ! supportedStyles.includes( 'minHeight' ) ) {\n\t\t\tupdatedSettings.dimensions = {\n\t\t\t\t...updatedSettings.dimensions,\n\t\t\t\tminHeight: false,\n\t\t\t};\n\t\t}\n\n\t\t[ 'radius', 'color', 'style', 'width' ].forEach( ( key ) => {\n\t\t\tif (\n\t\t\t\t! supportedStyles.includes(\n\t\t\t\t\t'border' + key.charAt( 0 ).toUpperCase() + key.slice( 1 )\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tupdatedSettings.border = {\n\t\t\t\t\t...updatedSettings.border,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\tupdatedSettings.shadow = supportedStyles.includes( 'shadow' )\n\t\t\t? updatedSettings.shadow\n\t\t\t: false;\n\n\t\treturn updatedSettings;\n\t}, [ parentSettings, supportedStyles, supports ] );\n}\n\nexport function useColorsPerOrigin( settings ) {\n\tconst customColors = settings?.color?.palette?.custom;\n\tconst themeColors = settings?.color?.palette?.theme;\n\tconst defaultColors = settings?.color?.palette?.default;\n\tconst shouldDisplayDefaultColors = settings?.color?.defaultPalette;\n\n\treturn useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeColors && themeColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tcolors: themeColors,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultColors &&\n\t\t\tdefaultColors &&\n\t\t\tdefaultColors.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tcolors: defaultColors,\n\t\t\t} );\n\t\t}\n\t\tif ( customColors && customColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tcolors: customColors,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [\n\t\tcustomColors,\n\t\tthemeColors,\n\t\tdefaultColors,\n\t\tshouldDisplayDefaultColors,\n\t] );\n}\n\nexport function useGradientsPerOrigin( settings ) {\n\tconst customGradients = settings?.color?.gradients?.custom;\n\tconst themeGradients = settings?.color?.gradients?.theme;\n\tconst defaultGradients = settings?.color?.gradients?.default;\n\tconst shouldDisplayDefaultGradients = settings?.color?.defaultGradients;\n\n\treturn useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeGradients && themeGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tgradients: themeGradients,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultGradients &&\n\t\t\tdefaultGradients &&\n\t\t\tdefaultGradients.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tgradients: defaultGradients,\n\t\t\t} );\n\t\t}\n\t\tif ( customGradients && customGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tgradients: customGradients,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [\n\t\tcustomGradients,\n\t\tthemeGradients,\n\t\tdefaultGradients,\n\t\tshouldDisplayDefaultGradients,\n\t] );\n}\n"]}
|
|
@@ -368,7 +368,12 @@ export default function useListViewDropZone({
|
|
|
368
368
|
}, [canInsertBlocks, draggedBlockClientIds, getBlockCount, getBlockIndex, getBlockRootClientId, rtl]), 200);
|
|
369
369
|
const ref = useDropZone({
|
|
370
370
|
dropZoneElement,
|
|
371
|
-
|
|
371
|
+
|
|
372
|
+
onDrop(event) {
|
|
373
|
+
if (target) {
|
|
374
|
+
onBlockDrop(event);
|
|
375
|
+
}
|
|
376
|
+
},
|
|
372
377
|
|
|
373
378
|
onDragLeave() {
|
|
374
379
|
throttled.cancel();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/use-list-view-drop-zone.js"],"names":["useSelect","useState","useCallback","useThrottle","__experimentalUseDropZone","useDropZone","isRTL","getDistanceToNearestEdge","isPointContainedByRect","useOnBlockDrop","store","blockEditorStore","NESTING_LEVEL_INDENTATION","isUpGesture","point","rect","nestingLevel","rtl","blockIndentPosition","right","left","x","getDesiredRelativeParentLevel","distanceBetweenPointAndBlockIndentPosition","desiredParentLevel","Math","round","abs","getCandidateBlockParents","candidateBlockData","blocksData","candidateBlockParents","currentBlockData","push","find","blockData","clientId","rootClientId","getNextNonDraggedBlock","index","nextBlockData","isDraggedBlock","isNestingGesture","isNestingHorizontalGesture","y","bottom","ALLOWED_DROP_EDGES","getListViewDropTarget","position","candidateEdge","candidateDistance","candidateRect","candidateBlockIndex","i","length","element","getBoundingClientRect","distance","edge","isCursorWithinBlock","undefined","indexOf","previousBlockData","isDraggingBelow","canInsertDraggedBlocksAsChild","innerBlockCount","isExpanded","newBlockIndex","blockIndex","dropPosition","nextBlock","currentLevel","nextLevel","desiredRelativeLevel","targetParentIndex","max","min","canInsertDraggedBlocksAsSibling","offset","useListViewDropZone","dropZoneElement","getBlockRootClientId","getBlockIndex","getBlockCount","getDraggedBlockClientIds","canInsertBlocks","target","setTarget","targetRootClientId","targetBlockIndex","onBlockDrop","draggedBlockClientIds","throttled","event","currentTarget","clientX","clientY","isBlockDrag","blockElements","Array","from","querySelectorAll","map","blockElement","dataset","block","expanded","classList","contains","parseInt","getAttribute","newTarget","ref","onDrop","onDragLeave","cancel","onDragOver","onDragEnd"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,QAAT,EAAmBC,WAAnB,QAAsC,oBAAtC;AACA,SACCC,WADD,EAECC,yBAAyB,IAAIC,WAF9B,QAGO,oBAHP;AAIA,SAASC,KAAT,QAAsB,iBAAtB;AAEA;AACA;AACA;;AACA,SACCC,wBADD,EAECC,sBAFD,QAGO,kBAHP;AAIA,OAAOC,cAAP,MAA2B,sBAA3B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA;;AAEA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,YAFe,CAD0B,GAKzC,IAdG;AAeN2B,QAAAA,6BAA6B,EAAEiC,WAAW,GACvCZ,eAAe,CAAEM,qBAAF,EAAyBvD,QAAzB,CADwB,GAEvC;AAjBG,OAAP;AAmBA,KAhCkB,CAAnB;AAkCA,UAAM2E,SAAS,GAAGhE,qBAAqB,CACtCjB,UADsC,EAEtCkB,QAFsC,EAGtC/B,GAHsC,CAAvC;;AAMA,QAAK8F,SAAL,EAAiB;AAChBxB,MAAAA,SAAS,CAAEwB,SAAF,CAAT;AACA;AACD,GApDS,EAqDV,CACC1B,eADD,EAECM,qBAFD,EAGCR,aAHD,EAICD,aAJD,EAKCD,oBALD,EAMChE,GAND,CArDU,CADiB,EA+D5B,GA/D4B,CAA7B;AAkEA,QAAM+F,GAAG,GAAG3G,WAAW,CAAE;AACxB2E,IAAAA,eADwB;AAExBiC,IAAAA,MAAM,EAAEvB,WAFgB;;AAGxBwB,IAAAA,WAAW,GAAG;AACbtB,MAAAA,SAAS,CAACuB,MAAV;AACA5B,MAAAA,SAAS,CAAE,IAAF,CAAT;AACA,KANuB;;AAOxB6B,IAAAA,UAAU,CAAEvB,KAAF,EAAU;AACnB;AACA;AACA;AACAD,MAAAA,SAAS,CAAEC,KAAF,EAASA,KAAK,CAACC,aAAf,CAAT;AACA,KAZuB;;AAaxBuB,IAAAA,SAAS,GAAG;AACXzB,MAAAA,SAAS,CAACuB,MAAV;AACA5B,MAAAA,SAAS,CAAE,IAAF,CAAT;AACA;;AAhBuB,GAAF,CAAvB;AAmBA,SAAO;AAAEyB,IAAAA,GAAF;AAAO1B,IAAAA;AAAP,GAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useState, useCallback } from '@wordpress/element';\nimport {\n\tuseThrottle,\n\t__experimentalUseDropZone as useDropZone,\n} from '@wordpress/compose';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetDistanceToNearestEdge,\n\tisPointContainedByRect,\n} from '../../utils/math';\nimport useOnBlockDrop from '../use-on-block-drop';\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('../../utils/math').WPPoint} WPPoint */\n\n/**\n * The type of a drag event.\n *\n * @typedef {'default'|'file'|'html'} WPDragEventType\n */\n\n/**\n * An object representing data for blocks in the DOM used by drag and drop.\n *\n * @typedef {Object} WPListViewDropZoneBlock\n * @property {string} clientId The client id for the block.\n * @property {string} rootClientId The root client id for the block.\n * @property {number} blockIndex The block's index.\n * @property {Element} element The DOM element representing the block.\n * @property {number} innerBlockCount The number of inner blocks the block has.\n * @property {boolean} isDraggedBlock Whether the block is currently being dragged.\n * @property {boolean} isExpanded Whether the block is expanded in the UI.\n * @property {boolean} canInsertDraggedBlocksAsSibling Whether the dragged block can be a sibling of this block.\n * @property {boolean} canInsertDraggedBlocksAsChild Whether the dragged block can be a child of this block.\n */\n\n/**\n * An array representing data for blocks in the DOM used by drag and drop.\n *\n * @typedef {WPListViewDropZoneBlock[]} WPListViewDropZoneBlocks\n */\n\n/**\n * An object containing details of a drop target.\n *\n * @typedef {Object} WPListViewDropZoneTarget\n * @property {string} blockIndex The insertion index.\n * @property {string} rootClientId The root client id for the block.\n * @property {string|undefined} clientId The client id for the block.\n * @property {'top'|'bottom'|'inside'} dropPosition The position relative to the block that the user is dropping to.\n * 'inside' refers to nesting as an inner block.\n */\n\n// When the indentation level, the corresponding left margin in `style.scss`\n// must be updated as well to ensure the drop zone is aligned with the indentation.\nexport const NESTING_LEVEL_INDENTATION = 28;\n\n/**\n * Determines whether the user is positioning the dragged block to be\n * moved up to a parent level.\n *\n * Determined based on nesting level indentation of the current block.\n *\n * @param {WPPoint} point The point representing the cursor position when dragging.\n * @param {DOMRect} rect The rectangle.\n * @param {number} nestingLevel The nesting level of the block.\n * @param {boolean} rtl Whether the editor is in RTL mode.\n * @return {boolean} Whether the gesture is an upward gesture.\n */\nfunction isUpGesture( point, rect, nestingLevel = 1, rtl = false ) {\n\t// If the block is nested, and the user is dragging to the bottom\n\t// left of the block (or bottom right in RTL languages), then it is an upward gesture.\n\tconst blockIndentPosition = rtl\n\t\t? rect.right - nestingLevel * NESTING_LEVEL_INDENTATION\n\t\t: rect.left + nestingLevel * NESTING_LEVEL_INDENTATION;\n\treturn rtl ? point.x > blockIndentPosition : point.x < blockIndentPosition;\n}\n\n/**\n * Returns how many nesting levels up the user is attempting to drag to.\n *\n * The relative parent level is calculated based on how far\n * the cursor is from the provided nesting level (e.g. of a candidate block\n * that the user is hovering over). The nesting level is considered \"desired\"\n * because it is not guaranteed that the user will be able to drag to the desired level.\n *\n * The returned integer can be used to access an ascending array\n * of parent blocks, where the first item is the block the user\n * is hovering over, and the last item is the root block.\n *\n * @param {WPPoint} point The point representing the cursor position when dragging.\n * @param {DOMRect} rect The rectangle.\n * @param {number} nestingLevel The nesting level of the block.\n * @param {boolean} rtl Whether the editor is in RTL mode.\n * @return {number} The desired relative parent level.\n */\nfunction getDesiredRelativeParentLevel(\n\tpoint,\n\trect,\n\tnestingLevel = 1,\n\trtl = false\n) {\n\t// In RTL languages, the block indent position is from the right edge of the block.\n\t// In LTR languages, the block indent position is from the left edge of the block.\n\tconst blockIndentPosition = rtl\n\t\t? rect.right - nestingLevel * NESTING_LEVEL_INDENTATION\n\t\t: rect.left + nestingLevel * NESTING_LEVEL_INDENTATION;\n\n\tconst distanceBetweenPointAndBlockIndentPosition = rtl\n\t\t? blockIndentPosition - point.x\n\t\t: point.x - blockIndentPosition;\n\n\tconst desiredParentLevel = Math.round(\n\t\tdistanceBetweenPointAndBlockIndentPosition / NESTING_LEVEL_INDENTATION\n\t);\n\n\treturn Math.abs( desiredParentLevel );\n}\n\n/**\n * Returns an array of the parent blocks of the block the user is dropping to.\n *\n * @param {WPListViewDropZoneBlock} candidateBlockData The block the user is dropping to.\n * @param {WPListViewDropZoneBlocks} blocksData Data about the blocks in list view.\n * @return {WPListViewDropZoneBlocks} An array of block parents, including the block the user is dropping to.\n */\nfunction getCandidateBlockParents( candidateBlockData, blocksData ) {\n\tconst candidateBlockParents = [];\n\tlet currentBlockData = candidateBlockData;\n\n\twhile ( currentBlockData ) {\n\t\tcandidateBlockParents.push( { ...currentBlockData } );\n\t\tcurrentBlockData = blocksData.find(\n\t\t\t( blockData ) =>\n\t\t\t\tblockData.clientId === currentBlockData.rootClientId\n\t\t);\n\t}\n\n\treturn candidateBlockParents;\n}\n\n/**\n * Given a list of blocks data and a block index, return the next non-dragged\n * block. This is used to determine the block that the user is dropping to,\n * while ignoring the dragged block.\n *\n * @param {WPListViewDropZoneBlocks} blocksData Data about the blocks in list view.\n * @param {number} index The index to begin searching from.\n * @return {WPListViewDropZoneBlock | undefined} The next non-dragged block.\n */\nfunction getNextNonDraggedBlock( blocksData, index ) {\n\tconst nextBlockData = blocksData[ index + 1 ];\n\tif ( nextBlockData && nextBlockData.isDraggedBlock ) {\n\t\treturn getNextNonDraggedBlock( blocksData, index + 1 );\n\t}\n\n\treturn nextBlockData;\n}\n\n/**\n * Determines whether the user positioning the dragged block to nest as an\n * inner block.\n *\n * Determined based on nesting level indentation of the current block, plus\n * the indentation of the next level of nesting. The vertical position of the\n * cursor must also be within the block.\n *\n * @param {WPPoint} point The point representing the cursor position when dragging.\n * @param {DOMRect} rect The rectangle.\n * @param {number} nestingLevel The nesting level of the block.\n * @param {boolean} rtl Whether the editor is in RTL mode.\n */\nfunction isNestingGesture( point, rect, nestingLevel = 1, rtl = false ) {\n\tconst blockIndentPosition = rtl\n\t\t? rect.right - nestingLevel * NESTING_LEVEL_INDENTATION\n\t\t: rect.left + nestingLevel * NESTING_LEVEL_INDENTATION;\n\n\tconst isNestingHorizontalGesture = rtl\n\t\t? point.x < blockIndentPosition - NESTING_LEVEL_INDENTATION\n\t\t: point.x > blockIndentPosition + NESTING_LEVEL_INDENTATION;\n\n\treturn isNestingHorizontalGesture && point.y < rect.bottom;\n}\n\n// Block navigation is always a vertical list, so only allow dropping\n// to the above or below a block.\nconst ALLOWED_DROP_EDGES = [ 'top', 'bottom' ];\n\n/**\n * Given blocks data and the cursor position, compute the drop target.\n *\n * @param {WPListViewDropZoneBlocks} blocksData Data about the blocks in list view.\n * @param {WPPoint} position The point representing the cursor position when dragging.\n * @param {boolean} rtl Whether the editor is in RTL mode.\n *\n * @return {WPListViewDropZoneTarget | undefined} An object containing data about the drop target.\n */\nexport function getListViewDropTarget( blocksData, position, rtl = false ) {\n\tlet candidateEdge;\n\tlet candidateBlockData;\n\tlet candidateDistance;\n\tlet candidateRect;\n\tlet candidateBlockIndex;\n\n\tfor ( let i = 0; i < blocksData.length; i++ ) {\n\t\tconst blockData = blocksData[ i ];\n\t\tif ( blockData.isDraggedBlock ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst rect = blockData.element.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge(\n\t\t\tposition,\n\t\t\trect,\n\t\t\tALLOWED_DROP_EDGES\n\t\t);\n\n\t\tconst isCursorWithinBlock = isPointContainedByRect( position, rect );\n\t\tif (\n\t\t\tcandidateDistance === undefined ||\n\t\t\tdistance < candidateDistance ||\n\t\t\tisCursorWithinBlock\n\t\t) {\n\t\t\tcandidateDistance = distance;\n\n\t\t\tconst index = blocksData.indexOf( blockData );\n\t\t\tconst previousBlockData = blocksData[ index - 1 ];\n\n\t\t\t// If dragging near the top of a block and the preceding block\n\t\t\t// is at the same level, use the preceding block as the candidate\n\t\t\t// instead, as later it makes determining a nesting drop easier.\n\t\t\tif (\n\t\t\t\tedge === 'top' &&\n\t\t\t\tpreviousBlockData &&\n\t\t\t\tpreviousBlockData.rootClientId === blockData.rootClientId &&\n\t\t\t\t! previousBlockData.isDraggedBlock\n\t\t\t) {\n\t\t\t\tcandidateBlockData = previousBlockData;\n\t\t\t\tcandidateEdge = 'bottom';\n\t\t\t\tcandidateRect =\n\t\t\t\t\tpreviousBlockData.element.getBoundingClientRect();\n\t\t\t\tcandidateBlockIndex = index - 1;\n\t\t\t} else {\n\t\t\t\tcandidateBlockData = blockData;\n\t\t\t\tcandidateEdge = edge;\n\t\t\t\tcandidateRect = rect;\n\t\t\t\tcandidateBlockIndex = index;\n\t\t\t}\n\n\t\t\t// If the mouse position is within the block, break early\n\t\t\t// as the user would intend to drop either before or after\n\t\t\t// this block.\n\t\t\t//\n\t\t\t// This solves an issue where some rows in the list view\n\t\t\t// tree overlap slightly due to sub-pixel rendering.\n\t\t\tif ( isCursorWithinBlock ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( ! candidateBlockData ) {\n\t\treturn;\n\t}\n\n\tconst candidateBlockParents = getCandidateBlockParents(\n\t\tcandidateBlockData,\n\t\tblocksData\n\t);\n\n\tconst isDraggingBelow = candidateEdge === 'bottom';\n\n\t// If the user is dragging towards the bottom of the block check whether\n\t// they might be trying to nest the block as a child.\n\t// If the block already has inner blocks, and is expanded, this should be treated\n\t// as nesting since the next block in the tree will be the first child.\n\t// However, if the block is collapsed, dragging beneath the block should\n\t// still be allowed, as the next visible block in the tree will be a sibling.\n\tif (\n\t\tisDraggingBelow &&\n\t\tcandidateBlockData.canInsertDraggedBlocksAsChild &&\n\t\t( ( candidateBlockData.innerBlockCount > 0 &&\n\t\t\tcandidateBlockData.isExpanded ) ||\n\t\t\tisNestingGesture(\n\t\t\t\tposition,\n\t\t\t\tcandidateRect,\n\t\t\t\tcandidateBlockParents.length,\n\t\t\t\trtl\n\t\t\t) )\n\t) {\n\t\t// If the block is expanded, insert the block as the first child.\n\t\t// Otherwise, for collapsed blocks, insert the block as the last child.\n\t\tconst newBlockIndex = candidateBlockData.isExpanded\n\t\t\t? 0\n\t\t\t: candidateBlockData.innerBlockCount || 0;\n\n\t\treturn {\n\t\t\trootClientId: candidateBlockData.clientId,\n\t\t\tblockIndex: newBlockIndex,\n\t\t\tdropPosition: 'inside',\n\t\t};\n\t}\n\n\t// If the user is dragging towards the bottom of the block check whether\n\t// they might be trying to move the block to be at a parent level.\n\tif (\n\t\tisDraggingBelow &&\n\t\tcandidateBlockData.rootClientId &&\n\t\tisUpGesture(\n\t\t\tposition,\n\t\t\tcandidateRect,\n\t\t\tcandidateBlockParents.length,\n\t\t\trtl\n\t\t)\n\t) {\n\t\tconst nextBlock = getNextNonDraggedBlock(\n\t\t\tblocksData,\n\t\t\tcandidateBlockIndex\n\t\t);\n\t\tconst currentLevel = candidateBlockData.nestingLevel;\n\t\tconst nextLevel = nextBlock ? nextBlock.nestingLevel : 1;\n\n\t\tif ( currentLevel && nextLevel ) {\n\t\t\t// Determine the desired relative level of the block to be dropped.\n\t\t\tconst desiredRelativeLevel = getDesiredRelativeParentLevel(\n\t\t\t\tposition,\n\t\t\t\tcandidateRect,\n\t\t\t\tcandidateBlockParents.length,\n\t\t\t\trtl\n\t\t\t);\n\n\t\t\tconst targetParentIndex = Math.max(\n\t\t\t\tMath.min( desiredRelativeLevel, currentLevel - nextLevel ),\n\t\t\t\t0\n\t\t\t);\n\n\t\t\tif ( candidateBlockParents[ targetParentIndex ] ) {\n\t\t\t\t// Default to the block index of the candidate block.\n\t\t\t\tlet newBlockIndex = candidateBlockData.blockIndex;\n\n\t\t\t\t// If the next block is at the same level, use that as the default\n\t\t\t\t// block index. This ensures that the block is dropped in the correct\n\t\t\t\t// position when dragging to the bottom of a block.\n\t\t\t\tif (\n\t\t\t\t\tcandidateBlockParents[ targetParentIndex ].nestingLevel ===\n\t\t\t\t\tnextBlock?.nestingLevel\n\t\t\t\t) {\n\t\t\t\t\tnewBlockIndex = nextBlock?.blockIndex;\n\t\t\t\t} else {\n\t\t\t\t\t// Otherwise, search from the current block index back\n\t\t\t\t\t// to find the last block index within the same target parent.\n\t\t\t\t\tfor ( let i = candidateBlockIndex; i >= 0; i-- ) {\n\t\t\t\t\t\tconst blockData = blocksData[ i ];\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tblockData.rootClientId ===\n\t\t\t\t\t\t\tcandidateBlockParents[ targetParentIndex ]\n\t\t\t\t\t\t\t\t.rootClientId\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tnewBlockIndex = blockData.blockIndex + 1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\trootClientId:\n\t\t\t\t\t\tcandidateBlockParents[ targetParentIndex ].rootClientId,\n\t\t\t\t\tclientId: candidateBlockData.clientId,\n\t\t\t\t\tblockIndex: newBlockIndex,\n\t\t\t\t\tdropPosition: candidateEdge,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t}\n\n\t// If dropping as a sibling, but block cannot be inserted in\n\t// this context, return early.\n\tif ( ! candidateBlockData.canInsertDraggedBlocksAsSibling ) {\n\t\treturn;\n\t}\n\n\tconst offset = isDraggingBelow ? 1 : 0;\n\treturn {\n\t\trootClientId: candidateBlockData.rootClientId,\n\t\tclientId: candidateBlockData.clientId,\n\t\tblockIndex: candidateBlockData.blockIndex + offset,\n\t\tdropPosition: candidateEdge,\n\t};\n}\n\n/**\n * A react hook for implementing a drop zone in list view.\n *\n * @param {Object} props Named parameters.\n * @param {?HTMLElement} [props.dropZoneElement] Optional element to be used as the drop zone.\n *\n * @return {WPListViewDropZoneTarget} The drop target.\n */\nexport default function useListViewDropZone( { dropZoneElement } ) {\n\tconst {\n\t\tgetBlockRootClientId,\n\t\tgetBlockIndex,\n\t\tgetBlockCount,\n\t\tgetDraggedBlockClientIds,\n\t\tcanInsertBlocks,\n\t} = useSelect( blockEditorStore );\n\tconst [ target, setTarget ] = useState();\n\tconst { rootClientId: targetRootClientId, blockIndex: targetBlockIndex } =\n\t\ttarget || {};\n\n\tconst onBlockDrop = useOnBlockDrop( targetRootClientId, targetBlockIndex );\n\n\tconst rtl = isRTL();\n\n\tconst draggedBlockClientIds = getDraggedBlockClientIds();\n\tconst throttled = useThrottle(\n\t\tuseCallback(\n\t\t\t( event, currentTarget ) => {\n\t\t\t\tconst position = { x: event.clientX, y: event.clientY };\n\t\t\t\tconst isBlockDrag = !! draggedBlockClientIds?.length;\n\n\t\t\t\tconst blockElements = Array.from(\n\t\t\t\t\tcurrentTarget.querySelectorAll( '[data-block]' )\n\t\t\t\t);\n\n\t\t\t\tconst blocksData = blockElements.map( ( blockElement ) => {\n\t\t\t\t\tconst clientId = blockElement.dataset.block;\n\t\t\t\t\tconst isExpanded = blockElement.dataset.expanded === 'true';\n\t\t\t\t\tconst isDraggedBlock =\n\t\t\t\t\t\tblockElement.classList.contains( 'is-dragging' );\n\n\t\t\t\t\t// Get nesting level from `aria-level` attribute because Firefox does not support `element.ariaLevel`.\n\t\t\t\t\tconst nestingLevel = parseInt(\n\t\t\t\t\t\tblockElement.getAttribute( 'aria-level' ),\n\t\t\t\t\t\t10\n\t\t\t\t\t);\n\t\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\tisExpanded,\n\t\t\t\t\t\trootClientId,\n\t\t\t\t\t\tblockIndex: getBlockIndex( clientId ),\n\t\t\t\t\t\telement: blockElement,\n\t\t\t\t\t\tnestingLevel: nestingLevel || undefined,\n\t\t\t\t\t\tisDraggedBlock: isBlockDrag ? isDraggedBlock : false,\n\t\t\t\t\t\tinnerBlockCount: getBlockCount( clientId ),\n\t\t\t\t\t\tcanInsertDraggedBlocksAsSibling: isBlockDrag\n\t\t\t\t\t\t\t? canInsertBlocks(\n\t\t\t\t\t\t\t\t\tdraggedBlockClientIds,\n\t\t\t\t\t\t\t\t\trootClientId\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: true,\n\t\t\t\t\t\tcanInsertDraggedBlocksAsChild: isBlockDrag\n\t\t\t\t\t\t\t? canInsertBlocks( draggedBlockClientIds, clientId )\n\t\t\t\t\t\t\t: true,\n\t\t\t\t\t};\n\t\t\t\t} );\n\n\t\t\t\tconst newTarget = getListViewDropTarget(\n\t\t\t\t\tblocksData,\n\t\t\t\t\tposition,\n\t\t\t\t\trtl\n\t\t\t\t);\n\n\t\t\t\tif ( newTarget ) {\n\t\t\t\t\tsetTarget( newTarget );\n\t\t\t\t}\n\t\t\t},\n\t\t\t[\n\t\t\t\tcanInsertBlocks,\n\t\t\t\tdraggedBlockClientIds,\n\t\t\t\tgetBlockCount,\n\t\t\t\tgetBlockIndex,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\trtl,\n\t\t\t]\n\t\t),\n\t\t200\n\t);\n\n\tconst ref = useDropZone( {\n\t\tdropZoneElement,\n\t\tonDrop: onBlockDrop,\n\t\tonDragLeave() {\n\t\t\tthrottled.cancel();\n\t\t\tsetTarget( null );\n\t\t},\n\t\tonDragOver( event ) {\n\t\t\t// `currentTarget` is only available while the event is being\n\t\t\t// handled, so get it now and pass it to the thottled function.\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget\n\t\t\tthrottled( event, event.currentTarget );\n\t\t},\n\t\tonDragEnd() {\n\t\t\tthrottled.cancel();\n\t\t\tsetTarget( null );\n\t\t},\n\t} );\n\n\treturn { ref, target };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/use-list-view-drop-zone.js"],"names":["useSelect","useState","useCallback","useThrottle","__experimentalUseDropZone","useDropZone","isRTL","getDistanceToNearestEdge","isPointContainedByRect","useOnBlockDrop","store","blockEditorStore","NESTING_LEVEL_INDENTATION","isUpGesture","point","rect","nestingLevel","rtl","blockIndentPosition","right","left","x","getDesiredRelativeParentLevel","distanceBetweenPointAndBlockIndentPosition","desiredParentLevel","Math","round","abs","getCandidateBlockParents","candidateBlockData","blocksData","candidateBlockParents","currentBlockData","push","find","blockData","clientId","rootClientId","getNextNonDraggedBlock","index","nextBlockData","isDraggedBlock","isNestingGesture","isNestingHorizontalGesture","y","bottom","ALLOWED_DROP_EDGES","getListViewDropTarget","position","candidateEdge","candidateDistance","candidateRect","candidateBlockIndex","i","length","element","getBoundingClientRect","distance","edge","isCursorWithinBlock","undefined","indexOf","previousBlockData","isDraggingBelow","canInsertDraggedBlocksAsChild","innerBlockCount","isExpanded","newBlockIndex","blockIndex","dropPosition","nextBlock","currentLevel","nextLevel","desiredRelativeLevel","targetParentIndex","max","min","canInsertDraggedBlocksAsSibling","offset","useListViewDropZone","dropZoneElement","getBlockRootClientId","getBlockIndex","getBlockCount","getDraggedBlockClientIds","canInsertBlocks","target","setTarget","targetRootClientId","targetBlockIndex","onBlockDrop","draggedBlockClientIds","throttled","event","currentTarget","clientX","clientY","isBlockDrag","blockElements","Array","from","querySelectorAll","map","blockElement","dataset","block","expanded","classList","contains","parseInt","getAttribute","newTarget","ref","onDrop","onDragLeave","cancel","onDragOver","onDragEnd"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,QAAT,EAAmBC,WAAnB,QAAsC,oBAAtC;AACA,SACCC,WADD,EAECC,yBAAyB,IAAIC,WAF9B,QAGO,oBAHP;AAIA,SAASC,KAAT,QAAsB,iBAAtB;AAEA;AACA;AACA;;AACA,SACCC,wBADD,EAECC,sBAFD,QAGO,kBAHP;AAIA,OAAOC,cAAP,MAA2B,sBAA3B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;;AACA,OAAO,MAAMC,yBAAyB,GAAG,EAAlC;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,WAAT,CAAsBC,KAAtB,EAA6BC,IAA7B,EAAmCC,YAAY,GAAG,CAAlD,EAAqDC,GAAG,GAAG,KAA3D,EAAmE;AAClE;AACA;AACA,QAAMC,mBAAmB,GAAGD,GAAG,GAC5BF,IAAI,CAACI,KAAL,GAAaH,YAAY,GAAGJ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,GAAG3G,WAAW,CAAE;AACxB2E,IAAAA,eADwB;;AAExBiC,IAAAA,MAAM,CAAEpB,KAAF,EAAU;AACf,UAAKP,MAAL,EAAc;AACbI,QAAAA,WAAW,CAAEG,KAAF,CAAX;AACA;AACD,KANuB;;AAOxBqB,IAAAA,WAAW,GAAG;AACbtB,MAAAA,SAAS,CAACuB,MAAV;AACA5B,MAAAA,SAAS,CAAE,IAAF,CAAT;AACA,KAVuB;;AAWxB6B,IAAAA,UAAU,CAAEvB,KAAF,EAAU;AACnB;AACA;AACA;AACAD,MAAAA,SAAS,CAAEC,KAAF,EAASA,KAAK,CAACC,aAAf,CAAT;AACA,KAhBuB;;AAiBxBuB,IAAAA,SAAS,GAAG;AACXzB,MAAAA,SAAS,CAACuB,MAAV;AACA5B,MAAAA,SAAS,CAAE,IAAF,CAAT;AACA;;AApBuB,GAAF,CAAvB;AAuBA,SAAO;AAAEyB,IAAAA,GAAF;AAAO1B,IAAAA;AAAP,GAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useState, useCallback } from '@wordpress/element';\nimport {\n\tuseThrottle,\n\t__experimentalUseDropZone as useDropZone,\n} from '@wordpress/compose';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetDistanceToNearestEdge,\n\tisPointContainedByRect,\n} from '../../utils/math';\nimport useOnBlockDrop from '../use-on-block-drop';\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('../../utils/math').WPPoint} WPPoint */\n\n/**\n * The type of a drag event.\n *\n * @typedef {'default'|'file'|'html'} WPDragEventType\n */\n\n/**\n * An object representing data for blocks in the DOM used by drag and drop.\n *\n * @typedef {Object} WPListViewDropZoneBlock\n * @property {string} clientId The client id for the block.\n * @property {string} rootClientId The root client id for the block.\n * @property {number} blockIndex The block's index.\n * @property {Element} element The DOM element representing the block.\n * @property {number} innerBlockCount The number of inner blocks the block has.\n * @property {boolean} isDraggedBlock Whether the block is currently being dragged.\n * @property {boolean} isExpanded Whether the block is expanded in the UI.\n * @property {boolean} canInsertDraggedBlocksAsSibling Whether the dragged block can be a sibling of this block.\n * @property {boolean} canInsertDraggedBlocksAsChild Whether the dragged block can be a child of this block.\n */\n\n/**\n * An array representing data for blocks in the DOM used by drag and drop.\n *\n * @typedef {WPListViewDropZoneBlock[]} WPListViewDropZoneBlocks\n */\n\n/**\n * An object containing details of a drop target.\n *\n * @typedef {Object} WPListViewDropZoneTarget\n * @property {string} blockIndex The insertion index.\n * @property {string} rootClientId The root client id for the block.\n * @property {string|undefined} clientId The client id for the block.\n * @property {'top'|'bottom'|'inside'} dropPosition The position relative to the block that the user is dropping to.\n * 'inside' refers to nesting as an inner block.\n */\n\n// When the indentation level, the corresponding left margin in `style.scss`\n// must be updated as well to ensure the drop zone is aligned with the indentation.\nexport const NESTING_LEVEL_INDENTATION = 28;\n\n/**\n * Determines whether the user is positioning the dragged block to be\n * moved up to a parent level.\n *\n * Determined based on nesting level indentation of the current block.\n *\n * @param {WPPoint} point The point representing the cursor position when dragging.\n * @param {DOMRect} rect The rectangle.\n * @param {number} nestingLevel The nesting level of the block.\n * @param {boolean} rtl Whether the editor is in RTL mode.\n * @return {boolean} Whether the gesture is an upward gesture.\n */\nfunction isUpGesture( point, rect, nestingLevel = 1, rtl = false ) {\n\t// If the block is nested, and the user is dragging to the bottom\n\t// left of the block (or bottom right in RTL languages), then it is an upward gesture.\n\tconst blockIndentPosition = rtl\n\t\t? rect.right - nestingLevel * NESTING_LEVEL_INDENTATION\n\t\t: rect.left + nestingLevel * NESTING_LEVEL_INDENTATION;\n\treturn rtl ? point.x > blockIndentPosition : point.x < blockIndentPosition;\n}\n\n/**\n * Returns how many nesting levels up the user is attempting to drag to.\n *\n * The relative parent level is calculated based on how far\n * the cursor is from the provided nesting level (e.g. of a candidate block\n * that the user is hovering over). The nesting level is considered \"desired\"\n * because it is not guaranteed that the user will be able to drag to the desired level.\n *\n * The returned integer can be used to access an ascending array\n * of parent blocks, where the first item is the block the user\n * is hovering over, and the last item is the root block.\n *\n * @param {WPPoint} point The point representing the cursor position when dragging.\n * @param {DOMRect} rect The rectangle.\n * @param {number} nestingLevel The nesting level of the block.\n * @param {boolean} rtl Whether the editor is in RTL mode.\n * @return {number} The desired relative parent level.\n */\nfunction getDesiredRelativeParentLevel(\n\tpoint,\n\trect,\n\tnestingLevel = 1,\n\trtl = false\n) {\n\t// In RTL languages, the block indent position is from the right edge of the block.\n\t// In LTR languages, the block indent position is from the left edge of the block.\n\tconst blockIndentPosition = rtl\n\t\t? rect.right - nestingLevel * NESTING_LEVEL_INDENTATION\n\t\t: rect.left + nestingLevel * NESTING_LEVEL_INDENTATION;\n\n\tconst distanceBetweenPointAndBlockIndentPosition = rtl\n\t\t? blockIndentPosition - point.x\n\t\t: point.x - blockIndentPosition;\n\n\tconst desiredParentLevel = Math.round(\n\t\tdistanceBetweenPointAndBlockIndentPosition / NESTING_LEVEL_INDENTATION\n\t);\n\n\treturn Math.abs( desiredParentLevel );\n}\n\n/**\n * Returns an array of the parent blocks of the block the user is dropping to.\n *\n * @param {WPListViewDropZoneBlock} candidateBlockData The block the user is dropping to.\n * @param {WPListViewDropZoneBlocks} blocksData Data about the blocks in list view.\n * @return {WPListViewDropZoneBlocks} An array of block parents, including the block the user is dropping to.\n */\nfunction getCandidateBlockParents( candidateBlockData, blocksData ) {\n\tconst candidateBlockParents = [];\n\tlet currentBlockData = candidateBlockData;\n\n\twhile ( currentBlockData ) {\n\t\tcandidateBlockParents.push( { ...currentBlockData } );\n\t\tcurrentBlockData = blocksData.find(\n\t\t\t( blockData ) =>\n\t\t\t\tblockData.clientId === currentBlockData.rootClientId\n\t\t);\n\t}\n\n\treturn candidateBlockParents;\n}\n\n/**\n * Given a list of blocks data and a block index, return the next non-dragged\n * block. This is used to determine the block that the user is dropping to,\n * while ignoring the dragged block.\n *\n * @param {WPListViewDropZoneBlocks} blocksData Data about the blocks in list view.\n * @param {number} index The index to begin searching from.\n * @return {WPListViewDropZoneBlock | undefined} The next non-dragged block.\n */\nfunction getNextNonDraggedBlock( blocksData, index ) {\n\tconst nextBlockData = blocksData[ index + 1 ];\n\tif ( nextBlockData && nextBlockData.isDraggedBlock ) {\n\t\treturn getNextNonDraggedBlock( blocksData, index + 1 );\n\t}\n\n\treturn nextBlockData;\n}\n\n/**\n * Determines whether the user positioning the dragged block to nest as an\n * inner block.\n *\n * Determined based on nesting level indentation of the current block, plus\n * the indentation of the next level of nesting. The vertical position of the\n * cursor must also be within the block.\n *\n * @param {WPPoint} point The point representing the cursor position when dragging.\n * @param {DOMRect} rect The rectangle.\n * @param {number} nestingLevel The nesting level of the block.\n * @param {boolean} rtl Whether the editor is in RTL mode.\n */\nfunction isNestingGesture( point, rect, nestingLevel = 1, rtl = false ) {\n\tconst blockIndentPosition = rtl\n\t\t? rect.right - nestingLevel * NESTING_LEVEL_INDENTATION\n\t\t: rect.left + nestingLevel * NESTING_LEVEL_INDENTATION;\n\n\tconst isNestingHorizontalGesture = rtl\n\t\t? point.x < blockIndentPosition - NESTING_LEVEL_INDENTATION\n\t\t: point.x > blockIndentPosition + NESTING_LEVEL_INDENTATION;\n\n\treturn isNestingHorizontalGesture && point.y < rect.bottom;\n}\n\n// Block navigation is always a vertical list, so only allow dropping\n// to the above or below a block.\nconst ALLOWED_DROP_EDGES = [ 'top', 'bottom' ];\n\n/**\n * Given blocks data and the cursor position, compute the drop target.\n *\n * @param {WPListViewDropZoneBlocks} blocksData Data about the blocks in list view.\n * @param {WPPoint} position The point representing the cursor position when dragging.\n * @param {boolean} rtl Whether the editor is in RTL mode.\n *\n * @return {WPListViewDropZoneTarget | undefined} An object containing data about the drop target.\n */\nexport function getListViewDropTarget( blocksData, position, rtl = false ) {\n\tlet candidateEdge;\n\tlet candidateBlockData;\n\tlet candidateDistance;\n\tlet candidateRect;\n\tlet candidateBlockIndex;\n\n\tfor ( let i = 0; i < blocksData.length; i++ ) {\n\t\tconst blockData = blocksData[ i ];\n\t\tif ( blockData.isDraggedBlock ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst rect = blockData.element.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge(\n\t\t\tposition,\n\t\t\trect,\n\t\t\tALLOWED_DROP_EDGES\n\t\t);\n\n\t\tconst isCursorWithinBlock = isPointContainedByRect( position, rect );\n\t\tif (\n\t\t\tcandidateDistance === undefined ||\n\t\t\tdistance < candidateDistance ||\n\t\t\tisCursorWithinBlock\n\t\t) {\n\t\t\tcandidateDistance = distance;\n\n\t\t\tconst index = blocksData.indexOf( blockData );\n\t\t\tconst previousBlockData = blocksData[ index - 1 ];\n\n\t\t\t// If dragging near the top of a block and the preceding block\n\t\t\t// is at the same level, use the preceding block as the candidate\n\t\t\t// instead, as later it makes determining a nesting drop easier.\n\t\t\tif (\n\t\t\t\tedge === 'top' &&\n\t\t\t\tpreviousBlockData &&\n\t\t\t\tpreviousBlockData.rootClientId === blockData.rootClientId &&\n\t\t\t\t! previousBlockData.isDraggedBlock\n\t\t\t) {\n\t\t\t\tcandidateBlockData = previousBlockData;\n\t\t\t\tcandidateEdge = 'bottom';\n\t\t\t\tcandidateRect =\n\t\t\t\t\tpreviousBlockData.element.getBoundingClientRect();\n\t\t\t\tcandidateBlockIndex = index - 1;\n\t\t\t} else {\n\t\t\t\tcandidateBlockData = blockData;\n\t\t\t\tcandidateEdge = edge;\n\t\t\t\tcandidateRect = rect;\n\t\t\t\tcandidateBlockIndex = index;\n\t\t\t}\n\n\t\t\t// If the mouse position is within the block, break early\n\t\t\t// as the user would intend to drop either before or after\n\t\t\t// this block.\n\t\t\t//\n\t\t\t// This solves an issue where some rows in the list view\n\t\t\t// tree overlap slightly due to sub-pixel rendering.\n\t\t\tif ( isCursorWithinBlock ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( ! candidateBlockData ) {\n\t\treturn;\n\t}\n\n\tconst candidateBlockParents = getCandidateBlockParents(\n\t\tcandidateBlockData,\n\t\tblocksData\n\t);\n\n\tconst isDraggingBelow = candidateEdge === 'bottom';\n\n\t// If the user is dragging towards the bottom of the block check whether\n\t// they might be trying to nest the block as a child.\n\t// If the block already has inner blocks, and is expanded, this should be treated\n\t// as nesting since the next block in the tree will be the first child.\n\t// However, if the block is collapsed, dragging beneath the block should\n\t// still be allowed, as the next visible block in the tree will be a sibling.\n\tif (\n\t\tisDraggingBelow &&\n\t\tcandidateBlockData.canInsertDraggedBlocksAsChild &&\n\t\t( ( candidateBlockData.innerBlockCount > 0 &&\n\t\t\tcandidateBlockData.isExpanded ) ||\n\t\t\tisNestingGesture(\n\t\t\t\tposition,\n\t\t\t\tcandidateRect,\n\t\t\t\tcandidateBlockParents.length,\n\t\t\t\trtl\n\t\t\t) )\n\t) {\n\t\t// If the block is expanded, insert the block as the first child.\n\t\t// Otherwise, for collapsed blocks, insert the block as the last child.\n\t\tconst newBlockIndex = candidateBlockData.isExpanded\n\t\t\t? 0\n\t\t\t: candidateBlockData.innerBlockCount || 0;\n\n\t\treturn {\n\t\t\trootClientId: candidateBlockData.clientId,\n\t\t\tblockIndex: newBlockIndex,\n\t\t\tdropPosition: 'inside',\n\t\t};\n\t}\n\n\t// If the user is dragging towards the bottom of the block check whether\n\t// they might be trying to move the block to be at a parent level.\n\tif (\n\t\tisDraggingBelow &&\n\t\tcandidateBlockData.rootClientId &&\n\t\tisUpGesture(\n\t\t\tposition,\n\t\t\tcandidateRect,\n\t\t\tcandidateBlockParents.length,\n\t\t\trtl\n\t\t)\n\t) {\n\t\tconst nextBlock = getNextNonDraggedBlock(\n\t\t\tblocksData,\n\t\t\tcandidateBlockIndex\n\t\t);\n\t\tconst currentLevel = candidateBlockData.nestingLevel;\n\t\tconst nextLevel = nextBlock ? nextBlock.nestingLevel : 1;\n\n\t\tif ( currentLevel && nextLevel ) {\n\t\t\t// Determine the desired relative level of the block to be dropped.\n\t\t\tconst desiredRelativeLevel = getDesiredRelativeParentLevel(\n\t\t\t\tposition,\n\t\t\t\tcandidateRect,\n\t\t\t\tcandidateBlockParents.length,\n\t\t\t\trtl\n\t\t\t);\n\n\t\t\tconst targetParentIndex = Math.max(\n\t\t\t\tMath.min( desiredRelativeLevel, currentLevel - nextLevel ),\n\t\t\t\t0\n\t\t\t);\n\n\t\t\tif ( candidateBlockParents[ targetParentIndex ] ) {\n\t\t\t\t// Default to the block index of the candidate block.\n\t\t\t\tlet newBlockIndex = candidateBlockData.blockIndex;\n\n\t\t\t\t// If the next block is at the same level, use that as the default\n\t\t\t\t// block index. This ensures that the block is dropped in the correct\n\t\t\t\t// position when dragging to the bottom of a block.\n\t\t\t\tif (\n\t\t\t\t\tcandidateBlockParents[ targetParentIndex ].nestingLevel ===\n\t\t\t\t\tnextBlock?.nestingLevel\n\t\t\t\t) {\n\t\t\t\t\tnewBlockIndex = nextBlock?.blockIndex;\n\t\t\t\t} else {\n\t\t\t\t\t// Otherwise, search from the current block index back\n\t\t\t\t\t// to find the last block index within the same target parent.\n\t\t\t\t\tfor ( let i = candidateBlockIndex; i >= 0; i-- ) {\n\t\t\t\t\t\tconst blockData = blocksData[ i ];\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tblockData.rootClientId ===\n\t\t\t\t\t\t\tcandidateBlockParents[ targetParentIndex ]\n\t\t\t\t\t\t\t\t.rootClientId\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tnewBlockIndex = blockData.blockIndex + 1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\trootClientId:\n\t\t\t\t\t\tcandidateBlockParents[ targetParentIndex ].rootClientId,\n\t\t\t\t\tclientId: candidateBlockData.clientId,\n\t\t\t\t\tblockIndex: newBlockIndex,\n\t\t\t\t\tdropPosition: candidateEdge,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t}\n\n\t// If dropping as a sibling, but block cannot be inserted in\n\t// this context, return early.\n\tif ( ! candidateBlockData.canInsertDraggedBlocksAsSibling ) {\n\t\treturn;\n\t}\n\n\tconst offset = isDraggingBelow ? 1 : 0;\n\treturn {\n\t\trootClientId: candidateBlockData.rootClientId,\n\t\tclientId: candidateBlockData.clientId,\n\t\tblockIndex: candidateBlockData.blockIndex + offset,\n\t\tdropPosition: candidateEdge,\n\t};\n}\n\n/**\n * A react hook for implementing a drop zone in list view.\n *\n * @param {Object} props Named parameters.\n * @param {?HTMLElement} [props.dropZoneElement] Optional element to be used as the drop zone.\n *\n * @return {WPListViewDropZoneTarget} The drop target.\n */\nexport default function useListViewDropZone( { dropZoneElement } ) {\n\tconst {\n\t\tgetBlockRootClientId,\n\t\tgetBlockIndex,\n\t\tgetBlockCount,\n\t\tgetDraggedBlockClientIds,\n\t\tcanInsertBlocks,\n\t} = useSelect( blockEditorStore );\n\tconst [ target, setTarget ] = useState();\n\tconst { rootClientId: targetRootClientId, blockIndex: targetBlockIndex } =\n\t\ttarget || {};\n\n\tconst onBlockDrop = useOnBlockDrop( targetRootClientId, targetBlockIndex );\n\n\tconst rtl = isRTL();\n\n\tconst draggedBlockClientIds = getDraggedBlockClientIds();\n\tconst throttled = useThrottle(\n\t\tuseCallback(\n\t\t\t( event, currentTarget ) => {\n\t\t\t\tconst position = { x: event.clientX, y: event.clientY };\n\t\t\t\tconst isBlockDrag = !! draggedBlockClientIds?.length;\n\n\t\t\t\tconst blockElements = Array.from(\n\t\t\t\t\tcurrentTarget.querySelectorAll( '[data-block]' )\n\t\t\t\t);\n\n\t\t\t\tconst blocksData = blockElements.map( ( blockElement ) => {\n\t\t\t\t\tconst clientId = blockElement.dataset.block;\n\t\t\t\t\tconst isExpanded = blockElement.dataset.expanded === 'true';\n\t\t\t\t\tconst isDraggedBlock =\n\t\t\t\t\t\tblockElement.classList.contains( 'is-dragging' );\n\n\t\t\t\t\t// Get nesting level from `aria-level` attribute because Firefox does not support `element.ariaLevel`.\n\t\t\t\t\tconst nestingLevel = parseInt(\n\t\t\t\t\t\tblockElement.getAttribute( 'aria-level' ),\n\t\t\t\t\t\t10\n\t\t\t\t\t);\n\t\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\tisExpanded,\n\t\t\t\t\t\trootClientId,\n\t\t\t\t\t\tblockIndex: getBlockIndex( clientId ),\n\t\t\t\t\t\telement: blockElement,\n\t\t\t\t\t\tnestingLevel: nestingLevel || undefined,\n\t\t\t\t\t\tisDraggedBlock: isBlockDrag ? isDraggedBlock : false,\n\t\t\t\t\t\tinnerBlockCount: getBlockCount( clientId ),\n\t\t\t\t\t\tcanInsertDraggedBlocksAsSibling: isBlockDrag\n\t\t\t\t\t\t\t? canInsertBlocks(\n\t\t\t\t\t\t\t\t\tdraggedBlockClientIds,\n\t\t\t\t\t\t\t\t\trootClientId\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: true,\n\t\t\t\t\t\tcanInsertDraggedBlocksAsChild: isBlockDrag\n\t\t\t\t\t\t\t? canInsertBlocks( draggedBlockClientIds, clientId )\n\t\t\t\t\t\t\t: true,\n\t\t\t\t\t};\n\t\t\t\t} );\n\n\t\t\t\tconst newTarget = getListViewDropTarget(\n\t\t\t\t\tblocksData,\n\t\t\t\t\tposition,\n\t\t\t\t\trtl\n\t\t\t\t);\n\n\t\t\t\tif ( newTarget ) {\n\t\t\t\t\tsetTarget( newTarget );\n\t\t\t\t}\n\t\t\t},\n\t\t\t[\n\t\t\t\tcanInsertBlocks,\n\t\t\t\tdraggedBlockClientIds,\n\t\t\t\tgetBlockCount,\n\t\t\t\tgetBlockIndex,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\trtl,\n\t\t\t]\n\t\t),\n\t\t200\n\t);\n\n\tconst ref = useDropZone( {\n\t\tdropZoneElement,\n\t\tonDrop( event ) {\n\t\t\tif ( target ) {\n\t\t\t\tonBlockDrop( event );\n\t\t\t}\n\t\t},\n\t\tonDragLeave() {\n\t\t\tthrottled.cancel();\n\t\t\tsetTarget( null );\n\t\t},\n\t\tonDragOver( event ) {\n\t\t\t// `currentTarget` is only available while the event is being\n\t\t\t// handled, so get it now and pass it to the thottled function.\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget\n\t\t\tthrottled( event, event.currentTarget );\n\t\t},\n\t\tonDragEnd() {\n\t\t\tthrottled.cancel();\n\t\t\tsetTarget( null );\n\t\t},\n\t} );\n\n\treturn { ref, target };\n}\n"]}
|
|
@@ -4,38 +4,63 @@ import { createElement } from "@wordpress/element";
|
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
6
|
import { getActiveFormat, getActiveObject } from '@wordpress/rich-text';
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
import { useContext, useMemo } from '@wordpress/element';
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import BlockContext from '../block-context';
|
|
13
|
+
const DEFAULT_BLOCK_CONTEXT = {};
|
|
14
|
+
export const usesContextKey = Symbol('usesContext');
|
|
15
|
+
|
|
16
|
+
function Edit({
|
|
9
17
|
onChange,
|
|
10
18
|
onFocus,
|
|
11
19
|
value,
|
|
12
|
-
forwardedRef
|
|
20
|
+
forwardedRef,
|
|
21
|
+
settings
|
|
13
22
|
}) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
23
|
+
const {
|
|
24
|
+
name,
|
|
25
|
+
edit: EditFunction,
|
|
26
|
+
[usesContextKey]: usesContext
|
|
27
|
+
} = settings;
|
|
28
|
+
const blockContext = useContext(BlockContext); // Assign context values using the block type's declared context needs.
|
|
19
29
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
30
|
+
const context = useMemo(() => {
|
|
31
|
+
return usesContext ? Object.fromEntries(Object.entries(blockContext).filter(([key]) => usesContext.includes(key))) : DEFAULT_BLOCK_CONTEXT;
|
|
32
|
+
}, [usesContext, blockContext]);
|
|
23
33
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
if (!EditFunction) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const activeFormat = getActiveFormat(value, name);
|
|
39
|
+
const isActive = activeFormat !== undefined;
|
|
40
|
+
const activeObject = getActiveObject(value);
|
|
41
|
+
const isObjectActive = activeObject !== undefined && activeObject.type === name;
|
|
42
|
+
return createElement(EditFunction, {
|
|
43
|
+
key: name,
|
|
44
|
+
isActive: isActive,
|
|
45
|
+
activeAttributes: isActive ? activeFormat.attributes || {} : {},
|
|
46
|
+
isObjectActive: isObjectActive,
|
|
47
|
+
activeObjectAttributes: isObjectActive ? activeObject.attributes || {} : {},
|
|
48
|
+
value: value,
|
|
49
|
+
onChange: onChange,
|
|
50
|
+
onFocus: onFocus,
|
|
51
|
+
contentRef: forwardedRef,
|
|
52
|
+
context: context
|
|
39
53
|
});
|
|
40
54
|
}
|
|
55
|
+
|
|
56
|
+
export default function FormatEdit({
|
|
57
|
+
formatTypes,
|
|
58
|
+
...props
|
|
59
|
+
}) {
|
|
60
|
+
return formatTypes.map(settings => createElement(Edit, {
|
|
61
|
+
settings: settings,
|
|
62
|
+
...props,
|
|
63
|
+
key: settings.name
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
41
66
|
//# sourceMappingURL=format-edit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/format-edit.js"],"names":["getActiveFormat","getActiveObject","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/format-edit.js"],"names":["getActiveFormat","getActiveObject","useContext","useMemo","BlockContext","DEFAULT_BLOCK_CONTEXT","usesContextKey","Symbol","Edit","onChange","onFocus","value","forwardedRef","settings","name","edit","EditFunction","usesContext","blockContext","context","Object","fromEntries","entries","filter","key","includes","activeFormat","isActive","undefined","activeObject","isObjectActive","type","attributes","FormatEdit","formatTypes","props","map"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,eAAT,EAA0BC,eAA1B,QAAiD,sBAAjD;AACA,SAASC,UAAT,EAAqBC,OAArB,QAAoC,oBAApC;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AAEA,MAAMC,qBAAqB,GAAG,EAA9B;AAEA,OAAO,MAAMC,cAAc,GAAGC,MAAM,CAAE,aAAF,CAA7B;;AAEP,SAASC,IAAT,CAAe;AAAEC,EAAAA,QAAF;AAAYC,EAAAA,OAAZ;AAAqBC,EAAAA,KAArB;AAA4BC,EAAAA,YAA5B;AAA0CC,EAAAA;AAA1C,CAAf,EAAsE;AACrE,QAAM;AACLC,IAAAA,IADK;AAELC,IAAAA,IAAI,EAAEC,YAFD;AAGL,KAAEV,cAAF,GAAoBW;AAHf,MAIFJ,QAJJ;AAMA,QAAMK,YAAY,GAAGhB,UAAU,CAAEE,YAAF,CAA/B,CAPqE,CASrE;;AACA,QAAMe,OAAO,GAAGhB,OAAO,CAAE,MAAM;AAC9B,WAAOc,WAAW,GACfG,MAAM,CAACC,WAAP,CACAD,MAAM,CAACE,OAAP,CAAgBJ,YAAhB,EAA+BK,MAA/B,CAAuC,CAAE,CAAEC,GAAF,CAAF,KACtCP,WAAW,CAACQ,QAAZ,CAAsBD,GAAtB,CADD,CADA,CADe,GAMfnB,qBANH;AAOA,GARsB,EAQpB,CAAEY,WAAF,EAAeC,YAAf,CARoB,CAAvB;;AAUA,MAAK,CAAEF,YAAP,EAAsB;AACrB,WAAO,IAAP;AACA;;AAED,QAAMU,YAAY,GAAG1B,eAAe,CAAEW,KAAF,EAASG,IAAT,CAApC;AACA,QAAMa,QAAQ,GAAGD,YAAY,KAAKE,SAAlC;AACA,QAAMC,YAAY,GAAG5B,eAAe,CAAEU,KAAF,CAApC;AACA,QAAMmB,cAAc,GACnBD,YAAY,KAAKD,SAAjB,IAA8BC,YAAY,CAACE,IAAb,KAAsBjB,IADrD;AAGA,SACC,cAAC,YAAD;AACC,IAAA,GAAG,EAAGA,IADP;AAEC,IAAA,QAAQ,EAAGa,QAFZ;AAGC,IAAA,gBAAgB,EAAGA,QAAQ,GAAGD,YAAY,CAACM,UAAb,IAA2B,EAA9B,GAAmC,EAH/D;AAIC,IAAA,cAAc,EAAGF,cAJlB;AAKC,IAAA,sBAAsB,EACrBA,cAAc,GAAGD,YAAY,CAACG,UAAb,IAA2B,EAA9B,GAAmC,EANnD;AAQC,IAAA,KAAK,EAAGrB,KART;AASC,IAAA,QAAQ,EAAGF,QATZ;AAUC,IAAA,OAAO,EAAGC,OAVX;AAWC,IAAA,UAAU,EAAGE,YAXd;AAYC,IAAA,OAAO,EAAGO;AAZX,IADD;AAgBA;;AAED,eAAe,SAASc,UAAT,CAAqB;AAAEC,EAAAA,WAAF;AAAe,KAAGC;AAAlB,CAArB,EAAiD;AAC/D,SAAOD,WAAW,CAACE,GAAZ,CAAmBvB,QAAF,IACvB,cAAC,IAAD;AAAM,IAAA,QAAQ,EAAGA,QAAjB;AAAA,OAAiCsB,KAAjC;AAAyC,IAAA,GAAG,EAAGtB,QAAQ,CAACC;AAAxD,IADM,CAAP;AAGA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getActiveFormat, getActiveObject } from '@wordpress/rich-text';\nimport { useContext, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockContext from '../block-context';\n\nconst DEFAULT_BLOCK_CONTEXT = {};\n\nexport const usesContextKey = Symbol( 'usesContext' );\n\nfunction Edit( { onChange, onFocus, value, forwardedRef, settings } ) {\n\tconst {\n\t\tname,\n\t\tedit: EditFunction,\n\t\t[ usesContextKey ]: usesContext,\n\t} = settings;\n\n\tconst blockContext = useContext( BlockContext );\n\n\t// Assign context values using the block type's declared context needs.\n\tconst context = useMemo( () => {\n\t\treturn usesContext\n\t\t\t? Object.fromEntries(\n\t\t\t\t\tObject.entries( blockContext ).filter( ( [ key ] ) =>\n\t\t\t\t\t\tusesContext.includes( key )\n\t\t\t\t\t)\n\t\t\t )\n\t\t\t: DEFAULT_BLOCK_CONTEXT;\n\t}, [ usesContext, blockContext ] );\n\n\tif ( ! EditFunction ) {\n\t\treturn null;\n\t}\n\n\tconst activeFormat = getActiveFormat( value, name );\n\tconst isActive = activeFormat !== undefined;\n\tconst activeObject = getActiveObject( value );\n\tconst isObjectActive =\n\t\tactiveObject !== undefined && activeObject.type === name;\n\n\treturn (\n\t\t<EditFunction\n\t\t\tkey={ name }\n\t\t\tisActive={ isActive }\n\t\t\tactiveAttributes={ isActive ? activeFormat.attributes || {} : {} }\n\t\t\tisObjectActive={ isObjectActive }\n\t\t\tactiveObjectAttributes={\n\t\t\t\tisObjectActive ? activeObject.attributes || {} : {}\n\t\t\t}\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tonFocus={ onFocus }\n\t\t\tcontentRef={ forwardedRef }\n\t\t\tcontext={ context }\n\t\t/>\n\t);\n}\n\nexport default function FormatEdit( { formatTypes, ...props } ) {\n\treturn formatTypes.map( ( settings ) => (\n\t\t<Edit settings={ settings } { ...props } key={ settings.name } />\n\t) );\n}\n"]}
|
|
@@ -85,8 +85,8 @@ export function getCustomValueFromPreset(value, spacingSizes) {
|
|
|
85
85
|
*/
|
|
86
86
|
|
|
87
87
|
export function getPresetValueFromCustomValue(value, spacingSizes) {
|
|
88
|
-
// Return value as-is if it is already a preset;
|
|
89
|
-
if (isValueSpacingPreset(value) || value === '0') {
|
|
88
|
+
// Return value as-is if it is undefined or is already a preset, or '0';
|
|
89
|
+
if (!value || isValueSpacingPreset(value) || value === '0') {
|
|
90
90
|
return value;
|
|
91
91
|
}
|
|
92
92
|
|