@wordpress/block-editor 12.3.5 → 12.3.7
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/components/block-draggable/index.js +6 -3
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/iframe/index.js +21 -46
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/inserter/reusable-block-rename-hint.js +1 -1
- package/build/components/inserter/reusable-block-rename-hint.js.map +1 -1
- package/build/components/link-control/constants.js +1 -1
- package/build/components/link-control/constants.js.map +1 -1
- package/build/components/link-control/search-create-button.js +5 -21
- package/build/components/link-control/search-create-button.js.map +1 -1
- package/build/components/link-control/search-item.js +13 -30
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/link-control/search-results.js +2 -2
- package/build/components/link-control/search-results.js.map +1 -1
- package/build/components/rich-text/content.js +0 -36
- package/build/components/rich-text/content.js.map +1 -1
- package/build/components/rich-text/get-rich-text-values.js +112 -0
- package/build/components/rich-text/get-rich-text-values.js.map +1 -0
- package/build/components/use-block-display-information/index.js +7 -3
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/hooks/margin.js +1 -1
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +1 -1
- package/build/hooks/padding.js.map +1 -1
- package/build/private-apis.js +2 -2
- package/build/private-apis.js.map +1 -1
- package/build/store/selectors.js +1 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-draggable/index.js +6 -3
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/iframe/index.js +22 -47
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inserter/reusable-block-rename-hint.js +1 -1
- package/build-module/components/inserter/reusable-block-rename-hint.js.map +1 -1
- package/build-module/components/link-control/constants.js +1 -1
- package/build-module/components/link-control/constants.js.map +1 -1
- package/build-module/components/link-control/search-create-button.js +7 -20
- package/build-module/components/link-control/search-create-button.js.map +1 -1
- package/build-module/components/link-control/search-item.js +14 -28
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/link-control/search-results.js +3 -3
- package/build-module/components/link-control/search-results.js.map +1 -1
- package/build-module/components/rich-text/content.js +1 -36
- package/build-module/components/rich-text/content.js.map +1 -1
- package/build-module/components/rich-text/get-rich-text-values.js +99 -0
- package/build-module/components/rich-text/get-rich-text-values.js.map +1 -0
- package/build-module/components/use-block-display-information/index.js +7 -3
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/hooks/margin.js +1 -1
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +1 -1
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/private-apis.js +1 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/selectors.js +1 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +20 -83
- package/build-style/style.css +20 -83
- package/package.json +5 -5
- package/src/components/block-draggable/index.js +13 -4
- package/src/components/iframe/index.js +16 -47
- package/src/components/inserter/reusable-block-rename-hint.js +1 -1
- package/src/components/link-control/constants.js +1 -1
- package/src/components/link-control/search-create-button.js +8 -26
- package/src/components/link-control/search-item.js +21 -43
- package/src/components/link-control/search-results.js +48 -46
- package/src/components/link-control/style.scss +25 -95
- package/src/components/link-control/test/index.js +6 -7
- package/src/components/rich-text/content.js +1 -46
- package/src/components/rich-text/get-rich-text-values.js +95 -0
- package/src/components/use-block-display-information/index.js +12 -5
- package/src/hooks/margin.js +4 -1
- package/src/hooks/padding.js +4 -1
- package/src/private-apis.js +1 -1
- package/src/store/selectors.js +1 -1
- package/src/store/test/selectors.js +1 -1
|
@@ -43,17 +43,20 @@ const BlockDraggable = ({
|
|
|
43
43
|
const {
|
|
44
44
|
canMoveBlocks,
|
|
45
45
|
getBlockRootClientId,
|
|
46
|
-
getBlockName
|
|
46
|
+
getBlockName,
|
|
47
|
+
getBlockAttributes
|
|
47
48
|
} = select(_store.store);
|
|
48
49
|
const {
|
|
49
|
-
getBlockType
|
|
50
|
+
getBlockType,
|
|
51
|
+
getActiveBlockVariation
|
|
50
52
|
} = select(_blocks.store);
|
|
51
53
|
const rootClientId = getBlockRootClientId(clientIds[0]);
|
|
52
54
|
const blockName = getBlockName(clientIds[0]);
|
|
55
|
+
const variation = getActiveBlockVariation(blockName, getBlockAttributes(clientIds[0]));
|
|
53
56
|
return {
|
|
54
57
|
srcRootClientId: rootClientId,
|
|
55
58
|
isDraggable: canMoveBlocks(clientIds, rootClientId),
|
|
56
|
-
icon: getBlockType(blockName)?.icon
|
|
59
|
+
icon: variation?.icon || getBlockType(blockName)?.icon
|
|
57
60
|
};
|
|
58
61
|
}, [clientIds]);
|
|
59
62
|
const isDragging = (0, _element.useRef)(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-draggable/index.js"],"names":["BlockDraggable","children","clientIds","cloneClassname","onDragStart","onDragEnd","srcRootClientId","isDraggable","icon","select","canMoveBlocks","getBlockRootClientId","getBlockName","blockEditorStore","getBlockType","blocksStore","rootClientId","blockName","isDragging","startScrolling","scrollOnDragOver","stopScrolling","startDraggingBlocks","stopDraggingBlocks","current","draggable","transferData","type","srcClientIds","event","window","requestAnimationFrame","length","onDraggableStart","onDraggableEnd"],"mappings":";;;;;;;;;AAMA;;AAHA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AAbA;AACA;AACA;;AAMA;AACA;AACA;AAKA,MAAMA,cAAc,GAAG,CAAE;AACxBC,EAAAA,QADwB;AAExBC,EAAAA,SAFwB;AAGxBC,EAAAA,cAHwB;AAIxBC,EAAAA,WAJwB;AAKxBC,EAAAA;AALwB,CAAF,KAMhB;AACN,QAAM;AAAEC,IAAAA,eAAF;AAAmBC,IAAAA,WAAnB;AAAgCC,IAAAA;AAAhC,MAAyC,qBAC5CC,MAAF,IAAc;AACb,UAAM;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-draggable/index.js"],"names":["BlockDraggable","children","clientIds","cloneClassname","onDragStart","onDragEnd","srcRootClientId","isDraggable","icon","select","canMoveBlocks","getBlockRootClientId","getBlockName","getBlockAttributes","blockEditorStore","getBlockType","getActiveBlockVariation","blocksStore","rootClientId","blockName","variation","isDragging","startScrolling","scrollOnDragOver","stopScrolling","startDraggingBlocks","stopDraggingBlocks","current","draggable","transferData","type","srcClientIds","event","window","requestAnimationFrame","length","onDraggableStart","onDraggableEnd"],"mappings":";;;;;;;;;AAMA;;AAHA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AAbA;AACA;AACA;;AAMA;AACA;AACA;AAKA,MAAMA,cAAc,GAAG,CAAE;AACxBC,EAAAA,QADwB;AAExBC,EAAAA,SAFwB;AAGxBC,EAAAA,cAHwB;AAIxBC,EAAAA,WAJwB;AAKxBC,EAAAA;AALwB,CAAF,KAMhB;AACN,QAAM;AAAEC,IAAAA,eAAF;AAAmBC,IAAAA,WAAnB;AAAgCC,IAAAA;AAAhC,MAAyC,qBAC5CC,MAAF,IAAc;AACb,UAAM;AACLC,MAAAA,aADK;AAELC,MAAAA,oBAFK;AAGLC,MAAAA,YAHK;AAILC,MAAAA;AAJK,QAKFJ,MAAM,CAAEK,YAAF,CALV;AAMA,UAAM;AAAEC,MAAAA,YAAF;AAAgBC,MAAAA;AAAhB,QACLP,MAAM,CAAEQ,aAAF,CADP;AAEA,UAAMC,YAAY,GAAGP,oBAAoB,CAAET,SAAS,CAAE,CAAF,CAAX,CAAzC;AACA,UAAMiB,SAAS,GAAGP,YAAY,CAAEV,SAAS,CAAE,CAAF,CAAX,CAA9B;AACA,UAAMkB,SAAS,GAAGJ,uBAAuB,CACxCG,SADwC,EAExCN,kBAAkB,CAAEX,SAAS,CAAE,CAAF,CAAX,CAFsB,CAAzC;AAKA,WAAO;AACNI,MAAAA,eAAe,EAAEY,YADX;AAENX,MAAAA,WAAW,EAAEG,aAAa,CAAER,SAAF,EAAagB,YAAb,CAFpB;AAGNV,MAAAA,IAAI,EAAEY,SAAS,EAAEZ,IAAX,IAAmB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GAAqB,KAArB;AAEAH,MAAAA,aAAa;;AAEb,UAAKnB,SAAL,EAAiB;AAChBA,QAAAA,SAAS;AACT;AACD,KA5BF;AA6BC,IAAA,2BAA2B,EAC1B,4BAAC,sBAAD;AAAoB,MAAA,KAAK,EAAGH,SAAS,CAACiC,MAAtC;AAA+C,MAAA,IAAI,EAAG3B;AAAtD;AA9BF,KAiCG,CAAE;AAAE4B,IAAAA,gBAAF;AAAoBC,IAAAA;AAApB,GAAF,KAA4C;AAC7C,WAAOpC,QAAQ,CAAE;AAChB2B,MAAAA,SAAS,EAAE,IADK;AAEhBxB,MAAAA,WAAW,EAAEgC,gBAFG;AAGhB/B,MAAAA,SAAS,EAAEgC;AAHK,KAAF,CAAf;AAKA,GAvCF,CADD;AA2CA,CArGD;;eAuGerC,c","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { Draggable } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockDraggableChip from './draggable-chip';\nimport useScrollWhenDragging from './use-scroll-when-dragging';\nimport { store as blockEditorStore } from '../../store';\n\nconst BlockDraggable = ( {\n\tchildren,\n\tclientIds,\n\tcloneClassname,\n\tonDragStart,\n\tonDragEnd,\n} ) => {\n\tconst { srcRootClientId, isDraggable, icon } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tcanMoveBlocks,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockAttributes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockType, getActiveBlockVariation } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\tconst blockName = getBlockName( clientIds[ 0 ] );\n\t\t\tconst variation = getActiveBlockVariation(\n\t\t\t\tblockName,\n\t\t\t\tgetBlockAttributes( clientIds[ 0 ] )\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tsrcRootClientId: rootClientId,\n\t\t\t\tisDraggable: canMoveBlocks( clientIds, rootClientId ),\n\t\t\t\ticon: variation?.icon || getBlockType( blockName )?.icon,\n\t\t\t};\n\t\t},\n\t\t[ clientIds ]\n\t);\n\tconst isDragging = useRef( false );\n\tconst [ startScrolling, scrollOnDragOver, stopScrolling ] =\n\t\tuseScrollWhenDragging();\n\n\tconst { startDraggingBlocks, stopDraggingBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Stop dragging blocks if the block draggable is unmounted.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( isDragging.current ) {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\tif ( ! isDraggable ) {\n\t\treturn children( { draggable: false } );\n\t}\n\n\tconst transferData = {\n\t\ttype: 'block',\n\t\tsrcClientIds: clientIds,\n\t\tsrcRootClientId,\n\t};\n\n\treturn (\n\t\t<Draggable\n\t\t\tcloneClassname={ cloneClassname }\n\t\t\t__experimentalTransferDataType=\"wp-blocks\"\n\t\t\ttransferData={ transferData }\n\t\t\tonDragStart={ ( event ) => {\n\t\t\t\t// Defer hiding the dragged source element to the next\n\t\t\t\t// frame to enable dragging.\n\t\t\t\twindow.requestAnimationFrame( () => {\n\t\t\t\t\tstartDraggingBlocks( clientIds );\n\t\t\t\t\tisDragging.current = true;\n\n\t\t\t\t\tstartScrolling( event );\n\n\t\t\t\t\tif ( onDragStart ) {\n\t\t\t\t\t\tonDragStart();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tonDragOver={ scrollOnDragOver }\n\t\t\tonDragEnd={ () => {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t\tisDragging.current = false;\n\n\t\t\t\tstopScrolling();\n\n\t\t\t\tif ( onDragEnd ) {\n\t\t\t\t\tonDragEnd();\n\t\t\t\t}\n\t\t\t} }\n\t\t\t__experimentalDragComponent={\n\t\t\t\t<BlockDraggableChip count={ clientIds.length } icon={ icon } />\n\t\t\t}\n\t\t>\n\t\t\t{ ( { onDraggableStart, onDraggableEnd } ) => {\n\t\t\t\treturn children( {\n\t\t\t\t\tdraggable: true,\n\t\t\t\t\tonDragStart: onDraggableStart,\n\t\t\t\t\tonDragEnd: onDraggableEnd,\n\t\t\t\t} );\n\t\t\t} }\n\t\t</Draggable>\n\t);\n};\n\nexport default BlockDraggable;\n"]}
|
|
@@ -88,36 +88,6 @@ function bubbleEvents(doc) {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
function useParsedAssets(html) {
|
|
92
|
-
return (0, _element.useMemo)(() => {
|
|
93
|
-
const doc = document.implementation.createHTMLDocument('');
|
|
94
|
-
doc.body.innerHTML = html;
|
|
95
|
-
return Array.from(doc.body.children);
|
|
96
|
-
}, [html]);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
async function loadScript(head, {
|
|
100
|
-
id,
|
|
101
|
-
src
|
|
102
|
-
}) {
|
|
103
|
-
return new Promise((resolve, reject) => {
|
|
104
|
-
const script = head.ownerDocument.createElement('script');
|
|
105
|
-
script.id = id;
|
|
106
|
-
|
|
107
|
-
if (src) {
|
|
108
|
-
script.src = src;
|
|
109
|
-
|
|
110
|
-
script.onload = () => resolve();
|
|
111
|
-
|
|
112
|
-
script.onerror = () => reject();
|
|
113
|
-
} else {
|
|
114
|
-
resolve();
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
head.appendChild(script);
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
91
|
function Iframe({
|
|
122
92
|
contentRef,
|
|
123
93
|
children,
|
|
@@ -129,20 +99,23 @@ function Iframe({
|
|
|
129
99
|
forwardedRef: ref,
|
|
130
100
|
...props
|
|
131
101
|
}) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
102
|
+
const {
|
|
103
|
+
styles = '',
|
|
104
|
+
scripts = ''
|
|
105
|
+
} = (0, _data.useSelect)(select => select(_store.store).getSettings().__unstableResolvedAssets, []);
|
|
136
106
|
const [iframeDocument, setIframeDocument] = (0, _element.useState)();
|
|
137
107
|
const [bodyClasses, setBodyClasses] = (0, _element.useState)([]);
|
|
138
108
|
const compatStyles = (0, _useCompatibilityStyles.useCompatibilityStyles)();
|
|
139
|
-
const scripts = useParsedAssets(assets?.scripts);
|
|
140
109
|
const clearerRef = (0, _blockSelectionClearer.useBlockSelectionClearer)();
|
|
141
110
|
const [before, writingFlowRef, after] = (0, _writingFlow.useWritingFlow)();
|
|
142
111
|
const [contentResizeListener, {
|
|
143
112
|
height: contentHeight
|
|
144
113
|
}] = (0, _compose.useResizeObserver)();
|
|
145
114
|
const setRef = (0, _compose.useRefEffect)(node => {
|
|
115
|
+
node._load = () => {
|
|
116
|
+
setIframeDocument(node.contentDocument);
|
|
117
|
+
};
|
|
118
|
+
|
|
146
119
|
let iFrameDocument; // Prevent the default browser action for files dropped outside of dropzones.
|
|
147
120
|
|
|
148
121
|
function preventFileDropDefault(event) {
|
|
@@ -159,14 +132,12 @@ function Iframe({
|
|
|
159
132
|
} = contentDocument;
|
|
160
133
|
iFrameDocument = contentDocument;
|
|
161
134
|
bubbleEvents(contentDocument);
|
|
162
|
-
setIframeDocument(contentDocument);
|
|
163
135
|
clearerRef(documentElement); // Ideally ALL classes that are added through get_body_class should
|
|
164
136
|
// be added in the editor too, which we'll somehow have to get from
|
|
165
137
|
// the server in the future (which will run the PHP filters).
|
|
166
138
|
|
|
167
139
|
setBodyClasses(Array.from(ownerDocument.body.classList).filter(name => name.startsWith('admin-color-') || name.startsWith('post-type-') || name === 'wp-embed-responsive'));
|
|
168
140
|
contentDocument.dir = ownerDocument.dir;
|
|
169
|
-
documentElement.removeChild(contentDocument.body);
|
|
170
141
|
|
|
171
142
|
for (const compatStyle of compatStyles) {
|
|
172
143
|
if (contentDocument.getElementById(compatStyle.id)) {
|
|
@@ -189,21 +160,25 @@ function Iframe({
|
|
|
189
160
|
iFrameDocument?.removeEventListener('drop', preventFileDropDefault);
|
|
190
161
|
};
|
|
191
162
|
}, []);
|
|
192
|
-
const headRef = (0, _compose.useRefEffect)(element => {
|
|
193
|
-
scripts.reduce((promise, script) => promise.then(() => loadScript(element, script)), Promise.resolve()).finally(() => {
|
|
194
|
-
// When script are loaded, re-render blocks to allow them
|
|
195
|
-
// to initialise.
|
|
196
|
-
forceRender();
|
|
197
|
-
});
|
|
198
|
-
}, []);
|
|
199
163
|
const disabledRef = (0, _compose.useDisabled)({
|
|
200
164
|
isDisabled: !readonly
|
|
201
165
|
});
|
|
202
|
-
const bodyRef = (0, _compose.useMergeRefs)([contentRef, clearerRef, writingFlowRef, disabledRef
|
|
166
|
+
const bodyRef = (0, _compose.useMergeRefs)([contentRef, clearerRef, writingFlowRef, disabledRef]); // Correct doctype is required to enable rendering in standards
|
|
203
167
|
// mode. Also preload the styles to avoid a flash of unstyled
|
|
204
168
|
// content.
|
|
205
169
|
|
|
206
|
-
const html =
|
|
170
|
+
const html = `<!doctype html>
|
|
171
|
+
<html>
|
|
172
|
+
<head>
|
|
173
|
+
<script>window.frameElement._load()</script>
|
|
174
|
+
<style>html{height:auto!important;min-height:100%;}body{margin:0}</style>
|
|
175
|
+
${styles}
|
|
176
|
+
${scripts}
|
|
177
|
+
</head>
|
|
178
|
+
<body>
|
|
179
|
+
<script>document.currentScript.parentElement.remove()</script>
|
|
180
|
+
</body>
|
|
181
|
+
</html>`;
|
|
207
182
|
const [src, cleanup] = (0, _element.useMemo)(() => {
|
|
208
183
|
const _src = URL.createObjectURL(new window.Blob([html], {
|
|
209
184
|
type: 'text/html'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"names":["bubbleEvents","doc","defaultView","frameElement","bubbleEvent","event","prototype","Object","getPrototypeOf","constructorName","constructor","name","Constructor","window","init","key","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","cancelled","dispatchEvent","preventDefault","eventTypes","addEventListener","useParsedAssets","html","document","implementation","createHTMLDocument","body","innerHTML","Array","from","children","loadScript","head","id","src","Promise","resolve","reject","script","ownerDocument","createElement","onload","onerror","appendChild","Iframe","contentRef","tabIndex","scale","frameSize","expand","readonly","forwardedRef","ref","props","assets","select","blockEditorStore","getSettings","__unstableResolvedAssets","forceRender","iframeDocument","setIframeDocument","bodyClasses","setBodyClasses","compatStyles","scripts","clearerRef","before","writingFlowRef","after","contentResizeListener","height","contentHeight","setRef","node","iFrameDocument","preventFileDropDefault","onLoad","contentDocument","documentElement","classList","filter","startsWith","dir","removeChild","compatStyle","getElementById","cloneNode","console","warn","removeEventListener","headRef","element","reduce","promise","then","finally","disabledRef","isDisabled","bodyRef","styles","cleanup","_src","URL","createObjectURL","Blob","revokeObjectURL","marginFromScaling","style","marginTop","marginBottom","transform","transition","IframeIfReady","isInitialised","__internalIsInitialized"],"mappings":";;;;;;;;;AAQA;;AALA;;AAaA;;AACA;;AAMA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAhCA;AACA;AACA;;AAGA;AACA;AACA;;AAmBA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,YAAT,CAAuBC,GAAvB,EAA6B;AAC5B,QAAM;AAAEC,IAAAA;AAAF,MAAkBD,GAAxB;AACA,QAAM;AAAEE,IAAAA;AAAF,MAAmBD,WAAzB;;AAEA,WAASE,WAAT,CAAsBC,KAAtB,EAA8B;AAC7B,UAAMC,SAAS,GAAGC,MAAM,CAACC,cAAP,CAAuBH,KAAvB,CAAlB;AACA,UAAMI,eAAe,GAAGH,SAAS,CAACI,WAAV,CAAsBC,IAA9C;AACA,UAAMC,WAAW,GAAGC,MAAM,CAAEJ,eAAF,CAA1B;AAEA,UAAMK,IAAI,GAAG,EAAb;;AAEA,SAAM,MAAMC,GAAZ,IAAmBV,KAAnB,EAA2B;AAC1BS,MAAAA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,GAxBP;AAyBC,IAAA,KAAK,EAAG,cAAI,eAAJ;AAzBT,KA2BG0B,cAAc,IACf,2BACC;AACC,IAAA,GAAG,EAAGuC,OADP;AAEC,IAAA,SAAS,EAAG,yBACX,2BADW,EAEX,uBAFW,EAGX,GAAGrC,WAHQ;AAFb,KAQGQ,qBARH,EASC,4BAAC,uCAAD;AAAe,IAAA,QAAQ,EAAGV;AAA1B,KACG9B,QADH,CATD,CADD,EAcC8B,cAAc,CAACmB,eAdhB,CA5BF,CAFD,EA+CGjC,QAAQ,IAAI,CAAZ,IAAiBuB,KA/CpB,CADD;AAmDA;;AAED,SAAS4C,aAAT,CAAwB5D,KAAxB,EAA+BD,GAA/B,EAAqC;AACpC,QAAM8D,aAAa,GAAG,qBACnB3D,MAAF,IACCA,MAAM,CAAEC,YAAF,CAAN,CAA2BC,WAA3B,GAAyC0D,uBAFrB,EAGrB,EAHqB,CAAtB,CADoC,CAOpC;AACA;AACA;AACA;AACA;;AACA,MAAK,CAAED,aAAP,EAAuB;AACtB,WAAO,IAAP;AACA;;AAED,SAAO,4BAAC,MAAD,OAAa7D,KAAb;AAAqB,IAAA,YAAY,EAAGD;AAApC,IAAP;AACA;;eAEc,yBAAY6D,aAAZ,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tcreatePortal,\n\tforwardRef,\n\tuseMemo,\n\tuseReducer,\n\tuseEffect,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseResizeObserver,\n\tuseMergeRefs,\n\tuseRefEffect,\n\tuseDisabled,\n} from '@wordpress/compose';\nimport { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { useWritingFlow } from '../writing-flow';\nimport { useCompatibilityStyles } from './use-compatibility-styles';\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Bubbles some event types (keydown, keypress, and dragover) to parent document\n * document to ensure that the keyboard shortcuts and drag and drop work.\n *\n * Ideally, we should remove event bubbling in the future. Keyboard shortcuts\n * should be context dependent, e.g. actions on blocks like Cmd+A should not\n * work globally outside the block editor.\n *\n * @param {Document} doc Document to attach listeners to.\n */\nfunction bubbleEvents( doc ) {\n\tconst { defaultView } = doc;\n\tconst { frameElement } = defaultView;\n\n\tfunction bubbleEvent( event ) {\n\t\tconst prototype = Object.getPrototypeOf( event );\n\t\tconst constructorName = prototype.constructor.name;\n\t\tconst Constructor = window[ constructorName ];\n\n\t\tconst init = {};\n\n\t\tfor ( const key in event ) {\n\t\t\tinit[ key ] = event[ key ];\n\t\t}\n\n\t\tif ( event instanceof defaultView.MouseEvent ) {\n\t\t\tconst rect = frameElement.getBoundingClientRect();\n\t\t\tinit.clientX += rect.left;\n\t\t\tinit.clientY += rect.top;\n\t\t}\n\n\t\tconst newEvent = new Constructor( event.type, init );\n\t\tconst cancelled = ! frameElement.dispatchEvent( newEvent );\n\n\t\tif ( cancelled ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\n\tconst eventTypes = [ 'dragover', 'mousemove' ];\n\n\tfor ( const name of eventTypes ) {\n\t\tdoc.addEventListener( name, bubbleEvent );\n\t}\n}\n\nfunction useParsedAssets( html ) {\n\treturn useMemo( () => {\n\t\tconst doc = document.implementation.createHTMLDocument( '' );\n\t\tdoc.body.innerHTML = html;\n\t\treturn Array.from( doc.body.children );\n\t}, [ html ] );\n}\n\nasync function loadScript( head, { id, src } ) {\n\treturn new Promise( ( resolve, reject ) => {\n\t\tconst script = head.ownerDocument.createElement( 'script' );\n\t\tscript.id = id;\n\t\tif ( src ) {\n\t\t\tscript.src = src;\n\t\t\tscript.onload = () => resolve();\n\t\t\tscript.onerror = () => reject();\n\t\t} else {\n\t\t\tresolve();\n\t\t}\n\t\thead.appendChild( script );\n\t} );\n}\n\nfunction Iframe( {\n\tcontentRef,\n\tchildren,\n\ttabIndex = 0,\n\tscale = 1,\n\tframeSize = 0,\n\texpand = false,\n\treadonly,\n\tforwardedRef: ref,\n\t...props\n} ) {\n\tconst assets = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().__unstableResolvedAssets,\n\t\t[]\n\t);\n\tconst [ , forceRender ] = useReducer( () => ( {} ) );\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst [ bodyClasses, setBodyClasses ] = useState( [] );\n\tconst compatStyles = useCompatibilityStyles();\n\tconst scripts = useParsedAssets( assets?.scripts );\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst [ before, writingFlowRef, after ] = useWritingFlow();\n\tconst [ contentResizeListener, { height: contentHeight } ] =\n\t\tuseResizeObserver();\n\tconst setRef = useRefEffect( ( node ) => {\n\t\tlet iFrameDocument;\n\t\t// Prevent the default browser action for files dropped outside of dropzones.\n\t\tfunction preventFileDropDefault( event ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t\tfunction onLoad() {\n\t\t\tconst { contentDocument, ownerDocument } = node;\n\t\t\tconst { documentElement } = contentDocument;\n\t\t\tiFrameDocument = contentDocument;\n\n\t\t\tbubbleEvents( contentDocument );\n\t\t\tsetIframeDocument( contentDocument );\n\t\t\tclearerRef( documentElement );\n\n\t\t\t// Ideally ALL classes that are added through get_body_class should\n\t\t\t// be added in the editor too, which we'll somehow have to get from\n\t\t\t// the server in the future (which will run the PHP filters).\n\t\t\tsetBodyClasses(\n\t\t\t\tArray.from( ownerDocument.body.classList ).filter(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tname.startsWith( 'admin-color-' ) ||\n\t\t\t\t\t\tname.startsWith( 'post-type-' ) ||\n\t\t\t\t\t\tname === 'wp-embed-responsive'\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tcontentDocument.dir = ownerDocument.dir;\n\t\t\tdocumentElement.removeChild( contentDocument.body );\n\n\t\t\tfor ( const compatStyle of compatStyles ) {\n\t\t\t\tif ( contentDocument.getElementById( compatStyle.id ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tcontentDocument.head.appendChild(\n\t\t\t\t\tcompatStyle.cloneNode( true )\n\t\t\t\t);\n\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`${ compatStyle.id } was added to the iframe incorrectly. Please use block.json or enqueue_block_assets to add styles to the iframe.`,\n\t\t\t\t\tcompatStyle\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t}\n\n\t\tnode.addEventListener( 'load', onLoad );\n\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'load', onLoad );\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t};\n\t}, [] );\n\n\tconst headRef = useRefEffect( ( element ) => {\n\t\tscripts\n\t\t\t.reduce(\n\t\t\t\t( promise, script ) =>\n\t\t\t\t\tpromise.then( () => loadScript( element, script ) ),\n\t\t\t\tPromise.resolve()\n\t\t\t)\n\t\t\t.finally( () => {\n\t\t\t\t// When script are loaded, re-render blocks to allow them\n\t\t\t\t// to initialise.\n\t\t\t\tforceRender();\n\t\t\t} );\n\t}, [] );\n\tconst disabledRef = useDisabled( { isDisabled: ! readonly } );\n\tconst bodyRef = useMergeRefs( [\n\t\tcontentRef,\n\t\tclearerRef,\n\t\twritingFlowRef,\n\t\tdisabledRef,\n\t\theadRef,\n\t] );\n\n\t// Correct doctype is required to enable rendering in standards\n\t// mode. Also preload the styles to avoid a flash of unstyled\n\t// content.\n\tconst html =\n\t\t'<!doctype html>' +\n\t\t'<style>html{height:auto!important;min-height:100%;}body{margin:0}</style>' +\n\t\t( assets?.styles ?? '' );\n\n\tconst [ src, cleanup ] = useMemo( () => {\n\t\tconst _src = URL.createObjectURL(\n\t\t\tnew window.Blob( [ html ], { type: 'text/html' } )\n\t\t);\n\t\treturn [ _src, () => URL.revokeObjectURL( _src ) ];\n\t}, [ html ] );\n\n\tuseEffect( () => cleanup, [ cleanup ] );\n\n\t// We need to counter the margin created by scaling the iframe. If the scale\n\t// is e.g. 0.45, then the top + bottom margin is 0.55 (1 - scale). Just the\n\t// top or bottom margin is 0.55 / 2 ((1 - scale) / 2).\n\tconst marginFromScaling = ( contentHeight * ( 1 - scale ) ) / 2;\n\n\treturn (\n\t\t<>\n\t\t\t{ tabIndex >= 0 && before }\n\t\t\t<iframe\n\t\t\t\t{ ...props }\n\t\t\t\tstyle={ {\n\t\t\t\t\t...props.style,\n\t\t\t\t\theight: expand ? contentHeight : props.style?.height,\n\t\t\t\t\tmarginTop:\n\t\t\t\t\t\tscale !== 1\n\t\t\t\t\t\t\t? -marginFromScaling + frameSize\n\t\t\t\t\t\t\t: props.style?.marginTop,\n\t\t\t\t\tmarginBottom:\n\t\t\t\t\t\tscale !== 1\n\t\t\t\t\t\t\t? -marginFromScaling + frameSize\n\t\t\t\t\t\t\t: props.style?.marginBottom,\n\t\t\t\t\ttransform:\n\t\t\t\t\t\tscale !== 1\n\t\t\t\t\t\t\t? `scale( ${ scale } )`\n\t\t\t\t\t\t\t: props.style?.transform,\n\t\t\t\t\ttransition: 'all .3s',\n\t\t\t\t} }\n\t\t\t\tref={ useMergeRefs( [ ref, setRef ] ) }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t// Correct doctype is required to enable rendering in standards\n\t\t\t\t// mode. Also preload the styles to avoid a flash of unstyled\n\t\t\t\t// content.\n\t\t\t\tsrc={ src }\n\t\t\t\ttitle={ __( 'Editor canvas' ) }\n\t\t\t>\n\t\t\t\t{ iframeDocument &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<body\n\t\t\t\t\t\t\tref={ bodyRef }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-iframe__body',\n\t\t\t\t\t\t\t\t'editor-styles-wrapper',\n\t\t\t\t\t\t\t\t...bodyClasses\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ contentResizeListener }\n\t\t\t\t\t\t\t<StyleProvider document={ iframeDocument }>\n\t\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t</StyleProvider>\n\t\t\t\t\t\t</body>,\n\t\t\t\t\t\tiframeDocument.documentElement\n\t\t\t\t\t) }\n\t\t\t</iframe>\n\t\t\t{ tabIndex >= 0 && after }\n\t\t</>\n\t);\n}\n\nfunction IframeIfReady( props, ref ) {\n\tconst isInitialised = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().__internalIsInitialized,\n\t\t[]\n\t);\n\n\t// We shouldn't render the iframe until the editor settings are initialised.\n\t// The initial settings are needed to get the styles for the srcDoc, which\n\t// cannot be changed after the iframe is mounted. srcDoc is used to to set\n\t// the initial iframe HTML, which is required to avoid a flash of unstyled\n\t// content.\n\tif ( ! isInitialised ) {\n\t\treturn null;\n\t}\n\n\treturn <Iframe { ...props } forwardedRef={ ref } />;\n}\n\nexport default forwardRef( IframeIfReady );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"names":["bubbleEvents","doc","defaultView","frameElement","bubbleEvent","event","prototype","Object","getPrototypeOf","constructorName","constructor","name","Constructor","window","init","key","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","cancelled","dispatchEvent","preventDefault","eventTypes","addEventListener","Iframe","contentRef","children","tabIndex","scale","frameSize","expand","readonly","forwardedRef","ref","props","styles","scripts","select","blockEditorStore","getSettings","__unstableResolvedAssets","iframeDocument","setIframeDocument","bodyClasses","setBodyClasses","compatStyles","clearerRef","before","writingFlowRef","after","contentResizeListener","height","contentHeight","setRef","node","_load","contentDocument","iFrameDocument","preventFileDropDefault","onLoad","ownerDocument","documentElement","Array","from","body","classList","filter","startsWith","dir","compatStyle","getElementById","id","head","appendChild","cloneNode","console","warn","removeEventListener","disabledRef","isDisabled","bodyRef","html","src","cleanup","_src","URL","createObjectURL","Blob","revokeObjectURL","marginFromScaling","style","marginTop","marginBottom","transform","transition","IframeIfReady","isInitialised","__internalIsInitialized"],"mappings":";;;;;;;;;AAQA;;AALA;;AAYA;;AACA;;AAMA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AA/BA;AACA;AACA;;AAGA;AACA;AACA;;AAkBA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,YAAT,CAAuBC,GAAvB,EAA6B;AAC5B,QAAM;AAAEC,IAAAA;AAAF,MAAkBD,GAAxB;AACA,QAAM;AAAEE,IAAAA;AAAF,MAAmBD,WAAzB;;AAEA,WAASE,WAAT,CAAsBC,KAAtB,EAA8B;AAC7B,UAAMC,SAAS,GAAGC,MAAM,CAACC,cAAP,CAAuBH,KAAvB,CAAlB;AACA,UAAMI,eAAe,GAAGH,SAAS,CAACI,WAAV,CAAsBC,IAA9C;AACA,UAAMC,WAAW,GAAGC,MAAM,CAAEJ,eAAF,CAA1B;AAEA,UAAMK,IAAI,GAAG,EAAb;;AAEA,SAAM,MAAMC,GAAZ,IAAmBV,KAAnB,EAA2B;AAC1BS,MAAAA,IAAI,CAAEC,GAAF,CAAJ,GAAcV,KAAK,CAAEU,GAAF,CAAnB;AACA;;AAED,QAAKV,KAAK,YAAYH,WAAW,CAACc,UAAlC,EAA+C;AAC9C,YAAMC,IAAI,GAAGd,YAAY,CAACe,qBAAb,EAAb;AACAJ,MAAAA,IAAI,CAACK,OAAL,IAAgBF,IAAI,CAACG,IAArB;AACAN,MAA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Z,IAAiBsB,KA/CpB,CADD;AAmDA;;AAED,SAAS8C,aAAT,CAAwB7D,KAAxB,EAA+BD,GAA/B,EAAqC;AACpC,QAAM+D,aAAa,GAAG,qBACnB3D,MAAF,IACCA,MAAM,CAAEC,YAAF,CAAN,CAA2BC,WAA3B,GAAyC0D,uBAFrB,EAGrB,EAHqB,CAAtB,CADoC,CAOpC;AACA;AACA;AACA;AACA;;AACA,MAAK,CAAED,aAAP,EAAuB;AACtB,WAAO,IAAP;AACA;;AAED,SAAO,4BAAC,MAAD,OAAa9D,KAAb;AAAqB,IAAA,YAAY,EAAGD;AAApC,IAAP;AACA;;eAEc,yBAAY8D,aAAZ,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tcreatePortal,\n\tforwardRef,\n\tuseMemo,\n\tuseEffect,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseResizeObserver,\n\tuseMergeRefs,\n\tuseRefEffect,\n\tuseDisabled,\n} from '@wordpress/compose';\nimport { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { useWritingFlow } from '../writing-flow';\nimport { useCompatibilityStyles } from './use-compatibility-styles';\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Bubbles some event types (keydown, keypress, and dragover) to parent document\n * document to ensure that the keyboard shortcuts and drag and drop work.\n *\n * Ideally, we should remove event bubbling in the future. Keyboard shortcuts\n * should be context dependent, e.g. actions on blocks like Cmd+A should not\n * work globally outside the block editor.\n *\n * @param {Document} doc Document to attach listeners to.\n */\nfunction bubbleEvents( doc ) {\n\tconst { defaultView } = doc;\n\tconst { frameElement } = defaultView;\n\n\tfunction bubbleEvent( event ) {\n\t\tconst prototype = Object.getPrototypeOf( event );\n\t\tconst constructorName = prototype.constructor.name;\n\t\tconst Constructor = window[ constructorName ];\n\n\t\tconst init = {};\n\n\t\tfor ( const key in event ) {\n\t\t\tinit[ key ] = event[ key ];\n\t\t}\n\n\t\tif ( event instanceof defaultView.MouseEvent ) {\n\t\t\tconst rect = frameElement.getBoundingClientRect();\n\t\t\tinit.clientX += rect.left;\n\t\t\tinit.clientY += rect.top;\n\t\t}\n\n\t\tconst newEvent = new Constructor( event.type, init );\n\t\tconst cancelled = ! frameElement.dispatchEvent( newEvent );\n\n\t\tif ( cancelled ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\n\tconst eventTypes = [ 'dragover', 'mousemove' ];\n\n\tfor ( const name of eventTypes ) {\n\t\tdoc.addEventListener( name, bubbleEvent );\n\t}\n}\n\nfunction Iframe( {\n\tcontentRef,\n\tchildren,\n\ttabIndex = 0,\n\tscale = 1,\n\tframeSize = 0,\n\texpand = false,\n\treadonly,\n\tforwardedRef: ref,\n\t...props\n} ) {\n\tconst { styles = '', scripts = '' } = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().__unstableResolvedAssets,\n\t\t[]\n\t);\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst [ bodyClasses, setBodyClasses ] = useState( [] );\n\tconst compatStyles = useCompatibilityStyles();\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst [ before, writingFlowRef, after ] = useWritingFlow();\n\tconst [ contentResizeListener, { height: contentHeight } ] =\n\t\tuseResizeObserver();\n\tconst setRef = useRefEffect( ( node ) => {\n\t\tnode._load = () => {\n\t\t\tsetIframeDocument( node.contentDocument );\n\t\t};\n\t\tlet iFrameDocument;\n\t\t// Prevent the default browser action for files dropped outside of dropzones.\n\t\tfunction preventFileDropDefault( event ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t\tfunction onLoad() {\n\t\t\tconst { contentDocument, ownerDocument } = node;\n\t\t\tconst { documentElement } = contentDocument;\n\t\t\tiFrameDocument = contentDocument;\n\n\t\t\tbubbleEvents( contentDocument );\n\t\t\tclearerRef( documentElement );\n\n\t\t\t// Ideally ALL classes that are added through get_body_class should\n\t\t\t// be added in the editor too, which we'll somehow have to get from\n\t\t\t// the server in the future (which will run the PHP filters).\n\t\t\tsetBodyClasses(\n\t\t\t\tArray.from( ownerDocument.body.classList ).filter(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tname.startsWith( 'admin-color-' ) ||\n\t\t\t\t\t\tname.startsWith( 'post-type-' ) ||\n\t\t\t\t\t\tname === 'wp-embed-responsive'\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tcontentDocument.dir = ownerDocument.dir;\n\n\t\t\tfor ( const compatStyle of compatStyles ) {\n\t\t\t\tif ( contentDocument.getElementById( compatStyle.id ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tcontentDocument.head.appendChild(\n\t\t\t\t\tcompatStyle.cloneNode( true )\n\t\t\t\t);\n\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`${ compatStyle.id } was added to the iframe incorrectly. Please use block.json or enqueue_block_assets to add styles to the iframe.`,\n\t\t\t\t\tcompatStyle\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t}\n\n\t\tnode.addEventListener( 'load', onLoad );\n\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'load', onLoad );\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t};\n\t}, [] );\n\n\tconst disabledRef = useDisabled( { isDisabled: ! readonly } );\n\tconst bodyRef = useMergeRefs( [\n\t\tcontentRef,\n\t\tclearerRef,\n\t\twritingFlowRef,\n\t\tdisabledRef,\n\t] );\n\n\t// Correct doctype is required to enable rendering in standards\n\t// mode. Also preload the styles to avoid a flash of unstyled\n\t// content.\n\tconst html = `<!doctype html>\n<html>\n\t<head>\n\t\t<script>window.frameElement._load()</script>\n\t\t<style>html{height:auto!important;min-height:100%;}body{margin:0}</style>\n\t\t${ styles }\n\t\t${ scripts }\n\t</head>\n\t<body>\n\t\t<script>document.currentScript.parentElement.remove()</script>\n\t</body>\n</html>`;\n\n\tconst [ src, cleanup ] = useMemo( () => {\n\t\tconst _src = URL.createObjectURL(\n\t\t\tnew window.Blob( [ html ], { type: 'text/html' } )\n\t\t);\n\t\treturn [ _src, () => URL.revokeObjectURL( _src ) ];\n\t}, [ html ] );\n\n\tuseEffect( () => cleanup, [ cleanup ] );\n\n\t// We need to counter the margin created by scaling the iframe. If the scale\n\t// is e.g. 0.45, then the top + bottom margin is 0.55 (1 - scale). Just the\n\t// top or bottom margin is 0.55 / 2 ((1 - scale) / 2).\n\tconst marginFromScaling = ( contentHeight * ( 1 - scale ) ) / 2;\n\n\treturn (\n\t\t<>\n\t\t\t{ tabIndex >= 0 && before }\n\t\t\t<iframe\n\t\t\t\t{ ...props }\n\t\t\t\tstyle={ {\n\t\t\t\t\t...props.style,\n\t\t\t\t\theight: expand ? contentHeight : props.style?.height,\n\t\t\t\t\tmarginTop:\n\t\t\t\t\t\tscale !== 1\n\t\t\t\t\t\t\t? -marginFromScaling + frameSize\n\t\t\t\t\t\t\t: props.style?.marginTop,\n\t\t\t\t\tmarginBottom:\n\t\t\t\t\t\tscale !== 1\n\t\t\t\t\t\t\t? -marginFromScaling + frameSize\n\t\t\t\t\t\t\t: props.style?.marginBottom,\n\t\t\t\t\ttransform:\n\t\t\t\t\t\tscale !== 1\n\t\t\t\t\t\t\t? `scale( ${ scale } )`\n\t\t\t\t\t\t\t: props.style?.transform,\n\t\t\t\t\ttransition: 'all .3s',\n\t\t\t\t} }\n\t\t\t\tref={ useMergeRefs( [ ref, setRef ] ) }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t// Correct doctype is required to enable rendering in standards\n\t\t\t\t// mode. Also preload the styles to avoid a flash of unstyled\n\t\t\t\t// content.\n\t\t\t\tsrc={ src }\n\t\t\t\ttitle={ __( 'Editor canvas' ) }\n\t\t\t>\n\t\t\t\t{ iframeDocument &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<body\n\t\t\t\t\t\t\tref={ bodyRef }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-iframe__body',\n\t\t\t\t\t\t\t\t'editor-styles-wrapper',\n\t\t\t\t\t\t\t\t...bodyClasses\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ contentResizeListener }\n\t\t\t\t\t\t\t<StyleProvider document={ iframeDocument }>\n\t\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t</StyleProvider>\n\t\t\t\t\t\t</body>,\n\t\t\t\t\t\tiframeDocument.documentElement\n\t\t\t\t\t) }\n\t\t\t</iframe>\n\t\t\t{ tabIndex >= 0 && after }\n\t\t</>\n\t);\n}\n\nfunction IframeIfReady( props, ref ) {\n\tconst isInitialised = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().__internalIsInitialized,\n\t\t[]\n\t);\n\n\t// We shouldn't render the iframe until the editor settings are initialised.\n\t// The initial settings are needed to get the styles for the srcDoc, which\n\t// cannot be changed after the iframe is mounted. srcDoc is used to to set\n\t// the initial iframe HTML, which is required to avoid a flash of unstyled\n\t// content.\n\tif ( ! isInitialised ) {\n\t\treturn null;\n\t}\n\n\treturn <Iframe { ...props } forwardedRef={ ref } />;\n}\n\nexport default forwardRef( IframeIfReady );\n"]}
|
|
@@ -44,7 +44,7 @@ function ReusableBlocksRenameHint() {
|
|
|
44
44
|
className: "reusable-blocks-menu-items__rename-hint"
|
|
45
45
|
}, (0, _element.createElement)("div", {
|
|
46
46
|
className: "reusable-blocks-menu-items__rename-hint-content"
|
|
47
|
-
}, (0, _i18n.__)('Reusable blocks are now
|
|
47
|
+
}, (0, _i18n.__)('Reusable blocks are now synced patterns. A synced pattern will behave in exactly the same way as a reusable block.')), (0, _element.createElement)(_components.Button, {
|
|
48
48
|
className: "reusable-blocks-menu-items__rename-hint-dismiss",
|
|
49
49
|
icon: _icons.close,
|
|
50
50
|
iconSize: "16",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/reusable-block-rename-hint.js"],"names":["PREFERENCE_NAME","ReusableBlocksRenameHint","isReusableBlocksRenameHint","select","preferencesStore","get","ref","set","setPreference","close","previousElement","focus","tabbable","findPrevious","current"],"mappings":";;;;;;;AAMA;;AAHA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AATA;AACA;AACA;AASA,MAAMA,eAAe,GAAG,oCAAxB;;AAEe,SAASC,wBAAT,GAAoC;AAClD,QAAMC,0BAA0B,GAAG,qBAChCC,MAAF;AAAA;;AAAA,0BACCA,MAAM,CAAEC,kBAAF,CAAN,CAA2BC,GAA3B,CAAgC,MAAhC,EAAwCL,eAAxC,CADD,qDAC8D,IAD9D;AAAA,GADkC,EAGlC,EAHkC,CAAnC;AAMA,QAAMM,GAAG,GAAG,sBAAZ;AAEA,QAAM;AAAEC,IAAAA,GAAG,EAAEC;AAAP,MAAyB,uBAAaJ,kBAAb,CAA/B;;AACA,MAAK,CAAEF,0BAAP,EAAoC;AACnC,WAAO,IAAP;AACA;;AAED,SACC;AAAK,IAAA,GAAG,EAAGI,GAAX;AAAiB,IAAA,SAAS,EAAC;AAA3B,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACG,cACD,oHADC,CADH,CADD,EAMC,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,iDADX;AAEC,IAAA,IAAI,EAAGG,YAFR;AAGC,IAAA,QAAQ,EAAC,IAHV;AAIC,IAAA,KAAK,EAAG,cAAI,cAAJ,CAJT;AAKC,IAAA,OAAO,EAAG,MAAM;AACf;AACA,YAAMC,eAAe,GAAGC,WAAMC,QAAN,CAAeC,YAAf,CACvBP,GAAG,CAACQ,OADmB,CAAxB;;AAGAJ,MAAAA,eAAe,EAAEC,KAAjB;AACAH,MAAAA,aAAa,CAAE,MAAF,EAAUR,eAAV,EAA2B,KAA3B,CAAb;AACA,KAZF;AAaC,IAAA,WAAW,EAAG;AAbf,IAND,CADD;AAwBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { focus } from '@wordpress/dom';\nimport { useRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { close } from '@wordpress/icons';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\nconst PREFERENCE_NAME = 'isResuableBlocksrRenameHintVisible';\n\nexport default function ReusableBlocksRenameHint() {\n\tconst isReusableBlocksRenameHint = useSelect(\n\t\t( select ) =>\n\t\t\tselect( preferencesStore ).get( 'core', PREFERENCE_NAME ) ?? true,\n\t\t[]\n\t);\n\n\tconst ref = useRef();\n\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\tif ( ! isReusableBlocksRenameHint ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div ref={ ref } className=\"reusable-blocks-menu-items__rename-hint\">\n\t\t\t<div className=\"reusable-blocks-menu-items__rename-hint-content\">\n\t\t\t\t{ __(\n\t\t\t\t\t'Reusable blocks are now
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/reusable-block-rename-hint.js"],"names":["PREFERENCE_NAME","ReusableBlocksRenameHint","isReusableBlocksRenameHint","select","preferencesStore","get","ref","set","setPreference","close","previousElement","focus","tabbable","findPrevious","current"],"mappings":";;;;;;;AAMA;;AAHA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AATA;AACA;AACA;AASA,MAAMA,eAAe,GAAG,oCAAxB;;AAEe,SAASC,wBAAT,GAAoC;AAClD,QAAMC,0BAA0B,GAAG,qBAChCC,MAAF;AAAA;;AAAA,0BACCA,MAAM,CAAEC,kBAAF,CAAN,CAA2BC,GAA3B,CAAgC,MAAhC,EAAwCL,eAAxC,CADD,qDAC8D,IAD9D;AAAA,GADkC,EAGlC,EAHkC,CAAnC;AAMA,QAAMM,GAAG,GAAG,sBAAZ;AAEA,QAAM;AAAEC,IAAAA,GAAG,EAAEC;AAAP,MAAyB,uBAAaJ,kBAAb,CAA/B;;AACA,MAAK,CAAEF,0BAAP,EAAoC;AACnC,WAAO,IAAP;AACA;;AAED,SACC;AAAK,IAAA,GAAG,EAAGI,GAAX;AAAiB,IAAA,SAAS,EAAC;AAA3B,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACG,cACD,oHADC,CADH,CADD,EAMC,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,iDADX;AAEC,IAAA,IAAI,EAAGG,YAFR;AAGC,IAAA,QAAQ,EAAC,IAHV;AAIC,IAAA,KAAK,EAAG,cAAI,cAAJ,CAJT;AAKC,IAAA,OAAO,EAAG,MAAM;AACf;AACA,YAAMC,eAAe,GAAGC,WAAMC,QAAN,CAAeC,YAAf,CACvBP,GAAG,CAACQ,OADmB,CAAxB;;AAGAJ,MAAAA,eAAe,EAAEC,KAAjB;AACAH,MAAAA,aAAa,CAAE,MAAF,EAAUR,eAAV,EAA2B,KAA3B,CAAb;AACA,KAZF;AAaC,IAAA,WAAW,EAAG;AAbf,IAND,CADD;AAwBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { focus } from '@wordpress/dom';\nimport { useRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { close } from '@wordpress/icons';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\nconst PREFERENCE_NAME = 'isResuableBlocksrRenameHintVisible';\n\nexport default function ReusableBlocksRenameHint() {\n\tconst isReusableBlocksRenameHint = useSelect(\n\t\t( select ) =>\n\t\t\tselect( preferencesStore ).get( 'core', PREFERENCE_NAME ) ?? true,\n\t\t[]\n\t);\n\n\tconst ref = useRef();\n\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\tif ( ! isReusableBlocksRenameHint ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div ref={ ref } className=\"reusable-blocks-menu-items__rename-hint\">\n\t\t\t<div className=\"reusable-blocks-menu-items__rename-hint-content\">\n\t\t\t\t{ __(\n\t\t\t\t\t'Reusable blocks are now synced patterns. A synced pattern will behave in exactly the same way as a reusable block.'\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t<Button\n\t\t\t\tclassName=\"reusable-blocks-menu-items__rename-hint-dismiss\"\n\t\t\t\ticon={ close }\n\t\t\t\ticonSize=\"16\"\n\t\t\t\tlabel={ __( 'Dismiss hint' ) }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\t// Retain focus when dismissing the element.\n\t\t\t\t\tconst previousElement = focus.tabbable.findPrevious(\n\t\t\t\t\t\tref.current\n\t\t\t\t\t);\n\t\t\t\t\tpreviousElement?.focus();\n\t\t\t\t\tsetPreference( 'core', PREFERENCE_NAME, false );\n\t\t\t\t} }\n\t\t\t\tshowTooltip={ false }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -17,7 +17,7 @@ const CREATE_TYPE = '__CREATE__';
|
|
|
17
17
|
exports.CREATE_TYPE = CREATE_TYPE;
|
|
18
18
|
const TEL_TYPE = 'tel';
|
|
19
19
|
exports.TEL_TYPE = TEL_TYPE;
|
|
20
|
-
const URL_TYPE = '
|
|
20
|
+
const URL_TYPE = 'link';
|
|
21
21
|
exports.URL_TYPE = URL_TYPE;
|
|
22
22
|
const MAILTO_TYPE = 'mailto';
|
|
23
23
|
exports.MAILTO_TYPE = MAILTO_TYPE;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/constants.js"],"names":["CREATE_TYPE","TEL_TYPE","URL_TYPE","MAILTO_TYPE","INTERNAL_TYPE","LINK_ENTRY_TYPES","DEFAULT_LINK_SETTINGS","id","title"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGA;AACA;AACA;AACO,MAAMA,WAAW,GAAG,YAApB;;AACA,MAAMC,QAAQ,GAAG,KAAjB;;AACA,MAAMC,QAAQ,GAAG,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/constants.js"],"names":["CREATE_TYPE","TEL_TYPE","URL_TYPE","MAILTO_TYPE","INTERNAL_TYPE","LINK_ENTRY_TYPES","DEFAULT_LINK_SETTINGS","id","title"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGA;AACA;AACA;AACO,MAAMA,WAAW,GAAG,YAApB;;AACA,MAAMC,QAAQ,GAAG,KAAjB;;AACA,MAAMC,QAAQ,GAAG,MAAjB;;AACA,MAAMC,WAAW,GAAG,QAApB;;AACA,MAAMC,aAAa,GAAG,UAAtB;;AAEA,MAAMC,gBAAgB,GAAG,CAC/BH,QAD+B,EAE/BC,WAF+B,EAG/BF,QAH+B,EAI/BG,aAJ+B,CAAzB;;AAOA,MAAME,qBAAqB,GAAG,CACpC;AACCC,EAAAA,EAAE,EAAE,eADL;AAECC,EAAAA,KAAK,EAAE,cAAI,iBAAJ;AAFR,CADoC,CAA9B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n// Used as a unique identifier for the \"Create\" option within search results.\n// Used to help distinguish the \"Create\" suggestion within the search results in\n// order to handle it as a unique case.\nexport const CREATE_TYPE = '__CREATE__';\nexport const TEL_TYPE = 'tel';\nexport const URL_TYPE = 'link';\nexport const MAILTO_TYPE = 'mailto';\nexport const INTERNAL_TYPE = 'internal';\n\nexport const LINK_ENTRY_TYPES = [\n\tURL_TYPE,\n\tMAILTO_TYPE,\n\tTEL_TYPE,\n\tINTERNAL_TYPE,\n];\n\nexport const DEFAULT_LINK_SETTINGS = [\n\t{\n\t\tid: 'opensInNewTab',\n\t\ttitle: __( 'Open in new tab' ),\n\t},\n];\n"]}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
@@ -9,18 +7,12 @@ exports.default = exports.LinkControlSearchCreate = void 0;
|
|
|
9
7
|
|
|
10
8
|
var _element = require("@wordpress/element");
|
|
11
9
|
|
|
12
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
-
|
|
14
10
|
var _i18n = require("@wordpress/i18n");
|
|
15
11
|
|
|
16
12
|
var _components = require("@wordpress/components");
|
|
17
13
|
|
|
18
14
|
var _icons = require("@wordpress/icons");
|
|
19
15
|
|
|
20
|
-
/**
|
|
21
|
-
* External dependencies
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
16
|
/**
|
|
25
17
|
* WordPress dependencies
|
|
26
18
|
*/
|
|
@@ -28,7 +20,6 @@ const LinkControlSearchCreate = ({
|
|
|
28
20
|
searchTerm,
|
|
29
21
|
onClick,
|
|
30
22
|
itemProps,
|
|
31
|
-
isSelected,
|
|
32
23
|
buttonText
|
|
33
24
|
}) => {
|
|
34
25
|
if (!searchTerm) {
|
|
@@ -47,19 +38,12 @@ const LinkControlSearchCreate = ({
|
|
|
47
38
|
});
|
|
48
39
|
}
|
|
49
40
|
|
|
50
|
-
return (0, _element.createElement)(_components.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
41
|
+
return (0, _element.createElement)(_components.MenuItem, { ...itemProps,
|
|
42
|
+
iconPosition: "left",
|
|
43
|
+
icon: _icons.plus,
|
|
44
|
+
className: "block-editor-link-control__search-item",
|
|
54
45
|
onClick: onClick
|
|
55
|
-
},
|
|
56
|
-
className: "block-editor-link-control__search-item-icon",
|
|
57
|
-
icon: _icons.plus
|
|
58
|
-
}), (0, _element.createElement)("span", {
|
|
59
|
-
className: "block-editor-link-control__search-item-header"
|
|
60
|
-
}, (0, _element.createElement)("span", {
|
|
61
|
-
className: "block-editor-link-control__search-item-title"
|
|
62
|
-
}, text)));
|
|
46
|
+
}, text);
|
|
63
47
|
};
|
|
64
48
|
|
|
65
49
|
exports.LinkControlSearchCreate = LinkControlSearchCreate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-create-button.js"],"names":["LinkControlSearchCreate","searchTerm","onClick","itemProps","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-create-button.js"],"names":["LinkControlSearchCreate","searchTerm","onClick","itemProps","buttonText","text","mark","plus"],"mappings":";;;;;;;AAKA;;AAFA;;AACA;;AAEA;;AANA;AACA;AACA;AAMO,MAAMA,uBAAuB,GAAG,CAAE;AACxCC,EAAAA,UADwC;AAExCC,EAAAA,OAFwC;AAGxCC,EAAAA,SAHwC;AAIxCC,EAAAA;AAJwC,CAAF,KAKhC;AACN,MAAK,CAAEH,UAAP,EAAoB;AACnB,WAAO,IAAP;AACA;;AAED,MAAII,IAAJ;;AACA,MAAKD,UAAL,EAAkB;AACjBC,IAAAA,IAAI,GACH,OAAOD,UAAP,KAAsB,UAAtB,GACGA,UAAU,CAAEH,UAAF,CADb,GAEGG,UAHJ;AAIA,GALD,MAKO;AACNC,IAAAA,IAAI,GAAG,uCACN;AACC;AACA,kBAAI,yBAAJ,CAFD,EAGCJ,UAHD,CADM,EAMN;AAAEK,MAAAA,IAAI,EAAE;AAAR,KANM,CAAP;AAQA;;AAED,SACC,4BAAC,oBAAD,OACMH,SADN;AAEC,IAAA,YAAY,EAAC,MAFd;AAGC,IAAA,IAAI,EAAGI,WAHR;AAIC,IAAA,SAAS,EAAC,wCAJX;AAKC,IAAA,OAAO,EAAGL;AALX,KAOGG,IAPH,CADD;AAWA,CAtCM;;;eAwCQL,uB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { MenuItem } from '@wordpress/components';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { plus } from '@wordpress/icons';\n\nexport const LinkControlSearchCreate = ( {\n\tsearchTerm,\n\tonClick,\n\titemProps,\n\tbuttonText,\n} ) => {\n\tif ( ! searchTerm ) {\n\t\treturn null;\n\t}\n\n\tlet text;\n\tif ( buttonText ) {\n\t\ttext =\n\t\t\ttypeof buttonText === 'function'\n\t\t\t\t? buttonText( searchTerm )\n\t\t\t\t: buttonText;\n\t} else {\n\t\ttext = createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: search term. */\n\t\t\t\t__( 'Create: <mark>%s</mark>' ),\n\t\t\t\tsearchTerm\n\t\t\t),\n\t\t\t{ mark: <mark /> }\n\t\t);\n\t}\n\n\treturn (\n\t\t<MenuItem\n\t\t\t{ ...itemProps }\n\t\t\ticonPosition=\"left\"\n\t\t\ticon={ plus }\n\t\t\tclassName=\"block-editor-link-control__search-item\"\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ text }\n\t\t</MenuItem>\n\t);\n};\n\nexport default LinkControlSearchCreate;\n"]}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
@@ -9,10 +7,6 @@ exports.default = exports.LinkControlSearchItem = void 0;
|
|
|
9
7
|
|
|
10
8
|
var _element = require("@wordpress/element");
|
|
11
9
|
|
|
12
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
-
|
|
14
|
-
var _url = require("@wordpress/url");
|
|
15
|
-
|
|
16
10
|
var _i18n = require("@wordpress/i18n");
|
|
17
11
|
|
|
18
12
|
var _components = require("@wordpress/components");
|
|
@@ -21,9 +15,7 @@ var _icons = require("@wordpress/icons");
|
|
|
21
15
|
|
|
22
16
|
var _dom = require("@wordpress/dom");
|
|
23
17
|
|
|
24
|
-
|
|
25
|
-
* External dependencies
|
|
26
|
-
*/
|
|
18
|
+
var _url = require("@wordpress/url");
|
|
27
19
|
|
|
28
20
|
/**
|
|
29
21
|
* WordPress dependencies
|
|
@@ -61,36 +53,27 @@ function SearchItemIcon({
|
|
|
61
53
|
const LinkControlSearchItem = ({
|
|
62
54
|
itemProps,
|
|
63
55
|
suggestion,
|
|
64
|
-
|
|
56
|
+
searchTerm,
|
|
65
57
|
onClick,
|
|
66
58
|
isURL = false,
|
|
67
|
-
searchTerm = '',
|
|
68
59
|
shouldShowType = false
|
|
69
60
|
}) => {
|
|
70
|
-
|
|
61
|
+
const info = isURL ? (0, _i18n.__)('Press ENTER to add this link') : (0, _url.filterURLForDisplay)((0, _url.safeDecodeURI)(suggestion?.url));
|
|
62
|
+
return (0, _element.createElement)(_components.MenuItem, { ...itemProps,
|
|
63
|
+
info: info,
|
|
64
|
+
iconPosition: "left",
|
|
65
|
+
icon: (0, _element.createElement)(SearchItemIcon, {
|
|
66
|
+
suggestion: suggestion,
|
|
67
|
+
isURL: isURL
|
|
68
|
+
}),
|
|
71
69
|
onClick: onClick,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
'is-url': isURL,
|
|
75
|
-
'is-entity': !isURL
|
|
76
|
-
})
|
|
77
|
-
}, (0, _element.createElement)(SearchItemIcon, {
|
|
78
|
-
suggestion: suggestion,
|
|
79
|
-
isURL: isURL
|
|
80
|
-
}), (0, _element.createElement)("span", {
|
|
81
|
-
className: "block-editor-link-control__search-item-header"
|
|
82
|
-
}, (0, _element.createElement)("span", {
|
|
83
|
-
className: "block-editor-link-control__search-item-title"
|
|
70
|
+
shortcut: shouldShowType && getVisualTypeName(suggestion),
|
|
71
|
+
className: "block-editor-link-control__search-item"
|
|
84
72
|
}, (0, _element.createElement)(_components.TextHighlight // The component expects a plain text string.
|
|
85
73
|
, {
|
|
86
74
|
text: (0, _dom.__unstableStripHTML)(suggestion.title),
|
|
87
75
|
highlight: searchTerm
|
|
88
|
-
}))
|
|
89
|
-
"aria-hidden": !isURL,
|
|
90
|
-
className: "block-editor-link-control__search-item-info"
|
|
91
|
-
}, !isURL && ((0, _url.filterURLForDisplay)((0, _url.safeDecodeURI)(suggestion.url)) || ''), isURL && (0, _i18n.__)('Press ENTER to add this link'))), shouldShowType && suggestion.type && (0, _element.createElement)("span", {
|
|
92
|
-
className: "block-editor-link-control__search-item-type"
|
|
93
|
-
}, getVisualTypeName(suggestion)));
|
|
76
|
+
}));
|
|
94
77
|
};
|
|
95
78
|
|
|
96
79
|
exports.LinkControlSearchItem = LinkControlSearchItem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-item.js"],"names":["ICONS_MAP","post","postList","page","post_tag","tag","category","attachment","file","SearchItemIcon","isURL","suggestion","icon","globe","type","LinkControlSearchItem","itemProps","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-item.js"],"names":["ICONS_MAP","post","postList","page","post_tag","tag","category","attachment","file","SearchItemIcon","isURL","suggestion","icon","globe","type","LinkControlSearchItem","itemProps","searchTerm","onClick","shouldShowType","info","url","getVisualTypeName","title","isFrontPage"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AASA;;AACA;;AAfA;AACA;AACA;AAeA,MAAMA,SAAS,GAAG;AACjBC,EAAAA,IAAI,EAAEC,eADW;AAEjBC,EAAAA,IAAI,EAAJA,WAFiB;AAGjBC,EAAAA,QAAQ,EAAEC,UAHO;AAIjBC,EAAAA,QAAQ,EAARA,eAJiB;AAKjBC,EAAAA,UAAU,EAAEC;AALK,CAAlB;;AAQA,SAASC,cAAT,CAAyB;AAAEC,EAAAA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4BX,UAA5B,EAAyC;AACxC,MAAKA,UAAU,CAACa,WAAhB,EAA8B;AAC7B,WAAO,YAAP;AACA,GAHuC,CAKxC;;;AACA,SAAOb,UAAU,CAACG,IAAX,KAAoB,UAApB,GAAiC,KAAjC,GAAyCH,UAAU,CAACG,IAA3D;AACA;;eAEcC,qB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { MenuItem, TextHighlight } from '@wordpress/components';\nimport {\n\tIcon,\n\tglobe,\n\tpage,\n\ttag,\n\tpostList,\n\tcategory,\n\tfile,\n} from '@wordpress/icons';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { safeDecodeURI, filterURLForDisplay } from '@wordpress/url';\n\nconst ICONS_MAP = {\n\tpost: postList,\n\tpage,\n\tpost_tag: tag,\n\tcategory,\n\tattachment: file,\n};\n\nfunction SearchItemIcon( { isURL, suggestion } ) {\n\tlet icon = null;\n\n\tif ( isURL ) {\n\t\ticon = globe;\n\t} else if ( suggestion.type in ICONS_MAP ) {\n\t\ticon = ICONS_MAP[ suggestion.type ];\n\t}\n\n\tif ( icon ) {\n\t\treturn (\n\t\t\t<Icon\n\t\t\t\tclassName=\"block-editor-link-control__search-item-icon\"\n\t\t\t\ticon={ icon }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn null;\n}\n\nexport const LinkControlSearchItem = ( {\n\titemProps,\n\tsuggestion,\n\tsearchTerm,\n\tonClick,\n\tisURL = false,\n\tshouldShowType = false,\n} ) => {\n\tconst info = isURL\n\t\t? __( 'Press ENTER to add this link' )\n\t\t: filterURLForDisplay( safeDecodeURI( suggestion?.url ) );\n\n\treturn (\n\t\t<MenuItem\n\t\t\t{ ...itemProps }\n\t\t\tinfo={ info }\n\t\t\ticonPosition=\"left\"\n\t\t\ticon={\n\t\t\t\t<SearchItemIcon suggestion={ suggestion } isURL={ isURL } />\n\t\t\t}\n\t\t\tonClick={ onClick }\n\t\t\tshortcut={ shouldShowType && getVisualTypeName( suggestion ) }\n\t\t\tclassName=\"block-editor-link-control__search-item\"\n\t\t>\n\t\t\t<TextHighlight\n\t\t\t\t// The component expects a plain text string.\n\t\t\t\ttext={ stripHTML( suggestion.title ) }\n\t\t\t\thighlight={ searchTerm }\n\t\t\t/>\n\t\t</MenuItem>\n\t);\n};\n\nfunction getVisualTypeName( suggestion ) {\n\tif ( suggestion.isFrontPage ) {\n\t\treturn 'front page';\n\t}\n\n\t// Rename 'post_tag' to 'tag'. Ideally, the API would return the localised CPT or taxonomy label.\n\treturn suggestion.type === 'post_tag' ? 'tag' : suggestion.type;\n}\n\nexport default LinkControlSearchItem;\n"]}
|
|
@@ -70,7 +70,7 @@ function LinkControlSearchResults({
|
|
|
70
70
|
}, searchResultsLabel, (0, _element.createElement)("div", { ...suggestionsListProps,
|
|
71
71
|
className: resultsListClasses,
|
|
72
72
|
"aria-labelledby": searchResultsLabelId
|
|
73
|
-
}, suggestions.map((suggestion, index) => {
|
|
73
|
+
}, (0, _element.createElement)(_components.MenuGroup, null, suggestions.map((suggestion, index) => {
|
|
74
74
|
if (shouldShowCreateSuggestion && _constants.CREATE_TYPE === suggestion.type) {
|
|
75
75
|
return (0, _element.createElement)(_searchCreateButton.default, {
|
|
76
76
|
searchTerm: currentInputValue,
|
|
@@ -105,6 +105,6 @@ function LinkControlSearchResults({
|
|
|
105
105
|
shouldShowType: shouldShowSuggestionsTypes,
|
|
106
106
|
isFrontPage: suggestion?.isFrontPage
|
|
107
107
|
});
|
|
108
|
-
})));
|
|
108
|
+
}))));
|
|
109
109
|
}
|
|
110
110
|
//# sourceMappingURL=search-results.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-results.js"],"names":["LinkControlSearchResults","instanceId","withCreateSuggestion","currentInputValue","handleSuggestionClick","suggestionsListProps","buildSuggestionItemProps","suggestions","selectedSuggestion","isLoading","isInitialSuggestions","createSuggestionButtonText","suggestionsQuery","resultsListClasses","isSingleDirectEntryResult","length","LINK_ENTRY_TYPES","includes","type","shouldShowCreateSuggestion","shouldShowSuggestionsTypes","searchResultsLabelId","labelText","searchResultsLabel","map","suggestion","index","CREATE_TYPE","id","isFrontPage"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AAKA;;AAKA;;AACA;;AACA;;AAhBA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AAKe,SAASA,wBAAT,CAAmC;AACjDC,EAAAA,UADiD;AAEjDC,EAAAA,oBAFiD;AAGjDC,EAAAA,iBAHiD;AAIjDC,EAAAA,qBAJiD;AAKjDC,EAAAA,oBALiD;AAMjDC,EAAAA,wBANiD;AAOjDC,EAAAA,WAPiD;AAQjDC,EAAAA,kBARiD;AASjDC,EAAAA,SATiD;AAUjDC,EAAAA,oBAViD;AAWjDC,EAAAA,0BAXiD;AAYjDC,EAAAA;AAZiD,CAAnC,EAaX;AACH,QAAMC,kBAAkB,GAAG,yBAC1B,2CAD0B,EAE1B;AACC,kBAAcJ;AADf,GAF0B,CAA3B;;AAOA,QAAMK,yBAAyB,GAC9BP,WAAW,CAACQ,MAAZ,KAAuB,CAAvB,IACAC,4BAAiBC,QAAjB,CAA2BV,WAAW,CAAE,CAAF,CAAX,CAAiBW,IAA5C,CAFD;;AAGA,QAAMC,0BAA0B,GAC/BjB,oBAAoB,IACpB,CAAEY,yBADF,IAEA,CAAEJ,oBAHH,CAXG,CAeH;;AACA,QAAMU,0BAA0B,GAAG,CAAER,gBAAgB,EAAEM,IAAvD,CAhBG,CAkBH;AACA;AACA;;AACA,QAAMG,oBAAoB,GAAI,kDAAkDpB,UAAY,EAA5F;AACA,QAAMqB,SAAS,GAAGZ,oBAAoB,GACnC,cAAI,aAAJ,CADmC,GAEnC;AACA;AACA,gBAAI,yBAAJ,CAFA,EAGAP,iBAHA,CAFH;AAOA,QAAMoB,kBAAkB,GACvB,4BAAC,0BAAD;AAAgB,IAAA,EAAE,EAAGF;AAArB,KACGC,SADH,CADD;AAMA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGC,kBADH,EAEC,wCACMlB,oBADN;AAEC,IAAA,SAAS,EAAGQ,kBAFb;AAGC,uBAAkBQ;AAHnB,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-results.js"],"names":["LinkControlSearchResults","instanceId","withCreateSuggestion","currentInputValue","handleSuggestionClick","suggestionsListProps","buildSuggestionItemProps","suggestions","selectedSuggestion","isLoading","isInitialSuggestions","createSuggestionButtonText","suggestionsQuery","resultsListClasses","isSingleDirectEntryResult","length","LINK_ENTRY_TYPES","includes","type","shouldShowCreateSuggestion","shouldShowSuggestionsTypes","searchResultsLabelId","labelText","searchResultsLabel","map","suggestion","index","CREATE_TYPE","id","isFrontPage"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AAKA;;AAKA;;AACA;;AACA;;AAhBA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AAKe,SAASA,wBAAT,CAAmC;AACjDC,EAAAA,UADiD;AAEjDC,EAAAA,oBAFiD;AAGjDC,EAAAA,iBAHiD;AAIjDC,EAAAA,qBAJiD;AAKjDC,EAAAA,oBALiD;AAMjDC,EAAAA,wBANiD;AAOjDC,EAAAA,WAPiD;AAQjDC,EAAAA,kBARiD;AASjDC,EAAAA,SATiD;AAUjDC,EAAAA,oBAViD;AAWjDC,EAAAA,0BAXiD;AAYjDC,EAAAA;AAZiD,CAAnC,EAaX;AACH,QAAMC,kBAAkB,GAAG,yBAC1B,2CAD0B,EAE1B;AACC,kBAAcJ;AADf,GAF0B,CAA3B;;AAOA,QAAMK,yBAAyB,GAC9BP,WAAW,CAACQ,MAAZ,KAAuB,CAAvB,IACAC,4BAAiBC,QAAjB,CAA2BV,WAAW,CAAE,CAAF,CAAX,CAAiBW,IAA5C,CAFD;;AAGA,QAAMC,0BAA0B,GAC/BjB,oBAAoB,IACpB,CAAEY,yBADF,IAEA,CAAEJ,oBAHH,CAXG,CAeH;;AACA,QAAMU,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AAMC,MAAA,UAAU,EAAGD,UANd;AAOC,MAAA,KAAK,EAAGC,KAPT;AAQC,MAAA,OAAO,EAAG,MAAM;AACftB,QAAAA,qBAAqB,CAAEqB,UAAF,CAArB;AACA,OAVF;AAWC,MAAA,UAAU,EAAGC,KAAK,KAAKlB,kBAXxB;AAYC,MAAA,KAAK,EAAGQ,4BAAiBC,QAAjB,CACPQ,UAAU,CAACP,IADJ,CAZT;AAeC,MAAA,UAAU,EAAGf,iBAfd;AAgBC,MAAA,cAAc,EAAGiB,0BAhBlB;AAiBC,MAAA,WAAW,EAAGK,UAAU,EAAEI;AAjB3B,MADD;AAqBA,GApDC,CADH,CALD,CAFD,CADD;AAkEA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { VisuallyHidden, MenuGroup } from '@wordpress/components';\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * Internal dependencies\n */\nimport LinkControlSearchCreate from './search-create-button';\nimport LinkControlSearchItem from './search-item';\nimport { CREATE_TYPE, LINK_ENTRY_TYPES } from './constants';\n\nexport default function LinkControlSearchResults( {\n\tinstanceId,\n\twithCreateSuggestion,\n\tcurrentInputValue,\n\thandleSuggestionClick,\n\tsuggestionsListProps,\n\tbuildSuggestionItemProps,\n\tsuggestions,\n\tselectedSuggestion,\n\tisLoading,\n\tisInitialSuggestions,\n\tcreateSuggestionButtonText,\n\tsuggestionsQuery,\n} ) {\n\tconst resultsListClasses = classnames(\n\t\t'block-editor-link-control__search-results',\n\t\t{\n\t\t\t'is-loading': isLoading,\n\t\t}\n\t);\n\n\tconst isSingleDirectEntryResult =\n\t\tsuggestions.length === 1 &&\n\t\tLINK_ENTRY_TYPES.includes( suggestions[ 0 ].type );\n\tconst shouldShowCreateSuggestion =\n\t\twithCreateSuggestion &&\n\t\t! isSingleDirectEntryResult &&\n\t\t! isInitialSuggestions;\n\t// If the query has a specified type, then we can skip showing them in the result. See #24839.\n\tconst shouldShowSuggestionsTypes = ! suggestionsQuery?.type;\n\n\t// According to guidelines aria-label should be added if the label\n\t// itself is not visible.\n\t// See: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/listbox_role\n\tconst searchResultsLabelId = `block-editor-link-control-search-results-label-${ instanceId }`;\n\tconst labelText = isInitialSuggestions\n\t\t? __( 'Suggestions' )\n\t\t: sprintf(\n\t\t\t\t/* translators: %s: search term. */\n\t\t\t\t__( 'Search results for \"%s\"' ),\n\t\t\t\tcurrentInputValue\n\t\t );\n\tconst searchResultsLabel = (\n\t\t<VisuallyHidden id={ searchResultsLabelId }>\n\t\t\t{ labelText }\n\t\t</VisuallyHidden>\n\t);\n\n\treturn (\n\t\t<div className=\"block-editor-link-control__search-results-wrapper\">\n\t\t\t{ searchResultsLabel }\n\t\t\t<div\n\t\t\t\t{ ...suggestionsListProps }\n\t\t\t\tclassName={ resultsListClasses }\n\t\t\t\taria-labelledby={ searchResultsLabelId }\n\t\t\t>\n\t\t\t\t<MenuGroup>\n\t\t\t\t\t{ suggestions.map( ( suggestion, index ) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tshouldShowCreateSuggestion &&\n\t\t\t\t\t\t\tCREATE_TYPE === suggestion.type\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<LinkControlSearchCreate\n\t\t\t\t\t\t\t\t\tsearchTerm={ currentInputValue }\n\t\t\t\t\t\t\t\t\tbuttonText={ createSuggestionButtonText }\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\thandleSuggestionClick( suggestion )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t// Intentionally only using `type` here as\n\t\t\t\t\t\t\t\t\t// the constant is enough to uniquely\n\t\t\t\t\t\t\t\t\t// identify the single \"CREATE\" suggestion.\n\t\t\t\t\t\t\t\t\tkey={ suggestion.type }\n\t\t\t\t\t\t\t\t\titemProps={ buildSuggestionItemProps(\n\t\t\t\t\t\t\t\t\t\tsuggestion,\n\t\t\t\t\t\t\t\t\t\tindex\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tisSelected={ index === selectedSuggestion }\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\n\t\t\t\t\t\t// If we're not handling \"Create\" suggestions above then\n\t\t\t\t\t\t// we don't want them in the main results so exit early.\n\t\t\t\t\t\tif ( CREATE_TYPE === suggestion.type ) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<LinkControlSearchItem\n\t\t\t\t\t\t\t\tkey={ `${ suggestion.id }-${ suggestion.type }` }\n\t\t\t\t\t\t\t\titemProps={ buildSuggestionItemProps(\n\t\t\t\t\t\t\t\t\tsuggestion,\n\t\t\t\t\t\t\t\t\tindex\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tsuggestion={ suggestion }\n\t\t\t\t\t\t\t\tindex={ index }\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\thandleSuggestionClick( suggestion );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tisSelected={ index === selectedSuggestion }\n\t\t\t\t\t\t\t\tisURL={ LINK_ENTRY_TYPES.includes(\n\t\t\t\t\t\t\t\t\tsuggestion.type\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tsearchTerm={ currentInputValue }\n\t\t\t\t\t\t\t\tshouldShowType={ shouldShowSuggestionsTypes }\n\t\t\t\t\t\t\t\tisFrontPage={ suggestion?.isFrontPage }\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</MenuGroup>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.Content = void 0;
|
|
9
|
-
exports.getRichTextValues = getRichTextValues;
|
|
10
9
|
|
|
11
10
|
var _element = require("@wordpress/element");
|
|
12
11
|
|
|
@@ -61,39 +60,4 @@ const Content = ({
|
|
|
61
60
|
};
|
|
62
61
|
|
|
63
62
|
exports.Content = Content;
|
|
64
|
-
Content.__unstableIsRichTextContent = {};
|
|
65
|
-
|
|
66
|
-
function findContent(blocks, richTextValues = []) {
|
|
67
|
-
if (!Array.isArray(blocks)) {
|
|
68
|
-
blocks = [blocks];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
for (const block of blocks) {
|
|
72
|
-
if (block?.type?.__unstableIsRichTextContent === Content.__unstableIsRichTextContent) {
|
|
73
|
-
richTextValues.push(block.props.value);
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (block?.props?.children) {
|
|
78
|
-
findContent(block.props.children, richTextValues);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return richTextValues;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function _getSaveElement({
|
|
86
|
-
name,
|
|
87
|
-
attributes,
|
|
88
|
-
innerBlocks
|
|
89
|
-
}) {
|
|
90
|
-
return (0, _blocks.getSaveElement)(name, attributes, innerBlocks.map(_getSaveElement));
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function getRichTextValues(blocks = []) {
|
|
94
|
-
_blocks.__unstableGetBlockProps.skipFilters = true;
|
|
95
|
-
const values = findContent((Array.isArray(blocks) ? blocks : [blocks]).map(_getSaveElement));
|
|
96
|
-
_blocks.__unstableGetBlockProps.skipFilters = false;
|
|
97
|
-
return values;
|
|
98
|
-
}
|
|
99
63
|
//# sourceMappingURL=content.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/content.js"],"names":["Content","value","tagName","Tag","multiline","props","Array","isArray","since","version","alternative","link","childrenSource","toHTML","MultilineTag","content","format","restProps"
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/content.js"],"names":["Content","value","tagName","Tag","multiline","props","Array","isArray","since","version","alternative","link","childrenSource","toHTML","MultilineTag","content","format","restProps"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAGO,MAAMA,OAAO,GAAG,CAAE;AAAEC,EAAAA,KAAF;AAASC,EAAAA,OAAO,EAAEC,GAAlB;AAAuBC,EAAAA,SAAvB;AAAkC,KAAGC;AAArC,CAAF,KAAoD;AAC1E;AACA,MAAKC,KAAK,CAACC,OAAN,CAAeN,KAAf,CAAL,EAA8B;AAC7B,6BAAY,qDAAZ,EAAmE;AAClEO,MAAAA,KAAK,EAAE,KAD2D;AAElEC,MAAAA,OAAO,EAAE,KAFyD;AAGlEC,MAAAA,WAAW,EAAE,sBAHqD;AAIlEC,MAAAA,IAAI,EAAE;AAJ4D,KAAnE;AAOAV,IAAAA,KAAK,GAAGW,iBAAeC,MAAf,CAAuBZ,KAAvB,CAAR;AACA;;AAED,QAAMa,YAAY,GAAG,4BAAiBV,SAAjB,CAArB;;AAEA,MAAK,CAAEH,KAAF,IAAWa,YAAhB,EAA+B;AAC9Bb,IAAAA,KAAK,GAAI,IAAIa,YAAc,MAAMA,YAAc,GAA/C;AACA;;AAED,QAAMC,OAAO,GAAG,4BAAC,gBAAD,QAAWd,KAAX,CAAhB;;AAEA,MAAKE,GAAL,EAAW;AACV,UAAM;AAAEa,MAAAA,MAAF;AAAU,SAAGC;AAAb,QAA2BZ,KAAjC;AACA,WAAO,4BAAC,GAAD,OAAUY;AAAV,OAAwBF,OAAxB,CAAP;AACA;;AAED,SAAOA,OAAP;AACA,CA3BM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { RawHTML } from '@wordpress/element';\nimport { children as childrenSource } from '@wordpress/blocks';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { getMultilineTag } from './utils';\n\nexport const Content = ( { value, tagName: Tag, multiline, ...props } ) => {\n\t// Handle deprecated `children` and `node` sources.\n\tif ( Array.isArray( value ) ) {\n\t\tdeprecated( 'wp.blockEditor.RichText value prop as children type', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t\talternative: 'value prop as string',\n\t\t\tlink: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/',\n\t\t} );\n\n\t\tvalue = childrenSource.toHTML( value );\n\t}\n\n\tconst MultilineTag = getMultilineTag( multiline );\n\n\tif ( ! value && MultilineTag ) {\n\t\tvalue = `<${ MultilineTag }></${ MultilineTag }>`;\n\t}\n\n\tconst content = <RawHTML>{ value }</RawHTML>;\n\n\tif ( Tag ) {\n\t\tconst { format, ...restProps } = props;\n\t\treturn <Tag { ...restProps }>{ content }</Tag>;\n\t}\n\n\treturn content;\n};\n"]}
|