@wordpress/lazy-editor 1.9.1-next.v.202604091042.0 → 1.10.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/preview/index.tsx", "../../../src/components/preview/style.scss"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useId, useMemo } from '@wordpress/element';\n// @ts-expect-error Block Editor not fully typed yet.\nimport { BlockPreview, BlockEditorProvider } from '@wordpress/block-editor';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,qBAA+B;AAE/B,0BAAkD;AAClD,oBAAiD;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useId, useMemo } from '@wordpress/element';\n// @ts-expect-error Block Editor not fully typed yet.\nimport { BlockPreview, BlockEditorProvider } from '@wordpress/block-editor';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { parse } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport './style.scss';\nimport { unlock } from '../../lock-unlock';\nimport { useEditorAssets } from '../../hooks/use-editor-assets';\nimport { useEditorSettings } from '../../hooks/use-editor-settings';\nimport { useStylesId } from '../../hooks/use-styles-id';\n\nconst { useStyle } = unlock( editorPrivateApis );\n\nfunction PreviewContent( {\n\tblocks,\n\tcontent,\n\tdescription,\n}: {\n\tblocks?: any[];\n\tcontent?: string;\n\tdescription: string;\n} ) {\n\tconst descriptionId = useId();\n\tconst backgroundColor = useStyle( 'color.background' );\n\tconst actualBlocks = useMemo( () => {\n\t\treturn (\n\t\t\tblocks ??\n\t\t\tparse( content!, {\n\t\t\t\t__unstableSkipMigrationLogs: true,\n\t\t\t} )\n\t\t);\n\t}, [ content, blocks ] );\n\tconst isEmpty = ! actualBlocks?.length;\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"lazy-editor-block-preview__container\"\n\t\t\tstyle={ { backgroundColor } }\n\t\t\taria-describedby={ !! description ? descriptionId : undefined }\n\t\t>\n\t\t\t{ isEmpty && __( 'Empty.' ) }\n\t\t\t{ ! isEmpty && (\n\t\t\t\t<BlockPreview.Async>\n\t\t\t\t\t<BlockPreview blocks={ actualBlocks } />\n\t\t\t\t</BlockPreview.Async>\n\t\t\t) }\n\t\t\t{ !! description && (\n\t\t\t\t<div hidden id={ descriptionId }>\n\t\t\t\t\t{ description }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport function Preview( {\n\tblocks,\n\tcontent,\n\tdescription,\n}: {\n\tblocks?: any[];\n\tcontent?: string;\n\tdescription: string;\n} ) {\n\t// Resolve styles ID from template\n\tconst stylesId = useStylesId();\n\n\t// Load editor settings and assets\n\tconst { isReady: settingsReady, editorSettings } = useEditorSettings( {\n\t\tstylesId,\n\t} );\n\tconst { isReady: assetsReady } = useEditorAssets();\n\tconst finalSettings = useMemo(\n\t\t() => ( {\n\t\t\t...editorSettings,\n\t\t\tisPreviewMode: true,\n\t\t} ),\n\t\t[ editorSettings ]\n\t);\n\tif ( ! settingsReady || ! assetsReady ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<BlockEditorProvider settings={ finalSettings }>\n\t\t\t<PreviewContent\n\t\t\t\tblocks={ blocks }\n\t\t\t\tcontent={ content }\n\t\t\t\tdescription={ description }\n\t\t\t/>\n\t\t</BlockEditorProvider>\n\t);\n}\n", "if (typeof document !== 'undefined' && process.env.NODE_ENV !== 'test' && !document.head.querySelector(\"style[data-wp-hash='95327475c1']\")) {\n\tconst style = document.createElement(\"style\");\n\tstyle.setAttribute(\"data-wp-hash\", \"95327475c1\");\n\tstyle.appendChild(document.createTextNode(\".lazy-editor-block-preview__container{align-items:center;border-radius:4px;display:flex;flex-direction:column;height:100%;justify-content:center}.dataviews-view-grid .lazy-editor-block-preview__container .block-editor-block-preview__container{height:100%}.dataviews-view-table .lazy-editor-block-preview__container{text-wrap:balance;text-wrap:pretty;flex-grow:0;width:96px}\"));\n\tdocument.head.appendChild(style);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,qBAA+B;AAE/B,0BAAkD;AAClD,oBAAiD;AACjD,oBAAsB;;;ACRtB,IAAI,OAAO,aAAa,eAAe,QAAQ,IAAI,aAAa,UAAU,CAAC,SAAS,KAAK,cAAc,kCAAkC,GAAG;AAC3I,QAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,QAAM,aAAa,gBAAgB,YAAY;AAC/C,QAAM,YAAY,SAAS,eAAe,uXAAuX,CAAC;AACla,WAAS,KAAK,YAAY,KAAK;AAChC;;;ADSA,yBAAuB;AACvB,+BAAgC;AAChC,iCAAkC;AAClC,2BAA4B;AA0B1B;AAxBF,IAAM,EAAE,SAAS,QAAI,2BAAQ,cAAAA,WAAkB;AAE/C,SAAS,eAAgB;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AACD,GAII;AACH,QAAM,oBAAgB,sBAAM;AAC5B,QAAM,kBAAkB,SAAU,kBAAmB;AACrD,QAAM,mBAAe,wBAAS,MAAM;AACnC,WACC,cACA,qBAAO,SAAU;AAAA,MAChB,6BAA6B;AAAA,IAC9B,CAAE;AAAA,EAEJ,GAAG,CAAE,SAAS,MAAO,CAAE;AACvB,QAAM,UAAU,CAAE,cAAc;AAEhC,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,OAAQ,EAAE,gBAAgB;AAAA,MAC1B,oBAAmB,CAAC,CAAE,cAAc,gBAAgB;AAAA,MAElD;AAAA,uBAAW,gBAAI,QAAS;AAAA,QACxB,CAAE,WACH,4CAAC,iCAAa,OAAb,EACA,sDAAC,oCAAa,QAAS,cAAe,GACvC;AAAA,QAEC,CAAC,CAAE,eACJ,4CAAC,SAAI,QAAM,MAAC,IAAK,eACd,uBACH;AAAA;AAAA;AAAA,EAEF;AAEF;AAEO,SAAS,QAAS;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AACD,GAII;AAEH,QAAM,eAAW,kCAAY;AAG7B,QAAM,EAAE,SAAS,eAAe,eAAe,QAAI,8CAAmB;AAAA,IACrE;AAAA,EACD,CAAE;AACF,QAAM,EAAE,SAAS,YAAY,QAAI,0CAAgB;AACjD,QAAM,oBAAgB;AAAA,IACrB,OAAQ;AAAA,MACP,GAAG;AAAA,MACH,eAAe;AAAA,IAChB;AAAA,IACA,CAAE,cAAe;AAAA,EAClB;AACA,MAAK,CAAE,iBAAiB,CAAE,aAAc;AACvC,WAAO;AAAA,EACR;AACA,SACC,4CAAC,2CAAoB,UAAW,eAC/B;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACD,GACD;AAEF;",
|
|
6
6
|
"names": ["editorPrivateApis"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/preview/index.tsx", "../../../src/components/preview/style.scss"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useId, useMemo } from '@wordpress/element';\n// @ts-expect-error Block Editor not fully typed yet.\nimport { BlockPreview, BlockEditorProvider } from '@wordpress/block-editor';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,OAAO,eAAe;AAE/B,SAAS,cAAc,2BAA2B;AAClD,SAAS,eAAe,yBAAyB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useId, useMemo } from '@wordpress/element';\n// @ts-expect-error Block Editor not fully typed yet.\nimport { BlockPreview, BlockEditorProvider } from '@wordpress/block-editor';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { parse } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport './style.scss';\nimport { unlock } from '../../lock-unlock';\nimport { useEditorAssets } from '../../hooks/use-editor-assets';\nimport { useEditorSettings } from '../../hooks/use-editor-settings';\nimport { useStylesId } from '../../hooks/use-styles-id';\n\nconst { useStyle } = unlock( editorPrivateApis );\n\nfunction PreviewContent( {\n\tblocks,\n\tcontent,\n\tdescription,\n}: {\n\tblocks?: any[];\n\tcontent?: string;\n\tdescription: string;\n} ) {\n\tconst descriptionId = useId();\n\tconst backgroundColor = useStyle( 'color.background' );\n\tconst actualBlocks = useMemo( () => {\n\t\treturn (\n\t\t\tblocks ??\n\t\t\tparse( content!, {\n\t\t\t\t__unstableSkipMigrationLogs: true,\n\t\t\t} )\n\t\t);\n\t}, [ content, blocks ] );\n\tconst isEmpty = ! actualBlocks?.length;\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"lazy-editor-block-preview__container\"\n\t\t\tstyle={ { backgroundColor } }\n\t\t\taria-describedby={ !! description ? descriptionId : undefined }\n\t\t>\n\t\t\t{ isEmpty && __( 'Empty.' ) }\n\t\t\t{ ! isEmpty && (\n\t\t\t\t<BlockPreview.Async>\n\t\t\t\t\t<BlockPreview blocks={ actualBlocks } />\n\t\t\t\t</BlockPreview.Async>\n\t\t\t) }\n\t\t\t{ !! description && (\n\t\t\t\t<div hidden id={ descriptionId }>\n\t\t\t\t\t{ description }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport function Preview( {\n\tblocks,\n\tcontent,\n\tdescription,\n}: {\n\tblocks?: any[];\n\tcontent?: string;\n\tdescription: string;\n} ) {\n\t// Resolve styles ID from template\n\tconst stylesId = useStylesId();\n\n\t// Load editor settings and assets\n\tconst { isReady: settingsReady, editorSettings } = useEditorSettings( {\n\t\tstylesId,\n\t} );\n\tconst { isReady: assetsReady } = useEditorAssets();\n\tconst finalSettings = useMemo(\n\t\t() => ( {\n\t\t\t...editorSettings,\n\t\t\tisPreviewMode: true,\n\t\t} ),\n\t\t[ editorSettings ]\n\t);\n\tif ( ! settingsReady || ! assetsReady ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<BlockEditorProvider settings={ finalSettings }>\n\t\t\t<PreviewContent\n\t\t\t\tblocks={ blocks }\n\t\t\t\tcontent={ content }\n\t\t\t\tdescription={ description }\n\t\t\t/>\n\t\t</BlockEditorProvider>\n\t);\n}\n", "if (typeof document !== 'undefined' && process.env.NODE_ENV !== 'test' && !document.head.querySelector(\"style[data-wp-hash='95327475c1']\")) {\n\tconst style = document.createElement(\"style\");\n\tstyle.setAttribute(\"data-wp-hash\", \"95327475c1\");\n\tstyle.appendChild(document.createTextNode(\".lazy-editor-block-preview__container{align-items:center;border-radius:4px;display:flex;flex-direction:column;height:100%;justify-content:center}.dataviews-view-grid .lazy-editor-block-preview__container .block-editor-block-preview__container{height:100%}.dataviews-view-table .lazy-editor-block-preview__container{text-wrap:balance;text-wrap:pretty;flex-grow:0;width:96px}\"));\n\tdocument.head.appendChild(style);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,OAAO,eAAe;AAE/B,SAAS,cAAc,2BAA2B;AAClD,SAAS,eAAe,yBAAyB;AACjD,SAAS,aAAa;;;ACRtB,IAAI,OAAO,aAAa,eAAe,QAAQ,IAAI,aAAa,UAAU,CAAC,SAAS,KAAK,cAAc,kCAAkC,GAAG;AAC3I,QAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,QAAM,aAAa,gBAAgB,YAAY;AAC/C,QAAM,YAAY,SAAS,eAAe,uXAAuX,CAAC;AACla,WAAS,KAAK,YAAY,KAAK;AAChC;;;ADSA,SAAS,cAAc;AACvB,SAAS,uBAAuB;AAChC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AA,EACD,GACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/preview/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/preview/index.tsx"],"names":[],"mappings":"AAUA;;GAEG;AACH,OAAO,cAAc,CAAC;AAkDtB,wBAAgB,OAAO,CAAE,EACxB,MAAM,EACN,OAAO,EACP,WAAW,GACX,EAAE;IACF,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACpB,sCA4BA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/lazy-editor",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "Lazy-loading editor component with automatic asset and settings management.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -45,21 +45,21 @@
|
|
|
45
45
|
"wpScriptModuleExports": "./build-module/index.mjs",
|
|
46
46
|
"types": "build-types",
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@wordpress/asset-loader": "^1.
|
|
49
|
-
"@wordpress/base-styles": "^6.
|
|
50
|
-
"@wordpress/block-editor": "^15.
|
|
51
|
-
"@wordpress/blocks": "^15.
|
|
52
|
-
"@wordpress/components": "^32.
|
|
53
|
-
"@wordpress/core-data": "^7.
|
|
54
|
-
"@wordpress/data": "^10.
|
|
55
|
-
"@wordpress/editor": "^14.
|
|
56
|
-
"@wordpress/element": "^6.44.
|
|
57
|
-
"@wordpress/global-styles-engine": "^1.
|
|
58
|
-
"@wordpress/i18n": "^6.17.
|
|
59
|
-
"@wordpress/private-apis": "^1.
|
|
48
|
+
"@wordpress/asset-loader": "^1.10.0",
|
|
49
|
+
"@wordpress/base-styles": "^6.20.0",
|
|
50
|
+
"@wordpress/block-editor": "^15.17.0",
|
|
51
|
+
"@wordpress/blocks": "^15.17.0",
|
|
52
|
+
"@wordpress/components": "^32.6.0",
|
|
53
|
+
"@wordpress/core-data": "^7.44.0",
|
|
54
|
+
"@wordpress/data": "^10.44.0",
|
|
55
|
+
"@wordpress/editor": "^14.44.0",
|
|
56
|
+
"@wordpress/element": "^6.44.0",
|
|
57
|
+
"@wordpress/global-styles-engine": "^1.11.0",
|
|
58
|
+
"@wordpress/i18n": "^6.17.0",
|
|
59
|
+
"@wordpress/private-apis": "^1.44.0"
|
|
60
60
|
},
|
|
61
61
|
"publishConfig": {
|
|
62
62
|
"access": "public"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "b862d8c84121a47bbeff882f6c87e61681ce2e0d"
|
|
65
65
|
}
|
|
@@ -6,7 +6,6 @@ import { useId, useMemo } from '@wordpress/element';
|
|
|
6
6
|
// @ts-expect-error Block Editor not fully typed yet.
|
|
7
7
|
import { BlockPreview, BlockEditorProvider } from '@wordpress/block-editor';
|
|
8
8
|
import { privateApis as editorPrivateApis } from '@wordpress/editor';
|
|
9
|
-
// @ts-expect-error Blocks not fully typed yet.
|
|
10
9
|
import { parse } from '@wordpress/blocks';
|
|
11
10
|
|
|
12
11
|
/**
|
|
@@ -34,7 +33,7 @@ function PreviewContent( {
|
|
|
34
33
|
const actualBlocks = useMemo( () => {
|
|
35
34
|
return (
|
|
36
35
|
blocks ??
|
|
37
|
-
parse( content
|
|
36
|
+
parse( content!, {
|
|
38
37
|
__unstableSkipMigrationLogs: true,
|
|
39
38
|
} )
|
|
40
39
|
);
|