@wordpress/edit-site 4.18.0 → 4.19.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 +2 -0
- package/build/components/add-new-template/add-custom-template-modal.js +3 -1
- package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build/components/block-editor/resizable-editor.js +9 -47
- package/build/components/block-editor/resizable-editor.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +46 -2
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +32 -0
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/palette.js +8 -1
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +52 -16
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +43 -8
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/header-edit-mode/document-actions/index.js +3 -1
- package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build/components/header-edit-mode/index.js +14 -7
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +3 -0
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/list/table.js +1 -1
- package/build/components/list/table.js.map +1 -1
- package/build/components/list/use-register-shortcuts.js +3 -0
- package/build/components/list/use-register-shortcuts.js.map +1 -1
- package/build/components/save-button/index.js +20 -2
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/template-card/index.js +4 -2
- package/build/components/sidebar-edit-mode/template-card/index.js.map +1 -1
- package/build/components/template-details/index.js +4 -2
- package/build/components/template-details/index.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-template-modal.js +2 -1
- package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build-module/components/block-editor/resizable-editor.js +11 -49
- package/build-module/components/block-editor/resizable-editor.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +46 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +27 -1
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/palette.js +9 -3
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +53 -16
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +44 -9
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/header-edit-mode/document-actions/index.js +2 -1
- package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +13 -7
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +3 -0
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/list/table.js +1 -1
- package/build-module/components/list/table.js.map +1 -1
- package/build-module/components/list/use-register-shortcuts.js +3 -0
- package/build-module/components/list/use-register-shortcuts.js.map +1 -1
- package/build-module/components/save-button/index.js +21 -2
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/template-card/index.js +3 -2
- package/build-module/components/sidebar-edit-mode/template-card/index.js.map +1 -1
- package/build-module/components/template-details/index.js +3 -2
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-style/style-rtl.css +15 -15
- package/build-style/style.css +15 -15
- package/package.json +30 -29
- package/src/components/add-new-template/add-custom-template-modal.js +5 -1
- package/src/components/block-editor/resizable-editor.js +10 -55
- package/src/components/editor/style.scss +1 -7
- package/src/components/global-styles/dimensions-panel.js +59 -1
- package/src/components/global-styles/hooks.js +36 -0
- package/src/components/global-styles/palette.js +15 -1
- package/src/components/global-styles/test/typography-utils.js +82 -98
- package/src/components/global-styles/test/use-global-styles-output.js +6 -6
- package/src/components/global-styles/typography-panel.js +57 -15
- package/src/components/global-styles/use-global-styles-output.js +47 -10
- package/src/components/header-edit-mode/document-actions/index.js +2 -1
- package/src/components/header-edit-mode/index.js +8 -4
- package/src/components/keyboard-shortcuts/index.js +4 -0
- package/src/components/list/table.js +1 -1
- package/src/components/list/use-register-shortcuts.js +4 -0
- package/src/components/navigation-sidebar/navigation-panel/style.scss +0 -7
- package/src/components/navigation-sidebar/navigation-toggle/test/index.js +20 -24
- package/src/components/save-button/index.js +17 -1
- package/src/components/sidebar-edit-mode/template-card/index.js +3 -2
- package/src/components/template-details/index.js +3 -2
- package/src/components/navigation-sidebar/navigation-toggle/test/__snapshots__/index.js.snap +0 -41
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/list/use-register-shortcuts.js"],"names":["useRegisterShortcuts","registerShortcut","keyboardShortcutsStore","name","category","description","keyCombination","modifier","character","aliases"],"mappings":";;;;;;;AAIA;;AACA;;AACA;;AACA;;AAPA;AACA;AACA;AAOe,SAASA,oBAAT,GAAgC;AAC9C,QAAM;AAAEC,IAAAA;AAAF,MAAuB,uBAAaC,wBAAb,CAA7B;AACA,0BAAW,MAAM;AAChBD,IAAAA,gBAAgB,CAAE;AACjBE,MAAAA,IAAI,EAAE,4BADW;AAEjBC,MAAAA,QAAQ,EAAE,QAFO;AAGjBC,MAAAA,WAAW,EAAE,cAAI,0CAAJ,CAHI;AAIjBC,MAAAA,cAAc,EAAE;AACfC,QAAAA,QAAQ,EAAE,MADK;AAEfC,QAAAA,SAAS,EAAE;AAFI,OAJC;AAQjBC,MAAAA,OAAO,EAAE,CACR;AACCF,QAAAA,QAAQ,EAAE,QADX;AAECC,QAAAA,SAAS,EAAE;AAFZ,OADQ;AARQ,KAAF,CAAhB;AAgBAP,IAAAA,gBAAgB,CAAE;AACjBE,MAAAA,IAAI,EAAE,gCADW;AAEjBC,MAAAA,QAAQ,EAAE,QAFO;AAGjBC,MAAAA,WAAW,EAAE,cAAI,8CAAJ,CAHI;AAIjBC,MAAAA,cAAc,EAAE;AACfC,QAAAA,QAAQ,EAAE,WADK;AAEfC,QAAAA,SAAS,EAAE;AAFI,OAJC;AAQjBC,MAAAA,OAAO,EAAE,CACR;AACCF,QAAAA,QAAQ,EAAE,QADX;AAECC,QAAAA,SAAS,EAAE;AAFZ,OADQ;AARQ,KAAF,CAAhB;
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/list/use-register-shortcuts.js"],"names":["useRegisterShortcuts","registerShortcut","keyboardShortcutsStore","name","category","description","keyCombination","modifier","character","aliases"],"mappings":";;;;;;;AAIA;;AACA;;AACA;;AACA;;AAPA;AACA;AACA;AAOe,SAASA,oBAAT,GAAgC;AAC9C,QAAM;AAAEC,IAAAA;AAAF,MAAuB,uBAAaC,wBAAb,CAA7B;AACA,0BAAW,MAAM;AAChBD,IAAAA,gBAAgB,CAAE;AACjBE,MAAAA,IAAI,EAAE,4BADW;AAEjBC,MAAAA,QAAQ,EAAE,QAFO;AAGjBC,MAAAA,WAAW,EAAE,cAAI,0CAAJ,CAHI;AAIjBC,MAAAA,cAAc,EAAE;AACfC,QAAAA,QAAQ,EAAE,MADK;AAEfC,QAAAA,SAAS,EAAE;AAFI,OAJC;AAQjBC,MAAAA,OAAO,EAAE,CACR;AACCF,QAAAA,QAAQ,EAAE,QADX;AAECC,QAAAA,SAAS,EAAE;AAFZ,OADQ;AARQ,KAAF,CAAhB;AAgBAP,IAAAA,gBAAgB,CAAE;AACjBE,MAAAA,IAAI,EAAE,gCADW;AAEjBC,MAAAA,QAAQ,EAAE,QAFO;AAGjBC,MAAAA,WAAW,EAAE,cAAI,8CAAJ,CAHI;AAIjBC,MAAAA,cAAc,EAAE;AACfC,QAAAA,QAAQ,EAAE,WADK;AAEfC,QAAAA,SAAS,EAAE;AAFI,OAJC;AAQjBC,MAAAA,OAAO,EAAE,CACR;AACCF,QAAAA,QAAQ,EAAE,QADX;AAECC,QAAAA,SAAS,EAAE;AAFZ,OADQ,EAKR;AACCD,QAAAA,QAAQ,EAAE,WADX;AAECC,QAAAA,SAAS,EAAE;AAFZ,OALQ;AARQ,KAAF,CAAhB;AAmBA,GApCD,EAoCG,EApCH;AAqCA","sourcesContent":["/**\n * WordPress dependencies\n */\n\nimport { useDispatch } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n\nexport default function useRegisterShortcuts() {\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-site/next-region',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Navigate to the next part of the editor.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'ctrl',\n\t\t\t\tcharacter: '`',\n\t\t\t},\n\t\t\taliases: [\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: 'n',\n\t\t\t\t},\n\t\t\t],\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-site/previous-region',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Navigate to the previous part of the editor.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'ctrlShift',\n\t\t\t\tcharacter: '`',\n\t\t\t},\n\t\t\taliases: [\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: 'p',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'ctrlShift',\n\t\t\t\t\tcharacter: '~',\n\t\t\t\t},\n\t\t\t],\n\t\t} );\n\t}, [] );\n}\n"]}
|
|
@@ -15,6 +15,8 @@ var _i18n = require("@wordpress/i18n");
|
|
|
15
15
|
|
|
16
16
|
var _coreData = require("@wordpress/core-data");
|
|
17
17
|
|
|
18
|
+
var _keycodes = require("@wordpress/keycodes");
|
|
19
|
+
|
|
18
20
|
var _store = require("../../store");
|
|
19
21
|
|
|
20
22
|
/**
|
|
@@ -50,13 +52,29 @@ function SaveButton() {
|
|
|
50
52
|
setIsSaveViewOpened
|
|
51
53
|
} = (0, _data.useDispatch)(_store.store);
|
|
52
54
|
const disabled = !isDirty || isSaving;
|
|
55
|
+
const label = (0, _i18n.__)('Save');
|
|
53
56
|
return (0, _element.createElement)(_components.Button, {
|
|
54
57
|
variant: "primary",
|
|
55
58
|
className: "edit-site-save-button__button",
|
|
56
59
|
"aria-disabled": disabled,
|
|
57
60
|
"aria-expanded": isSaveViewOpen,
|
|
58
61
|
isBusy: isSaving,
|
|
59
|
-
onClick: disabled ? undefined : () => setIsSaveViewOpened(true)
|
|
60
|
-
|
|
62
|
+
onClick: disabled ? undefined : () => setIsSaveViewOpened(true),
|
|
63
|
+
label: label
|
|
64
|
+
/*
|
|
65
|
+
* We want the tooltip to show the keyboard shortcut only when the
|
|
66
|
+
* button does something, i.e. when it's not disabled.
|
|
67
|
+
*/
|
|
68
|
+
,
|
|
69
|
+
shortcut: disabled ? undefined : _keycodes.displayShortcut.primary('s')
|
|
70
|
+
/*
|
|
71
|
+
* Displaying the keyboard shortcut conditionally makes the tooltip
|
|
72
|
+
* itself show conditionally. This would trigger a full-rerendering
|
|
73
|
+
* of the button that we want to avoid. By setting `showTooltip`,
|
|
74
|
+
& the tooltip is always rendered even when there's no keyboard shortcut.
|
|
75
|
+
*/
|
|
76
|
+
,
|
|
77
|
+
showTooltip: true
|
|
78
|
+
}, label);
|
|
61
79
|
}
|
|
62
80
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/save-button/index.js"],"names":["SaveButton","isDirty","isSaving","isSaveViewOpen","select","__experimentalGetDirtyEntityRecords","isSavingEntityRecord","coreStore","dirtyEntityRecords","isSaveViewOpened","editSiteStore","length","some","record","kind","name","key","setIsSaveViewOpened","disabled","undefined"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/save-button/index.js"],"names":["SaveButton","isDirty","isSaving","isSaveViewOpen","select","__experimentalGetDirtyEntityRecords","isSavingEntityRecord","coreStore","dirtyEntityRecords","isSaveViewOpened","editSiteStore","length","some","record","kind","name","key","setIsSaveViewOpened","disabled","label","undefined","displayShortcut","primary"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;AAGe,SAASA,UAAT,GAAsB;AACpC,QAAM;AAAEC,IAAAA,OAAF;AAAWC,IAAAA,QAAX;AAAqBC,IAAAA;AAArB,MAAwC,qBAAaC,MAAF,IAAc;AACtE,UAAM;AAAEC,MAAAA,mCAAF;AAAuCC,MAAAA;AAAvC,QACLF,MAAM,CAAEG,eAAF,CADP;;AAEA,UAAMC,kBAAkB,GAAGH,mCAAmC,EAA9D;;AACA,UAAM;AAAEI,MAAAA;AAAF,QAAuBL,MAAM,CAAEM,YAAF,CAAnC;AACA,WAAO;AACNT,MAAAA,OAAO,EAAEO,kBAAkB,CAACG,MAAnB,GAA4B,CAD/B;AAENT,MAAAA,QAAQ,EAAEM,kBAAkB,CAACI,IAAnB,CAA2BC,MAAF,IAClCP,oBAAoB,CAAEO,MAAM,CAACC,IAAT,EAAeD,MAAM,CAACE,IAAtB,EAA4BF,MAAM,CAACG,GAAnC,CADX,CAFJ;AAKNb,MAAAA,cAAc,EAAEM,gBAAgB;AAL1B,KAAP;AAOA,GAZ6C,EAY3C,EAZ2C,CAA9C;AAaA,QAAM;AAAEQ,IAAAA;AAAF,MAA0B,uBAAaP,YAAb,CAAhC;AAEA,QAAMQ,QAAQ,GAAG,CAAEjB,OAAF,IAAaC,QAA9B;AAEA,QAAMiB,KAAK,GAAG,cAAI,MAAJ,CAAd;AAEA,SACC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,SAAS,EAAC,+BAFX;AAGC,qBAAgBD,QAHjB;AAIC,qBAAgBf,cAJjB;AAKC,IAAA,MAAM,EAAGD,QALV;AAMC,IAAA,OAAO,EAAGgB,QAAQ,GAAGE,SAAH,GAAe,MAAMH,mBAAmB,CAAE,IAAF,CAN3D;AAOC,IAAA,KAAK,EAAGE;AACR;AACH;AACA;AACA;AAXE;AAYC,IAAA,QAAQ,EAAGD,QAAQ,GAAGE,SAAH,GAAeC,0BAAgBC,OAAhB,CAAyB,GAAzB;AAClC;AACH;AACA;AACA;AACA;AACA;AAlBE;AAmBC,IAAA,WAAW;AAnBZ,KAqBGH,KArBH,CADD;AAyBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { displayShortcut } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nexport default function SaveButton() {\n\tconst { isDirty, isSaving, isSaveViewOpen } = useSelect( ( select ) => {\n\t\tconst { __experimentalGetDirtyEntityRecords, isSavingEntityRecord } =\n\t\t\tselect( coreStore );\n\t\tconst dirtyEntityRecords = __experimentalGetDirtyEntityRecords();\n\t\tconst { isSaveViewOpened } = select( editSiteStore );\n\t\treturn {\n\t\t\tisDirty: dirtyEntityRecords.length > 0,\n\t\t\tisSaving: dirtyEntityRecords.some( ( record ) =>\n\t\t\t\tisSavingEntityRecord( record.kind, record.name, record.key )\n\t\t\t),\n\t\t\tisSaveViewOpen: isSaveViewOpened(),\n\t\t};\n\t}, [] );\n\tconst { setIsSaveViewOpened } = useDispatch( editSiteStore );\n\n\tconst disabled = ! isDirty || isSaving;\n\n\tconst label = __( 'Save' );\n\n\treturn (\n\t\t<Button\n\t\t\tvariant=\"primary\"\n\t\t\tclassName=\"edit-site-save-button__button\"\n\t\t\taria-disabled={ disabled }\n\t\t\taria-expanded={ isSaveViewOpen }\n\t\t\tisBusy={ isSaving }\n\t\t\tonClick={ disabled ? undefined : () => setIsSaveViewOpened( true ) }\n\t\t\tlabel={ label }\n\t\t\t/*\n\t\t\t * We want the tooltip to show the keyboard shortcut only when the\n\t\t\t * button does something, i.e. when it's not disabled.\n\t\t\t */\n\t\t\tshortcut={ disabled ? undefined : displayShortcut.primary( 's' ) }\n\t\t\t/*\n\t\t\t * Displaying the keyboard shortcut conditionally makes the tooltip\n\t\t\t * itself show conditionally. This would trigger a full-rerendering\n\t\t\t * of the button that we want to avoid. By setting `showTooltip`,\n\t\t\t & the tooltip is always rendered even when there's no keyboard shortcut.\n\t\t\t */\n\t\t\tshowTooltip\n\t\t>\n\t\t\t{ label }\n\t\t</Button>\n\t);\n}\n"]}
|
|
@@ -17,6 +17,8 @@ var _editor = require("@wordpress/editor");
|
|
|
17
17
|
|
|
18
18
|
var _coreData = require("@wordpress/core-data");
|
|
19
19
|
|
|
20
|
+
var _htmlEntities = require("@wordpress/html-entities");
|
|
21
|
+
|
|
20
22
|
var _store = require("../../../store");
|
|
21
23
|
|
|
22
24
|
var _templateActions = _interopRequireDefault(require("./template-actions"));
|
|
@@ -74,10 +76,10 @@ function TemplateCard() {
|
|
|
74
76
|
className: "edit-site-template-card__header"
|
|
75
77
|
}, (0, _element.createElement)("h2", {
|
|
76
78
|
className: "edit-site-template-card__title"
|
|
77
|
-
}, title), (0, _element.createElement)(_templateActions.default, {
|
|
79
|
+
}, (0, _htmlEntities.decodeEntities)(title)), (0, _element.createElement)(_templateActions.default, {
|
|
78
80
|
template: template
|
|
79
81
|
})), (0, _element.createElement)("div", {
|
|
80
82
|
className: "edit-site-template-card__description"
|
|
81
|
-
}, description), (0, _element.createElement)(_templateAreas.default, null)));
|
|
83
|
+
}, (0, _htmlEntities.decodeEntities)(description)), (0, _element.createElement)(_templateAreas.default, null)));
|
|
82
84
|
}
|
|
83
85
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-edit-mode/template-card/index.js"],"names":["TemplateCard","info","title","description","icon","template","select","getEditedPostType","getEditedPostId","editSiteStore","getEditedEntityRecord","coreStore","__experimentalGetTemplateInfo","getTemplateInfo","editorStore","postType","postId","record"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-edit-mode/template-card/index.js"],"names":["TemplateCard","info","title","description","icon","template","select","getEditedPostType","getEditedPostId","editSiteStore","getEditedEntityRecord","coreStore","__experimentalGetTemplateInfo","getTemplateInfo","editorStore","postType","postId","record"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAdA;AACA;AACA;;AAOA;AACA;AACA;AAKe,SAASA,YAAT,GAAwB;AACtC,QAAM;AACLC,IAAAA,IAAI,EAAE;AAAEC,MAAAA,KAAF;AAASC,MAAAA,WAAT;AAAsBC,MAAAA;AAAtB,KADD;AAELC,IAAAA;AAFK,MAGF,qBAAaC,MAAF,IAAc;AAC5B,UAAM;AAAEC,MAAAA,iBAAF;AAAqBC,MAAAA;AAArB,QAAyCF,MAAM,CAAEG,YAAF,CAArD;AACA,UAAM;AAAEC,MAAAA;AAAF,QAA4BJ,MAAM,CAAEK,eAAF,CAAxC;AACA,UAAM;AAAEC,MAAAA,6BAA6B,EAAEC;AAAjC,QACLP,MAAM,CAAEQ,aAAF,CADP;AAGA,UAAMC,QAAQ,GAAGR,iBAAiB,EAAlC;AACA,UAAMS,MAAM,GAAGR,eAAe,EAA9B;AACA,UAAMS,MAAM,GAAGP,qBAAqB,CAAE,UAAF,EAAcK,QAAd,EAAwBC,MAAxB,CAApC;AAEA,UAAMf,IAAI,GAAGgB,MAAM,GAAGJ,eAAe,CAAEI,MAAF,CAAlB,GAA+B,EAAlD;AAEA,WAAO;AAAEhB,MAAAA,IAAF;AAAQI,MAAAA,QAAQ,EAAEY;AAAlB,KAAP;AACA,GAbG,EAaD,EAbC,CAHJ;;AAkBA,MAAK,CAAEf,KAAF,IAAW,CAAEC,WAAlB,EAAgC;AAC/B,WAAO,IAAP;AACA;;AAED,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,gBAAD;AAAM,IAAA,SAAS,EAAC,+BAAhB;AAAgD,IAAA,IAAI,EAAGC;AAAvD,IADD,EAEC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAI,IAAA,SAAS,EAAC;AAAd,KACG,kCAAgBF,KAAhB,CADH,CADD,EAIC,4BAAC,wBAAD;AAAiB,IAAA,QAAQ,EAAGG;AAA5B,IAJD,CADD,EAOC;AAAK,IAAA,SAAS,EAAC;AAAf,KACG,kCAAgBF,WAAhB,CADH,CAPD,EAUC,4BAAC,sBAAD,OAVD,CAFD,CADD;AAiBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { Icon } from '@wordpress/components';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../../store';\nimport TemplateActions from './template-actions';\nimport TemplateAreas from './template-areas';\n\nexport default function TemplateCard() {\n\tconst {\n\t\tinfo: { title, description, icon },\n\t\ttemplate,\n\t} = useSelect( ( select ) => {\n\t\tconst { getEditedPostType, getEditedPostId } = select( editSiteStore );\n\t\tconst { getEditedEntityRecord } = select( coreStore );\n\t\tconst { __experimentalGetTemplateInfo: getTemplateInfo } =\n\t\t\tselect( editorStore );\n\n\t\tconst postType = getEditedPostType();\n\t\tconst postId = getEditedPostId();\n\t\tconst record = getEditedEntityRecord( 'postType', postType, postId );\n\n\t\tconst info = record ? getTemplateInfo( record ) : {};\n\n\t\treturn { info, template: record };\n\t}, [] );\n\n\tif ( ! title && ! description ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div className=\"edit-site-template-card\">\n\t\t\t<Icon className=\"edit-site-template-card__icon\" icon={ icon } />\n\t\t\t<div className=\"edit-site-template-card__content\">\n\t\t\t\t<div className=\"edit-site-template-card__header\">\n\t\t\t\t\t<h2 className=\"edit-site-template-card__title\">\n\t\t\t\t\t\t{ decodeEntities( title ) }\n\t\t\t\t\t</h2>\n\t\t\t\t\t<TemplateActions template={ template } />\n\t\t\t\t</div>\n\t\t\t\t<div className=\"edit-site-template-card__description\">\n\t\t\t\t\t{ decodeEntities( description ) }\n\t\t\t\t</div>\n\t\t\t\t<TemplateAreas />\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -19,6 +19,8 @@ var _data = require("@wordpress/data");
|
|
|
19
19
|
|
|
20
20
|
var _editor = require("@wordpress/editor");
|
|
21
21
|
|
|
22
|
+
var _htmlEntities = require("@wordpress/html-entities");
|
|
23
|
+
|
|
22
24
|
var _isTemplateRevertable = _interopRequireDefault(require("../../utils/is-template-revertable"));
|
|
23
25
|
|
|
24
26
|
var _store = require("../../store");
|
|
@@ -81,11 +83,11 @@ function TemplateDetails(_ref) {
|
|
|
81
83
|
weight: 600,
|
|
82
84
|
className: "edit-site-template-details__title",
|
|
83
85
|
as: "p"
|
|
84
|
-
}, title), description && (0, _element.createElement)(_components.__experimentalText, {
|
|
86
|
+
}, (0, _htmlEntities.decodeEntities)(title)), description && (0, _element.createElement)(_components.__experimentalText, {
|
|
85
87
|
size: "body",
|
|
86
88
|
className: "edit-site-template-details__description",
|
|
87
89
|
as: "p"
|
|
88
|
-
}, description)), isTemplatePart && (0, _element.createElement)("div", {
|
|
90
|
+
}, (0, _htmlEntities.decodeEntities)(description))), isTemplatePart && (0, _element.createElement)("div", {
|
|
89
91
|
className: "edit-site-template-details__group"
|
|
90
92
|
}, (0, _element.createElement)(_templatePartAreaSelector.default, {
|
|
91
93
|
id: template.id
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/template-details/index.js"],"names":["TemplateDetails","template","onClose","title","description","select","editorStore","__experimentalGetTemplateInfo","revertTemplate","editSiteStore","browseAllLinkProps","postType","type","postId","undefined","isTemplatePart","canEditTitle","has_theme_file","is_custom","revert","id"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AAOA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/template-details/index.js"],"names":["TemplateDetails","template","onClose","title","description","select","editorStore","__experimentalGetTemplateInfo","revertTemplate","editSiteStore","browseAllLinkProps","postType","type","postId","undefined","isTemplatePart","canEditTitle","has_theme_file","is_custom","revert","id"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AAOA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAvBA;AACA;AACA;;AAaA;AACA;AACA;AAQe,SAASA,eAAT,OAAkD;AAAA,MAAxB;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAwB;AAChE,QAAM;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,MAAyB,qBAC5BC,MAAF,IACCA,MAAM,CAAEC,aAAF,CAAN,CAAsBC,6BAAtB,CAAqDN,QAArD,CAF6B,EAG9B,EAH8B,CAA/B;AAKA,QAAM;AAAEO,IAAAA;AAAF,MAAqB,uBAAaC,YAAb,CAA3B;AAEA,QAAMC,kBAAkB,GAAG,mBAAS;AACnC;AACAC,IAAAA,QAAQ,EAAEV,QAAQ,CAACW,IAFgB;AAGnCC,IAAAA,MAAM,EAAEC;AAH2B,GAAT,CAA3B;AAMA,QAAMC,cAAc,GAAGd,QAAQ,CAACW,IAAT,KAAkB,kBAAzC,CAdgE,CAgBhE;AACA;;AACA,QAAMI,YAAY,GAAGD,cAAc,GAChC,CAAEd,QAAQ,CAACgB,cADqB,GAEhChB,QAAQ,CAACiB,SAAT,IAAsB,CAAEjB,QAAQ,CAACgB,cAFpC;;AAIA,MAAK,CAAEhB,QAAP,EAAkB;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aAAnB,GACC,cAAI,sBAAJ,CADD,GAEC,cAAI,2BAAJ,CANJ,CAhDD,CADD;AA2DA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tButton,\n\tMenuGroup,\n\tMenuItem,\n\t__experimentalVStack as VStack,\n\t__experimentalText as Text,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport isTemplateRevertable from '../../utils/is-template-revertable';\nimport { store as editSiteStore } from '../../store';\nimport TemplateAreas from './template-areas';\nimport EditTemplateTitle from './edit-template-title';\nimport { useLink } from '../routes/link';\nimport TemplatePartAreaSelector from './template-part-area-selector';\n\nexport default function TemplateDetails( { template, onClose } ) {\n\tconst { title, description } = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).__experimentalGetTemplateInfo( template ),\n\t\t[]\n\t);\n\tconst { revertTemplate } = useDispatch( editSiteStore );\n\n\tconst browseAllLinkProps = useLink( {\n\t\t// TODO: We should update this to filter by template part's areas as well.\n\t\tpostType: template.type,\n\t\tpostId: undefined,\n\t} );\n\n\tconst isTemplatePart = template.type === 'wp_template_part';\n\n\t// Only user-created and non-default templates can change the name.\n\t// But any user-created template part can be renamed.\n\tconst canEditTitle = isTemplatePart\n\t\t? ! template.has_theme_file\n\t\t: template.is_custom && ! template.has_theme_file;\n\n\tif ( ! template ) {\n\t\treturn null;\n\t}\n\n\tconst revert = () => {\n\t\trevertTemplate( template );\n\t\tonClose();\n\t};\n\n\treturn (\n\t\t<div className=\"edit-site-template-details\">\n\t\t\t<VStack className=\"edit-site-template-details__group\" spacing={ 3 }>\n\t\t\t\t{ canEditTitle ? (\n\t\t\t\t\t<EditTemplateTitle template={ template } />\n\t\t\t\t) : (\n\t\t\t\t\t<Text\n\t\t\t\t\t\tsize={ 16 }\n\t\t\t\t\t\tweight={ 600 }\n\t\t\t\t\t\tclassName=\"edit-site-template-details__title\"\n\t\t\t\t\t\tas=\"p\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ decodeEntities( title ) }\n\t\t\t\t\t</Text>\n\t\t\t\t) }\n\n\t\t\t\t{ description && (\n\t\t\t\t\t<Text\n\t\t\t\t\t\tsize=\"body\"\n\t\t\t\t\t\tclassName=\"edit-site-template-details__description\"\n\t\t\t\t\t\tas=\"p\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ decodeEntities( description ) }\n\t\t\t\t\t</Text>\n\t\t\t\t) }\n\t\t\t</VStack>\n\n\t\t\t{ isTemplatePart && (\n\t\t\t\t<div className=\"edit-site-template-details__group\">\n\t\t\t\t\t<TemplatePartAreaSelector id={ template.id } />\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t<TemplateAreas closeTemplateDetailsDropdown={ onClose } />\n\n\t\t\t{ isTemplateRevertable( template ) && (\n\t\t\t\t<MenuGroup className=\"edit-site-template-details__group edit-site-template-details__revert\">\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tclassName=\"edit-site-template-details__revert-button\"\n\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t'Use the template as supplied by the theme.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tonClick={ revert }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Clear customizations' ) }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\n\t\t\t<Button\n\t\t\t\tclassName=\"edit-site-template-details__show-all-button\"\n\t\t\t\t{ ...browseAllLinkProps }\n\t\t\t>\n\t\t\t\t{ template?.type === 'wp_template'\n\t\t\t\t\t? __( 'Browse all templates' )\n\t\t\t\t\t: __( 'Browse all template parts' ) }\n\t\t\t</Button>\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -9,6 +9,7 @@ import { __, sprintf } from '@wordpress/i18n';
|
|
|
9
9
|
import { Button, Flex, FlexItem, Modal, SearchControl, TextHighlight, __experimentalText as Text, __unstableComposite as Composite, __unstableUseCompositeState as useCompositeState, __unstableCompositeItem as CompositeItem } from '@wordpress/components';
|
|
10
10
|
import { useDebounce } from '@wordpress/compose';
|
|
11
11
|
import { useEntityRecords } from '@wordpress/core-data';
|
|
12
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
12
13
|
/**
|
|
13
14
|
* Internal dependencies
|
|
14
15
|
*/
|
|
@@ -35,7 +36,7 @@ function SuggestionListItem(_ref) {
|
|
|
35
36
|
}), createElement("span", {
|
|
36
37
|
className: `${baseCssClass}__title`
|
|
37
38
|
}, createElement(TextHighlight, {
|
|
38
|
-
text: suggestion.name,
|
|
39
|
+
text: decodeEntities(suggestion.name),
|
|
39
40
|
highlight: search
|
|
40
41
|
})), suggestion.link && createElement("span", {
|
|
41
42
|
className: `${baseCssClass}__info`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/add-custom-template-modal.js"],"names":["useState","useMemo","useEffect","__","sprintf","Button","Flex","FlexItem","Modal","SearchControl","TextHighlight","__experimentalText","Text","__unstableComposite","Composite","__unstableUseCompositeState","useCompositeState","__unstableCompositeItem","CompositeItem","useDebounce","useEntityRecords","TemplateActionsLoadingScreen","mapToIHasNameAndId","EMPTY_ARRAY","SuggestionListItem","suggestion","search","onSelect","entityForSuggestions","composite","baseCssClass","config","getSpecificTemplate","name","link","useDebouncedInput","input","setInput","debounced","setter","setDebounced","useSearchSuggestions","query","order","context","per_page","queryArgs","records","searchResults","hasResolved","searchHasResolved","type","slug","suggestions","setSuggestions","newSuggestions","length","recordNamePath","SuggestionList","orientation","setSearch","debouncedSearch","labels","showSearchControl","setShowSearchControl","search_items","map","not_found","AddCustomTemplateModal","onClose","isCreatingTemplate","showSearchEntities","setShowSearchEntities","hasGeneralTemplate","singular_name","title","description","templatePrefix","template","all_items"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,OAAnB,EA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,oBADxB;AAEC,IAAA,QAAQ,EAAGD;AAFZ,IAND,CAxEF,CADD;AAuFA;;AAED,eAAeyC,sBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useMemo, useEffect } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tFlex,\n\tFlexItem,\n\tModal,\n\tSearchControl,\n\tTextHighlight,\n\t__experimentalText as Text,\n\t__unstableComposite as Composite,\n\t__unstableUseCompositeState as useCompositeState,\n\t__unstableCompositeItem as CompositeItem,\n} from '@wordpress/components';\nimport { useDebounce } from '@wordpress/compose';\nimport { useEntityRecords } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport TemplateActionsLoadingScreen from './template-actions-loading-screen';\nimport { mapToIHasNameAndId } from './utils';\n\nconst EMPTY_ARRAY = [];\n\nfunction SuggestionListItem( {\n\tsuggestion,\n\tsearch,\n\tonSelect,\n\tentityForSuggestions,\n\tcomposite,\n} ) {\n\tconst baseCssClass =\n\t\t'edit-site-custom-template-modal__suggestions_list__list-item';\n\treturn (\n\t\t<CompositeItem\n\t\t\trole=\"option\"\n\t\t\tas={ Button }\n\t\t\t{ ...composite }\n\t\t\tclassName={ baseCssClass }\n\t\t\tonClick={ () =>\n\t\t\t\tonSelect(\n\t\t\t\t\tentityForSuggestions.config.getSpecificTemplate(\n\t\t\t\t\t\tsuggestion\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t}\n\t\t>\n\t\t\t<span className={ `${ baseCssClass }__title` }>\n\t\t\t\t<TextHighlight text={ suggestion.name } highlight={ search } />\n\t\t\t</span>\n\t\t\t{ suggestion.link && (\n\t\t\t\t<span className={ `${ baseCssClass }__info` }>\n\t\t\t\t\t{ suggestion.link }\n\t\t\t\t</span>\n\t\t\t) }\n\t\t</CompositeItem>\n\t);\n}\n\nfunction useDebouncedInput() {\n\tconst [ input, setInput ] = useState( '' );\n\tconst [ debounced, setter ] = useState( '' );\n\tconst setDebounced = useDebounce( setter, 250 );\n\tuseEffect( () => {\n\t\tif ( debounced !== input ) {\n\t\t\tsetDebounced( input );\n\t\t}\n\t}, [ debounced, input ] );\n\treturn [ input, setInput, debounced ];\n}\n\nfunction useSearchSuggestions( entityForSuggestions, search ) {\n\tconst { config } = entityForSuggestions;\n\tconst query = useMemo(\n\t\t() => ( {\n\t\t\torder: 'asc',\n\t\t\tcontext: 'view',\n\t\t\tsearch,\n\t\t\tper_page: search ? 20 : 10,\n\t\t\t...config.queryArgs( search ),\n\t\t} ),\n\t\t[ search, config ]\n\t);\n\tconst { records: searchResults, hasResolved: searchHasResolved } =\n\t\tuseEntityRecords(\n\t\t\tentityForSuggestions.type,\n\t\t\tentityForSuggestions.slug,\n\t\t\tquery\n\t\t);\n\tconst [ suggestions, setSuggestions ] = useState( EMPTY_ARRAY );\n\tuseEffect( () => {\n\t\tif ( ! searchHasResolved ) return;\n\t\tlet newSuggestions = EMPTY_ARRAY;\n\t\tif ( searchResults?.length ) {\n\t\t\tnewSuggestions = searchResults;\n\t\t\tif ( config.recordNamePath ) {\n\t\t\t\tnewSuggestions = mapToIHasNameAndId(\n\t\t\t\t\tnewSuggestions,\n\t\t\t\t\tconfig.recordNamePath\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\t// Update suggestions only when the query has resolved, so as to keep\n\t\t// the previous results in the UI.\n\t\tsetSuggestions( newSuggestions );\n\t}, [ searchResults, searchHasResolved ] );\n\treturn suggestions;\n}\n\nfunction SuggestionList( { entityForSuggestions, onSelect } ) {\n\tconst composite = useCompositeState( { orientation: 'vertical' } );\n\tconst [ search, setSearch, debouncedSearch ] = useDebouncedInput();\n\tconst suggestions = useSearchSuggestions(\n\t\tentityForSuggestions,\n\t\tdebouncedSearch\n\t);\n\tconst { labels } = entityForSuggestions;\n\tconst [ showSearchControl, setShowSearchControl ] = useState( false );\n\tif ( ! showSearchControl && suggestions?.length > 9 ) {\n\t\tsetShowSearchControl( true );\n\t}\n\treturn (\n\t\t<>\n\t\t\t{ showSearchControl && (\n\t\t\t\t<SearchControl\n\t\t\t\t\tonChange={ setSearch }\n\t\t\t\t\tvalue={ search }\n\t\t\t\t\tlabel={ labels.search_items }\n\t\t\t\t\tplaceholder={ labels.search_items }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ !! suggestions?.length && (\n\t\t\t\t<Composite\n\t\t\t\t\t{ ...composite }\n\t\t\t\t\trole=\"listbox\"\n\t\t\t\t\tclassName=\"edit-site-custom-template-modal__suggestions_list\"\n\t\t\t\t\taria-label={ __( 'Suggestions list' ) }\n\t\t\t\t>\n\t\t\t\t\t{ suggestions.map( ( suggestion ) => (\n\t\t\t\t\t\t<SuggestionListItem\n\t\t\t\t\t\t\tkey={ suggestion.slug }\n\t\t\t\t\t\t\tsuggestion={ suggestion }\n\t\t\t\t\t\t\tsearch={ debouncedSearch }\n\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t\tentityForSuggestions={ entityForSuggestions }\n\t\t\t\t\t\t\tcomposite={ composite }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t</Composite>\n\t\t\t) }\n\t\t\t{ debouncedSearch && ! suggestions?.length && (\n\t\t\t\t<p className=\"edit-site-custom-template-modal__no-results\">\n\t\t\t\t\t{ labels.not_found }\n\t\t\t\t</p>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction AddCustomTemplateModal( {\n\tonClose,\n\tonSelect,\n\tentityForSuggestions,\n\tisCreatingTemplate,\n} ) {\n\tconst [ showSearchEntities, setShowSearchEntities ] = useState(\n\t\tentityForSuggestions.hasGeneralTemplate\n\t);\n\tconst baseCssClass = 'edit-site-custom-template-modal';\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ sprintf(\n\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t__( 'Add template: %s' ),\n\t\t\t\tentityForSuggestions.labels.singular_name\n\t\t\t) }\n\t\t\tclassName={ baseCssClass }\n\t\t\tcloseLabel={ __( 'Close' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t>\n\t\t\t{ isCreatingTemplate && <TemplateActionsLoadingScreen /> }\n\t\t\t{ ! showSearchEntities && (\n\t\t\t\t<>\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Select whether to create a single template for all items or a specific one.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t\t<Flex\n\t\t\t\t\t\tclassName={ `${ baseCssClass }__contents` }\n\t\t\t\t\t\tgap=\"4\"\n\t\t\t\t\t\talign=\"initial\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\ttemplatePrefix,\n\t\t\t\t\t\t\t\t} = entityForSuggestions.template;\n\t\t\t\t\t\t\t\tonSelect( {\n\t\t\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\ttemplatePrefix,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Text as=\"span\" weight={ 600 }>\n\t\t\t\t\t\t\t\t{ entityForSuggestions.labels.all_items }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t<Text as=\"span\">\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t// translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one.\n\t\t\t\t\t\t\t\t\t__( 'For all items' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetShowSearchEntities( true );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Text as=\"span\" weight={ 600 }>\n\t\t\t\t\t\t\t\t{ entityForSuggestions.labels.singular_name }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t<Text as=\"span\">\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t// translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one.\n\t\t\t\t\t\t\t\t\t__( 'For a specific item' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t</Flex>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ showSearchEntities && (\n\t\t\t\t<>\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'This template will be used only for the specific item chosen.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t\t<SuggestionList\n\t\t\t\t\t\tentityForSuggestions={ entityForSuggestions }\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</Modal>\n\t);\n}\n\nexport default AddCustomTemplateModal;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/add-custom-template-modal.js"],"names":["useState","useMemo","useEffect","__","sprintf","Button","Flex","FlexItem","Modal","SearchControl","TextHighlight","__experimentalText","Text","__unstableComposite","Composite","__unstableUseCompositeState","useCompositeState","__unstableCompositeItem","CompositeItem","useDebounce","useEntityRecords","decodeEntities","TemplateActionsLoadingScreen","mapToIHasNameAndId","EMPTY_ARRAY","SuggestionListItem","suggestion","search","onSelect","entityForSuggestions","composite","baseCssClass","config","getSpecificTemplate","name","link","useDebouncedInput","input","setInput","debounced","setter","setDebounced","useSearchSuggestions","query","order","context","per_page","queryArgs","records","searchResults","hasResolved","searchHasResolved","type","slug","suggestions","setSuggestions","newSuggestions","length","recordNamePath","SuggestionList","orientation","setSearch","debouncedSearch","labels","showSearchControl","setShowSearchControl","search_items","map","not_found","AddCustomTemplateModal","onClose","isCreatingTemplate","showSearchEntities","setShowSearchEntities","hasGeneralTemplate","singular_name","title","description","templatePrefix","template","all_items"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,OAAnB,EAA4BC,SAA5B,QAA6C,oBAA7C;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SACCC,MADD,EAECC,IAFD,EAGCC,QAHD,EAICC,KAJD,EAKCC,aALD,EAMCC,aAND,EAOCC,kBAAkB,IAAIC,IAPvB,EAQCC,mBAAmB,IAAIC,SARxB,EASCC,2BAA2B,IAAIC,iBAThC,EAUCC,uBAAuB,IAAIC,aAV5B,QAWO,uBAXP;AAYA,SAASC,WAAT,QAA4B,oBAA5B;AACA,SAASC,gBAAT,QAAiC,sBAAjC;AACA,SAASC,cAAT,QAA+B,0BAA/B;AAEA;AACA;AACA;;AACA,OAAOC,4BAAP,MAAyC,mCAAzC;AACA,SAASC,kBAAT,QAAmC,SAAnC;AAEA,MAAMC,WAAW,GAAG,EAApB;;AAEA,SAASC,kBAAT,OAMI;AAAA,MANyB;AAC5BC,IAAAA,UAD4B;AAE5BC,IAAAA,MAF4B;AAG5BC,IAAAA,QAH4B;AAI5BC,IAAAA,oBAJ4B;AAK5BC,IAAAA;AAL4B,GAMzB;AACH,QAAMC,YAAY,GACjB,8DADD;AAEA,SACC,cAAC,aAAD;AACC,IAAA,IAAI,EAAC,QADN;AAEC,IAAA,EAAE,EAAG1B;AAFN,KAGMyB,SAHN;AAIC,IAAA,SAAS,EAAGC,YAJb;AAKC,IAAA,OAAO,EAAG,MACTH,QAAQ,CACPC,oBAAoB,CAACG,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MAAAA,qBAAqB,CAAE,IAAF,CAArB;AACA;AALF,KAOC,cAAC,IAAD;AAAM,IAAA,EAAE,EAAC,MAAT;AAAgB,IAAA,MAAM,EAAG;AAAzB,KACG5C,oBAAoB,CAACkC,MAArB,CAA4BY,aAD/B,CAPD,EAUC,cAAC,IAAD;AAAM,IAAA,EAAE,EAAC;AAAT,KAEE;AACAxE,EAAAA,EAAE,CAAE,qBAAF,CAHJ,CAVD,CAjCD,CAND,CAZF,EAuEGqE,kBAAkB,IACnB,8BACC,yBACGrE,EAAE,CACH,+DADG,CADL,CADD,EAMC,cAAC,cAAD;AACC,IAAA,oBAAoB,EAAG0B,oBADxB;AAEC,IAAA,QAAQ,EAAGD;AAFZ,IAND,CAxEF,CADD;AAuFA;;AAED,eAAeyC,sBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useMemo, useEffect } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tFlex,\n\tFlexItem,\n\tModal,\n\tSearchControl,\n\tTextHighlight,\n\t__experimentalText as Text,\n\t__unstableComposite as Composite,\n\t__unstableUseCompositeState as useCompositeState,\n\t__unstableCompositeItem as CompositeItem,\n} from '@wordpress/components';\nimport { useDebounce } from '@wordpress/compose';\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport TemplateActionsLoadingScreen from './template-actions-loading-screen';\nimport { mapToIHasNameAndId } from './utils';\n\nconst EMPTY_ARRAY = [];\n\nfunction SuggestionListItem( {\n\tsuggestion,\n\tsearch,\n\tonSelect,\n\tentityForSuggestions,\n\tcomposite,\n} ) {\n\tconst baseCssClass =\n\t\t'edit-site-custom-template-modal__suggestions_list__list-item';\n\treturn (\n\t\t<CompositeItem\n\t\t\trole=\"option\"\n\t\t\tas={ Button }\n\t\t\t{ ...composite }\n\t\t\tclassName={ baseCssClass }\n\t\t\tonClick={ () =>\n\t\t\t\tonSelect(\n\t\t\t\t\tentityForSuggestions.config.getSpecificTemplate(\n\t\t\t\t\t\tsuggestion\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t}\n\t\t>\n\t\t\t<span className={ `${ baseCssClass }__title` }>\n\t\t\t\t<TextHighlight\n\t\t\t\t\ttext={ decodeEntities( suggestion.name ) }\n\t\t\t\t\thighlight={ search }\n\t\t\t\t/>\n\t\t\t</span>\n\t\t\t{ suggestion.link && (\n\t\t\t\t<span className={ `${ baseCssClass }__info` }>\n\t\t\t\t\t{ suggestion.link }\n\t\t\t\t</span>\n\t\t\t) }\n\t\t</CompositeItem>\n\t);\n}\n\nfunction useDebouncedInput() {\n\tconst [ input, setInput ] = useState( '' );\n\tconst [ debounced, setter ] = useState( '' );\n\tconst setDebounced = useDebounce( setter, 250 );\n\tuseEffect( () => {\n\t\tif ( debounced !== input ) {\n\t\t\tsetDebounced( input );\n\t\t}\n\t}, [ debounced, input ] );\n\treturn [ input, setInput, debounced ];\n}\n\nfunction useSearchSuggestions( entityForSuggestions, search ) {\n\tconst { config } = entityForSuggestions;\n\tconst query = useMemo(\n\t\t() => ( {\n\t\t\torder: 'asc',\n\t\t\tcontext: 'view',\n\t\t\tsearch,\n\t\t\tper_page: search ? 20 : 10,\n\t\t\t...config.queryArgs( search ),\n\t\t} ),\n\t\t[ search, config ]\n\t);\n\tconst { records: searchResults, hasResolved: searchHasResolved } =\n\t\tuseEntityRecords(\n\t\t\tentityForSuggestions.type,\n\t\t\tentityForSuggestions.slug,\n\t\t\tquery\n\t\t);\n\tconst [ suggestions, setSuggestions ] = useState( EMPTY_ARRAY );\n\tuseEffect( () => {\n\t\tif ( ! searchHasResolved ) return;\n\t\tlet newSuggestions = EMPTY_ARRAY;\n\t\tif ( searchResults?.length ) {\n\t\t\tnewSuggestions = searchResults;\n\t\t\tif ( config.recordNamePath ) {\n\t\t\t\tnewSuggestions = mapToIHasNameAndId(\n\t\t\t\t\tnewSuggestions,\n\t\t\t\t\tconfig.recordNamePath\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\t// Update suggestions only when the query has resolved, so as to keep\n\t\t// the previous results in the UI.\n\t\tsetSuggestions( newSuggestions );\n\t}, [ searchResults, searchHasResolved ] );\n\treturn suggestions;\n}\n\nfunction SuggestionList( { entityForSuggestions, onSelect } ) {\n\tconst composite = useCompositeState( { orientation: 'vertical' } );\n\tconst [ search, setSearch, debouncedSearch ] = useDebouncedInput();\n\tconst suggestions = useSearchSuggestions(\n\t\tentityForSuggestions,\n\t\tdebouncedSearch\n\t);\n\tconst { labels } = entityForSuggestions;\n\tconst [ showSearchControl, setShowSearchControl ] = useState( false );\n\tif ( ! showSearchControl && suggestions?.length > 9 ) {\n\t\tsetShowSearchControl( true );\n\t}\n\treturn (\n\t\t<>\n\t\t\t{ showSearchControl && (\n\t\t\t\t<SearchControl\n\t\t\t\t\tonChange={ setSearch }\n\t\t\t\t\tvalue={ search }\n\t\t\t\t\tlabel={ labels.search_items }\n\t\t\t\t\tplaceholder={ labels.search_items }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ !! suggestions?.length && (\n\t\t\t\t<Composite\n\t\t\t\t\t{ ...composite }\n\t\t\t\t\trole=\"listbox\"\n\t\t\t\t\tclassName=\"edit-site-custom-template-modal__suggestions_list\"\n\t\t\t\t\taria-label={ __( 'Suggestions list' ) }\n\t\t\t\t>\n\t\t\t\t\t{ suggestions.map( ( suggestion ) => (\n\t\t\t\t\t\t<SuggestionListItem\n\t\t\t\t\t\t\tkey={ suggestion.slug }\n\t\t\t\t\t\t\tsuggestion={ suggestion }\n\t\t\t\t\t\t\tsearch={ debouncedSearch }\n\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t\tentityForSuggestions={ entityForSuggestions }\n\t\t\t\t\t\t\tcomposite={ composite }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t</Composite>\n\t\t\t) }\n\t\t\t{ debouncedSearch && ! suggestions?.length && (\n\t\t\t\t<p className=\"edit-site-custom-template-modal__no-results\">\n\t\t\t\t\t{ labels.not_found }\n\t\t\t\t</p>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction AddCustomTemplateModal( {\n\tonClose,\n\tonSelect,\n\tentityForSuggestions,\n\tisCreatingTemplate,\n} ) {\n\tconst [ showSearchEntities, setShowSearchEntities ] = useState(\n\t\tentityForSuggestions.hasGeneralTemplate\n\t);\n\tconst baseCssClass = 'edit-site-custom-template-modal';\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ sprintf(\n\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t__( 'Add template: %s' ),\n\t\t\t\tentityForSuggestions.labels.singular_name\n\t\t\t) }\n\t\t\tclassName={ baseCssClass }\n\t\t\tcloseLabel={ __( 'Close' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t>\n\t\t\t{ isCreatingTemplate && <TemplateActionsLoadingScreen /> }\n\t\t\t{ ! showSearchEntities && (\n\t\t\t\t<>\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Select whether to create a single template for all items or a specific one.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t\t<Flex\n\t\t\t\t\t\tclassName={ `${ baseCssClass }__contents` }\n\t\t\t\t\t\tgap=\"4\"\n\t\t\t\t\t\talign=\"initial\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\ttemplatePrefix,\n\t\t\t\t\t\t\t\t} = entityForSuggestions.template;\n\t\t\t\t\t\t\t\tonSelect( {\n\t\t\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\ttemplatePrefix,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Text as=\"span\" weight={ 600 }>\n\t\t\t\t\t\t\t\t{ entityForSuggestions.labels.all_items }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t<Text as=\"span\">\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t// translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one.\n\t\t\t\t\t\t\t\t\t__( 'For all items' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetShowSearchEntities( true );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Text as=\"span\" weight={ 600 }>\n\t\t\t\t\t\t\t\t{ entityForSuggestions.labels.singular_name }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t<Text as=\"span\">\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t// translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one.\n\t\t\t\t\t\t\t\t\t__( 'For a specific item' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t</Flex>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ showSearchEntities && (\n\t\t\t\t<>\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'This template will be used only for the specific item chosen.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t\t<SuggestionList\n\t\t\t\t\t\tentityForSuggestions={ entityForSuggestions }\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</Modal>\n\t);\n}\n\nexport default AddCustomTemplateModal;\n"]}
|
|
@@ -4,21 +4,17 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
4
4
|
/**
|
|
5
5
|
* WordPress dependencies
|
|
6
6
|
*/
|
|
7
|
-
import { useState,
|
|
7
|
+
import { useState, useRef, useCallback } from '@wordpress/element';
|
|
8
8
|
import { ResizableBox } from '@wordpress/components';
|
|
9
9
|
import { __experimentalUseResizeCanvas as useResizeCanvas, __unstableEditorStyles as EditorStyles, __unstableIframe as Iframe, __unstableUseMouseMoveTypingReset as useMouseMoveTypingReset, store as blockEditorStore } from '@wordpress/block-editor';
|
|
10
10
|
import { useSelect } from '@wordpress/data';
|
|
11
|
-
import { useMergeRefs } from '@wordpress/compose';
|
|
11
|
+
import { useMergeRefs, useResizeObserver } from '@wordpress/compose';
|
|
12
12
|
/**
|
|
13
13
|
* Internal dependencies
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
import { store as editSiteStore } from '../../store';
|
|
17
|
-
import ResizeHandle from './resize-handle';
|
|
18
|
-
const DEFAULT_STYLES = {
|
|
19
|
-
width: '100%',
|
|
20
|
-
height: '100%'
|
|
21
|
-
}; // Removes the inline styles in the drag handles.
|
|
17
|
+
import ResizeHandle from './resize-handle'; // Removes the inline styles in the drag handles.
|
|
22
18
|
|
|
23
19
|
const HANDLE_STYLES_OVERRIDE = {
|
|
24
20
|
position: undefined,
|
|
@@ -39,6 +35,7 @@ function ResizableEditor(_ref) {
|
|
|
39
35
|
children,
|
|
40
36
|
...props
|
|
41
37
|
} = _ref;
|
|
38
|
+
const [resizeObserver, sizes] = useResizeObserver();
|
|
42
39
|
const {
|
|
43
40
|
deviceType,
|
|
44
41
|
isZoomOutMode
|
|
@@ -47,43 +44,10 @@ function ResizableEditor(_ref) {
|
|
|
47
44
|
isZoomOutMode: select(blockEditorStore).__unstableGetEditorMode() === 'zoom-out'
|
|
48
45
|
}), []);
|
|
49
46
|
const deviceStyles = useResizeCanvas(deviceType);
|
|
50
|
-
const [width, setWidth] = useState(
|
|
51
|
-
const [height, setHeight] = useState(DEFAULT_STYLES.height);
|
|
47
|
+
const [width, setWidth] = useState('100%');
|
|
52
48
|
const iframeRef = useRef();
|
|
53
49
|
const mouseMoveTypingResetRef = useMouseMoveTypingReset();
|
|
54
50
|
const ref = useMergeRefs([iframeRef, mouseMoveTypingResetRef]);
|
|
55
|
-
useEffect(function autoResizeIframeHeight() {
|
|
56
|
-
if (!iframeRef.current || !enableResizing) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const iframe = iframeRef.current;
|
|
61
|
-
|
|
62
|
-
function setFrameHeight() {
|
|
63
|
-
setHeight(iframe.contentDocument.body.scrollHeight);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
let resizeObserver;
|
|
67
|
-
|
|
68
|
-
function registerObserver() {
|
|
69
|
-
var _resizeObserver;
|
|
70
|
-
|
|
71
|
-
(_resizeObserver = resizeObserver) === null || _resizeObserver === void 0 ? void 0 : _resizeObserver.disconnect();
|
|
72
|
-
resizeObserver = new iframe.contentWindow.ResizeObserver(setFrameHeight); // Observe the body, since the `html` element seems to always
|
|
73
|
-
// have a height of `100%`.
|
|
74
|
-
|
|
75
|
-
resizeObserver.observe(iframe.contentDocument.body);
|
|
76
|
-
setFrameHeight();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
iframe.addEventListener('load', registerObserver);
|
|
80
|
-
return () => {
|
|
81
|
-
var _resizeObserver2;
|
|
82
|
-
|
|
83
|
-
(_resizeObserver2 = resizeObserver) === null || _resizeObserver2 === void 0 ? void 0 : _resizeObserver2.disconnect();
|
|
84
|
-
iframe.removeEventListener('load', registerObserver);
|
|
85
|
-
};
|
|
86
|
-
}, [enableResizing, iframeRef.current]);
|
|
87
51
|
const resizeWidthBy = useCallback(deltaPixels => {
|
|
88
52
|
if (iframeRef.current) {
|
|
89
53
|
setWidth(iframeRef.current.offsetWidth + deltaPixels);
|
|
@@ -91,8 +55,8 @@ function ResizableEditor(_ref) {
|
|
|
91
55
|
}, []);
|
|
92
56
|
return createElement(ResizableBox, {
|
|
93
57
|
size: {
|
|
94
|
-
width,
|
|
95
|
-
height
|
|
58
|
+
width: enableResizing ? width : '100%',
|
|
59
|
+
height: enableResizing && sizes.height ? sizes.height : '100%'
|
|
96
60
|
},
|
|
97
61
|
onResizeStop: (event, direction, element) => {
|
|
98
62
|
setWidth(element.style.width);
|
|
@@ -126,22 +90,20 @@ function ResizableEditor(_ref) {
|
|
|
126
90
|
}
|
|
127
91
|
}, createElement(Iframe, _extends({
|
|
128
92
|
isZoomedOut: isZoomOutMode,
|
|
129
|
-
style: enableResizing ? {
|
|
130
|
-
height
|
|
131
|
-
} : deviceStyles,
|
|
93
|
+
style: enableResizing ? {} : deviceStyles,
|
|
132
94
|
head: createElement(Fragment, null, createElement(EditorStyles, {
|
|
133
95
|
styles: settings.styles
|
|
134
96
|
}), createElement("style", null, // Forming a "block formatting context" to prevent margin collapsing.
|
|
135
97
|
// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context
|
|
136
|
-
`.is-root-container { display: flow-root; }
|
|
137
|
-
|
|
98
|
+
`.is-root-container { display: flow-root; }
|
|
99
|
+
body { position: relative; }`), enableResizing && createElement("style", null, // Some themes will have `min-height: 100vh` for the root container,
|
|
138
100
|
// which isn't a requirement in auto resize mode.
|
|
139
101
|
`.is-root-container { min-height: 0 !important; }`)),
|
|
140
102
|
assets: settings.__unstableResolvedAssets,
|
|
141
103
|
ref: ref,
|
|
142
104
|
name: "editor-canvas",
|
|
143
105
|
className: "edit-site-visual-editor__editor-canvas"
|
|
144
|
-
}, props), settings.svgFilters, children));
|
|
106
|
+
}, props), settings.svgFilters, resizeObserver, children));
|
|
145
107
|
}
|
|
146
108
|
|
|
147
109
|
export default ResizableEditor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/resizable-editor.js"],"names":["useState","useEffect","useRef","useCallback","ResizableBox","__experimentalUseResizeCanvas","useResizeCanvas","__unstableEditorStyles","EditorStyles","__unstableIframe","Iframe","__unstableUseMouseMoveTypingReset","useMouseMoveTypingReset","store","blockEditorStore","useSelect","useMergeRefs","editSiteStore","ResizeHandle","DEFAULT_STYLES","width","height","HANDLE_STYLES_OVERRIDE","position","undefined","userSelect","cursor","top","right","bottom","left","ResizableEditor","enableResizing","settings","children","props","deviceType","isZoomOutMode","select","__experimentalGetPreviewDeviceType","__unstableGetEditorMode","deviceStyles","setWidth","setHeight","iframeRef","mouseMoveTypingResetRef","ref","autoResizeIframeHeight","current","iframe","setFrameHeight","contentDocument","body","scrollHeight","resizeObserver","registerObserver","disconnect","contentWindow","ResizeObserver","observe","addEventListener","removeEventListener","resizeWidthBy","deltaPixels","offsetWidth","event","direction","element","style","styles","__unstableResolvedAssets","svgFilters"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,SAAnB,EAA8BC,MAA9B,EAAsCC,WAAtC,QAAyD,oBAAzD;AACA,SAASC,YAAT,QAA6B,uBAA7B;AACA,SACCC,6BAA6B,IAAIC,eADlC,EAECC,sBAAsB,IAAIC,YAF3B,EAGCC,gBAAgB,IAAIC,MAHrB,EAICC,iCAAiC,IAAIC,uBAJtC,EAKCC,KAAK,IAAIC,gBALV,QAMO,yBANP;AAOA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,YAAT,QAA6B,oBAA7B;AAEA;AACA;AACA;;AACA,SAASH,KAAK,IAAII,aAAlB,QAAuC,aAAvC;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AAEA,MAAMC,cAAc,GAAG;AACtBC,EAAAA,KAAK,EAAE,MADe;AAEtBC,EAAAA,MAAM,EAAE;AAFc,CAAvB,C,CAKA;;AACA,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,EAkCGrC,QAlCH,CAxCD,CADD;AA+EA;;AAED,eAAeH,eAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useRef, useCallback } from '@wordpress/element';\nimport { ResizableBox } from '@wordpress/components';\nimport {\n\t__experimentalUseResizeCanvas as useResizeCanvas,\n\t__unstableEditorStyles as EditorStyles,\n\t__unstableIframe as Iframe,\n\t__unstableUseMouseMoveTypingReset as useMouseMoveTypingReset,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport ResizeHandle from './resize-handle';\n\nconst DEFAULT_STYLES = {\n\twidth: '100%',\n\theight: '100%',\n};\n\n// Removes the inline styles in the drag handles.\nconst HANDLE_STYLES_OVERRIDE = {\n\tposition: undefined,\n\tuserSelect: undefined,\n\tcursor: undefined,\n\twidth: undefined,\n\theight: undefined,\n\ttop: undefined,\n\tright: undefined,\n\tbottom: undefined,\n\tleft: undefined,\n};\n\nfunction ResizableEditor( { enableResizing, settings, children, ...props } ) {\n\tconst { deviceType, isZoomOutMode } = useSelect(\n\t\t( select ) => ( {\n\t\t\tdeviceType:\n\t\t\t\tselect( editSiteStore ).__experimentalGetPreviewDeviceType(),\n\t\t\tisZoomOutMode:\n\t\t\t\tselect( blockEditorStore ).__unstableGetEditorMode() ===\n\t\t\t\t'zoom-out',\n\t\t} ),\n\t\t[]\n\t);\n\tconst deviceStyles = useResizeCanvas( deviceType );\n\tconst [ width, setWidth ] = useState( DEFAULT_STYLES.width );\n\tconst [ height, setHeight ] = useState( DEFAULT_STYLES.height );\n\tconst iframeRef = useRef();\n\tconst mouseMoveTypingResetRef = useMouseMoveTypingReset();\n\tconst ref = useMergeRefs( [ iframeRef, mouseMoveTypingResetRef ] );\n\n\tuseEffect(\n\t\tfunction autoResizeIframeHeight() {\n\t\t\tif ( ! iframeRef.current || ! enableResizing ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst iframe = iframeRef.current;\n\n\t\t\tfunction setFrameHeight() {\n\t\t\t\tsetHeight( iframe.contentDocument.body.scrollHeight );\n\t\t\t}\n\n\t\t\tlet resizeObserver;\n\n\t\t\tfunction registerObserver() {\n\t\t\t\tresizeObserver?.disconnect();\n\n\t\t\t\tresizeObserver = new iframe.contentWindow.ResizeObserver(\n\t\t\t\t\tsetFrameHeight\n\t\t\t\t);\n\n\t\t\t\t// Observe the body, since the `html` element seems to always\n\t\t\t\t// have a height of `100%`.\n\t\t\t\tresizeObserver.observe( iframe.contentDocument.body );\n\t\t\t\tsetFrameHeight();\n\t\t\t}\n\n\t\t\tiframe.addEventListener( 'load', registerObserver );\n\n\t\t\treturn () => {\n\t\t\t\tresizeObserver?.disconnect();\n\t\t\t\tiframe.removeEventListener( 'load', registerObserver );\n\t\t\t};\n\t\t},\n\t\t[ enableResizing, iframeRef.current ]\n\t);\n\n\tconst resizeWidthBy = useCallback( ( deltaPixels ) => {\n\t\tif ( iframeRef.current ) {\n\t\t\tsetWidth( iframeRef.current.offsetWidth + deltaPixels );\n\t\t}\n\t}, [] );\n\n\treturn (\n\t\t<ResizableBox\n\t\t\tsize={ {\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t} }\n\t\t\tonResizeStop={ ( event, direction, element ) => {\n\t\t\t\tsetWidth( element.style.width );\n\t\t\t} }\n\t\t\tminWidth={ 300 }\n\t\t\tmaxWidth=\"100%\"\n\t\t\tmaxHeight=\"100%\"\n\t\t\tenable={ {\n\t\t\t\tright: enableResizing,\n\t\t\t\tleft: enableResizing,\n\t\t\t} }\n\t\t\tshowHandle={ enableResizing }\n\t\t\t// The editor is centered horizontally, resizing it only\n\t\t\t// moves half the distance. Hence double the ratio to correctly\n\t\t\t// align the cursor to the resizer handle.\n\t\t\tresizeRatio={ 2 }\n\t\t\thandleComponent={ {\n\t\t\t\tleft: (\n\t\t\t\t\t<ResizeHandle\n\t\t\t\t\t\tdirection=\"left\"\n\t\t\t\t\t\tresizeWidthBy={ resizeWidthBy }\n\t\t\t\t\t/>\n\t\t\t\t),\n\t\t\t\tright: (\n\t\t\t\t\t<ResizeHandle\n\t\t\t\t\t\tdirection=\"right\"\n\t\t\t\t\t\tresizeWidthBy={ resizeWidthBy }\n\t\t\t\t\t/>\n\t\t\t\t),\n\t\t\t} }\n\t\t\thandleClasses={ undefined }\n\t\t\thandleStyles={ {\n\t\t\t\tleft: HANDLE_STYLES_OVERRIDE,\n\t\t\t\tright: HANDLE_STYLES_OVERRIDE,\n\t\t\t} }\n\t\t>\n\t\t\t<Iframe\n\t\t\t\tisZoomedOut={ isZoomOutMode }\n\t\t\t\tstyle={ enableResizing ? { height } : deviceStyles }\n\t\t\t\thead={\n\t\t\t\t\t<>\n\t\t\t\t\t\t<EditorStyles styles={ settings.styles } />\n\t\t\t\t\t\t<style>{\n\t\t\t\t\t\t\t// Forming a \"block formatting context\" to prevent margin collapsing.\n\t\t\t\t\t\t\t// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context\n\t\t\t\t\t\t\t`.is-root-container { display: flow-root; }`\n\t\t\t\t\t\t}</style>\n\t\t\t\t\t\t{ enableResizing && (\n\t\t\t\t\t\t\t<style>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t// Force the <html> and <body>'s heights to fit the content.\n\t\t\t\t\t\t\t\t\t`html, body { height: -moz-fit-content !important; height: fit-content !important; min-height: 0 !important; }`\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t// Some themes will have `min-height: 100vh` for the root container,\n\t\t\t\t\t\t\t\t\t// which isn't a requirement in auto resize mode.\n\t\t\t\t\t\t\t\t\t`.is-root-container { min-height: 0 !important; }`\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</style>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t}\n\t\t\t\tassets={ settings.__unstableResolvedAssets }\n\t\t\t\tref={ ref }\n\t\t\t\tname=\"editor-canvas\"\n\t\t\t\tclassName=\"edit-site-visual-editor__editor-canvas\"\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t{ /* Filters need to be rendered before children to avoid Safari rendering issues. */ }\n\t\t\t\t{ settings.svgFilters }\n\t\t\t\t{ children }\n\t\t\t</Iframe>\n\t\t</ResizableBox>\n\t);\n}\n\nexport default ResizableEditor;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/resizable-editor.js"],"names":["useState","useRef","useCallback","ResizableBox","__experimentalUseResizeCanvas","useResizeCanvas","__unstableEditorStyles","EditorStyles","__unstableIframe","Iframe","__unstableUseMouseMoveTypingReset","useMouseMoveTypingReset","store","blockEditorStore","useSelect","useMergeRefs","useResizeObserver","editSiteStore","ResizeHandle","HANDLE_STYLES_OVERRIDE","position","undefined","userSelect","cursor","width","height","top","right","bottom","left","ResizableEditor","enableResizing","settings","children","props","resizeObserver","sizes","deviceType","isZoomOutMode","select","__experimentalGetPreviewDeviceType","__unstableGetEditorMode","deviceStyles","setWidth","iframeRef","mouseMoveTypingResetRef","ref","resizeWidthBy","deltaPixels","current","offsetWidth","event","direction","element","style","styles","__unstableResolvedAssets","svgFilters"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,MAAnB,EAA2BC,WAA3B,QAA8C,oBAA9C;AACA,SAASC,YAAT,QAA6B,uBAA7B;AACA,SACCC,6BAA6B,IAAIC,eADlC,EAECC,sBAAsB,IAAIC,YAF3B,EAGCC,gBAAgB,IAAIC,MAHrB,EAICC,iCAAiC,IAAIC,uBAJtC,EAKCC,KAAK,IAAIC,gBALV,QAMO,yBANP;AAOA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,YAAT,EAAuBC,iBAAvB,QAAgD,oBAAhD;AAEA;AACA;AACA;;AACA,SAASJ,KAAK,IAAIK,aAAlB,QAAuC,aAAv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B,aADf;AAEC,IAAA,KAAK,EAAGP,cAAc,GAAG,EAAH,GAAQW,YAF/B;AAGC,IAAA,IAAI,EACH,8BACC,cAAC,YAAD;AAAc,MAAA,MAAM,EAAGV,QAAQ,CAACuB;AAAhC,MADD,EAEC,6BACC;AACA;AACC;AACR,oCAJM,CAFD,EAQGxB,cAAc,IACf,6BAEE;AACA;AACC,sDAJH,CATF,CAJF;AAuBC,IAAA,MAAM,EAAGC,QAAQ,CAACwB,wBAvBnB;AAwBC,IAAA,GAAG,EAAGV,GAxBP;AAyBC,IAAA,IAAI,EAAC,eAzBN;AA0BC,IAAA,SAAS,EAAC;AA1BX,KA2BMZ,KA3BN,GA8BGF,QAAQ,CAACyB,UA9BZ,EA+BGtB,cA/BH,EAgCGF,QAhCH,CAxCD,CADD;AA6EA;;AAED,eAAeH,eAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useRef, useCallback } from '@wordpress/element';\nimport { ResizableBox } from '@wordpress/components';\nimport {\n\t__experimentalUseResizeCanvas as useResizeCanvas,\n\t__unstableEditorStyles as EditorStyles,\n\t__unstableIframe as Iframe,\n\t__unstableUseMouseMoveTypingReset as useMouseMoveTypingReset,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useMergeRefs, useResizeObserver } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport ResizeHandle from './resize-handle';\n\n// Removes the inline styles in the drag handles.\nconst HANDLE_STYLES_OVERRIDE = {\n\tposition: undefined,\n\tuserSelect: undefined,\n\tcursor: undefined,\n\twidth: undefined,\n\theight: undefined,\n\ttop: undefined,\n\tright: undefined,\n\tbottom: undefined,\n\tleft: undefined,\n};\n\nfunction ResizableEditor( { enableResizing, settings, children, ...props } ) {\n\tconst [ resizeObserver, sizes ] = useResizeObserver();\n\tconst { deviceType, isZoomOutMode } = useSelect(\n\t\t( select ) => ( {\n\t\t\tdeviceType:\n\t\t\t\tselect( editSiteStore ).__experimentalGetPreviewDeviceType(),\n\t\t\tisZoomOutMode:\n\t\t\t\tselect( blockEditorStore ).__unstableGetEditorMode() ===\n\t\t\t\t'zoom-out',\n\t\t} ),\n\t\t[]\n\t);\n\tconst deviceStyles = useResizeCanvas( deviceType );\n\tconst [ width, setWidth ] = useState( '100%' );\n\tconst iframeRef = useRef();\n\tconst mouseMoveTypingResetRef = useMouseMoveTypingReset();\n\tconst ref = useMergeRefs( [ iframeRef, mouseMoveTypingResetRef ] );\n\n\tconst resizeWidthBy = useCallback( ( deltaPixels ) => {\n\t\tif ( iframeRef.current ) {\n\t\t\tsetWidth( iframeRef.current.offsetWidth + deltaPixels );\n\t\t}\n\t}, [] );\n\treturn (\n\t\t<ResizableBox\n\t\t\tsize={ {\n\t\t\t\twidth: enableResizing ? width : '100%',\n\t\t\t\theight: enableResizing && sizes.height ? sizes.height : '100%',\n\t\t\t} }\n\t\t\tonResizeStop={ ( event, direction, element ) => {\n\t\t\t\tsetWidth( element.style.width );\n\t\t\t} }\n\t\t\tminWidth={ 300 }\n\t\t\tmaxWidth=\"100%\"\n\t\t\tmaxHeight=\"100%\"\n\t\t\tenable={ {\n\t\t\t\tright: enableResizing,\n\t\t\t\tleft: enableResizing,\n\t\t\t} }\n\t\t\tshowHandle={ enableResizing }\n\t\t\t// The editor is centered horizontally, resizing it only\n\t\t\t// moves half the distance. Hence double the ratio to correctly\n\t\t\t// align the cursor to the resizer handle.\n\t\t\tresizeRatio={ 2 }\n\t\t\thandleComponent={ {\n\t\t\t\tleft: (\n\t\t\t\t\t<ResizeHandle\n\t\t\t\t\t\tdirection=\"left\"\n\t\t\t\t\t\tresizeWidthBy={ resizeWidthBy }\n\t\t\t\t\t/>\n\t\t\t\t),\n\t\t\t\tright: (\n\t\t\t\t\t<ResizeHandle\n\t\t\t\t\t\tdirection=\"right\"\n\t\t\t\t\t\tresizeWidthBy={ resizeWidthBy }\n\t\t\t\t\t/>\n\t\t\t\t),\n\t\t\t} }\n\t\t\thandleClasses={ undefined }\n\t\t\thandleStyles={ {\n\t\t\t\tleft: HANDLE_STYLES_OVERRIDE,\n\t\t\t\tright: HANDLE_STYLES_OVERRIDE,\n\t\t\t} }\n\t\t>\n\t\t\t<Iframe\n\t\t\t\tisZoomedOut={ isZoomOutMode }\n\t\t\t\tstyle={ enableResizing ? {} : deviceStyles }\n\t\t\t\thead={\n\t\t\t\t\t<>\n\t\t\t\t\t\t<EditorStyles styles={ settings.styles } />\n\t\t\t\t\t\t<style>{\n\t\t\t\t\t\t\t// Forming a \"block formatting context\" to prevent margin collapsing.\n\t\t\t\t\t\t\t// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context\n\t\t\t\t\t\t\t`.is-root-container { display: flow-root; }\n\t\t\t\t\t\t\tbody { position: relative; }`\n\t\t\t\t\t\t}</style>\n\t\t\t\t\t\t{ enableResizing && (\n\t\t\t\t\t\t\t<style>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t// Some themes will have `min-height: 100vh` for the root container,\n\t\t\t\t\t\t\t\t\t// which isn't a requirement in auto resize mode.\n\t\t\t\t\t\t\t\t\t`.is-root-container { min-height: 0 !important; }`\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</style>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t}\n\t\t\t\tassets={ settings.__unstableResolvedAssets }\n\t\t\t\tref={ ref }\n\t\t\t\tname=\"editor-canvas\"\n\t\t\t\tclassName=\"edit-site-visual-editor__editor-canvas\"\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t{ /* Filters need to be rendered before children to avoid Safari rendering issues. */ }\n\t\t\t\t{ settings.svgFilters }\n\t\t\t\t{ resizeObserver }\n\t\t\t\t{ children }\n\t\t\t</Iframe>\n\t\t</ResizableBox>\n\t);\n}\n\nexport default ResizableEditor;\n"]}
|
|
@@ -24,7 +24,8 @@ export function useHasDimensionsPanel(name) {
|
|
|
24
24
|
const hasPadding = useHasPadding(name);
|
|
25
25
|
const hasMargin = useHasMargin(name);
|
|
26
26
|
const hasGap = useHasGap(name);
|
|
27
|
-
|
|
27
|
+
const hasMinHeight = useHasMinHeight(name);
|
|
28
|
+
return hasContentSize || hasWideSize || hasPadding || hasMargin || hasGap || hasMinHeight;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
function useHasContentSize(name) {
|
|
@@ -57,6 +58,12 @@ function useHasGap(name) {
|
|
|
57
58
|
return settings && supports.includes('blockGap');
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
function useHasMinHeight(name) {
|
|
62
|
+
const supports = getSupportedGlobalStylesPanels(name);
|
|
63
|
+
const [settings] = useSetting('dimensions.minHeight', name);
|
|
64
|
+
return settings && supports.includes('minHeight');
|
|
65
|
+
}
|
|
66
|
+
|
|
60
67
|
function useHasSpacingPresets() {
|
|
61
68
|
const [settings] = useSetting('spacing.spacingSizes');
|
|
62
69
|
return settings && settings.length > 0;
|
|
@@ -247,6 +254,22 @@ function useBlockGapProps(name) {
|
|
|
247
254
|
resetGapValue,
|
|
248
255
|
hasGapValue
|
|
249
256
|
};
|
|
257
|
+
} // Props for managing `dimensions.minHeight`.
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
function useMinHeightProps(name) {
|
|
261
|
+
const [minHeightValue, setMinHeightValue] = useStyle('dimensions.minHeight', name);
|
|
262
|
+
|
|
263
|
+
const resetMinHeightValue = () => setMinHeightValue(undefined);
|
|
264
|
+
|
|
265
|
+
const hasMinHeightValue = () => !!minHeightValue;
|
|
266
|
+
|
|
267
|
+
return {
|
|
268
|
+
minHeightValue,
|
|
269
|
+
setMinHeightValue,
|
|
270
|
+
resetMinHeightValue,
|
|
271
|
+
hasMinHeightValue
|
|
272
|
+
};
|
|
250
273
|
}
|
|
251
274
|
|
|
252
275
|
export default function DimensionsPanel(_ref) {
|
|
@@ -258,6 +281,7 @@ export default function DimensionsPanel(_ref) {
|
|
|
258
281
|
const showPaddingControl = useHasPadding(name);
|
|
259
282
|
const showMarginControl = useHasMargin(name);
|
|
260
283
|
const showGapControl = useHasGap(name);
|
|
284
|
+
const showMinHeightControl = useHasMinHeight(name);
|
|
261
285
|
const showSpacingPresetsControl = useHasSpacingPresets();
|
|
262
286
|
const units = useCustomUnits({
|
|
263
287
|
availableUnits: useSetting('spacing.units', name)[0] || ['%', 'px', 'em', 'rem', 'vw']
|
|
@@ -304,7 +328,14 @@ export default function DimensionsPanel(_ref) {
|
|
|
304
328
|
setGapValues,
|
|
305
329
|
resetGapValue,
|
|
306
330
|
hasGapValue
|
|
307
|
-
} = useBlockGapProps(name);
|
|
331
|
+
} = useBlockGapProps(name); // Props for managing `dimensions.minHeight`.
|
|
332
|
+
|
|
333
|
+
const {
|
|
334
|
+
minHeightValue,
|
|
335
|
+
setMinHeightValue,
|
|
336
|
+
resetMinHeightValue,
|
|
337
|
+
hasMinHeightValue
|
|
338
|
+
} = useMinHeightProps(name);
|
|
308
339
|
|
|
309
340
|
const resetAll = () => {
|
|
310
341
|
resetPaddingValue();
|
|
@@ -440,6 +471,19 @@ export default function DimensionsPanel(_ref) {
|
|
|
440
471
|
values: gapValues,
|
|
441
472
|
allowReset: false,
|
|
442
473
|
splitOnAxis: isAxialGap
|
|
474
|
+
})), showMinHeightControl && createElement(ToolsPanelItem, {
|
|
475
|
+
className: "single-column",
|
|
476
|
+
hasValue: hasMinHeightValue,
|
|
477
|
+
label: __('Min. height'),
|
|
478
|
+
onDeselect: resetMinHeightValue,
|
|
479
|
+
isShownByDefault: true
|
|
480
|
+
}, createElement(UnitControl, {
|
|
481
|
+
label: __('Min. height'),
|
|
482
|
+
value: minHeightValue,
|
|
483
|
+
onChange: setMinHeightValue,
|
|
484
|
+
units: units,
|
|
485
|
+
min: 0,
|
|
486
|
+
size: '__unstable-large'
|
|
443
487
|
})));
|
|
444
488
|
}
|
|
445
489
|
//# sourceMappingURL=dimensions-panel.js.map
|