@voplus/morpho-document 6.0.205 → 6.0.206

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.
@@ -1,32 +1,33 @@
1
- import React, { useState } from "react";
1
+ import React, { useMemo, useState } from "react";
2
+ import { State } from "./state";
2
3
  import { observe } from "@voplus/morpho-ui";
3
4
  import { Skeleton, Space, Button } from "antd";
4
5
  import { Scrollbars } from "react-custom-scrollbars-2";
5
- import { useMessageTemplate, useMessageTemplateStore } from "../../../../data/message-template";
6
+ import { useMessageTemplateStore } from "../../../../data/message-template";
6
7
  import ProseMirror from "@voplus/morpho-text/es/controls/ProseMirror";
7
8
  import CodeMirror from "../../components/CodeMirror";
8
9
  import "./index.less";
9
10
  const MessageTemplateContent = (props) => {
10
- const messageTemplate = useMessageTemplate(props.id, {
11
- reload: true,
12
- includes: "layout,preview",
13
- });
14
- const store = useMessageTemplateStore();
15
11
  const [edit, setEdit] = useState(false);
16
12
  const [codeContent, setCodeContent] = useState();
17
- return observe(() => (React.createElement("div", { className: "message-template-page" },
18
- props.canEdit && (React.createElement("div", { className: "message-template-body-header" }, edit ? (React.createElement(Space, null,
19
- React.createElement(Button, { onClick: () => setEdit(false) }, "Cancel"),
20
- React.createElement(Button, { type: "primary", onClick: async () => {
21
- await store
22
- .edit(props.id, { data: { Body: codeContent }, error: "message" })
23
- .then(() => setEdit(false));
24
- } }, "Save"))) : (React.createElement(Button, { type: "primary", onClick: () => setEdit(true) }, "Edit")))),
25
- edit ? (React.createElement("div", { className: "message-template-edit-code-mirror" },
26
- React.createElement(Scrollbars, { autoHide: true }, messageTemplate.editor === "RichText" ? (React.createElement(ProseMirror, { scroll: true, toolbarProps: { sticky: false }, defaultHtml: messageTemplate.body, onChange: (opt) => setCodeContent(opt.getInnerHtml()) })) : (React.createElement(CodeMirror, { code: messageTemplate.body, onChange: (code) => setCodeContent(code) }))))) : (React.createElement(Skeleton, { loading: !messageTemplate.loaded },
27
- React.createElement("div", { className: "message-template-iframe-content" },
28
- React.createElement("div", null,
29
- React.createElement("iframe", { srcDoc: messageTemplate.preview }))))))));
13
+ const store = useMessageTemplateStore();
14
+ const state = useMemo(() => new State(props.id, store), [props.id]);
15
+ return observe(() => {
16
+ var _a;
17
+ return (React.createElement("div", { className: "message-template-page" },
18
+ props.canEdit && (React.createElement("div", { className: "message-template-body-header" }, edit ? (React.createElement(Space, null,
19
+ React.createElement(Button, { onClick: () => setEdit(false) }, "Cancel"),
20
+ React.createElement(Button, { type: "primary", onClick: async () => {
21
+ await store
22
+ .edit(props.id, { data: { Body: codeContent }, error: "message" })
23
+ .then(() => setEdit(false));
24
+ } }, "Save"))) : (React.createElement(Button, { type: "primary", onClick: () => setEdit(true) }, "Edit")))),
25
+ edit ? (React.createElement("div", { className: "message-template-edit-code-mirror" },
26
+ React.createElement(Scrollbars, { autoHide: true }, state.messageTemplate.editor === "RichText" ? (React.createElement(ProseMirror, { scroll: true, toolbarProps: { sticky: false }, defaultHtml: state.messageTemplate.body, onChange: (opt) => setCodeContent(opt.getInnerHtml()) })) : (React.createElement(CodeMirror, { code: state.messageTemplate.body, onChange: (code) => setCodeContent(code) }))))) : (React.createElement(Skeleton, { loading: state.loading },
27
+ React.createElement("div", { className: "message-template-iframe-content" },
28
+ React.createElement("div", null,
29
+ React.createElement("iframe", { srcDoc: (_a = state.messageTemplate) === null || _a === void 0 ? void 0 : _a.preview })))))));
30
+ });
30
31
  // function merge(isLayout: boolean, body: string = "", layoutBody: string = "") {
31
32
  // return isLayout ? body : layoutBody.replace("{{Content}}", body);
32
33
  // }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/message-template/components/MessageTemplateContent/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,KA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F,CACR,CAAC,CAAC,CAAC,CACH,oBAAC,MAAM,IAAC,IAAI,EAAC,SAAS,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,WAE1C,CACT,CACI,CACN;QACA,IAAI,CAAC,CAAC,CAAC,CACP,6BAAK,SAAS,EAAC,mCAAmC;YACjD,oBAAC,UAAU,IAAC,QAAQ,UAClB,eAAe,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,CACxC,oBAAC,WAAW,IACX,MAAM,QACN,YAAY,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAC/B,WAAW,EAAE,eAAe,CAAC,IAAI,EACjC,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,GACpD,CACF,CAAC,CAAC,CAAC,CACH,oBAAC,UAAU,IAAC,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,GAAI,CACpF,CACW,CACR,CACN,CAAC,CAAC,CAAC,CACH,oBAAC,QAAQ,IAAC,OAAO,EAAE,CAAC,eAAe,CAAC,MAAM;YACzC,6BAAK,SAAS,EAAC,iCAAiC;gBAC/C;oBAEC,gCAAQ,MAAM,EAAE,eAAe,CAAC,OAAO,GAAI,CACtC,CACD,CACI,CACX,CACI,CACN,CAAC,CAAC;IAEH,kFAAkF;IAClF,qEAAqE;IACrE,IAAI;AACL,CAAC,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/message-template/components/MessageTemplateContent/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MA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AG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;oBAC9B,CAAC,WAGO,CACF,CACR,CAAC,CAAC,CAAC,CACH,oBAAC,MAAM,IAAC,IAAI,EAAC,SAAS,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,WAE1C,CACT,CACI,CACN;YACA,IAAI,CAAC,CAAC,CAAC,CACP,6BAAK,SAAS,EAAC,mCAAmC;gBACjD,oBAAC,UAAU,IAAC,QAAQ,UAClB,KAAK,CAAC,eAAe,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,CAC9C,oBAAC,WAAW,IACX,MAAM,QACN,YAAY,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAC/B,WAAW,EAAE,KAAK,CAAC,eAAe,CAAC,IAAI,EACvC,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,GACpD,CACF,CAAC,CAAC,CAAC,CACH,oBAAC,UAAU,IACV,IAAI,EAAE,KAAK,CAAC,eAAe,CAAC,IAAI,EAChC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,GACvC,CACF,CACW,CACR,CACN,CAAC,CAAC,CAAC,CACH,oBAAC,QAAQ,IAAC,OAAO,EAAE,KAAK,CAAC,OAAO;gBAC/B,6BAAK,SAAS,EAAC,iCAAiC;oBAC/C;wBAEC,gCAAQ,MAAM,EAAE,MAAA,KAAK,CAAC,eAAe,0CAAE,OAAO,GAAI,CAC7C,CACD,CACI,CACX,CACI,CACN,CAAA;KAAA,CAAC,CAAC;IAEH,kFAAkF;IAClF,qEAAqE;IACrE,IAAI;AACL,CAAC,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { MessageTemplateStore, IMessageTemplate } from "../../../../data/message-template";
2
+ export declare class State {
3
+ private id;
4
+ private store;
5
+ loading: boolean;
6
+ messageTemplate: IMessageTemplate;
7
+ constructor(id: string, store: MessageTemplateStore);
8
+ loadData(): Promise<void>;
9
+ }
@@ -0,0 +1,49 @@
1
+ import { __decorate } from "tslib";
2
+ import { action, makeObservable, observable } from "mobx";
3
+ export class State {
4
+ constructor(id, store) {
5
+ Object.defineProperty(this, "id", {
6
+ enumerable: true,
7
+ configurable: true,
8
+ writable: true,
9
+ value: id
10
+ });
11
+ Object.defineProperty(this, "store", {
12
+ enumerable: true,
13
+ configurable: true,
14
+ writable: true,
15
+ value: store
16
+ });
17
+ Object.defineProperty(this, "loading", {
18
+ enumerable: true,
19
+ configurable: true,
20
+ writable: true,
21
+ value: false
22
+ });
23
+ Object.defineProperty(this, "messageTemplate", {
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true,
27
+ value: void 0
28
+ });
29
+ makeObservable(this);
30
+ this.loadData();
31
+ }
32
+ async loadData() {
33
+ this.loading = true;
34
+ await this.store
35
+ .load(this.id, { includes: "layout,preview" })
36
+ .then((res) => (this.messageTemplate = res))
37
+ .then(() => (this.loading = false));
38
+ }
39
+ }
40
+ __decorate([
41
+ observable
42
+ ], State.prototype, "loading", void 0);
43
+ __decorate([
44
+ observable
45
+ ], State.prototype, "messageTemplate", void 0);
46
+ __decorate([
47
+ action
48
+ ], State.prototype, "loadData", null);
49
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../../../../../src/modules/message-template/components/MessageTemplateContent/state.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAG1D,MAAM,OAAO,KAAK;IAIjB,YAAoB,EAAU,EAAU,KAA2B;QAAvD;;;;mBAAQ,EAAE;WAAQ;QAAE;;;;mBAAQ,KAAK;WAAsB;QAHhD;;;;mBAAU,KAAK;WAAC;QAChB;;;;;WAAkC;QAGpD,cAAc,CAAC,IAAI,CAAC,CAAC;QAErB,IAAI,CAAC,QAAQ,EAAE,CAAC;IACjB,CAAC;IAGY,AAAN,KAAK,CAAC,QAAQ;QACpB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QAEpB,MAAM,IAAI,CAAC,KAAK;aACd,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC;aAC7C,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,eAAe,GAAG,GAAG,CAAC,CAAC;aAC3C,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC;IACtC,CAAC;CACD;AAlBmB;IAAlB,UAAU;sCAAwB;AAChB;IAAlB,UAAU;8CAA0C;AASxC;IADZ,MAAM;qCAQN"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voplus/morpho-document",
3
- "version": "6.0.205",
3
+ "version": "6.0.206",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://voplus.visualstudio.com/morpho-document/_git/morpho-document"