@wordpress/block-library 7.0.0 → 7.0.2
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/README.md +16 -0
- package/build/button/edit.native.js +2 -2
- package/build/button/edit.native.js.map +1 -1
- package/build/columns/index.js +12 -0
- package/build/columns/index.js.map +1 -1
- package/build/comment-author-avatar/edit.js +17 -4
- package/build/comment-author-avatar/edit.js.map +1 -1
- package/build/comment-template/edit.js +94 -36
- package/build/comment-template/edit.js.map +1 -1
- package/build/comment-template/hooks.js +175 -0
- package/build/comment-template/hooks.js.map +1 -0
- package/build/comment-template/index.js +1 -1
- package/build/comment-template/util.js.map +1 -1
- package/build/comments-pagination-next/index.js +1 -1
- package/build/comments-pagination-numbers/index.js +1 -1
- package/build/comments-query-loop/edit/comments-inspector-controls.js +20 -9
- package/build/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
- package/build/comments-query-loop/edit.js +1 -19
- package/build/comments-query-loop/edit.js.map +1 -1
- package/build/comments-query-loop/index.js +5 -0
- package/build/comments-query-loop/index.js.map +1 -1
- package/build/cover/edit.js +21 -22
- package/build/cover/edit.js.map +1 -1
- package/build/cover/edit.native.js +7 -5
- package/build/cover/edit.native.js.map +1 -1
- package/build/cover/overlay-color-settings.native.js +4 -3
- package/build/cover/overlay-color-settings.native.js.map +1 -1
- package/build/cover/transforms.js +4 -2
- package/build/cover/transforms.js.map +1 -1
- package/build/group/index.js +1 -0
- package/build/group/index.js.map +1 -1
- package/build/heading/edit.js +14 -2
- package/build/heading/edit.js.map +1 -1
- package/build/image/deprecated.js +89 -5
- package/build/image/deprecated.js.map +1 -1
- package/build/image/save.js +0 -7
- package/build/image/save.js.map +1 -1
- package/build/latest-posts/edit.js +1 -0
- package/build/latest-posts/edit.js.map +1 -1
- package/build/navigation/edit/index.js +17 -15
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +44 -27
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/placeholder/index.js +8 -22
- package/build/navigation/edit/placeholder/index.js.map +1 -1
- package/build/navigation/use-navigation-menu.js +6 -6
- package/build/navigation/use-navigation-menu.js.map +1 -1
- package/build/navigation-submenu/edit.js +41 -9
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/page-list/edit.js +11 -17
- package/build/page-list/edit.js.map +1 -1
- package/build/social-links/deprecated.js +1 -62
- package/build/social-links/deprecated.js.map +1 -1
- package/build/template-part/edit/index.js +36 -64
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/edit/placeholder.js +64 -0
- package/build/template-part/edit/placeholder.js.map +1 -0
- package/build/template-part/edit/selection-modal.js +103 -0
- package/build/template-part/edit/selection-modal.js.map +1 -0
- package/build/template-part/edit/title-modal.js +54 -0
- package/build/template-part/edit/title-modal.js.map +1 -0
- package/build/template-part/edit/utils/hooks.js +156 -0
- package/build/template-part/edit/utils/hooks.js.map +1 -0
- package/build/template-part/index.js +3 -1
- package/build/template-part/index.js.map +1 -1
- package/build-module/button/edit.native.js +4 -4
- package/build-module/button/edit.native.js.map +1 -1
- package/build-module/columns/index.js +12 -0
- package/build-module/columns/index.js.map +1 -1
- package/build-module/comment-author-avatar/edit.js +18 -6
- package/build-module/comment-author-avatar/edit.js.map +1 -1
- package/build-module/comment-template/edit.js +95 -37
- package/build-module/comment-template/edit.js.map +1 -1
- package/build-module/comment-template/hooks.js +156 -0
- package/build-module/comment-template/hooks.js.map +1 -0
- package/build-module/comment-template/index.js +1 -1
- package/build-module/comment-template/util.js.map +1 -1
- package/build-module/comments-pagination-next/index.js +1 -1
- package/build-module/comments-pagination-numbers/index.js +1 -1
- package/build-module/comments-query-loop/edit/comments-inspector-controls.js +20 -9
- package/build-module/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
- package/build-module/comments-query-loop/edit.js +2 -19
- package/build-module/comments-query-loop/edit.js.map +1 -1
- package/build-module/comments-query-loop/index.js +5 -0
- package/build-module/comments-query-loop/index.js.map +1 -1
- package/build-module/cover/edit.js +23 -24
- package/build-module/cover/edit.js.map +1 -1
- package/build-module/cover/edit.native.js +10 -8
- package/build-module/cover/edit.native.js.map +1 -1
- package/build-module/cover/overlay-color-settings.native.js +4 -4
- package/build-module/cover/overlay-color-settings.native.js.map +1 -1
- package/build-module/cover/transforms.js +4 -2
- package/build-module/cover/transforms.js.map +1 -1
- package/build-module/group/index.js +1 -0
- package/build-module/group/index.js.map +1 -1
- package/build-module/heading/edit.js +15 -3
- package/build-module/heading/edit.js.map +1 -1
- package/build-module/image/deprecated.js +90 -7
- package/build-module/image/deprecated.js.map +1 -1
- package/build-module/image/save.js +0 -7
- package/build-module/image/save.js.map +1 -1
- package/build-module/latest-posts/edit.js +1 -0
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/navigation/edit/index.js +17 -15
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +45 -27
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/placeholder/index.js +8 -21
- package/build-module/navigation/edit/placeholder/index.js.map +1 -1
- package/build-module/navigation/use-navigation-menu.js +6 -6
- package/build-module/navigation/use-navigation-menu.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +41 -10
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/page-list/edit.js +12 -18
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/social-links/deprecated.js +1 -62
- package/build-module/social-links/deprecated.js.map +1 -1
- package/build-module/template-part/edit/index.js +37 -65
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/edit/placeholder.js +52 -0
- package/build-module/template-part/edit/placeholder.js.map +1 -0
- package/build-module/template-part/edit/selection-modal.js +89 -0
- package/build-module/template-part/edit/selection-modal.js.map +1 -0
- package/build-module/template-part/edit/title-modal.js +46 -0
- package/build-module/template-part/edit/title-modal.js.map +1 -0
- package/build-module/template-part/edit/utils/hooks.js +135 -0
- package/build-module/template-part/edit/utils/hooks.js.map +1 -0
- package/build-module/template-part/index.js +2 -1
- package/build-module/template-part/index.js.map +1 -1
- package/build-style/comment-author-avatar/editor-rtl.css +83 -0
- package/build-style/comment-author-avatar/editor.css +83 -0
- package/build-style/cover/style-rtl.css +4 -0
- package/build-style/cover/style.css +4 -0
- package/build-style/editor-rtl.css +27 -81
- package/build-style/editor.css +27 -81
- package/build-style/image/editor-rtl.css +0 -16
- package/build-style/image/editor.css +0 -16
- package/build-style/image/style-rtl.css +2 -0
- package/build-style/image/style.css +2 -0
- package/build-style/navigation/style-rtl.css +14 -3
- package/build-style/navigation/style.css +14 -3
- package/build-style/page-list/editor-rtl.css +0 -9
- package/build-style/page-list/editor.css +0 -9
- package/build-style/style-rtl.css +20 -3
- package/build-style/style.css +20 -3
- package/build-style/template-part/editor-rtl.css +19 -56
- package/build-style/template-part/editor.css +19 -56
- package/package.json +15 -15
- package/src/archives/index.php +1 -1
- package/src/button/edit.native.js +3 -3
- package/src/columns/block.json +12 -0
- package/src/comment-author-avatar/edit.js +13 -8
- package/src/comment-author-avatar/editor.scss +7 -0
- package/src/comment-template/block.json +7 -1
- package/src/comment-template/edit.js +102 -40
- package/src/comment-template/hooks.js +151 -0
- package/src/comment-template/index.php +8 -0
- package/src/comment-template/util.js +1 -0
- package/src/comments-pagination-next/block.json +8 -1
- package/src/comments-pagination-next/index.php +6 -8
- package/src/comments-pagination-numbers/block.json +7 -1
- package/src/comments-pagination-numbers/index.php +3 -10
- package/src/comments-query-loop/block.json +5 -0
- package/src/comments-query-loop/edit/comments-inspector-controls.js +22 -4
- package/src/comments-query-loop/edit.js +1 -16
- package/src/cover/edit.js +15 -28
- package/src/cover/edit.native.js +15 -7
- package/src/cover/overlay-color-settings.native.js +3 -4
- package/src/cover/style.scss +4 -0
- package/src/cover/transforms.js +2 -0
- package/src/editor.scss +1 -0
- package/src/gallery/index.php +1 -8
- package/src/group/block.json +1 -0
- package/src/heading/edit.js +18 -5
- package/src/home-link/index.php +1 -19
- package/src/image/deprecated.js +105 -1
- package/src/image/editor.scss +0 -18
- package/src/image/save.js +0 -8
- package/src/image/style.scss +3 -0
- package/src/image/test/edit.native.js +0 -10
- package/src/latest-posts/edit.js +1 -0
- package/src/latest-posts/index.php +1 -1
- package/src/navigation/edit/index.js +25 -26
- package/src/navigation/edit/navigation-menu-selector.js +73 -28
- package/src/navigation/edit/placeholder/index.js +8 -32
- package/src/navigation/index.php +4 -4
- package/src/navigation/style.scss +22 -3
- package/src/navigation/use-navigation-menu.js +6 -6
- package/src/navigation-link/index.php +3 -22
- package/src/navigation-submenu/edit.js +50 -12
- package/src/navigation-submenu/index.php +3 -21
- package/src/page-list/edit.js +21 -25
- package/src/page-list/editor.scss +0 -10
- package/src/page-list/index.php +4 -4
- package/src/post-navigation-link/index.php +3 -3
- package/src/search/index.php +6 -3
- package/src/site-logo/index.php +1 -1
- package/src/social-links/deprecated.js +0 -59
- package/src/template-part/edit/index.js +61 -71
- package/src/template-part/edit/placeholder.js +78 -0
- package/src/template-part/edit/selection-modal.js +115 -0
- package/src/template-part/edit/title-modal.js +59 -0
- package/src/template-part/edit/utils/hooks.js +158 -0
- package/src/template-part/editor.scss +16 -74
- package/src/template-part/index.js +4 -1
- package/build/navigation/edit/existing-menus-options.js +0 -62
- package/build/navigation/edit/existing-menus-options.js.map +0 -1
- package/build/template-part/edit/placeholder/index.js +0 -141
- package/build/template-part/edit/placeholder/index.js.map +0 -1
- package/build/template-part/edit/placeholder/patterns-setup.js +0 -100
- package/build/template-part/edit/placeholder/patterns-setup.js.map +0 -1
- package/build/template-part/edit/selection/index.js +0 -45
- package/build/template-part/edit/selection/index.js.map +0 -1
- package/build/template-part/edit/selection/template-part-previews.js +0 -317
- package/build/template-part/edit/selection/template-part-previews.js.map +0 -1
- package/build-module/navigation/edit/existing-menus-options.js +0 -53
- package/build-module/navigation/edit/existing-menus-options.js.map +0 -1
- package/build-module/template-part/edit/placeholder/index.js +0 -124
- package/build-module/template-part/edit/placeholder/index.js.map +0 -1
- package/build-module/template-part/edit/placeholder/patterns-setup.js +0 -91
- package/build-module/template-part/edit/placeholder/patterns-setup.js.map +0 -1
- package/build-module/template-part/edit/selection/index.js +0 -35
- package/build-module/template-part/edit/selection/index.js.map +0 -1
- package/build-module/template-part/edit/selection/template-part-previews.js +0 -298
- package/build-module/template-part/edit/selection/template-part-previews.js.map +0 -1
- package/src/navigation/edit/existing-menus-options.js +0 -70
- package/src/template-part/edit/placeholder/index.js +0 -172
- package/src/template-part/edit/placeholder/patterns-setup.js +0 -124
- package/src/template-part/edit/selection/index.js +0 -37
- package/src/template-part/edit/selection/template-part-previews.js +0 -372
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/template-part/edit/utils/hooks.js"],"names":["useAlternativeTemplateParts","area","excludedId","templateParts","isResolving","select","getEntityRecords","_isResolving","coreStore","query","per_page","isLoading","filteredTemplateParts","filter","templatePart","theme","slug","useAlternativeBlockPatterns","clientId","blockNameWithArea","getBlockRootClientId","__experimentalGetPatternsByBlockTypes","blockEditorStore","rootClientId","useCreateTemplatePartFromBlocks","setAttributes","saveEntityRecord","blocks","title","record","content","undefined","useTemplatePartArea","definedAreas","__experimentalGetDefaultTemplatePartAreas","selectedArea","defaultArea","icon","label","tagName","area_tag"],"mappings":";;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,2BAAT,CAAsCC,IAAtC,EAA4CC,UAA5C,EAAyD;AAC/D,QAAM;AAAEC,IAAAA,aAAF;AAAiBC,IAAAA;AAAjB,MAAiC,qBAAaC,MAAF,IAAc;AAC/D,UAAM;AAAEC,MAAAA,gBAAF;AAAoBF,MAAAA,WAAW,EAAEG;AAAjC,QAAkDF,MAAM,CAC7DG,eAD6D,CAA9D;AAGA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AAtB,uBAAsBA,WAAW,CAAEC,IAAnC,CADA;AAENC,MAAAA,KAAK,EAAE,CAAAH,YAAY,SAAZ,IAAAA,YAAY,WAAZ,YAAAA,YAAY,CAAEG,KAAd,KAAuB,cAAI,eAAJ,CAFxB;AAGNC,MAAAA,OAAO,2BAAEJ,YAAF,aAAEA,YAAF,uBAAEA,YAAY,CAAEK,QAAhB,yEAA4B;AAH7B,KAAP;AAKA,GAjBK,EAkBN,CAAEvC,IAAF,CAlBM,CAAP;AAoBA","sourcesContent":["/**\n * External dependencies\n */\nimport { find, kebabCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useMemo } from '@wordpress/element';\nimport { serialize } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { createTemplatePartId } from './create-template-part-id';\n\n/**\n * Retrieves the available template parts for the given area.\n *\n * @param {string} area Template part area.\n * @param {string} excludedId Template part ID to exclude.\n *\n * @return {{ templateParts: Array, isResolving: boolean }} array of template parts.\n */\nexport function useAlternativeTemplateParts( area, excludedId ) {\n\tconst { templateParts, isResolving } = useSelect( ( select ) => {\n\t\tconst { getEntityRecords, isResolving: _isResolving } = select(\n\t\t\tcoreStore\n\t\t);\n\t\tconst query = { per_page: -1 };\n\t\treturn {\n\t\t\ttemplateParts: getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\tquery\n\t\t\t),\n\t\t\tisLoading: _isResolving( 'getEntityRecords', [\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\tquery,\n\t\t\t] ),\n\t\t};\n\t}, [] );\n\n\tconst filteredTemplateParts = useMemo( () => {\n\t\tif ( ! templateParts ) {\n\t\t\treturn [];\n\t\t}\n\t\treturn (\n\t\t\ttemplateParts.filter(\n\t\t\t\t( templatePart ) =>\n\t\t\t\t\tcreateTemplatePartId(\n\t\t\t\t\t\ttemplatePart.theme,\n\t\t\t\t\t\ttemplatePart.slug\n\t\t\t\t\t) !== excludedId &&\n\t\t\t\t\t( ! area ||\n\t\t\t\t\t\t'uncategorized' === area ||\n\t\t\t\t\t\ttemplatePart.area === area )\n\t\t\t) || []\n\t\t);\n\t}, [ templateParts, area ] );\n\n\treturn {\n\t\ttemplateParts: filteredTemplateParts,\n\t\tisResolving,\n\t};\n}\n\n/**\n * Retrieves the available block patterns for the given area.\n *\n * @param {string} area Template part area.\n * @param {string} clientId Block Client ID. (The container of the block can impact allowed blocks).\n *\n * @return {Array} array of block patterns.\n */\nexport function useAlternativeBlockPatterns( area, clientId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst blockNameWithArea = area\n\t\t\t\t? `core/template-part/${ area }`\n\t\t\t\t: 'core/template-part';\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\t__experimentalGetPatternsByBlockTypes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\treturn __experimentalGetPatternsByBlockTypes(\n\t\t\t\tblockNameWithArea,\n\t\t\t\trootClientId\n\t\t\t);\n\t\t},\n\t\t[ area, clientId ]\n\t);\n}\n\nexport function useCreateTemplatePartFromBlocks( area, setAttributes ) {\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\treturn async ( blocks = [], title = __( 'Untitled Template Part' ) ) => {\n\t\t// If we have `area` set from block attributes, means an exposed\n\t\t// block variation was inserted. So add this prop to the template\n\t\t// part entity on creation. Afterwards remove `area` value from\n\t\t// block attributes.\n\t\tconst record = {\n\t\t\ttitle,\n\t\t\tslug: kebabCase( title ),\n\t\t\tcontent: serialize( blocks ),\n\t\t\t// `area` is filterable on the server and defaults to `UNCATEGORIZED`\n\t\t\t// if provided value is not allowed.\n\t\t\tarea,\n\t\t};\n\t\tconst templatePart = await saveEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\trecord\n\t\t);\n\t\tsetAttributes( {\n\t\t\tslug: templatePart.slug,\n\t\t\ttheme: templatePart.theme,\n\t\t\tarea: undefined,\n\t\t} );\n\t};\n}\n\n/**\n * Retrieves the template part area object.\n *\n * @param {string} area Template part area identifier.\n *\n * @return {{icon: Object, label: string, tagName: string}} Template Part area.\n */\nexport function useTemplatePartArea( area ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\t// FIXME: @wordpress/block-library should not depend on @wordpress/editor.\n\t\t\t// Blocks can be loaded into a *non-post* block editor.\n\t\t\t// eslint-disable-next-line @wordpress/data-no-store-string-literals\n\t\t\tconst definedAreas = select(\n\t\t\t\t'core/editor'\n\t\t\t).__experimentalGetDefaultTemplatePartAreas();\n\n\t\t\tconst selectedArea = find( definedAreas, { area } );\n\t\t\tconst defaultArea = find( definedAreas, { area: 'uncategorized' } );\n\n\t\t\treturn {\n\t\t\t\ticon: selectedArea?.icon || defaultArea?.icon,\n\t\t\t\tlabel: selectedArea?.label || __( 'Template Part' ),\n\t\t\t\ttagName: selectedArea?.area_tag ?? 'div',\n\t\t\t};\n\t\t},\n\t\t[ area ]\n\t);\n}\n"]}
|
|
@@ -17,6 +17,8 @@ var _icons = require("@wordpress/icons");
|
|
|
17
17
|
|
|
18
18
|
var _hooks = require("@wordpress/hooks");
|
|
19
19
|
|
|
20
|
+
var _htmlEntities = require("@wordpress/html-entities");
|
|
21
|
+
|
|
20
22
|
var _edit = _interopRequireDefault(require("./edit"));
|
|
21
23
|
|
|
22
24
|
var _variations = require("./variations");
|
|
@@ -88,7 +90,7 @@ const settings = {
|
|
|
88
90
|
return;
|
|
89
91
|
}
|
|
90
92
|
|
|
91
|
-
return (0,
|
|
93
|
+
return (0, _htmlEntities.decodeEntities)((_entity$title = entity.title) === null || _entity$title === void 0 ? void 0 : _entity$title.rendered) || (0, _lodash.startCase)(entity.slug);
|
|
92
94
|
},
|
|
93
95
|
edit: _edit.default
|
|
94
96
|
}; // Importing this file includes side effects. This is whitelisted in block-library/package.json under sideEffects
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/template-part/index.js"],"names":["name","metadata","settings","icon","symbolFilled","__experimentalLabel","slug","theme","entity","coreDataStore","getEntityRecord","title","rendered","edit","enhanceTemplatePartVariations","DISALLOWED_PARENTS","can","blockType","rootClientId","getBlock","getBlockParentsByBlockName","disallowedParentType","hasDisallowedParent","length"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AAMA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/template-part/index.js"],"names":["name","metadata","settings","icon","symbolFilled","__experimentalLabel","slug","theme","entity","coreDataStore","getEntityRecord","title","rendered","edit","enhanceTemplatePartVariations","DISALLOWED_PARENTS","can","blockType","rootClientId","getBlock","getBlockParentsByBlockName","disallowedParentType","hasDisallowedParent","length"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AAnBA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAEC,mBADiB;AAEvBC,EAAAA,mBAAmB,EAAE,QAAuB;AAAA;;AAAA,QAArB;AAAEC,MAAAA,IAAF;AAAQC,MAAAA;AAAR,KAAqB;;AAC3C;AACA;AACA,QAAK,CAAED,IAAP,EAAc;AACb;AACA;;AAED,UAAME,MAAM,GAAG,kBAAQC,eAAR,EAAwBC,eAAxB,CACd,UADc,EAEd,kBAFc,EAGdH,KAAK,GAAG,IAAR,GAAeD,IAHD,CAAf;;AAKA,QAAK,CAAEE,MAAP,EAAgB;AACf;AACA;;AAED,WACC,mDAAgBA,MAAM,CAACG,KAAvB,kDAAgB,cAAcC,QAA9B,KAA4C,uBAAWJ,MAAM,CAACF,IAAlB,CAD7C;AAGA,GArBsB;AAsBvBO,EAAAA,IAAI,EAAJA;AAtBuB,CAAjB,C,CAyBP;;;AACA,sBACC,0BADD,EAEC,oBAFD,EAGCC,yCAHD,E,CAMA;;AACA,MAAMC,kBAAkB,GAAG,CAAE,oBAAF,EAAwB,mBAAxB,CAA3B;AACA,sBACC,0CADD,EAEC,sCAFD,EAGC,CACCC,GADD,EAECC,SAFD,EAGCC,YAHD,YAKK;AAAA,MADJ;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GACI;;AACJ,MAAKH,SAAS,CAACjB,IAAV,KAAmB,oBAAxB,EAA+C;AAC9C,WAAOgB,GAAP;AACA;;AAED,OAAM,MAAMK,oBAAZ,IAAoCN,kBAApC,EAAyD;AAAA;;AACxD,UAAMO,mBAAmB,GACxB,cAAAH,QAAQ,CAAED,YAAF,CAAR,wDAA0BlB,IAA1B,MAAmCqB,oBAAnC,IACAD,0BAA0B,CAAEF,YAAF,EAAgBG,oBAAhB,CAA1B,CACEE,MAHH;;AAIA,QAAKD,mBAAL,EAA2B;AAC1B,aAAO,KAAP;AACA;AACD;;AACD,SAAO,IAAP;AACA,CAvBF","sourcesContent":["/**\n * External dependencies\n */\nimport { startCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { select } from '@wordpress/data';\nimport { symbolFilled } from '@wordpress/icons';\nimport { addFilter } from '@wordpress/hooks';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\nimport { enhanceTemplatePartVariations } from './variations';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon: symbolFilled,\n\t__experimentalLabel: ( { slug, theme } ) => {\n\t\t// Attempt to find entity title if block is a template part.\n\t\t// Require slug to request, otherwise entity is uncreated and will throw 404.\n\t\tif ( ! slug ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst entity = select( coreDataStore ).getEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\ttheme + '//' + slug\n\t\t);\n\t\tif ( ! entity ) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn (\n\t\t\tdecodeEntities( entity.title?.rendered ) || startCase( entity.slug )\n\t\t);\n\t},\n\tedit,\n};\n\n// Importing this file includes side effects. This is whitelisted in block-library/package.json under sideEffects\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/template-part',\n\tenhanceTemplatePartVariations\n);\n\n// Prevent adding template parts inside post templates.\nconst DISALLOWED_PARENTS = [ 'core/post-template', 'core/post-content' ];\naddFilter(\n\t'blockEditor.__unstableCanInsertBlockType',\n\t'removeTemplatePartsFromPostTemplates',\n\t(\n\t\tcan,\n\t\tblockType,\n\t\trootClientId,\n\t\t{ getBlock, getBlockParentsByBlockName }\n\t) => {\n\t\tif ( blockType.name !== 'core/template-part' ) {\n\t\t\treturn can;\n\t\t}\n\n\t\tfor ( const disallowedParentType of DISALLOWED_PARENTS ) {\n\t\t\tconst hasDisallowedParent =\n\t\t\t\tgetBlock( rootClientId )?.name === disallowedParentType ||\n\t\t\t\tgetBlockParentsByBlockName( rootClientId, disallowedParentType )\n\t\t\t\t\t.length;\n\t\t\tif ( hasDisallowedParent ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n);\n"]}
|
|
@@ -13,8 +13,8 @@ import { View, AccessibilityInfo, Platform, Text } from 'react-native';
|
|
|
13
13
|
import { useCallback, useEffect, useState, useRef } from '@wordpress/element';
|
|
14
14
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
15
15
|
import { __, _x } from '@wordpress/i18n';
|
|
16
|
-
import { RichText, InspectorControls, BlockControls, store as blockEditorStore, getColorObjectByAttributeValues, getGradientValueBySlug, __experimentalGetColorClassesAndStyles as getColorClassesAndStyles
|
|
17
|
-
import { PanelBody, ToolbarGroup, ToolbarButton, LinkSettingsNavigation, UnitControl, getValueAndUnit, BottomSheetSelectControl, CSS_UNITS, filterUnitsWithSettings } from '@wordpress/components';
|
|
16
|
+
import { RichText, InspectorControls, BlockControls, store as blockEditorStore, getColorObjectByAttributeValues, getGradientValueBySlug, __experimentalGetColorClassesAndStyles as getColorClassesAndStyles } from '@wordpress/block-editor';
|
|
17
|
+
import { PanelBody, ToolbarGroup, ToolbarButton, LinkSettingsNavigation, UnitControl, getValueAndUnit, BottomSheetSelectControl, CSS_UNITS, filterUnitsWithSettings, useMobileGlobalStylesColors } from '@wordpress/components';
|
|
18
18
|
import { link } from '@wordpress/icons';
|
|
19
19
|
import { store as editPostStore } from '@wordpress/edit-post';
|
|
20
20
|
/**
|
|
@@ -126,8 +126,8 @@ function ButtonEdit(props) {
|
|
|
126
126
|
const [placeholderTextWidth, setPlaceholderTextWidth] = useState(0);
|
|
127
127
|
const [borderRadiusUnit, setBorderRadiusUnit] = useState(valueUnit);
|
|
128
128
|
const richTextRef = useRef();
|
|
129
|
-
const colors =
|
|
130
|
-
const gradients =
|
|
129
|
+
const colors = useMobileGlobalStylesColors();
|
|
130
|
+
const gradients = useMobileGlobalStylesColors('gradients');
|
|
131
131
|
useEffect(() => {
|
|
132
132
|
if (isSelected) {
|
|
133
133
|
onToggleButtonFocus(true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/button/edit.native.js"],"names":["View","AccessibilityInfo","Platform","Text","useCallback","useEffect","useState","useRef","useSelect","useDispatch","__","_x","RichText","InspectorControls","BlockControls","store","blockEditorStore","getColorObjectByAttributeValues","getGradientValueBySlug","__experimentalGetColorClassesAndStyles","getColorClassesAndStyles","useSetting","PanelBody","ToolbarGroup","ToolbarButton","LinkSettingsNavigation","UnitControl","getValueAndUnit","BottomSheetSelectControl","CSS_UNITS","filterUnitsWithSettings","link","editPostStore","richTextStyle","styles","ColorBackground","MIN_BORDER_RADIUS_VALUE","MAX_BORDER_RADIUS_VALUE","INITIAL_MAX_WIDTH","MIN_WIDTH","MIN_WIDTH_MARGINS","button75","marginLeft","button50","button25","WidthPanel","selectedWidth","setAttributes","handleChange","newWidth","width","undefined","options","value","label","ButtonEdit","props","isSelected","parentWidth","initialBorderRadius","attributes","style","border","radius","valueUnit","editorSidebarOpened","numOfButtons","select","isEditorSidebarOpened","getBlockCount","getBlockRootClientId","parentId","clientId","blockCount","currentIsEditorSidebarOpened","closeGeneralSidebar","maxWidth","setMaxWidth","isLinkSheetVisible","setIsLinkSheetVisible","isButtonFocused","setIsButtonFocused","placeholderTextWidth","setPlaceholderTextWidth","borderRadiusUnit","setBorderRadiusUnit","richTextRef","colors","gradients","onToggleButtonFocus","onSetMaxWidth","OS","current","blur","isScreenReaderEnabled","then","enabled","focus","linkSettingsActions","onPress","onClearSettings","linkSettingsOptions","url","placeholder","autoFocus","autoFill","openInNewTab","linkRel","noFocusLinkSettingOptions","getBackgroundColor","backgroundColor","gradient","gradientValue","colorProps","colorObject","color","background","defaultButton","getTextColor","textColor","onChangeText","text","onChangeBorderRadius","newRadius","newStyle","getNewStyle","onChangeBorderRadiusUnit","newRadiusUnit","newBorderRadius","getBorderRadiusValue","radiusUnit","onShowLinkSettings","onHideLinkSettings","rel","linkTarget","onLayout","nativeEvent","layout","isParentWidthDidChange","marginRight","spacing","isParentWidthChanged","isWidthChanged","onRemove","onDeleteBlock","onReplace","onPlaceholderTextWidth","textWidth","lines","Math","min","onSetRef","ref","onUnstableOnFocus","onBlur","dismissSheet","getLinkSettings","isCompatibleWithSettings","getPlaceholderWidth","placeholderText","currentBorderRadius","defaultBorderRadius","valueAndUnit","Number","isInteger","parseInt","valueToConvert","parseFloat","mergeBlocks","buttonStyle","align","paddingTop","borderWidth","borderRadiusValue","borderRadius","buttonBorderRadiusValue","floor","outlineBorderRadius","minWidth","isFixedWidth","outLineStyles","outline","borderColor","textStyles","richText","paddingLeft","paddingRight","placeholderTextColor","fontSize"],"mappings":";;;;AAAA;AACA;AACA;AACA,SA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AAAW,IAAA,KAAK,EAAGrC,EAAE,CAAE,eAAF;AAArB,KACGkJ,eAAe,CAAE,IAAF,CADlB,CApBD,CAZD,CAvCF,CADD;AAgFA;;AAED,eAAerG,UAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { View, AccessibilityInfo, Platform, Text } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useState, useRef } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tRichText,\n\tInspectorControls,\n\tBlockControls,\n\tstore as blockEditorStore,\n\tgetColorObjectByAttributeValues,\n\tgetGradientValueBySlug,\n\t__experimentalGetColorClassesAndStyles as getColorClassesAndStyles,\n\tuseSetting,\n} from '@wordpress/block-editor';\nimport {\n\tPanelBody,\n\tToolbarGroup,\n\tToolbarButton,\n\tLinkSettingsNavigation,\n\tUnitControl,\n\tgetValueAndUnit,\n\tBottomSheetSelectControl,\n\tCSS_UNITS,\n\tfilterUnitsWithSettings,\n} from '@wordpress/components';\nimport { link } from '@wordpress/icons';\nimport { store as editPostStore } from '@wordpress/edit-post';\n\n/**\n * Internal dependencies\n */\nimport richTextStyle from './rich-text.scss';\nimport styles from './editor.scss';\nimport ColorBackground from './color-background';\n\nconst MIN_BORDER_RADIUS_VALUE = 0;\nconst MAX_BORDER_RADIUS_VALUE = 50;\nconst INITIAL_MAX_WIDTH = 108;\nconst MIN_WIDTH = 40;\n// Map of the percentage width to pixel subtraction that make the buttons fit nicely into columns.\nconst MIN_WIDTH_MARGINS = {\n\t100: 0,\n\t75: styles.button75?.marginLeft,\n\t50: styles.button50?.marginLeft,\n\t25: styles.button25?.marginLeft,\n};\n\nfunction WidthPanel( { selectedWidth, setAttributes } ) {\n\tfunction handleChange( newWidth ) {\n\t\t// Check if we are toggling the width off\n\t\tlet width = selectedWidth === newWidth ? undefined : newWidth;\n\t\tif ( newWidth === 'auto' ) {\n\t\t\twidth = undefined;\n\t\t}\n\t\t// Update attributes\n\t\tsetAttributes( { width } );\n\t}\n\n\tconst options = [\n\t\t{ value: 'auto', label: __( 'Auto' ) },\n\t\t{ value: 25, label: '25%' },\n\t\t{ value: 50, label: '50%' },\n\t\t{ value: 75, label: '75%' },\n\t\t{ value: 100, label: '100%' },\n\t];\n\n\tif ( ! selectedWidth ) {\n\t\tselectedWidth = 'auto';\n\t}\n\n\treturn (\n\t\t<PanelBody title={ __( 'Width Settings' ) }>\n\t\t\t<BottomSheetSelectControl\n\t\t\t\tlabel={ __( 'Button width' ) }\n\t\t\t\tvalue={ selectedWidth }\n\t\t\t\tonChange={ handleChange }\n\t\t\t\toptions={ options }\n\t\t\t/>\n\t\t</PanelBody>\n\t);\n}\n\nfunction ButtonEdit( props ) {\n\tconst { isSelected, parentWidth } = props;\n\tconst initialBorderRadius = props?.attributes?.style?.border?.radius;\n\tconst { valueUnit = 'px' } = getValueAndUnit( initialBorderRadius ) || {};\n\n\tconst { editorSidebarOpened, numOfButtons } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isEditorSidebarOpened } = select( editPostStore );\n\t\t\tconst { getBlockCount, getBlockRootClientId } = select(\n\t\t\t\tblockEditorStore\n\t\t\t);\n\t\t\tconst parentId = getBlockRootClientId( clientId );\n\t\t\tconst blockCount = getBlockCount( parentId );\n\t\t\tconst currentIsEditorSidebarOpened = isEditorSidebarOpened();\n\n\t\t\treturn {\n\t\t\t\teditorSidebarOpened: isSelected && currentIsEditorSidebarOpened,\n\t\t\t\tnumOfButtons: blockCount,\n\t\t\t};\n\t\t},\n\t\t[ clientId, isSelected ]\n\t);\n\n\tconst { closeGeneralSidebar } = useDispatch( editPostStore );\n\tconst [ maxWidth, setMaxWidth ] = useState( INITIAL_MAX_WIDTH );\n\tconst [ isLinkSheetVisible, setIsLinkSheetVisible ] = useState( false );\n\tconst [ isButtonFocused, setIsButtonFocused ] = useState( true );\n\tconst [ placeholderTextWidth, setPlaceholderTextWidth ] = useState( 0 );\n\tconst [ borderRadiusUnit, setBorderRadiusUnit ] = useState( valueUnit );\n\n\tconst richTextRef = useRef();\n\tconst colors = useSetting( 'color.palette' ) || [];\n\tconst gradients = useSetting( 'color.gradients' ) || [];\n\n\tuseEffect( () => {\n\t\tif ( isSelected ) {\n\t\t\tonToggleButtonFocus( true );\n\t\t}\n\t}, [ isSelected ] );\n\n\tuseEffect( () => {\n\t\tonSetMaxWidth( null, true );\n\t}, [ parentWidth ] );\n\n\tuseEffect( () => {\n\t\t// Blur `RichText` on Android when link settings sheet or button settings sheet is opened,\n\t\t// to avoid flashing caret after closing one of them\n\t\tif ( editorSidebarOpened || isLinkSheetVisible ) {\n\t\t\tif ( Platform.OS === 'android' && richTextRef?.current ) {\n\t\t\t\trichTextRef.current.blur();\n\t\t\t\tonToggleButtonFocus( false );\n\t\t\t}\n\t\t}\n\t}, [ editorSidebarOpened, isLinkSheetVisible ] );\n\n\tuseEffect( () => {\n\t\tif ( richTextRef?.current ) {\n\t\t\tif ( ! isSelected && isButtonFocused ) {\n\t\t\t\tonToggleButtonFocus( false );\n\t\t\t}\n\n\t\t\tif ( isSelected && ! isButtonFocused ) {\n\t\t\t\tAccessibilityInfo.isScreenReaderEnabled().then( ( enabled ) => {\n\t\t\t\t\tif ( enabled ) {\n\t\t\t\t\t\tonToggleButtonFocus( true );\n\t\t\t\t\t\trichTextRef?.current.focus();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}, [ isSelected, isButtonFocused ] );\n\n\tconst linkSettingsActions = [\n\t\t{\n\t\t\tlabel: __( 'Remove link' ),\n\t\t\tonPress: onClearSettings,\n\t\t},\n\t];\n\n\tconst linkSettingsOptions = {\n\t\turl: {\n\t\t\tlabel: __( 'Button Link URL' ),\n\t\t\tplaceholder: __( 'Add URL' ),\n\t\t\tautoFocus: true,\n\t\t\tautoFill: false,\n\t\t},\n\t\topenInNewTab: {\n\t\t\tlabel: __( 'Open in new tab' ),\n\t\t},\n\t\tlinkRel: {\n\t\t\tlabel: __( 'Link Rel' ),\n\t\t\tplaceholder: _x( 'None', 'Link rel attribute value placeholder' ),\n\t\t},\n\t};\n\n\tconst noFocusLinkSettingOptions = {\n\t\t...linkSettingsOptions,\n\t\turl: {\n\t\t\t...linkSettingsOptions.url,\n\t\t\tautoFocus: false,\n\t\t},\n\t};\n\n\tfunction getBackgroundColor() {\n\t\tconst { attributes, style } = props;\n\t\tconst { backgroundColor, gradient } = attributes;\n\n\t\t// Return named gradient value if available.\n\t\tconst gradientValue = getGradientValueBySlug( gradients, gradient );\n\n\t\tif ( gradientValue ) {\n\t\t\treturn gradientValue;\n\t\t}\n\n\t\tconst colorProps = getColorClassesAndStyles( attributes );\n\n\t\t// Retrieve named color object to force inline styles for themes that\n\t\t// do not load their color stylesheets in the editor.\n\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\tcolors,\n\t\t\tbackgroundColor\n\t\t);\n\n\t\treturn (\n\t\t\tcolorObject?.color ||\n\t\t\tcolorProps.style?.backgroundColor ||\n\t\t\tcolorProps.style?.background ||\n\t\t\tstyle?.backgroundColor ||\n\t\t\tstyles.defaultButton.backgroundColor\n\t\t);\n\t}\n\n\tfunction getTextColor() {\n\t\tconst { attributes, style } = props;\n\t\tconst colorProps = getColorClassesAndStyles( attributes );\n\n\t\t// Retrieve named color object to force inline styles for themes that\n\t\t// do not load their color stylesheets in the editor.\n\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\tcolors,\n\t\t\tattributes.textColor\n\t\t);\n\n\t\treturn (\n\t\t\tcolorObject?.color ||\n\t\t\tcolorProps.style?.color ||\n\t\t\tstyle?.color ||\n\t\t\tstyles.defaultButton.color\n\t\t);\n\t}\n\n\tfunction onChangeText( value ) {\n\t\tconst { setAttributes } = props;\n\t\tsetAttributes( { text: value } );\n\t}\n\n\tfunction onChangeBorderRadius( newRadius ) {\n\t\tconst { setAttributes, attributes } = props;\n\t\tconst { style } = attributes;\n\t\tconst newStyle = getNewStyle( style, newRadius, borderRadiusUnit );\n\n\t\tsetAttributes( { style: newStyle } );\n\t}\n\n\tfunction onChangeBorderRadiusUnit( newRadiusUnit ) {\n\t\tconst { setAttributes, attributes } = props;\n\t\tconst { style } = attributes;\n\t\tconst newBorderRadius = getBorderRadiusValue(\n\t\t\tattributes?.style?.border?.radius\n\t\t);\n\t\tconst newStyle = getNewStyle( style, newBorderRadius, newRadiusUnit );\n\t\tsetAttributes( { style: newStyle } );\n\t\tsetBorderRadiusUnit( newRadiusUnit );\n\t}\n\n\tfunction getNewStyle( style, radius, radiusUnit ) {\n\t\treturn {\n\t\t\t...style,\n\t\t\tborder: {\n\t\t\t\t...style?.border,\n\t\t\t\tradius: `${ radius }${ radiusUnit }`, // Store the value with the unit so that it works as expected.\n\t\t\t},\n\t\t};\n\t}\n\n\tfunction onShowLinkSettings() {\n\t\tsetIsLinkSheetVisible( true );\n\t}\n\n\tfunction onHideLinkSettings() {\n\t\tsetIsLinkSheetVisible( false );\n\t}\n\n\tfunction onToggleButtonFocus( value ) {\n\t\tif ( value !== isButtonFocused ) {\n\t\t\tsetIsButtonFocused( value );\n\t\t}\n\t}\n\n\tfunction onClearSettings() {\n\t\tconst { setAttributes } = props;\n\n\t\tsetAttributes( {\n\t\t\turl: '',\n\t\t\trel: '',\n\t\t\tlinkTarget: '',\n\t\t} );\n\n\t\tonHideLinkSettings();\n\t}\n\n\tfunction onLayout( { nativeEvent } ) {\n\t\tconst { width } = nativeEvent.layout;\n\t\tonSetMaxWidth( width );\n\t}\n\n\tconst onSetMaxWidth = useCallback(\n\t\t( width, isParentWidthDidChange = false ) => {\n\t\t\tconst { marginRight: spacing } = styles.defaultButton;\n\n\t\t\tconst isParentWidthChanged = isParentWidthDidChange\n\t\t\t\t? isParentWidthDidChange\n\t\t\t\t: maxWidth !== parentWidth;\n\t\t\tconst isWidthChanged = maxWidth !== width;\n\n\t\t\tif ( parentWidth && ! width && isParentWidthChanged ) {\n\t\t\t\tsetMaxWidth( parentWidth - spacing );\n\t\t\t} else if ( ! parentWidth && width && isWidthChanged ) {\n\t\t\t\tsetMaxWidth( width - spacing );\n\t\t\t}\n\t\t},\n\t\t[ maxWidth, parentWidth ]\n\t);\n\n\tfunction onRemove() {\n\t\tconst { onDeleteBlock, onReplace } = props;\n\n\t\tif ( numOfButtons === 1 ) {\n\t\t\tonDeleteBlock();\n\t\t} else {\n\t\t\tonReplace( [] );\n\t\t}\n\t}\n\n\tfunction onPlaceholderTextWidth( { nativeEvent } ) {\n\t\tconst textWidth =\n\t\t\tnativeEvent.lines[ 0 ] && nativeEvent.lines[ 0 ].width;\n\n\t\tif ( textWidth && textWidth !== placeholderTextWidth ) {\n\t\t\tsetPlaceholderTextWidth( Math.min( textWidth, maxWidth ) );\n\t\t}\n\t}\n\n\tconst onSetRef = useCallback(\n\t\t( ref ) => {\n\t\t\trichTextRef.current = ref;\n\t\t},\n\t\t[ richTextRef ]\n\t);\n\n\tconst onUnstableOnFocus = useCallback( () => {\n\t\tonToggleButtonFocus( true );\n\t}, [] );\n\n\tconst onBlur = useCallback( () => {\n\t\tonSetMaxWidth();\n\t}, [] );\n\n\tfunction dismissSheet() {\n\t\tonHideLinkSettings();\n\t\tcloseGeneralSidebar();\n\t}\n\n\tfunction getLinkSettings( isCompatibleWithSettings ) {\n\t\tconst { attributes, setAttributes } = props;\n\t\treturn (\n\t\t\t<LinkSettingsNavigation\n\t\t\t\tisVisible={ isLinkSheetVisible }\n\t\t\t\turl={ attributes.url }\n\t\t\t\trel={ attributes.rel }\n\t\t\t\tlinkTarget={ attributes.linkTarget }\n\t\t\t\tonClose={ dismissSheet }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\twithBottomSheet={ ! isCompatibleWithSettings }\n\t\t\t\thasPicker\n\t\t\t\tactions={ linkSettingsActions }\n\t\t\t\toptions={\n\t\t\t\t\tisCompatibleWithSettings\n\t\t\t\t\t\t? linkSettingsOptions\n\t\t\t\t\t\t: noFocusLinkSettingOptions\n\t\t\t\t}\n\t\t\t\tshowIcon={ ! isCompatibleWithSettings }\n\t\t\t/>\n\t\t);\n\t}\n\n\t// Render `Text` with `placeholderText` styled as a placeholder\n\t// to calculate its width which then is set as a `minWidth`\n\tfunction getPlaceholderWidth( placeholderText ) {\n\t\treturn (\n\t\t\t<Text\n\t\t\t\tstyle={ styles.placeholder }\n\t\t\t\tonTextLayout={ onPlaceholderTextWidth }\n\t\t\t>\n\t\t\t\t{ placeholderText }\n\t\t\t</Text>\n\t\t);\n\t}\n\n\tfunction getBorderRadiusValue( currentBorderRadius, defaultBorderRadius ) {\n\t\tconst valueAndUnit = getValueAndUnit( currentBorderRadius );\n\t\tif ( Number.isInteger( parseInt( valueAndUnit?.valueToConvert ) ) ) {\n\t\t\treturn parseFloat( valueAndUnit.valueToConvert );\n\t\t}\n\t\treturn defaultBorderRadius;\n\t}\n\n\tconst {\n\t\tattributes,\n\t\tclientId,\n\t\tonReplace,\n\t\tmergeBlocks,\n\t\tsetAttributes,\n\t\tstyle,\n\t} = props;\n\tconst {\n\t\tplaceholder,\n\t\ttext,\n\t\tstyle: buttonStyle,\n\t\turl,\n\t\talign = 'center',\n\t\twidth,\n\t} = attributes;\n\tconst { paddingTop: spacing, borderWidth } = styles.defaultButton;\n\n\tif ( parentWidth === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst currentBorderRadius = buttonStyle?.border?.radius;\n\tconst borderRadiusValue = getBorderRadiusValue(\n\t\tcurrentBorderRadius,\n\t\tstyles.defaultButton.borderRadius\n\t);\n\n\tconst buttonBorderRadiusValue =\n\t\tborderRadiusUnit === 'px' || borderRadiusUnit === '%'\n\t\t\t? borderRadiusValue\n\t\t\t: Math.floor( 14 * borderRadiusValue ); // lets assume that the font size is set to 14px; TO get a nicer preview.\n\tconst outlineBorderRadius =\n\t\tbuttonBorderRadiusValue > 0\n\t\t\t? buttonBorderRadiusValue + spacing + borderWidth\n\t\t\t: 0;\n\n\t// To achieve proper expanding and shrinking `RichText` on iOS, there is a need to set a `minWidth`\n\t// value at least on 1 when `RichText` is focused or when is not focused, but `RichText` value is\n\t// different than empty string.\n\tlet minWidth =\n\t\tisButtonFocused || ( ! isButtonFocused && text && text !== '' )\n\t\t\t? MIN_WIDTH\n\t\t\t: placeholderTextWidth;\n\tif ( width ) {\n\t\t// Set the width of the button.\n\t\tminWidth = Math.floor(\n\t\t\tmaxWidth * ( width / 100 ) - MIN_WIDTH_MARGINS[ width ]\n\t\t);\n\t}\n\t// To achieve proper expanding and shrinking `RichText` on Android, there is a need to set\n\t// a `placeholder` as an empty string when `RichText` is focused,\n\t// because `AztecView` is calculating a `minWidth` based on placeholder text.\n\tconst placeholderText =\n\t\tisButtonFocused || ( ! isButtonFocused && text && text !== '' )\n\t\t\t? ''\n\t\t\t: placeholder || __( 'Add text…' );\n\n\tconst backgroundColor = getBackgroundColor();\n\tconst textColor = getTextColor();\n\tconst isFixedWidth = !! width;\n\tconst outLineStyles = [\n\t\tstyles.outline,\n\t\t{\n\t\t\tborderRadius: outlineBorderRadius,\n\t\t\tborderColor: backgroundColor,\n\t\t},\n\t];\n\tconst textStyles = {\n\t\t...richTextStyle.richText,\n\t\tpaddingLeft: isFixedWidth ? 0 : richTextStyle.richText.paddingLeft,\n\t\tpaddingRight: isFixedWidth ? 0 : richTextStyle.richText.paddingRight,\n\t\tcolor: textColor,\n\t};\n\n\treturn (\n\t\t<View onLayout={ onLayout }>\n\t\t\t{ getPlaceholderWidth( placeholderText ) }\n\t\t\t<ColorBackground\n\t\t\t\tborderRadiusValue={ buttonBorderRadiusValue }\n\t\t\t\tbackgroundColor={ backgroundColor }\n\t\t\t\tisSelected={ isSelected }\n\t\t\t>\n\t\t\t\t{ isSelected && (\n\t\t\t\t\t<View pointerEvents=\"none\" style={ outLineStyles } />\n\t\t\t\t) }\n\t\t\t\t<RichText\n\t\t\t\t\tsetRef={ onSetRef }\n\t\t\t\t\tplaceholder={ placeholderText }\n\t\t\t\t\tvalue={ text }\n\t\t\t\t\tonChange={ onChangeText }\n\t\t\t\t\tstyle={ textStyles }\n\t\t\t\t\ttextAlign={ align }\n\t\t\t\t\tplaceholderTextColor={\n\t\t\t\t\t\tstyle?.color || styles.placeholderTextColor.color\n\t\t\t\t\t}\n\t\t\t\t\tidentifier=\"text\"\n\t\t\t\t\ttagName=\"p\"\n\t\t\t\t\tminWidth={ minWidth } // The minimum Button size.\n\t\t\t\t\tmaxWidth={ isFixedWidth ? minWidth : maxWidth } // The width of the screen.\n\t\t\t\t\tid={ clientId }\n\t\t\t\t\tisSelected={ isButtonFocused }\n\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\tunstableOnFocus={ onUnstableOnFocus }\n\t\t\t\t\t__unstableMobileNoFocusOnMount={ ! isSelected }\n\t\t\t\t\tselectionColor={ textColor }\n\t\t\t\t\tonBlur={ onBlur }\n\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\tonRemove={ onRemove }\n\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\tfontSize={ style?.fontSize }\n\t\t\t\t/>\n\t\t\t</ColorBackground>\n\n\t\t\t{ isSelected && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\t\ttitle={ __( 'Edit link' ) }\n\t\t\t\t\t\t\t\ticon={ link }\n\t\t\t\t\t\t\t\tonClick={ onShowLinkSettings }\n\t\t\t\t\t\t\t\tisActive={ url }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t\t{ getLinkSettings( false ) }\n\t\t\t\t\t<InspectorControls>\n\t\t\t\t\t\t<PanelBody title={ __( 'Border Settings' ) }>\n\t\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Border Radius' ) }\n\t\t\t\t\t\t\t\tmin={ MIN_BORDER_RADIUS_VALUE }\n\t\t\t\t\t\t\t\tmax={ MAX_BORDER_RADIUS_VALUE }\n\t\t\t\t\t\t\t\tvalue={ borderRadiusValue }\n\t\t\t\t\t\t\t\tonChange={ onChangeBorderRadius }\n\t\t\t\t\t\t\t\tonUnitChange={ onChangeBorderRadiusUnit }\n\t\t\t\t\t\t\t\tunit={ borderRadiusUnit }\n\t\t\t\t\t\t\t\tunits={ filterUnitsWithSettings(\n\t\t\t\t\t\t\t\t\t[ 'px', 'em', 'rem' ],\n\t\t\t\t\t\t\t\t\tCSS_UNITS\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</PanelBody>\n\t\t\t\t\t\t<WidthPanel\n\t\t\t\t\t\t\tselectedWidth={ width }\n\t\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<PanelBody title={ __( 'Link Settings' ) }>\n\t\t\t\t\t\t\t{ getLinkSettings( true ) }\n\t\t\t\t\t\t</PanelBody>\n\t\t\t\t\t</InspectorControls>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</View>\n\t);\n}\n\nexport default ButtonEdit;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/button/edit.native.js"],"names":["View","AccessibilityInfo","Platform","Text","useCallback","useEffect","useState","useRef","useSelect","useDispatch","__","_x","RichText","InspectorControls","BlockControls","store","blockEditorStore","getColorObjectByAttributeValues","getGradientValueBySlug","__experimentalGetColorClassesAndStyles","getColorClassesAndStyles","PanelBody","ToolbarGroup","ToolbarButton","LinkSettingsNavigation","UnitControl","getValueAndUnit","BottomSheetSelectControl","CSS_UNITS","filterUnitsWithSettings","useMobileGlobalStylesColors","link","editPostStore","richTextStyle","styles","ColorBackground","MIN_BORDER_RADIUS_VALUE","MAX_BORDER_RADIUS_VALUE","INITIAL_MAX_WIDTH","MIN_WIDTH","MIN_WIDTH_MARGINS","button75","marginLeft","button50","button25","WidthPanel","selectedWidth","setAttributes","handleChange","newWidth","width","undefined","options","value","label","ButtonEdit","props","isSelected","parentWidth","initialBorderRadius","attributes","style","border","radius","valueUnit","editorSidebarOpened","numOfButtons","select","isEditorSidebarOpened","getBlockCount","getBlockRootClientId","parentId","clientId","blockCount","currentIsEditorSidebarOpened","closeGeneralSidebar","maxWidth","setMaxWidth","isLinkSheetVisible","setIsLinkSheetVisible","isButtonFocused","setIsButtonFocused","placeholderTextWidth","setPlaceholderTextWidth","borderRadiusUnit","setBorderRadiusUnit","richTextRef","colors","gradients","onToggleButtonFocus","onSetMaxWidth","OS","current","blur","isScreenReaderEnabled","then","enabled","focus","linkSettingsActions","onPress","onClearSettings","linkSettingsOptions","url","placeholder","autoFocus","autoFill","openInNewTab","linkRel","noFocusLinkSettingOptions","getBackgroundColor","backgroundColor","gradient","gradientValue","colorProps","colorObject","color","background","defaultButton","getTextColor","textColor","onChangeText","text","onChangeBorderRadius","newRadius","newStyle","getNewStyle","onChangeBorderRadiusUnit","newRadiusUnit","newBorderRadius","getBorderRadiusValue","radiusUnit","onShowLinkSettings","onHideLinkSettings","rel","linkTarget","onLayout","nativeEvent","layout","isParentWidthDidChange","marginRight","spacing","isParentWidthChanged","isWidthChanged","onRemove","onDeleteBlock","onReplace","onPlaceholderTextWidth","textWidth","lines","Math","min","onSetRef","ref","onUnstableOnFocus","onBlur","dismissSheet","getLinkSettings","isCompatibleWithSettings","getPlaceholderWidth","placeholderText","currentBorderRadius","defaultBorderRadius","valueAndUnit","Number","isInteger","parseInt","valueToConvert","parseFloat","mergeBlocks","buttonStyle","align","paddingTop","borderWidth","borderRadiusValue","borderRadius","buttonBorderRadiusValue","floor","outlineBorderRadius","minWidth","isFixedWidth","outLineStyles","outline","borderColor","textStyles","richText","paddingLeft","paddingRight","placeholderTextColor","fontSize"],"mappings":";;;;AAAA;AACA;AACA;AACA,SAASA,IAAT,EAAeC,iBAAf,EAAkCC,QAAlC,EAA4CC,IAA5C,QAAwD,cAAxD;AAEA;AACA;AACA;;AACA,SAASC,WAAT,EAAsBC,SAAtB,EAAiCC,QAAjC,EAA2CC,MAA3C,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form, Text } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useState, useRef } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tRichText,\n\tInspectorControls,\n\tBlockControls,\n\tstore as blockEditorStore,\n\tgetColorObjectByAttributeValues,\n\tgetGradientValueBySlug,\n\t__experimentalGetColorClassesAndStyles as getColorClassesAndStyles,\n} from '@wordpress/block-editor';\nimport {\n\tPanelBody,\n\tToolbarGroup,\n\tToolbarButton,\n\tLinkSettingsNavigation,\n\tUnitControl,\n\tgetValueAndUnit,\n\tBottomSheetSelectControl,\n\tCSS_UNITS,\n\tfilterUnitsWithSettings,\n\tuseMobileGlobalStylesColors,\n} from '@wordpress/components';\nimport { link } from '@wordpress/icons';\nimport { store as editPostStore } from '@wordpress/edit-post';\n\n/**\n * Internal dependencies\n */\nimport richTextStyle from './rich-text.scss';\nimport styles from './editor.scss';\nimport ColorBackground from './color-background';\n\nconst MIN_BORDER_RADIUS_VALUE = 0;\nconst MAX_BORDER_RADIUS_VALUE = 50;\nconst INITIAL_MAX_WIDTH = 108;\nconst MIN_WIDTH = 40;\n// Map of the percentage width to pixel subtraction that make the buttons fit nicely into columns.\nconst MIN_WIDTH_MARGINS = {\n\t100: 0,\n\t75: styles.button75?.marginLeft,\n\t50: styles.button50?.marginLeft,\n\t25: styles.button25?.marginLeft,\n};\n\nfunction WidthPanel( { selectedWidth, setAttributes } ) {\n\tfunction handleChange( newWidth ) {\n\t\t// Check if we are toggling the width off\n\t\tlet width = selectedWidth === newWidth ? undefined : newWidth;\n\t\tif ( newWidth === 'auto' ) {\n\t\t\twidth = undefined;\n\t\t}\n\t\t// Update attributes\n\t\tsetAttributes( { width } );\n\t}\n\n\tconst options = [\n\t\t{ value: 'auto', label: __( 'Auto' ) },\n\t\t{ value: 25, label: '25%' },\n\t\t{ value: 50, label: '50%' },\n\t\t{ value: 75, label: '75%' },\n\t\t{ value: 100, label: '100%' },\n\t];\n\n\tif ( ! selectedWidth ) {\n\t\tselectedWidth = 'auto';\n\t}\n\n\treturn (\n\t\t<PanelBody title={ __( 'Width Settings' ) }>\n\t\t\t<BottomSheetSelectControl\n\t\t\t\tlabel={ __( 'Button width' ) }\n\t\t\t\tvalue={ selectedWidth }\n\t\t\t\tonChange={ handleChange }\n\t\t\t\toptions={ options }\n\t\t\t/>\n\t\t</PanelBody>\n\t);\n}\n\nfunction ButtonEdit( props ) {\n\tconst { isSelected, parentWidth } = props;\n\tconst initialBorderRadius = props?.attributes?.style?.border?.radius;\n\tconst { valueUnit = 'px' } = getValueAndUnit( initialBorderRadius ) || {};\n\n\tconst { editorSidebarOpened, numOfButtons } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isEditorSidebarOpened } = select( editPostStore );\n\t\t\tconst { getBlockCount, getBlockRootClientId } = select(\n\t\t\t\tblockEditorStore\n\t\t\t);\n\t\t\tconst parentId = getBlockRootClientId( clientId );\n\t\t\tconst blockCount = getBlockCount( parentId );\n\t\t\tconst currentIsEditorSidebarOpened = isEditorSidebarOpened();\n\n\t\t\treturn {\n\t\t\t\teditorSidebarOpened: isSelected && currentIsEditorSidebarOpened,\n\t\t\t\tnumOfButtons: blockCount,\n\t\t\t};\n\t\t},\n\t\t[ clientId, isSelected ]\n\t);\n\n\tconst { closeGeneralSidebar } = useDispatch( editPostStore );\n\tconst [ maxWidth, setMaxWidth ] = useState( INITIAL_MAX_WIDTH );\n\tconst [ isLinkSheetVisible, setIsLinkSheetVisible ] = useState( false );\n\tconst [ isButtonFocused, setIsButtonFocused ] = useState( true );\n\tconst [ placeholderTextWidth, setPlaceholderTextWidth ] = useState( 0 );\n\tconst [ borderRadiusUnit, setBorderRadiusUnit ] = useState( valueUnit );\n\n\tconst richTextRef = useRef();\n\tconst colors = useMobileGlobalStylesColors();\n\tconst gradients = useMobileGlobalStylesColors( 'gradients' );\n\n\tuseEffect( () => {\n\t\tif ( isSelected ) {\n\t\t\tonToggleButtonFocus( true );\n\t\t}\n\t}, [ isSelected ] );\n\n\tuseEffect( () => {\n\t\tonSetMaxWidth( null, true );\n\t}, [ parentWidth ] );\n\n\tuseEffect( () => {\n\t\t// Blur `RichText` on Android when link settings sheet or button settings sheet is opened,\n\t\t// to avoid flashing caret after closing one of them\n\t\tif ( editorSidebarOpened || isLinkSheetVisible ) {\n\t\t\tif ( Platform.OS === 'android' && richTextRef?.current ) {\n\t\t\t\trichTextRef.current.blur();\n\t\t\t\tonToggleButtonFocus( false );\n\t\t\t}\n\t\t}\n\t}, [ editorSidebarOpened, isLinkSheetVisible ] );\n\n\tuseEffect( () => {\n\t\tif ( richTextRef?.current ) {\n\t\t\tif ( ! isSelected && isButtonFocused ) {\n\t\t\t\tonToggleButtonFocus( false );\n\t\t\t}\n\n\t\t\tif ( isSelected && ! isButtonFocused ) {\n\t\t\t\tAccessibilityInfo.isScreenReaderEnabled().then( ( enabled ) => {\n\t\t\t\t\tif ( enabled ) {\n\t\t\t\t\t\tonToggleButtonFocus( true );\n\t\t\t\t\t\trichTextRef?.current.focus();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}, [ isSelected, isButtonFocused ] );\n\n\tconst linkSettingsActions = [\n\t\t{\n\t\t\tlabel: __( 'Remove link' ),\n\t\t\tonPress: onClearSettings,\n\t\t},\n\t];\n\n\tconst linkSettingsOptions = {\n\t\turl: {\n\t\t\tlabel: __( 'Button Link URL' ),\n\t\t\tplaceholder: __( 'Add URL' ),\n\t\t\tautoFocus: true,\n\t\t\tautoFill: false,\n\t\t},\n\t\topenInNewTab: {\n\t\t\tlabel: __( 'Open in new tab' ),\n\t\t},\n\t\tlinkRel: {\n\t\t\tlabel: __( 'Link Rel' ),\n\t\t\tplaceholder: _x( 'None', 'Link rel attribute value placeholder' ),\n\t\t},\n\t};\n\n\tconst noFocusLinkSettingOptions = {\n\t\t...linkSettingsOptions,\n\t\turl: {\n\t\t\t...linkSettingsOptions.url,\n\t\t\tautoFocus: false,\n\t\t},\n\t};\n\n\tfunction getBackgroundColor() {\n\t\tconst { attributes, style } = props;\n\t\tconst { backgroundColor, gradient } = attributes;\n\n\t\t// Return named gradient value if available.\n\t\tconst gradientValue = getGradientValueBySlug( gradients, gradient );\n\n\t\tif ( gradientValue ) {\n\t\t\treturn gradientValue;\n\t\t}\n\n\t\tconst colorProps = getColorClassesAndStyles( attributes );\n\n\t\t// Retrieve named color object to force inline styles for themes that\n\t\t// do not load their color stylesheets in the editor.\n\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\tcolors,\n\t\t\tbackgroundColor\n\t\t);\n\n\t\treturn (\n\t\t\tcolorObject?.color ||\n\t\t\tcolorProps.style?.backgroundColor ||\n\t\t\tcolorProps.style?.background ||\n\t\t\tstyle?.backgroundColor ||\n\t\t\tstyles.defaultButton.backgroundColor\n\t\t);\n\t}\n\n\tfunction getTextColor() {\n\t\tconst { attributes, style } = props;\n\t\tconst colorProps = getColorClassesAndStyles( attributes );\n\n\t\t// Retrieve named color object to force inline styles for themes that\n\t\t// do not load their color stylesheets in the editor.\n\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\tcolors,\n\t\t\tattributes.textColor\n\t\t);\n\n\t\treturn (\n\t\t\tcolorObject?.color ||\n\t\t\tcolorProps.style?.color ||\n\t\t\tstyle?.color ||\n\t\t\tstyles.defaultButton.color\n\t\t);\n\t}\n\n\tfunction onChangeText( value ) {\n\t\tconst { setAttributes } = props;\n\t\tsetAttributes( { text: value } );\n\t}\n\n\tfunction onChangeBorderRadius( newRadius ) {\n\t\tconst { setAttributes, attributes } = props;\n\t\tconst { style } = attributes;\n\t\tconst newStyle = getNewStyle( style, newRadius, borderRadiusUnit );\n\n\t\tsetAttributes( { style: newStyle } );\n\t}\n\n\tfunction onChangeBorderRadiusUnit( newRadiusUnit ) {\n\t\tconst { setAttributes, attributes } = props;\n\t\tconst { style } = attributes;\n\t\tconst newBorderRadius = getBorderRadiusValue(\n\t\t\tattributes?.style?.border?.radius\n\t\t);\n\t\tconst newStyle = getNewStyle( style, newBorderRadius, newRadiusUnit );\n\t\tsetAttributes( { style: newStyle } );\n\t\tsetBorderRadiusUnit( newRadiusUnit );\n\t}\n\n\tfunction getNewStyle( style, radius, radiusUnit ) {\n\t\treturn {\n\t\t\t...style,\n\t\t\tborder: {\n\t\t\t\t...style?.border,\n\t\t\t\tradius: `${ radius }${ radiusUnit }`, // Store the value with the unit so that it works as expected.\n\t\t\t},\n\t\t};\n\t}\n\n\tfunction onShowLinkSettings() {\n\t\tsetIsLinkSheetVisible( true );\n\t}\n\n\tfunction onHideLinkSettings() {\n\t\tsetIsLinkSheetVisible( false );\n\t}\n\n\tfunction onToggleButtonFocus( value ) {\n\t\tif ( value !== isButtonFocused ) {\n\t\t\tsetIsButtonFocused( value );\n\t\t}\n\t}\n\n\tfunction onClearSettings() {\n\t\tconst { setAttributes } = props;\n\n\t\tsetAttributes( {\n\t\t\turl: '',\n\t\t\trel: '',\n\t\t\tlinkTarget: '',\n\t\t} );\n\n\t\tonHideLinkSettings();\n\t}\n\n\tfunction onLayout( { nativeEvent } ) {\n\t\tconst { width } = nativeEvent.layout;\n\t\tonSetMaxWidth( width );\n\t}\n\n\tconst onSetMaxWidth = useCallback(\n\t\t( width, isParentWidthDidChange = false ) => {\n\t\t\tconst { marginRight: spacing } = styles.defaultButton;\n\n\t\t\tconst isParentWidthChanged = isParentWidthDidChange\n\t\t\t\t? isParentWidthDidChange\n\t\t\t\t: maxWidth !== parentWidth;\n\t\t\tconst isWidthChanged = maxWidth !== width;\n\n\t\t\tif ( parentWidth && ! width && isParentWidthChanged ) {\n\t\t\t\tsetMaxWidth( parentWidth - spacing );\n\t\t\t} else if ( ! parentWidth && width && isWidthChanged ) {\n\t\t\t\tsetMaxWidth( width - spacing );\n\t\t\t}\n\t\t},\n\t\t[ maxWidth, parentWidth ]\n\t);\n\n\tfunction onRemove() {\n\t\tconst { onDeleteBlock, onReplace } = props;\n\n\t\tif ( numOfButtons === 1 ) {\n\t\t\tonDeleteBlock();\n\t\t} else {\n\t\t\tonReplace( [] );\n\t\t}\n\t}\n\n\tfunction onPlaceholderTextWidth( { nativeEvent } ) {\n\t\tconst textWidth =\n\t\t\tnativeEvent.lines[ 0 ] && nativeEvent.lines[ 0 ].width;\n\n\t\tif ( textWidth && textWidth !== placeholderTextWidth ) {\n\t\t\tsetPlaceholderTextWidth( Math.min( textWidth, maxWidth ) );\n\t\t}\n\t}\n\n\tconst onSetRef = useCallback(\n\t\t( ref ) => {\n\t\t\trichTextRef.current = ref;\n\t\t},\n\t\t[ richTextRef ]\n\t);\n\n\tconst onUnstableOnFocus = useCallback( () => {\n\t\tonToggleButtonFocus( true );\n\t}, [] );\n\n\tconst onBlur = useCallback( () => {\n\t\tonSetMaxWidth();\n\t}, [] );\n\n\tfunction dismissSheet() {\n\t\tonHideLinkSettings();\n\t\tcloseGeneralSidebar();\n\t}\n\n\tfunction getLinkSettings( isCompatibleWithSettings ) {\n\t\tconst { attributes, setAttributes } = props;\n\t\treturn (\n\t\t\t<LinkSettingsNavigation\n\t\t\t\tisVisible={ isLinkSheetVisible }\n\t\t\t\turl={ attributes.url }\n\t\t\t\trel={ attributes.rel }\n\t\t\t\tlinkTarget={ attributes.linkTarget }\n\t\t\t\tonClose={ dismissSheet }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\twithBottomSheet={ ! isCompatibleWithSettings }\n\t\t\t\thasPicker\n\t\t\t\tactions={ linkSettingsActions }\n\t\t\t\toptions={\n\t\t\t\t\tisCompatibleWithSettings\n\t\t\t\t\t\t? linkSettingsOptions\n\t\t\t\t\t\t: noFocusLinkSettingOptions\n\t\t\t\t}\n\t\t\t\tshowIcon={ ! isCompatibleWithSettings }\n\t\t\t/>\n\t\t);\n\t}\n\n\t// Render `Text` with `placeholderText` styled as a placeholder\n\t// to calculate its width which then is set as a `minWidth`\n\tfunction getPlaceholderWidth( placeholderText ) {\n\t\treturn (\n\t\t\t<Text\n\t\t\t\tstyle={ styles.placeholder }\n\t\t\t\tonTextLayout={ onPlaceholderTextWidth }\n\t\t\t>\n\t\t\t\t{ placeholderText }\n\t\t\t</Text>\n\t\t);\n\t}\n\n\tfunction getBorderRadiusValue( currentBorderRadius, defaultBorderRadius ) {\n\t\tconst valueAndUnit = getValueAndUnit( currentBorderRadius );\n\t\tif ( Number.isInteger( parseInt( valueAndUnit?.valueToConvert ) ) ) {\n\t\t\treturn parseFloat( valueAndUnit.valueToConvert );\n\t\t}\n\t\treturn defaultBorderRadius;\n\t}\n\n\tconst {\n\t\tattributes,\n\t\tclientId,\n\t\tonReplace,\n\t\tmergeBlocks,\n\t\tsetAttributes,\n\t\tstyle,\n\t} = props;\n\tconst {\n\t\tplaceholder,\n\t\ttext,\n\t\tstyle: buttonStyle,\n\t\turl,\n\t\talign = 'center',\n\t\twidth,\n\t} = attributes;\n\tconst { paddingTop: spacing, borderWidth } = styles.defaultButton;\n\n\tif ( parentWidth === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst currentBorderRadius = buttonStyle?.border?.radius;\n\tconst borderRadiusValue = getBorderRadiusValue(\n\t\tcurrentBorderRadius,\n\t\tstyles.defaultButton.borderRadius\n\t);\n\n\tconst buttonBorderRadiusValue =\n\t\tborderRadiusUnit === 'px' || borderRadiusUnit === '%'\n\t\t\t? borderRadiusValue\n\t\t\t: Math.floor( 14 * borderRadiusValue ); // lets assume that the font size is set to 14px; TO get a nicer preview.\n\tconst outlineBorderRadius =\n\t\tbuttonBorderRadiusValue > 0\n\t\t\t? buttonBorderRadiusValue + spacing + borderWidth\n\t\t\t: 0;\n\n\t// To achieve proper expanding and shrinking `RichText` on iOS, there is a need to set a `minWidth`\n\t// value at least on 1 when `RichText` is focused or when is not focused, but `RichText` value is\n\t// different than empty string.\n\tlet minWidth =\n\t\tisButtonFocused || ( ! isButtonFocused && text && text !== '' )\n\t\t\t? MIN_WIDTH\n\t\t\t: placeholderTextWidth;\n\tif ( width ) {\n\t\t// Set the width of the button.\n\t\tminWidth = Math.floor(\n\t\t\tmaxWidth * ( width / 100 ) - MIN_WIDTH_MARGINS[ width ]\n\t\t);\n\t}\n\t// To achieve proper expanding and shrinking `RichText` on Android, there is a need to set\n\t// a `placeholder` as an empty string when `RichText` is focused,\n\t// because `AztecView` is calculating a `minWidth` based on placeholder text.\n\tconst placeholderText =\n\t\tisButtonFocused || ( ! isButtonFocused && text && text !== '' )\n\t\t\t? ''\n\t\t\t: placeholder || __( 'Add text…' );\n\n\tconst backgroundColor = getBackgroundColor();\n\tconst textColor = getTextColor();\n\tconst isFixedWidth = !! width;\n\tconst outLineStyles = [\n\t\tstyles.outline,\n\t\t{\n\t\t\tborderRadius: outlineBorderRadius,\n\t\t\tborderColor: backgroundColor,\n\t\t},\n\t];\n\tconst textStyles = {\n\t\t...richTextStyle.richText,\n\t\tpaddingLeft: isFixedWidth ? 0 : richTextStyle.richText.paddingLeft,\n\t\tpaddingRight: isFixedWidth ? 0 : richTextStyle.richText.paddingRight,\n\t\tcolor: textColor,\n\t};\n\n\treturn (\n\t\t<View onLayout={ onLayout }>\n\t\t\t{ getPlaceholderWidth( placeholderText ) }\n\t\t\t<ColorBackground\n\t\t\t\tborderRadiusValue={ buttonBorderRadiusValue }\n\t\t\t\tbackgroundColor={ backgroundColor }\n\t\t\t\tisSelected={ isSelected }\n\t\t\t>\n\t\t\t\t{ isSelected && (\n\t\t\t\t\t<View pointerEvents=\"none\" style={ outLineStyles } />\n\t\t\t\t) }\n\t\t\t\t<RichText\n\t\t\t\t\tsetRef={ onSetRef }\n\t\t\t\t\tplaceholder={ placeholderText }\n\t\t\t\t\tvalue={ text }\n\t\t\t\t\tonChange={ onChangeText }\n\t\t\t\t\tstyle={ textStyles }\n\t\t\t\t\ttextAlign={ align }\n\t\t\t\t\tplaceholderTextColor={\n\t\t\t\t\t\tstyle?.color || styles.placeholderTextColor.color\n\t\t\t\t\t}\n\t\t\t\t\tidentifier=\"text\"\n\t\t\t\t\ttagName=\"p\"\n\t\t\t\t\tminWidth={ minWidth } // The minimum Button size.\n\t\t\t\t\tmaxWidth={ isFixedWidth ? minWidth : maxWidth } // The width of the screen.\n\t\t\t\t\tid={ clientId }\n\t\t\t\t\tisSelected={ isButtonFocused }\n\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\tunstableOnFocus={ onUnstableOnFocus }\n\t\t\t\t\t__unstableMobileNoFocusOnMount={ ! isSelected }\n\t\t\t\t\tselectionColor={ textColor }\n\t\t\t\t\tonBlur={ onBlur }\n\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\tonRemove={ onRemove }\n\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\tfontSize={ style?.fontSize }\n\t\t\t\t/>\n\t\t\t</ColorBackground>\n\n\t\t\t{ isSelected && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\t\ttitle={ __( 'Edit link' ) }\n\t\t\t\t\t\t\t\ticon={ link }\n\t\t\t\t\t\t\t\tonClick={ onShowLinkSettings }\n\t\t\t\t\t\t\t\tisActive={ url }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t\t{ getLinkSettings( false ) }\n\t\t\t\t\t<InspectorControls>\n\t\t\t\t\t\t<PanelBody title={ __( 'Border Settings' ) }>\n\t\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Border Radius' ) }\n\t\t\t\t\t\t\t\tmin={ MIN_BORDER_RADIUS_VALUE }\n\t\t\t\t\t\t\t\tmax={ MAX_BORDER_RADIUS_VALUE }\n\t\t\t\t\t\t\t\tvalue={ borderRadiusValue }\n\t\t\t\t\t\t\t\tonChange={ onChangeBorderRadius }\n\t\t\t\t\t\t\t\tonUnitChange={ onChangeBorderRadiusUnit }\n\t\t\t\t\t\t\t\tunit={ borderRadiusUnit }\n\t\t\t\t\t\t\t\tunits={ filterUnitsWithSettings(\n\t\t\t\t\t\t\t\t\t[ 'px', 'em', 'rem' ],\n\t\t\t\t\t\t\t\t\tCSS_UNITS\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</PanelBody>\n\t\t\t\t\t\t<WidthPanel\n\t\t\t\t\t\t\tselectedWidth={ width }\n\t\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<PanelBody title={ __( 'Link Settings' ) }>\n\t\t\t\t\t\t\t{ getLinkSettings( true ) }\n\t\t\t\t\t\t</PanelBody>\n\t\t\t\t\t</InspectorControls>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</View>\n\t);\n}\n\nexport default ButtonEdit;\n"]}
|
|
@@ -54,6 +54,18 @@ const metadata = {
|
|
|
54
54
|
type: "flex",
|
|
55
55
|
flexWrap: "nowrap"
|
|
56
56
|
}
|
|
57
|
+
},
|
|
58
|
+
__experimentalBorder: {
|
|
59
|
+
color: true,
|
|
60
|
+
radius: true,
|
|
61
|
+
style: true,
|
|
62
|
+
width: true,
|
|
63
|
+
__experimentalDefaultControls: {
|
|
64
|
+
color: true,
|
|
65
|
+
radius: true,
|
|
66
|
+
style: true,
|
|
67
|
+
width: true
|
|
68
|
+
}
|
|
57
69
|
}
|
|
58
70
|
},
|
|
59
71
|
editorStyle: "wp-block-columns-editor",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/columns/index.js"],"names":["__","columns","icon","deprecated","edit","save","variations","transforms","name","metadata","settings","example","viewportWidth","innerBlocks","attributes","content","url"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,OAAO,IAAIC,IAApB,QAAgC,kBAAhC;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,IAAP,MAAiB,QAAjB
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/columns/index.js"],"names":["__","columns","icon","deprecated","edit","save","variations","transforms","name","metadata","settings","example","viewportWidth","innerBlocks","attributes","content","url"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,OAAO,IAAIC,IAApB,QAAgC,kBAAhC;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,IAAP,MAAiB,QAAjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AAEA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBR,EAAAA,IADuB;AAEvBI,EAAAA,UAFuB;AAGvBK,EAAAA,OAAO,EAAE;AACRC,IAAAA,aAAa,EAAE,GADP;AACY;AACpBC,IAAAA,WAAW,EAAE,CACZ;AACCL,MAAAA,IAAI,EAAE,aADP;AAECK,MAAAA,WAAW,EAAE,CACZ;AACCL,QAAAA,IAAI,EAAE,gBADP;AAECM,QAAAA,UAAU,EAAE;AACX;AACAC,UAAAA,OAAO,EAAEf,EAAE,CACV,qFADU;AAFA;AAFb,OADY,EAUZ;AACCQ,QAAAA,IAAI,EAAE,YADP;AAECM,QAAAA,UAAU,EAAE;AACXE,UAAAA,GAAG,EACF;AAFU;AAFb,OAVY,EAiBZ;AACCR,QAAAA,IAAI,EAAE,gBADP;AAECM,QAAAA,UAAU,EAAE;AACX;AACAC,UAAAA,OAAO,EAAEf,EAAE,CACV,6DADU;AAFA;AAFb,OAjBY;AAFd,KADY,EA+BZ;AACCQ,MAAAA,IAAI,EAAE,aADP;AAECK,MAAAA,WAAW,EAAE,CACZ;AACCL,QAAAA,IAAI,EAAE,gBADP;AAECM,QAAAA,UAAU,EAAE;AACX;AACAC,UAAAA,OAAO,EAAEf,EAAE,CACV,+JADU;AAFA;AAFb,OADY,EAUZ;AACCQ,QAAAA,IAAI,EAAE,gBADP;AAECM,QAAAA,UAAU,EAAE;AACX;AACAC,UAAAA,OAAO,EAAEf,EAAE,CACV,yGADU;AAFA;AAFb,OAVY;AAFd,KA/BY;AAFL,GAHc;AA6DvBG,EAAAA,UA7DuB;AA8DvBC,EAAAA,IA9DuB;AA+DvBC,EAAAA,IA/DuB;AAgEvBE,EAAAA;AAhEuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { columns as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport variations from './variations';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tvariations,\n\texample: {\n\t\tviewportWidth: 600, // Columns collapse \"@media (max-width: 599px)\".\n\t\tinnerBlocks: [\n\t\t\t{\n\t\t\t\tname: 'core/column',\n\t\t\t\tinnerBlocks: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'core/paragraph',\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t/* translators: example text. */\n\t\t\t\t\t\t\tcontent: __(\n\t\t\t\t\t\t\t\t'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent et eros eu felis.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'core/image',\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\turl:\n\t\t\t\t\t\t\t\t'https://s.w.org/images/core/5.3/Windbuchencom.jpg',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'core/paragraph',\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t/* translators: example text. */\n\t\t\t\t\t\t\tcontent: __(\n\t\t\t\t\t\t\t\t'Suspendisse commodo neque lacus, a dictum orci interdum et.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'core/column',\n\t\t\t\tinnerBlocks: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'core/paragraph',\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t/* translators: example text. */\n\t\t\t\t\t\t\tcontent: __(\n\t\t\t\t\t\t\t\t'Etiam et egestas lorem. Vivamus sagittis sit amet dolor quis lobortis. Integer sed fermentum arcu, id vulputate lacus. Etiam fermentum sem eu quam hendrerit.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'core/paragraph',\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t/* translators: example text. */\n\t\t\t\t\t\t\tcontent: __(\n\t\t\t\t\t\t\t\t'Nam risus massa, ullamcorper consectetur eros fermentum, porta aliquet ligula. Sed vel mauris nec enim.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t},\n\tdeprecated,\n\tedit,\n\tsave,\n\ttransforms,\n};\n"]}
|
|
@@ -4,10 +4,11 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
4
4
|
/**
|
|
5
5
|
* WordPress dependencies
|
|
6
6
|
*/
|
|
7
|
-
import { InspectorControls, useBlockProps, __experimentalGetSpacingClassesAndStyles as useSpacingProps } from '@wordpress/block-editor';
|
|
7
|
+
import { InspectorControls, useBlockProps, __experimentalGetSpacingClassesAndStyles as useSpacingProps, store as blockEditorStore } from '@wordpress/block-editor';
|
|
8
8
|
import { PanelBody, ResizableBox, RangeControl } from '@wordpress/components';
|
|
9
9
|
import { useEntityProp } from '@wordpress/core-data';
|
|
10
|
-
import {
|
|
10
|
+
import { useSelect } from '@wordpress/data';
|
|
11
|
+
import { __, isRTL } from '@wordpress/i18n';
|
|
11
12
|
export default function Edit(_ref) {
|
|
12
13
|
let {
|
|
13
14
|
attributes,
|
|
@@ -30,6 +31,17 @@ export default function Edit(_ref) {
|
|
|
30
31
|
const blockProps = useBlockProps();
|
|
31
32
|
const spacingProps = useSpacingProps(attributes);
|
|
32
33
|
const maxSizeBuffer = Math.floor(maxSize * 2.5);
|
|
34
|
+
const {
|
|
35
|
+
avatarURL
|
|
36
|
+
} = useSelect(select => {
|
|
37
|
+
const {
|
|
38
|
+
getSettings
|
|
39
|
+
} = select(blockEditorStore);
|
|
40
|
+
const {
|
|
41
|
+
__experimentalDiscussionSettings
|
|
42
|
+
} = getSettings();
|
|
43
|
+
return __experimentalDiscussionSettings;
|
|
44
|
+
});
|
|
33
45
|
const inspectorControls = createElement(InspectorControls, null, createElement(PanelBody, {
|
|
34
46
|
title: __('Avatar Settings')
|
|
35
47
|
}, createElement(RangeControl, {
|
|
@@ -43,7 +55,7 @@ export default function Edit(_ref) {
|
|
|
43
55
|
initialPosition: width,
|
|
44
56
|
value: width
|
|
45
57
|
})));
|
|
46
|
-
const
|
|
58
|
+
const resizableAvatar = createElement(ResizableBox, {
|
|
47
59
|
size: {
|
|
48
60
|
width,
|
|
49
61
|
height
|
|
@@ -65,9 +77,9 @@ export default function Edit(_ref) {
|
|
|
65
77
|
minWidth: minSize,
|
|
66
78
|
maxWidth: maxSizeBuffer
|
|
67
79
|
}, createElement("img", _extends({
|
|
68
|
-
src: avatarUrls[avatarUrls.length - 1],
|
|
80
|
+
src: avatarUrls ? avatarUrls[avatarUrls.length - 1] : avatarURL,
|
|
69
81
|
alt: `${authorName} ${__('Avatar')}`
|
|
70
|
-
}, blockProps)))
|
|
71
|
-
return createElement(Fragment, null, inspectorControls, createElement("div", spacingProps,
|
|
82
|
+
}, blockProps)));
|
|
83
|
+
return createElement(Fragment, null, inspectorControls, createElement("div", spacingProps, resizableAvatar));
|
|
72
84
|
}
|
|
73
85
|
//# sourceMappingURL=edit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/comment-author-avatar/edit.js"],"names":["InspectorControls","useBlockProps","__experimentalGetSpacingClassesAndStyles","useSpacingProps","PanelBody","ResizableBox","RangeControl","useEntityProp","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/comment-author-avatar/edit.js"],"names":["InspectorControls","useBlockProps","__experimentalGetSpacingClassesAndStyles","useSpacingProps","store","blockEditorStore","PanelBody","ResizableBox","RangeControl","useEntityProp","useSelect","__","isRTL","Edit","attributes","context","commentId","setAttributes","isSelected","height","width","avatars","authorName","avatarUrls","Object","values","sizes","keys","minSize","maxSize","length","blockProps","spacingProps","maxSizeBuffer","Math","floor","avatarURL","select","getSettings","__experimentalDiscussionSettings","inspectorControls","newWidth","resizableAvatar","event","direction","elt","delta","parseInt","top","right","bottom","left"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,iBADD,EAECC,aAFD,EAGCC,wCAAwC,IAAIC,eAH7C,EAICC,KAAK,IAAIC,gBAJV,QAKO,yBALP;AAMA,SAASC,SAAT,EAAoBC,YAApB,EAAkCC,YAAlC,QAAsD,uBAAtD;AACA,SAASC,aAAT,QAA8B,sBAA9B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,EAAT,EAAaC,KAAb,QAA0B,iBAA1B;AAEA,eAAe,SAASC,IAAT,OAKX;AAAA,MAL0B;AAC7BC,IAAAA,UAD6B;AAE7BC,IAAAA,OAAO,EAAE;AAAEC,MAAAA;AAAF,KAFoB;AAG7BC,IAAAA,aAH6B;AAI7BC,IAAAA;AAJ6B,GAK1B;AACH,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,MAAoBN,UAA1B;AAEA,QAAM,CAAEO,OAAF,IAA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\n\tInspectorControls,\n\tuseBlockProps,\n\t__experimentalGetSpacingClassesAndStyles as useSpacingProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { PanelBody, ResizableBox, RangeControl } from '@wordpress/components';\nimport { useEntityProp } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { __, isRTL } from '@wordpress/i18n';\n\nexport default function Edit( {\n\tattributes,\n\tcontext: { commentId },\n\tsetAttributes,\n\tisSelected,\n} ) {\n\tconst { height, width } = attributes;\n\n\tconst [ avatars ] = useEntityProp(\n\t\t'root',\n\t\t'comment',\n\t\t'author_avatar_urls',\n\t\tcommentId\n\t);\n\n\tconst [ authorName ] = useEntityProp(\n\t\t'root',\n\t\t'comment',\n\t\t'author_name',\n\t\tcommentId\n\t);\n\tconst avatarUrls = avatars ? Object.values( avatars ) : null;\n\tconst sizes = avatars ? Object.keys( avatars ) : null;\n\tconst minSize = sizes ? sizes[ 0 ] : 24;\n\tconst maxSize = sizes ? sizes[ sizes.length - 1 ] : 96;\n\tconst blockProps = useBlockProps();\n\tconst spacingProps = useSpacingProps( attributes );\n\tconst maxSizeBuffer = Math.floor( maxSize * 2.5 );\n\tconst { avatarURL } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { __experimentalDiscussionSettings } = getSettings();\n\t\treturn __experimentalDiscussionSettings;\n\t} );\n\n\tconst inspectorControls = (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Avatar Settings' ) }>\n\t\t\t\t<RangeControl\n\t\t\t\t\tlabel={ __( 'Image size' ) }\n\t\t\t\t\tonChange={ ( newWidth ) =>\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\twidth: newWidth,\n\t\t\t\t\t\t\theight: newWidth,\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t\tmin={ minSize }\n\t\t\t\t\tmax={ maxSizeBuffer }\n\t\t\t\t\tinitialPosition={ width }\n\t\t\t\t\tvalue={ width }\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n\n\tconst resizableAvatar = (\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\tshowHandle={ isSelected }\n\t\t\tonResizeStop={ ( event, direction, elt, delta ) => {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\theight: parseInt( height + delta.height, 10 ),\n\t\t\t\t\twidth: parseInt( width + delta.width, 10 ),\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tlockAspectRatio\n\t\t\tenable={ {\n\t\t\t\ttop: false,\n\t\t\t\tright: ! isRTL(),\n\t\t\t\tbottom: true,\n\t\t\t\tleft: isRTL(),\n\t\t\t} }\n\t\t\tminWidth={ minSize }\n\t\t\tmaxWidth={ maxSizeBuffer }\n\t\t>\n\t\t\t<img\n\t\t\t\tsrc={\n\t\t\t\t\tavatarUrls ? avatarUrls[ avatarUrls.length - 1 ] : avatarURL\n\t\t\t\t}\n\t\t\t\talt={ `${ authorName } ${ __( 'Avatar' ) }` }\n\t\t\t\t{ ...blockProps }\n\t\t\t/>\n\t\t</ResizableBox>\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ inspectorControls }\n\t\t\t<div { ...spacingProps }>{ resizableAvatar }</div>\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -4,7 +4,7 @@ import { createElement } from "@wordpress/element";
|
|
|
4
4
|
/**
|
|
5
5
|
* WordPress dependencies
|
|
6
6
|
*/
|
|
7
|
-
import { useState,
|
|
7
|
+
import { useState, memo } from '@wordpress/element';
|
|
8
8
|
import { useSelect } from '@wordpress/data';
|
|
9
9
|
import { __ } from '@wordpress/i18n';
|
|
10
10
|
import { BlockContextProvider, useBlockProps, useInnerBlocksProps, store as blockEditorStore, __experimentalUseBlockPreview as useBlockPreview } from '@wordpress/block-editor';
|
|
@@ -14,8 +14,61 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import { useCommentQueryArgs, useCommentTree } from './hooks';
|
|
18
18
|
const TEMPLATE = [['core/comment-author-avatar'], ['core/comment-author-name'], ['core/comment-date'], ['core/comment-content'], ['core/comment-reply-link'], ['core/comment-edit-link']];
|
|
19
|
+
/**
|
|
20
|
+
* Function that returns a comment structure that will be rendered with default placehoders.
|
|
21
|
+
*
|
|
22
|
+
* @param {Object} settings Discussion Settings.
|
|
23
|
+
* @param {number} [settings.perPage] - Comments per page setting or block attribute.
|
|
24
|
+
* @param {boolean} [settings.threadComments] - Enable threaded (nested) comments setting.
|
|
25
|
+
* @param {number} [settings.threadCommentsDepth] - Level deep of threaded comments.
|
|
26
|
+
*
|
|
27
|
+
* @typedef {{id: null, children: EmptyComment[]}} EmptyComment
|
|
28
|
+
* @return {EmptyComment[]} Inner blocks of the Comment Template
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
const getCommentsPlaceholder = _ref => {
|
|
32
|
+
let {
|
|
33
|
+
perPage,
|
|
34
|
+
threadComments,
|
|
35
|
+
threadCommentsDepth
|
|
36
|
+
} = _ref;
|
|
37
|
+
// In case that `threadCommentsDepth` is falsy, we default to a somewhat
|
|
38
|
+
// arbitrary value of 3.
|
|
39
|
+
// In case that the value is set but larger than 3 we truncate it to 3.
|
|
40
|
+
const commentsDepth = Math.min(threadCommentsDepth || 3, 3); // We set a limit in order not to overload the editor of empty comments.
|
|
41
|
+
|
|
42
|
+
const defaultCommentsToShow = perPage <= commentsDepth ? perPage : commentsDepth;
|
|
43
|
+
|
|
44
|
+
if (!threadComments || defaultCommentsToShow === 1) {
|
|
45
|
+
// If displaying threaded comments is disabled, we only show one comment
|
|
46
|
+
return [{
|
|
47
|
+
commentId: null,
|
|
48
|
+
children: []
|
|
49
|
+
}];
|
|
50
|
+
} else if (defaultCommentsToShow === 2) {
|
|
51
|
+
return [{
|
|
52
|
+
commentId: null,
|
|
53
|
+
children: [{
|
|
54
|
+
commentId: null,
|
|
55
|
+
children: []
|
|
56
|
+
}]
|
|
57
|
+
}];
|
|
58
|
+
} // In case that the value is set but larger than 3 we truncate it to 3.
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
return [{
|
|
62
|
+
commentId: null,
|
|
63
|
+
children: [{
|
|
64
|
+
commentId: null,
|
|
65
|
+
children: [{
|
|
66
|
+
commentId: null,
|
|
67
|
+
children: []
|
|
68
|
+
}]
|
|
69
|
+
}]
|
|
70
|
+
}];
|
|
71
|
+
};
|
|
19
72
|
/**
|
|
20
73
|
* Component which renders the inner blocks of the Comment Template.
|
|
21
74
|
*
|
|
@@ -29,7 +82,8 @@ const TEMPLATE = [['core/comment-author-avatar'], ['core/comment-author-name'],
|
|
|
29
82
|
* @return {WPElement} Inner blocks of the Comment Template
|
|
30
83
|
*/
|
|
31
84
|
|
|
32
|
-
|
|
85
|
+
|
|
86
|
+
function CommentTemplateInnerBlocks(_ref2) {
|
|
33
87
|
var _comment$children;
|
|
34
88
|
|
|
35
89
|
let {
|
|
@@ -38,7 +92,7 @@ function CommentTemplateInnerBlocks(_ref) {
|
|
|
38
92
|
setActiveComment,
|
|
39
93
|
firstComment,
|
|
40
94
|
blocks
|
|
41
|
-
} =
|
|
95
|
+
} = _ref2;
|
|
42
96
|
const {
|
|
43
97
|
children,
|
|
44
98
|
...innerBlocksProps
|
|
@@ -58,13 +112,13 @@ function CommentTemplateInnerBlocks(_ref) {
|
|
|
58
112
|
}) : null);
|
|
59
113
|
}
|
|
60
114
|
|
|
61
|
-
const CommentTemplatePreview =
|
|
115
|
+
const CommentTemplatePreview = _ref3 => {
|
|
62
116
|
let {
|
|
63
117
|
blocks,
|
|
64
118
|
comment,
|
|
65
119
|
setActiveComment,
|
|
66
120
|
isHidden
|
|
67
|
-
} =
|
|
121
|
+
} = _ref3;
|
|
68
122
|
const blockPreviewProps = useBlockPreview({
|
|
69
123
|
blocks
|
|
70
124
|
});
|
|
@@ -104,16 +158,16 @@ const MemoizedCommentTemplatePreview = memo(CommentTemplatePreview);
|
|
|
104
158
|
* @return {WPElement} List of comments.
|
|
105
159
|
*/
|
|
106
160
|
|
|
107
|
-
const CommentsList =
|
|
161
|
+
const CommentsList = _ref4 => {
|
|
108
162
|
let {
|
|
109
163
|
comments,
|
|
110
164
|
blockProps,
|
|
111
165
|
activeComment,
|
|
112
166
|
setActiveComment,
|
|
113
167
|
blocks
|
|
114
|
-
} =
|
|
115
|
-
return createElement("ol", blockProps, comments && comments.map(comment => createElement(BlockContextProvider, {
|
|
116
|
-
key: comment.commentId,
|
|
168
|
+
} = _ref4;
|
|
169
|
+
return createElement("ol", blockProps, comments && comments.map((comment, index) => createElement(BlockContextProvider, {
|
|
170
|
+
key: comment.commentId || index,
|
|
117
171
|
value: comment
|
|
118
172
|
}, createElement(CommentTemplateInnerBlocks, {
|
|
119
173
|
comment: comment,
|
|
@@ -124,28 +178,37 @@ const CommentsList = _ref3 => {
|
|
|
124
178
|
}))));
|
|
125
179
|
};
|
|
126
180
|
|
|
127
|
-
export default function CommentTemplateEdit(
|
|
181
|
+
export default function CommentTemplateEdit(_ref5) {
|
|
128
182
|
let {
|
|
129
183
|
clientId,
|
|
130
184
|
context: {
|
|
131
185
|
postId,
|
|
132
186
|
'comments/perPage': perPage,
|
|
133
|
-
'comments/order': order
|
|
187
|
+
'comments/order': order,
|
|
188
|
+
'comments/defaultPage': defaultPage,
|
|
189
|
+
'comments/inherit': inherit
|
|
134
190
|
}
|
|
135
|
-
} =
|
|
191
|
+
} = _ref5;
|
|
136
192
|
const blockProps = useBlockProps();
|
|
137
193
|
const [activeComment, setActiveComment] = useState();
|
|
138
194
|
const {
|
|
139
195
|
commentOrder,
|
|
140
|
-
|
|
196
|
+
threadCommentsDepth,
|
|
197
|
+
threadComments
|
|
141
198
|
} = useSelect(select => {
|
|
142
199
|
const {
|
|
143
200
|
getSettings
|
|
144
201
|
} = select(blockEditorStore);
|
|
145
202
|
return getSettings().__experimentalDiscussionSettings;
|
|
146
203
|
});
|
|
204
|
+
const commentQuery = useCommentQueryArgs({
|
|
205
|
+
postId,
|
|
206
|
+
perPage,
|
|
207
|
+
defaultPage,
|
|
208
|
+
inherit
|
|
209
|
+
});
|
|
147
210
|
const {
|
|
148
|
-
|
|
211
|
+
topLevelComments,
|
|
149
212
|
blocks
|
|
150
213
|
} = useSelect(select => {
|
|
151
214
|
const {
|
|
@@ -154,40 +217,35 @@ export default function CommentTemplateEdit(_ref4) {
|
|
|
154
217
|
const {
|
|
155
218
|
getBlocks
|
|
156
219
|
} = select(blockEditorStore);
|
|
157
|
-
const commentQuery = {
|
|
158
|
-
post: postId,
|
|
159
|
-
status: 'approve',
|
|
160
|
-
context: 'embed',
|
|
161
|
-
order: order || commentOrder
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
if (order) {
|
|
165
|
-
commentQuery.order = order;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
220
|
return {
|
|
169
|
-
|
|
221
|
+
// Request only top-level comments. Replies are embedded.
|
|
222
|
+
topLevelComments: commentQuery ? getEntityRecords('root', 'comment', commentQuery) : null,
|
|
170
223
|
blocks: getBlocks(clientId)
|
|
171
224
|
};
|
|
172
|
-
}, [
|
|
225
|
+
}, [clientId, commentQuery]);
|
|
226
|
+
order = inherit || !order ? commentOrder : order; // Generate a tree structure of comment IDs.
|
|
173
227
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
// This is because passing `per_page` to `getEntityRecords()` does not
|
|
177
|
-
// take into account nested comments.
|
|
228
|
+
let commentTree = useCommentTree( // Reverse the order of top comments if needed.
|
|
229
|
+
order === 'desc' && topLevelComments ? [...topLevelComments].reverse() : topLevelComments);
|
|
178
230
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
if (!rawComments) {
|
|
231
|
+
if (!topLevelComments) {
|
|
182
232
|
return createElement("p", blockProps, createElement(Spinner, null));
|
|
183
233
|
}
|
|
184
234
|
|
|
185
|
-
if (!
|
|
235
|
+
if (!postId) {
|
|
236
|
+
commentTree = getCommentsPlaceholder({
|
|
237
|
+
perPage,
|
|
238
|
+
threadComments,
|
|
239
|
+
threadCommentsDepth
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (!commentTree.length) {
|
|
186
244
|
return createElement("p", blockProps, " ", __('No results found.'));
|
|
187
245
|
}
|
|
188
246
|
|
|
189
247
|
return createElement(CommentsList, {
|
|
190
|
-
comments:
|
|
248
|
+
comments: commentTree,
|
|
191
249
|
blockProps: blockProps,
|
|
192
250
|
blocks: blocks,
|
|
193
251
|
activeComment: activeComment,
|