@wordpress/block-editor 8.5.4 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/README.md +4 -2
- package/build/components/block-alignment-control/constants.js +48 -0
- package/build/components/block-alignment-control/constants.js.map +1 -0
- package/build/components/block-alignment-control/ui.js +9 -40
- package/build/components/block-alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/ui.native.js +92 -0
- package/build/components/block-alignment-control/ui.native.js.map +1 -0
- package/build/components/block-content-overlay/index.js +13 -4
- package/build/components/block-content-overlay/index.js.map +1 -1
- package/build/components/block-list/block.native.js +3 -1
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-class-names.js +1 -7
- package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build/components/block-lock/modal.js +34 -4
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-lock/toolbar.js +2 -1
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-lock/use-block-lock.js +4 -1
- package/build/components/block-lock/use-block-lock.js.map +1 -1
- package/build/components/block-mover/button.js +4 -4
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +39 -65
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-navigation/dropdown.js +11 -5
- package/build/components/block-navigation/dropdown.js.map +1 -1
- package/build/components/block-popover/inbetween.js +183 -0
- package/build/components/block-popover/inbetween.js.map +1 -0
- package/build/components/block-popover/index.js +97 -0
- package/build/components/block-popover/index.js.map +1 -0
- package/build/components/{block-tools → block-popover}/use-popover-scroll.js +4 -1
- package/build/components/block-popover/use-popover-scroll.js.map +1 -0
- package/build/components/block-styles/index.js +1 -10
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-tools/back-compat.js +2 -2
- package/build/components/block-tools/back-compat.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +4 -2
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +5 -5
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +14 -121
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -108
- package/build/components/block-tools/selected-block-popover.js.map +1 -0
- package/build/components/color-style-selector/index.js +9 -0
- package/build/components/color-style-selector/index.js.map +1 -1
- package/build/components/duotone-control/index.js +5 -1
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/index.js +0 -9
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/index.native.js +30 -8
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/list-view/block.js +15 -15
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +9 -13
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/context.js +1 -4
- package/build/components/list-view/context.js.map +1 -1
- package/build/components/list-view/index.js +15 -32
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/rich-text/index.js +0 -5
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +0 -4
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/url-input/index.js +7 -3
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-display-information/index.js +3 -1
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/components/use-setting/index.js +42 -18
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/border.js +468 -44
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/dimensions.js +2 -2
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/index.js +3 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/margin.js +64 -12
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +60 -12
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/settings.js +32 -0
- package/build/hooks/settings.js.map +1 -0
- package/build/hooks/use-border-props.js +22 -32
- package/build/hooks/use-border-props.js.map +1 -1
- package/build/store/actions.js +14 -2
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +0 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +0 -26
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +47 -15
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-alignment-control/constants.js +36 -0
- package/build-module/components/block-alignment-control/constants.js.map +1 -0
- package/build-module/components/block-alignment-control/ui.js +4 -35
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/ui.native.js +78 -0
- package/build-module/components/block-alignment-control/ui.native.js.map +1 -0
- package/build-module/components/block-content-overlay/index.js +13 -4
- package/build-module/components/block-content-overlay/index.js.map +1 -1
- package/build-module/components/block-list/block.native.js +3 -1
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-class-names.js +1 -7
- package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build-module/components/block-lock/modal.js +34 -5
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +2 -1
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-lock/use-block-lock.js +4 -1
- package/build-module/components/block-lock/use-block-lock.js.map +1 -1
- package/build-module/components/block-mover/button.js +5 -5
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +38 -63
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-navigation/dropdown.js +10 -5
- package/build-module/components/block-navigation/dropdown.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +165 -0
- package/build-module/components/block-popover/inbetween.js.map +1 -0
- package/build-module/components/block-popover/index.js +83 -0
- package/build-module/components/block-popover/index.js.map +1 -0
- package/build-module/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
- package/build-module/components/block-popover/use-popover-scroll.js.map +1 -0
- package/build-module/components/block-styles/index.js +1 -9
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-tools/back-compat.js +1 -1
- package/build-module/components/block-tools/back-compat.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +3 -2
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +3 -3
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +16 -121
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -105
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -0
- package/build-module/components/color-style-selector/index.js +6 -0
- package/build-module/components/color-style-selector/index.js.map +1 -1
- package/build-module/components/duotone-control/index.js +4 -1
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/index.js +0 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +31 -10
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/list-view/block.js +15 -16
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +9 -13
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/context.js +1 -4
- package/build-module/components/list-view/context.js.map +1 -1
- package/build-module/components/list-view/index.js +15 -31
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +0 -4
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +0 -4
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/url-input/index.js +7 -3
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +3 -1
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +43 -19
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/border.js +458 -44
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/dimensions.js +5 -5
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/index.js +2 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/margin.js +61 -13
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +57 -13
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/settings.js +29 -0
- package/build-module/hooks/settings.js.map +1 -0
- package/build-module/hooks/use-border-props.js +21 -30
- package/build-module/hooks/use-border-props.js.map +1 -1
- package/build-module/store/actions.js +14 -2
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +0 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/reducer.js +0 -24
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +44 -15
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +128 -276
- package/build-style/style.css +128 -276
- package/package.json +28 -28
- package/src/components/block-alignment-control/constants.js +45 -0
- package/src/components/block-alignment-control/ui.js +69 -109
- package/src/components/block-alignment-control/ui.native.js +86 -0
- package/src/components/block-content-overlay/index.js +19 -2
- package/src/components/block-list/block.native.js +2 -0
- package/src/components/block-list/style.scss +7 -18
- package/src/components/block-list/use-block-props/use-block-class-names.js +1 -11
- package/src/components/block-lock/modal.js +42 -3
- package/src/components/block-lock/toolbar.js +2 -2
- package/src/components/block-lock/use-block-lock.js +4 -1
- package/src/components/block-mover/button.js +5 -7
- package/src/components/block-mover/index.js +37 -60
- package/src/components/block-mover/stories/index.js +110 -0
- package/src/components/block-mover/style.scss +48 -138
- package/src/components/block-navigation/dropdown.js +12 -8
- package/src/components/block-popover/README.md +41 -0
- package/src/components/block-popover/inbetween.js +180 -0
- package/src/components/block-popover/index.js +90 -0
- package/src/components/block-popover/style.scss +27 -0
- package/src/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
- package/src/components/block-styles/index.js +1 -12
- package/src/components/block-switcher/style.scss +0 -4
- package/src/components/block-toolbar/style.scss +0 -12
- package/src/components/block-tools/back-compat.js +1 -1
- package/src/components/block-tools/block-selection-button.js +3 -1
- package/src/components/block-tools/index.js +6 -4
- package/src/components/block-tools/insertion-point.js +19 -152
- package/src/components/block-tools/{block-popover.js → selected-block-popover.js} +24 -116
- package/src/components/block-tools/style.scss +11 -123
- package/src/components/border-radius-control/style.scss +5 -2
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/color-style-selector/index.js +18 -9
- package/src/components/default-block-appender/style.scss +1 -2
- package/src/components/duotone-control/index.js +8 -1
- package/src/components/gradients/README.md +29 -0
- package/src/components/image-size-control/README.md +1 -1
- package/src/components/index.js +0 -1
- package/src/components/inserter/index.native.js +60 -25
- package/src/components/inserter/style.native.scss +25 -3
- package/src/components/list-view/block.js +24 -34
- package/src/components/list-view/branch.js +10 -20
- package/src/components/list-view/context.js +1 -4
- package/src/components/list-view/index.js +11 -41
- package/src/components/navigable-toolbar/README.md +16 -0
- package/src/components/rich-text/index.js +0 -2
- package/src/components/rich-text/index.native.js +0 -4
- package/src/components/url-input/index.js +6 -3
- package/src/components/use-block-display-information/index.js +2 -0
- package/src/components/use-setting/index.js +57 -21
- package/src/hooks/border.js +438 -72
- package/src/hooks/border.scss +48 -0
- package/src/hooks/dimensions.js +44 -38
- package/src/hooks/index.js +2 -1
- package/src/hooks/margin.js +64 -15
- package/src/hooks/padding.js +60 -15
- package/src/hooks/padding.scss +12 -0
- package/src/hooks/settings.js +32 -0
- package/src/hooks/test/settings.js +48 -0
- package/src/hooks/use-border-props.js +15 -32
- package/src/store/actions.js +14 -2
- package/src/store/defaults.js +0 -1
- package/src/store/reducer.js +0 -21
- package/src/store/selectors.js +46 -15
- package/src/store/test/actions.js +0 -18
- package/src/store/test/reducer.js +0 -19
- package/src/store/test/selectors.js +17 -19
- package/src/style.scss +2 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-mobile-toolbar/index.js +0 -42
- package/build/components/block-mobile-toolbar/index.js.map +0 -1
- package/build/components/block-tools/block-popover.js.map +0 -1
- package/build/components/block-tools/use-popover-scroll.js.map +0 -1
- package/build/components/border-style-control/index.js +0 -60
- package/build/components/border-style-control/index.js.map +0 -1
- package/build/components/list-view/appender.js +0 -93
- package/build/components/list-view/appender.js.map +0 -1
- package/build/components/list-view/list-item.js +0 -62
- package/build/components/list-view/list-item.js.map +0 -1
- package/build/components/rich-text/use-caret-in-format.js +0 -43
- package/build/components/rich-text/use-caret-in-format.js.map +0 -1
- package/build/hooks/border-color.js +0 -302
- package/build/hooks/border-color.js.map +0 -1
- package/build/hooks/border-style.js +0 -96
- package/build/hooks/border-style.js.map +0 -1
- package/build/hooks/border-width.js +0 -162
- package/build/hooks/border-width.js.map +0 -1
- package/build-module/components/block-mobile-toolbar/index.js +0 -31
- package/build-module/components/block-mobile-toolbar/index.js.map +0 -1
- package/build-module/components/block-tools/block-popover.js.map +0 -1
- package/build-module/components/block-tools/use-popover-scroll.js.map +0 -1
- package/build-module/components/border-style-control/index.js +0 -50
- package/build-module/components/border-style-control/index.js.map +0 -1
- package/build-module/components/list-view/appender.js +0 -76
- package/build-module/components/list-view/appender.js.map +0 -1
- package/build-module/components/list-view/list-item.js +0 -47
- package/build-module/components/list-view/list-item.js.map +0 -1
- package/build-module/components/rich-text/use-caret-in-format.js +0 -33
- package/build-module/components/rich-text/use-caret-in-format.js.map +0 -1
- package/build-module/hooks/border-color.js +0 -276
- package/build-module/hooks/border-color.js.map +0 -1
- package/build-module/hooks/border-style.js +0 -78
- package/build-module/hooks/border-style.js.map +0 -1
- package/build-module/hooks/border-width.js +0 -143
- package/build-module/hooks/border-width.js.map +0 -1
- package/src/components/block-mobile-toolbar/index.js +0 -24
- package/src/components/block-mobile-toolbar/style.scss +0 -29
- package/src/components/border-style-control/index.js +0 -47
- package/src/components/border-style-control/style.scss +0 -18
- package/src/components/list-view/appender.js +0 -82
- package/src/components/list-view/list-item.js +0 -59
- package/src/components/rich-text/use-caret-in-format.js +0 -28
- package/src/hooks/border-color.js +0 -315
- package/src/hooks/border-style.js +0 -64
- package/src/hooks/border-width.js +0 -139
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/use-setting/index.js"],"names":["get","useSelect","__EXPERIMENTAL_PATHS_WITH_MERGE","PATHS_WITH_MERGE","useBlockEditContext","store","blockEditorStore","blockedPaths","deprecatedFlags","settings","colors","undefined","gradients","disableCustomColors","disableCustomGradients","fontSizes","disableCustomFontSizes","enableCustomLineHeight","enableCustomUnits","enableCustomSpacing","prefixedFlags","removeCustomPrefixes","path","useSetting","name","blockName","setting","select","includes","console","warn","getSettings","normalizedPath","defaultsPath","blockPath","experimentalFeaturesResult","custom","theme","default","deprecatedSettingsValue"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,+BAA+B,IAAIC,gBAA5C,QAAoE,mBAApE;AAEA;AACA;AACA;;AACA,SAASC,mBAAT,QAAoC,eAApC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA,MAAMC,YAAY,GAAG,CAAE,OAAF,EAAW,QAAX,EAAqB,YAArB,EAAmC,SAAnC,CAArB;AAEA,MAAMC,eAAe,GAAG;AACvB,mBAAmBC,QAAF,IAChBA,QAAQ,CAACC,MAAT,KAAoBC,SAApB,GAAgCA,SAAhC,GAA4CF,QAAQ,CAACC,MAF/B;AAGvB,qBAAqBD,QAAF,IAClBA,QAAQ,CAACG,SAAT,KAAuBD,SAAvB,GAAmCA,SAAnC,GAA+CF,QAAQ,CAACG,SAJlC;AAKvB,kBAAkBH,QAAF,IACfA,QAAQ,CAACI,mBAAT,KAAiCF,SAAjC,GACGA,SADH,GAEG,CAAEF,QAAQ,CAACI,mBARQ;AASvB,0BAA0BJ,QAAF,IACvBA,QAAQ,CAACK,sBAAT,KAAoCH,SAApC,GACGA,SADH,GAEG,CAAEF,QAAQ,CAACK,sBAZQ;AAavB,0BAA0BL,QAAF,IACvBA,QAAQ,CAAC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AAzB;AA+CA,SAAOI,OAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { __EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit';\nimport { store as blockEditorStore } from '../../store';\n\nconst blockedPaths = [ 'color', 'border', 'typography', 'spacing' ];\n\nconst deprecatedFlags = {\n\t'color.palette': ( settings ) =>\n\t\tsettings.colors === undefined ? undefined : settings.colors,\n\t'color.gradients': ( settings ) =>\n\t\tsettings.gradients === undefined ? undefined : settings.gradients,\n\t'color.custom': ( settings ) =>\n\t\tsettings.disableCustomColors === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomColors,\n\t'color.customGradient': ( settings ) =>\n\t\tsettings.disableCustomGradients === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomGradients,\n\t'typography.fontSizes': ( settings ) =>\n\t\tsettings.fontSizes === undefined ? undefined : settings.fontSizes,\n\t'typography.customFontSize': ( settings ) =>\n\t\tsettings.disableCustomFontSizes === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomFontSizes,\n\t'typography.lineHeight': ( settings ) => settings.enableCustomLineHeight,\n\t'spacing.units': ( settings ) => {\n\t\tif ( settings.enableCustomUnits === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( settings.enableCustomUnits === true ) {\n\t\t\treturn [ 'px', 'em', 'rem', 'vh', 'vw', '%' ];\n\t\t}\n\n\t\treturn settings.enableCustomUnits;\n\t},\n\t'spacing.padding': ( settings ) => settings.enableCustomSpacing,\n};\n\nconst prefixedFlags = {\n\t/*\n\t * These were only available in the plugin\n\t * and can be removed when the minimum WordPress version\n\t * for the plugin is 5.9.\n\t */\n\t'border.customColor': 'border.color',\n\t'border.customStyle': 'border.style',\n\t'border.customWidth': 'border.width',\n\t'typography.customFontStyle': 'typography.fontStyle',\n\t'typography.customFontWeight': 'typography.fontWeight',\n\t'typography.customLetterSpacing': 'typography.letterSpacing',\n\t'typography.customTextDecorations': 'typography.textDecoration',\n\t'typography.customTextTransforms': 'typography.textTransform',\n\t/*\n\t * These were part of WordPress 5.8 and we need to keep them.\n\t */\n\t'border.customRadius': 'border.radius',\n\t'spacing.customMargin': 'spacing.margin',\n\t'spacing.customPadding': 'spacing.padding',\n\t'typography.customLineHeight': 'typography.lineHeight',\n};\n\n/**\n * Remove `custom` prefixes for flags that did not land in 5.8.\n *\n * This provides continued support for `custom` prefixed properties. It will\n * be removed once third party devs have had sufficient time to update themes,\n * plugins, etc.\n *\n * @see https://github.com/WordPress/gutenberg/pull/34485\n *\n * @param {string} path Path to desired value in settings.\n * @return {string} The value for defined setting.\n */\nconst removeCustomPrefixes = ( path ) => {\n\treturn prefixedFlags[ path ] || path;\n};\n\n/**\n * Hook that retrieves the editor setting.\n * It works with nested objects using by finding the value at path.\n *\n * @param {string} path The path to the setting.\n * @return {any} Returns the value defined for the setting.\n * @example\n * ```js\n * const isEnabled = useSetting( 'typography.dropCap' );\n * ```\n */\nexport default function useSetting( path ) {\n\tconst { name: blockName } = useBlockEditContext();\n\n\tconst setting = useSelect(\n\t\t( select ) => {\n\t\t\tif ( blockedPaths.includes( path ) ) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.warn(\n\t\t\t\t\t'Top level useSetting paths are disabled. Please use a subpath to query the information needed.'\n\t\t\t\t);\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tconst settings = select( blockEditorStore ).getSettings();\n\n\t\t\t// 1 - Use __experimental features, if available.\n\t\t\t// We cascade to the all value if the block one is not available.\n\t\t\tconst normalizedPath = removeCustomPrefixes( path );\n\t\t\tconst defaultsPath = `__experimentalFeatures.${ normalizedPath }`;\n\t\t\tconst blockPath = `__experimentalFeatures.blocks.${ blockName }.${ normalizedPath }`;\n\t\t\tconst experimentalFeaturesResult =\n\t\t\t\tget( settings, blockPath ) ?? get( settings, defaultsPath );\n\n\t\t\tif ( experimentalFeaturesResult !== undefined ) {\n\t\t\t\tif ( PATHS_WITH_MERGE[ normalizedPath ] ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\texperimentalFeaturesResult.custom ??\n\t\t\t\t\t\texperimentalFeaturesResult.theme ??\n\t\t\t\t\t\texperimentalFeaturesResult.default\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn experimentalFeaturesResult;\n\t\t\t}\n\n\t\t\t// 2 - Use deprecated settings, otherwise.\n\t\t\tconst deprecatedSettingsValue = deprecatedFlags[ normalizedPath ]\n\t\t\t\t? deprecatedFlags[ normalizedPath ]( settings )\n\t\t\t\t: undefined;\n\t\t\tif ( deprecatedSettingsValue !== undefined ) {\n\t\t\t\treturn deprecatedSettingsValue;\n\t\t\t}\n\n\t\t\t// 3 - Fall back for typography.dropCap:\n\t\t\t// This is only necessary to support typography.dropCap.\n\t\t\t// when __experimentalFeatures are not present (core without plugin).\n\t\t\t// To remove when __experimentalFeatures are ported to core.\n\t\t\treturn normalizedPath === 'typography.dropCap' ? true : undefined;\n\t\t},\n\t\t[ blockName, path ]\n\t);\n\n\treturn setting;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/use-setting/index.js"],"names":["get","useSelect","__EXPERIMENTAL_PATHS_WITH_MERGE","PATHS_WITH_MERGE","hasBlockSupport","useBlockEditContext","store","blockEditorStore","blockedPaths","deprecatedFlags","settings","colors","undefined","gradients","disableCustomColors","disableCustomGradients","fontSizes","disableCustomFontSizes","enableCustomLineHeight","enableCustomUnits","enableCustomSpacing","prefixedFlags","removeCustomPrefixes","path","useSetting","name","blockName","clientId","setting","select","includes","console","warn","result","normalizedPath","candidates","getBlockParents","forEach","candidateClientId","candidateBlockName","getBlockName","candidateAtts","getBlockAttributes","candidateResult","getSettings","defaultsPath","blockPath","custom","theme","default","deprecatedSettingsValue"],"mappings":"AAAA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AAM,CAACe,KAA/B,uCAAwCf,MAAM,CAACgB,OAA/C;AACA;;AACD,aAAOhB,MAAP;AACA,KA1DY,CA4Db;;;AACA,UAAMiB,uBAAuB,GAAGzC,eAAe,CAAEyB,cAAF,CAAf,GAC7BzB,eAAe,CAAEyB,cAAF,CAAf,CAAmCxB,QAAnC,CAD6B,GAE7BE,SAFH;;AAGA,QAAKsC,uBAAuB,KAAKtC,SAAjC,EAA6C;AAC5C,aAAOsC,uBAAP;AACA,KAlEY,CAoEb;AACA;AACA;AACA;;;AACA,WAAOhB,cAAc,KAAK,oBAAnB,GAA0C,IAA1C,GAAiDtB,SAAxD;AACA,GA1EuB,EA2ExB,CAAEc,SAAF,EAAaC,QAAb,EAAuBJ,IAAvB,CA3EwB,CAAzB;AA8EA,SAAOK,OAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\t__EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE,\n\thasBlockSupport,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit';\nimport { store as blockEditorStore } from '../../store';\n\nconst blockedPaths = [ 'color', 'border', 'typography', 'spacing' ];\n\nconst deprecatedFlags = {\n\t'color.palette': ( settings ) =>\n\t\tsettings.colors === undefined ? undefined : settings.colors,\n\t'color.gradients': ( settings ) =>\n\t\tsettings.gradients === undefined ? undefined : settings.gradients,\n\t'color.custom': ( settings ) =>\n\t\tsettings.disableCustomColors === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomColors,\n\t'color.customGradient': ( settings ) =>\n\t\tsettings.disableCustomGradients === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomGradients,\n\t'typography.fontSizes': ( settings ) =>\n\t\tsettings.fontSizes === undefined ? undefined : settings.fontSizes,\n\t'typography.customFontSize': ( settings ) =>\n\t\tsettings.disableCustomFontSizes === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomFontSizes,\n\t'typography.lineHeight': ( settings ) => settings.enableCustomLineHeight,\n\t'spacing.units': ( settings ) => {\n\t\tif ( settings.enableCustomUnits === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( settings.enableCustomUnits === true ) {\n\t\t\treturn [ 'px', 'em', 'rem', 'vh', 'vw', '%' ];\n\t\t}\n\n\t\treturn settings.enableCustomUnits;\n\t},\n\t'spacing.padding': ( settings ) => settings.enableCustomSpacing,\n};\n\nconst prefixedFlags = {\n\t/*\n\t * These were only available in the plugin\n\t * and can be removed when the minimum WordPress version\n\t * for the plugin is 5.9.\n\t */\n\t'border.customColor': 'border.color',\n\t'border.customStyle': 'border.style',\n\t'border.customWidth': 'border.width',\n\t'typography.customFontStyle': 'typography.fontStyle',\n\t'typography.customFontWeight': 'typography.fontWeight',\n\t'typography.customLetterSpacing': 'typography.letterSpacing',\n\t'typography.customTextDecorations': 'typography.textDecoration',\n\t'typography.customTextTransforms': 'typography.textTransform',\n\t/*\n\t * These were part of WordPress 5.8 and we need to keep them.\n\t */\n\t'border.customRadius': 'border.radius',\n\t'spacing.customMargin': 'spacing.margin',\n\t'spacing.customPadding': 'spacing.padding',\n\t'typography.customLineHeight': 'typography.lineHeight',\n};\n\n/**\n * Remove `custom` prefixes for flags that did not land in 5.8.\n *\n * This provides continued support for `custom` prefixed properties. It will\n * be removed once third party devs have had sufficient time to update themes,\n * plugins, etc.\n *\n * @see https://github.com/WordPress/gutenberg/pull/34485\n *\n * @param {string} path Path to desired value in settings.\n * @return {string} The value for defined setting.\n */\nconst removeCustomPrefixes = ( path ) => {\n\treturn prefixedFlags[ path ] || path;\n};\n\n/**\n * Hook that retrieves the given setting for the block instance in use.\n *\n * It looks up the settings first in the block instance hierarchy.\n * If none is found, it'll look it up in the block editor store.\n *\n * @param {string} path The path to the setting.\n * @return {any} Returns the value defined for the setting.\n * @example\n * ```js\n * const isEnabled = useSetting( 'typography.dropCap' );\n * ```\n */\nexport default function useSetting( path ) {\n\tconst { name: blockName, clientId } = useBlockEditContext();\n\n\tconst setting = useSelect(\n\t\t( select ) => {\n\t\t\tif ( blockedPaths.includes( path ) ) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.warn(\n\t\t\t\t\t'Top level useSetting paths are disabled. Please use a subpath to query the information needed.'\n\t\t\t\t);\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tlet result;\n\t\t\tconst normalizedPath = removeCustomPrefixes( path );\n\n\t\t\t// 1. Take settings from the block instance or its ancestors.\n\t\t\tconst candidates = [\n\t\t\t\t...select( blockEditorStore ).getBlockParents( clientId ),\n\t\t\t\tclientId, // The current block is added last, so it overwrites any ancestor.\n\t\t\t];\n\t\t\tcandidates.forEach( ( candidateClientId ) => {\n\t\t\t\tconst candidateBlockName = select(\n\t\t\t\t\tblockEditorStore\n\t\t\t\t).getBlockName( candidateClientId );\n\t\t\t\tif (\n\t\t\t\t\thasBlockSupport(\n\t\t\t\t\t\tcandidateBlockName,\n\t\t\t\t\t\t'__experimentalSettings',\n\t\t\t\t\t\tfalse\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tconst candidateAtts = select(\n\t\t\t\t\t\tblockEditorStore\n\t\t\t\t\t).getBlockAttributes( candidateClientId );\n\t\t\t\t\tconst candidateResult =\n\t\t\t\t\t\tget(\n\t\t\t\t\t\t\tcandidateAtts,\n\t\t\t\t\t\t\t`settings.blocks.${ blockName }.${ normalizedPath }`\n\t\t\t\t\t\t) ??\n\t\t\t\t\t\tget( candidateAtts, `settings.${ normalizedPath }` );\n\t\t\t\t\tif ( candidateResult !== undefined ) {\n\t\t\t\t\t\tresult = candidateResult;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\t// 2. Fall back to the settings from the block editor store (__experimentalFeatures).\n\t\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\t\tif ( result === undefined ) {\n\t\t\t\tconst defaultsPath = `__experimentalFeatures.${ normalizedPath }`;\n\t\t\t\tconst blockPath = `__experimentalFeatures.blocks.${ blockName }.${ normalizedPath }`;\n\t\t\t\tresult =\n\t\t\t\t\tget( settings, blockPath ) ?? get( settings, defaultsPath );\n\t\t\t}\n\n\t\t\t// Return if the setting was found in either the block instance or the store.\n\t\t\tif ( result !== undefined ) {\n\t\t\t\tif ( PATHS_WITH_MERGE[ normalizedPath ] ) {\n\t\t\t\t\treturn result.custom ?? result.theme ?? result.default;\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\t// 3. Otherwise, use deprecated settings.\n\t\t\tconst deprecatedSettingsValue = deprecatedFlags[ normalizedPath ]\n\t\t\t\t? deprecatedFlags[ normalizedPath ]( settings )\n\t\t\t\t: undefined;\n\t\t\tif ( deprecatedSettingsValue !== undefined ) {\n\t\t\t\treturn deprecatedSettingsValue;\n\t\t\t}\n\n\t\t\t// 4. Fallback for typography.dropCap:\n\t\t\t// This is only necessary to support typography.dropCap.\n\t\t\t// when __experimentalFeatures are not present (core without plugin).\n\t\t\t// To remove when __experimentalFeatures are ported to core.\n\t\t\treturn normalizedPath === 'typography.dropCap' ? true : undefined;\n\t\t},\n\t\t[ blockName, clientId, path ]\n\t);\n\n\treturn setting;\n}\n"]}
|
|
@@ -1,89 +1,322 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import { createElement } from "@wordpress/element";
|
|
2
3
|
|
|
4
|
+
/**
|
|
5
|
+
* External dependencies
|
|
6
|
+
*/
|
|
7
|
+
import classnames from 'classnames';
|
|
3
8
|
/**
|
|
4
9
|
* WordPress dependencies
|
|
5
10
|
*/
|
|
11
|
+
|
|
6
12
|
import { getBlockSupport } from '@wordpress/blocks';
|
|
7
|
-
import { __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';
|
|
13
|
+
import { __experimentalBorderBoxControl as BorderBoxControl, __experimentalHasSplitBorders as hasSplitBorders, __experimentalIsDefinedBorder as isDefinedBorder, __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';
|
|
14
|
+
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
8
15
|
import { Platform } from '@wordpress/element';
|
|
16
|
+
import { addFilter } from '@wordpress/hooks';
|
|
9
17
|
import { __ } from '@wordpress/i18n';
|
|
10
18
|
/**
|
|
11
19
|
* Internal dependencies
|
|
12
20
|
*/
|
|
13
21
|
|
|
14
|
-
import { BorderColorEdit, hasBorderColorValue, resetBorderColor } from './border-color';
|
|
15
22
|
import { BorderRadiusEdit, hasBorderRadiusValue, resetBorderRadius } from './border-radius';
|
|
16
|
-
import {
|
|
17
|
-
import { BorderWidthEdit, hasBorderWidthValue, resetBorderWidth } from './border-width';
|
|
23
|
+
import { getColorClassName } from '../components/colors';
|
|
18
24
|
import InspectorControls from '../components/inspector-controls';
|
|
25
|
+
import useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';
|
|
19
26
|
import useSetting from '../components/use-setting';
|
|
20
|
-
import { cleanEmptyObject } from './utils';
|
|
27
|
+
import { cleanEmptyObject, shouldSkipSerialization } from './utils';
|
|
21
28
|
export const BORDER_SUPPORT_KEY = '__experimentalBorder';
|
|
29
|
+
const borderSides = ['top', 'right', 'bottom', 'left'];
|
|
30
|
+
|
|
31
|
+
const hasBorderValue = props => {
|
|
32
|
+
const {
|
|
33
|
+
borderColor,
|
|
34
|
+
style
|
|
35
|
+
} = props.attributes;
|
|
36
|
+
return isDefinedBorder(style === null || style === void 0 ? void 0 : style.border) || !!borderColor;
|
|
37
|
+
}; // The border color, style, and width are omitted so they get undefined. The
|
|
38
|
+
// border radius is separate and must retain its selection.
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
const resetBorder = _ref => {
|
|
42
|
+
var _style$border;
|
|
43
|
+
|
|
44
|
+
let {
|
|
45
|
+
attributes = {},
|
|
46
|
+
setAttributes
|
|
47
|
+
} = _ref;
|
|
48
|
+
const {
|
|
49
|
+
style
|
|
50
|
+
} = attributes;
|
|
51
|
+
setAttributes({
|
|
52
|
+
borderColor: undefined,
|
|
53
|
+
style: { ...style,
|
|
54
|
+
border: cleanEmptyObject({
|
|
55
|
+
radius: style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.radius
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const resetBorderFilter = newAttributes => {
|
|
62
|
+
var _newAttributes$style, _newAttributes$style$;
|
|
63
|
+
|
|
64
|
+
return { ...newAttributes,
|
|
65
|
+
borderColor: undefined,
|
|
66
|
+
style: { ...newAttributes.style,
|
|
67
|
+
border: {
|
|
68
|
+
radius: (_newAttributes$style = newAttributes.style) === null || _newAttributes$style === void 0 ? void 0 : (_newAttributes$style$ = _newAttributes$style.border) === null || _newAttributes$style$ === void 0 ? void 0 : _newAttributes$style$.radius
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const getColorByProperty = (colors, property, value) => {
|
|
75
|
+
let matchedColor;
|
|
76
|
+
colors.some(origin => origin.colors.some(color => {
|
|
77
|
+
if (color[property] === value) {
|
|
78
|
+
matchedColor = color;
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return false;
|
|
83
|
+
}));
|
|
84
|
+
return matchedColor;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const getMultiOriginColor = _ref2 => {
|
|
88
|
+
let {
|
|
89
|
+
colors,
|
|
90
|
+
namedColor,
|
|
91
|
+
customColor
|
|
92
|
+
} = _ref2;
|
|
93
|
+
|
|
94
|
+
// Search each origin (default, theme, or user) for matching color by name.
|
|
95
|
+
if (namedColor) {
|
|
96
|
+
const colorObject = getColorByProperty(colors, 'slug', namedColor);
|
|
97
|
+
|
|
98
|
+
if (colorObject) {
|
|
99
|
+
return colorObject;
|
|
100
|
+
}
|
|
101
|
+
} // Skip if no custom color or matching named color.
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
if (!customColor) {
|
|
105
|
+
return {
|
|
106
|
+
color: undefined
|
|
107
|
+
};
|
|
108
|
+
} // Attempt to find color via custom color value or build new object.
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
const colorObject = getColorByProperty(colors, 'color', customColor);
|
|
112
|
+
return colorObject ? colorObject : {
|
|
113
|
+
color: customColor
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const getBorderObject = (attributes, colors) => {
|
|
118
|
+
const {
|
|
119
|
+
borderColor,
|
|
120
|
+
style
|
|
121
|
+
} = attributes;
|
|
122
|
+
const {
|
|
123
|
+
border: borderStyles
|
|
124
|
+
} = style || {}; // If we have a named color for a flat border. Fetch that color object and
|
|
125
|
+
// apply that color's value to the color property within the style object.
|
|
126
|
+
|
|
127
|
+
if (borderColor) {
|
|
128
|
+
const {
|
|
129
|
+
color
|
|
130
|
+
} = getMultiOriginColor({
|
|
131
|
+
colors,
|
|
132
|
+
namedColor: borderColor
|
|
133
|
+
});
|
|
134
|
+
return color ? { ...borderStyles,
|
|
135
|
+
color
|
|
136
|
+
} : borderStyles;
|
|
137
|
+
} // Individual side border color slugs are stored within the border style
|
|
138
|
+
// object. If we don't have a border styles object we have nothing further
|
|
139
|
+
// to hydrate.
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
if (!borderStyles) {
|
|
143
|
+
return borderStyles;
|
|
144
|
+
} // If we have named colors for the individual side borders, retrieve their
|
|
145
|
+
// related color objects and apply the real color values to the split
|
|
146
|
+
// border objects.
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
const hydratedBorderStyles = { ...borderStyles
|
|
150
|
+
};
|
|
151
|
+
borderSides.forEach(side => {
|
|
152
|
+
var _hydratedBorderStyles;
|
|
153
|
+
|
|
154
|
+
const colorSlug = getColorSlugFromVariable((_hydratedBorderStyles = hydratedBorderStyles[side]) === null || _hydratedBorderStyles === void 0 ? void 0 : _hydratedBorderStyles.color);
|
|
155
|
+
|
|
156
|
+
if (colorSlug) {
|
|
157
|
+
const {
|
|
158
|
+
color
|
|
159
|
+
} = getMultiOriginColor({
|
|
160
|
+
colors,
|
|
161
|
+
namedColor: colorSlug
|
|
162
|
+
});
|
|
163
|
+
hydratedBorderStyles[side] = { ...hydratedBorderStyles[side],
|
|
164
|
+
color
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
return hydratedBorderStyles;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
function getColorSlugFromVariable(value) {
|
|
172
|
+
const namedColor = /var:preset\|color\|(.+)/.exec(value);
|
|
173
|
+
|
|
174
|
+
if (namedColor && namedColor[1]) {
|
|
175
|
+
return namedColor[1];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
|
|
22
181
|
export function BorderPanel(props) {
|
|
23
182
|
const {
|
|
24
|
-
|
|
183
|
+
attributes,
|
|
184
|
+
clientId,
|
|
185
|
+
setAttributes
|
|
25
186
|
} = props;
|
|
187
|
+
const {
|
|
188
|
+
style
|
|
189
|
+
} = attributes;
|
|
190
|
+
const {
|
|
191
|
+
colors
|
|
192
|
+
} = useMultipleOriginColorsAndGradients();
|
|
193
|
+
const isSupported = hasBorderSupport(props.name);
|
|
26
194
|
const isColorSupported = useSetting('border.color') && hasBorderSupport(props.name, 'color');
|
|
27
195
|
const isRadiusSupported = useSetting('border.radius') && hasBorderSupport(props.name, 'radius');
|
|
28
196
|
const isStyleSupported = useSetting('border.style') && hasBorderSupport(props.name, 'style');
|
|
29
197
|
const isWidthSupported = useSetting('border.width') && hasBorderSupport(props.name, 'width');
|
|
30
198
|
const isDisabled = [!isColorSupported, !isRadiusSupported, !isStyleSupported, !isWidthSupported].every(Boolean);
|
|
31
199
|
|
|
32
|
-
if (isDisabled) {
|
|
200
|
+
if (isDisabled || !isSupported) {
|
|
33
201
|
return null;
|
|
34
202
|
}
|
|
35
203
|
|
|
36
204
|
const defaultBorderControls = getBlockSupport(props.name, [BORDER_SUPPORT_KEY, '__experimentalDefaultControls']);
|
|
205
|
+
const showBorderByDefault = (defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.color) || (defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.width);
|
|
37
206
|
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
return newAttributes => {
|
|
41
|
-
var _newAttributes$style;
|
|
207
|
+
const onBorderChange = newBorder => {
|
|
208
|
+
var _style$border2;
|
|
42
209
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
210
|
+
// Filter out named colors and apply them to appropriate block
|
|
211
|
+
// attributes so that CSS classes can be used to apply those colors.
|
|
212
|
+
// e.g. has-primary-border-top-color.
|
|
213
|
+
let newBorderStyles = { ...newBorder
|
|
214
|
+
};
|
|
215
|
+
let newBorderColor;
|
|
216
|
+
|
|
217
|
+
if (hasSplitBorders(newBorder)) {
|
|
218
|
+
// For each side check if the side has a color value set
|
|
219
|
+
// If so, determine if it belongs to a named color, in which case
|
|
220
|
+
// we update the color property.
|
|
221
|
+
//
|
|
222
|
+
// This deliberately overwrites `newBorderStyles` to avoid mutating
|
|
223
|
+
// the passed object which causes problems otherwise.
|
|
224
|
+
newBorderStyles = {
|
|
225
|
+
top: { ...newBorder.top
|
|
226
|
+
},
|
|
227
|
+
right: { ...newBorder.right
|
|
228
|
+
},
|
|
229
|
+
bottom: { ...newBorder.bottom
|
|
230
|
+
},
|
|
231
|
+
left: { ...newBorder.left
|
|
49
232
|
}
|
|
50
233
|
};
|
|
51
|
-
|
|
234
|
+
borderSides.forEach(side => {
|
|
235
|
+
var _newBorder$side;
|
|
236
|
+
|
|
237
|
+
if ((_newBorder$side = newBorder[side]) !== null && _newBorder$side !== void 0 && _newBorder$side.color) {
|
|
238
|
+
var _newBorder$side2;
|
|
239
|
+
|
|
240
|
+
const colorObject = getMultiOriginColor({
|
|
241
|
+
colors,
|
|
242
|
+
customColor: (_newBorder$side2 = newBorder[side]) === null || _newBorder$side2 === void 0 ? void 0 : _newBorder$side2.color
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
if (colorObject.slug) {
|
|
246
|
+
newBorderStyles[side].color = `var:preset|color|${colorObject.slug}`;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
} else if (newBorder !== null && newBorder !== void 0 && newBorder.color) {
|
|
251
|
+
// We have a flat border configuration. Apply named color slug to
|
|
252
|
+
// `borderColor` attribute and clear color style property if found.
|
|
253
|
+
const customColor = newBorder === null || newBorder === void 0 ? void 0 : newBorder.color;
|
|
254
|
+
const colorObject = getMultiOriginColor({
|
|
255
|
+
colors,
|
|
256
|
+
customColor
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
if (colorObject.slug) {
|
|
260
|
+
newBorderColor = colorObject.slug;
|
|
261
|
+
newBorderStyles.color = undefined;
|
|
262
|
+
}
|
|
263
|
+
} // Ensure previous border radius styles are maintained and clean
|
|
264
|
+
// overall result for empty objects or properties.
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
const newStyle = cleanEmptyObject({ ...style,
|
|
268
|
+
border: {
|
|
269
|
+
radius: style === null || style === void 0 ? void 0 : (_style$border2 = style.border) === null || _style$border2 === void 0 ? void 0 : _style$border2.radius,
|
|
270
|
+
...newBorderStyles
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
setAttributes({
|
|
274
|
+
style: newStyle,
|
|
275
|
+
borderColor: newBorderColor
|
|
276
|
+
});
|
|
52
277
|
};
|
|
53
278
|
|
|
279
|
+
const hydratedBorder = getBorderObject(attributes, colors);
|
|
54
280
|
return createElement(InspectorControls, {
|
|
55
281
|
__experimentalGroup: "border"
|
|
56
|
-
}, isWidthSupported && createElement(ToolsPanelItem, {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
resetAllFilter: createResetAllFilter('width'),
|
|
63
|
-
panelId: clientId
|
|
64
|
-
}, createElement(BorderWidthEdit, props)), isStyleSupported && createElement(ToolsPanelItem, {
|
|
65
|
-
className: "single-column",
|
|
66
|
-
hasValue: () => hasBorderStyleValue(props),
|
|
67
|
-
label: __('Style'),
|
|
68
|
-
onDeselect: () => resetBorderStyle(props),
|
|
69
|
-
isShownByDefault: defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.style,
|
|
70
|
-
resetAllFilter: createResetAllFilter('style'),
|
|
71
|
-
panelId: clientId
|
|
72
|
-
}, createElement(BorderStyleEdit, props)), isColorSupported && createElement(ToolsPanelItem, {
|
|
73
|
-
hasValue: () => hasBorderColorValue(props),
|
|
74
|
-
label: __('Color'),
|
|
75
|
-
onDeselect: () => resetBorderColor(props),
|
|
76
|
-
isShownByDefault: defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.color,
|
|
77
|
-
resetAllFilter: createResetAllFilter('color', {
|
|
78
|
-
borderColor: undefined
|
|
79
|
-
}),
|
|
282
|
+
}, (isWidthSupported || isColorSupported) && createElement(ToolsPanelItem, {
|
|
283
|
+
hasValue: () => hasBorderValue(props),
|
|
284
|
+
label: __('Border'),
|
|
285
|
+
onDeselect: () => resetBorder(props),
|
|
286
|
+
isShownByDefault: showBorderByDefault,
|
|
287
|
+
resetAllFilter: resetBorderFilter,
|
|
80
288
|
panelId: clientId
|
|
81
|
-
}, createElement(
|
|
289
|
+
}, createElement(BorderBoxControl, {
|
|
290
|
+
colors: colors,
|
|
291
|
+
enableAlpha: true,
|
|
292
|
+
onChange: onBorderChange,
|
|
293
|
+
popoverClassNames: {
|
|
294
|
+
linked: 'block-editor__border-box-control__popover',
|
|
295
|
+
top: 'block-editor__border-box-control__popover-top',
|
|
296
|
+
right: 'block-editor__border-box-control__popover-right',
|
|
297
|
+
bottom: 'block-editor__border-box-control__popover-bottom',
|
|
298
|
+
left: 'block-editor__border-box-control__popover-left'
|
|
299
|
+
},
|
|
300
|
+
showStyle: isStyleSupported,
|
|
301
|
+
value: hydratedBorder,
|
|
302
|
+
__experimentalHasMultipleOrigins: true,
|
|
303
|
+
__experimentalIsRenderedInSidebar: true
|
|
304
|
+
})), isRadiusSupported && createElement(ToolsPanelItem, {
|
|
82
305
|
hasValue: () => hasBorderRadiusValue(props),
|
|
83
306
|
label: __('Radius'),
|
|
84
307
|
onDeselect: () => resetBorderRadius(props),
|
|
85
308
|
isShownByDefault: defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.radius,
|
|
86
|
-
resetAllFilter:
|
|
309
|
+
resetAllFilter: newAttributes => {
|
|
310
|
+
var _newAttributes$style2;
|
|
311
|
+
|
|
312
|
+
return { ...newAttributes,
|
|
313
|
+
style: { ...newAttributes.style,
|
|
314
|
+
border: { ...((_newAttributes$style2 = newAttributes.style) === null || _newAttributes$style2 === void 0 ? void 0 : _newAttributes$style2.border),
|
|
315
|
+
radius: undefined
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
},
|
|
87
320
|
panelId: clientId
|
|
88
321
|
}, createElement(BorderRadiusEdit, props)));
|
|
89
322
|
}
|
|
@@ -132,4 +365,185 @@ export function removeBorderAttribute(style, attribute) {
|
|
|
132
365
|
}
|
|
133
366
|
});
|
|
134
367
|
}
|
|
368
|
+
/**
|
|
369
|
+
* Filters registered block settings, extending attributes to include
|
|
370
|
+
* `borderColor` if needed.
|
|
371
|
+
*
|
|
372
|
+
* @param {Object} settings Original block settings.
|
|
373
|
+
*
|
|
374
|
+
* @return {Object} Updated block settings.
|
|
375
|
+
*/
|
|
376
|
+
|
|
377
|
+
function addAttributes(settings) {
|
|
378
|
+
if (!hasBorderSupport(settings, 'color')) {
|
|
379
|
+
return settings;
|
|
380
|
+
} // Allow blocks to specify default value if needed.
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
if (settings.attributes.borderColor) {
|
|
384
|
+
return settings;
|
|
385
|
+
} // Add new borderColor attribute to block settings.
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
return { ...settings,
|
|
389
|
+
attributes: { ...settings.attributes,
|
|
390
|
+
borderColor: {
|
|
391
|
+
type: 'string'
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Override props assigned to save component to inject border color.
|
|
398
|
+
*
|
|
399
|
+
* @param {Object} props Additional props applied to save element.
|
|
400
|
+
* @param {Object} blockType Block type definition.
|
|
401
|
+
* @param {Object} attributes Block's attributes.
|
|
402
|
+
*
|
|
403
|
+
* @return {Object} Filtered props to apply to save element.
|
|
404
|
+
*/
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
function addSaveProps(props, blockType, attributes) {
|
|
408
|
+
if (!hasBorderSupport(blockType, 'color') || shouldSkipSerialization(blockType, BORDER_SUPPORT_KEY, 'color')) {
|
|
409
|
+
return props;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
const borderClasses = getBorderClasses(attributes);
|
|
413
|
+
const newClassName = classnames(props.className, borderClasses); // If we are clearing the last of the previous classes in `className`
|
|
414
|
+
// set it to `undefined` to avoid rendering empty DOM attributes.
|
|
415
|
+
|
|
416
|
+
props.className = newClassName ? newClassName : undefined;
|
|
417
|
+
return props;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Generates a CSS class name consisting of all the applicable border color
|
|
421
|
+
* classes given the current block attributes.
|
|
422
|
+
*
|
|
423
|
+
* @param {Object} attributes Block's attributes.
|
|
424
|
+
*
|
|
425
|
+
* @return {string} CSS class name.
|
|
426
|
+
*/
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
export function getBorderClasses(attributes) {
|
|
430
|
+
var _style$border3;
|
|
431
|
+
|
|
432
|
+
const {
|
|
433
|
+
borderColor,
|
|
434
|
+
style
|
|
435
|
+
} = attributes;
|
|
436
|
+
const borderColorClass = getColorClassName('border-color', borderColor);
|
|
437
|
+
return classnames({
|
|
438
|
+
'has-border-color': borderColor || (style === null || style === void 0 ? void 0 : (_style$border3 = style.border) === null || _style$border3 === void 0 ? void 0 : _style$border3.color),
|
|
439
|
+
[borderColorClass]: !!borderColorClass
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Filters the registered block settings to apply border color styles and
|
|
444
|
+
* classnames to the block edit wrapper.
|
|
445
|
+
*
|
|
446
|
+
* @param {Object} settings Original block settings.
|
|
447
|
+
*
|
|
448
|
+
* @return {Object} Filtered block settings.
|
|
449
|
+
*/
|
|
450
|
+
|
|
451
|
+
function addEditProps(settings) {
|
|
452
|
+
if (!hasBorderSupport(settings, 'color') || shouldSkipSerialization(settings, BORDER_SUPPORT_KEY, 'color')) {
|
|
453
|
+
return settings;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
const existingGetEditWrapperProps = settings.getEditWrapperProps;
|
|
457
|
+
|
|
458
|
+
settings.getEditWrapperProps = attributes => {
|
|
459
|
+
let props = {};
|
|
460
|
+
|
|
461
|
+
if (existingGetEditWrapperProps) {
|
|
462
|
+
props = existingGetEditWrapperProps(attributes);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
return addSaveProps(props, settings, attributes);
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
return settings;
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* This adds inline styles for color palette colors.
|
|
472
|
+
* Ideally, this is not needed and themes should load their palettes on the editor.
|
|
473
|
+
*
|
|
474
|
+
* @param {Function} BlockListBlock Original component.
|
|
475
|
+
*
|
|
476
|
+
* @return {Function} Wrapped component.
|
|
477
|
+
*/
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
export const withBorderColorPaletteStyles = createHigherOrderComponent(BlockListBlock => props => {
|
|
481
|
+
var _style$border4, _style$border4$top, _style$border5, _style$border5$right, _style$border6, _style$border6$bottom, _style$border7, _style$border7$left, _props$wrapperProps;
|
|
482
|
+
|
|
483
|
+
const {
|
|
484
|
+
name,
|
|
485
|
+
attributes
|
|
486
|
+
} = props;
|
|
487
|
+
const {
|
|
488
|
+
borderColor,
|
|
489
|
+
style
|
|
490
|
+
} = attributes;
|
|
491
|
+
const {
|
|
492
|
+
colors
|
|
493
|
+
} = useMultipleOriginColorsAndGradients();
|
|
494
|
+
|
|
495
|
+
if (!hasBorderSupport(name, 'color') || shouldSkipSerialization(name, BORDER_SUPPORT_KEY, 'color')) {
|
|
496
|
+
return createElement(BlockListBlock, props);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
const {
|
|
500
|
+
color: borderColorValue
|
|
501
|
+
} = getMultiOriginColor({
|
|
502
|
+
colors,
|
|
503
|
+
namedColor: borderColor
|
|
504
|
+
});
|
|
505
|
+
const {
|
|
506
|
+
color: borderTopColor
|
|
507
|
+
} = getMultiOriginColor({
|
|
508
|
+
colors,
|
|
509
|
+
namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border4 = style.border) === null || _style$border4 === void 0 ? void 0 : (_style$border4$top = _style$border4.top) === null || _style$border4$top === void 0 ? void 0 : _style$border4$top.color)
|
|
510
|
+
});
|
|
511
|
+
const {
|
|
512
|
+
color: borderRightColor
|
|
513
|
+
} = getMultiOriginColor({
|
|
514
|
+
colors,
|
|
515
|
+
namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border5 = style.border) === null || _style$border5 === void 0 ? void 0 : (_style$border5$right = _style$border5.right) === null || _style$border5$right === void 0 ? void 0 : _style$border5$right.color)
|
|
516
|
+
});
|
|
517
|
+
const {
|
|
518
|
+
color: borderBottomColor
|
|
519
|
+
} = getMultiOriginColor({
|
|
520
|
+
colors,
|
|
521
|
+
namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border6 = style.border) === null || _style$border6 === void 0 ? void 0 : (_style$border6$bottom = _style$border6.bottom) === null || _style$border6$bottom === void 0 ? void 0 : _style$border6$bottom.color)
|
|
522
|
+
});
|
|
523
|
+
const {
|
|
524
|
+
color: borderLeftColor
|
|
525
|
+
} = getMultiOriginColor({
|
|
526
|
+
colors,
|
|
527
|
+
namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border7 = style.border) === null || _style$border7 === void 0 ? void 0 : (_style$border7$left = _style$border7.left) === null || _style$border7$left === void 0 ? void 0 : _style$border7$left.color)
|
|
528
|
+
});
|
|
529
|
+
const extraStyles = {
|
|
530
|
+
borderTopColor: borderTopColor || borderColorValue,
|
|
531
|
+
borderRightColor: borderRightColor || borderColorValue,
|
|
532
|
+
borderBottomColor: borderBottomColor || borderColorValue,
|
|
533
|
+
borderLeftColor: borderLeftColor || borderColorValue
|
|
534
|
+
};
|
|
535
|
+
let wrapperProps = props.wrapperProps;
|
|
536
|
+
wrapperProps = { ...props.wrapperProps,
|
|
537
|
+
style: { ...((_props$wrapperProps = props.wrapperProps) === null || _props$wrapperProps === void 0 ? void 0 : _props$wrapperProps.style),
|
|
538
|
+
...extraStyles
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
return createElement(BlockListBlock, _extends({}, props, {
|
|
542
|
+
wrapperProps: wrapperProps
|
|
543
|
+
}));
|
|
544
|
+
});
|
|
545
|
+
addFilter('blocks.registerBlockType', 'core/border/addAttributes', addAttributes);
|
|
546
|
+
addFilter('blocks.getSaveContent.extraProps', 'core/border/addSaveProps', addSaveProps);
|
|
547
|
+
addFilter('blocks.registerBlockType', 'core/border/addEditProps', addEditProps);
|
|
548
|
+
addFilter('editor.BlockListBlock', 'core/border/with-border-color-palette-styles', withBorderColorPaletteStyles);
|
|
135
549
|
//# sourceMappingURL=border.js.map
|