Web: Common/Doceditor: fixed name of init state of editor

This commit is contained in:
Artem Tarasov 2022-07-26 10:56:25 +03:00
parent 42c42f19eb
commit 045c00b4ff
5 changed files with 16 additions and 17 deletions

View File

@ -1,6 +1,6 @@
export const LANGUAGE = "language"; export const LANGUAGE = "language";
export const ARTICLE_PINNED_KEY = "asc_article_pinned_key"; export const ARTICLE_PINNED_KEY = "asc_article_pinned_key";
export const EDITOR_STATE_NAME = "__ASC_INITIAL_EDITOR_STATE__";
/** /**
* Enum for employee activation status. * Enum for employee activation status.
* @readonly * @readonly

View File

@ -1,6 +1,6 @@
import { makeAutoObservable } from "mobx"; import { makeAutoObservable } from "mobx";
import api from "../api"; import api from "../api";
import { LANGUAGE, TenantStatus, EDITOR_STATE_NAME } from "../constants"; import { LANGUAGE, TenantStatus } from "../constants";
import { combineUrl } from "../utils"; import { combineUrl } from "../utils";
import FirebaseHelper from "../utils/firebase"; import FirebaseHelper from "../utils/firebase";
import { AppServerConfig, ThemeKeys } from "../constants"; import { AppServerConfig, ThemeKeys } from "../constants";
@ -175,8 +175,8 @@ class SettingsStore {
getSettings = async () => { getSettings = async () => {
let newSettings = null; let newSettings = null;
if (window[`${EDITOR_STATE_NAME}`]?.portalSettings) if (window?.__ASC_INITIAL_EDITOR_STATE__?.portalSettings)
newSettings = window[`${EDITOR_STATE_NAME}`].portalSettings; newSettings = window.__ASC_INITIAL_EDITOR_STATE__.portalSettings;
else newSettings = await api.settings.getSettings(); else newSettings = await api.settings.getSettings();
if (window["AscDesktopEditor"] !== undefined || this.personal) { if (window["AscDesktopEditor"] !== undefined || this.personal) {
@ -218,9 +218,9 @@ class SettingsStore {
getCurrentCustomSchema = async (id) => { getCurrentCustomSchema = async (id) => {
let customNames = null; let customNames = null;
if (window[`${EDITOR_STATE_NAME}`]?.customNames) { if (window?.__ASC_INITIAL_EDITOR_STATE__?.customNames) {
customNames = window[`${EDITOR_STATE_NAME}`].customNames; customNames = window.__ASC_INITIAL_EDITOR_STATE__.customNames;
window[`${EDITOR_STATE_NAME}`].customNames = null; window.__ASC_INITIAL_EDITOR_STATE__.customNames = null;
} else customNames = await api.settings.getCurrentCustomSchema(id); } else customNames = await api.settings.getCurrentCustomSchema(id);
this.customNames = customNames; this.customNames = customNames;
}; };
@ -438,8 +438,8 @@ class SettingsStore {
getBuildVersionInfo = async () => { getBuildVersionInfo = async () => {
let versionInfo = null; let versionInfo = null;
if (window[`${EDITOR_STATE_NAME}`]?.versionInfo) if (window?.__ASC_INITIAL_EDITOR_STATE__?.versionInfo)
versionInfo = window[`${EDITOR_STATE_NAME}`].versionInfo; versionInfo = window.__ASC_INITIAL_EDITOR_STATE__.versionInfo;
else versionInfo = await api.settings.getBuildVersion(); else versionInfo = await api.settings.getBuildVersion();
this.setBuildVersionInfo(versionInfo); this.setBuildVersionInfo(versionInfo);
}; };

View File

@ -1,6 +1,5 @@
import { makeAutoObservable } from "mobx"; import { makeAutoObservable } from "mobx";
import api from "../api"; import api from "../api";
import { EDITOR_STATE_NAME } from "../constants";
class UserStore { class UserStore {
user = null; user = null;
@ -14,8 +13,8 @@ class UserStore {
loadCurrentUser = async () => { loadCurrentUser = async () => {
let user = null; let user = null;
if (window[`${EDITOR_STATE_NAME}`]?.user) if (window?.__ASC_INITIAL_EDITOR_STATE__?.user)
user = window[`${EDITOR_STATE_NAME}`].user; user = window.__ASC_INITIAL_EDITOR_STATE__.user;
else user = await api.people.getUser(); else user = await api.people.getUser();
this.setUser(user); this.setUser(user);

View File

@ -4,9 +4,8 @@ import { registerSW } from "@appserver/common/sw/helper";
import App from "./App.js"; import App from "./App.js";
import pkg from "../../package.json"; import pkg from "../../package.json";
import { initI18n } from "./helpers/utils.js"; import { initI18n } from "./helpers/utils.js";
import { EDITOR_STATE_NAME } from "@appserver/common/constants";
const propsObj = window[`${EDITOR_STATE_NAME}`]; const propsObj = window.__ASC_INITIAL_EDITOR_STATE__;
const initialI18nStoreASC = window.initialI18nStoreASC; const initialI18nStoreASC = window.initialI18nStoreASC;
const initialLanguage = window.initialLanguage; const initialLanguage = window.initialLanguage;

View File

@ -1,6 +1,5 @@
import { getFavicon, getScripts } from "./helpers"; import { getFavicon, getScripts } from "./helpers";
import pkg from "../../../package.json"; import pkg from "../../../package.json";
import { EDITOR_STATE_NAME } from "@appserver/common/constants";
export default function template( export default function template(
initialEditorState = {}, initialEditorState = {},
@ -34,8 +33,10 @@ export default function template(
} }
const scripts = ` const scripts = `
<script id="${EDITOR_STATE_NAME}"> <script id="__ASC_INITIAL_EDITOR_STATE__">
window.${EDITOR_STATE_NAME} = ${JSON.stringify(initialEditorState)} window.__ASC_INITIAL_EDITOR_STATE__ = ${JSON.stringify(
initialEditorState
)}
</script> </script>
<script id="__ASC_INITIAL_EDITOR_I18N__"> <script id="__ASC_INITIAL_EDITOR_I18N__">
window.initialI18nStoreASC = ${JSON.stringify(initialI18nStoreASC)} window.initialI18nStoreASC = ${JSON.stringify(initialI18nStoreASC)}