fix: prevent asset conflicts between React and Grid.js versions

Add coexistence checks to all enqueue methods to prevent loading
both React and Grid.js assets simultaneously.

Changes:
- ReactAdmin.php: Only enqueue React assets when ?react=1
- Init.php: Skip Grid.js when React active on admin pages
- Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0
- Customer.php, Product.php, License.php: Add coexistence checks

Now the toggle between Classic and React versions works correctly.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
dwindown
2026-04-18 17:02:14 +07:00
parent bd9cdac02e
commit e8fbfb14c1
74973 changed files with 6658406 additions and 71 deletions

View File

@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.clickBlockOptionsMenuItem = void 0;
/**
* Clicks a block toolbar button.
*
* @param this
* @param label The text string of the button label.
*/
async function clickBlockOptionsMenuItem(label) {
await this.clickBlockToolbarButton('Options');
await this.page
.getByRole('menu', { name: 'Options' })
.getByRole('menuitem', { name: label })
.click();
}
exports.clickBlockOptionsMenuItem = clickBlockOptionsMenuItem;
//# sourceMappingURL=click-block-options-menu-item.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"click-block-options-menu-item.js","sourceRoot":"","sources":["../../src/editor/click-block-options-menu-item.ts"],"names":[],"mappings":";;;AAKA;;;;;GAKG;AACI,KAAK,UAAU,yBAAyB,CAAgB,KAAa;IAC3E,MAAM,IAAI,CAAC,uBAAuB,CAAE,SAAS,CAAE,CAAC;IAChD,MAAM,IAAI,CAAC,IAAI;SACb,SAAS,CAAE,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAE;SACxC,SAAS,CAAE,UAAU,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAE;SACxC,KAAK,EAAE,CAAC;AACX,CAAC;AAND,8DAMC"}

View File

@@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.clickBlockToolbarButton = void 0;
/**
* Clicks a block toolbar button.
*
* @param this
* @param label The text string of the button label.
*/
async function clickBlockToolbarButton(label) {
await this.showBlockToolbar();
const blockToolbar = this.page.locator('role=toolbar[name="Block tools"i]');
const button = blockToolbar.locator(`role=button[name="${label}"]`);
await button.click();
}
exports.clickBlockToolbarButton = clickBlockToolbarButton;
//# sourceMappingURL=click-block-toolbar-button.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"click-block-toolbar-button.js","sourceRoot":"","sources":["../../src/editor/click-block-toolbar-button.ts"],"names":[],"mappings":";;;AAKA;;;;;GAKG;AACI,KAAK,UAAU,uBAAuB,CAAgB,KAAa;IACzE,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAE9B,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CACrC,mCAAmC,CACnC,CAAC;IACF,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAE,qBAAsB,KAAM,IAAI,CAAE,CAAC;IAExE,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;AACtB,CAAC;AATD,0DASC"}

View File

@@ -0,0 +1,47 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getBlocks = void 0;
/**
* Returns the edited blocks.
*
* @param this
* @param options
* @param options.clientId Limit the results to be only under a partial tree of the specified clientId.
* @param options.full Whether to return the full block data or just the name and attributes.
*
* @return The blocks.
*/
async function getBlocks({ clientId, full = false } = {}) {
await this.page.waitForFunction(() => window?.wp?.blocks && window?.wp?.data);
return await this.page.evaluate(([_full, _clientId]) => {
// Serialize serializable attributes of blocks.
function serializeAttributes(attributes) {
return Object.fromEntries(Object.entries(attributes).map(([key, value]) => {
// Serialize RichTextData to string.
if (value instanceof window.wp.richText.RichTextData) {
return [key, value.toString()];
}
return [key, value];
}));
}
// Remove other unpredictable properties like clientId from blocks for testing purposes.
function recursivelyTransformBlocks(blocks) {
return blocks.map((block) => ({
name: block.name,
attributes: serializeAttributes(block.attributes),
innerBlocks: recursivelyTransformBlocks(block.innerBlocks),
}));
}
const blocks = window.wp.data
.select('core/block-editor')
.getBlocks(_clientId);
// The editor might still contain an unmodified empty block even when it's technically "empty".
if (blocks.length === 1 &&
window.wp.blocks.isUnmodifiedDefaultBlock(blocks[0])) {
return [];
}
return _full ? blocks : recursivelyTransformBlocks(blocks);
}, [full, clientId]);
}
exports.getBlocks = getBlocks;
//# sourceMappingURL=get-blocks.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-blocks.js","sourceRoot":"","sources":["../../src/editor/get-blocks.ts"],"names":[],"mappings":";;;AAWA;;;;;;;;;GASG;AACI,KAAK,UAAU,SAAS,CAE9B,EAAE,QAAQ,EAAE,IAAI,GAAG,KAAK,KAA4C,EAAE;IAEtE,MAAM,IAAI,CAAC,IAAI,CAAC,eAAe,CAC9B,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,EAAE,MAAM,IAAI,MAAM,EAAE,EAAE,EAAE,IAAI,CAC5C,CAAC;IAEF,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAC9B,CAAE,CAAE,KAAK,EAAE,SAAS,CAAE,EAAG,EAAE;QAC1B,+CAA+C;QAC/C,SAAS,mBAAmB,CAC3B,UAAqC;YAErC,OAAO,MAAM,CAAC,WAAW,CACxB,MAAM,CAAC,OAAO,CAAE,UAAU,CAAE,CAAC,GAAG,CAAE,CAAE,CAAE,GAAG,EAAE,KAAK,CAAE,EAAG,EAAE;gBACtD,oCAAoC;gBACpC,IACC,KAAK,YAAY,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,YAAY,EAC/C,CAAC;oBACF,OAAO,CAAE,GAAG,EAAI,KAAiB,CAAC,QAAQ,EAAE,CAAE,CAAC;gBAChD,CAAC;gBACD,OAAO,CAAE,GAAG,EAAE,KAAK,CAAE,CAAC;YACvB,CAAC,CAAE,CACH,CAAC;QACH,CAAC;QAED,wFAAwF;QACxF,SAAS,0BAA0B,CAAE,MAAe;YACnD,OAAO,MAAM,CAAC,GAAG,CAAE,CAAE,KAAK,EAAG,EAAE,CAAC,CAAE;gBACjC,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,UAAU,EAAE,mBAAmB,CAAE,KAAK,CAAC,UAAU,CAAE;gBACnD,WAAW,EAAE,0BAA0B,CACtC,KAAK,CAAC,WAAW,CACjB;aACD,CAAE,CAAE,CAAC;QACP,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,IAAI;aAC3B,MAAM,CAAE,mBAAmB,CAAE;aAC7B,SAAS,CAAE,SAAS,CAAa,CAAC;QAEpC,+FAA+F;QAC/F,IACC,MAAM,CAAC,MAAM,KAAK,CAAC;YACnB,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,wBAAwB,CAAE,MAAM,CAAE,CAAC,CAAE,CAAE,EACvD,CAAC;YACF,OAAO,EAAE,CAAC;QACX,CAAC;QAED,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,0BAA0B,CAAE,MAAM,CAAE,CAAC;IAC9D,CAAC,EACD,CAAE,IAAI,EAAE,QAAQ,CAAE,CAClB,CAAC;AACH,CAAC;AAtDD,8BAsDC"}

View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEditedPostContent = void 0;
/**
* Returns a promise which resolves with the edited post content (HTML string).
*
* @param this
*
* @return Promise resolving with post content markup.
*/
async function getEditedPostContent() {
await this.page.waitForFunction(() => window?.wp?.data);
return await this.page.evaluate(() => window.wp.data.select('core/editor').getEditedPostContent());
}
exports.getEditedPostContent = getEditedPostContent;
//# sourceMappingURL=get-edited-post-content.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-edited-post-content.js","sourceRoot":"","sources":["../../src/editor/get-edited-post-content.ts"],"names":[],"mappings":";;;AAKA;;;;;;GAMG;AACI,KAAK,UAAU,oBAAoB;IACzC,MAAM,IAAI,CAAC,IAAI,CAAC,eAAe,CAAE,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,CAAE,CAAC;IAE1D,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAE,GAAG,EAAE,CACrC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAE,aAAa,CAAE,CAAC,oBAAoB,EAAE,CAC7D,CAAC;AACH,CAAC;AAND,oDAMC"}

View File

@@ -0,0 +1,72 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Editor = void 0;
/**
* Internal dependencies
*/
const click_block_options_menu_item_1 = require("./click-block-options-menu-item");
const click_block_toolbar_button_1 = require("./click-block-toolbar-button");
const get_blocks_1 = require("./get-blocks");
const get_edited_post_content_1 = require("./get-edited-post-content");
const insert_block_1 = require("./insert-block");
const open_document_settings_sidebar_1 = require("./open-document-settings-sidebar");
const preview_1 = require("./preview");
const publish_post_1 = require("./publish-post");
const save_draft_1 = require("./save-draft");
const select_blocks_1 = require("./select-blocks");
const set_content_1 = require("./set-content");
const set_preferences_1 = require("./set-preferences");
const show_block_toolbar_1 = require("./show-block-toolbar");
const site_editor_1 = require("./site-editor");
const set_is_fixed_toolbar_1 = require("./set-is-fixed-toolbar");
const switch_to_legacy_canvas_1 = require("./switch-to-legacy-canvas");
const transform_block_to_1 = require("./transform-block-to");
class Editor {
browser;
page;
context;
constructor({ page }) {
this.page = page;
this.context = page.context();
this.browser = this.context.browser();
}
get canvas() {
return this.page.frameLocator('[name="editor-canvas"]');
}
/** @borrows clickBlockOptionsMenuItem as this.clickBlockOptionsMenuItem */
clickBlockOptionsMenuItem = click_block_options_menu_item_1.clickBlockOptionsMenuItem.bind(this);
/** @borrows clickBlockToolbarButton as this.clickBlockToolbarButton */
clickBlockToolbarButton = click_block_toolbar_button_1.clickBlockToolbarButton.bind(this);
/** @borrows getBlocks as this.getBlocks */
getBlocks = get_blocks_1.getBlocks.bind(this);
/** @borrows getEditedPostContent as this.getEditedPostContent */
getEditedPostContent = get_edited_post_content_1.getEditedPostContent.bind(this);
/** @borrows insertBlock as this.insertBlock */
insertBlock = insert_block_1.insertBlock.bind(this);
/** @borrows openDocumentSettingsSidebar as this.openDocumentSettingsSidebar */
openDocumentSettingsSidebar = open_document_settings_sidebar_1.openDocumentSettingsSidebar.bind(this);
/** @borrows openPreviewPage as this.openPreviewPage */
openPreviewPage = preview_1.openPreviewPage.bind(this);
/** @borrows publishPost as this.publishPost */
publishPost = publish_post_1.publishPost.bind(this);
/** @borrows saveDraft as this.saveDraft */
saveDraft = save_draft_1.saveDraft.bind(this);
/** @borrows saveSiteEditorEntities as this.saveSiteEditorEntities */
saveSiteEditorEntities = site_editor_1.saveSiteEditorEntities.bind(this);
/** @borrows selectBlocks as this.selectBlocks */
selectBlocks = select_blocks_1.selectBlocks.bind(this);
/** @borrows setContent as this.setContent */
setContent = set_content_1.setContent.bind(this);
/** @borrows setPreferences as this.setPreferences */
setPreferences = set_preferences_1.setPreferences.bind(this);
/** @borrows showBlockToolbar as this.showBlockToolbar */
showBlockToolbar = show_block_toolbar_1.showBlockToolbar.bind(this);
/** @borrows setIsFixedToolbar as this.setIsFixedToolbar */
setIsFixedToolbar = set_is_fixed_toolbar_1.setIsFixedToolbar.bind(this);
/** @borrows switchToLegacyCanvas as this.switchToLegacyCanvas */
switchToLegacyCanvas = switch_to_legacy_canvas_1.switchToLegacyCanvas.bind(this);
/** @borrows transformBlockTo as this.transformBlockTo */
transformBlockTo = transform_block_to_1.transformBlockTo.bind(this);
}
exports.Editor = Editor;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/editor/index.ts"],"names":[],"mappings":";;;AAUA;;GAEG;AACH,mFAA4E;AAC5E,6EAAuE;AACvE,6CAAyC;AACzC,uEAAiE;AACjE,iDAA6C;AAC7C,qFAA+E;AAC/E,uCAA4C;AAC5C,iDAA6C;AAC7C,6CAAyC;AACzC,mDAA+C;AAC/C,+CAA2C;AAC3C,uDAAmD;AACnD,6DAAwD;AACxD,+CAAuD;AACvD,iEAA2D;AAC3D,uEAAiE;AACjE,6DAAwD;AAMxD,MAAa,MAAM;IAClB,OAAO,CAAU;IACjB,IAAI,CAAO;IACX,OAAO,CAAiB;IAExB,YAAa,EAAE,IAAI,EAA0B;QAC5C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAG,CAAC;IACxC,CAAC;IAED,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,CAAE,wBAAwB,CAAE,CAAC;IAC3D,CAAC;IAED,2EAA2E;IAC3E,yBAAyB,GACxB,yDAAyB,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IACxC,uEAAuE;IACvE,uBAAuB,GACtB,oDAAuB,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IACtC,2CAA2C;IAC3C,SAAS,GAAqB,sBAAS,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IACrD,iEAAiE;IACjE,oBAAoB,GACnB,8CAAoB,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IACnC,+CAA+C;IAC/C,WAAW,GAAuB,0BAAW,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IAC3D,+EAA+E;IAC/E,2BAA2B,GAC1B,4DAA2B,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IAC1C,uDAAuD;IACvD,eAAe,GAA2B,yBAAe,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IACvE,+CAA+C;IAC/C,WAAW,GAAuB,0BAAW,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IAC3D,2CAA2C;IAC3C,SAAS,GAAqB,sBAAS,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IACrD,qEAAqE;IACrE,sBAAsB,GACrB,oCAAsB,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IACrC,iDAAiD;IACjD,YAAY,GAAwB,4BAAY,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IAC9D,6CAA6C;IAC7C,UAAU,GAAsB,wBAAU,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IACxD,qDAAqD;IACrD,cAAc,GAA0B,gCAAc,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IACpE,yDAAyD;IACzD,gBAAgB,GAA4B,qCAAgB,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IAC1E,2DAA2D;IAC3D,iBAAiB,GAChB,wCAAiB,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IAChC,iEAAiE;IACjE,oBAAoB,GACnB,8CAAoB,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IACnC,yDAAyD;IACzD,gBAAgB,GAA4B,qCAAgB,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;CAC1E;AAxDD,wBAwDC"}

View File

@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.insertBlock = void 0;
/**
* Insert a block.
*
* @param this
* @param blockRepresentation Inserted block representation.
* @param options
* @param options.clientId Client ID of the parent block to insert into.
*/
async function insertBlock(blockRepresentation, { clientId } = {}) {
await this.page.waitForFunction(() => window?.wp?.blocks && window?.wp?.data);
await this.page.evaluate(([_blockRepresentation, _clientId]) => {
function recursiveCreateBlock({ name, attributes = {}, innerBlocks = [], }) {
return window.wp.blocks.createBlock(name, attributes, innerBlocks.map((innerBlock) => recursiveCreateBlock(innerBlock)));
}
const block = recursiveCreateBlock(_blockRepresentation);
window.wp.data
.dispatch('core/block-editor')
.insertBlock(block, undefined, _clientId);
}, [blockRepresentation, clientId]);
}
exports.insertBlock = insertBlock;
//# sourceMappingURL=insert-block.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"insert-block.js","sourceRoot":"","sources":["../../src/editor/insert-block.ts"],"names":[],"mappings":";;;AAWA;;;;;;;GAOG;AACH,KAAK,UAAU,WAAW,CAEzB,mBAAwC,EACxC,EAAE,QAAQ,KAA4B,EAAE;IAExC,MAAM,IAAI,CAAC,IAAI,CAAC,eAAe,CAC9B,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,EAAE,MAAM,IAAI,MAAM,EAAE,EAAE,EAAE,IAAI,CAC5C,CAAC;IAEF,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CACvB,CAAE,CAAE,oBAAoB,EAAE,SAAS,CAAE,EAAG,EAAE;QACzC,SAAS,oBAAoB,CAAE,EAC9B,IAAI,EACJ,UAAU,GAAG,EAAE,EACf,WAAW,GAAG,EAAE,GACK;YACrB,OAAO,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,WAAW,CAClC,IAAI,EACJ,UAAU,EACV,WAAW,CAAC,GAAG,CAAE,CAAE,UAAU,EAAG,EAAE,CACjC,oBAAoB,CAAE,UAAU,CAAE,CAClC,CACD,CAAC;QACH,CAAC;QACD,MAAM,KAAK,GAAG,oBAAoB,CAAE,oBAAoB,CAAE,CAAC;QAE3D,MAAM,CAAC,EAAE,CAAC,IAAI;aACZ,QAAQ,CAAE,mBAAmB,CAAE;aAC/B,WAAW,CAAE,KAAK,EAAE,SAAS,EAAE,SAAS,CAAE,CAAC;IAC9C,CAAC,EACD,CAAE,mBAAmB,EAAE,QAAQ,CAAW,CAC1C,CAAC;AACH,CAAC;AAGQ,kCAAW"}

View File

@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.openDocumentSettingsSidebar = void 0;
/**
* Clicks on the button in the header which opens Document Settings sidebar when
* it is closed.
*
* @param this
*/
async function openDocumentSettingsSidebar() {
const toggleButton = this.page
.getByRole('region', { name: 'Editor top bar' })
.getByRole('button', {
name: 'Settings',
disabled: false,
});
const isClosed = (await toggleButton.getAttribute('aria-expanded')) === 'false';
if (isClosed) {
await toggleButton.click();
await this.page
.getByRole('region', { name: 'Editor settings' })
.getByRole('button', { name: 'Close Settings' })
.waitFor();
}
}
exports.openDocumentSettingsSidebar = openDocumentSettingsSidebar;
//# sourceMappingURL=open-document-settings-sidebar.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"open-document-settings-sidebar.js","sourceRoot":"","sources":["../../src/editor/open-document-settings-sidebar.ts"],"names":[],"mappings":";;;AAKA;;;;;GAKG;AACI,KAAK,UAAU,2BAA2B;IAChD,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI;SAC5B,SAAS,CAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAE;SACjD,SAAS,CAAE,QAAQ,EAAE;QACrB,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE,KAAK;KACf,CAAE,CAAC;IAEL,MAAM,QAAQ,GACb,CAAE,MAAM,YAAY,CAAC,YAAY,CAAE,eAAe,CAAE,CAAE,KAAK,OAAO,CAAC;IAEpE,IAAK,QAAQ,EAAG,CAAC;QAChB,MAAM,YAAY,CAAC,KAAK,EAAE,CAAC;QAC3B,MAAM,IAAI,CAAC,IAAI;aACb,SAAS,CAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAE;aAClD,SAAS,CAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAE;aACjD,OAAO,EAAE,CAAC;IACb,CAAC;AACF,CAAC;AAlBD,kEAkBC"}

View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.openPreviewPage = void 0;
/**
* Opens the preview page of an edited post.
*
* @param this
*
* @return preview page.
*/
async function openPreviewPage() {
const editorTopBar = this.page.locator('role=region[name="Editor top bar"i]');
const previewButton = editorTopBar.locator('role=button[name="View"i]');
await previewButton.click();
const [previewPage] = await Promise.all([
this.context.waitForEvent('page'),
this.page.click('role=menuitem[name="Preview in new tab"i]'),
]);
return previewPage;
}
exports.openPreviewPage = openPreviewPage;
//# sourceMappingURL=preview.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"preview.js","sourceRoot":"","sources":["../../src/editor/preview.ts"],"names":[],"mappings":";;;AAUA;;;;;;GAMG;AACI,KAAK,UAAU,eAAe;IACpC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CACrC,qCAAqC,CACrC,CAAC;IACF,MAAM,aAAa,GAAG,YAAY,CAAC,OAAO,CAAE,2BAA2B,CAAE,CAAC;IAE1E,MAAM,aAAa,CAAC,KAAK,EAAE,CAAC;IAE5B,MAAM,CAAE,WAAW,CAAE,GAAG,MAAM,OAAO,CAAC,GAAG,CAAE;QAC1C,IAAI,CAAC,OAAO,CAAC,YAAY,CAAE,MAAM,CAAE;QACnC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAE,2CAA2C,CAAE;KAC9D,CAAE,CAAC;IAEJ,OAAO,WAAW,CAAC;AACpB,CAAC;AAdD,0CAcC"}

View File

@@ -0,0 +1,41 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.publishPost = void 0;
/**
* Publishes the post, resolving once the request is complete (once a notice
* is displayed).
*
* @param this
*/
async function publishPost() {
// If we have changes in other entities, the label is `Save` instead of `Publish`.
const saveButton = this.page
.getByRole('region', { name: 'Editor top bar' })
.getByRole('button', { name: 'Save', exact: true });
const publishButton = this.page
.getByRole('region', { name: 'Editor top bar' })
.getByRole('button', { name: 'Publish', exact: true });
const buttonToClick = (await saveButton.isVisible())
? saveButton
: publishButton;
await buttonToClick.click();
const entitiesSaveButton = this.page
.getByRole('region', { name: 'Editor publish' })
.getByRole('button', { name: 'Save', exact: true });
const isEntitiesSavePanelVisible = await entitiesSaveButton.isVisible();
// Save any entities.
if (isEntitiesSavePanelVisible) {
// Handle saving entities.
await entitiesSaveButton.click();
}
// Handle saving just the post.
await this.page.click('role=region[name="Editor publish"i] >> role=button[name="Publish"i]');
await this.page
.getByRole('button', { name: 'Dismiss this notice' })
.filter({ hasText: 'published' })
.waitFor();
const postId = new URL(this.page.url()).searchParams.get('post');
return typeof postId === 'string' ? parseInt(postId, 10) : null;
}
exports.publishPost = publishPost;
//# sourceMappingURL=publish-post.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"publish-post.js","sourceRoot":"","sources":["../../src/editor/publish-post.ts"],"names":[],"mappings":";;;AAKA;;;;;GAKG;AACI,KAAK,UAAU,WAAW;IAChC,kFAAkF;IAClF,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI;SAC1B,SAAS,CAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAE;SACjD,SAAS,CAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,CAAE,CAAC;IACvD,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI;SAC7B,SAAS,CAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAE;SACjD,SAAS,CAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,CAAE,CAAC;IAC1D,MAAM,aAAa,GAAG,CAAE,MAAM,UAAU,CAAC,SAAS,EAAE,CAAE;QACrD,CAAC,CAAC,UAAU;QACZ,CAAC,CAAC,aAAa,CAAC;IACjB,MAAM,aAAa,CAAC,KAAK,EAAE,CAAC;IAE5B,MAAM,kBAAkB,GAAG,IAAI,CAAC,IAAI;SAClC,SAAS,CAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAE;SACjD,SAAS,CAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,CAAE,CAAC;IACvD,MAAM,0BAA0B,GAAG,MAAM,kBAAkB,CAAC,SAAS,EAAE,CAAC;IAExE,qBAAqB;IACrB,IAAK,0BAA0B,EAAG,CAAC;QAClC,0BAA0B;QAC1B,MAAM,kBAAkB,CAAC,KAAK,EAAE,CAAC;IAClC,CAAC;IAED,+BAA+B;IAC/B,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CACpB,qEAAqE,CACrE,CAAC;IAEF,MAAM,IAAI,CAAC,IAAI;SACb,SAAS,CAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAE;SACtD,MAAM,CAAE,EAAE,OAAO,EAAE,WAAW,EAAE,CAAE;SAClC,OAAO,EAAE,CAAC;IACZ,MAAM,MAAM,GAAG,IAAI,GAAG,CAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAE,CAAC,YAAY,CAAC,GAAG,CAAE,MAAM,CAAE,CAAC;IAErE,OAAO,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAE,MAAM,EAAE,EAAE,CAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACnE,CAAC;AApCD,kCAoCC"}

View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.saveDraft = void 0;
/**
* Saves the post as a draft, resolving once the request is complete (once a notice
* is displayed).
*/
async function saveDraft() {
await this.page
.getByRole('region', { name: 'Editor top bar' })
.getByRole('button', { name: 'Save draft' })
.click();
await this.page
.getByRole('button', { name: 'Dismiss this notice' })
.filter({ hasText: 'Draft saved' })
.waitFor();
}
exports.saveDraft = saveDraft;
//# sourceMappingURL=save-draft.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"save-draft.js","sourceRoot":"","sources":["../../src/editor/save-draft.ts"],"names":[],"mappings":";;;AAKA;;;GAGG;AACI,KAAK,UAAU,SAAS;IAC9B,MAAM,IAAI,CAAC,IAAI;SACb,SAAS,CAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAE;SACjD,SAAS,CAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,CAAE;SAC7C,KAAK,EAAE,CAAC;IAEV,MAAM,IAAI,CAAC,IAAI;SACb,SAAS,CAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAE;SACtD,MAAM,CAAE,EAAE,OAAO,EAAE,aAAa,EAAE,CAAE;SACpC,OAAO,EAAE,CAAC;AACb,CAAC;AAVD,8BAUC"}

View File

@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.selectBlocks = void 0;
async function selectBlocks(startSelectorOrLocator, endSelectorOrLocator) {
const startBlock = typeof startSelectorOrLocator === 'string'
? this.canvas.locator(startSelectorOrLocator)
: startSelectorOrLocator;
const endBlock = typeof endSelectorOrLocator === 'string'
? this.canvas.locator(endSelectorOrLocator)
: endSelectorOrLocator;
const startClientId = await startBlock.getAttribute('data-block');
const endClientId = await endBlock?.getAttribute('data-block');
if (endClientId) {
await this.page.evaluate(([startId, endId]) => {
// @ts-ignore
wp.data
.dispatch('core/block-editor')
.multiSelect(startId, endId);
}, [startClientId, endClientId]);
}
else {
await this.page.evaluate(([clientId]) => {
// @ts-ignore
wp.data.dispatch('core/block-editor').selectBlock(clientId);
}, [startClientId]);
}
}
exports.selectBlocks = selectBlocks;
//# sourceMappingURL=select-blocks.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"select-blocks.js","sourceRoot":"","sources":["../../src/editor/select-blocks.ts"],"names":[],"mappings":";;;AAUO,KAAK,UAAU,YAAY,CAEjC,sBAAwC,EACxC,oBAAuC;IAEvC,MAAM,UAAU,GACf,OAAO,sBAAsB,KAAK,QAAQ;QACzC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAE,sBAAsB,CAAE;QAC/C,CAAC,CAAC,sBAAsB,CAAC;IAE3B,MAAM,QAAQ,GACb,OAAO,oBAAoB,KAAK,QAAQ;QACvC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAE,oBAAoB,CAAE;QAC7C,CAAC,CAAC,oBAAoB,CAAC;IAEzB,MAAM,aAAa,GAAG,MAAM,UAAU,CAAC,YAAY,CAAE,YAAY,CAAE,CAAC;IACpE,MAAM,WAAW,GAAG,MAAM,QAAQ,EAAE,YAAY,CAAE,YAAY,CAAE,CAAC;IAEjE,IAAK,WAAW,EAAG,CAAC;QACnB,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CACvB,CAAE,CAAE,OAAO,EAAE,KAAK,CAAE,EAAG,EAAE;YACxB,aAAa;YACb,EAAE,CAAC,IAAI;iBACL,QAAQ,CAAE,mBAAmB,CAAE;iBAC/B,WAAW,CAAE,OAAO,EAAE,KAAK,CAAE,CAAC;QACjC,CAAC,EACD,CAAE,aAAa,EAAE,WAAW,CAAE,CAC9B,CAAC;IACH,CAAC;SAAM,CAAC;QACP,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CACvB,CAAE,CAAE,QAAQ,CAAE,EAAG,EAAE;YAClB,aAAa;YACb,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAE,mBAAmB,CAAE,CAAC,WAAW,CAAE,QAAQ,CAAE,CAAC;QACjE,CAAC,EACD,CAAE,aAAa,CAAE,CACjB,CAAC;IACH,CAAC;AACF,CAAC;AArCD,oCAqCC"}

View File

@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setContent = void 0;
/**
* Set the content of the editor.
*
* @param this
* @param html Serialized block HTML.
*/
async function setContent(html) {
await this.page.waitForFunction(() => window?.wp?.blocks && window?.wp?.data);
await this.page.evaluate((_html) => {
const blocks = window.wp.blocks.parse(_html);
window.wp.data.dispatch('core/block-editor').resetBlocks(blocks);
}, html);
}
exports.setContent = setContent;
//# sourceMappingURL=set-content.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"set-content.js","sourceRoot":"","sources":["../../src/editor/set-content.ts"],"names":[],"mappings":";;;AAKA;;;;;GAKG;AACH,KAAK,UAAU,UAAU,CAAgB,IAAY;IACpD,MAAM,IAAI,CAAC,IAAI,CAAC,eAAe,CAC9B,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,EAAE,MAAM,IAAI,MAAM,EAAE,EAAE,EAAE,IAAI,CAC5C,CAAC;IAEF,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAE,CAAE,KAAK,EAAG,EAAE;QACrC,MAAM,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAE,KAAK,CAAE,CAAC;QAE/C,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAE,mBAAmB,CAAE,CAAC,WAAW,CAAE,MAAM,CAAE,CAAC;IACtE,CAAC,EAAE,IAAI,CAAE,CAAC;AACX,CAAC;AAEQ,gCAAU"}

View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setIsFixedToolbar = void 0;
/**
* Toggles the fixed toolbar option.
*
* @param this
* @param isFixed Boolean value true/false for on/off.
*/
async function setIsFixedToolbar(isFixed) {
await this.page.waitForFunction(() => window?.wp?.data);
await this.page.evaluate((_isFixed) => {
window.wp.data
.dispatch('core/preferences')
.set('core', 'fixedToolbar', _isFixed);
}, isFixed);
}
exports.setIsFixedToolbar = setIsFixedToolbar;
//# sourceMappingURL=set-is-fixed-toolbar.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"set-is-fixed-toolbar.js","sourceRoot":"","sources":["../../src/editor/set-is-fixed-toolbar.ts"],"names":[],"mappings":";;;AAKA;;;;;GAKG;AACI,KAAK,UAAU,iBAAiB,CAAgB,OAAgB;IACtE,MAAM,IAAI,CAAC,IAAI,CAAC,eAAe,CAAE,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,CAAE,CAAC;IAE1D,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAE,CAAE,QAAQ,EAAG,EAAE;QACxC,MAAM,CAAC,EAAE,CAAC,IAAI;aACZ,QAAQ,CAAE,kBAAkB,CAAE;aAC9B,GAAG,CAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,CAAE,CAAC;IAC3C,CAAC,EAAE,OAAO,CAAE,CAAC;AACd,CAAC;AARD,8CAQC"}

View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setPreferences = void 0;
/**
* Set the preferences of the editor.
*
* @param this
* @param context Context to set preferences for.
* @param preferences Preferences to set.
*/
async function setPreferences(context, preferences) {
await this.page.waitForFunction(() => window?.wp?.data);
await this.page.evaluate(async (props) => {
for (const [key, value] of Object.entries(props.preferences)) {
await window.wp.data
.dispatch('core/preferences')
.set(props.context, key, value);
}
}, { context, preferences });
}
exports.setPreferences = setPreferences;
//# sourceMappingURL=set-preferences.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"set-preferences.js","sourceRoot":"","sources":["../../src/editor/set-preferences.ts"],"names":[],"mappings":";;;AAUA;;;;;;GAMG;AACI,KAAK,UAAU,cAAc,CAEnC,OAA2B,EAC3B,WAAkC;IAElC,MAAM,IAAI,CAAC,IAAI,CAAC,eAAe,CAAE,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,CAAE,CAAC;IAE1D,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CACvB,KAAK,EAAG,KAAK,EAAG,EAAE;QACjB,KAAM,MAAM,CAAE,GAAG,EAAE,KAAK,CAAE,IAAI,MAAM,CAAC,OAAO,CAC3C,KAAK,CAAC,WAAW,CACjB,EAAG,CAAC;YACJ,MAAM,MAAM,CAAC,EAAE,CAAC,IAAI;iBAClB,QAAQ,CAAE,kBAAkB,CAAE;iBAC9B,GAAG,CAAE,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAE,CAAC;QACpC,CAAC;IACF,CAAC,EACD,EAAE,OAAO,EAAE,WAAW,EAAE,CACxB,CAAC;AACH,CAAC;AAnBD,wCAmBC"}

View File

@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.showBlockToolbar = void 0;
/**
* The block toolbar is not always visible while typing.
* Call this function to reveal it.
*
* @param this
*/
async function showBlockToolbar() {
// Move the mouse to disable the isTyping mode. We need at least three
// mousemove events for it to work across windows (iframe). With three
// moves, it's a guarantee that at least two will be in the same window.
// Two events are required for the flag to be unset.
await this.page.mouse.move(50, 50);
await this.page.mouse.move(75, 75);
await this.page.mouse.move(100, 100);
}
exports.showBlockToolbar = showBlockToolbar;
//# sourceMappingURL=show-block-toolbar.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"show-block-toolbar.js","sourceRoot":"","sources":["../../src/editor/show-block-toolbar.ts"],"names":[],"mappings":";;;AAKA;;;;;GAKG;AACI,KAAK,UAAU,gBAAgB;IACrC,sEAAsE;IACtE,sEAAsE;IACtE,wEAAwE;IACxE,oDAAoD;IACpD,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAE,EAAE,EAAE,EAAE,CAAE,CAAC;IACrC,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAE,EAAE,EAAE,EAAE,CAAE,CAAC;IACrC,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAE,GAAG,EAAE,GAAG,CAAE,CAAC;AACxC,CAAC;AARD,4CAQC"}

View File

@@ -0,0 +1,44 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.saveSiteEditorEntities = void 0;
/**
* Save entities in the site editor. Assumes the editor is in a dirty state.
*
* @param this
* @param options
*/
async function saveSiteEditorEntities(options = {}) {
const editorTopBar = this.page.getByRole('region', {
name: 'Editor top bar',
});
// If we have changes in a single entity which can be published the label is `Publish`.
const saveButton = editorTopBar.getByRole('button', {
name: 'Save',
exact: true,
});
const publishButton = editorTopBar.getByRole('button', {
name: 'Publish',
});
const publishButtonIsVisible = !(await saveButton.isVisible());
// First Save button in the top bar.
const buttonToClick = publishButtonIsVisible ? publishButton : saveButton;
await buttonToClick.click();
if (!options.isOnlyCurrentEntityDirty) {
// Second Save button in the entities panel.
await this.page
.getByRole('region', {
name: /(Editor publish|Save panel)/,
})
.getByRole('button', { name: 'Save', exact: true })
.click();
}
// The text in the notice can be different based on the edited entity, whether
// we are saving multiple entities and whether we publish or update. So for now,
// we locate it based on the last part.
await this.page
.getByRole('button', { name: 'Dismiss this notice' })
.getByText(/(updated|published)\./)
.waitFor();
}
exports.saveSiteEditorEntities = saveSiteEditorEntities;
//# sourceMappingURL=site-editor.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"site-editor.js","sourceRoot":"","sources":["../../src/editor/site-editor.ts"],"names":[],"mappings":";;;AAUA;;;;;GAKG;AACI,KAAK,UAAU,sBAAsB,CAE3C,UAAmB,EAAE;IAErB,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAE,QAAQ,EAAE;QACnD,IAAI,EAAE,gBAAgB;KACtB,CAAE,CAAC;IAEJ,uFAAuF;IACvF,MAAM,UAAU,GAAG,YAAY,CAAC,SAAS,CAAE,QAAQ,EAAE;QACpD,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,IAAI;KACX,CAAE,CAAC;IACJ,MAAM,aAAa,GAAG,YAAY,CAAC,SAAS,CAAE,QAAQ,EAAE;QACvD,IAAI,EAAE,SAAS;KACf,CAAE,CAAC;IACJ,MAAM,sBAAsB,GAAG,CAAE,CAAE,MAAM,UAAU,CAAC,SAAS,EAAE,CAAE,CAAC;IAClE,oCAAoC;IACpC,MAAM,aAAa,GAAG,sBAAsB,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,UAAU,CAAC;IAC1E,MAAM,aAAa,CAAC,KAAK,EAAE,CAAC;IAE5B,IAAK,CAAE,OAAO,CAAC,wBAAwB,EAAG,CAAC;QAC1C,4CAA4C;QAC5C,MAAM,IAAI,CAAC,IAAI;aACb,SAAS,CAAE,QAAQ,EAAE;YACrB,IAAI,EAAE,6BAA6B;SACnC,CAAE;aACF,SAAS,CAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,CAAE;aACpD,KAAK,EAAE,CAAC;IACX,CAAC;IACD,8EAA8E;IAC9E,gFAAgF;IAChF,uCAAuC;IACvC,MAAM,IAAI,CAAC,IAAI;SACb,SAAS,CAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAE;SACtD,SAAS,CAAE,uBAAuB,CAAE;SACpC,OAAO,EAAE,CAAC;AACb,CAAC;AArCD,wDAqCC"}

View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.switchToLegacyCanvas = void 0;
/**
* Switches to legacy (non-iframed) canvas.
*
* @param this
*/
async function switchToLegacyCanvas() {
await this.page.waitForFunction(() => window?.wp?.blocks);
await this.page.evaluate(() => {
window.wp.blocks.registerBlockType('test/v2', {
apiVersion: '2',
title: 'test',
});
});
}
exports.switchToLegacyCanvas = switchToLegacyCanvas;
//# sourceMappingURL=switch-to-legacy-canvas.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"switch-to-legacy-canvas.js","sourceRoot":"","sources":["../../src/editor/switch-to-legacy-canvas.ts"],"names":[],"mappings":";;;AAKA;;;;GAIG;AACI,KAAK,UAAU,oBAAoB;IACzC,MAAM,IAAI,CAAC,IAAI,CAAC,eAAe,CAAE,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,EAAE,MAAM,CAAE,CAAC;IAE5D,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAE,GAAG,EAAE;QAC9B,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAE,SAAS,EAAE;YAC9C,UAAU,EAAE,GAAG;YACf,KAAK,EAAE,MAAM;SACb,CAAE,CAAC;IACL,CAAC,CAAE,CAAC;AACL,CAAC;AATD,oDASC"}

View File

@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformBlockTo = void 0;
/**
* Clicks the default block appender.
*
* @param this
* @param name Block name.
*/
async function transformBlockTo(name) {
await this.page.waitForFunction(() => window?.wp?.blocks && window?.wp?.data);
await this.page.evaluate(([blockName]) => {
const clientIds = window.wp.data
.select('core/block-editor')
.getSelectedBlockClientIds();
const blocks = window.wp.data
.select('core/block-editor')
.getBlocksByClientId(clientIds);
window.wp.data
.dispatch('core/block-editor')
.replaceBlocks(clientIds, window.wp.blocks.switchToBlockType(blocks, blockName));
}, [name]);
}
exports.transformBlockTo = transformBlockTo;
//# sourceMappingURL=transform-block-to.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"transform-block-to.js","sourceRoot":"","sources":["../../src/editor/transform-block-to.ts"],"names":[],"mappings":";;;AAKA;;;;;GAKG;AACI,KAAK,UAAU,gBAAgB,CAAgB,IAAY;IACjE,MAAM,IAAI,CAAC,IAAI,CAAC,eAAe,CAC9B,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,EAAE,MAAM,IAAI,MAAM,EAAE,EAAE,EAAE,IAAI,CAC5C,CAAC;IAEF,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CACvB,CAAE,CAAE,SAAS,CAAE,EAAG,EAAE;QACnB,MAAM,SAAS,GAAG,MAAM,CAAC,EAAE,CAAC,IAAI;aAC9B,MAAM,CAAE,mBAAmB,CAAE;aAC7B,yBAAyB,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,IAAI;aAC3B,MAAM,CAAE,mBAAmB,CAAE;aAC7B,mBAAmB,CAAE,SAAS,CAAE,CAAC;QACnC,MAAM,CAAC,EAAE,CAAC,IAAI;aACZ,QAAQ,CAAE,mBAAmB,CAAE;aAC/B,aAAa,CACb,SAAS,EACT,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAE,MAAM,EAAE,SAAS,CAAE,CACvD,CAAC;IACJ,CAAC,EACD,CAAE,IAAI,CAAE,CACR,CAAC;AACH,CAAC;AAtBD,4CAsBC"}