@wordpress/block-library 9.45.0 → 9.45.1-next.v.202605131006.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/build/breadcrumbs/edit.cjs +1 -1
- package/build/breadcrumbs/edit.cjs.map +1 -1
- package/build/buttons/edit.cjs +0 -13
- package/build/buttons/edit.cjs.map +3 -3
- package/build/comment-reply-link/edit.cjs +2 -1
- package/build/comment-reply-link/edit.cjs.map +2 -2
- package/build/comments/edit/placeholder.cjs +2 -1
- package/build/comments/edit/placeholder.cjs.map +2 -2
- package/build/embed/transforms.cjs +24 -1
- package/build/embed/transforms.cjs.map +2 -2
- package/build/freeform/convert-to-blocks-button.cjs +2 -14
- package/build/freeform/convert-to-blocks-button.cjs.map +3 -3
- package/build/freeform/edit.cjs +43 -15
- package/build/freeform/edit.cjs.map +3 -3
- package/build/freeform/index.cjs +7 -1
- package/build/freeform/index.cjs.map +3 -3
- package/build/freeform/migration-notice.cjs +58 -0
- package/build/freeform/migration-notice.cjs.map +7 -0
- package/build/image/image.cjs +16 -52
- package/build/image/image.cjs.map +3 -3
- package/build/image/use-open-image-media-editor-modal.cjs +239 -0
- package/build/image/use-open-image-media-editor-modal.cjs.map +7 -0
- package/build/index.cjs +1 -5
- package/build/index.cjs.map +2 -2
- package/build/shortcode/transforms.cjs +27 -1
- package/build/shortcode/transforms.cjs.map +2 -2
- package/build/site-logo/edit.cjs +1 -0
- package/build/site-logo/edit.cjs.map +2 -2
- package/build/table/edit.cjs +2 -2
- package/build/table/edit.cjs.map +2 -2
- package/build-module/breadcrumbs/edit.mjs +1 -1
- package/build-module/breadcrumbs/edit.mjs.map +1 -1
- package/build-module/buttons/edit.mjs +0 -13
- package/build-module/buttons/edit.mjs.map +2 -2
- package/build-module/comment-reply-link/edit.mjs +3 -2
- package/build-module/comment-reply-link/edit.mjs.map +2 -2
- package/build-module/comments/edit/placeholder.mjs +3 -2
- package/build-module/comments/edit/placeholder.mjs.map +2 -2
- package/build-module/embed/transforms.mjs +24 -1
- package/build-module/embed/transforms.mjs.map +2 -2
- package/build-module/freeform/convert-to-blocks-button.mjs +3 -15
- package/build-module/freeform/convert-to-blocks-button.mjs.map +2 -2
- package/build-module/freeform/edit.mjs +44 -16
- package/build-module/freeform/edit.mjs.map +2 -2
- package/build-module/freeform/index.mjs +7 -1
- package/build-module/freeform/index.mjs.map +2 -2
- package/build-module/freeform/migration-notice.mjs +37 -0
- package/build-module/freeform/migration-notice.mjs.map +7 -0
- package/build-module/image/image.mjs +16 -52
- package/build-module/image/image.mjs.map +3 -3
- package/build-module/image/use-open-image-media-editor-modal.mjs +215 -0
- package/build-module/image/use-open-image-media-editor-modal.mjs.map +7 -0
- package/build-module/index.mjs +1 -5
- package/build-module/index.mjs.map +2 -2
- package/build-module/shortcode/transforms.mjs +27 -1
- package/build-module/shortcode/transforms.mjs.map +2 -2
- package/build-module/site-logo/edit.mjs +1 -0
- package/build-module/site-logo/edit.mjs.map +2 -2
- package/build-module/table/edit.mjs +3 -3
- package/build-module/table/edit.mjs.map +2 -2
- package/build-types/table-of-contents/list.d.ts +1 -1
- package/build-types/table-of-contents/list.d.ts.map +1 -1
- package/package.json +41 -40
- package/src/breadcrumbs/edit.js +1 -1
- package/src/buttons/edit.js +0 -13
- package/src/comment-reply-link/edit.js +5 -2
- package/src/comments/edit/placeholder.js +5 -2
- package/src/cover/editor.scss +2 -2
- package/src/cover/style.scss +10 -6
- package/src/embed/transforms.js +30 -4
- package/src/freeform/convert-to-blocks-button.js +3 -18
- package/src/freeform/edit.js +40 -7
- package/src/freeform/index.js +9 -1
- package/src/freeform/migration-notice.js +51 -0
- package/src/image/image.js +14 -63
- package/src/image/test/use-open-image-media-editor-modal.js +791 -0
- package/src/image/use-open-image-media-editor-modal.js +337 -0
- package/src/index.js +3 -16
- package/src/navigation/index.php +11 -1
- package/src/query/editor.scss +1 -2
- package/src/shortcode/transforms.js +37 -0
- package/src/site-logo/edit.js +5 -0
- package/src/table/edit.js +3 -3
- package/src/template-part/editor.scss +1 -1
|
@@ -263,7 +263,7 @@ function BreadcrumbEdit({
|
|
|
263
263
|
checked: showOnHomePage,
|
|
264
264
|
onChange: (value) => setAttributes({ showOnHomePage: value }),
|
|
265
265
|
help: (0, import_i18n.__)(
|
|
266
|
-
"If this
|
|
266
|
+
"If this Breadcrumbs block appears in a template or template part that\u2019s shown on the homepage, enable this option to display the breadcrumb trail. Otherwise, this setting has no effect."
|
|
267
267
|
)
|
|
268
268
|
}
|
|
269
269
|
),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/breadcrumbs/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { InspectorControls, useBlockProps } from '@wordpress/block-editor';\nimport {\n\tToggleControl,\n\tTextControl,\n\tCheckboxControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\tSpinner,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport { useServerSideRender } from '@wordpress/server-side-render';\nimport { useDisabled } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\nimport HtmlRenderer from '../utils/html-renderer';\n\nconst separatorDefaultValue = '/';\n\nexport default function BreadcrumbEdit( {\n\tattributes,\n\tsetAttributes,\n\tname,\n\tcontext: { postId, postType, templateSlug },\n} ) {\n\tconst {\n\t\tseparator,\n\t\tshowHomeItem,\n\t\tshowCurrentItem,\n\t\tprefersTaxonomy,\n\t\tshowOnHomePage,\n\t} = attributes;\n\tconst {\n\t\tpost,\n\t\tisPostTypeHierarchical,\n\t\tpostTypeHasTaxonomies,\n\t\thasTermsAssigned,\n\t\tisLoading,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! postType ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst _post = select( coreStore ).getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId\n\t\t\t);\n\t\t\tconst postTypeObject = select( coreStore ).getPostType( postType );\n\t\t\tconst _postTypeHasTaxonomies =\n\t\t\t\tpostTypeObject && postTypeObject.taxonomies.length;\n\t\t\tlet taxonomies;\n\t\t\tif ( _postTypeHasTaxonomies ) {\n\t\t\t\ttaxonomies = select( coreStore ).getTaxonomies( {\n\t\t\t\t\ttype: postType,\n\t\t\t\t\tper_page: -1,\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tpost: _post,\n\t\t\t\tisPostTypeHierarchical: postTypeObject?.hierarchical,\n\t\t\t\tpostTypeHasTaxonomies: _postTypeHasTaxonomies,\n\t\t\t\thasTermsAssigned:\n\t\t\t\t\t_post &&\n\t\t\t\t\t( taxonomies || [] )\n\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t( { visibility } ) => visibility?.publicly_queryable\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.some( ( taxonomy ) => {\n\t\t\t\t\t\t\treturn !! _post[ taxonomy.rest_base ]?.length;\n\t\t\t\t\t\t} ),\n\t\t\t\tisLoading:\n\t\t\t\t\t( postId && ! _post ) ||\n\t\t\t\t\t! postTypeObject ||\n\t\t\t\t\t( _postTypeHasTaxonomies && ! taxonomies ),\n\t\t\t};\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\t/**\n\t * Counter used to cache-bust `useServerSideRender`.\n\t *\n\t * This is a catch-all signal to re-render the block when a post's title,\n\t * parent ID, or terms change.\n\t *\n\t * This is fundamentally imperfect, because there are other entities which\n\t * could change in the meantime (the titles of ancestor posts, or the\n\t * labels of taxonomy terms), hence the choice to re-render systematically\n\t * upon saving.\n\t */\n\tconst [ invalidationKey, setInvalidationKey ] = useState( 0 );\n\tuseEffect( () => {\n\t\tsetInvalidationKey( ( c ) => c + 1 );\n\t}, [ post ] );\n\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst { content, status, error } = useServerSideRender( {\n\t\tattributes,\n\t\tskipBlockSupportAttributes: true,\n\t\tblock: name,\n\t\turlQueryArgs: { post_id: postId, invalidationKey },\n\t} );\n\tconst prevContentRef = useRef( '' );\n\tuseEffect( () => {\n\t\tif ( status === 'success' ) {\n\t\t\tprevContentRef.current = content;\n\t\t}\n\t}, [ content, status ] );\n\tconst [ showLoader, setShowLoader ] = useState( false );\n\tuseEffect( () => {\n\t\tif ( status !== 'loading' ) {\n\t\t\treturn;\n\t\t}\n\t\tconst timeout = setTimeout( () => {\n\t\t\tsetShowLoader( true );\n\t\t}, 400 );\n\t\treturn () => {\n\t\t\tclearTimeout( timeout );\n\t\t\tsetShowLoader( false );\n\t\t};\n\t}, [ status ] );\n\tconst disabledRef = useDisabled();\n\tconst blockProps = useBlockProps( { ref: disabledRef } );\n\n\tif ( isLoading ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Spinner />\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Try to determine breadcrumb type for more accurate previews.\n\tlet _showTerms;\n\t// Some non-hierarchical post types (e.g., attachments) can have parents.\n\t// Use hierarchical breadcrumbs if a parent exists, otherwise use taxonomy breadcrumbs.\n\tif ( ! isPostTypeHierarchical && ! post?.parent ) {\n\t\t_showTerms = true;\n\t} else if ( ! postTypeHasTaxonomies ) {\n\t\t// Hierarchical post type without taxonomies can only use ancestors.\n\t\t_showTerms = false;\n\t} else {\n\t\t// For hierarchical post types with taxonomies, use the attribute.\n\t\t_showTerms = prefersTaxonomy;\n\t}\n\tlet placeholder = null;\n\t// This is fragile because this block is server side rendered and we'll have to\n\t// update the placeholder html if the server side rendering output changes.\n\tconst showPlaceholder =\n\t\t! postId ||\n\t\t! postType ||\n\t\t// When `templateSlug` is set only show placeholder if the post type is not.\n\t\t// This is needed because when we are showing the template in post editor we\n\t\t// want to show the real breadcrumbs if we have the post type.\n\t\t( templateSlug && ! postType ) ||\n\t\t( ! _showTerms && ! isPostTypeHierarchical ) ||\n\t\t( _showTerms && ! hasTermsAssigned );\n\tif ( showPlaceholder ) {\n\t\tconst placeholderItems = [];\n\t\tif ( showHomeItem ) {\n\t\t\tplaceholderItems.push( __( 'Home' ) );\n\t\t}\n\t\tif ( templateSlug && ! postId ) {\n\t\t\tplaceholderItems.push( __( 'Page' ) );\n\t\t} else if ( _showTerms ) {\n\t\t\tplaceholderItems.push( __( 'Category' ) );\n\t\t} else {\n\t\t\tplaceholderItems.push( __( 'Ancestor' ), __( 'Parent' ) );\n\t\t}\n\t\tplaceholder = (\n\t\t\t<nav\n\t\t\t\t{ ...blockProps }\n\t\t\t\tstyle={ {\n\t\t\t\t\t'--separator': `\"${ separator\n\t\t\t\t\t\t.replace( /\\\\/g, '\\\\\\\\' )\n\t\t\t\t\t\t.replace( /\"/g, '\\\\\"' ) }\"`,\n\t\t\t\t\t...blockProps.style,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<ol>\n\t\t\t\t\t{ placeholderItems.map( ( text, index ) => (\n\t\t\t\t\t\t<li key={ index }>\n\t\t\t\t\t\t\t<a href={ `#breadcrumbs-pseudo-link-${ index }` }>\n\t\t\t\t\t\t\t\t{ text }\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t) ) }\n\t\t\t\t\t{ showCurrentItem && (\n\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t<span aria-current=\"page\">{ __( 'Current' ) }</span>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t) }\n\t\t\t\t</ol>\n\t\t\t</nav>\n\t\t);\n\t}\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tseparator: separatorDefaultValue,\n\t\t\t\t\t\t\tshowHomeItem: true,\n\t\t\t\t\t\t\tshowCurrentItem: true,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Show home breadcrumb' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => ! showHomeItem }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowHomeItem: true,\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\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Show home breadcrumb' ) }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { showHomeItem: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tchecked={ showHomeItem }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Show current breadcrumb' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => ! showCurrentItem }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowCurrentItem: true,\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\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Show current breadcrumb' ) }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { showCurrentItem: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tchecked={ showCurrentItem }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Separator' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => separator !== separatorDefaultValue }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tseparator: separatorDefaultValue,\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\t<TextControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\t\tlabel={ __( 'Separator' ) }\n\t\t\t\t\t\t\tvalue={ separator }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { separator: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonBlur={ () => {\n\t\t\t\t\t\t\t\tif ( ! separator ) {\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tseparator: separatorDefaultValue,\n\t\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} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<CheckboxControl\n\t\t\t\t\tlabel={ __( 'Show on homepage' ) }\n\t\t\t\t\tchecked={ showOnHomePage }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { showOnHomePage: value } )\n\t\t\t\t\t}\n\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t'If this breadcrumbs block appears in a template or template part that\u2019s shown on the homepage, enable this option to display the breadcrumb trail. Otherwise, this setting has no effect.'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t\t<CheckboxControl\n\t\t\t\t\tlabel={ __( 'Prefer taxonomy terms' ) }\n\t\t\t\t\tchecked={ prefersTaxonomy }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { prefersTaxonomy: value } )\n\t\t\t\t\t}\n\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t'The exact type of breadcrumbs shown will vary automatically depending on the page in which this block is displayed. In the specific case of a hierarchical post type with taxonomies, the breadcrumbs can either reflect its post hierarchy (default) or the hierarchy of its assigned taxonomy terms.'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t{ status === 'loading' &&\n\t\t\t\t! showPlaceholder &&\n\t\t\t\t( prevContentRef.current ? (\n\t\t\t\t\t<HtmlRenderer\n\t\t\t\t\t\twrapperProps={ {\n\t\t\t\t\t\t\t...blockProps,\n\t\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t\t...blockProps.style,\n\t\t\t\t\t\t\t\topacity: showLoader ? 0.3 : 1,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} }\n\t\t\t\t\t\thtml={ prevContentRef.current }\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<div { ...blockProps }>\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t</div>\n\t\t\t\t) ) }\n\t\t\t{ status === 'error' && (\n\t\t\t\t<div { ...blockProps }>\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t/* translators: %s: error message returned when rendering the block. */\n\t\t\t\t\t\t\t__( 'Error: %s' ),\n\t\t\t\t\t\t\terror\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ showPlaceholder && placeholder }\n\t\t\t{ ! showPlaceholder && status === 'success' && (\n\t\t\t\t<HtmlRenderer wrapperProps={ blockProps } html={ content } />\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { InspectorControls, useBlockProps } from '@wordpress/block-editor';\nimport {\n\tToggleControl,\n\tTextControl,\n\tCheckboxControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\tSpinner,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport { useServerSideRender } from '@wordpress/server-side-render';\nimport { useDisabled } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\nimport HtmlRenderer from '../utils/html-renderer';\n\nconst separatorDefaultValue = '/';\n\nexport default function BreadcrumbEdit( {\n\tattributes,\n\tsetAttributes,\n\tname,\n\tcontext: { postId, postType, templateSlug },\n} ) {\n\tconst {\n\t\tseparator,\n\t\tshowHomeItem,\n\t\tshowCurrentItem,\n\t\tprefersTaxonomy,\n\t\tshowOnHomePage,\n\t} = attributes;\n\tconst {\n\t\tpost,\n\t\tisPostTypeHierarchical,\n\t\tpostTypeHasTaxonomies,\n\t\thasTermsAssigned,\n\t\tisLoading,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! postType ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst _post = select( coreStore ).getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId\n\t\t\t);\n\t\t\tconst postTypeObject = select( coreStore ).getPostType( postType );\n\t\t\tconst _postTypeHasTaxonomies =\n\t\t\t\tpostTypeObject && postTypeObject.taxonomies.length;\n\t\t\tlet taxonomies;\n\t\t\tif ( _postTypeHasTaxonomies ) {\n\t\t\t\ttaxonomies = select( coreStore ).getTaxonomies( {\n\t\t\t\t\ttype: postType,\n\t\t\t\t\tper_page: -1,\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tpost: _post,\n\t\t\t\tisPostTypeHierarchical: postTypeObject?.hierarchical,\n\t\t\t\tpostTypeHasTaxonomies: _postTypeHasTaxonomies,\n\t\t\t\thasTermsAssigned:\n\t\t\t\t\t_post &&\n\t\t\t\t\t( taxonomies || [] )\n\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t( { visibility } ) => visibility?.publicly_queryable\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.some( ( taxonomy ) => {\n\t\t\t\t\t\t\treturn !! _post[ taxonomy.rest_base ]?.length;\n\t\t\t\t\t\t} ),\n\t\t\t\tisLoading:\n\t\t\t\t\t( postId && ! _post ) ||\n\t\t\t\t\t! postTypeObject ||\n\t\t\t\t\t( _postTypeHasTaxonomies && ! taxonomies ),\n\t\t\t};\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\t/**\n\t * Counter used to cache-bust `useServerSideRender`.\n\t *\n\t * This is a catch-all signal to re-render the block when a post's title,\n\t * parent ID, or terms change.\n\t *\n\t * This is fundamentally imperfect, because there are other entities which\n\t * could change in the meantime (the titles of ancestor posts, or the\n\t * labels of taxonomy terms), hence the choice to re-render systematically\n\t * upon saving.\n\t */\n\tconst [ invalidationKey, setInvalidationKey ] = useState( 0 );\n\tuseEffect( () => {\n\t\tsetInvalidationKey( ( c ) => c + 1 );\n\t}, [ post ] );\n\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst { content, status, error } = useServerSideRender( {\n\t\tattributes,\n\t\tskipBlockSupportAttributes: true,\n\t\tblock: name,\n\t\turlQueryArgs: { post_id: postId, invalidationKey },\n\t} );\n\tconst prevContentRef = useRef( '' );\n\tuseEffect( () => {\n\t\tif ( status === 'success' ) {\n\t\t\tprevContentRef.current = content;\n\t\t}\n\t}, [ content, status ] );\n\tconst [ showLoader, setShowLoader ] = useState( false );\n\tuseEffect( () => {\n\t\tif ( status !== 'loading' ) {\n\t\t\treturn;\n\t\t}\n\t\tconst timeout = setTimeout( () => {\n\t\t\tsetShowLoader( true );\n\t\t}, 400 );\n\t\treturn () => {\n\t\t\tclearTimeout( timeout );\n\t\t\tsetShowLoader( false );\n\t\t};\n\t}, [ status ] );\n\tconst disabledRef = useDisabled();\n\tconst blockProps = useBlockProps( { ref: disabledRef } );\n\n\tif ( isLoading ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Spinner />\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Try to determine breadcrumb type for more accurate previews.\n\tlet _showTerms;\n\t// Some non-hierarchical post types (e.g., attachments) can have parents.\n\t// Use hierarchical breadcrumbs if a parent exists, otherwise use taxonomy breadcrumbs.\n\tif ( ! isPostTypeHierarchical && ! post?.parent ) {\n\t\t_showTerms = true;\n\t} else if ( ! postTypeHasTaxonomies ) {\n\t\t// Hierarchical post type without taxonomies can only use ancestors.\n\t\t_showTerms = false;\n\t} else {\n\t\t// For hierarchical post types with taxonomies, use the attribute.\n\t\t_showTerms = prefersTaxonomy;\n\t}\n\tlet placeholder = null;\n\t// This is fragile because this block is server side rendered and we'll have to\n\t// update the placeholder html if the server side rendering output changes.\n\tconst showPlaceholder =\n\t\t! postId ||\n\t\t! postType ||\n\t\t// When `templateSlug` is set only show placeholder if the post type is not.\n\t\t// This is needed because when we are showing the template in post editor we\n\t\t// want to show the real breadcrumbs if we have the post type.\n\t\t( templateSlug && ! postType ) ||\n\t\t( ! _showTerms && ! isPostTypeHierarchical ) ||\n\t\t( _showTerms && ! hasTermsAssigned );\n\tif ( showPlaceholder ) {\n\t\tconst placeholderItems = [];\n\t\tif ( showHomeItem ) {\n\t\t\tplaceholderItems.push( __( 'Home' ) );\n\t\t}\n\t\tif ( templateSlug && ! postId ) {\n\t\t\tplaceholderItems.push( __( 'Page' ) );\n\t\t} else if ( _showTerms ) {\n\t\t\tplaceholderItems.push( __( 'Category' ) );\n\t\t} else {\n\t\t\tplaceholderItems.push( __( 'Ancestor' ), __( 'Parent' ) );\n\t\t}\n\t\tplaceholder = (\n\t\t\t<nav\n\t\t\t\t{ ...blockProps }\n\t\t\t\tstyle={ {\n\t\t\t\t\t'--separator': `\"${ separator\n\t\t\t\t\t\t.replace( /\\\\/g, '\\\\\\\\' )\n\t\t\t\t\t\t.replace( /\"/g, '\\\\\"' ) }\"`,\n\t\t\t\t\t...blockProps.style,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<ol>\n\t\t\t\t\t{ placeholderItems.map( ( text, index ) => (\n\t\t\t\t\t\t<li key={ index }>\n\t\t\t\t\t\t\t<a href={ `#breadcrumbs-pseudo-link-${ index }` }>\n\t\t\t\t\t\t\t\t{ text }\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t) ) }\n\t\t\t\t\t{ showCurrentItem && (\n\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t<span aria-current=\"page\">{ __( 'Current' ) }</span>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t) }\n\t\t\t\t</ol>\n\t\t\t</nav>\n\t\t);\n\t}\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tseparator: separatorDefaultValue,\n\t\t\t\t\t\t\tshowHomeItem: true,\n\t\t\t\t\t\t\tshowCurrentItem: true,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Show home breadcrumb' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => ! showHomeItem }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowHomeItem: true,\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\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Show home breadcrumb' ) }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { showHomeItem: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tchecked={ showHomeItem }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Show current breadcrumb' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => ! showCurrentItem }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowCurrentItem: true,\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\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Show current breadcrumb' ) }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { showCurrentItem: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tchecked={ showCurrentItem }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Separator' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => separator !== separatorDefaultValue }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tseparator: separatorDefaultValue,\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\t<TextControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\t\tlabel={ __( 'Separator' ) }\n\t\t\t\t\t\t\tvalue={ separator }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { separator: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonBlur={ () => {\n\t\t\t\t\t\t\t\tif ( ! separator ) {\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tseparator: separatorDefaultValue,\n\t\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} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<CheckboxControl\n\t\t\t\t\tlabel={ __( 'Show on homepage' ) }\n\t\t\t\t\tchecked={ showOnHomePage }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { showOnHomePage: value } )\n\t\t\t\t\t}\n\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t'If this Breadcrumbs block appears in a template or template part that\u2019s shown on the homepage, enable this option to display the breadcrumb trail. Otherwise, this setting has no effect.'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t\t<CheckboxControl\n\t\t\t\t\tlabel={ __( 'Prefer taxonomy terms' ) }\n\t\t\t\t\tchecked={ prefersTaxonomy }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { prefersTaxonomy: value } )\n\t\t\t\t\t}\n\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t'The exact type of breadcrumbs shown will vary automatically depending on the page in which this block is displayed. In the specific case of a hierarchical post type with taxonomies, the breadcrumbs can either reflect its post hierarchy (default) or the hierarchy of its assigned taxonomy terms.'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t{ status === 'loading' &&\n\t\t\t\t! showPlaceholder &&\n\t\t\t\t( prevContentRef.current ? (\n\t\t\t\t\t<HtmlRenderer\n\t\t\t\t\t\twrapperProps={ {\n\t\t\t\t\t\t\t...blockProps,\n\t\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t\t...blockProps.style,\n\t\t\t\t\t\t\t\topacity: showLoader ? 0.3 : 1,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} }\n\t\t\t\t\t\thtml={ prevContentRef.current }\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<div { ...blockProps }>\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t</div>\n\t\t\t\t) ) }\n\t\t\t{ status === 'error' && (\n\t\t\t\t<div { ...blockProps }>\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t/* translators: %s: error message returned when rendering the block. */\n\t\t\t\t\t\t\t__( 'Error: %s' ),\n\t\t\t\t\t\t\terror\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ showPlaceholder && placeholder }\n\t\t\t{ ! showPlaceholder && status === 'success' && (\n\t\t\t\t<HtmlRenderer wrapperProps={ blockProps } html={ content } />\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA4B;AAC5B,0BAAiD;AACjD,wBAOO;AACP,kBAA0B;AAC1B,uBAAmC;AACnC,qBAA4C;AAC5C,gCAAoC;AACpC,qBAA4B;AAK5B,mBAA+C;AAC/C,2BAAyB;AAiHrB;AA/GJ,IAAM,wBAAwB;AAEf,SAAR,eAAiC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS,EAAE,QAAQ,UAAU,aAAa;AAC3C,GAAI;AACH,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AACJ,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,E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A,UACH,OAAO;AAAA,YACN,GAAG,WAAW;AAAA,YACd,SAAS,aAAa,MAAM;AAAA,UAC7B;AAAA,QACD;AAAA,QACA,MAAO,eAAe;AAAA;AAAA,IACvB,IAEA,4CAAC,SAAM,GAAG,YACT,sDAAC,6BAAQ,GACV;AAAA,IAEA,WAAW,WACZ,4CAAC,SAAM,GAAG,YACT,sDAAC,OACE;AAAA;AAAA,UAED,gBAAI,WAAY;AAAA,MAChB;AAAA,IACD,GACD,GACD;AAAA,IAEC,mBAAmB;AAAA,IACnB,CAAE,mBAAmB,WAAW,aACjC,4CAAC,qBAAAA,SAAA,EAAa,cAAe,YAAa,MAAO,SAAU;AAAA,KAE7D;AAEF;",
|
|
6
6
|
"names": ["coreStore", "ToolsPanel", "ToolsPanelItem", "HtmlRenderer"]
|
|
7
7
|
}
|
package/build/buttons/edit.cjs
CHANGED
|
@@ -35,8 +35,6 @@ __export(edit_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(edit_exports);
|
|
36
36
|
var import_clsx = __toESM(require("clsx"));
|
|
37
37
|
var import_block_editor = require("@wordpress/block-editor");
|
|
38
|
-
var import_data = require("@wordpress/data");
|
|
39
|
-
var import_blocks = require("@wordpress/blocks");
|
|
40
38
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
41
39
|
var DEFAULT_BLOCK = {
|
|
42
40
|
name: "core/button",
|
|
@@ -59,19 +57,8 @@ function ButtonsEdit({ attributes, className }) {
|
|
|
59
57
|
"has-custom-font-size": fontSize || style?.typography?.fontSize
|
|
60
58
|
})
|
|
61
59
|
});
|
|
62
|
-
const { hasButtonVariations } = (0, import_data.useSelect)((select) => {
|
|
63
|
-
const buttonVariations = select(import_blocks.store).getBlockVariations(
|
|
64
|
-
"core/button",
|
|
65
|
-
"inserter"
|
|
66
|
-
);
|
|
67
|
-
return {
|
|
68
|
-
hasButtonVariations: buttonVariations.length > 0
|
|
69
|
-
};
|
|
70
|
-
}, []);
|
|
71
60
|
const innerBlocksProps = (0, import_block_editor.useInnerBlocksProps)(blockProps, {
|
|
72
61
|
defaultBlock: DEFAULT_BLOCK,
|
|
73
|
-
// This check should be handled by the `Inserter` internally to be consistent across all blocks that use it.
|
|
74
|
-
directInsert: !hasButtonVariations,
|
|
75
62
|
template: [["core/button"]],
|
|
76
63
|
templateInsertUpdatesSelection: true,
|
|
77
64
|
orientation: layout?.orientation ?? "horizontal"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/buttons/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,0BAAmD;
|
|
6
|
-
"names": ["clsx"
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';\n\nconst DEFAULT_BLOCK = {\n\tname: 'core/button',\n\tattributesToCopy: [\n\t\t'backgroundColor',\n\t\t'border',\n\t\t'className',\n\t\t'fontFamily',\n\t\t'fontSize',\n\t\t'gradient',\n\t\t'style',\n\t\t'textColor',\n\t\t'width',\n\t],\n};\n\nfunction ButtonsEdit( { attributes, className } ) {\n\tconst { fontSize, layout, style } = attributes;\n\tconst blockProps = useBlockProps( {\n\t\tclassName: clsx( className, {\n\t\t\t'has-custom-font-size': fontSize || style?.typography?.fontSize,\n\t\t} ),\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tdefaultBlock: DEFAULT_BLOCK,\n\t\ttemplate: [ [ 'core/button' ] ],\n\t\ttemplateInsertUpdatesSelection: true,\n\t\torientation: layout?.orientation ?? 'horizontal',\n\t} );\n\n\treturn <div { ...innerBlocksProps } />;\n}\n\nexport default ButtonsEdit;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,0BAAmD;AAgC3C;AA9BR,IAAM,gBAAgB;AAAA,EACrB,MAAM;AAAA,EACN,kBAAkB;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;AAEA,SAAS,YAAa,EAAE,YAAY,UAAU,GAAI;AACjD,QAAM,EAAE,UAAU,QAAQ,MAAM,IAAI;AACpC,QAAM,iBAAa,mCAAe;AAAA,IACjC,eAAW,YAAAA,SAAM,WAAW;AAAA,MAC3B,wBAAwB,YAAY,OAAO,YAAY;AAAA,IACxD,CAAE;AAAA,EACH,CAAE;AAEF,QAAM,uBAAmB,yCAAqB,YAAY;AAAA,IACzD,cAAc;AAAA,IACd,UAAU,CAAE,CAAE,aAAc,CAAE;AAAA,IAC9B,gCAAgC;AAAA,IAChC,aAAa,QAAQ,eAAe;AAAA,EACrC,CAAE;AAEF,SAAO,4CAAC,SAAM,GAAG,kBAAmB;AACrC;AAEA,IAAO,eAAQ;",
|
|
6
|
+
"names": ["clsx"]
|
|
7
7
|
}
|
|
@@ -45,7 +45,8 @@ function Edit(props) {
|
|
|
45
45
|
{
|
|
46
46
|
href: "#comment-reply-pseudo-link",
|
|
47
47
|
onClick: (event) => event.preventDefault(),
|
|
48
|
-
|
|
48
|
+
/* translators: Comment reply button text. */
|
|
49
|
+
children: (0, import_i18n._x)("Reply", "verb")
|
|
49
50
|
}
|
|
50
51
|
) }) });
|
|
51
52
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/comment-reply-link/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,0BAA8B;AAK9B,8CAAmC;AAOjC;AALF,SAAS,KAAM,OAAQ;AACtB,8CAAAA,SAAwB,KAAM;AAC9B,QAAM,iBAAa,mCAAc;AAEjC,SACC,2EACC,sDAAC,SAAM,GAAG,YACT;AAAA,IAAC;AAAA;AAAA,MACA,MAAK;AAAA,MACL,SAAU,CAAE,UAAW,MAAM,eAAe;AAAA,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\nimport { useBlockProps } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport useDeprecatedTextAlign from '../utils/deprecated-text-align-attributes';\n\nfunction Edit( props ) {\n\tuseDeprecatedTextAlign( props );\n\tconst blockProps = useBlockProps();\n\n\treturn (\n\t\t<>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<a\n\t\t\t\t\thref=\"#comment-reply-pseudo-link\"\n\t\t\t\t\tonClick={ ( event ) => event.preventDefault() }\n\t\t\t\t>\n\t\t\t\t\t{\n\t\t\t\t\t\t/* translators: Comment reply button text. */\n\t\t\t\t\t\t_x( 'Reply', 'verb' )\n\t\t\t\t\t}\n\t\t\t\t</a>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default Edit;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,0BAA8B;AAK9B,8CAAmC;AAOjC;AALF,SAAS,KAAM,OAAQ;AACtB,8CAAAA,SAAwB,KAAM;AAC9B,QAAM,iBAAa,mCAAc;AAEjC,SACC,2EACC,sDAAC,SAAM,GAAG,YACT;AAAA,IAAC;AAAA;AAAA,MACA,MAAK;AAAA,MACL,SAAU,CAAE,UAAW,MAAM,eAAe;AAAA;AAAA,MAI3C,8BAAI,SAAS,MAAO;AAAA;AAAA,EAEtB,GACD,GACD;AAEF;AAEA,IAAO,eAAQ;",
|
|
6
6
|
"names": ["useDeprecatedTextAlign"]
|
|
7
7
|
}
|
|
@@ -123,7 +123,8 @@ function PostCommentsPlaceholder({ postType, postId }) {
|
|
|
123
123
|
"aria-label": (0, import_i18n.__)(
|
|
124
124
|
"Reply to A WordPress Commenter"
|
|
125
125
|
),
|
|
126
|
-
|
|
126
|
+
/* translators: Comment reply button text. */
|
|
127
|
+
children: (0, import_i18n._x)("Reply", "verb")
|
|
127
128
|
}
|
|
128
129
|
) })
|
|
129
130
|
] }) }) }),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/comments/edit/placeholder.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { useEntityProp } from '@wordpress/core-data';\nimport { createInterpolateElement } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport CommentsForm from '../../post-comments-form/form';\n\nexport default function PostCommentsPlaceholder( { postType, postId } ) {\n\tlet [ postTitle ] = useEntityProp( 'postType', postType, 'title', postId );\n\tpostTitle = postTitle || __( 'Post Title' );\n\n\tconst avatarURL = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings()\n\t\t\t\t.__experimentalDiscussionSettings?.avatarURL,\n\t\t[]\n\t);\n\n\treturn (\n\t\t<div className=\"wp-block-comments__legacy-placeholder\" inert=\"true\">\n\t\t\t<h3>\n\t\t\t\t{\n\t\t\t\t\t/* translators: %s: Post title. */\n\t\t\t\t\tsprintf( __( 'One response to %s' ), postTitle )\n\t\t\t\t}\n\t\t\t</h3>\n\n\t\t\t<div className=\"navigation\">\n\t\t\t\t<div className=\"alignleft\">\n\t\t\t\t\t<a href=\"#top\">\u00AB { __( 'Older Comments' ) }</a>\n\t\t\t\t</div>\n\t\t\t\t<div className=\"alignright\">\n\t\t\t\t\t<a href=\"#top\">{ __( 'Newer Comments' ) } \u00BB</a>\n\t\t\t\t</div>\n\t\t\t</div>\n\n\t\t\t<ol className=\"commentlist\">\n\t\t\t\t<li className=\"comment even thread-even depth-1\">\n\t\t\t\t\t<article className=\"comment-body\">\n\t\t\t\t\t\t<footer className=\"comment-meta\">\n\t\t\t\t\t\t\t<div className=\"comment-author vcard\">\n\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\talt={ __( 'Commenter Avatar' ) }\n\t\t\t\t\t\t\t\t\tsrc={ avatarURL }\n\t\t\t\t\t\t\t\t\tclassName=\"avatar avatar-32 photo\"\n\t\t\t\t\t\t\t\t\theight=\"32\"\n\t\t\t\t\t\t\t\t\twidth=\"32\"\n\t\t\t\t\t\t\t\t\tloading=\"lazy\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<b className=\"fn\">\n\t\t\t\t\t\t\t\t\t<a href=\"#top\" className=\"url\">\n\t\t\t\t\t\t\t\t\t\t{ __( 'A WordPress Commenter' ) }\n\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t</b>{ ' ' }\n\t\t\t\t\t\t\t\t<span className=\"says\">{ __( 'says' ) }:</span>\n\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t<div className=\"comment-metadata\">\n\t\t\t\t\t\t\t\t<a href=\"#top\">\n\t\t\t\t\t\t\t\t\t<time dateTime=\"2000-01-01T00:00:00+00:00\">\n\t\t\t\t\t\t\t\t\t\t{ __( 'January 1, 2000 at 00:00 am' ) }\n\t\t\t\t\t\t\t\t\t</time>\n\t\t\t\t\t\t\t\t</a>{ ' ' }\n\t\t\t\t\t\t\t\t<span className=\"edit-link\">\n\t\t\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\t\t\tclassName=\"comment-edit-link\"\n\t\t\t\t\t\t\t\t\t\thref=\"#top\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Edit' ) }\n\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</footer>\n\n\t\t\t\t\t\t<div className=\"comment-content\">\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\t{ __( 'Hi, this is a comment.' ) }\n\t\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'Commenter avatars come from <a>Gravatar</a>.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/anchor-has-content\n\t\t\t\t\t\t\t\t\t\t\t<a href=\"https://gravatar.com/\" />\n\t\t\t\t\t\t\t\t\t\t),\n\t\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</p>\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t<div className=\"reply\">\n\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\tclassName=\"comment-reply-link\"\n\t\t\t\t\t\t\t\thref=\"#top\"\n\t\t\t\t\t\t\t\taria-label={ __(\n\t\t\t\t\t\t\t\t\t'Reply to A WordPress Commenter'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAA0C;AAC1C,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { useEntityProp } from '@wordpress/core-data';\nimport { createInterpolateElement } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport CommentsForm from '../../post-comments-form/form';\n\nexport default function PostCommentsPlaceholder( { postType, postId } ) {\n\tlet [ postTitle ] = useEntityProp( 'postType', postType, 'title', postId );\n\tpostTitle = postTitle || __( 'Post Title' );\n\n\tconst avatarURL = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings()\n\t\t\t\t.__experimentalDiscussionSettings?.avatarURL,\n\t\t[]\n\t);\n\n\treturn (\n\t\t<div className=\"wp-block-comments__legacy-placeholder\" inert=\"true\">\n\t\t\t<h3>\n\t\t\t\t{\n\t\t\t\t\t/* translators: %s: Post title. */\n\t\t\t\t\tsprintf( __( 'One response to %s' ), postTitle )\n\t\t\t\t}\n\t\t\t</h3>\n\n\t\t\t<div className=\"navigation\">\n\t\t\t\t<div className=\"alignleft\">\n\t\t\t\t\t<a href=\"#top\">\u00AB { __( 'Older Comments' ) }</a>\n\t\t\t\t</div>\n\t\t\t\t<div className=\"alignright\">\n\t\t\t\t\t<a href=\"#top\">{ __( 'Newer Comments' ) } \u00BB</a>\n\t\t\t\t</div>\n\t\t\t</div>\n\n\t\t\t<ol className=\"commentlist\">\n\t\t\t\t<li className=\"comment even thread-even depth-1\">\n\t\t\t\t\t<article className=\"comment-body\">\n\t\t\t\t\t\t<footer className=\"comment-meta\">\n\t\t\t\t\t\t\t<div className=\"comment-author vcard\">\n\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\talt={ __( 'Commenter Avatar' ) }\n\t\t\t\t\t\t\t\t\tsrc={ avatarURL }\n\t\t\t\t\t\t\t\t\tclassName=\"avatar avatar-32 photo\"\n\t\t\t\t\t\t\t\t\theight=\"32\"\n\t\t\t\t\t\t\t\t\twidth=\"32\"\n\t\t\t\t\t\t\t\t\tloading=\"lazy\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<b className=\"fn\">\n\t\t\t\t\t\t\t\t\t<a href=\"#top\" className=\"url\">\n\t\t\t\t\t\t\t\t\t\t{ __( 'A WordPress Commenter' ) }\n\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t</b>{ ' ' }\n\t\t\t\t\t\t\t\t<span className=\"says\">{ __( 'says' ) }:</span>\n\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t<div className=\"comment-metadata\">\n\t\t\t\t\t\t\t\t<a href=\"#top\">\n\t\t\t\t\t\t\t\t\t<time dateTime=\"2000-01-01T00:00:00+00:00\">\n\t\t\t\t\t\t\t\t\t\t{ __( 'January 1, 2000 at 00:00 am' ) }\n\t\t\t\t\t\t\t\t\t</time>\n\t\t\t\t\t\t\t\t</a>{ ' ' }\n\t\t\t\t\t\t\t\t<span className=\"edit-link\">\n\t\t\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\t\t\tclassName=\"comment-edit-link\"\n\t\t\t\t\t\t\t\t\t\thref=\"#top\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Edit' ) }\n\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</footer>\n\n\t\t\t\t\t\t<div className=\"comment-content\">\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\t{ __( 'Hi, this is a comment.' ) }\n\t\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'Commenter avatars come from <a>Gravatar</a>.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/anchor-has-content\n\t\t\t\t\t\t\t\t\t\t\t<a href=\"https://gravatar.com/\" />\n\t\t\t\t\t\t\t\t\t\t),\n\t\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</p>\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t<div className=\"reply\">\n\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\tclassName=\"comment-reply-link\"\n\t\t\t\t\t\t\t\thref=\"#top\"\n\t\t\t\t\t\t\t\taria-label={ __(\n\t\t\t\t\t\t\t\t\t'Reply to A WordPress Commenter'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t/* translators: Comment reply button text. */\n\t\t\t\t\t\t\t\t\t_x( 'Reply', 'verb' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</article>\n\t\t\t\t</li>\n\t\t\t</ol>\n\n\t\t\t<div className=\"navigation\">\n\t\t\t\t<div className=\"alignleft\">\n\t\t\t\t\t<a href=\"#top\">\u00AB { __( 'Older Comments' ) }</a>\n\t\t\t\t</div>\n\t\t\t\t<div className=\"alignright\">\n\t\t\t\t\t<a href=\"#top\">{ __( 'Newer Comments' ) } \u00BB</a>\n\t\t\t\t</div>\n\t\t\t</div>\n\n\t\t\t<CommentsForm postId={ postId } postType={ postType } />\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;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vD;AAEF;",
|
|
6
6
|
"names": ["blockEditorStore", "CommentsForm"]
|
|
7
7
|
}
|
|
@@ -34,6 +34,7 @@ __export(transforms_exports, {
|
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(transforms_exports);
|
|
36
36
|
var import_blocks = require("@wordpress/blocks");
|
|
37
|
+
var import_url = require("@wordpress/url");
|
|
37
38
|
var import_block = __toESM(require("./block.json"));
|
|
38
39
|
var import_util = require("./util.cjs");
|
|
39
40
|
var { name: EMBED_BLOCK } = import_block.default;
|
|
@@ -41,7 +42,18 @@ var transforms = {
|
|
|
41
42
|
from: [
|
|
42
43
|
{
|
|
43
44
|
type: "raw",
|
|
44
|
-
isMatch: (node) =>
|
|
45
|
+
isMatch: (node) => {
|
|
46
|
+
if (node.nodeName !== "P") {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
const trimmed = node.textContent.trim();
|
|
50
|
+
if (!(0, import_url.isURL)(trimmed) || !/^https:\/\//i.test(trimmed) || trimmed.match(/https:\/\//gi)?.length !== 1) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
return !/\.(?!(html?|php)$)[a-z0-9]+$/i.test(
|
|
54
|
+
(0, import_url.getFilename)(trimmed) || ""
|
|
55
|
+
);
|
|
56
|
+
},
|
|
45
57
|
transform: (node) => {
|
|
46
58
|
const url = (0, import_util.rewriteXToTwitter)(node.textContent.trim());
|
|
47
59
|
return (0, import_blocks.createBlock)(EMBED_BLOCK, {
|
|
@@ -49,6 +61,17 @@ var transforms = {
|
|
|
49
61
|
...(0, import_util.findMoreSuitableBlock)(url)?.attributes
|
|
50
62
|
});
|
|
51
63
|
}
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
type: "shortcode",
|
|
67
|
+
tag: "embed",
|
|
68
|
+
transform: (_attrs, { shortcode }) => {
|
|
69
|
+
const url = (0, import_util.rewriteXToTwitter)(shortcode.content?.trim());
|
|
70
|
+
return (0, import_blocks.createBlock)(EMBED_BLOCK, {
|
|
71
|
+
url,
|
|
72
|
+
...(0, import_util.findMoreSuitableBlock)(url)?.attributes
|
|
73
|
+
});
|
|
74
|
+
}
|
|
52
75
|
}
|
|
53
76
|
],
|
|
54
77
|
to: [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/embed/transforms.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport {\n\tfindMoreSuitableBlock,\n\trewriteXToTwitter,\n\tremoveAspectRatioClasses,\n} from './util';\n\nconst { name: EMBED_BLOCK } = metadata;\n\n/**\n * Default transforms for generic embeds.\n */\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'raw',\n\t\t\tisMatch: ( node )
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA4B;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { isURL, getFilename } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport {\n\tfindMoreSuitableBlock,\n\trewriteXToTwitter,\n\tremoveAspectRatioClasses,\n} from './util';\n\nconst { name: EMBED_BLOCK } = metadata;\n\n/**\n * Default transforms for generic embeds.\n */\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'raw',\n\t\t\tisMatch: ( node ) => {\n\t\t\t\tif ( node.nodeName !== 'P' ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tconst trimmed = node.textContent.trim();\n\t\t\t\tif (\n\t\t\t\t\t! isURL( trimmed ) ||\n\t\t\t\t\t! /^https:\\/\\//i.test( trimmed ) ||\n\t\t\t\t\ttrimmed.match( /https:\\/\\//gi )?.length !== 1\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\t// Reject URLs whose filename ends in a file extension,\n\t\t\t\t// except common page extensions used by permalinks.\n\t\t\t\treturn ! /\\.(?!(html?|php)$)[a-z0-9]+$/i.test(\n\t\t\t\t\tgetFilename( trimmed ) || ''\n\t\t\t\t);\n\t\t\t},\n\t\t\ttransform: ( node ) => {\n\t\t\t\tconst url = rewriteXToTwitter( node.textContent.trim() );\n\t\t\t\treturn createBlock( EMBED_BLOCK, {\n\t\t\t\t\turl,\n\t\t\t\t\t...findMoreSuitableBlock( url )?.attributes,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'shortcode',\n\t\t\ttag: 'embed',\n\t\t\ttransform: ( _attrs, { shortcode } ) => {\n\t\t\t\tconst url = rewriteXToTwitter( shortcode.content?.trim() );\n\t\t\t\treturn createBlock( EMBED_BLOCK, {\n\t\t\t\t\turl,\n\t\t\t\t\t...findMoreSuitableBlock( url )?.attributes,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t],\n\tto: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\tisMatch: ( { url } ) => !! url,\n\t\t\ttransform: ( { url, caption, className } ) => {\n\t\t\t\tlet value = `<a href=\"${ url }\">${ url }</a>`;\n\t\t\t\tif ( caption?.trim() ) {\n\t\t\t\t\tvalue += `<br />${ caption }`;\n\t\t\t\t}\n\t\t\t\treturn createBlock( 'core/paragraph', {\n\t\t\t\t\tcontent: value,\n\t\t\t\t\tclassName: removeAspectRatioClasses( className ),\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default transforms;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA4B;AAC5B,iBAAmC;AAKnC,mBAAqB;AACrB,kBAIO;AAEP,IAAM,EAAE,MAAM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AAA,UACT,eAAW,sCAA0B,SAAU;AAAA,QAChD,CAAE;AAAA,MACH;AAAA,IACD;AAAA,EACD;AACD;AAEA,IAAO,qBAAQ;",
|
|
6
6
|
"names": ["metadata"]
|
|
7
7
|
}
|
|
@@ -25,25 +25,13 @@ __export(convert_to_blocks_button_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(convert_to_blocks_button_exports);
|
|
26
26
|
var import_i18n = require("@wordpress/i18n");
|
|
27
27
|
var import_components = require("@wordpress/components");
|
|
28
|
-
var import_data = require("@wordpress/data");
|
|
29
28
|
var import_blocks = require("@wordpress/blocks");
|
|
30
|
-
var import_block_editor = require("@wordpress/block-editor");
|
|
31
29
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
-
var ConvertToBlocksButton = ({
|
|
33
|
-
const { replaceBlocks } = (0, import_data.useDispatch)(import_block_editor.store);
|
|
34
|
-
const block = (0, import_data.useSelect)(
|
|
35
|
-
(select) => {
|
|
36
|
-
return select(import_block_editor.store).getBlock(clientId);
|
|
37
|
-
},
|
|
38
|
-
[clientId]
|
|
39
|
-
);
|
|
30
|
+
var ConvertToBlocksButton = ({ content, onReplace }) => {
|
|
40
31
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
41
32
|
import_components.ToolbarButton,
|
|
42
33
|
{
|
|
43
|
-
onClick: () =>
|
|
44
|
-
block.clientId,
|
|
45
|
-
(0, import_blocks.rawHandler)({ HTML: (0, import_blocks.serialize)(block) })
|
|
46
|
-
),
|
|
34
|
+
onClick: () => onReplace((0, import_blocks.rawHandler)({ HTML: content })),
|
|
47
35
|
children: (0, import_i18n.__)("Convert to blocks")
|
|
48
36
|
}
|
|
49
37
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/freeform/convert-to-blocks-button.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { ToolbarButton } from '@wordpress/components';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,wBAA8B;AAC9B,
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { ToolbarButton } from '@wordpress/components';\nimport { rawHandler } from '@wordpress/blocks';\n\nconst ConvertToBlocksButton = ( { content, onReplace } ) => {\n\treturn (\n\t\t<ToolbarButton\n\t\t\tonClick={ () => onReplace( rawHandler( { HTML: content } ) ) }\n\t\t>\n\t\t\t{ __( 'Convert to blocks' ) }\n\t\t</ToolbarButton>\n\t);\n};\n\nexport default ConvertToBlocksButton;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,wBAA8B;AAC9B,oBAA2B;AAIzB;AAFF,IAAM,wBAAwB,CAAE,EAAE,SAAS,UAAU,MAAO;AAC3D,SACC;AAAA,IAAC;AAAA;AAAA,MACA,SAAU,MAAM,cAAW,0BAAY,EAAE,MAAM,QAAQ,CAAE,CAAE;AAAA,MAEzD,8BAAI,mBAAoB;AAAA;AAAA,EAC3B;AAEF;AAEA,IAAO,mCAAQ;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/build/freeform/edit.cjs
CHANGED
|
@@ -40,12 +40,14 @@ var import_element = require("@wordpress/element");
|
|
|
40
40
|
var import_i18n = require("@wordpress/i18n");
|
|
41
41
|
var import_icons = require("@wordpress/icons");
|
|
42
42
|
var import_convert_to_blocks_button = __toESM(require("./convert-to-blocks-button.cjs"));
|
|
43
|
+
var import_migration_notice = __toESM(require("./migration-notice.cjs"));
|
|
43
44
|
var import_modal = __toESM(require("./modal.cjs"));
|
|
44
45
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
45
46
|
function FreeformEdit({
|
|
46
47
|
attributes,
|
|
47
48
|
setAttributes,
|
|
48
|
-
clientId
|
|
49
|
+
clientId,
|
|
50
|
+
onReplace
|
|
49
51
|
}) {
|
|
50
52
|
const { content } = attributes;
|
|
51
53
|
const [isOpen, setOpen] = (0, import_element.useState)(false);
|
|
@@ -54,8 +56,16 @@ function FreeformEdit({
|
|
|
54
56
|
(select) => select(import_block_editor.store).canRemoveBlock(clientId),
|
|
55
57
|
[clientId]
|
|
56
58
|
);
|
|
59
|
+
const { removeBlock } = (0, import_data.useDispatch)(import_block_editor.store);
|
|
60
|
+
const isDeprecationMode = window.__experimentalClassicBlockDeprecation;
|
|
57
61
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
58
|
-
canRemove && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.BlockControls, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.ToolbarGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
62
|
+
canRemove && !isDeprecationMode && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.BlockControls, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.ToolbarGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
63
|
+
import_convert_to_blocks_button.default,
|
|
64
|
+
{
|
|
65
|
+
content,
|
|
66
|
+
onReplace
|
|
67
|
+
}
|
|
68
|
+
) }) }),
|
|
59
69
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.BlockControls, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.ToolbarGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
60
70
|
import_components.ToolbarButton,
|
|
61
71
|
{
|
|
@@ -65,23 +75,41 @@ function FreeformEdit({
|
|
|
65
75
|
}
|
|
66
76
|
) }) }),
|
|
67
77
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ...(0, import_block_editor.useBlockProps)(), children: [
|
|
68
|
-
|
|
78
|
+
isDeprecationMode && canRemove && content && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
79
|
+
import_migration_notice.default,
|
|
80
|
+
{
|
|
81
|
+
content,
|
|
82
|
+
onReplace
|
|
83
|
+
}
|
|
84
|
+
),
|
|
85
|
+
content ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_element.RawHTML, { children: content }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
69
86
|
import_components.Placeholder,
|
|
70
87
|
{
|
|
71
88
|
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.BlockIcon, { icon: import_icons.classic }),
|
|
72
89
|
label: (0, import_i18n.__)("Classic"),
|
|
73
|
-
instructions: (0, import_i18n.__)(
|
|
74
|
-
"
|
|
75
|
-
),
|
|
76
|
-
children:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
90
|
+
instructions: isDeprecationMode ? (0, import_i18n.__)(
|
|
91
|
+
"The Classic block is being phased out. It\u2019s recommended to use other blocks for the best editing experience."
|
|
92
|
+
) : (0, import_i18n.__)("Use the classic editor to add content."),
|
|
93
|
+
children: [
|
|
94
|
+
isDeprecationMode && canRemove && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
95
|
+
import_components.Button,
|
|
96
|
+
{
|
|
97
|
+
__next40pxDefaultSize: true,
|
|
98
|
+
variant: "primary",
|
|
99
|
+
onClick: () => removeBlock(clientId),
|
|
100
|
+
children: (0, import_i18n.__)("Remove block")
|
|
101
|
+
}
|
|
102
|
+
),
|
|
103
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
104
|
+
import_components.Button,
|
|
105
|
+
{
|
|
106
|
+
__next40pxDefaultSize: true,
|
|
107
|
+
variant: isDeprecationMode && canRemove ? "secondary" : "primary",
|
|
108
|
+
onClick: () => setOpen(true),
|
|
109
|
+
children: (0, import_i18n.__)("Edit contents")
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
]
|
|
85
113
|
}
|
|
86
114
|
),
|
|
87
115
|
isOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/freeform/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tButton,\n\tPlaceholder,\n\tToolbarGroup,\n\tToolbarButton,\n} from '@wordpress/components';\nimport { useState, useRef, RawHTML } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { classic } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport ConvertToBlocksButton from './convert-to-blocks-button';\nimport ModalEdit from './modal';\n\nexport default function FreeformEdit( {\n\tattributes,\n\tsetAttributes,\n\tclientId,\n} ) {\n\tconst { content } = attributes;\n\tconst [ isOpen, setOpen ] = useState( false );\n\tconst editButtonRef = useRef( null );\n\n\tconst canRemove = useSelect(\n\t\t( select ) => select( blockEditorStore ).canRemoveBlock( clientId ),\n\t\t[ clientId ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ canRemove && (\n\t\t\t\t<BlockControls>\n\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t<ConvertToBlocksButton
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAKO;AACP,
|
|
6
|
-
"names": ["blockEditorStore", "ConvertToBlocksButton", "ModalEdit"]
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tButton,\n\tPlaceholder,\n\tToolbarGroup,\n\tToolbarButton,\n} from '@wordpress/components';\nimport { useState, useRef, RawHTML } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { classic } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport ConvertToBlocksButton from './convert-to-blocks-button';\nimport MigrationNotice from './migration-notice';\nimport ModalEdit from './modal';\n\nexport default function FreeformEdit( {\n\tattributes,\n\tsetAttributes,\n\tclientId,\n\tonReplace,\n} ) {\n\tconst { content } = attributes;\n\tconst [ isOpen, setOpen ] = useState( false );\n\tconst editButtonRef = useRef( null );\n\n\tconst canRemove = useSelect(\n\t\t( select ) => select( blockEditorStore ).canRemoveBlock( clientId ),\n\t\t[ clientId ]\n\t);\n\tconst { removeBlock } = useDispatch( blockEditorStore );\n\n\t// Gated by an experiment so authors can opt into a stronger nudge to\n\t// migrate Classic block content ahead of its planned deprecation.\n\tconst isDeprecationMode = window.__experimentalClassicBlockDeprecation;\n\n\treturn (\n\t\t<>\n\t\t\t{ canRemove && ! isDeprecationMode && (\n\t\t\t\t<BlockControls>\n\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t<ConvertToBlocksButton\n\t\t\t\t\t\t\tcontent={ content }\n\t\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tref={ editButtonRef }\n\t\t\t\t\t\tonClick={ () => setOpen( true ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Edit' ) }\n\t\t\t\t\t</ToolbarButton>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t<div { ...useBlockProps() }>\n\t\t\t\t{ isDeprecationMode && canRemove && content && (\n\t\t\t\t\t<MigrationNotice\n\t\t\t\t\t\tcontent={ content }\n\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ content ? (\n\t\t\t\t\t<RawHTML>{ content }</RawHTML>\n\t\t\t\t) : (\n\t\t\t\t\t<Placeholder\n\t\t\t\t\t\ticon={ <BlockIcon icon={ classic } /> }\n\t\t\t\t\t\tlabel={ __( 'Classic' ) }\n\t\t\t\t\t\tinstructions={\n\t\t\t\t\t\t\tisDeprecationMode\n\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t'The Classic block is being phased out. It\u2019s recommended to use other blocks for the best editing experience.'\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: __( 'Use the classic editor to add content.' )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t{ isDeprecationMode && canRemove && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\tonClick={ () => removeBlock( clientId ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Remove block' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\tisDeprecationMode && canRemove\n\t\t\t\t\t\t\t\t\t? 'secondary'\n\t\t\t\t\t\t\t\t\t: 'primary'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonClick={ () => setOpen( true ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Edit contents' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</Placeholder>\n\t\t\t\t) }\n\t\t\t\t{ isOpen && (\n\t\t\t\t\t<ModalEdit\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tcontent={ content }\n\t\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\t\tsetOpen( false );\n\t\t\t\t\t\t\tif ( editButtonRef.current ) {\n\t\t\t\t\t\t\t\teditButtonRef.current.focus();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonChange={ ( newContent ) =>\n\t\t\t\t\t\t\tsetAttributes( { content: newContent } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAKO;AACP,kBAAuC;AACvC,wBAKO;AACP,qBAA0C;AAC1C,kBAAmB;AACnB,mBAAwB;AAKxB,sCAAkC;AAClC,8BAA4B;AAC5B,mBAAsB;AAuBpB;AArBa,SAAR,aAA+B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,EAAE,QAAQ,IAAI;AACpB,QAAM,CAAE,QAAQ,OAAQ,QAAI,yBAAU,KAAM;AAC5C,QAAM,oBAAgB,uBAAQ,IAAK;AAEnC,QAAM,gBAAY;AAAA,IACjB,CAAE,WAAY,OAAQ,oBAAAA,KAAiB,EAAE,eAAgB,QAAS;AAAA,IAClE,CAAE,QAAS;AAAA,EACZ;AACA,QAAM,EAAE,YAAY,QAAI,yBAAa,oBAAAA,KAAiB;AAItD,QAAM,oBAAoB,OAAO;AAEjC,SACC,4EACG;AAAA,iBAAa,CAAE,qBAChB,4CAAC,qCACA,sDAAC,kCACA;AAAA,MAAC,gCAAAC;AAAA,MAAA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD,GACD,GACD;AAAA,IAED,4CAAC,qCACA,sDAAC,kCACA;AAAA,MAAC;AAAA;AAAA,QACA,KAAM;AAAA,QACN,SAAU,MAAM,QAAS,IAAK;AAAA,QAE5B,8BAAI,MAAO;AAAA;AAAA,IACd,GACD,GACD;AAAA,IACA,6CAAC,SAAM,OAAG,mCAAc,GACrB;AAAA,2BAAqB,aAAa,WACnC;AAAA,QAAC,wBAAAC;AAAA,QAAA;AAAA,UACA;AAAA,UACA;AAAA;AAAA,MACD;AAAA,MAEC,UACD,4CAAC,0BAAU,mBAAS,IAEpB;AAAA,QAAC;AAAA;AAAA,UACA,MAAO,4CAAC,iCAAU,MAAO,sBAAU;AAAA,UACnC,WAAQ,gBAAI,SAAU;AAAA,UACtB,cACC,wBACG;AAAA,YACA;AAAA,UACA,QACA,gBAAI,wCAAyC;AAAA,UAG/C;AAAA,iCAAqB,aACtB;AAAA,cAAC;AAAA;AAAA,gBACA,uBAAqB;AAAA,gBACrB,SAAQ;AAAA,gBACR,SAAU,MAAM,YAAa,QAAS;AAAA,gBAEpC,8BAAI,cAAe;AAAA;AAAA,YACtB;AAAA,YAED;AAAA,cAAC;AAAA;AAAA,gBACA,uBAAqB;AAAA,gBACrB,SACC,qBAAqB,YAClB,cACA;AAAA,gBAEJ,SAAU,MAAM,QAAS,IAAK;AAAA,gBAE5B,8BAAI,eAAgB;AAAA;AAAA,YACvB;AAAA;AAAA;AAAA,MACD;AAAA,MAEC,UACD;AAAA,QAAC,aAAAC;AAAA,QAAA;AAAA,UACA;AAAA,UACA;AAAA,UACA,SAAU,MAAM;AACf,oBAAS,KAAM;AACf,gBAAK,cAAc,SAAU;AAC5B,4BAAc,QAAQ,MAAM;AAAA,YAC7B;AAAA,UACD;AAAA,UACA,UAAW,CAAE,eACZ,cAAe,EAAE,SAAS,WAAW,CAAE;AAAA;AAAA,MAEzC;AAAA,OAEF;AAAA,KACD;AAEF;",
|
|
6
|
+
"names": ["blockEditorStore", "ConvertToBlocksButton", "MigrationNotice", "ModalEdit"]
|
|
7
7
|
}
|
package/build/freeform/index.cjs
CHANGED
|
@@ -47,7 +47,13 @@ var settings = {
|
|
|
47
47
|
edit: import_edit.default,
|
|
48
48
|
save: import_save.default
|
|
49
49
|
};
|
|
50
|
-
var init = () =>
|
|
50
|
+
var init = () => {
|
|
51
|
+
const supports = {
|
|
52
|
+
...import_block.default.supports,
|
|
53
|
+
inserter: !!window?.__needsClassicBlock
|
|
54
|
+
};
|
|
55
|
+
return (0, import_init_block.default)({ name, metadata: import_block.default, settings: { ...settings, supports } });
|
|
56
|
+
};
|
|
51
57
|
// Annotate the CommonJS export names for ESM import in node:
|
|
52
58
|
0 && (module.exports = {
|
|
53
59
|
init,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/freeform/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { classic as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,+BAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAGA,mBAAgC;AAKhC,wBAAsB;AACtB,kBAAiB;AACjB,mBAAqB;AACrB,kBAAiB;AAEjB,IAAM,EAAE,KAAK,IAAI,aAAAA;AAIV,IAAM,WAAW;AAAA,EACvB,mBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,kBAAAC;AACD;AAEO,IAAM,OAAO,
|
|
6
|
-
"names": ["metadata", "icon", "edit", "save", "
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { classic as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n};\n\nexport const init = () => {\n\t// Only expose the block in the inserter if the current post actually needs\n\t// a classic block.\n\tconst supports = {\n\t\t...metadata.supports,\n\t\tinserter: !! window?.__needsClassicBlock,\n\t};\n\treturn initBlock( { name, metadata, settings: { ...settings, supports } } );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,+BAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAGA,mBAAgC;AAKhC,wBAAsB;AACtB,kBAAiB;AACjB,mBAAqB;AACrB,kBAAiB;AAEjB,IAAM,EAAE,KAAK,IAAI,aAAAA;AAIV,IAAM,WAAW;AAAA,EACvB,mBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,kBAAAC;AACD;AAEO,IAAM,OAAO,MAAM;AAGzB,QAAM,WAAW;AAAA,IAChB,GAAG,aAAAC,QAAS;AAAA,IACZ,UAAU,CAAC,CAAE,QAAQ;AAAA,EACtB;AACA,aAAO,kBAAAC,SAAW,EAAE,MAAM,uBAAAD,SAAU,UAAU,EAAE,GAAG,UAAU,SAAS,EAAE,CAAE;AAC3E;",
|
|
6
|
+
"names": ["metadata", "icon", "edit", "save", "metadata", "initBlock"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/block-library/src/freeform/migration-notice.js
|
|
21
|
+
var migration_notice_exports = {};
|
|
22
|
+
__export(migration_notice_exports, {
|
|
23
|
+
default: () => MigrationNotice
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(migration_notice_exports);
|
|
26
|
+
var import_block_editor = require("@wordpress/block-editor");
|
|
27
|
+
var import_components = require("@wordpress/components");
|
|
28
|
+
var import_blocks = require("@wordpress/blocks");
|
|
29
|
+
var import_i18n = require("@wordpress/i18n");
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
function MigrationNotice({ content, onReplace }) {
|
|
32
|
+
const actions = [
|
|
33
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
34
|
+
import_components.Button,
|
|
35
|
+
{
|
|
36
|
+
__next40pxDefaultSize: true,
|
|
37
|
+
variant: "primary",
|
|
38
|
+
onClick: () => onReplace((0, import_blocks.rawHandler)({ HTML: content })),
|
|
39
|
+
children: (0, import_i18n.__)("Convert to blocks")
|
|
40
|
+
},
|
|
41
|
+
"convert-to-blocks"
|
|
42
|
+
),
|
|
43
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
44
|
+
import_components.Button,
|
|
45
|
+
{
|
|
46
|
+
__next40pxDefaultSize: true,
|
|
47
|
+
variant: "secondary",
|
|
48
|
+
onClick: () => onReplace((0, import_blocks.createBlock)("core/html", { content })),
|
|
49
|
+
children: (0, import_i18n.__)("Convert to HTML")
|
|
50
|
+
},
|
|
51
|
+
"convert-to-html"
|
|
52
|
+
)
|
|
53
|
+
];
|
|
54
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.Warning, { actions, children: (0, import_i18n.__)(
|
|
55
|
+
"The Classic block is being phased out. Convert this content to blocks for the best editing experience, or move it to a Custom HTML block to preserve the markup as-is."
|
|
56
|
+
) });
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=migration-notice.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/freeform/migration-notice.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Warning } from '@wordpress/block-editor';\nimport { Button } from '@wordpress/components';\nimport { createBlock, rawHandler } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Block-level deprecation warning rendered when the\n * `gutenberg-classic-block-deprecation` experiment is enabled.\n *\n * Uses the same `Warning` primitive as `core/missing` so the experience is\n * visually consistent with how the editor already surfaces deprecated blocks,\n * and offers two migration actions - a primary \"Convert to blocks\", and a\n * secondary \"Convert to Custom HTML\".\n *\n * @param {Object} props\n * @param {string} props.content Raw HTML content of the Classic block.\n * @param {Function} props.onReplace Replace the current block with the given blocks.\n */\nexport default function MigrationNotice( { content, onReplace } ) {\n\tconst actions = [\n\t\t<Button\n\t\t\t__next40pxDefaultSize\n\t\t\tkey=\"convert-to-blocks\"\n\t\t\tvariant=\"primary\"\n\t\t\tonClick={ () => onReplace( rawHandler( { HTML: content } ) ) }\n\t\t>\n\t\t\t{ __( 'Convert to blocks' ) }\n\t\t</Button>,\n\t\t<Button\n\t\t\t__next40pxDefaultSize\n\t\t\tkey=\"convert-to-html\"\n\t\t\tvariant=\"secondary\"\n\t\t\tonClick={ () =>\n\t\t\t\tonReplace( createBlock( 'core/html', { content } ) )\n\t\t\t}\n\t\t>\n\t\t\t{ __( 'Convert to HTML' ) }\n\t\t</Button>,\n\t];\n\n\treturn (\n\t\t<Warning actions={ actions }>\n\t\t\t{ __(\n\t\t\t\t'The Classic block is being phased out. Convert this content to blocks for the best editing experience, or move it to a Custom HTML block to preserve the markup as-is.'\n\t\t\t) }\n\t\t</Warning>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAAwB;AACxB,wBAAuB;AACvB,oBAAwC;AACxC,kBAAmB;AAiBjB;AAFa,SAAR,gBAAkC,EAAE,SAAS,UAAU,GAAI;AACjE,QAAM,UAAU;AAAA,IACf;AAAA,MAAC;AAAA;AAAA,QACA,uBAAqB;AAAA,QAErB,SAAQ;AAAA,QACR,SAAU,MAAM,cAAW,0BAAY,EAAE,MAAM,QAAQ,CAAE,CAAE;AAAA,QAEzD,8BAAI,mBAAoB;AAAA;AAAA,MAJtB;AAAA,IAKL;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,uBAAqB;AAAA,QAErB,SAAQ;AAAA,QACR,SAAU,MACT,cAAW,2BAAa,aAAa,EAAE,QAAQ,CAAE,CAAE;AAAA,QAGlD,8BAAI,iBAAkB;AAAA;AAAA,MANpB;AAAA,IAOL;AAAA,EACD;AAEA,SACC,4CAAC,+BAAQ,SACN;AAAA,IACD;AAAA,EACD,GACD;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|