@wordpress/editor 14.22.0 → 14.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/post-author/check.js +3 -7
- package/build/components/post-author/check.js.map +1 -1
- package/build/components/post-author/panel.js +10 -2
- package/build/components/post-author/panel.js.map +1 -1
- package/build/components/post-template/swap-template-button.js +18 -4
- package/build/components/post-template/swap-template-button.js.map +1 -1
- package/build/components/visual-editor/index.js +1 -2
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/utils/search-templates.js +75 -0
- package/build/utils/search-templates.js.map +1 -0
- package/build-module/components/post-author/check.js +3 -7
- package/build-module/components/post-author/check.js.map +1 -1
- package/build-module/components/post-author/panel.js +10 -2
- package/build-module/components/post-author/panel.js.map +1 -1
- package/build-module/components/post-template/swap-template-button.js +19 -5
- package/build-module/components/post-template/swap-template-button.js.map +1 -1
- package/build-module/components/visual-editor/index.js +1 -2
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/utils/search-templates.js +68 -0
- package/build-module/utils/search-templates.js.map +1 -0
- package/build-style/style-rtl.css +13 -18
- package/build-style/style.css +13 -18
- package/build-types/components/post-author/check.d.ts.map +1 -1
- package/build-types/components/post-author/panel.d.ts.map +1 -1
- package/build-types/components/post-template/swap-template-button.d.ts.map +1 -1
- package/build-types/components/visual-editor/index.d.ts.map +1 -1
- package/build-types/utils/search-templates.d.ts +10 -0
- package/build-types/utils/search-templates.d.ts.map +1 -0
- package/package.json +37 -37
- package/src/components/editor-interface/style.scss +1 -2
- package/src/components/post-author/check.js +2 -7
- package/src/components/post-author/panel.js +10 -2
- package/src/components/post-author/test/check.js +3 -11
- package/src/components/post-template/style.scss +10 -0
- package/src/components/post-template/swap-template-button.js +23 -6
- package/src/components/visual-editor/index.js +0 -1
- package/src/components/visual-editor/style.scss +6 -29
- package/src/utils/search-templates.js +77 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { useMemo, useState } from '@wordpress/element';
|
|
5
5
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
6
6
|
import { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';
|
|
7
|
-
import { MenuItem, Modal } from '@wordpress/components';
|
|
7
|
+
import { MenuItem, Modal, SearchControl } from '@wordpress/components';
|
|
8
8
|
import { __ } from '@wordpress/i18n';
|
|
9
9
|
import { useDispatch } from '@wordpress/data';
|
|
10
10
|
import { store as coreStore } from '@wordpress/core-data';
|
|
@@ -14,6 +14,7 @@ import { parse } from '@wordpress/blocks';
|
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
16
|
import { useAvailableTemplates, useEditedPostContext } from './hooks';
|
|
17
|
+
import { searchTemplates } from '../../utils/search-templates';
|
|
17
18
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
19
|
export default function SwapTemplateButton({
|
|
19
20
|
onClick
|
|
@@ -61,6 +62,7 @@ function TemplatesList({
|
|
|
61
62
|
postType,
|
|
62
63
|
onSelect
|
|
63
64
|
}) {
|
|
65
|
+
const [searchValue, setSearchValue] = useState('');
|
|
64
66
|
const availableTemplates = useAvailableTemplates(postType);
|
|
65
67
|
const templatesAsPatterns = useMemo(() => availableTemplates.map(template => ({
|
|
66
68
|
name: template.slug,
|
|
@@ -68,10 +70,22 @@ function TemplatesList({
|
|
|
68
70
|
title: decodeEntities(template.title.rendered),
|
|
69
71
|
id: template.id
|
|
70
72
|
})), [availableTemplates]);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
const filteredBlockTemplates = useMemo(() => {
|
|
74
|
+
return searchTemplates(templatesAsPatterns, searchValue);
|
|
75
|
+
}, [templatesAsPatterns, searchValue]);
|
|
76
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
77
|
+
children: [/*#__PURE__*/_jsx(SearchControl, {
|
|
78
|
+
__nextHasNoMarginBottom: true,
|
|
79
|
+
onChange: setSearchValue,
|
|
80
|
+
value: searchValue,
|
|
81
|
+
label: __('Search'),
|
|
82
|
+
placeholder: __('Search'),
|
|
83
|
+
className: "editor-post-template__swap-template-search"
|
|
84
|
+
}), /*#__PURE__*/_jsx(BlockPatternsList, {
|
|
85
|
+
label: __('Templates'),
|
|
86
|
+
blockPatterns: filteredBlockTemplates,
|
|
87
|
+
onClickPattern: onSelect
|
|
88
|
+
})]
|
|
75
89
|
});
|
|
76
90
|
}
|
|
77
91
|
//# sourceMappingURL=swap-template-button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","useState","decodeEntities","__experimentalBlockPatternsList","BlockPatternsList","MenuItem","Modal","__","useDispatch","store","coreStore","parse","useAvailableTemplates","useEditedPostContext","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","SwapTemplateButton","onClick","showModal","setShowModal","postType","postId","availableTemplates","editEntityRecord","onTemplateSelect","template","name","undoIgnore","children","disabled","length","accessibleWhenDisabled","title","onRequestClose","overlayClassName","isFullScreen","className","TemplatesList","onSelect","templatesAsPatterns","map","slug","blocks","content","raw","rendered","id","label","blockPatterns","onClickPattern"],"sources":["@wordpress/editor/src/components/post-template/swap-template-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';\nimport { MenuItem, Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { parse } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useAvailableTemplates, useEditedPostContext } from './hooks';\n\nexport default function SwapTemplateButton( { onClick } ) {\n\tconst [ showModal, setShowModal ] = useState( false );\n\tconst { postType, postId } = useEditedPostContext();\n\tconst availableTemplates = useAvailableTemplates( postType );\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\n\tconst onTemplateSelect = async ( template ) => {\n\t\teditEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tpostId,\n\t\t\t{ template: template.name },\n\t\t\t{ undoIgnore: true }\n\t\t);\n\t\tsetShowModal( false ); // Close the template suggestions modal first.\n\t\tonClick();\n\t};\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tdisabled={ ! availableTemplates?.length }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () => setShowModal( true ) }\n\t\t\t>\n\t\t\t\t{ __( 'Change template' ) }\n\t\t\t</MenuItem>\n\t\t\t{ showModal && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Choose a template' ) }\n\t\t\t\t\tonRequestClose={ () => setShowModal( false ) }\n\t\t\t\t\toverlayClassName=\"editor-post-template__swap-template-modal\"\n\t\t\t\t\tisFullScreen\n\t\t\t\t>\n\t\t\t\t\t<div className=\"editor-post-template__swap-template-modal-content\">\n\t\t\t\t\t\t<TemplatesList\n\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\tonSelect={ onTemplateSelect }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction TemplatesList( { postType, onSelect } ) {\n\tconst availableTemplates = useAvailableTemplates( postType );\n\tconst templatesAsPatterns = useMemo(\n\t\t() =>\n\t\t\tavailableTemplates.map( ( template ) => ( {\n\t\t\t\tname: template.slug,\n\t\t\t\tblocks: parse( template.content.raw ),\n\t\t\t\ttitle: decodeEntities( template.title.rendered ),\n\t\t\t\tid: template.id,\n\t\t\t} ) ),\n\t\t[ availableTemplates ]\n\t);\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tlabel={ __( 'Templates' ) }\n\t\t\tblockPatterns={
|
|
1
|
+
{"version":3,"names":["useMemo","useState","decodeEntities","__experimentalBlockPatternsList","BlockPatternsList","MenuItem","Modal","SearchControl","__","useDispatch","store","coreStore","parse","useAvailableTemplates","useEditedPostContext","searchTemplates","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","SwapTemplateButton","onClick","showModal","setShowModal","postType","postId","availableTemplates","editEntityRecord","onTemplateSelect","template","name","undoIgnore","children","disabled","length","accessibleWhenDisabled","title","onRequestClose","overlayClassName","isFullScreen","className","TemplatesList","onSelect","searchValue","setSearchValue","templatesAsPatterns","map","slug","blocks","content","raw","rendered","id","filteredBlockTemplates","__nextHasNoMarginBottom","onChange","value","label","placeholder","blockPatterns","onClickPattern"],"sources":["@wordpress/editor/src/components/post-template/swap-template-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';\nimport { MenuItem, Modal, SearchControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { parse } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useAvailableTemplates, useEditedPostContext } from './hooks';\nimport { searchTemplates } from '../../utils/search-templates';\n\nexport default function SwapTemplateButton( { onClick } ) {\n\tconst [ showModal, setShowModal ] = useState( false );\n\tconst { postType, postId } = useEditedPostContext();\n\tconst availableTemplates = useAvailableTemplates( postType );\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\n\tconst onTemplateSelect = async ( template ) => {\n\t\teditEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tpostId,\n\t\t\t{ template: template.name },\n\t\t\t{ undoIgnore: true }\n\t\t);\n\t\tsetShowModal( false ); // Close the template suggestions modal first.\n\t\tonClick();\n\t};\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tdisabled={ ! availableTemplates?.length }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () => setShowModal( true ) }\n\t\t\t>\n\t\t\t\t{ __( 'Change template' ) }\n\t\t\t</MenuItem>\n\t\t\t{ showModal && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Choose a template' ) }\n\t\t\t\t\tonRequestClose={ () => setShowModal( false ) }\n\t\t\t\t\toverlayClassName=\"editor-post-template__swap-template-modal\"\n\t\t\t\t\tisFullScreen\n\t\t\t\t>\n\t\t\t\t\t<div className=\"editor-post-template__swap-template-modal-content\">\n\t\t\t\t\t\t<TemplatesList\n\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\tonSelect={ onTemplateSelect }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction TemplatesList( { postType, onSelect } ) {\n\tconst [ searchValue, setSearchValue ] = useState( '' );\n\tconst availableTemplates = useAvailableTemplates( postType );\n\tconst templatesAsPatterns = useMemo(\n\t\t() =>\n\t\t\tavailableTemplates.map( ( template ) => ( {\n\t\t\t\tname: template.slug,\n\t\t\t\tblocks: parse( template.content.raw ),\n\t\t\t\ttitle: decodeEntities( template.title.rendered ),\n\t\t\t\tid: template.id,\n\t\t\t} ) ),\n\t\t[ availableTemplates ]\n\t);\n\n\tconst filteredBlockTemplates = useMemo( () => {\n\t\treturn searchTemplates( templatesAsPatterns, searchValue );\n\t}, [ templatesAsPatterns, searchValue ] );\n\n\treturn (\n\t\t<>\n\t\t\t<SearchControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tonChange={ setSearchValue }\n\t\t\t\tvalue={ searchValue }\n\t\t\t\tlabel={ __( 'Search' ) }\n\t\t\t\tplaceholder={ __( 'Search' ) }\n\t\t\t\tclassName=\"editor-post-template__swap-template-search\"\n\t\t\t/>\n\t\t\t<BlockPatternsList\n\t\t\t\tlabel={ __( 'Templates' ) }\n\t\t\t\tblockPatterns={ filteredBlockTem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B,CACrB,CAAC;EAED,MAAM2B,sBAAsB,GAAGvD,OAAO,CAAE,MAAM;IAC7C,OAAOe,eAAe,CAAEgC,mBAAmB,EAAEF,WAAY,CAAC;EAC3D,CAAC,EAAE,CAAEE,mBAAmB,EAAEF,WAAW,CAAG,CAAC;EAEzC,oBACCxB,KAAA,CAAAF,SAAA;IAAAe,QAAA,gBACCjB,IAAA,CAACV,aAAa;MACbiD,uBAAuB;MACvBC,QAAQ,EAAGX,cAAgB;MAC3BY,KAAK,EAAGb,WAAa;MACrBc,KAAK,EAAGnD,EAAE,CAAE,QAAS,CAAG;MACxBoD,WAAW,EAAGpD,EAAE,CAAE,QAAS,CAAG;MAC9BkC,SAAS,EAAC;IAA4C,CACtD,CAAC,eACFzB,IAAA,CAACb,iBAAiB;MACjBuD,KAAK,EAAGnD,EAAE,CAAE,WAAY,CAAG;MAC3BqD,aAAa,EAAGN,sBAAwB;MACxCO,cAAc,EAAGlB;IAAU,CAC3B,CAAC;EAAA,CACD,CAAC;AAEL","ignoreList":[]}
|
|
@@ -282,8 +282,7 @@ function VisualEditor({
|
|
|
282
282
|
'edit-post-visual-editor', className, {
|
|
283
283
|
'has-padding': isFocusedEntity || enableResizing,
|
|
284
284
|
'is-resizable': enableResizing,
|
|
285
|
-
'is-iframed': !disableIframe
|
|
286
|
-
'is-scrollable': disableIframe || deviceType !== 'Desktop'
|
|
285
|
+
'is-iframed': !disableIframe
|
|
287
286
|
}),
|
|
288
287
|
children: /*#__PURE__*/_jsx(ResizableEditor, {
|
|
289
288
|
enableResizing: enableResizing,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","BlockList","store","blockEditorStore","__unstableUseTypewriter","useTypewriter","__unstableUseTypingObserver","useTypingObserver","useSettings","RecursionProvider","privateApis","blockEditorPrivateApis","__experimentalUseResizeCanvas","useResizeCanvas","useEffect","useRef","useMemo","useState","useSelect","parse","coreStore","useMergeRefs","useViewportMatch","useResizeObserver","PostTitle","editorStore","unlock","EditTemplateBlocksNotification","ResizableEditor","useSelectNearestEditableBlock","NAVIGATION_POST_TYPE","PATTERN_POST_TYPE","TEMPLATE_PART_POST_TYPE","TEMPLATE_POST_TYPE","useZoomOutModeExit","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","LayoutStyle","useLayoutClasses","useLayoutStyles","ExperimentalBlockCanvas","BlockCanvas","useFlashEditableBlocks","DESIGN_POST_TYPES","getPostContentAttributes","blocks","i","length","name","attributes","innerBlocks","nestedPostContent","checkForPostContentAtRootLevel","VisualEditor","autoFocus","styles","disableIframe","iframeProps","contentRef","className","contentHeight","setContentHeight","effectContentHeight","entry","borderBoxSize","blockSize","isMobileViewport","renderingMode","postContentAttributes","editedPostTemplate","wrapperBlockName","wrapperUniqueId","deviceType","isFocusedEntity","isDesignPostType","postType","isPreview","select","getCurrentPostId","getCurrentPostType","getCurrentTemplateId","getEditorSettings","getRenderingMode","getDeviceType","getPostType","getEditedEntityRecord","postTypeSlug","_renderingMode","_wrapperBlockName","editorSettings","supportsTemplateMode","postTypeObject","currentTemplateId","template","undefined","includes","viewable","onNavigateToPreviousEntityRecord","isPreviewMode","isCleanNewPost","hasRootPaddingAwareAlignments","themeHasDisabledLayoutStyles","themeSupportsLayout","isZoomedOut","getSettings","isZoomOut","_isZoomOut","_settings","disableLayoutStyles","supportsLayout","__experimentalFeatures","useRootPaddingAwareAlignments","deviceStyles","globalLayoutSettings","fallbackLayout","type","newestPostContentAttributes","content","parseableContent","hasPostContentAtRootLevel","layout","align","postContentLayoutClasses","blockListLayoutClass","postContentLayoutStyles","postContentLayout","inherit","contentSize","wideSize","blockListLayout","postEditorLayout","observeTypingRef","titleRef","current","focus","alignCSS","forceFullHeight","enableResizing","iframeStyles","css","localRef","typewriterRef","isEnabled","children","height","shouldIframe","style","selector","contentEditable","ref","marginTop","blockName","uniqueId","toLowerCase","dropZoneElement","parentNode","__unstableDisableDropZone"],"sources":["@wordpress/editor/src/components/visual-editor/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBlockList,\n\tstore as blockEditorStore,\n\t__unstableUseTypewriter as useTypewriter,\n\t__unstableUseTypingObserver as useTypingObserver,\n\tuseSettings,\n\tRecursionProvider,\n\tprivateApis as blockEditorPrivateApis,\n\t__experimentalUseResizeCanvas as useResizeCanvas,\n} from '@wordpress/block-editor';\nimport { useEffect, useRef, useMemo, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { parse } from '@wordpress/blocks';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tuseMergeRefs,\n\tuseViewportMatch,\n\tuseResizeObserver,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport PostTitle from '../post-title';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport EditTemplateBlocksNotification from './edit-template-blocks-notification';\nimport ResizableEditor from '../resizable-editor';\nimport useSelectNearestEditableBlock from './use-select-nearest-editable-block';\nimport {\n\tNAVIGATION_POST_TYPE,\n\tPATTERN_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tTEMPLATE_POST_TYPE,\n} from '../../store/constants';\nimport { useZoomOutModeExit } from './use-zoom-out-mode-exit';\n\nconst {\n\tLayoutStyle,\n\tuseLayoutClasses,\n\tuseLayoutStyles,\n\tExperimentalBlockCanvas: BlockCanvas,\n\tuseFlashEditableBlocks,\n} = unlock( blockEditorPrivateApis );\n\n/**\n * These post types have a special editor where they don't allow you to fill the title\n * and they don't apply the layout styles.\n */\nconst DESIGN_POST_TYPES = [\n\tPATTERN_POST_TYPE,\n\tTEMPLATE_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n];\n\n/**\n * Given an array of nested blocks, find the first Post Content\n * block inside it, recursing through any nesting levels,\n * and return its attributes.\n *\n * @param {Array} blocks A list of blocks.\n *\n * @return {Object | undefined} The Post Content block.\n */\nfunction getPostContentAttributes( blocks ) {\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\tif ( blocks[ i ].name === 'core/post-content' ) {\n\t\t\treturn blocks[ i ].attributes;\n\t\t}\n\t\tif ( blocks[ i ].innerBlocks.length ) {\n\t\t\tconst nestedPostContent = getPostContentAttributes(\n\t\t\t\tblocks[ i ].innerBlocks\n\t\t\t);\n\n\t\t\tif ( nestedPostContent ) {\n\t\t\t\treturn nestedPostContent;\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction checkForPostContentAtRootLevel( blocks ) {\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\tif ( blocks[ i ].name === 'core/post-content' ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\nfunction VisualEditor( {\n\t// Ideally as we unify post and site editors, we won't need these props.\n\tautoFocus,\n\tstyles,\n\tdisableIframe = false,\n\tiframeProps,\n\tcontentRef,\n\tclassName,\n} ) {\n\tconst [ contentHeight, setContentHeight ] = useState( '' );\n\tconst effectContentHeight = useResizeObserver( ( [ entry ] ) => {\n\t\tsetContentHeight( entry.borderBoxSize[ 0 ].blockSize );\n\t} );\n\tconst isMobileViewport = useViewportMatch( 'small', '<' );\n\tconst {\n\t\trenderingMode,\n\t\tpostContentAttributes,\n\t\teditedPostTemplate = {},\n\t\twrapperBlockName,\n\t\twrapperUniqueId,\n\t\tdeviceType,\n\t\tisFocusedEntity,\n\t\tisDesignPostType,\n\t\tpostType,\n\t\tisPreview,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetCurrentPostId,\n\t\t\tgetCurrentPostType,\n\t\t\tgetCurrentTemplateId,\n\t\t\tgetEditorSettings,\n\t\t\tgetRenderingMode,\n\t\t\tgetDeviceType,\n\t\t} = select( editorStore );\n\t\tconst { getPostType, getEditedEntityRecord } = select( coreStore );\n\t\tconst postTypeSlug = getCurrentPostType();\n\t\tconst _renderingMode = getRenderingMode();\n\t\tlet _wrapperBlockName;\n\n\t\tif ( postTypeSlug === PATTERN_POST_TYPE ) {\n\t\t\t_wrapperBlockName = 'core/block';\n\t\t} else if ( _renderingMode === 'post-only' ) {\n\t\t\t_wrapperBlockName = 'core/post-content';\n\t\t}\n\n\t\tconst editorSettings = getEditorSettings();\n\t\tconst supportsTemplateMode = editorSettings.supportsTemplateMode;\n\t\tconst postTypeObject = getPostType( postTypeSlug );\n\t\tconst currentTemplateId = getCurrentTemplateId();\n\t\tconst template = currentTemplateId\n\t\t\t? getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t\tcurrentTemplateId\n\t\t\t )\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\trenderingMode: _renderingMode,\n\t\t\tpostContentAttributes: editorSettings.postContentAttributes,\n\t\t\tisDesignPostType: DESIGN_POST_TYPES.includes( postTypeSlug ),\n\t\t\t// Post template fetch returns a 404 on classic themes, which\n\t\t\t// messes with e2e tests, so check it's a block theme first.\n\t\t\teditedPostTemplate:\n\t\t\t\tpostTypeObject?.viewable && supportsTemplateMode\n\t\t\t\t\t? template\n\t\t\t\t\t: undefined,\n\t\t\twrapperBlockName: _wrapperBlockName,\n\t\t\twrapperUniqueId: getCurrentPostId(),\n\t\t\tdeviceType: getDeviceType(),\n\t\t\tisFocusedEntity: !! editorSettings.onNavigateToPreviousEntityRecord,\n\t\t\tpostType: postTypeSlug,\n\t\t\tisPreview: editorSettings.isPreviewMode,\n\t\t};\n\t}, [] );\n\tconst { isCleanNewPost } = useSelect( editorStore );\n\tconst {\n\t\thasRootPaddingAwareAlignments,\n\t\tthemeHasDisabledLayoutStyles,\n\t\tthemeSupportsLayout,\n\t\tisZoomedOut,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSettings, isZoomOut: _isZoomOut } = unlock(\n\t\t\tselect( blockEditorStore )\n\t\t);\n\n\t\tconst _settings = getSettings();\n\t\treturn {\n\t\t\tthemeHasDisabledLayoutStyles: _settings.disableLayoutStyles,\n\t\t\tthemeSupportsLayout: _settings.supportsLayout,\n\t\t\thasRootPaddingAwareAlignments:\n\t\t\t\t_settings.__experimentalFeatures?.useRootPaddingAwareAlignments,\n\t\t\tisZoomedOut: _isZoomOut(),\n\t\t};\n\t}, [] );\n\n\tconst deviceStyles = useResizeCanvas( deviceType );\n\tconst [ globalLayoutSettings ] = useSettings( 'layout' );\n\n\t// fallbackLayout is used if there is no Post Content,\n\t// and for Post Title.\n\tconst fallbackLayout = useMemo( () => {\n\t\tif ( renderingMode !== 'post-only' || isDesignPostType ) {\n\t\t\treturn { type: 'default' };\n\t\t}\n\n\t\tif ( themeSupportsLayout ) {\n\t\t\t// We need to ensure support for wide and full alignments,\n\t\t\t// so we add the constrained type.\n\t\t\treturn { ...globalLayoutSettings, type: 'constrained' };\n\t\t}\n\t\t// Set default layout for classic themes so all alignments are supported.\n\t\treturn { type: 'default' };\n\t}, [\n\t\trenderingMode,\n\t\tthemeSupportsLayout,\n\t\tglobalLayoutSettings,\n\t\tisDesignPostType,\n\t] );\n\n\tconst newestPostContentAttributes = useMemo( () => {\n\t\tif (\n\t\t\t! editedPostTemplate?.content &&\n\t\t\t! editedPostTemplate?.blocks &&\n\t\t\tpostContentAttributes\n\t\t) {\n\t\t\treturn postContentAttributes;\n\t\t}\n\t\t// When in template editing mode, we can access the blocks directly.\n\t\tif ( editedPostTemplate?.blocks ) {\n\t\t\treturn getPostContentAttributes( editedPostTemplate?.blocks );\n\t\t}\n\t\t// If there are no blocks, we have to parse the content string.\n\t\t// Best double-check it's a string otherwise the parse function gets unhappy.\n\t\tconst parseableContent =\n\t\t\ttypeof editedPostTemplate?.content === 'string'\n\t\t\t\t? editedPostTemplate?.content\n\t\t\t\t: '';\n\n\t\treturn getPostContentAttributes( parse( parseableContent ) ) || {};\n\t}, [\n\t\teditedPostTemplate?.content,\n\t\teditedPostTemplate?.blocks,\n\t\tpostContentAttributes,\n\t] );\n\n\tconst hasPostContentAtRootLevel = useMemo( () => {\n\t\tif ( ! editedPostTemplate?.content && ! editedPostTemplate?.blocks ) {\n\t\t\treturn false;\n\t\t}\n\t\t// When in template editing mode, we can access the blocks directly.\n\t\tif ( editedPostTemplate?.blocks ) {\n\t\t\treturn checkForPostContentAtRootLevel( editedPostTemplate?.blocks );\n\t\t}\n\t\t// If there are no blocks, we have to parse the content string.\n\t\t// Best double-check it's a string otherwise the parse function gets unhappy.\n\t\tconst parseableContent =\n\t\t\ttypeof editedPostTemplate?.content === 'string'\n\t\t\t\t? editedPostTemplate?.content\n\t\t\t\t: '';\n\n\t\treturn (\n\t\t\tcheckForPostContentAtRootLevel( parse( parseableContent ) ) || false\n\t\t);\n\t}, [ editedPostTemplate?.content, editedPostTemplate?.blocks ] );\n\n\tconst { layout = {}, align = '' } = newestPostContentAttributes || {};\n\n\tconst postContentLayoutClasses = useLayoutClasses(\n\t\tnewestPostContentAttributes,\n\t\t'core/post-content'\n\t);\n\n\tconst blockListLayoutClass = clsx(\n\t\t{\n\t\t\t'is-layout-flow': ! themeSupportsLayout,\n\t\t},\n\t\tthemeSupportsLayout && postContentLayoutClasses,\n\t\talign && `align${ align }`\n\t);\n\n\tconst postContentLayoutStyles = useLayoutStyles(\n\t\tnewestPostContentAttributes,\n\t\t'core/post-content',\n\t\t'.block-editor-block-list__layout.is-root-container'\n\t);\n\n\t// Update type for blocks using legacy layouts.\n\tconst postContentLayout = useMemo( () => {\n\t\treturn layout &&\n\t\t\t( layout?.type === 'constrained' ||\n\t\t\t\tlayout?.inherit ||\n\t\t\t\tlayout?.contentSize ||\n\t\t\t\tlayout?.wideSize )\n\t\t\t? { ...globalLayoutSettings, ...layout, type: 'constrained' }\n\t\t\t: { ...globalLayoutSettings, ...layout, type: 'default' };\n\t}, [\n\t\tlayout?.type,\n\t\tlayout?.inherit,\n\t\tlayout?.contentSize,\n\t\tlayout?.wideSize,\n\t\tglobalLayoutSettings,\n\t] );\n\n\t// If there is a Post Content block we use its layout for the block list;\n\t// if not, this must be a classic theme, in which case we use the fallback layout.\n\tconst blockListLayout = postContentAttributes\n\t\t? postContentLayout\n\t\t: fallbackLayout;\n\n\tconst postEditorLayout =\n\t\tblockListLayout?.type === 'default' && ! hasPostContentAtRootLevel\n\t\t\t? fallbackLayout\n\t\t\t: blockListLayout;\n\tconst observeTypingRef = useTypingObserver();\n\tconst titleRef = useRef();\n\tuseEffect( () => {\n\t\tif ( ! autoFocus || ! isCleanNewPost() ) {\n\t\t\treturn;\n\t\t}\n\t\ttitleRef?.current?.focus();\n\t}, [ autoFocus, isCleanNewPost ] );\n\n\t// Add some styles for alignwide/alignfull Post Content and its children.\n\tconst alignCSS = `.is-root-container.alignwide { max-width: var(--wp--style--global--wide-size); margin-left: auto; margin-right: auto;}\n\t\t.is-root-container.alignwide:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: var(--wp--style--global--wide-size);}\n\t\t.is-root-container.alignfull { max-width: none; margin-left: auto; margin-right: auto;}\n\t\t.is-root-container.alignfull:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: none;}`;\n\n\tconst forceFullHeight = postType === NAVIGATION_POST_TYPE;\n\tconst enableResizing =\n\t\t[\n\t\t\tNAVIGATION_POST_TYPE,\n\t\t\tTEMPLATE_PART_POST_TYPE,\n\t\t\tPATTERN_POST_TYPE,\n\t\t].includes( postType ) &&\n\t\t// Disable in previews / view mode.\n\t\t! isPreview &&\n\t\t// Disable resizing in mobile viewport.\n\t\t! isMobileViewport &&\n\t\t// Disable resizing in zoomed-out mode.\n\t\t! isZoomedOut;\n\n\tconst iframeStyles = useMemo( () => {\n\t\treturn [\n\t\t\t...( styles ?? [] ),\n\t\t\t{\n\t\t\t\t// Ensures margins of children are contained so that the body background paints behind them.\n\t\t\t\t// Otherwise, the background of html (when zoomed out) would show there and appear broken. It’s\n\t\t\t\t// important mostly for post-only views yet conceivably an issue in templated views too.\n\t\t\t\tcss: `:where(.block-editor-iframe__body){display:flow-root;}.is-root-container{display:flow-root;${\n\t\t\t\t\t// Some themes will have `min-height: 100vh` for the root container,\n\t\t\t\t\t// which isn't a requirement in auto resize mode.\n\t\t\t\t\tenableResizing ? 'min-height:0!important;' : ''\n\t\t\t\t}}`,\n\t\t\t},\n\t\t];\n\t}, [ styles, enableResizing ] );\n\n\tconst localRef = useRef();\n\tconst typewriterRef = useTypewriter();\n\tcontentRef = useMergeRefs( [\n\t\tlocalRef,\n\t\tcontentRef,\n\t\trenderingMode === 'post-only' ? typewriterRef : null,\n\t\tuseFlashEditableBlocks( {\n\t\t\tisEnabled: renderingMode === 'template-locked',\n\t\t} ),\n\t\tuseSelectNearestEditableBlock( {\n\t\t\tisEnabled: renderingMode === 'template-locked',\n\t\t} ),\n\t\tuseZoomOutModeExit(),\n\t\t// Avoid resize listeners when not needed, these will trigger\n\t\t// unnecessary re-renders when animating the iframe width.\n\t\tenableResizing ? effectContentHeight : null,\n\t] );\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ clsx(\n\t\t\t\t'editor-visual-editor',\n\t\t\t\t// this class is here for backward compatibility reasons.\n\t\t\t\t'edit-post-visual-editor',\n\t\t\t\tclassName,\n\t\t\t\t{\n\t\t\t\t\t'has-padding': isFocusedEntity || enableResizing,\n\t\t\t\t\t'is-resizable': enableResizing,\n\t\t\t\t\t'is-iframed': ! disableIframe,\n\t\t\t\t\t'is-scrollable': disableIframe || deviceType !== 'Desktop',\n\t\t\t\t}\n\t\t\t) }\n\t\t>\n\t\t\t<ResizableEditor\n\t\t\t\tenableResizing={ enableResizing }\n\t\t\t\theight={\n\t\t\t\t\tcontentHeight && ! forceFullHeight ? contentHeight : '100%'\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t<BlockCanvas\n\t\t\t\t\tshouldIframe={ ! disableIframe }\n\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t\tstyles={ iframeStyles }\n\t\t\t\t\theight=\"100%\"\n\t\t\t\t\tiframeProps={ {\n\t\t\t\t\t\t...iframeProps,\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t...iframeProps?.style,\n\t\t\t\t\t\t\t...deviceStyles,\n\t\t\t\t\t\t},\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ themeSupportsLayout &&\n\t\t\t\t\t\t! themeHasDisabledLayoutStyles &&\n\t\t\t\t\t\trenderingMode === 'post-only' &&\n\t\t\t\t\t\t! isDesignPostType && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\t\t\tselector=\".editor-visual-editor__post-title-wrapper\"\n\t\t\t\t\t\t\t\t\tlayout={ fallbackLayout }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\t\t\tselector=\".block-editor-block-list__layout.is-root-container\"\n\t\t\t\t\t\t\t\t\tlayout={ postEditorLayout }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ align && <LayoutStyle css={ alignCSS } /> }\n\t\t\t\t\t\t\t\t{ postContentLayoutStyles && (\n\t\t\t\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\t\t\t\tlayout={ postContentLayout }\n\t\t\t\t\t\t\t\t\t\tcss={ postContentLayoutStyles }\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{ renderingMode === 'post-only' && ! isDesignPostType && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t'editor-visual-editor__post-title-wrapper',\n\t\t\t\t\t\t\t\t// The following class is only here for backward compatibility\n\t\t\t\t\t\t\t\t// some themes might be using it to style the post title.\n\t\t\t\t\t\t\t\t'edit-post-visual-editor__post-title-wrapper',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'has-global-padding':\n\t\t\t\t\t\t\t\t\t\thasRootPaddingAwareAlignments,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tcontentEditable={ false }\n\t\t\t\t\t\t\tref={ observeTypingRef }\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t// This is using inline styles\n\t\t\t\t\t\t\t\t// so it's applied for both iframed and non iframed editors.\n\t\t\t\t\t\t\t\tmarginTop: '4rem',\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<PostTitle ref={ titleRef } />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t\t<RecursionProvider\n\t\t\t\t\t\tblockName={ wrapperBlockName }\n\t\t\t\t\t\tuniqueId={ wrapperUniqueId }\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockList\n\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t'is-' + deviceType.toLowerCase() + '-preview',\n\t\t\t\t\t\t\t\trenderingMode !== 'post-only' ||\n\t\t\t\t\t\t\t\t\tisDesignPostType\n\t\t\t\t\t\t\t\t\t? 'wp-site-blocks'\n\t\t\t\t\t\t\t\t\t: `${ blockListLayoutClass } wp-block-post-content`, // Ensure root level blocks receive default/flow blockGap styling rules.\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'has-global-padding':\n\t\t\t\t\t\t\t\t\t\trenderingMode === 'post-only' &&\n\t\t\t\t\t\t\t\t\t\t! isDesignPostType &&\n\t\t\t\t\t\t\t\t\t\thasRootPaddingAwareAlignments,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tlayout={ blockListLayout }\n\t\t\t\t\t\t\tdropZoneElement={\n\t\t\t\t\t\t\t\t// When iframed, pass in the html element of the iframe to\n\t\t\t\t\t\t\t\t// ensure the drop zone extends to the edges of the iframe.\n\t\t\t\t\t\t\t\tdisableIframe\n\t\t\t\t\t\t\t\t\t? localRef.current\n\t\t\t\t\t\t\t\t\t: localRef.current?.parentNode\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t__unstableDisableDropZone={\n\t\t\t\t\t\t\t\t// In template preview mode, disable drop zones at the root of the template.\n\t\t\t\t\t\t\t\trenderingMode === 'template-locked'\n\t\t\t\t\t\t\t\t\t? true\n\t\t\t\t\t\t\t\t\t: false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ renderingMode === 'template-locked' && (\n\t\t\t\t\t\t\t<EditTemplateBlocksNotification\n\t\t\t\t\t\t\t\tcontentRef={ localRef }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</RecursionProvider>\n\t\t\t\t</BlockCanvas>\n\t\t\t</ResizableEditor>\n\t\t</div>\n\t);\n}\n\nexport default VisualEditor;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SACCC,SAAS,EACTC,KAAK,IAAIC,gBAAgB,EACzBC,uBAAuB,IAAIC,aAAa,EACxCC,2BAA2B,IAAIC,iBAAiB,EAChDC,WAAW,EACXC,iBAAiB,EACjBC,WAAW,IAAIC,sBAAsB,EACrCC,6BAA6B,IAAIC,eAAe,QAC1C,yBAAyB;AAChC,SAASC,SAAS,EAAEC,MAAM,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACzE,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,QAAQ,mBAAmB;AACzC,SAASjB,KAAK,IAAIkB,SAAS,QAAQ,sBAAsB;AACzD,SACCC,YAAY,EACZC,gBAAgB,EAChBC,iBAAiB,QACX,oBAAoB;;AAE3B;AACA;AACA;AACA,OAAOC,SAAS,MAAM,eAAe;AACrC,SAAStB,KAAK,IAAIuB,WAAW,QAAQ,aAAa;AAClD,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,8BAA8B,MAAM,qCAAqC;AAChF,OAAOC,eAAe,MAAM,qBAAqB;AACjD,OAAOC,6BAA6B,MAAM,qCAAqC;AAC/E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F,aAAa,KAAK,WAAW,IAC5BO,gBAAgB,GACd,gBAAgB,GAChB,GAAIiD,oBAAoB,wBAAyB;YAAE;YACtD;cACC,oBAAoB,EACnBxD,aAAa,KAAK,WAAW,IAC7B,CAAEO,gBAAgB,IAClB0B;YACF,CACD,CAAG;YACHoB,MAAM,EAAGS,eAAiB;YAC1ByB,eAAe;YACd;YACA;YACAlG,aAAa,GACVoF,QAAQ,CAACP,OAAO,GAChBO,QAAQ,CAACP,OAAO,EAAEsB,UACrB;YACDC,yBAAyB;YACxB;YACAzF,aAAa,KAAK,iBAAiB,GAChC,IAAI,GACJ;UACH,CACD,CAAC,EACAA,aAAa,KAAK,iBAAiB,iBACpCnC,IAAA,CAACT,8BAA8B;YAC9BmC,UAAU,EAAGkF;UAAU,CACvB,CACD;QAAA,CACiB,CAAC;MAAA,CACR;IAAC,CACE;EAAC,CACd,CAAC;AAER;AAEA,eAAevF,YAAY","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["clsx","BlockList","store","blockEditorStore","__unstableUseTypewriter","useTypewriter","__unstableUseTypingObserver","useTypingObserver","useSettings","RecursionProvider","privateApis","blockEditorPrivateApis","__experimentalUseResizeCanvas","useResizeCanvas","useEffect","useRef","useMemo","useState","useSelect","parse","coreStore","useMergeRefs","useViewportMatch","useResizeObserver","PostTitle","editorStore","unlock","EditTemplateBlocksNotification","ResizableEditor","useSelectNearestEditableBlock","NAVIGATION_POST_TYPE","PATTERN_POST_TYPE","TEMPLATE_PART_POST_TYPE","TEMPLATE_POST_TYPE","useZoomOutModeExit","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","LayoutStyle","useLayoutClasses","useLayoutStyles","ExperimentalBlockCanvas","BlockCanvas","useFlashEditableBlocks","DESIGN_POST_TYPES","getPostContentAttributes","blocks","i","length","name","attributes","innerBlocks","nestedPostContent","checkForPostContentAtRootLevel","VisualEditor","autoFocus","styles","disableIframe","iframeProps","contentRef","className","contentHeight","setContentHeight","effectContentHeight","entry","borderBoxSize","blockSize","isMobileViewport","renderingMode","postContentAttributes","editedPostTemplate","wrapperBlockName","wrapperUniqueId","deviceType","isFocusedEntity","isDesignPostType","postType","isPreview","select","getCurrentPostId","getCurrentPostType","getCurrentTemplateId","getEditorSettings","getRenderingMode","getDeviceType","getPostType","getEditedEntityRecord","postTypeSlug","_renderingMode","_wrapperBlockName","editorSettings","supportsTemplateMode","postTypeObject","currentTemplateId","template","undefined","includes","viewable","onNavigateToPreviousEntityRecord","isPreviewMode","isCleanNewPost","hasRootPaddingAwareAlignments","themeHasDisabledLayoutStyles","themeSupportsLayout","isZoomedOut","getSettings","isZoomOut","_isZoomOut","_settings","disableLayoutStyles","supportsLayout","__experimentalFeatures","useRootPaddingAwareAlignments","deviceStyles","globalLayoutSettings","fallbackLayout","type","newestPostContentAttributes","content","parseableContent","hasPostContentAtRootLevel","layout","align","postContentLayoutClasses","blockListLayoutClass","postContentLayoutStyles","postContentLayout","inherit","contentSize","wideSize","blockListLayout","postEditorLayout","observeTypingRef","titleRef","current","focus","alignCSS","forceFullHeight","enableResizing","iframeStyles","css","localRef","typewriterRef","isEnabled","children","height","shouldIframe","style","selector","contentEditable","ref","marginTop","blockName","uniqueId","toLowerCase","dropZoneElement","parentNode","__unstableDisableDropZone"],"sources":["@wordpress/editor/src/components/visual-editor/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBlockList,\n\tstore as blockEditorStore,\n\t__unstableUseTypewriter as useTypewriter,\n\t__unstableUseTypingObserver as useTypingObserver,\n\tuseSettings,\n\tRecursionProvider,\n\tprivateApis as blockEditorPrivateApis,\n\t__experimentalUseResizeCanvas as useResizeCanvas,\n} from '@wordpress/block-editor';\nimport { useEffect, useRef, useMemo, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { parse } from '@wordpress/blocks';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tuseMergeRefs,\n\tuseViewportMatch,\n\tuseResizeObserver,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport PostTitle from '../post-title';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport EditTemplateBlocksNotification from './edit-template-blocks-notification';\nimport ResizableEditor from '../resizable-editor';\nimport useSelectNearestEditableBlock from './use-select-nearest-editable-block';\nimport {\n\tNAVIGATION_POST_TYPE,\n\tPATTERN_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tTEMPLATE_POST_TYPE,\n} from '../../store/constants';\nimport { useZoomOutModeExit } from './use-zoom-out-mode-exit';\n\nconst {\n\tLayoutStyle,\n\tuseLayoutClasses,\n\tuseLayoutStyles,\n\tExperimentalBlockCanvas: BlockCanvas,\n\tuseFlashEditableBlocks,\n} = unlock( blockEditorPrivateApis );\n\n/**\n * These post types have a special editor where they don't allow you to fill the title\n * and they don't apply the layout styles.\n */\nconst DESIGN_POST_TYPES = [\n\tPATTERN_POST_TYPE,\n\tTEMPLATE_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n];\n\n/**\n * Given an array of nested blocks, find the first Post Content\n * block inside it, recursing through any nesting levels,\n * and return its attributes.\n *\n * @param {Array} blocks A list of blocks.\n *\n * @return {Object | undefined} The Post Content block.\n */\nfunction getPostContentAttributes( blocks ) {\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\tif ( blocks[ i ].name === 'core/post-content' ) {\n\t\t\treturn blocks[ i ].attributes;\n\t\t}\n\t\tif ( blocks[ i ].innerBlocks.length ) {\n\t\t\tconst nestedPostContent = getPostContentAttributes(\n\t\t\t\tblocks[ i ].innerBlocks\n\t\t\t);\n\n\t\t\tif ( nestedPostContent ) {\n\t\t\t\treturn nestedPostContent;\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction checkForPostContentAtRootLevel( blocks ) {\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\tif ( blocks[ i ].name === 'core/post-content' ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\nfunction VisualEditor( {\n\t// Ideally as we unify post and site editors, we won't need these props.\n\tautoFocus,\n\tstyles,\n\tdisableIframe = false,\n\tiframeProps,\n\tcontentRef,\n\tclassName,\n} ) {\n\tconst [ contentHeight, setContentHeight ] = useState( '' );\n\tconst effectContentHeight = useResizeObserver( ( [ entry ] ) => {\n\t\tsetContentHeight( entry.borderBoxSize[ 0 ].blockSize );\n\t} );\n\tconst isMobileViewport = useViewportMatch( 'small', '<' );\n\tconst {\n\t\trenderingMode,\n\t\tpostContentAttributes,\n\t\teditedPostTemplate = {},\n\t\twrapperBlockName,\n\t\twrapperUniqueId,\n\t\tdeviceType,\n\t\tisFocusedEntity,\n\t\tisDesignPostType,\n\t\tpostType,\n\t\tisPreview,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetCurrentPostId,\n\t\t\tgetCurrentPostType,\n\t\t\tgetCurrentTemplateId,\n\t\t\tgetEditorSettings,\n\t\t\tgetRenderingMode,\n\t\t\tgetDeviceType,\n\t\t} = select( editorStore );\n\t\tconst { getPostType, getEditedEntityRecord } = select( coreStore );\n\t\tconst postTypeSlug = getCurrentPostType();\n\t\tconst _renderingMode = getRenderingMode();\n\t\tlet _wrapperBlockName;\n\n\t\tif ( postTypeSlug === PATTERN_POST_TYPE ) {\n\t\t\t_wrapperBlockName = 'core/block';\n\t\t} else if ( _renderingMode === 'post-only' ) {\n\t\t\t_wrapperBlockName = 'core/post-content';\n\t\t}\n\n\t\tconst editorSettings = getEditorSettings();\n\t\tconst supportsTemplateMode = editorSettings.supportsTemplateMode;\n\t\tconst postTypeObject = getPostType( postTypeSlug );\n\t\tconst currentTemplateId = getCurrentTemplateId();\n\t\tconst template = currentTemplateId\n\t\t\t? getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t\tcurrentTemplateId\n\t\t\t )\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\trenderingMode: _renderingMode,\n\t\t\tpostContentAttributes: editorSettings.postContentAttributes,\n\t\t\tisDesignPostType: DESIGN_POST_TYPES.includes( postTypeSlug ),\n\t\t\t// Post template fetch returns a 404 on classic themes, which\n\t\t\t// messes with e2e tests, so check it's a block theme first.\n\t\t\teditedPostTemplate:\n\t\t\t\tpostTypeObject?.viewable && supportsTemplateMode\n\t\t\t\t\t? template\n\t\t\t\t\t: undefined,\n\t\t\twrapperBlockName: _wrapperBlockName,\n\t\t\twrapperUniqueId: getCurrentPostId(),\n\t\t\tdeviceType: getDeviceType(),\n\t\t\tisFocusedEntity: !! editorSettings.onNavigateToPreviousEntityRecord,\n\t\t\tpostType: postTypeSlug,\n\t\t\tisPreview: editorSettings.isPreviewMode,\n\t\t};\n\t}, [] );\n\tconst { isCleanNewPost } = useSelect( editorStore );\n\tconst {\n\t\thasRootPaddingAwareAlignments,\n\t\tthemeHasDisabledLayoutStyles,\n\t\tthemeSupportsLayout,\n\t\tisZoomedOut,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSettings, isZoomOut: _isZoomOut } = unlock(\n\t\t\tselect( blockEditorStore )\n\t\t);\n\n\t\tconst _settings = getSettings();\n\t\treturn {\n\t\t\tthemeHasDisabledLayoutStyles: _settings.disableLayoutStyles,\n\t\t\tthemeSupportsLayout: _settings.supportsLayout,\n\t\t\thasRootPaddingAwareAlignments:\n\t\t\t\t_settings.__experimentalFeatures?.useRootPaddingAwareAlignments,\n\t\t\tisZoomedOut: _isZoomOut(),\n\t\t};\n\t}, [] );\n\n\tconst deviceStyles = useResizeCanvas( deviceType );\n\tconst [ globalLayoutSettings ] = useSettings( 'layout' );\n\n\t// fallbackLayout is used if there is no Post Content,\n\t// and for Post Title.\n\tconst fallbackLayout = useMemo( () => {\n\t\tif ( renderingMode !== 'post-only' || isDesignPostType ) {\n\t\t\treturn { type: 'default' };\n\t\t}\n\n\t\tif ( themeSupportsLayout ) {\n\t\t\t// We need to ensure support for wide and full alignments,\n\t\t\t// so we add the constrained type.\n\t\t\treturn { ...globalLayoutSettings, type: 'constrained' };\n\t\t}\n\t\t// Set default layout for classic themes so all alignments are supported.\n\t\treturn { type: 'default' };\n\t}, [\n\t\trenderingMode,\n\t\tthemeSupportsLayout,\n\t\tglobalLayoutSettings,\n\t\tisDesignPostType,\n\t] );\n\n\tconst newestPostContentAttributes = useMemo( () => {\n\t\tif (\n\t\t\t! editedPostTemplate?.content &&\n\t\t\t! editedPostTemplate?.blocks &&\n\t\t\tpostContentAttributes\n\t\t) {\n\t\t\treturn postContentAttributes;\n\t\t}\n\t\t// When in template editing mode, we can access the blocks directly.\n\t\tif ( editedPostTemplate?.blocks ) {\n\t\t\treturn getPostContentAttributes( editedPostTemplate?.blocks );\n\t\t}\n\t\t// If there are no blocks, we have to parse the content string.\n\t\t// Best double-check it's a string otherwise the parse function gets unhappy.\n\t\tconst parseableContent =\n\t\t\ttypeof editedPostTemplate?.content === 'string'\n\t\t\t\t? editedPostTemplate?.content\n\t\t\t\t: '';\n\n\t\treturn getPostContentAttributes( parse( parseableContent ) ) || {};\n\t}, [\n\t\teditedPostTemplate?.content,\n\t\teditedPostTemplate?.blocks,\n\t\tpostContentAttributes,\n\t] );\n\n\tconst hasPostContentAtRootLevel = useMemo( () => {\n\t\tif ( ! editedPostTemplate?.content && ! editedPostTemplate?.blocks ) {\n\t\t\treturn false;\n\t\t}\n\t\t// When in template editing mode, we can access the blocks directly.\n\t\tif ( editedPostTemplate?.blocks ) {\n\t\t\treturn checkForPostContentAtRootLevel( editedPostTemplate?.blocks );\n\t\t}\n\t\t// If there are no blocks, we have to parse the content string.\n\t\t// Best double-check it's a string otherwise the parse function gets unhappy.\n\t\tconst parseableContent =\n\t\t\ttypeof editedPostTemplate?.content === 'string'\n\t\t\t\t? editedPostTemplate?.content\n\t\t\t\t: '';\n\n\t\treturn (\n\t\t\tcheckForPostContentAtRootLevel( parse( parseableContent ) ) || false\n\t\t);\n\t}, [ editedPostTemplate?.content, editedPostTemplate?.blocks ] );\n\n\tconst { layout = {}, align = '' } = newestPostContentAttributes || {};\n\n\tconst postContentLayoutClasses = useLayoutClasses(\n\t\tnewestPostContentAttributes,\n\t\t'core/post-content'\n\t);\n\n\tconst blockListLayoutClass = clsx(\n\t\t{\n\t\t\t'is-layout-flow': ! themeSupportsLayout,\n\t\t},\n\t\tthemeSupportsLayout && postContentLayoutClasses,\n\t\talign && `align${ align }`\n\t);\n\n\tconst postContentLayoutStyles = useLayoutStyles(\n\t\tnewestPostContentAttributes,\n\t\t'core/post-content',\n\t\t'.block-editor-block-list__layout.is-root-container'\n\t);\n\n\t// Update type for blocks using legacy layouts.\n\tconst postContentLayout = useMemo( () => {\n\t\treturn layout &&\n\t\t\t( layout?.type === 'constrained' ||\n\t\t\t\tlayout?.inherit ||\n\t\t\t\tlayout?.contentSize ||\n\t\t\t\tlayout?.wideSize )\n\t\t\t? { ...globalLayoutSettings, ...layout, type: 'constrained' }\n\t\t\t: { ...globalLayoutSettings, ...layout, type: 'default' };\n\t}, [\n\t\tlayout?.type,\n\t\tlayout?.inherit,\n\t\tlayout?.contentSize,\n\t\tlayout?.wideSize,\n\t\tglobalLayoutSettings,\n\t] );\n\n\t// If there is a Post Content block we use its layout for the block list;\n\t// if not, this must be a classic theme, in which case we use the fallback layout.\n\tconst blockListLayout = postContentAttributes\n\t\t? postContentLayout\n\t\t: fallbackLayout;\n\n\tconst postEditorLayout =\n\t\tblockListLayout?.type === 'default' && ! hasPostContentAtRootLevel\n\t\t\t? fallbackLayout\n\t\t\t: blockListLayout;\n\tconst observeTypingRef = useTypingObserver();\n\tconst titleRef = useRef();\n\tuseEffect( () => {\n\t\tif ( ! autoFocus || ! isCleanNewPost() ) {\n\t\t\treturn;\n\t\t}\n\t\ttitleRef?.current?.focus();\n\t}, [ autoFocus, isCleanNewPost ] );\n\n\t// Add some styles for alignwide/alignfull Post Content and its children.\n\tconst alignCSS = `.is-root-container.alignwide { max-width: var(--wp--style--global--wide-size); margin-left: auto; margin-right: auto;}\n\t\t.is-root-container.alignwide:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: var(--wp--style--global--wide-size);}\n\t\t.is-root-container.alignfull { max-width: none; margin-left: auto; margin-right: auto;}\n\t\t.is-root-container.alignfull:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: none;}`;\n\n\tconst forceFullHeight = postType === NAVIGATION_POST_TYPE;\n\tconst enableResizing =\n\t\t[\n\t\t\tNAVIGATION_POST_TYPE,\n\t\t\tTEMPLATE_PART_POST_TYPE,\n\t\t\tPATTERN_POST_TYPE,\n\t\t].includes( postType ) &&\n\t\t// Disable in previews / view mode.\n\t\t! isPreview &&\n\t\t// Disable resizing in mobile viewport.\n\t\t! isMobileViewport &&\n\t\t// Disable resizing in zoomed-out mode.\n\t\t! isZoomedOut;\n\n\tconst iframeStyles = useMemo( () => {\n\t\treturn [\n\t\t\t...( styles ?? [] ),\n\t\t\t{\n\t\t\t\t// Ensures margins of children are contained so that the body background paints behind them.\n\t\t\t\t// Otherwise, the background of html (when zoomed out) would show there and appear broken. It’s\n\t\t\t\t// important mostly for post-only views yet conceivably an issue in templated views too.\n\t\t\t\tcss: `:where(.block-editor-iframe__body){display:flow-root;}.is-root-container{display:flow-root;${\n\t\t\t\t\t// Some themes will have `min-height: 100vh` for the root container,\n\t\t\t\t\t// which isn't a requirement in auto resize mode.\n\t\t\t\t\tenableResizing ? 'min-height:0!important;' : ''\n\t\t\t\t}}`,\n\t\t\t},\n\t\t];\n\t}, [ styles, enableResizing ] );\n\n\tconst localRef = useRef();\n\tconst typewriterRef = useTypewriter();\n\tcontentRef = useMergeRefs( [\n\t\tlocalRef,\n\t\tcontentRef,\n\t\trenderingMode === 'post-only' ? typewriterRef : null,\n\t\tuseFlashEditableBlocks( {\n\t\t\tisEnabled: renderingMode === 'template-locked',\n\t\t} ),\n\t\tuseSelectNearestEditableBlock( {\n\t\t\tisEnabled: renderingMode === 'template-locked',\n\t\t} ),\n\t\tuseZoomOutModeExit(),\n\t\t// Avoid resize listeners when not needed, these will trigger\n\t\t// unnecessary re-renders when animating the iframe width.\n\t\tenableResizing ? effectContentHeight : null,\n\t] );\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ clsx(\n\t\t\t\t'editor-visual-editor',\n\t\t\t\t// this class is here for backward compatibility reasons.\n\t\t\t\t'edit-post-visual-editor',\n\t\t\t\tclassName,\n\t\t\t\t{\n\t\t\t\t\t'has-padding': isFocusedEntity || enableResizing,\n\t\t\t\t\t'is-resizable': enableResizing,\n\t\t\t\t\t'is-iframed': ! disableIframe,\n\t\t\t\t}\n\t\t\t) }\n\t\t>\n\t\t\t<ResizableEditor\n\t\t\t\tenableResizing={ enableResizing }\n\t\t\t\theight={\n\t\t\t\t\tcontentHeight && ! forceFullHeight ? contentHeight : '100%'\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t<BlockCanvas\n\t\t\t\t\tshouldIframe={ ! disableIframe }\n\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t\tstyles={ iframeStyles }\n\t\t\t\t\theight=\"100%\"\n\t\t\t\t\tiframeProps={ {\n\t\t\t\t\t\t...iframeProps,\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t...iframeProps?.style,\n\t\t\t\t\t\t\t...deviceStyles,\n\t\t\t\t\t\t},\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ themeSupportsLayout &&\n\t\t\t\t\t\t! themeHasDisabledLayoutStyles &&\n\t\t\t\t\t\trenderingMode === 'post-only' &&\n\t\t\t\t\t\t! isDesignPostType && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\t\t\tselector=\".editor-visual-editor__post-title-wrapper\"\n\t\t\t\t\t\t\t\t\tlayout={ fallbackLayout }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\t\t\tselector=\".block-editor-block-list__layout.is-root-container\"\n\t\t\t\t\t\t\t\t\tlayout={ postEditorLayout }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ align && <LayoutStyle css={ alignCSS } /> }\n\t\t\t\t\t\t\t\t{ postContentLayoutStyles && (\n\t\t\t\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\t\t\t\tlayout={ postContentLayout }\n\t\t\t\t\t\t\t\t\t\tcss={ postContentLayoutStyles }\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{ renderingMode === 'post-only' && ! isDesignPostType && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t'editor-visual-editor__post-title-wrapper',\n\t\t\t\t\t\t\t\t// The following class is only here for backward compatibility\n\t\t\t\t\t\t\t\t// some themes might be using it to style the post title.\n\t\t\t\t\t\t\t\t'edit-post-visual-editor__post-title-wrapper',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'has-global-padding':\n\t\t\t\t\t\t\t\t\t\thasRootPaddingAwareAlignments,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tcontentEditable={ false }\n\t\t\t\t\t\t\tref={ observeTypingRef }\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t// This is using inline styles\n\t\t\t\t\t\t\t\t// so it's applied for both iframed and non iframed editors.\n\t\t\t\t\t\t\t\tmarginTop: '4rem',\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<PostTitle ref={ titleRef } />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t\t<RecursionProvider\n\t\t\t\t\t\tblockName={ wrapperBlockName }\n\t\t\t\t\t\tuniqueId={ wrapperUniqueId }\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockList\n\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t'is-' + deviceType.toLowerCase() + '-preview',\n\t\t\t\t\t\t\t\trenderingMode !== 'post-only' ||\n\t\t\t\t\t\t\t\t\tisDesignPostType\n\t\t\t\t\t\t\t\t\t? 'wp-site-blocks'\n\t\t\t\t\t\t\t\t\t: `${ blockListLayoutClass } wp-block-post-content`, // Ensure root level blocks receive default/flow blockGap styling rules.\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'has-global-padding':\n\t\t\t\t\t\t\t\t\t\trenderingMode === 'post-only' &&\n\t\t\t\t\t\t\t\t\t\t! isDesignPostType &&\n\t\t\t\t\t\t\t\t\t\thasRootPaddingAwareAlignments,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tlayout={ blockListLayout }\n\t\t\t\t\t\t\tdropZoneElement={\n\t\t\t\t\t\t\t\t// When iframed, pass in the html element of the iframe to\n\t\t\t\t\t\t\t\t// ensure the drop zone extends to the edges of the iframe.\n\t\t\t\t\t\t\t\tdisableIframe\n\t\t\t\t\t\t\t\t\t? localRef.current\n\t\t\t\t\t\t\t\t\t: localRef.current?.parentNode\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t__unstableDisableDropZone={\n\t\t\t\t\t\t\t\t// In template preview mode, disable drop zones at the root of the template.\n\t\t\t\t\t\t\t\trenderingMode === 'template-locked'\n\t\t\t\t\t\t\t\t\t? true\n\t\t\t\t\t\t\t\t\t: false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ renderingMode === 'template-locked' && (\n\t\t\t\t\t\t\t<EditTemplateBlocksNotification\n\t\t\t\t\t\t\t\tcontentRef={ localRef }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</RecursionProvider>\n\t\t\t\t</BlockCanvas>\n\t\t\t</ResizableEditor>\n\t\t</div>\n\t);\n}\n\nexport default VisualE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,CAAC;MAAA,CACR;IAAC,CACE;EAAC,CACd,CAAC;AAER;AAEA,eAAevF,YAAY","ignoreList":[]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import removeAccents from 'remove-accents';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Sanitizes the search input string.
|
|
8
|
+
*
|
|
9
|
+
* @param {string} input The search input to normalize.
|
|
10
|
+
*
|
|
11
|
+
* @return {string} The normalized search input.
|
|
12
|
+
*/
|
|
13
|
+
function normalizeSearchInput(input = '') {
|
|
14
|
+
// Disregard diacritics.
|
|
15
|
+
input = removeAccents(input);
|
|
16
|
+
|
|
17
|
+
// Trim & Lowercase.
|
|
18
|
+
input = input.trim().toLowerCase();
|
|
19
|
+
return input;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Get the search rank for a given template and a specific search term.
|
|
24
|
+
*
|
|
25
|
+
* @param {Object} template Template to rank
|
|
26
|
+
* @param {string} searchValue Search term
|
|
27
|
+
*
|
|
28
|
+
* @return {number} A template search rank
|
|
29
|
+
*/
|
|
30
|
+
function getTemplateSearchRank(template, searchValue) {
|
|
31
|
+
const normalizedSearchValue = normalizeSearchInput(searchValue);
|
|
32
|
+
const normalizedTitle = normalizeSearchInput(template.title);
|
|
33
|
+
let rank = 0;
|
|
34
|
+
if (normalizedSearchValue === normalizedTitle) {
|
|
35
|
+
rank += 30;
|
|
36
|
+
} else if (normalizedTitle.startsWith(normalizedSearchValue)) {
|
|
37
|
+
rank += 20;
|
|
38
|
+
} else {
|
|
39
|
+
const searchTerms = normalizedSearchValue.split(' ');
|
|
40
|
+
const hasMatchedTerms = searchTerms.every(searchTerm => normalizedTitle.includes(searchTerm));
|
|
41
|
+
|
|
42
|
+
// Prefer template with every search word in the title.
|
|
43
|
+
if (hasMatchedTerms) {
|
|
44
|
+
rank += 10;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return rank;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Filters a template list given a search term.
|
|
52
|
+
*
|
|
53
|
+
* @param {Array} templates Item list
|
|
54
|
+
* @param {string} searchValue Search input.
|
|
55
|
+
*
|
|
56
|
+
* @return {Array} Filtered template list.
|
|
57
|
+
*/
|
|
58
|
+
export function searchTemplates(templates = [], searchValue = '') {
|
|
59
|
+
if (!searchValue) {
|
|
60
|
+
return templates;
|
|
61
|
+
}
|
|
62
|
+
const rankedTemplates = templates.map(template => {
|
|
63
|
+
return [template, getTemplateSearchRank(template, searchValue)];
|
|
64
|
+
}).filter(([, rank]) => rank > 0);
|
|
65
|
+
rankedTemplates.sort(([, rank1], [, rank2]) => rank2 - rank1);
|
|
66
|
+
return rankedTemplates.map(([template]) => template);
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=search-templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["removeAccents","normalizeSearchInput","input","trim","toLowerCase","getTemplateSearchRank","template","searchValue","normalizedSearchValue","normalizedTitle","title","rank","startsWith","searchTerms","split","hasMatchedTerms","every","searchTerm","includes","searchTemplates","templates","rankedTemplates","map","filter","sort","rank1","rank2"],"sources":["@wordpress/editor/src/utils/search-templates.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * Sanitizes the search input string.\n *\n * @param {string} input The search input to normalize.\n *\n * @return {string} The normalized search input.\n */\nfunction normalizeSearchInput( input = '' ) {\n\t// Disregard diacritics.\n\tinput = removeAccents( input );\n\n\t// Trim & Lowercase.\n\tinput = input.trim().toLowerCase();\n\n\treturn input;\n}\n\n/**\n * Get the search rank for a given template and a specific search term.\n *\n * @param {Object} template Template to rank\n * @param {string} searchValue Search term\n *\n * @return {number} A template search rank\n */\nfunction getTemplateSearchRank( template, searchValue ) {\n\tconst normalizedSearchValue = normalizeSearchInput( searchValue );\n\tconst normalizedTitle = normalizeSearchInput( template.title );\n\n\tlet rank = 0;\n\n\tif ( normalizedSearchValue === normalizedTitle ) {\n\t\trank += 30;\n\t} else if ( normalizedTitle.startsWith( normalizedSearchValue ) ) {\n\t\trank += 20;\n\t} else {\n\t\tconst searchTerms = normalizedSearchValue.split( ' ' );\n\t\tconst hasMatchedTerms = searchTerms.every( ( searchTerm ) =>\n\t\t\tnormalizedTitle.includes( searchTerm )\n\t\t);\n\n\t\t// Prefer template with every search word in the title.\n\t\tif ( hasMatchedTerms ) {\n\t\t\trank += 10;\n\t\t}\n\t}\n\n\treturn rank;\n}\n\n/**\n * Filters a template list given a search term.\n *\n * @param {Array} templates Item list\n * @param {string} searchValue Search input.\n *\n * @return {Array} Filtered template list.\n */\nexport function searchTemplates( templates = [], searchValue = '' ) {\n\tif ( ! searchValue ) {\n\t\treturn templates;\n\t}\n\n\tconst rankedTemplates = templates\n\t\t.map( ( template ) => {\n\t\t\treturn [ template, getTemplateSearchRank( template, searchValue ) ];\n\t\t} )\n\t\t.filter( ( [ , rank ] ) => rank > 0 );\n\n\trankedTemplates.sort( ( [ , rank1 ], [ , rank2 ] ) => rank2 - rank1 );\n\treturn rankedTemplates.map( ( [ template ] ) => template );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,gBAAgB;;AAE1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,oBAAoBA,CAAEC,KAAK,GAAG,EAAE,EAAG;EAC3C;EACAA,KAAK,GAAGF,aAAa,CAAEE,KAAM,CAAC;;EAE9B;EACAA,KAAK,GAAGA,KAAK,CAACC,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC;EAElC,OAAOF,KAAK;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASG,qBAAqBA,CAAEC,QAAQ,EAAEC,WAAW,EAAG;EACvD,MAAMC,qBAAqB,GAAGP,oBAAoB,CAAEM,WAAY,CAAC;EACjE,MAAME,eAA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
935
|
}
|
|
936
936
|
|
|
937
937
|
.editor-visual-editor {
|
|
938
|
-
flex: 1
|
|
938
|
+
flex: 1 0 auto;
|
|
939
939
|
}
|
|
940
940
|
|
|
941
941
|
.components-editor-notices__dismissible,
|
|
@@ -2042,6 +2042,15 @@ body.is-fullscreen-mode .interface-interface-skeleton {
|
|
|
2042
2042
|
.editor-post-template__swap-template-modal {
|
|
2043
2043
|
z-index: 1000001;
|
|
2044
2044
|
}
|
|
2045
|
+
.editor-post-template__swap-template-modal .editor-post-template__swap-template-search {
|
|
2046
|
+
background: #fff;
|
|
2047
|
+
position: sticky;
|
|
2048
|
+
top: 0;
|
|
2049
|
+
padding: 16px 0;
|
|
2050
|
+
transform: translateY(-4px);
|
|
2051
|
+
margin-bottom: -4px;
|
|
2052
|
+
z-index: 2;
|
|
2053
|
+
}
|
|
2045
2054
|
|
|
2046
2055
|
.editor-post-template__create-template-modal {
|
|
2047
2056
|
z-index: 1000001;
|
|
@@ -2513,7 +2522,6 @@ textarea.editor-post-text-editor:-ms-input-placeholder {
|
|
|
2513
2522
|
position: relative;
|
|
2514
2523
|
display: flex;
|
|
2515
2524
|
background-color: #ddd;
|
|
2516
|
-
overflow: hidden;
|
|
2517
2525
|
align-items: center;
|
|
2518
2526
|
}
|
|
2519
2527
|
.editor-visual-editor iframe[name=editor-canvas] {
|
|
@@ -2525,6 +2533,9 @@ textarea.editor-post-text-editor:-ms-input-placeholder {
|
|
|
2525
2533
|
.editor-visual-editor.has-padding {
|
|
2526
2534
|
padding: 24px 24px 0;
|
|
2527
2535
|
}
|
|
2536
|
+
.editor-visual-editor.is-iframed {
|
|
2537
|
+
overflow: hidden;
|
|
2538
|
+
}
|
|
2528
2539
|
.editor-visual-editor .components-button {
|
|
2529
2540
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
|
2530
2541
|
font-size: 13px;
|
|
@@ -2533,22 +2544,6 @@ textarea.editor-post-text-editor:-ms-input-placeholder {
|
|
|
2533
2544
|
.editor-visual-editor .components-button.is-tertiary, .editor-visual-editor .components-button.has-icon {
|
|
2534
2545
|
padding: 6px;
|
|
2535
2546
|
}
|
|
2536
|
-
.editor-visual-editor.is-scrollable .block-editor-block-canvas {
|
|
2537
|
-
overflow: auto;
|
|
2538
|
-
}
|
|
2539
|
-
.editor-visual-editor.is-scrollable .block-editor-block-canvas > .block-editor-writing-flow {
|
|
2540
|
-
display: flow-root;
|
|
2541
|
-
min-height: 100%;
|
|
2542
|
-
box-sizing: border-box;
|
|
2543
|
-
}
|
|
2544
|
-
.editor-visual-editor.is-scrollable .block-editor-block-canvas > .block-editor-iframe__container {
|
|
2545
|
-
display: flex;
|
|
2546
|
-
flex-direction: column;
|
|
2547
|
-
}
|
|
2548
|
-
.editor-visual-editor.is-scrollable .block-editor-block-canvas > .block-editor-iframe__container > .block-editor-iframe__scale-container {
|
|
2549
|
-
flex: 1 0 fit-content;
|
|
2550
|
-
display: flow-root;
|
|
2551
|
-
}
|
|
2552
2547
|
|
|
2553
2548
|
.editor-fields-content-preview {
|
|
2554
2549
|
display: flex;
|
package/build-style/style.css
CHANGED
|
@@ -935,7 +935,7 @@ body.is-fullscreen-mode .interface-interface-skeleton {
|
|
|
935
935
|
}
|
|
936
936
|
|
|
937
937
|
.editor-visual-editor {
|
|
938
|
-
flex: 1
|
|
938
|
+
flex: 1 0 auto;
|
|
939
939
|
}
|
|
940
940
|
|
|
941
941
|
.components-editor-notices__dismissible,
|
|
@@ -2042,6 +2042,15 @@ body.is-fullscreen-mode .interface-interface-skeleton {
|
|
|
2042
2042
|
.editor-post-template__swap-template-modal {
|
|
2043
2043
|
z-index: 1000001;
|
|
2044
2044
|
}
|
|
2045
|
+
.editor-post-template__swap-template-modal .editor-post-template__swap-template-search {
|
|
2046
|
+
background: #fff;
|
|
2047
|
+
position: sticky;
|
|
2048
|
+
top: 0;
|
|
2049
|
+
padding: 16px 0;
|
|
2050
|
+
transform: translateY(-4px);
|
|
2051
|
+
margin-bottom: -4px;
|
|
2052
|
+
z-index: 2;
|
|
2053
|
+
}
|
|
2045
2054
|
|
|
2046
2055
|
.editor-post-template__create-template-modal {
|
|
2047
2056
|
z-index: 1000001;
|
|
@@ -2517,7 +2526,6 @@ textarea.editor-post-text-editor:-ms-input-placeholder {
|
|
|
2517
2526
|
position: relative;
|
|
2518
2527
|
display: flex;
|
|
2519
2528
|
background-color: #ddd;
|
|
2520
|
-
overflow: hidden;
|
|
2521
2529
|
align-items: center;
|
|
2522
2530
|
}
|
|
2523
2531
|
.editor-visual-editor iframe[name=editor-canvas] {
|
|
@@ -2529,6 +2537,9 @@ textarea.editor-post-text-editor:-ms-input-placeholder {
|
|
|
2529
2537
|
.editor-visual-editor.has-padding {
|
|
2530
2538
|
padding: 24px 24px 0;
|
|
2531
2539
|
}
|
|
2540
|
+
.editor-visual-editor.is-iframed {
|
|
2541
|
+
overflow: hidden;
|
|
2542
|
+
}
|
|
2532
2543
|
.editor-visual-editor .components-button {
|
|
2533
2544
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
|
2534
2545
|
font-size: 13px;
|
|
@@ -2537,22 +2548,6 @@ textarea.editor-post-text-editor:-ms-input-placeholder {
|
|
|
2537
2548
|
.editor-visual-editor .components-button.is-tertiary, .editor-visual-editor .components-button.has-icon {
|
|
2538
2549
|
padding: 6px;
|
|
2539
2550
|
}
|
|
2540
|
-
.editor-visual-editor.is-scrollable .block-editor-block-canvas {
|
|
2541
|
-
overflow: auto;
|
|
2542
|
-
}
|
|
2543
|
-
.editor-visual-editor.is-scrollable .block-editor-block-canvas > .block-editor-writing-flow {
|
|
2544
|
-
display: flow-root;
|
|
2545
|
-
min-height: 100%;
|
|
2546
|
-
box-sizing: border-box;
|
|
2547
|
-
}
|
|
2548
|
-
.editor-visual-editor.is-scrollable .block-editor-block-canvas > .block-editor-iframe__container {
|
|
2549
|
-
display: flex;
|
|
2550
|
-
flex-direction: column;
|
|
2551
|
-
}
|
|
2552
|
-
.editor-visual-editor.is-scrollable .block-editor-block-canvas > .block-editor-iframe__container > .block-editor-iframe__scale-container {
|
|
2553
|
-
flex: 1 0 fit-content;
|
|
2554
|
-
display: flow-root;
|
|
2555
|
-
}
|
|
2556
2551
|
|
|
2557
2552
|
.editor-fields-content-preview {
|
|
2558
2553
|
display: flex;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../../src/components/post-author/check.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../../src/components/post-author/check.js"],"names":[],"mappings":"AAWA;;;;;;;;GAQG;AACH,sDALG;IAA+B,QAAQ,EAA/B,KAAK,CAAC,SAAS;CAEvB,GAAS,KAAK,CAAC,SAAS,CAuB1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panel.d.ts","sourceRoot":"","sources":["../../../src/components/post-author/panel.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"panel.d.ts","sourceRoot":"","sources":["../../../src/components/post-author/panel.js"],"names":[],"mappings":"AA8CA;;;;GAIG;AACH,8BAFY,KAAK,CAAC,SAAS,CA4C1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swap-template-button.d.ts","sourceRoot":"","sources":["../../../src/components/post-template/swap-template-button.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"swap-template-button.d.ts","sourceRoot":"","sources":["../../../src/components/post-template/swap-template-button.js"],"names":[],"mappings":"AAkBA;;gCA2CC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/visual-editor/index.js"],"names":[],"mappings":";AAmGA;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/visual-editor/index.js"],"names":[],"mappings":";AAmGA;;;;;;;gCA8YC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filters a template list given a search term.
|
|
3
|
+
*
|
|
4
|
+
* @param {Array} templates Item list
|
|
5
|
+
* @param {string} searchValue Search input.
|
|
6
|
+
*
|
|
7
|
+
* @return {Array} Filtered template list.
|
|
8
|
+
*/
|
|
9
|
+
export function searchTemplates(templates?: any[], searchValue?: string): any[];
|
|
10
|
+
//# sourceMappingURL=search-templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-templates.d.ts","sourceRoot":"","sources":["../../src/utils/search-templates.js"],"names":[],"mappings":"AAuDA;;;;;;;GAOG;AACH,iEAJW,MAAM,SAiBhB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/editor",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.23.0",
|
|
4
4
|
"description": "Enhanced block editor for WordPress posts.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -34,41 +34,41 @@
|
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@babel/runtime": "7.25.7",
|
|
37
|
-
"@wordpress/a11y": "^4.
|
|
38
|
-
"@wordpress/api-fetch": "^7.
|
|
39
|
-
"@wordpress/blob": "^4.
|
|
40
|
-
"@wordpress/block-editor": "^14.
|
|
41
|
-
"@wordpress/blocks": "^14.
|
|
42
|
-
"@wordpress/commands": "^1.
|
|
43
|
-
"@wordpress/components": "^29.
|
|
44
|
-
"@wordpress/compose": "^7.
|
|
45
|
-
"@wordpress/core-data": "^7.
|
|
46
|
-
"@wordpress/data": "^10.
|
|
47
|
-
"@wordpress/dataviews": "^4.
|
|
48
|
-
"@wordpress/date": "^5.
|
|
49
|
-
"@wordpress/deprecated": "^4.
|
|
50
|
-
"@wordpress/dom": "^4.
|
|
51
|
-
"@wordpress/element": "^6.
|
|
52
|
-
"@wordpress/fields": "^0.
|
|
53
|
-
"@wordpress/hooks": "^4.
|
|
54
|
-
"@wordpress/html-entities": "^4.
|
|
55
|
-
"@wordpress/i18n": "^5.
|
|
56
|
-
"@wordpress/icons": "^10.
|
|
57
|
-
"@wordpress/interface": "^9.
|
|
58
|
-
"@wordpress/keyboard-shortcuts": "^5.
|
|
59
|
-
"@wordpress/keycodes": "^4.
|
|
60
|
-
"@wordpress/media-utils": "^5.
|
|
61
|
-
"@wordpress/notices": "^5.
|
|
62
|
-
"@wordpress/patterns": "^2.
|
|
63
|
-
"@wordpress/plugins": "^7.
|
|
64
|
-
"@wordpress/preferences": "^4.
|
|
65
|
-
"@wordpress/private-apis": "^1.
|
|
66
|
-
"@wordpress/reusable-blocks": "^5.
|
|
67
|
-
"@wordpress/rich-text": "^7.
|
|
68
|
-
"@wordpress/server-side-render": "^5.
|
|
69
|
-
"@wordpress/url": "^4.
|
|
70
|
-
"@wordpress/warning": "^3.
|
|
71
|
-
"@wordpress/wordcount": "^4.
|
|
37
|
+
"@wordpress/a11y": "^4.23.0",
|
|
38
|
+
"@wordpress/api-fetch": "^7.23.0",
|
|
39
|
+
"@wordpress/blob": "^4.23.0",
|
|
40
|
+
"@wordpress/block-editor": "^14.18.0",
|
|
41
|
+
"@wordpress/blocks": "^14.12.0",
|
|
42
|
+
"@wordpress/commands": "^1.23.0",
|
|
43
|
+
"@wordpress/components": "^29.9.0",
|
|
44
|
+
"@wordpress/compose": "^7.23.0",
|
|
45
|
+
"@wordpress/core-data": "^7.23.0",
|
|
46
|
+
"@wordpress/data": "^10.23.0",
|
|
47
|
+
"@wordpress/dataviews": "^4.19.0",
|
|
48
|
+
"@wordpress/date": "^5.23.0",
|
|
49
|
+
"@wordpress/deprecated": "^4.23.0",
|
|
50
|
+
"@wordpress/dom": "^4.23.0",
|
|
51
|
+
"@wordpress/element": "^6.23.0",
|
|
52
|
+
"@wordpress/fields": "^0.15.0",
|
|
53
|
+
"@wordpress/hooks": "^4.23.0",
|
|
54
|
+
"@wordpress/html-entities": "^4.23.0",
|
|
55
|
+
"@wordpress/i18n": "^5.23.0",
|
|
56
|
+
"@wordpress/icons": "^10.23.0",
|
|
57
|
+
"@wordpress/interface": "^9.8.0",
|
|
58
|
+
"@wordpress/keyboard-shortcuts": "^5.23.0",
|
|
59
|
+
"@wordpress/keycodes": "^4.23.0",
|
|
60
|
+
"@wordpress/media-utils": "^5.23.0",
|
|
61
|
+
"@wordpress/notices": "^5.23.0",
|
|
62
|
+
"@wordpress/patterns": "^2.23.0",
|
|
63
|
+
"@wordpress/plugins": "^7.23.0",
|
|
64
|
+
"@wordpress/preferences": "^4.23.0",
|
|
65
|
+
"@wordpress/private-apis": "^1.23.0",
|
|
66
|
+
"@wordpress/reusable-blocks": "^5.23.0",
|
|
67
|
+
"@wordpress/rich-text": "^7.23.0",
|
|
68
|
+
"@wordpress/server-side-render": "^5.23.0",
|
|
69
|
+
"@wordpress/url": "^4.23.0",
|
|
70
|
+
"@wordpress/warning": "^3.23.0",
|
|
71
|
+
"@wordpress/wordcount": "^4.23.0",
|
|
72
72
|
"change-case": "^4.1.2",
|
|
73
73
|
"client-zip": "^2.4.5",
|
|
74
74
|
"clsx": "^2.1.1",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"publishConfig": {
|
|
89
89
|
"access": "public"
|
|
90
90
|
},
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "ab5c79cd40adbb68898536c50e035b0a734338ea"
|
|
92
92
|
}
|