@wordpress/block-editor 15.22.1-next.v.202606191442.0 → 15.22.1
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 +1 -1
- package/README.md +2 -2
- package/build/components/block-editing-mode/index.cjs +13 -7
- package/build/components/block-editing-mode/index.cjs.map +2 -2
- package/build/components/block-inspector/index.cjs +32 -16
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-rename/modal.cjs +0 -1
- package/build/components/block-rename/modal.cjs.map +2 -2
- package/build/components/block-toolbar/block-toolbar-icon.cjs +14 -6
- package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
- package/build/components/colors-gradients/control.cjs +25 -14
- package/build/components/colors-gradients/control.cjs.map +2 -2
- package/build/components/colors-gradients/dropdown.cjs +4 -1
- package/build/components/colors-gradients/dropdown.cjs.map +3 -3
- package/build/components/contrast-checker/index.cjs +22 -4
- package/build/components/contrast-checker/index.cjs.map +2 -2
- package/build/components/date-format-picker/index.cjs +0 -1
- package/build/components/date-format-picker/index.cjs.map +2 -2
- package/build/components/global-styles/background-panel.cjs +153 -25
- package/build/components/global-styles/background-panel.cjs.map +3 -3
- package/build/components/global-styles/color-gradient-dropdown-item.cjs +227 -0
- package/build/components/global-styles/color-gradient-dropdown-item.cjs.map +7 -0
- package/build/components/global-styles/color-panel.cjs +98 -375
- package/build/components/global-styles/color-panel.cjs.map +3 -3
- package/build/components/global-styles/dimensions-panel.cjs +0 -3
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/global-styles/hooks.cjs +34 -0
- package/build/components/global-styles/hooks.cjs.map +2 -2
- package/build/components/global-styles/typography-panel.cjs +82 -10
- package/build/components/global-styles/typography-panel.cjs.map +3 -3
- package/build/components/inspector-controls/groups.cjs +2 -0
- package/build/components/inspector-controls/groups.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/styles-tab.cjs +75 -31
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/components/link-control/index.cjs +1 -2
- package/build/components/link-control/index.cjs.map +2 -2
- package/build/components/list-view/block-select-button.cjs +1 -10
- package/build/components/list-view/block-select-button.cjs.map +3 -3
- package/build/components/provider/use-block-sync.cjs +3 -1
- package/build/components/provider/use-block-sync.cjs.map +2 -2
- package/build/components/url-popover/image-url-input-ui.cjs +0 -2
- package/build/components/url-popover/image-url-input-ui.cjs.map +2 -2
- package/build/components/use-block-display-information/index.cjs +10 -3
- package/build/components/use-block-display-information/index.cjs.map +2 -2
- package/build/hooks/anchor.cjs +0 -1
- package/build/hooks/anchor.cjs.map +2 -2
- package/build/hooks/background.cjs +124 -75
- package/build/hooks/background.cjs.map +3 -3
- package/build/hooks/color.cjs +0 -162
- package/build/hooks/color.cjs.map +3 -3
- package/build/hooks/contrast-checker.cjs +31 -28
- package/build/hooks/contrast-checker.cjs.map +3 -3
- package/build/hooks/custom-class-name.cjs +0 -1
- package/build/hooks/custom-class-name.cjs.map +2 -2
- package/build/hooks/elements.cjs +142 -0
- package/build/hooks/elements.cjs.map +7 -0
- package/build/hooks/grid-visualizer.cjs +21 -11
- package/build/hooks/grid-visualizer.cjs.map +2 -2
- package/build/hooks/layout-child.cjs +38 -8
- package/build/hooks/layout-child.cjs.map +2 -2
- package/build/hooks/layout.cjs +6 -3
- package/build/hooks/layout.cjs.map +2 -2
- package/build/hooks/states.cjs +2 -2
- package/build/hooks/states.cjs.map +2 -2
- package/build/hooks/style.cjs +8 -4
- package/build/hooks/style.cjs.map +2 -2
- package/build/hooks/typography.cjs +62 -10
- package/build/hooks/typography.cjs.map +3 -3
- package/build/layouts/flex.cjs +99 -6
- package/build/layouts/flex.cjs.map +2 -2
- package/build/utils/block-bindings.cjs +9 -9
- package/build/utils/block-bindings.cjs.map +3 -3
- package/build/utils/color-values.cjs +10 -1
- package/build/utils/color-values.cjs.map +3 -3
- package/build/utils/dom.cjs +2 -5
- package/build/utils/dom.cjs.map +3 -3
- package/build/utils/fit-text-frontend.cjs +6 -2
- package/build/utils/fit-text-frontend.cjs.map +3 -3
- package/build/utils/fit-text-utils.cjs +1 -1
- package/build/utils/fit-text-utils.cjs.map +3 -3
- package/build/utils/format-font-style.cjs +1 -1
- package/build/utils/format-font-style.cjs.map +3 -3
- package/build/utils/format-font-weight.cjs +1 -1
- package/build/utils/format-font-weight.cjs.map +3 -3
- package/build/utils/get-editor-region.cjs +4 -2
- package/build/utils/get-editor-region.cjs.map +3 -3
- package/build/utils/get-font-styles-and-weights.cjs +8 -12
- package/build/utils/get-font-styles-and-weights.cjs.map +3 -3
- package/build/utils/get-px-from-css-unit.cjs +1 -1
- package/build/utils/get-px-from-css-unit.cjs.map +1 -1
- package/build/utils/index.cjs +1 -1
- package/build/utils/index.cjs.map +1 -1
- package/build/utils/math.cjs +1 -1
- package/build/utils/math.cjs.map +3 -3
- package/build/utils/object.cjs +8 -8
- package/build/utils/object.cjs.map +3 -3
- package/build/utils/order-inserter-block-items.cjs +1 -1
- package/build/utils/order-inserter-block-items.cjs.map +3 -3
- package/build/utils/pasting.cjs +4 -2
- package/build/utils/pasting.cjs.map +3 -3
- package/build/utils/selection.cjs +2 -1
- package/build/utils/selection.cjs.map +3 -3
- package/build/utils/sorting.cjs +9 -3
- package/build/utils/sorting.cjs.map +3 -3
- package/build/utils/transform-styles/index.cjs +3 -2
- package/build/utils/transform-styles/index.cjs.map +3 -3
- package/build/utils/transform-styles/postcss-urlrebase.d.cjs +2 -0
- package/build/utils/transform-styles/postcss-urlrebase.d.cjs.map +7 -0
- package/build/utils/transform-styles/types.cjs +19 -0
- package/build/utils/transform-styles/types.cjs.map +7 -0
- package/build/utils/types.cjs +19 -0
- package/build/utils/types.cjs.map +7 -0
- package/build-module/components/block-editing-mode/index.mjs +14 -8
- package/build-module/components/block-editing-mode/index.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +32 -16
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-rename/modal.mjs +0 -1
- package/build-module/components/block-rename/modal.mjs.map +2 -2
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs +14 -6
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
- package/build-module/components/colors-gradients/control.mjs +27 -15
- package/build-module/components/colors-gradients/control.mjs.map +2 -2
- package/build-module/components/colors-gradients/dropdown.mjs +4 -1
- package/build-module/components/colors-gradients/dropdown.mjs.map +2 -2
- package/build-module/components/contrast-checker/index.mjs +18 -4
- package/build-module/components/contrast-checker/index.mjs.map +2 -2
- package/build-module/components/date-format-picker/index.mjs +0 -1
- package/build-module/components/date-format-picker/index.mjs.map +2 -2
- package/build-module/components/global-styles/background-panel.mjs +155 -27
- package/build-module/components/global-styles/background-panel.mjs.map +2 -2
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs +207 -0
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs.map +7 -0
- package/build-module/components/global-styles/color-panel.mjs +106 -387
- package/build-module/components/global-styles/color-panel.mjs.map +3 -3
- package/build-module/components/global-styles/dimensions-panel.mjs +0 -3
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/global-styles/hooks.mjs +33 -0
- package/build-module/components/global-styles/hooks.mjs.map +2 -2
- package/build-module/components/global-styles/typography-panel.mjs +84 -10
- package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
- package/build-module/components/inspector-controls/groups.mjs +2 -0
- package/build-module/components/inspector-controls/groups.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +75 -31
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/link-control/index.mjs +1 -2
- package/build-module/components/link-control/index.mjs.map +2 -2
- package/build-module/components/list-view/block-select-button.mjs +2 -17
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/provider/use-block-sync.mjs +3 -1
- package/build-module/components/provider/use-block-sync.mjs.map +2 -2
- package/build-module/components/url-popover/image-url-input-ui.mjs +0 -2
- package/build-module/components/url-popover/image-url-input-ui.mjs.map +2 -2
- package/build-module/components/use-block-display-information/index.mjs +10 -3
- package/build-module/components/use-block-display-information/index.mjs.map +2 -2
- package/build-module/hooks/anchor.mjs +0 -1
- package/build-module/hooks/anchor.mjs.map +2 -2
- package/build-module/hooks/background.mjs +123 -75
- package/build-module/hooks/background.mjs.map +2 -2
- package/build-module/hooks/color.mjs +2 -175
- package/build-module/hooks/color.mjs.map +2 -2
- package/build-module/hooks/contrast-checker.mjs +32 -19
- package/build-module/hooks/contrast-checker.mjs.map +2 -2
- package/build-module/hooks/custom-class-name.mjs +0 -1
- package/build-module/hooks/custom-class-name.mjs.map +2 -2
- package/build-module/hooks/elements.mjs +115 -0
- package/build-module/hooks/elements.mjs.map +7 -0
- package/build-module/hooks/grid-visualizer.mjs +21 -11
- package/build-module/hooks/grid-visualizer.mjs.map +2 -2
- package/build-module/hooks/layout-child.mjs +41 -8
- package/build-module/hooks/layout-child.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +6 -3
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/states.mjs +2 -2
- package/build-module/hooks/states.mjs.map +2 -2
- package/build-module/hooks/style.mjs +9 -5
- package/build-module/hooks/style.mjs.map +2 -2
- package/build-module/hooks/typography.mjs +62 -10
- package/build-module/hooks/typography.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +105 -7
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/utils/block-bindings.mjs +9 -9
- package/build-module/utils/block-bindings.mjs.map +3 -3
- package/build-module/utils/color-values.mjs +9 -1
- package/build-module/utils/color-values.mjs.map +3 -3
- package/build-module/utils/dom.mjs +2 -5
- package/build-module/utils/dom.mjs.map +3 -3
- package/build-module/utils/fit-text-frontend.mjs +6 -2
- package/build-module/utils/fit-text-frontend.mjs.map +3 -3
- package/build-module/utils/fit-text-utils.mjs +1 -1
- package/build-module/utils/fit-text-utils.mjs.map +3 -3
- package/build-module/utils/format-font-style.mjs +1 -1
- package/build-module/utils/format-font-style.mjs.map +3 -3
- package/build-module/utils/format-font-weight.mjs +1 -1
- package/build-module/utils/format-font-weight.mjs.map +3 -3
- package/build-module/utils/get-editor-region.mjs +4 -2
- package/build-module/utils/get-editor-region.mjs.map +3 -3
- package/build-module/utils/get-font-styles-and-weights.mjs +8 -12
- package/build-module/utils/get-font-styles-and-weights.mjs.map +3 -3
- package/build-module/utils/get-px-from-css-unit.mjs +1 -1
- package/build-module/utils/get-px-from-css-unit.mjs.map +1 -1
- package/build-module/utils/index.mjs +1 -1
- package/build-module/utils/index.mjs.map +1 -1
- package/build-module/utils/math.mjs +1 -1
- package/build-module/utils/math.mjs.map +3 -3
- package/build-module/utils/object.mjs +8 -8
- package/build-module/utils/object.mjs.map +3 -3
- package/build-module/utils/order-inserter-block-items.mjs +1 -1
- package/build-module/utils/order-inserter-block-items.mjs.map +3 -3
- package/build-module/utils/pasting.mjs +4 -2
- package/build-module/utils/pasting.mjs.map +3 -3
- package/build-module/utils/selection.mjs +2 -1
- package/build-module/utils/selection.mjs.map +3 -3
- package/build-module/utils/sorting.mjs +9 -3
- package/build-module/utils/sorting.mjs.map +3 -3
- package/build-module/utils/transform-styles/index.mjs +3 -2
- package/build-module/utils/transform-styles/index.mjs.map +3 -3
- package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs +1 -0
- package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs.map +7 -0
- package/build-module/utils/transform-styles/types.mjs +1 -0
- package/build-module/utils/transform-styles/types.mjs.map +7 -0
- package/build-module/utils/types.mjs +1 -0
- package/build-module/utils/types.mjs.map +7 -0
- package/build-style/content-rtl.css +2 -0
- package/build-style/content.css +2 -0
- package/build-style/style-rtl.css +34 -41
- package/build-style/style.css +34 -41
- package/build-types/utils/block-bindings.d.ts +27 -0
- package/build-types/utils/block-bindings.d.ts.map +1 -0
- package/build-types/utils/color-values.d.ts +40 -0
- package/build-types/utils/color-values.d.ts.map +1 -0
- package/build-types/utils/dom.d.ts +19 -19
- package/build-types/utils/dom.d.ts.map +1 -1
- package/build-types/utils/fit-text-frontend.d.ts +7 -0
- package/build-types/utils/fit-text-frontend.d.ts.map +1 -0
- package/build-types/utils/fit-text-utils.d.ts +15 -0
- package/build-types/utils/fit-text-utils.d.ts.map +1 -0
- package/build-types/utils/format-font-style.d.ts +12 -0
- package/build-types/utils/format-font-style.d.ts.map +1 -0
- package/build-types/utils/format-font-weight.d.ts +12 -0
- package/build-types/utils/format-font-weight.d.ts.map +1 -0
- package/build-types/utils/get-editor-region.d.ts +9 -0
- package/build-types/utils/get-editor-region.d.ts.map +1 -0
- package/build-types/utils/get-font-styles-and-weights.d.ts +16 -0
- package/build-types/utils/get-font-styles-and-weights.d.ts.map +1 -0
- package/build-types/utils/get-px-from-css-unit.d.ts +10 -0
- package/build-types/utils/get-px-from-css-unit.d.ts.map +1 -0
- package/build-types/utils/index.d.ts +3 -0
- package/build-types/utils/index.d.ts.map +1 -0
- package/build-types/utils/math.d.ts +61 -0
- package/build-types/utils/math.d.ts.map +1 -0
- package/build-types/utils/object.d.ts +39 -0
- package/build-types/utils/object.d.ts.map +1 -0
- package/build-types/utils/order-inserter-block-items.d.ts +13 -0
- package/build-types/utils/order-inserter-block-items.d.ts.map +1 -0
- package/build-types/utils/pasting.d.ts +28 -0
- package/build-types/utils/pasting.d.ts.map +1 -0
- package/build-types/utils/selection.d.ts +21 -0
- package/build-types/utils/selection.d.ts.map +1 -0
- package/build-types/utils/sorting.d.ts +17 -0
- package/build-types/utils/sorting.d.ts.map +1 -0
- package/build-types/utils/transform-styles/index.d.ts +15 -0
- package/build-types/utils/transform-styles/index.d.ts.map +1 -0
- package/build-types/utils/transform-styles/types.d.ts +13 -0
- package/build-types/utils/transform-styles/types.d.ts.map +1 -0
- package/build-types/utils/types.d.ts +28 -0
- package/build-types/utils/types.d.ts.map +1 -0
- package/package.json +40 -39
- package/src/components/alignment-control/test/__snapshots__/index.js.snap +6 -0
- package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +5 -0
- package/src/components/block-editing-mode/index.js +17 -9
- package/src/components/block-icon/test/__snapshots__/index.js.snap +1 -0
- package/src/components/block-inspector/index.js +20 -10
- package/src/components/block-rename/modal.js +0 -1
- package/src/components/block-toolbar/block-toolbar-icon.js +22 -6
- package/src/components/block-toolbar/test/block-toolbar-icon.js +99 -0
- package/src/components/block-vertical-alignment-control/test/__snapshots__/index.js.snap +4 -0
- package/src/components/colors-gradients/control.js +29 -12
- package/src/components/colors-gradients/dropdown.js +4 -1
- package/src/components/colors-gradients/style.scss +39 -2
- package/src/components/contrast-checker/README.md +9 -0
- package/src/components/contrast-checker/index.js +42 -3
- package/src/components/date-format-picker/index.js +0 -1
- package/src/components/default-block-appender/content.scss +3 -0
- package/src/components/global-styles/background-panel.js +201 -34
- package/src/components/global-styles/color-gradient-dropdown-item.js +258 -0
- package/src/components/global-styles/color-panel.js +125 -487
- package/src/components/global-styles/dimensions-panel.js +0 -3
- package/src/components/global-styles/hooks.js +45 -0
- package/src/components/global-styles/test/background-panel.js +56 -0
- package/src/components/global-styles/test/color-panel.js +172 -118
- package/src/components/global-styles/test/typography-panel.js +167 -0
- package/src/components/global-styles/typography-panel.js +100 -11
- package/src/components/inspector-controls/README.md +0 -2
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +74 -28
- package/src/components/link-control/index.js +0 -1
- package/src/components/link-control/test/index.js +2 -3
- package/src/components/list-view/block-select-button.js +2 -17
- package/src/components/provider/use-block-sync.js +3 -1
- package/src/components/rich-text/content.scss +2 -0
- package/src/components/url-popover/image-url-input-ui.js +0 -2
- package/src/components/use-block-display-information/index.js +15 -2
- package/src/components/use-block-display-information/test/index.js +140 -0
- package/src/hooks/anchor.js +0 -1
- package/src/hooks/background.js +210 -133
- package/src/hooks/background.scss +0 -35
- package/src/hooks/color.js +2 -205
- package/src/hooks/color.scss +3 -9
- package/src/hooks/contrast-checker.js +60 -17
- package/src/hooks/custom-class-name.js +0 -1
- package/src/hooks/elements.js +140 -0
- package/src/hooks/elements.scss +8 -0
- package/src/hooks/grid-visualizer.js +59 -45
- package/src/hooks/layout-child.js +51 -12
- package/src/hooks/layout.js +6 -3
- package/src/hooks/states.js +2 -2
- package/src/hooks/style.js +11 -7
- package/src/hooks/test/background.js +59 -0
- package/src/hooks/test/block-style-state.js +14 -14
- package/src/hooks/test/layout.js +6 -6
- package/src/hooks/test/style.js +8 -8
- package/src/hooks/typography.js +70 -6
- package/src/layouts/flex.js +118 -15
- package/src/store/test/private-selectors.js +28 -7
- package/src/store/test/reducer.js +61 -10
- package/src/style.scss +1 -0
- package/src/utils/block-bindings.ts +51 -0
- package/src/utils/color-values.ts +63 -0
- package/src/utils/{dom.js → dom.ts} +27 -27
- package/src/utils/{fit-text-frontend.js → fit-text-frontend.ts} +12 -4
- package/src/utils/{fit-text-utils.js → fit-text-utils.ts} +15 -7
- package/src/utils/{format-font-style.js → format-font-style.ts} +10 -3
- package/src/utils/{format-font-weight.js → format-font-weight.ts} +10 -3
- package/src/utils/{get-editor-region.js → get-editor-region.ts} +10 -6
- package/src/utils/{get-font-styles-and-weights.js → get-font-styles-and-weights.ts} +21 -17
- package/src/utils/{math.js → math.ts} +37 -30
- package/src/utils/object.ts +89 -0
- package/src/utils/{order-inserter-block-items.js → order-inserter-block-items.ts} +8 -5
- package/src/utils/{pasting.js → pasting.ts} +18 -11
- package/src/utils/{selection.js → selection.ts} +11 -4
- package/src/utils/sorting.ts +81 -0
- package/src/utils/test/color-values.js +44 -1
- package/src/utils/transform-styles/{index.js → index.ts} +25 -25
- package/src/utils/transform-styles/postcss-urlrebase.d.ts +15 -0
- package/src/utils/transform-styles/types.ts +13 -0
- package/src/utils/types.ts +29 -0
- package/src/utils/block-bindings.js +0 -46
- package/src/utils/color-values.js +0 -28
- package/src/utils/object.js +0 -67
- package/src/utils/sorting.js +0 -54
- /package/src/utils/{get-px-from-css-unit.js → get-px-from-css-unit.ts} +0 -0
- /package/src/utils/{index.js → index.ts} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/utils/get-font-styles-and-weights.
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { _x, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { formatFontStyle } from './format-font-style';\nimport { formatFontWeight } from './format-font-weight';\n\nconst FONT_STYLES = [\n\t{\n\t\tname: _x( 'Regular', 'font style' ),\n\t\tvalue: 'normal',\n\t},\n\t{\n\t\tname: _x( 'Italic', 'font style' ),\n\t\tvalue: 'italic',\n\t},\n];\n\nconst FONT_WEIGHTS = [\n\t{\n\t\tname: _x( 'Thin', 'font weight' ),\n\t\tvalue: '100',\n\t},\n\t{\n\t\tname: _x( 'Extra Light', 'font weight' ),\n\t\tvalue: '200',\n\t},\n\t{\n\t\tname: _x( 'Light', 'font weight' ),\n\t\tvalue: '300',\n\t},\n\t{\n\t\tname: _x( 'Regular', 'font weight' ),\n\t\tvalue: '400',\n\t},\n\t{\n\t\tname: _x( 'Medium', 'font weight' ),\n\t\tvalue: '500',\n\t},\n\t{\n\t\tname: _x( 'Semi Bold', 'font weight' ),\n\t\tvalue: '600',\n\t},\n\t{\n\t\tname: _x( 'Bold', 'font weight' ),\n\t\tvalue: '700',\n\t},\n\t{\n\t\tname: _x( 'Extra Bold', 'font weight' ),\n\t\tvalue: '800',\n\t},\n\t{\n\t\tname: _x( 'Black', 'font weight' ),\n\t\tvalue: '900',\n\t},\n\t{\n\t\tname: _x( 'Extra Black', 'font weight' ),\n\t\tvalue: '1000',\n\t},\n];\n\n/**\n * Builds a list of font style and weight options based on font family faces.\n * Defaults to the standard font styles and weights if no font family faces are provided.\n *\n * @param
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA4B;AAK5B,+BAAgC;AAChC,gCAAiC;
|
|
3
|
+
"sources": ["../../src/utils/get-font-styles-and-weights.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { _x, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { formatFontStyle } from './format-font-style';\nimport { formatFontWeight } from './format-font-weight';\nimport type {\n\tFontFamilyFace,\n\tFormattedFont,\n\tCombinedStyleAndWeightOption,\n} from './types';\n\nconst FONT_STYLES = [\n\t{\n\t\tname: _x( 'Regular', 'font style' ),\n\t\tvalue: 'normal',\n\t},\n\t{\n\t\tname: _x( 'Italic', 'font style' ),\n\t\tvalue: 'italic',\n\t},\n];\n\nconst FONT_WEIGHTS = [\n\t{\n\t\tname: _x( 'Thin', 'font weight' ),\n\t\tvalue: '100',\n\t},\n\t{\n\t\tname: _x( 'Extra Light', 'font weight' ),\n\t\tvalue: '200',\n\t},\n\t{\n\t\tname: _x( 'Light', 'font weight' ),\n\t\tvalue: '300',\n\t},\n\t{\n\t\tname: _x( 'Regular', 'font weight' ),\n\t\tvalue: '400',\n\t},\n\t{\n\t\tname: _x( 'Medium', 'font weight' ),\n\t\tvalue: '500',\n\t},\n\t{\n\t\tname: _x( 'Semi Bold', 'font weight' ),\n\t\tvalue: '600',\n\t},\n\t{\n\t\tname: _x( 'Bold', 'font weight' ),\n\t\tvalue: '700',\n\t},\n\t{\n\t\tname: _x( 'Extra Bold', 'font weight' ),\n\t\tvalue: '800',\n\t},\n\t{\n\t\tname: _x( 'Black', 'font weight' ),\n\t\tvalue: '900',\n\t},\n\t{\n\t\tname: _x( 'Extra Black', 'font weight' ),\n\t\tvalue: '1000',\n\t},\n];\n\n/**\n * Builds a list of font style and weight options based on font family faces.\n * Defaults to the standard font styles and weights if no font family faces are provided.\n *\n * @param fontFamilyFaces font family faces array\n * @return new object with combined and separated font style and weight properties\n */\nexport function getFontStylesAndWeights(\n\tfontFamilyFaces: FontFamilyFace[] | undefined\n) {\n\tlet fontStyles: FormattedFont[] = [];\n\tlet fontWeights: FormattedFont[] = [];\n\tconst combinedStyleAndWeightOptions: CombinedStyleAndWeightOption[] = [];\n\tconst isSystemFont = ! fontFamilyFaces || fontFamilyFaces?.length === 0;\n\tlet isVariableFont = false;\n\n\tfontFamilyFaces?.forEach( ( face ) => {\n\t\t// Check for variable font by looking for a space in the font weight value. e.g. \"100 900\"\n\t\tif (\n\t\t\t'string' === typeof face.fontWeight &&\n\t\t\t/\\s/.test( face.fontWeight.trim() )\n\t\t) {\n\t\t\tisVariableFont = true;\n\n\t\t\t// Find font weight start and end values.\n\t\t\tconst [ startStr, endStr ] = face.fontWeight.split( ' ' );\n\t\t\tconst startValue = parseInt( startStr.slice( 0, 1 ) );\n\t\t\tconst endValue =\n\t\t\t\tendStr === '1000' ? 10 : parseInt( endStr.slice( 0, 1 ) );\n\n\t\t\t// Create font weight options for available variable weights.\n\t\t\tfor ( let i = startValue; i <= endValue; i++ ) {\n\t\t\t\tconst fontWeightValue = `${ i.toString() }00`;\n\t\t\t\tif (\n\t\t\t\t\t! fontWeights.some(\n\t\t\t\t\t\t( weight ) => weight.value === fontWeightValue\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tfontWeights.push( formatFontWeight( fontWeightValue ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Format font style and weight values.\n\t\tconst fontWeight = formatFontWeight(\n\t\t\t'number' === typeof face.fontWeight\n\t\t\t\t? face.fontWeight.toString()\n\t\t\t\t: face.fontWeight\n\t\t);\n\t\tconst fontStyle = formatFontStyle( face.fontStyle );\n\n\t\t// Create font style and font weight lists without duplicates.\n\t\tif ( fontStyle && Object.keys( fontStyle ).length ) {\n\t\t\tif (\n\t\t\t\t! fontStyles.some(\n\t\t\t\t\t( style ) => style.value === fontStyle.value\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tfontStyles.push( fontStyle );\n\t\t\t}\n\t\t}\n\n\t\tif ( fontWeight && Object.keys( fontWeight ).length ) {\n\t\t\tif (\n\t\t\t\t! fontWeights.some(\n\t\t\t\t\t( weight ) => weight.value === fontWeight.value\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tif ( ! isVariableFont ) {\n\t\t\t\t\tfontWeights.push( fontWeight );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} );\n\n\t// If there is no font weight of 600 or above, then include faux bold as an option.\n\tif ( ! fontWeights.some( ( weight ) => ( weight.value ?? '' ) >= '600' ) ) {\n\t\tfontWeights.push( {\n\t\t\tname: _x( 'Bold', 'font weight' ),\n\t\t\tvalue: '700',\n\t\t} );\n\t}\n\n\t// If there is no italic font style, then include faux italic as an option.\n\tif ( ! fontStyles.some( ( style ) => style.value === 'italic' ) ) {\n\t\tfontStyles.push( {\n\t\t\tname: _x( 'Italic', 'font style' ),\n\t\t\tvalue: 'italic',\n\t\t} );\n\t}\n\n\t// Use default font styles and weights for system fonts.\n\tif ( isSystemFont ) {\n\t\tfontStyles = FONT_STYLES;\n\t\tfontWeights = FONT_WEIGHTS;\n\t}\n\n\t// Use default styles and weights if there are no available styles or weights from the provided font faces.\n\tfontStyles = fontStyles.length === 0 ? FONT_STYLES : fontStyles;\n\tfontWeights = fontWeights.length === 0 ? FONT_WEIGHTS : fontWeights;\n\n\t// Generate combined font style and weight options for available fonts.\n\tfontStyles.forEach( ( { name: styleName, value: styleValue } ) => {\n\t\tfontWeights.forEach( ( { name: weightName, value: weightValue } ) => {\n\t\t\tconst optionName =\n\t\t\t\tstyleValue === 'normal'\n\t\t\t\t\t? weightName\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t/* translators: 1: Font weight name. 2: Font style name. */\n\t\t\t\t\t\t\t_x( '%1$s %2$s', 'font' ),\n\t\t\t\t\t\t\tweightName ?? '',\n\t\t\t\t\t\t\tstyleName ?? ''\n\t\t\t\t\t );\n\n\t\t\tcombinedStyleAndWeightOptions.push( {\n\t\t\t\tkey: `${ styleValue }-${ weightValue }`,\n\t\t\t\tname: optionName ?? '',\n\t\t\t\tstyle: {\n\t\t\t\t\tfontStyle: styleValue,\n\t\t\t\t\tfontWeight: weightValue,\n\t\t\t\t},\n\t\t\t} );\n\t\t} );\n\t} );\n\n\treturn {\n\t\tfontStyles,\n\t\tfontWeights,\n\t\tcombinedStyleAndWeightOptions,\n\t\tisSystemFont,\n\t\tisVariableFont,\n\t};\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// packages/block-editor/src/utils/get-px-from-css-unit.
|
|
20
|
+
// packages/block-editor/src/utils/get-px-from-css-unit.ts
|
|
21
21
|
var get_px_from_css_unit_exports = {};
|
|
22
22
|
__export(get_px_from_css_unit_exports, {
|
|
23
23
|
default: () => get_px_from_css_unit_default
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/utils/get-px-from-css-unit.
|
|
3
|
+
"sources": ["../../src/utils/get-px-from-css-unit.ts"],
|
|
4
4
|
"sourcesContent": ["/**\n * This function was accidentally exposed for mobile/native usage.\n *\n * @deprecated\n *\n * @return {string} Empty string.\n */\nexport default () => '';\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,IAAO,+BAAQ,MAAM;",
|
|
6
6
|
"names": []
|
package/build/utils/index.cjs
CHANGED
|
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
|
-
// packages/block-editor/src/utils/index.
|
|
30
|
+
// packages/block-editor/src/utils/index.ts
|
|
31
31
|
var utils_exports = {};
|
|
32
32
|
__export(utils_exports, {
|
|
33
33
|
getPxFromCssUnit: () => import_get_px_from_css_unit.default,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/utils/index.
|
|
3
|
+
"sources": ["../../src/utils/index.ts"],
|
|
4
4
|
"sourcesContent": ["export { default as transformStyles } from './transform-styles';\nexport { default as getPxFromCssUnit } from './get-px-from-css-unit';\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAA2C;AAC3C,kCAA4C;",
|
|
6
6
|
"names": []
|
package/build/utils/math.cjs
CHANGED
|
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// packages/block-editor/src/utils/math.
|
|
20
|
+
// packages/block-editor/src/utils/math.ts
|
|
21
21
|
var math_exports = {};
|
|
22
22
|
__export(math_exports, {
|
|
23
23
|
getDistanceFromPointToEdge: () => getDistanceFromPointToEdge,
|
package/build/utils/math.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/utils/math.
|
|
4
|
-
"sourcesContent": ["/**\n * A string representing the name of an edge.\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BO,SAAS,
|
|
3
|
+
"sources": ["../../src/utils/math.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * A string representing the name of an edge.\n */\ntype EdgeName = 'top' | 'right' | 'bottom' | 'left';\n\ninterface Point {\n\t/** The horizontal position. */\n\tx: number;\n\t/** The vertical position. */\n\ty: number;\n}\n\n/**\n * Given a point, a DOMRect and the name of an edge, returns the distance to\n * that edge of the rect.\n *\n * This function works for edges that are horizontal or vertical (e.g. not\n * rotated), the following terms are used so that the function works in both\n * orientations:\n *\n * - Forward, meaning the axis running horizontally when an edge is vertical\n * and vertically when an edge is horizontal.\n * - Lateral, meaning the axis running vertically when an edge is vertical\n * and horizontally when an edge is horizontal.\n *\n * @param point The point to measure distance from.\n * @param rect A DOM Rect containing edge positions.\n * @param edge The edge to measure to.\n */\nexport function getDistanceFromPointToEdge(\n\tpoint: Point,\n\trect: DOMRect,\n\tedge: EdgeName\n) {\n\tconst isHorizontal = edge === 'top' || edge === 'bottom';\n\tconst { x, y } = point;\n\tconst pointLateralPosition = isHorizontal ? x : y;\n\tconst pointForwardPosition = isHorizontal ? y : x;\n\tconst edgeStart = isHorizontal ? rect.left : rect.top;\n\tconst edgeEnd = isHorizontal ? rect.right : rect.bottom;\n\tconst edgeForwardPosition = rect[ edge ];\n\n\t// Measure the straight line distance to the edge of the rect, when the\n\t// point is adjacent to the edge.\n\t// Else, if the point is positioned diagonally to the edge of the rect,\n\t// measure diagonally to the nearest corner that the edge meets.\n\tlet edgeLateralPosition;\n\tif (\n\t\tpointLateralPosition >= edgeStart &&\n\t\tpointLateralPosition <= edgeEnd\n\t) {\n\t\tedgeLateralPosition = pointLateralPosition;\n\t} else if ( pointLateralPosition < edgeEnd ) {\n\t\tedgeLateralPosition = edgeStart;\n\t} else {\n\t\tedgeLateralPosition = edgeEnd;\n\t}\n\n\treturn Math.sqrt(\n\t\t( pointLateralPosition - edgeLateralPosition ) ** 2 +\n\t\t\t( pointForwardPosition - edgeForwardPosition ) ** 2\n\t);\n}\n\n/**\n * Given a point, a DOMRect and a list of allowed edges returns the name of and\n * distance to the nearest edge.\n *\n * @param point The point to measure distance from.\n * @param rect A DOM Rect containing edge positions.\n * @param allowedEdges A list of the edges included in the\n * calculation. Defaults to all edges.\n *\n * @return An array where the first value is the distance\n * and a second is the edge name.\n */\nexport function getDistanceToNearestEdge(\n\tpoint: Point,\n\trect: DOMRect,\n\tallowedEdges: EdgeName[] = [ 'top', 'bottom', 'left', 'right' ]\n) {\n\tlet candidateDistance: number | undefined;\n\tlet candidateEdge: EdgeName | undefined;\n\n\tallowedEdges.forEach( ( edge ) => {\n\t\tconst distance = getDistanceFromPointToEdge( point, rect, edge );\n\n\t\tif ( candidateDistance === undefined || distance < candidateDistance ) {\n\t\t\tcandidateDistance = distance;\n\t\t\tcandidateEdge = edge;\n\t\t}\n\t} );\n\n\treturn [ candidateDistance, candidateEdge ];\n}\n\n/**\n * Is the point contained by the rectangle.\n *\n * @param point The point.\n * @param rect The rectangle.\n *\n * @return True if the point is contained by the rectangle, false otherwise.\n */\nexport function isPointContainedByRect( point: Point, rect: DOMRect ) {\n\treturn (\n\t\trect.left <= point.x &&\n\t\trect.right >= point.x &&\n\t\trect.top <= point.y &&\n\t\trect.bottom >= point.y\n\t);\n}\n\n/**\n * Is the point within the top and bottom boundaries of the rectangle.\n *\n * @param point The point.\n * @param rect The rectangle.\n *\n * @return True if the point is within top and bottom of rectangle, false otherwise.\n */\nexport function isPointWithinTopAndBottomBoundariesOfRect(\n\tpoint: Point,\n\trect: DOMRect\n) {\n\treturn rect.top <= point.y && rect.bottom >= point.y;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BO,SAAS,2BACf,OACA,MACA,MACC;AACD,QAAM,eAAe,SAAS,SAAS,SAAS;AAChD,QAAM,EAAE,GAAG,EAAE,IAAI;AACjB,QAAM,uBAAuB,eAAe,IAAI;AAChD,QAAM,uBAAuB,eAAe,IAAI;AAChD,QAAM,YAAY,eAAe,KAAK,OAAO,KAAK;AAClD,QAAM,UAAU,eAAe,KAAK,QAAQ,KAAK;AACjD,QAAM,sBAAsB,KAAM,IAAK;AAMvC,MAAI;AACJ,MACC,wBAAwB,aACxB,wBAAwB,SACvB;AACD,0BAAsB;AAAA,EACvB,WAAY,uBAAuB,SAAU;AAC5C,0BAAsB;AAAA,EACvB,OAAO;AACN,0BAAsB;AAAA,EACvB;AAEA,SAAO,KAAK;AAAA,KACT,uBAAuB,wBAAyB,KAC/C,uBAAuB,wBAAyB;AAAA,EACpD;AACD;AAcO,SAAS,yBACf,OACA,MACA,eAA2B,CAAE,OAAO,UAAU,QAAQ,OAAQ,GAC7D;AACD,MAAI;AACJ,MAAI;AAEJ,eAAa,QAAS,CAAE,SAAU;AACjC,UAAM,WAAW,2BAA4B,OAAO,MAAM,IAAK;AAE/D,QAAK,sBAAsB,UAAa,WAAW,mBAAoB;AACtE,0BAAoB;AACpB,sBAAgB;AAAA,IACjB;AAAA,EACD,CAAE;AAEF,SAAO,CAAE,mBAAmB,aAAc;AAC3C;AAUO,SAAS,uBAAwB,OAAc,MAAgB;AACrE,SACC,KAAK,QAAQ,MAAM,KACnB,KAAK,SAAS,MAAM,KACpB,KAAK,OAAO,MAAM,KAClB,KAAK,UAAU,MAAM;AAEvB;AAUO,SAAS,0CACf,OACA,MACC;AACD,SAAO,KAAK,OAAO,MAAM,KAAK,KAAK,UAAU,MAAM;AACpD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/utils/object.cjs
CHANGED
|
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// packages/block-editor/src/utils/object.
|
|
20
|
+
// packages/block-editor/src/utils/object.ts
|
|
21
21
|
var object_exports = {};
|
|
22
22
|
__export(object_exports, {
|
|
23
23
|
getValueFromObjectPath: () => getValueFromObjectPath,
|
|
@@ -26,16 +26,16 @@ __export(object_exports, {
|
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(object_exports);
|
|
28
28
|
function setImmutably(object, path, value) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const leaf =
|
|
32
|
-
let prev =
|
|
33
|
-
for (const key of
|
|
29
|
+
const pathArray = Array.isArray(path) ? [...path] : [path];
|
|
30
|
+
const result = Array.isArray(object) ? [...object] : { ...object };
|
|
31
|
+
const leaf = pathArray.pop();
|
|
32
|
+
let prev = result;
|
|
33
|
+
for (const key of pathArray) {
|
|
34
34
|
const lvl = prev[key];
|
|
35
|
-
prev = prev
|
|
35
|
+
prev[key] = prev = Array.isArray(lvl) ? [...lvl] : { ...lvl };
|
|
36
36
|
}
|
|
37
37
|
prev[leaf] = value;
|
|
38
|
-
return
|
|
38
|
+
return result;
|
|
39
39
|
}
|
|
40
40
|
var getValueFromObjectPath = (object, path, defaultValue) => {
|
|
41
41
|
const arrayPath = Array.isArray(path) ? path : path.split(".");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/utils/object.
|
|
4
|
-
"sourcesContent": ["/**\n * Immutably sets a value inside an object. Like `lodash#set`, but returning a\n * new object. Treats nullish initial values as empty objects. Clones any\n * nested objects. Supports arrays, too.\n *\n * @param
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
3
|
+
"sources": ["../../src/utils/object.ts"],
|
|
4
|
+
"sourcesContent": ["type AnyObject = Record< string, unknown >;\ntype ObjectOrArray = AnyObject | unknown[];\ntype ObjectPathKey = number | string;\ntype ObjectPath = ObjectPathKey | ObjectPathKey[];\n\n/**\n * Immutably sets a value inside an object. Like `lodash#set`, but returning a\n * new object. Treats nullish initial values as empty objects. Clones any\n * nested objects. Supports arrays, too.\n *\n * @param object Object to set a value in.\n * @param path Path in the object to modify.\n * @param value New value to set.\n * @return Cloned object with the new value set.\n */\nexport function setImmutably(\n\tobject: ObjectOrArray | null | undefined,\n\tpath: ObjectPath,\n\tvalue: unknown\n): ObjectOrArray {\n\t// Normalize path\n\tconst pathArray: ObjectPathKey[] = Array.isArray( path )\n\t\t? [ ...path ]\n\t\t: [ path ];\n\n\t// Shallowly clone the base of the object\n\tconst result: ObjectOrArray = Array.isArray( object )\n\t\t? [ ...object ]\n\t\t: { ...object };\n\n\tconst leaf = pathArray.pop() as ObjectPathKey;\n\n\t// Traverse object from root to leaf, shallowly cloning at each level\n\tlet prev: ObjectOrArray = result;\n\tfor ( const key of pathArray ) {\n\t\tconst lvl = ( prev as AnyObject )[ key ];\n\t\t( prev as AnyObject )[ key ] = prev = Array.isArray( lvl )\n\t\t\t? [ ...lvl ]\n\t\t\t: { ...( lvl as AnyObject ) };\n\t}\n\n\t( prev as AnyObject )[ leaf ] = value;\n\n\treturn result;\n}\n\n/**\n * Helper util to return a value from a certain path of the object.\n * Path is specified as either:\n * - a string of properties, separated by dots, for example: \"x.y\".\n * - an array of properties, for example `[ 'x', 'y' ]`.\n * You can also specify a default value in case the result is nullish.\n *\n * @param object Input object.\n * @param path Path to the object property.\n * @param defaultValue Default value if the value at the specified path is nullish.\n * @return Value of the object property at the specified path.\n */\nexport const getValueFromObjectPath = (\n\tobject: AnyObject | undefined | null,\n\tpath: string | string[],\n\tdefaultValue?: unknown\n) => {\n\tconst arrayPath = Array.isArray( path ) ? path : path.split( '.' );\n\tlet value: unknown = object;\n\tarrayPath.forEach( ( fieldName ) => {\n\t\tvalue = ( value as AnyObject | undefined | null )?.[ fieldName ];\n\t} );\n\treturn value ?? defaultValue;\n};\n\n/**\n * Helper util to filter out objects with duplicate values for a given property.\n *\n * @param array Array of objects to filter.\n * @param property Property to filter unique values by.\n *\n * @return Array of objects with unique values for the specified property.\n */\nexport function uniqByProperty< T extends AnyObject >(\n\tarray: T[],\n\tproperty: string\n) {\n\tconst seen = new Set();\n\treturn array.filter( ( item ) => {\n\t\tconst value = item[ property ];\n\t\treturn seen.has( value ) ? false : seen.add( value );\n\t} );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeO,SAAS,aACf,QACA,MACA,OACgB;AAEhB,QAAM,YAA6B,MAAM,QAAS,IAAK,IACpD,CAAE,GAAG,IAAK,IACV,CAAE,IAAK;AAGV,QAAM,SAAwB,MAAM,QAAS,MAAO,IACjD,CAAE,GAAG,MAAO,IACZ,EAAE,GAAG,OAAO;AAEf,QAAM,OAAO,UAAU,IAAI;AAG3B,MAAI,OAAsB;AAC1B,aAAY,OAAO,WAAY;AAC9B,UAAM,MAAQ,KAAqB,GAAI;AACvC,IAAE,KAAqB,GAAI,IAAI,OAAO,MAAM,QAAS,GAAI,IACtD,CAAE,GAAG,GAAI,IACT,EAAE,GAAK,IAAmB;AAAA,EAC9B;AAEA,EAAE,KAAqB,IAAK,IAAI;AAEhC,SAAO;AACR;AAcO,IAAM,yBAAyB,CACrC,QACA,MACA,iBACI;AACJ,QAAM,YAAY,MAAM,QAAS,IAAK,IAAI,OAAO,KAAK,MAAO,GAAI;AACjE,MAAI,QAAiB;AACrB,YAAU,QAAS,CAAE,cAAe;AACnC,YAAU,QAA2C,SAAU;AAAA,EAChE,CAAE;AACF,SAAO,SAAS;AACjB;AAUO,SAAS,eACf,OACA,UACC;AACD,QAAM,OAAO,oBAAI,IAAI;AACrB,SAAO,MAAM,OAAQ,CAAE,SAAU;AAChC,UAAM,QAAQ,KAAM,QAAS;AAC7B,WAAO,KAAK,IAAK,KAAM,IAAI,QAAQ,KAAK,IAAK,KAAM;AAAA,EACpD,CAAE;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// packages/block-editor/src/utils/order-inserter-block-items.
|
|
20
|
+
// packages/block-editor/src/utils/order-inserter-block-items.ts
|
|
21
21
|
var order_inserter_block_items_exports = {};
|
|
22
22
|
__export(order_inserter_block_items_exports, {
|
|
23
23
|
orderInserterBlockItems: () => orderInserterBlockItems
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/utils/order-inserter-block-items.
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASO,IAAM,0BAA0B,
|
|
3
|
+
"sources": ["../../src/utils/order-inserter-block-items.ts"],
|
|
4
|
+
"sourcesContent": ["type EditorInserterItem = { id: string };\n\n/**\n * Helper function to order inserter block items according to a provided array of prioritized blocks.\n *\n * @param items The array of editor inserter block items to be sorted.\n * @param priority The array of block names to be prioritized.\n * @return The sorted array of editor inserter block items.\n */\nexport const orderInserterBlockItems = (\n\titems: EditorInserterItem[],\n\tpriority: string[] | undefined\n) => {\n\tif ( ! priority ) {\n\t\treturn items;\n\t}\n\n\titems.sort( ( { id: aName }, { id: bName } ) => {\n\t\t// Sort block items according to `priority`.\n\t\tlet aIndex = priority.indexOf( aName );\n\t\tlet bIndex = priority.indexOf( bName );\n\t\t// All other block items should come after that.\n\t\tif ( aIndex < 0 ) {\n\t\t\taIndex = priority.length;\n\t\t}\n\t\tif ( bIndex < 0 ) {\n\t\t\tbIndex = priority.length;\n\t\t}\n\t\treturn aIndex - bIndex;\n\t} );\n\n\treturn items;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASO,IAAM,0BAA0B,CACtC,OACA,aACI;AACJ,MAAK,CAAE,UAAW;AACjB,WAAO;AAAA,EACR;AAEA,QAAM,KAAM,CAAE,EAAE,IAAI,MAAM,GAAG,EAAE,IAAI,MAAM,MAAO;AAE/C,QAAI,SAAS,SAAS,QAAS,KAAM;AACrC,QAAI,SAAS,SAAS,QAAS,KAAM;AAErC,QAAK,SAAS,GAAI;AACjB,eAAS,SAAS;AAAA,IACnB;AACA,QAAK,SAAS,GAAI;AACjB,eAAS,SAAS;AAAA,IACnB;AACA,WAAO,SAAS;AAAA,EACjB,CAAE;AAEF,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/utils/pasting.cjs
CHANGED
|
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// packages/block-editor/src/utils/pasting.
|
|
20
|
+
// packages/block-editor/src/utils/pasting.ts
|
|
21
21
|
var pasting_exports = {};
|
|
22
22
|
__export(pasting_exports, {
|
|
23
23
|
getPasteEventData: () => getPasteEventData,
|
|
@@ -47,7 +47,9 @@ function removeCharsetMetaTag(html) {
|
|
|
47
47
|
}
|
|
48
48
|
return html;
|
|
49
49
|
}
|
|
50
|
-
function getPasteEventData({
|
|
50
|
+
function getPasteEventData({
|
|
51
|
+
clipboardData
|
|
52
|
+
}) {
|
|
51
53
|
let plainText = "";
|
|
52
54
|
let html = "";
|
|
53
55
|
try {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/utils/pasting.
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\n\n/**\n * Normalizes a given string of HTML to remove the Windows-specific \"Fragment\"\n * comments and any preceding and trailing content.\n *\n * @param
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAAyC;AASzC,SAAS,uBAAwB,
|
|
3
|
+
"sources": ["../../src/utils/pasting.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\n\n/**\n * Normalizes a given string of HTML to remove the Windows-specific \"Fragment\"\n * comments and any preceding and trailing content.\n *\n * @param html the html to be normalized\n * @return the normalized html\n */\nfunction removeWindowsFragments( html: string ) {\n\tconst startStr = '<!--StartFragment-->';\n\tconst startIdx = html.indexOf( startStr );\n\tif ( startIdx > -1 ) {\n\t\thtml = html.substring( startIdx + startStr.length );\n\t} else {\n\t\t// No point looking for EndFragment\n\t\treturn html;\n\t}\n\n\tconst endStr = '<!--EndFragment-->';\n\tconst endIdx = html.indexOf( endStr );\n\tif ( endIdx > -1 ) {\n\t\thtml = html.substring( 0, endIdx );\n\t}\n\n\treturn html;\n}\n\n/**\n * Removes the charset meta tag inserted by Chromium.\n * See:\n * - https://github.com/WordPress/gutenberg/issues/33585\n * - https://bugs.chromium.org/p/chromium/issues/detail?id=1264616#c4\n *\n * @param html the html to be stripped of the meta tag.\n * @return the cleaned html\n */\nfunction removeCharsetMetaTag( html: string ) {\n\tconst metaTag = `<meta charset='utf-8'>`;\n\n\tif ( html.startsWith( metaTag ) ) {\n\t\treturn html.slice( metaTag.length );\n\t}\n\n\treturn html;\n}\n\nexport function getPasteEventData( {\n\tclipboardData,\n}: {\n\tclipboardData: DataTransfer;\n} ) {\n\tlet plainText = '';\n\tlet html = '';\n\n\ttry {\n\t\tplainText = clipboardData.getData( 'text/plain' );\n\t\thtml = clipboardData.getData( 'text/html' );\n\t} catch {\n\t\t// Some browsers like UC Browser paste plain text by default and\n\t\t// don't support clipboardData at all, so allow default\n\t\t// behaviour.\n\t\treturn;\n\t}\n\n\t// Remove Windows-specific metadata appended within copied HTML text.\n\thtml = removeWindowsFragments( html );\n\n\t// Strip meta tag.\n\thtml = removeCharsetMetaTag( html );\n\n\tconst files = getFilesFromDataTransfer( clipboardData );\n\n\tif ( files.length && ! shouldDismissPastedFiles( files, html ) ) {\n\t\treturn { files };\n\t}\n\n\treturn { html, plainText, files: [] };\n}\n\n/**\n * Given a collection of DataTransfer files and HTML and plain text strings,\n * determine whether the files are to be dismissed in favor of the HTML.\n *\n * Certain office-type programs, like Microsoft Word or Apple Numbers,\n * will, upon copy, generate a screenshot of the content being copied and\n * attach it to the clipboard alongside the actual rich text that the user\n * sought to copy. In those cases, we should let Gutenberg handle the rich text\n * content and not the screenshot, since this allows Gutenberg to insert\n * meaningful blocks, like paragraphs, lists or even tables.\n *\n * @param files File objects obtained from a paste event\n * @param html HTML content obtained from a paste event\n * @return True if the files should be dismissed\n */\nexport function shouldDismissPastedFiles(\n\tfiles: File[],\n\thtml: string /*, plainText */\n) {\n\t// The question is only relevant when there is actual HTML content and when\n\t// there is exactly one image file.\n\tif (\n\t\thtml &&\n\t\tfiles?.length === 1 &&\n\t\tfiles[ 0 ].type.indexOf( 'image/' ) === 0\n\t) {\n\t\t// A single <img> tag found in the HTML source suggests that the\n\t\t// content being pasted revolves around an image. Sometimes there are\n\t\t// other elements found, like <figure>, but we assume that the user's\n\t\t// intention is to paste the actual image file.\n\t\tconst IMAGE_TAG = /<\\s*img\\b/gi;\n\t\tif ( html.match( IMAGE_TAG )?.length !== 1 ) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Even when there is exactly one <img> tag in the HTML payload, we\n\t\t// choose to weed out local images, i.e. those whose source starts with\n\t\t// \"file://\". These payloads occur in specific configurations, such as\n\t\t// when copying an entire document from Microsoft Word, that contains\n\t\t// text and exactly one image, and pasting that content using Google\n\t\t// Chrome.\n\t\tconst IMG_WITH_LOCAL_SRC = /<\\s*img\\b[^>]*\\bsrc=\"file:\\/\\//i;\n\t\tif ( html.match( IMG_WITH_LOCAL_SRC ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAAyC;AASzC,SAAS,uBAAwB,MAAe;AAC/C,QAAM,WAAW;AACjB,QAAM,WAAW,KAAK,QAAS,QAAS;AACxC,MAAK,WAAW,IAAK;AACpB,WAAO,KAAK,UAAW,WAAW,SAAS,MAAO;AAAA,EACnD,OAAO;AAEN,WAAO;AAAA,EACR;AAEA,QAAM,SAAS;AACf,QAAM,SAAS,KAAK,QAAS,MAAO;AACpC,MAAK,SAAS,IAAK;AAClB,WAAO,KAAK,UAAW,GAAG,MAAO;AAAA,EAClC;AAEA,SAAO;AACR;AAWA,SAAS,qBAAsB,MAAe;AAC7C,QAAM,UAAU;AAEhB,MAAK,KAAK,WAAY,OAAQ,GAAI;AACjC,WAAO,KAAK,MAAO,QAAQ,MAAO;AAAA,EACnC;AAEA,SAAO;AACR;AAEO,SAAS,kBAAmB;AAAA,EAClC;AACD,GAEI;AACH,MAAI,YAAY;AAChB,MAAI,OAAO;AAEX,MAAI;AACH,gBAAY,cAAc,QAAS,YAAa;AAChD,WAAO,cAAc,QAAS,WAAY;AAAA,EAC3C,QAAQ;AAIP;AAAA,EACD;AAGA,SAAO,uBAAwB,IAAK;AAGpC,SAAO,qBAAsB,IAAK;AAElC,QAAM,YAAQ,qCAA0B,aAAc;AAEtD,MAAK,MAAM,UAAU,CAAE,yBAA0B,OAAO,IAAK,GAAI;AAChE,WAAO,EAAE,MAAM;AAAA,EAChB;AAEA,SAAO,EAAE,MAAM,WAAW,OAAO,CAAC,EAAE;AACrC;AAiBO,SAAS,yBACf,OACA,MACC;AAGD,MACC,QACA,OAAO,WAAW,KAClB,MAAO,CAAE,EAAE,KAAK,QAAS,QAAS,MAAM,GACvC;AAKD,UAAM,YAAY;AAClB,QAAK,KAAK,MAAO,SAAU,GAAG,WAAW,GAAI;AAC5C,aAAO;AAAA,IACR;AAQA,UAAM,qBAAqB;AAC3B,QAAK,KAAK,MAAO,kBAAmB,GAAI;AACvC,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// packages/block-editor/src/utils/selection.
|
|
20
|
+
// packages/block-editor/src/utils/selection.ts
|
|
21
21
|
var selection_exports = {};
|
|
22
22
|
__export(selection_exports, {
|
|
23
23
|
START_OF_SELECTED_AREA: () => START_OF_SELECTED_AREA,
|
|
@@ -44,6 +44,7 @@ function findRichTextAttributeKey(blockType) {
|
|
|
44
44
|
return key;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
+
return void 0;
|
|
47
48
|
}
|
|
48
49
|
// Annotate the CommonJS export names for ESM import in node:
|
|
49
50
|
0 && (module.exports = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/utils/selection.
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { RichTextData } from '@wordpress/rich-text';\n\n/**\n * A robust way to retain selection position through various\n * transforms is to insert a special character at the position and\n * then recover it.\n */\nexport const START_OF_SELECTED_AREA = '\\u0086';\n\n/**\n * Retrieve the block attribute that contains the selection position.\n *\n * @param
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAA6B;AAOtB,IAAM,yBAAyB;AAQ/B,SAAS,
|
|
3
|
+
"sources": ["../../src/utils/selection.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { RichTextData } from '@wordpress/rich-text';\n\n/**\n * A robust way to retain selection position through various\n * transforms is to insert a special character at the position and\n * then recover it.\n */\nexport const START_OF_SELECTED_AREA = '\\u0086';\n\n/**\n * Retrieve the block attribute that contains the selection position.\n *\n * @param blockAttributes Block attributes.\n * @return The name of the block attribute that was previously selected.\n */\nexport function retrieveSelectedAttribute(\n\tblockAttributes: Record< string, unknown > | undefined\n) {\n\tif ( ! blockAttributes ) {\n\t\treturn;\n\t}\n\n\treturn Object.keys( blockAttributes ).find( ( name ) => {\n\t\tconst value = blockAttributes[ name ];\n\t\treturn (\n\t\t\t( typeof value === 'string' || value instanceof RichTextData ) &&\n\t\t\t// To do: refactor this to use rich text's selection instead, so we\n\t\t\t// no longer have to use on this hack inserting a special character.\n\t\t\tvalue.toString().indexOf( START_OF_SELECTED_AREA ) !== -1\n\t\t);\n\t} );\n}\n\ntype BlockTypeWithAttributes = {\n\tattributes: Record< string, { source?: string } >;\n};\n\nexport function findRichTextAttributeKey( blockType: BlockTypeWithAttributes ) {\n\tfor ( const [ key, value ] of Object.entries( blockType.attributes ) ) {\n\t\tif ( value.source === 'rich-text' || value.source === 'html' ) {\n\t\t\treturn key;\n\t\t}\n\t}\n\treturn undefined;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAA6B;AAOtB,IAAM,yBAAyB;AAQ/B,SAAS,0BACf,iBACC;AACD,MAAK,CAAE,iBAAkB;AACxB;AAAA,EACD;AAEA,SAAO,OAAO,KAAM,eAAgB,EAAE,KAAM,CAAE,SAAU;AACvD,UAAM,QAAQ,gBAAiB,IAAK;AACpC,YACG,OAAO,UAAU,YAAY,iBAAiB;AAAA;AAAA,IAGhD,MAAM,SAAS,EAAE,QAAS,sBAAuB,MAAM;AAAA,EAEzD,CAAE;AACH;AAMO,SAAS,yBAA0B,WAAqC;AAC9E,aAAY,CAAE,KAAK,KAAM,KAAK,OAAO,QAAS,UAAU,UAAW,GAAI;AACtE,QAAK,MAAM,WAAW,eAAe,MAAM,WAAW,QAAS;AAC9D,aAAO;AAAA,IACR;AAAA,EACD;AACA,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/utils/sorting.cjs
CHANGED
|
@@ -17,12 +17,18 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// packages/block-editor/src/utils/sorting.
|
|
20
|
+
// packages/block-editor/src/utils/sorting.ts
|
|
21
21
|
var sorting_exports = {};
|
|
22
22
|
__export(sorting_exports, {
|
|
23
23
|
orderBy: () => orderBy
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(sorting_exports);
|
|
26
|
+
function isGreater(a, b) {
|
|
27
|
+
if (typeof a === "string" && typeof b === "string") {
|
|
28
|
+
return a > b;
|
|
29
|
+
}
|
|
30
|
+
return Number(a) > Number(b);
|
|
31
|
+
}
|
|
26
32
|
var comparator = (field, items, order) => {
|
|
27
33
|
return (a, b) => {
|
|
28
34
|
let cmpA, cmpB;
|
|
@@ -33,9 +39,9 @@ var comparator = (field, items, order) => {
|
|
|
33
39
|
cmpA = a[field];
|
|
34
40
|
cmpB = b[field];
|
|
35
41
|
}
|
|
36
|
-
if (cmpA
|
|
42
|
+
if (isGreater(cmpA, cmpB)) {
|
|
37
43
|
return order === "asc" ? 1 : -1;
|
|
38
|
-
} else if (cmpB
|
|
44
|
+
} else if (isGreater(cmpB, cmpA)) {
|
|
39
45
|
return order === "asc" ? -1 : 1;
|
|
40
46
|
}
|
|
41
47
|
const orderA = items.findIndex((item) => item === a);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/utils/sorting.
|
|
4
|
-
"sourcesContent": ["/**\n * Recursive stable sorting comparator function.\n *\n * @param
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
3
|
+
"sources": ["../../src/utils/sorting.ts"],
|
|
4
|
+
"sourcesContent": ["type Comparable = string | number | undefined;\ntype SortItem = Record< string, Comparable >;\ntype SortField< T > = string | ( ( item: T ) => Comparable );\n\n/**\n * Mirrors the `>` operator for `Comparable` values: lexicographic when both\n * are strings, numeric otherwise (an `undefined` operand is never greater).\n *\n * @param a Left-hand value.\n * @param b Right-hand value.\n * @return Whether `a` is greater than `b`.\n */\nfunction isGreater( a: Comparable, b: Comparable ): boolean {\n\tif ( typeof a === 'string' && typeof b === 'string' ) {\n\t\treturn a > b;\n\t}\n\treturn Number( a ) > Number( b );\n}\n\n/**\n * Recursive stable sorting comparator function.\n *\n * @param field Field to sort by.\n * @param items Items to sort.\n * @param order Order, 'asc' or 'desc'.\n * @return Comparison function to be used in a `.sort()`.\n */\nconst comparator = < T extends SortItem >(\n\tfield: SortField< T >,\n\titems: T[],\n\torder: string\n) => {\n\treturn ( a: T, b: T ) => {\n\t\tlet cmpA: Comparable, cmpB: Comparable;\n\n\t\tif ( typeof field === 'function' ) {\n\t\t\tcmpA = field( a );\n\t\t\tcmpB = field( b );\n\t\t} else {\n\t\t\tcmpA = a[ field ];\n\t\t\tcmpB = b[ field ];\n\t\t}\n\n\t\tif ( isGreater( cmpA, cmpB ) ) {\n\t\t\treturn order === 'asc' ? 1 : -1;\n\t\t} else if ( isGreater( cmpB, cmpA ) ) {\n\t\t\treturn order === 'asc' ? -1 : 1;\n\t\t}\n\n\t\tconst orderA = items.findIndex( ( item ) => item === a );\n\t\tconst orderB = items.findIndex( ( item ) => item === b );\n\n\t\t// Stable sort: maintaining original array order\n\t\tif ( orderA > orderB ) {\n\t\t\treturn 1;\n\t\t} else if ( orderB > orderA ) {\n\t\t\treturn -1;\n\t\t}\n\n\t\treturn 0;\n\t};\n};\n\n/**\n * Order items by a certain key.\n * Supports decorator functions that allow complex picking of a comparison field.\n * Sorts in ascending order by default, but supports descending as well.\n * Stable sort - maintains original order of equal items.\n *\n * @param items Items to order.\n * @param field Field to order by.\n * @param order Sorting order, `asc` or `desc`.\n * @return Sorted items.\n */\nexport function orderBy< T extends SortItem >(\n\titems: T[],\n\tfield: SortField< T >,\n\torder = 'asc'\n) {\n\treturn items.concat().sort( comparator( field, items, order ) );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,SAAS,UAAW,GAAe,GAAyB;AAC3D,MAAK,OAAO,MAAM,YAAY,OAAO,MAAM,UAAW;AACrD,WAAO,IAAI;AAAA,EACZ;AACA,SAAO,OAAQ,CAAE,IAAI,OAAQ,CAAE;AAChC;AAUA,IAAM,aAAa,CAClB,OACA,OACA,UACI;AACJ,SAAO,CAAE,GAAM,MAAU;AACxB,QAAI,MAAkB;AAEtB,QAAK,OAAO,UAAU,YAAa;AAClC,aAAO,MAAO,CAAE;AAChB,aAAO,MAAO,CAAE;AAAA,IACjB,OAAO;AACN,aAAO,EAAG,KAAM;AAChB,aAAO,EAAG,KAAM;AAAA,IACjB;AAEA,QAAK,UAAW,MAAM,IAAK,GAAI;AAC9B,aAAO,UAAU,QAAQ,IAAI;AAAA,IAC9B,WAAY,UAAW,MAAM,IAAK,GAAI;AACrC,aAAO,UAAU,QAAQ,KAAK;AAAA,IAC/B;AAEA,UAAM,SAAS,MAAM,UAAW,CAAE,SAAU,SAAS,CAAE;AACvD,UAAM,SAAS,MAAM,UAAW,CAAE,SAAU,SAAS,CAAE;AAGvD,QAAK,SAAS,QAAS;AACtB,aAAO;AAAA,IACR,WAAY,SAAS,QAAS;AAC7B,aAAO;AAAA,IACR;AAEA,WAAO;AAAA,EACR;AACD;AAaO,SAAS,QACf,OACA,OACA,QAAQ,OACP;AACD,SAAO,MAAM,OAAO,EAAE,KAAM,WAAY,OAAO,OAAO,KAAM,CAAE;AAC/D;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
|
-
// packages/block-editor/src/utils/transform-styles/index.
|
|
30
|
+
// packages/block-editor/src/utils/transform-styles/index.ts
|
|
31
31
|
var transform_styles_exports = {};
|
|
32
32
|
__export(transform_styles_exports, {
|
|
33
33
|
default: () => transform_styles_default
|
|
@@ -68,7 +68,8 @@ function prefixRootSelector(prefix, selector) {
|
|
|
68
68
|
0,
|
|
69
69
|
{
|
|
70
70
|
type: "combinator",
|
|
71
|
-
content: " "
|
|
71
|
+
content: " ",
|
|
72
|
+
pos: [0, 0]
|
|
72
73
|
},
|
|
73
74
|
...tokenizedPrefix
|
|
74
75
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/utils/transform-styles/index.
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport * as parsel from 'parsel-js';\nimport Processor from 'postcss/lib/processor';\nimport CssSyntaxError from 'postcss/lib/css-syntax-error';\nimport prefixSelector from 'postcss-prefix-selector';\nimport rebaseUrl from 'postcss-urlrebase';\n\nconst cacheByWrapperSelector = new Map();\n\nconst ROOT_SELECTOR_TOKENS = [\n\t{ type: 'type', content: 'body' },\n\t{ type: 'type', content: 'html' },\n\t{ type: 'pseudo-class', content: ':root' },\n\t{ type: 'pseudo-class', content: ':where(body)' },\n\t{ type: 'pseudo-class', content: ':where(:root)' },\n\t{ type: 'pseudo-class', content: ':where(html)' },\n];\n\n/**\n * Prefixes root selectors in a way that ensures consistent specificity.\n * This requires special handling, since prefixing a classname before\n * html, body, or :root will generally result in an invalid selector.\n *\n * Some libraries will simply replace the root selector with the prefix\n * instead, but this results in inconsistent specificity.\n *\n * This function instead inserts the prefix after the root tags but before\n * any other part of the selector. This results in consistent specificity:\n * - If a `:where()` selector is used for the prefix, all selectors output\n * by `transformStyles` will have no specificity increase.\n * - If a classname, id, or something else is used as the prefix, all selectors\n * will have the same specificity bump when transformed.\n *\n * @param
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
3
|
+
"sources": ["../../../src/utils/transform-styles/index.ts"],
|
|
4
|
+
"sourcesContent": ["/// <reference path=\"./postcss-urlrebase.d.ts\" />\n\n/**\n * External dependencies\n */\nimport * as parsel from 'parsel-js';\nimport Processor from 'postcss/lib/processor';\nimport CssSyntaxError from 'postcss/lib/css-syntax-error';\nimport prefixSelector from 'postcss-prefix-selector';\nimport rebaseUrl from 'postcss-urlrebase';\n\n/**\n * Internal dependencies\n */\nimport type { EditorStyle, TransformOptions } from './types';\n\nconst cacheByWrapperSelector = new Map();\n\nconst ROOT_SELECTOR_TOKENS = [\n\t{ type: 'type', content: 'body' },\n\t{ type: 'type', content: 'html' },\n\t{ type: 'pseudo-class', content: ':root' },\n\t{ type: 'pseudo-class', content: ':where(body)' },\n\t{ type: 'pseudo-class', content: ':where(:root)' },\n\t{ type: 'pseudo-class', content: ':where(html)' },\n];\n\n/**\n * Prefixes root selectors in a way that ensures consistent specificity.\n * This requires special handling, since prefixing a classname before\n * html, body, or :root will generally result in an invalid selector.\n *\n * Some libraries will simply replace the root selector with the prefix\n * instead, but this results in inconsistent specificity.\n *\n * This function instead inserts the prefix after the root tags but before\n * any other part of the selector. This results in consistent specificity:\n * - If a `:where()` selector is used for the prefix, all selectors output\n * by `transformStyles` will have no specificity increase.\n * - If a classname, id, or something else is used as the prefix, all selectors\n * will have the same specificity bump when transformed.\n *\n * @param prefix The prefix.\n * @param selector The selector.\n *\n * @return The prefixed root selector.\n */\nfunction prefixRootSelector( prefix: string, selector: string ) {\n\t// Use a tokenizer, since regular expressions are unreliable.\n\tconst tokenized = parsel.tokenize( selector );\n\n\t// Find the last token that contains a root selector by walking back\n\t// through the tokens.\n\tconst lastRootIndex = tokenized.findLastIndex( ( { content, type } ) => {\n\t\treturn ROOT_SELECTOR_TOKENS.some(\n\t\t\t( rootSelector ) =>\n\t\t\t\tcontent === rootSelector.content && type === rootSelector.type\n\t\t);\n\t} );\n\n\t// Walk forwards to find the combinator after the last root.\n\t// This is where the root ends and the rest of the selector begins,\n\t// and the index to insert before.\n\t// Doing it this way takes into account that a root selector like\n\t// 'body' may have additional id/class/pseudo-class/attribute-selector\n\t// parts chained to it, which is difficult to quantify using a regex.\n\tlet insertionPoint = -1;\n\tfor ( let i = lastRootIndex + 1; i < tokenized.length; i++ ) {\n\t\tif ( tokenized[ i ].type === 'combinator' ) {\n\t\t\tinsertionPoint = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t// Tokenize and insert the prefix with a ' ' combinator before it.\n\tconst tokenizedPrefix = parsel.tokenize( prefix );\n\ttokenized.splice(\n\t\t// Insert at the insertion point, or the end.\n\t\tinsertionPoint === -1 ? tokenized.length : insertionPoint,\n\t\t0,\n\t\t{\n\t\t\ttype: 'combinator',\n\t\t\tcontent: ' ',\n\t\t\tpos: [ 0, 0 ],\n\t\t} as parsel.Token,\n\t\t...tokenizedPrefix\n\t);\n\n\treturn parsel.stringify( tokenized );\n}\n\nfunction transformStyle(\n\t{ css, ignoredSelectors = [], baseURL }: EditorStyle,\n\twrapperSelector = '',\n\ttransformOptions?: TransformOptions\n) {\n\t// When there is no wrapper selector and no base URL, there is no need\n\t// to transform the CSS. This is most cases because in the default\n\t// iframed editor, no wrapping is needed, and not many styles\n\t// provide a base URL.\n\tif ( ! wrapperSelector && ! baseURL ) {\n\t\treturn css;\n\t}\n\n\ttry {\n\t\tconst excludedSelectors = [\n\t\t\t...ignoredSelectors,\n\t\t\t...( transformOptions?.ignoredSelectors ?? [] ),\n\t\t\twrapperSelector,\n\t\t];\n\n\t\treturn new Processor(\n\t\t\t[\n\t\t\t\twrapperSelector &&\n\t\t\t\t\tprefixSelector( {\n\t\t\t\t\t\tprefix: wrapperSelector,\n\t\t\t\t\t\ttransform( prefix, selector, prefixedSelector ) {\n\t\t\t\t\t\t\t// For backwards compatibility, don't use the `exclude` option\n\t\t\t\t\t\t\t// of postcss-prefix-selector, instead handle it here to match\n\t\t\t\t\t\t\t// the behavior of the old library (postcss-prefix-wrap) that\n\t\t\t\t\t\t\t// `transformStyle` previously used.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\texcludedSelectors.some( ( excludedSelector ) =>\n\t\t\t\t\t\t\t\t\texcludedSelector instanceof RegExp\n\t\t\t\t\t\t\t\t\t\t? selector.match( excludedSelector )\n\t\t\t\t\t\t\t\t\t\t: selector.includes( excludedSelector )\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\treturn selector;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst hasRootSelector = ROOT_SELECTOR_TOKENS.some(\n\t\t\t\t\t\t\t\t( rootSelector ) =>\n\t\t\t\t\t\t\t\t\tselector.startsWith( rootSelector.content )\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t// Reorganize root selectors such that the root part comes before the prefix,\n\t\t\t\t\t\t\t// but the prefix still comes before the remaining part of the selector.\n\t\t\t\t\t\t\tif ( hasRootSelector ) {\n\t\t\t\t\t\t\t\treturn prefixRootSelector( prefix, selector );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn prefixedSelector;\n\t\t\t\t\t\t},\n\t\t\t\t\t} ),\n\t\t\t\tbaseURL && rebaseUrl( { rootUrl: baseURL } ),\n\t\t\t].filter( Boolean ) as import('postcss').AcceptedPlugin[]\n\t\t).process( css, {} ).css; // use sync PostCSS API\n\t} catch ( error ) {\n\t\tif ( error instanceof CssSyntaxError ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.warn(\n\t\t\t\t'wp.blockEditor.transformStyles Failed to transform CSS.',\n\t\t\t\terror.message + '\\n' + error.showSourceCode( false )\n\t\t\t);\n\t\t} else {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.warn(\n\t\t\t\t'wp.blockEditor.transformStyles Failed to transform CSS.',\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\n\t\treturn null;\n\t}\n}\n\n/**\n * Applies a series of CSS rule transforms to wrap selectors inside a given class and/or rewrite URLs depending on the parameters passed.\n *\n * @param styles CSS rules.\n * @param wrapperSelector Wrapper selector.\n * @param transformOptions Additional options for style transformation.\n * @return converted rules.\n */\nconst transformStyles = (\n\tstyles: EditorStyle[],\n\twrapperSelector = '',\n\ttransformOptions?: TransformOptions\n) => {\n\tlet cache = cacheByWrapperSelector.get( wrapperSelector );\n\tif ( ! cache ) {\n\t\tcache = new WeakMap();\n\t\tcacheByWrapperSelector.set( wrapperSelector, cache );\n\t}\n\treturn styles.map( ( style ) => {\n\t\tlet css = cache.get( style );\n\t\tif ( ! css ) {\n\t\t\tcss = transformStyle( style, wrapperSelector, transformOptions );\n\t\t\tcache.set( style, css );\n\t\t}\n\t\treturn css;\n\t} );\n};\n\nexport default transformStyles;\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": ["Processor", "prefixSelector", "rebaseUrl", "CssSyntaxError"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// packages/block-editor/src/utils/transform-styles/types.ts
|
|
17
|
+
var types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(types_exports);
|
|
19
|
+
//# sourceMappingURL=types.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/utils/transform-styles/types.ts"],
|
|
4
|
+
"sourcesContent": ["export interface EditorStyle {\n\t/** The CSS block(s), as a single string. */\n\tcss: string;\n\t/** The base URL to be used as the reference when rewriting urls. */\n\tbaseURL?: string;\n\t/** The selectors not to wrap. */\n\tignoredSelectors?: ( string | RegExp )[];\n}\n\nexport interface TransformOptions {\n\t/** The selectors not to wrap. */\n\tignoredSelectors?: ( string | RegExp )[];\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// packages/block-editor/src/utils/types.ts
|
|
17
|
+
var types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(types_exports);
|
|
19
|
+
//# sourceMappingURL=types.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/types.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Result of formatting a font style or weight.\n */\nexport interface FormattedFont {\n\t/** Human readable name. */\n\tname?: string;\n\t/** Original CSS value. */\n\tvalue?: string;\n}\n\n/**\n * A font family face from theme.json.\n */\nexport interface FontFamilyFace {\n\tfontStyle?: string;\n\tfontWeight?: string | number;\n}\n\n/**\n * Combined font style and weight option for a font picker.\n */\nexport interface CombinedStyleAndWeightOption {\n\tkey: string;\n\tname: string;\n\tstyle: {\n\t\tfontStyle?: string;\n\t\tfontWeight?: string;\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// packages/block-editor/src/components/block-editing-mode/index.js
|
|
2
|
-
import { useSelect,
|
|
2
|
+
import { useSelect, useRegistry } from "@wordpress/data";
|
|
3
3
|
import { useEffect } from "@wordpress/element";
|
|
4
4
|
import { store as blockEditorStore } from "../../store/index.mjs";
|
|
5
5
|
import {
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
function useBlockEditingMode(mode) {
|
|
10
10
|
const context = useBlockEditContext();
|
|
11
11
|
const { clientId = "" } = context;
|
|
12
|
-
const
|
|
12
|
+
const registry = useRegistry();
|
|
13
13
|
const globalBlockEditingMode = useSelect(
|
|
14
14
|
(select) => (
|
|
15
15
|
// Avoid adding the subscription if not needed!
|
|
@@ -18,15 +18,21 @@ function useBlockEditingMode(mode) {
|
|
|
18
18
|
[clientId]
|
|
19
19
|
);
|
|
20
20
|
useEffect(() => {
|
|
21
|
-
if (mode) {
|
|
22
|
-
|
|
21
|
+
if (!mode) {
|
|
22
|
+
return;
|
|
23
23
|
}
|
|
24
|
+
const {
|
|
25
|
+
setBlockEditingMode,
|
|
26
|
+
unsetBlockEditingMode,
|
|
27
|
+
__unstableMarkNextChangeAsNotPersistent
|
|
28
|
+
} = registry.dispatch(blockEditorStore);
|
|
29
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
30
|
+
setBlockEditingMode(clientId, mode);
|
|
24
31
|
return () => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
32
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
33
|
+
unsetBlockEditingMode(clientId);
|
|
28
34
|
};
|
|
29
|
-
}, [clientId, mode
|
|
35
|
+
}, [registry, clientId, mode]);
|
|
30
36
|
return clientId ? context[blockEditingModeKey] : globalBlockEditingMode;
|
|
31
37
|
}
|
|
32
38
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-editing-mode/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect,
|
|
5
|
-
"mappings": ";AAGA,SAAS,WAAW,mBAAmB;AACvC,SAAS,iBAAiB;AAK1B,SAAS,SAAS,wBAAwB;AAC1C;AAAA,EACC;AAAA,EACA;AAAA,OACM;AAoCA,SAAS,oBAAqB,MAAO;AAC3C,QAAM,UAAU,oBAAoB;AACpC,QAAM,EAAE,WAAW,GAAG,IAAI;AAC1B,QAAM,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useRegistry } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport {\n\tuseBlockEditContext,\n\tblockEditingModeKey,\n} from '../block-edit/context';\n\n/**\n * @typedef {'disabled'|'contentOnly'|'default'} BlockEditingMode\n */\n\n/**\n * Allows a block to restrict the user interface that is displayed for editing\n * that block and its inner blocks.\n *\n * @example\n * ```js\n * function MyBlock( { attributes, setAttributes } ) {\n * useBlockEditingMode( 'disabled' );\n * return <div { ...useBlockProps() }></div>;\n * }\n * ```\n *\n * `mode` can be one of three options:\n *\n * - `'disabled'`: Prevents editing the block entirely, i.e. it cannot be\n * selected.\n * - `'contentOnly'`: Hides all non-content UI, e.g. auxiliary controls in the\n * toolbar, the block movers, block settings.\n * - `'default'`: Allows editing the block as normal.\n *\n * The mode is inherited by all of the block's inner blocks, unless they have\n * their own mode.\n *\n * If called outside of a block context, the mode is applied to all blocks.\n *\n * @param {?BlockEditingMode} mode The editing mode to apply. If undefined, the\n * current editing mode is not changed.\n *\n * @return {BlockEditingMode} The current editing mode.\n */\nexport function useBlockEditingMode( mode ) {\n\tconst context = useBlockEditContext();\n\tconst { clientId = '' } = context;\n\tconst registry = useRegistry();\n\tconst globalBlockEditingMode = useSelect(\n\t\t( select ) =>\n\t\t\t// Avoid adding the subscription if not needed!\n\t\t\tclientId ? null : select( blockEditorStore ).getBlockEditingMode(),\n\t\t[ clientId ]\n\t);\n\tuseEffect( () => {\n\t\tif ( ! mode ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst {\n\t\t\tsetBlockEditingMode,\n\t\t\tunsetBlockEditingMode,\n\t\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\t} = registry.dispatch( blockEditorStore );\n\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tsetBlockEditingMode( clientId, mode );\n\n\t\treturn () => {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tunsetBlockEditingMode( clientId );\n\t\t};\n\t}, [ registry, clientId, mode ] );\n\treturn clientId ? context[ blockEditingModeKey ] : globalBlockEditingMode;\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,WAAW,mBAAmB;AACvC,SAAS,iBAAiB;AAK1B,SAAS,SAAS,wBAAwB;AAC1C;AAAA,EACC;AAAA,EACA;AAAA,OACM;AAoCA,SAAS,oBAAqB,MAAO;AAC3C,QAAM,UAAU,oBAAoB;AACpC,QAAM,EAAE,WAAW,GAAG,IAAI;AAC1B,QAAM,WAAW,YAAY;AAC7B,QAAM,yBAAyB;AAAA,IAC9B,CAAE;AAAA;AAAA,MAED,WAAW,OAAO,OAAQ,gBAAiB,EAAE,oBAAoB;AAAA;AAAA,IAClE,CAAE,QAAS;AAAA,EACZ;AACA,YAAW,MAAM;AAChB,QAAK,CAAE,MAAO;AACb;AAAA,IACD;AAEA,UAAM;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACD,IAAI,SAAS,SAAU,gBAAiB;AAExC,4CAAwC;AACxC,wBAAqB,UAAU,IAAK;AAEpC,WAAO,MAAM;AACZ,8CAAwC;AACxC,4BAAuB,QAAS;AAAA,IACjC;AAAA,EACD,GAAG,CAAE,UAAU,UAAU,IAAK,CAAE;AAChC,SAAO,WAAW,QAAS,mBAAoB,IAAI;AACpD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|