diff --git a/packages/js/email-editor/src/global.d.ts b/packages/js/email-editor/src/global.d.ts index d5b6544b93..8fe992d9c4 100644 --- a/packages/js/email-editor/src/global.d.ts +++ b/packages/js/email-editor/src/global.d.ts @@ -16,4 +16,5 @@ interface Window { editor_theme: unknown; // Can't import type in global.d.ts. Typed in getEditorTheme() in store/settings.ts }; mailpoet_email_editor_current_post_type: string; + mailpoet_email_editor_current_post_id: number; } diff --git a/packages/js/email-editor/src/store/constants.ts b/packages/js/email-editor/src/store/constants.ts index e43f7da77f..765e3aa0b6 100644 --- a/packages/js/email-editor/src/store/constants.ts +++ b/packages/js/email-editor/src/store/constants.ts @@ -7,3 +7,4 @@ export const stylesSidebarId = 'email-editor/editor/styles'; export const editorCurrentPostType = window.mailpoet_email_editor_current_post_type; +export const editorCurrentPostId = window.mailpoet_email_editor_current_post_id; diff --git a/packages/js/email-editor/src/store/initial-state.ts b/packages/js/email-editor/src/store/initial-state.ts index de85acb979..64aa296d84 100644 --- a/packages/js/email-editor/src/store/initial-state.ts +++ b/packages/js/email-editor/src/store/initial-state.ts @@ -1,7 +1,7 @@ /** * Internal dependencies */ -import { mainSidebarDocumentTab } from './constants'; +import { mainSidebarDocumentTab, editorCurrentPostId } from './constants'; import { State } from './types'; import { getEditorSettings, @@ -12,8 +12,7 @@ import { } from './settings'; export function getInitialState(): State { - const searchParams = new URLSearchParams( window.location.search ); - const postId = parseInt( searchParams.get( 'post' ), 10 ); + const postId = editorCurrentPostId; return { inserterSidebar: { isOpened: false, diff --git a/packages/php/email-editor/src/Engine/class-email-editor.php b/packages/php/email-editor/src/Engine/class-email-editor.php index 6b838a2890..82fa6c6f76 100644 --- a/packages/php/email-editor/src/Engine/class-email-editor.php +++ b/packages/php/email-editor/src/Engine/class-email-editor.php @@ -317,7 +317,8 @@ class Email_Editor { ?>