@hkyhy/marsun-components-core 0.1.130 → 0.1.131

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.
Files changed (28) hide show
  1. package/README.md +1 -0
  2. package/dist/_virtual/index.js +5 -5
  3. package/dist/_virtual/index2.js +5 -5
  4. package/dist/components/Editor/RichTextEditor/RichTextEditor.d.ts +3 -1
  5. package/dist/components/Editor/RichTextEditor/RichTextEditor.js +140 -61
  6. package/dist/components/Editor/RichTextEditor/RichTextEditor.js.map +1 -1
  7. package/dist/components/Editor/RichTextEditor/style.module.scss.js +7 -7
  8. package/dist/components/Editor/index.d.ts +2 -2
  9. package/dist/components/Editor/index.js +20 -14
  10. package/dist/components/Editor/msgVarTokenPlugin.d.ts +22 -1
  11. package/dist/components/Editor/msgVarTokenPlugin.js +188 -45
  12. package/dist/components/Editor/msgVarTokenPlugin.js.map +1 -1
  13. package/dist/components/Editor/variableMention.d.ts +20 -1
  14. package/dist/components/Editor/variableMention.js +134 -46
  15. package/dist/components/Editor/variableMention.js.map +1 -1
  16. package/dist/components/FormInfo/RichTextField/index.d.ts +2 -0
  17. package/dist/components/FormInfo/RichTextField/index.js +46 -43
  18. package/dist/components/FormInfo/RichTextField/index.js.map +1 -1
  19. package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/Modal/TemplateFormModal.js +121 -112
  20. package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/Modal/TemplateFormModal.js.map +1 -1
  21. package/dist/editor.js +22 -16
  22. package/dist/index.js +361 -355
  23. package/dist/marsun-components-core.css +1 -1
  24. package/dist/node_modules/@antv/g-lite/dist/index.esm.js +1 -1
  25. package/dist/node_modules/@antv/g2/esm/data/kde.js +1 -1
  26. package/dist/node_modules/eventemitter3/index.js +1 -1
  27. package/dist/styles/global.css +1 -1
  28. package/package.json +1 -1
@@ -15,6 +15,8 @@ export type RichTextFieldProps = {
15
15
  className?: string;
16
16
  /** remount 键(换文档时传入) */
17
17
  editorKey?: string;
18
+ /** 编辑器 HTML 旁路(保存时优先用,避免 Form 滞后丢样式) */
19
+ onEditorHtml?: (html: string) => void;
18
20
  [key: string]: unknown;
19
21
  };
20
22
  export declare const RichTextField: ComponentType<RichTextFieldProps>;
@@ -1,59 +1,62 @@
1
- import { jsx as e } from "react/jsx-runtime";
2
- import * as p from "@kne/react-form-antd";
3
- import R from "classnames";
4
- import { Suspense as T, lazy as u } from "react";
5
- import o from "./style.module.scss.js";
6
- const N = u(
7
- () => import("../../Editor/index.js").then((t) => ({ default: t.RichTextEditor }))
8
- ), F = ({
9
- value: t = "",
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import * as T from "@kne/react-form-antd";
3
+ import u from "classnames";
4
+ import { Suspense as N, lazy as F } from "react";
5
+ import s from "./style.module.scss.js";
6
+ const y = F(
7
+ () => import("../../Editor/index.js").then((e) => ({ default: e.RichTextEditor }))
8
+ ), k = ({
9
+ value: e = "",
10
10
  onChange: r,
11
11
  disabled: i,
12
- readOnly: s,
13
- placeholder: m,
14
- minHeight: d = 140,
15
- enableVariableMention: a,
16
- variables: n,
17
- catalogError: l,
18
- className: h,
19
- editorKey: f,
20
- id: x
21
- }) => /* @__PURE__ */ e(
12
+ readOnly: m,
13
+ placeholder: d,
14
+ minHeight: l = 140,
15
+ enableVariableMention: f,
16
+ variables: x,
17
+ catalogError: h,
18
+ className: n,
19
+ editorKey: p,
20
+ onEditorHtml: c,
21
+ id: R
22
+ }) => /* @__PURE__ */ t(
22
23
  "div",
23
24
  {
24
- className: R(
25
+ className: u(
25
26
  "marsun-form-rich-text",
26
- o["form-rich-text"],
27
- i && o["form-rich-text-disabled"],
28
- h
27
+ s["form-rich-text"],
28
+ i && s["form-rich-text-disabled"],
29
+ n
29
30
  ),
30
- "data-field-id": x,
31
- children: /* @__PURE__ */ e(T, { fallback: /* @__PURE__ */ e("div", { className: o["form-rich-text-loading"], children: "加载编辑器…" }), children: /* @__PURE__ */ e(
32
- N,
31
+ "data-field-id": R,
32
+ children: /* @__PURE__ */ t(N, { fallback: /* @__PURE__ */ t("div", { className: s["form-rich-text-loading"], children: "加载编辑器…" }), children: /* @__PURE__ */ t(
33
+ y,
33
34
  {
34
- value: t,
35
- onChange: r,
35
+ value: e,
36
+ onChange: (o) => {
37
+ r == null || r(o), c == null || c(o);
38
+ },
36
39
  disabled: i,
37
- readOnly: s,
38
- placeholder: m,
39
- minHeight: d,
40
- enableVariableMention: a,
41
- variables: n,
42
- catalogError: l
40
+ readOnly: m,
41
+ placeholder: d,
42
+ minHeight: l,
43
+ enableVariableMention: f,
44
+ variables: x,
45
+ catalogError: h
43
46
  },
44
- f || "rte"
47
+ p || "rte"
45
48
  ) })
46
49
  }
47
- ), c = (t) => {
48
- const { useDecorator: r } = p.hooks;
50
+ ), a = (e) => {
51
+ const { useDecorator: r } = T.hooks;
49
52
  return r({
50
- fieldName: "richTextEditor",
51
- ...t
52
- })(F);
53
+ fieldName: "textArea",
54
+ ...e
55
+ })(k);
53
56
  };
54
- c.displayName = "RichTextField";
55
- const b = c;
57
+ a.displayName = "RichTextField";
58
+ const z = a;
56
59
  export {
57
- b as RichTextField
60
+ z as RichTextField
58
61
  };
59
62
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/components/FormInfo/RichTextField/index.tsx"],"sourcesContent":["import * as ReactFormAntd from '@kne/react-form-antd';\nimport classNames from 'classnames';\nimport type { ComponentType, FC, ReactNode } from 'react';\nimport { Suspense, lazy } from 'react';\nimport type { VariableMentionItem } from '@/components/Editor/variableMention';\nimport styles from './style.module.scss';\n\nconst RichTextEditor = lazy(() =>\n import('@/components/Editor').then((m) => ({ default: m.RichTextEditor })),\n);\n\nexport type RichTextFieldProps = {\n name: string;\n label?: ReactNode;\n labelTips?: ReactNode | ((props: RichTextFieldProps) => ReactNode);\n rule?: string;\n disabled?: boolean;\n readOnly?: boolean;\n placeholder?: string;\n minHeight?: number;\n enableVariableMention?: boolean;\n variables?: VariableMentionItem[];\n catalogError?: string;\n className?: string;\n /** remount 键(换文档时传入) */\n editorKey?: string;\n [key: string]: unknown;\n};\n\ntype FieldRenderProps = {\n value?: string;\n onChange?: (v: string) => void;\n disabled?: boolean;\n id?: string;\n readOnly?: boolean;\n placeholder?: string;\n minHeight?: number;\n enableVariableMention?: boolean;\n variables?: VariableMentionItem[];\n catalogError?: string;\n className?: string;\n editorKey?: string;\n};\n\ntype KneHooks = {\n useDecorator: (\n opts: Record<string, unknown>,\n ) => (Comp: ComponentType<FieldRenderProps>) => ReactNode;\n};\n\n/**\n * FormInfo 富文本字段:外观对齐 Input;L2 Editor 懒加载;「插入变量」+ 原子色块。\n * 须作为稳定组件类型交给 useDecorator(禁内联函数,否则每键 remount 丢焦)。\n */\nconst RichTextControl: FC<FieldRenderProps> = ({\n value = '',\n onChange,\n disabled,\n readOnly,\n placeholder,\n minHeight = 140,\n enableVariableMention,\n variables,\n catalogError,\n className,\n editorKey,\n id,\n}) => (\n <div\n className={classNames(\n 'marsun-form-rich-text',\n styles['form-rich-text'],\n disabled && styles['form-rich-text-disabled'],\n className,\n )}\n data-field-id={id}\n >\n <Suspense fallback={<div className={styles['form-rich-text-loading']}>加载编辑器…</div>}>\n <RichTextEditor\n key={editorKey || 'rte'}\n value={value}\n onChange={onChange}\n disabled={disabled}\n readOnly={readOnly}\n placeholder={placeholder}\n minHeight={minHeight}\n enableVariableMention={enableVariableMention}\n variables={variables}\n catalogError={catalogError}\n />\n </Suspense>\n </div>\n);\n\nconst RichTextFieldInner: FC<RichTextFieldProps> = (props) => {\n const { useDecorator } = (ReactFormAntd as unknown as { hooks: KneHooks }).hooks;\n const render = useDecorator({\n fieldName: 'richTextEditor',\n ...props,\n });\n return render(RichTextControl);\n};\n\nRichTextFieldInner.displayName = 'RichTextField';\n\nexport const RichTextField = RichTextFieldInner as ComponentType<RichTextFieldProps>;\n\nexport default RichTextField;\n"],"names":["RichTextEditor","lazy","m","RichTextControl","value","onChange","disabled","readOnly","placeholder","minHeight","enableVariableMention","variables","catalogError","className","editorKey","id","jsx","classNames","styles","Suspense","RichTextFieldInner","props","useDecorator","ReactFormAntd","RichTextField"],"mappings":";;;;;AAOA,MAAMA,IAAiBC;AAAA,EAAK,MAC1B,OAAO,uBAAqB,EAAE,KAAK,CAACC,OAAO,EAAE,SAASA,EAAE,iBAAiB;AAC3E,GA6CMC,IAAwC,CAAC;AAAA,EAC7C,OAAAC,IAAQ;AAAA,EACR,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,aAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,uBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,cAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,IAAAC;AACF,MACE,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,WAAWC;AAAA,MACT;AAAA,MACAC,EAAO,gBAAgB;AAAA,MACvBZ,KAAYY,EAAO,yBAAyB;AAAA,MAC5CL;AAAA,IAAA;AAAA,IAEF,iBAAeE;AAAA,IAEf,UAAA,gBAAAC,EAACG,GAAA,EAAS,UAAU,gBAAAH,EAAC,OAAA,EAAI,WAAWE,EAAO,wBAAwB,GAAG,UAAA,SAAA,CAAM,GAC1E,UAAA,gBAAAF;AAAA,MAAChB;AAAA,MAAA;AAAA,QAEC,OAAAI;AAAA,QACA,UAAAC;AAAA,QACA,UAAAC;AAAA,QACA,UAAAC;AAAA,QACA,aAAAC;AAAA,QACA,WAAAC;AAAA,QACA,uBAAAC;AAAA,QACA,WAAAC;AAAA,QACA,cAAAC;AAAA,MAAA;AAAA,MATKE,KAAa;AAAA,IAAA,EAUpB,CACF;AAAA,EAAA;AACF,GAGIM,IAA6C,CAACC,MAAU;AAC5D,QAAM,EAAE,cAAAC,MAAkBC,EAAiD;AAK3E,SAJeD,EAAa;AAAA,IAC1B,WAAW;AAAA,IACX,GAAGD;AAAA,EAAA,CACJ,EACalB,CAAe;AAC/B;AAEAiB,EAAmB,cAAc;AAE1B,MAAMI,IAAgBJ;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/FormInfo/RichTextField/index.tsx"],"sourcesContent":["import * as ReactFormAntd from '@kne/react-form-antd';\nimport classNames from 'classnames';\nimport type { ComponentType, FC, ReactNode } from 'react';\nimport { Suspense, lazy } from 'react';\nimport type { VariableMentionItem } from '@/components/Editor/variableMention';\nimport styles from './style.module.scss';\n\nconst RichTextEditor = lazy(() =>\n import('@/components/Editor').then((m) => ({ default: m.RichTextEditor })),\n);\n\nexport type RichTextFieldProps = {\n name: string;\n label?: ReactNode;\n labelTips?: ReactNode | ((props: RichTextFieldProps) => ReactNode);\n rule?: string;\n disabled?: boolean;\n readOnly?: boolean;\n placeholder?: string;\n minHeight?: number;\n enableVariableMention?: boolean;\n variables?: VariableMentionItem[];\n catalogError?: string;\n className?: string;\n /** remount 键(换文档时传入) */\n editorKey?: string;\n /** 编辑器 HTML 旁路(保存时优先用,避免 Form 滞后丢样式) */\n onEditorHtml?: (html: string) => void;\n [key: string]: unknown;\n};\n\ntype FieldRenderProps = {\n value?: string;\n onChange?: (v: string) => void;\n disabled?: boolean;\n id?: string;\n readOnly?: boolean;\n placeholder?: string;\n minHeight?: number;\n enableVariableMention?: boolean;\n variables?: VariableMentionItem[];\n catalogError?: string;\n className?: string;\n editorKey?: string;\n onEditorHtml?: (html: string) => void;\n};\n\ntype KneHooks = {\n useDecorator: (\n opts: Record<string, unknown>,\n ) => (Comp: ComponentType<FieldRenderProps>) => ReactNode;\n};\n\n/**\n * FormInfo 富文本字段:外观对齐 Input;L2 Editor 懒加载;「插入变量」+ 原子色块。\n * 须作为稳定组件类型交给 useDecorator(禁内联函数,否则每键 remount 丢焦)。\n */\nconst RichTextControl: FC<FieldRenderProps> = ({\n value = '',\n onChange,\n disabled,\n readOnly,\n placeholder,\n minHeight = 140,\n enableVariableMention,\n variables,\n catalogError,\n className,\n editorKey,\n onEditorHtml,\n id,\n}) => (\n <div\n className={classNames(\n 'marsun-form-rich-text',\n styles['form-rich-text'],\n disabled && styles['form-rich-text-disabled'],\n className,\n )}\n data-field-id={id}\n >\n <Suspense fallback={<div className={styles['form-rich-text-loading']}>加载编辑器…</div>}>\n <RichTextEditor\n key={editorKey || 'rte'}\n value={value}\n onChange={(html) => {\n onChange?.(html);\n onEditorHtml?.(html);\n }}\n disabled={disabled}\n readOnly={readOnly}\n placeholder={placeholder}\n minHeight={minHeight}\n enableVariableMention={enableVariableMention}\n variables={variables}\n catalogError={catalogError}\n />\n </Suspense>\n </div>\n);\n\nconst RichTextFieldInner: FC<RichTextFieldProps> = (props) => {\n const { useDecorator } = (ReactFormAntd as unknown as { hooks: KneHooks }).hooks;\n // fieldName 用已注册的 textArea,保证 Form data 按 name 回填 value(自定义名易空值)\n const render = useDecorator({\n fieldName: 'textArea',\n ...props,\n });\n return render(RichTextControl);\n};\n\nRichTextFieldInner.displayName = 'RichTextField';\n\nexport const RichTextField = RichTextFieldInner as ComponentType<RichTextFieldProps>;\n\nexport default RichTextField;\n"],"names":["RichTextEditor","lazy","m","RichTextControl","value","onChange","disabled","readOnly","placeholder","minHeight","enableVariableMention","variables","catalogError","className","editorKey","onEditorHtml","id","jsx","classNames","styles","Suspense","html","RichTextFieldInner","props","useDecorator","ReactFormAntd","RichTextField"],"mappings":";;;;;AAOA,MAAMA,IAAiBC;AAAA,EAAK,MAC1B,OAAO,uBAAqB,EAAE,KAAK,CAACC,OAAO,EAAE,SAASA,EAAE,iBAAiB;AAC3E,GAgDMC,IAAwC,CAAC;AAAA,EAC7C,OAAAC,IAAQ;AAAA,EACR,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,aAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,uBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,cAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,cAAAC;AAAA,EACA,IAAAC;AACF,MACE,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,WAAWC;AAAA,MACT;AAAA,MACAC,EAAO,gBAAgB;AAAA,MACvBb,KAAYa,EAAO,yBAAyB;AAAA,MAC5CN;AAAA,IAAA;AAAA,IAEF,iBAAeG;AAAA,IAEf,UAAA,gBAAAC,EAACG,GAAA,EAAS,UAAU,gBAAAH,EAAC,OAAA,EAAI,WAAWE,EAAO,wBAAwB,GAAG,UAAA,SAAA,CAAM,GAC1E,UAAA,gBAAAF;AAAA,MAACjB;AAAA,MAAA;AAAA,QAEC,OAAAI;AAAA,QACA,UAAU,CAACiB,MAAS;AAClB,UAAAhB,KAAA,QAAAA,EAAWgB,IACXN,KAAA,QAAAA,EAAeM;AAAA,QACjB;AAAA,QACA,UAAAf;AAAA,QACA,UAAAC;AAAA,QACA,aAAAC;AAAA,QACA,WAAAC;AAAA,QACA,uBAAAC;AAAA,QACA,WAAAC;AAAA,QACA,cAAAC;AAAA,MAAA;AAAA,MAZKE,KAAa;AAAA,IAAA,EAapB,CACF;AAAA,EAAA;AACF,GAGIQ,IAA6C,CAACC,MAAU;AAC5D,QAAM,EAAE,cAAAC,MAAkBC,EAAiD;AAM3E,SAJeD,EAAa;AAAA,IAC1B,WAAW;AAAA,IACX,GAAGD;AAAA,EAAA,CACJ,EACapB,CAAe;AAC/B;AAEAmB,EAAmB,cAAc;AAE1B,MAAMI,IAAgBJ;"}
@@ -1,63 +1,65 @@
1
- import { jsx as s, jsxs as y } from "react/jsx-runtime";
2
- import { RichTextField as Q } from "../../../../FormInfo/RichTextField/index.js";
3
- import { sanitizeInboxHtml as V } from "../../../Inbox/sanitizeInboxHtml.js";
4
- import { normalizeTemplatePlaceholders as v, applyTemplateVars as D } from "../../utils/templateCode.js";
5
- import { Typography as k, message as b, Modal as q, Collapse as G } from "antd";
6
- import { useState as H, useEffect as U, useMemo as I, useCallback as i } from "react";
7
- import { AUDIENCE_SLOT_OPTIONS as J, normalizeAudienceSlots as X, hasAudienceSelection as Y, ORG_TENANT_SLOT as Z } from "../audienceSlots.js";
8
- import t from "../style.module.scss.js";
9
- import { Input as A, Select as C } from "../../../../FormInfo/fields.js";
10
- import W from "../../../../FormInfo/FormModal.js";
11
- import ee from "../../../../FormInfo/FormInfo.js";
12
- import oe from "../../../../FormInfo/FormItem.js";
13
- const K = {
1
+ import { jsx as t, jsxs as y } from "react/jsx-runtime";
2
+ import { RichTextField as q } from "../../../../FormInfo/RichTextField/index.js";
3
+ import { ensureRichTextBlockHtml as L, unwrapMsgVarSpansForStorage as G } from "../../../../Editor/variableMention.js";
4
+ import { sanitizeInboxHtml as U } from "../../../Inbox/sanitizeInboxHtml.js";
5
+ import { normalizeTemplatePlaceholders as b, applyTemplateVars as O } from "../../utils/templateCode.js";
6
+ import { message as T, Modal as J, Typography as D, Collapse as X } from "antd";
7
+ import { useState as A, useRef as Y, useEffect as Z, useMemo as P, useCallback as i } from "react";
8
+ import { AUDIENCE_SLOT_OPTIONS as W, normalizeAudienceSlots as ee, hasAudienceSelection as oe, ORG_TENANT_SLOT as le } from "../audienceSlots.js";
9
+ import s from "../style.module.scss.js";
10
+ import { Input as V, Select as I } from "../../../../FormInfo/fields.js";
11
+ import te from "../../../../FormInfo/FormModal.js";
12
+ import se from "../../../../FormInfo/FormInfo.js";
13
+ import re from "../../../../FormInfo/FormItem.js";
14
+ const C = {
14
15
  getPopupContainer: () => document.body,
15
16
  styles: { popup: { root: { zIndex: 2e3 } } }
16
- }, ye = ({
17
- open: w,
17
+ }, ve = ({
18
+ open: S,
18
19
  isCreate: n,
19
20
  initial: e,
20
21
  catalog: p,
21
- roleOptions: S,
22
- variables: T,
22
+ roleOptions: R,
23
+ variables: h,
23
24
  catalogError: u,
24
- previewVars: F,
25
+ previewVars: K,
25
26
  canWrite: r,
26
- onCancel: R,
27
- onSubmit: M,
27
+ onCancel: x,
28
+ onSubmit: F,
28
29
  renderAudienceField: a
29
30
  }) => {
30
- const [x, E] = H([]), [N, h] = H(!1);
31
- U(() => {
32
- if (!w || !e) {
33
- h(!1);
31
+ const [N, M] = A([]), [E, g] = A(!1), v = Y("");
32
+ Z(() => {
33
+ if (!S || !e) {
34
+ g(!1), v.current = "";
34
35
  return;
35
36
  }
36
- E(e.audienceRoles || e.roles || []);
37
- const o = window.requestAnimationFrame(() => h(!0));
37
+ M(e.audienceRoles || e.roles || []), v.current = L(
38
+ b(e.bodyTemplate || "")
39
+ );
40
+ const o = window.requestAnimationFrame(() => g(!0));
38
41
  return () => window.cancelAnimationFrame(o);
39
- }, [w, e]);
40
- const _ = (e == null ? void 0 : e.id) || (e == null ? void 0 : e.code) || (n ? "create" : "edit"), P = I(() => e ? {
42
+ }, [S, e]);
43
+ const H = (e == null ? void 0 : e.id) || (e == null ? void 0 : e.code) || (n ? "create" : "edit"), k = P(() => e ? {
41
44
  code: e.code,
42
45
  eventKey: e.eventKey,
43
46
  scenario: e.scenario || e.label || "",
44
- titleTemplate: v(
47
+ titleTemplate: b(
45
48
  e.titleTemplate || e.titlePreview || ""
46
49
  ),
47
- bodyTemplate: v(e.bodyTemplate || ""),
50
+ // seed/库内常为无 <p> 纯文本;先块级化,避免 RTE setData 丢正文
51
+ bodyTemplate: L(
52
+ b(e.bodyTemplate || "")
53
+ ),
48
54
  audienceRoles: e.audienceRoles || e.roles || [],
49
55
  audienceSlots: e.audienceSlots || []
50
- } : {}, [e]), z = u ? `目录加载失败,无法插入变量(${u})` : T.length === 0 ? "暂无 catalog 变量" : "", B = i((o) => {
51
- h(!!o);
52
- }, []), $ = I(() => {
53
- if (!N)
54
- return [
55
- /* @__PURE__ */ s(k.Text, { type: "secondary", children: "加载编辑器…" }, "loading")
56
- ];
56
+ } : {}, [e]), _ = u ? `目录加载失败,无法插入变量(${u})` : h.length === 0 ? "暂无 catalog 变量" : "", $ = i((o) => {
57
+ g(!!o);
58
+ }, []), j = P(() => {
57
59
  const o = [];
58
- return n || o.push(/* @__PURE__ */ s(A, { name: "code", label: "编号", disabled: !0 }, "code")), o.push(
59
- /* @__PURE__ */ s(
60
- C,
60
+ return n || o.push(/* @__PURE__ */ t(V, { name: "code", label: "编号", disabled: !0 }, "code")), o.push(
61
+ /* @__PURE__ */ t(
62
+ I,
61
63
  {
62
64
  name: "eventKey",
63
65
  label: "适用场景",
@@ -69,71 +71,74 @@ const K = {
69
71
  label: l.label || l.eventKey
70
72
  })),
71
73
  placeholder: p.length ? "选择场景" : "暂无事件目录",
72
- ...K
74
+ ...C
73
75
  },
74
76
  "eventKey"
75
77
  ),
76
- /* @__PURE__ */ s(
77
- A,
78
+ /* @__PURE__ */ t(
79
+ V,
78
80
  {
79
81
  name: "titleTemplate",
80
82
  label: "标题模板",
81
83
  rule: "REQ",
82
84
  disabled: !r,
83
85
  enableVariableMention: !0,
84
- variables: T,
86
+ variables: h,
85
87
  catalogError: u,
86
88
  placeholder: "点「插入变量」选择 catalog 变量",
87
89
  labelTips: n ? "新建默认停用。标题:点「插入变量」插入明文 {{key}}(可手改)。正文:原子色块,不可改字,整颗删除。" : "标题可手改 {{key}};正文为原子色块(不可改字、Backspace 整颗删)。"
88
90
  },
89
91
  "titleTemplate"
90
92
  ),
91
- /* @__PURE__ */ s(
92
- Q,
93
+ /* @__PURE__ */ t(
94
+ q,
93
95
  {
94
96
  name: "bodyTemplate",
95
97
  label: "正文模板",
96
98
  disabled: !r,
97
99
  enableVariableMention: !0,
98
- variables: T,
100
+ variables: h,
99
101
  catalogError: u,
100
- editorKey: _,
102
+ editorKey: H,
101
103
  placeholder: "编辑正文,点「插入变量」",
102
- minHeight: 160
104
+ minHeight: 160,
105
+ onEditorHtml: (l) => {
106
+ v.current = l;
107
+ }
103
108
  },
104
109
  "bodyTemplate"
105
110
  )
106
111
  ), a || o.push(
107
- /* @__PURE__ */ s(
108
- C,
112
+ /* @__PURE__ */ t(
113
+ I,
109
114
  {
110
115
  name: "audienceRoles",
111
116
  label: "受众角色",
112
117
  mode: "multiple",
113
118
  allowClear: !0,
114
119
  disabled: !r,
115
- options: S.map((l) => ({
120
+ options: R.map((l) => ({
116
121
  value: l.code,
117
122
  label: l.name || l.code
118
123
  })),
119
124
  optionFilterProp: "label",
120
125
  maxTagCount: "responsive",
121
- placeholder: S.length ? "下拉选择角色(可多选)" : "暂无角色数据",
126
+ placeholder: R.length ? "下拉选择角色(可多选)" : "暂无角色数据",
122
127
  notFoundContent: "暂无角色",
123
128
  labelTips: "可与「通知范围」并存;至少选角色或槽位之一。emit 与显式 userIds 并集送达。",
124
- ...K
129
+ ...C
125
130
  },
126
131
  "audienceRoles"
127
132
  ),
128
- /* @__PURE__ */ s(
129
- C,
133
+ /* @__PURE__ */ t(
134
+ I,
130
135
  {
131
136
  name: "audienceSlots",
132
137
  label: "通知范围",
133
138
  mode: "multiple",
134
139
  allowClear: !0,
135
140
  disabled: !r,
136
- options: J.map((l) => ({
141
+ options: W.map((l) => ({
137
142
  value: l.value,
138
143
  label: l.label
139
144
  })),
@@ -142,114 +147,118 @@ const K = {
142
147
  placeholder: "可选:本人/领导/部门/分厂/租户或任务当事人",
143
148
  notFoundContent: "暂无槽位",
144
149
  labelTips: "依赖业务 emit.audienceContext;无上下文的槽不会发出。选「本租户」保存前会确认。",
145
- ...K
150
+ ...C
146
151
  },
147
152
  "audienceSlots"
148
153
  )
149
154
  ), o;
150
155
  }, [
151
- N,
156
+ E,
152
157
  n,
153
158
  r,
154
159
  p,
155
- T,
156
- _,
160
+ h,
161
+ H,
157
162
  u,
158
163
  a,
159
- S
160
- ]), j = I(
164
+ R
165
+ ]), Q = P(
161
166
  () => ({
162
- data: P,
167
+ data: k,
163
168
  onSubmit: async (o) => {
164
169
  if (!r)
165
- return b.warning("当前为只读(业务未授予写权限)"), !1;
170
+ return T.warning("当前为只读(业务未授予写权限)"), !1;
166
171
  const l = String(o.eventKey || "").trim();
167
172
  if (!l)
168
- return b.warning("请选择适用场景"), !1;
169
- const g = v(String(o.titleTemplate || ""));
170
- if (!g.trim())
171
- return b.warning("请填写标题模板"), !1;
172
- const f = a ? x : Array.isArray(o.audienceRoles) ? o.audienceRoles : [], m = X(o.audienceSlots || []);
173
- if (!Y({
173
+ return T.warning("请选择适用场景"), !1;
174
+ const w = b(String(o.titleTemplate || ""));
175
+ if (!w.trim())
176
+ return T.warning("请填写标题模板"), !1;
177
+ const f = a ? N : Array.isArray(o.audienceRoles) ? o.audienceRoles : [], m = ee(o.audienceSlots || []);
178
+ if (!oe({
174
179
  roles: f,
175
180
  slots: m,
176
181
  userIds: null
177
182
  }))
178
- return b.warning("请选择受众角色或通知范围(至少一个)"), !1;
179
- if (m.includes(Z) && !await new Promise((O) => {
180
- q.confirm({
183
+ return T.warning("请选择受众角色或通知范围(至少一个)"), !1;
184
+ if (m.includes(le) && !await new Promise((B) => {
185
+ J.confirm({
181
186
  title: "确认通知本租户全员?",
182
187
  content: "已选「本租户(全公司)」:将向当前租户内用户展开(≠跨租户)。确认保存?",
183
188
  okText: "确认保存",
184
189
  cancelText: "取消",
185
- onOk: () => O(!0),
186
- onCancel: () => O(!1)
190
+ onOk: () => B(!0),
191
+ onCancel: () => B(!1)
187
192
  });
188
193
  }))
189
194
  return !1;
190
- const d = p.find((c) => c.eventKey === l), L = String((d == null ? void 0 : d.label) || o.scenario || l).trim();
195
+ const c = p.find((d) => d.eventKey === l), z = String((c == null ? void 0 : c.label) || o.scenario || l).trim();
191
196
  try {
192
- await M({
197
+ await F({
193
198
  ...e || {},
194
199
  code: o.code || (e == null ? void 0 : e.code),
195
200
  eventKey: l,
196
- scenario: L,
197
- label: L,
198
- messageType: (d == null ? void 0 : d.messageType) || (e == null ? void 0 : e.messageType) || "alert",
199
- titleTemplate: g,
200
- bodyTemplate: v(String(o.bodyTemplate || "")),
201
+ scenario: z,
202
+ label: z,
203
+ messageType: (c == null ? void 0 : c.messageType) || (e == null ? void 0 : e.messageType) || "alert",
204
+ titleTemplate: w,
205
+ bodyTemplate: G(
206
+ b(
207
+ String(v.current || o.bodyTemplate || "")
208
+ )
209
+ ),
201
210
  audienceRoles: f,
202
211
  roles: f,
203
212
  audienceSlots: m,
204
213
  enabled: n ? !1 : (e == null ? void 0 : e.enabled) !== !1,
205
214
  channel: (e == null ? void 0 : e.channel) || "in_app"
206
- }), R();
207
- } catch (c) {
208
- return b.error(c instanceof Error ? c.message : String(c)), !1;
215
+ }), x();
216
+ } catch (d) {
217
+ return T.error(d instanceof Error ? d.message : String(d)), !1;
209
218
  }
210
219
  }
211
220
  }),
212
221
  [
213
- P,
222
+ k,
214
223
  r,
215
224
  p,
216
- M,
225
+ F,
217
226
  e,
218
- x,
227
+ N,
219
228
  n,
220
- R,
229
+ x,
221
230
  a
222
231
  ]
223
232
  );
224
233
  return /* @__PURE__ */ y(
225
- W,
234
+ te,
226
235
  {
227
236
  title: n ? "新建模板" : "编辑模板",
228
- open: w,
229
- onCancel: R,
237
+ open: S,
238
+ onCancel: x,
230
239
  width: 720,
231
240
  size: "small",
232
241
  className: "msg-center-form-modal",
233
242
  okText: "保存",
234
243
  autoClose: !1,
235
244
  focusable: { trap: !1 },
236
- afterOpenChange: B,
237
- formProps: j,
245
+ afterOpenChange: $,
246
+ formProps: Q,
238
247
  children: [
239
- /* @__PURE__ */ s(ee, { column: 1, list: $ }),
240
- a ? /* @__PURE__ */ y("div", { className: t.audienceBlock, children: [
241
- /* @__PURE__ */ y(k.Text, { className: t.audienceLabel, children: [
242
- /* @__PURE__ */ s("span", { style: { color: "#ff4d4f", marginRight: 4 }, children: "*" }),
248
+ /* @__PURE__ */ t(se, { column: 1, list: j }),
249
+ a ? /* @__PURE__ */ y("div", { className: s.audienceBlock, children: [
250
+ /* @__PURE__ */ y(D.Text, { className: s.audienceLabel, children: [
251
+ /* @__PURE__ */ t("span", { style: { color: "#ff4d4f", marginRight: 4 }, children: "*" }),
243
252
  "受众角色"
244
253
  ] }),
245
- a({ roles: x, onChange: E })
254
+ a({ roles: N, onChange: M })
246
255
  ] }) : null,
247
- N ? /* @__PURE__ */ s(oe, { children: (o) => {
248
- const l = (typeof o.getFormData == "function" ? o.getFormData() : void 0) ?? o.formData ?? P, g = D(String(l.titleTemplate || ""), F), f = D(String(l.bodyTemplate || ""), F), m = V(f);
249
- return /* @__PURE__ */ y("div", { className: t.previewCollapse, children: [
250
- z ? /* @__PURE__ */ s(k.Text, { type: "secondary", children: z }) : null,
251
- /* @__PURE__ */ s(
252
- G,
256
+ E ? /* @__PURE__ */ t(re, { children: (o) => {
257
+ const l = (typeof o.getFormData == "function" ? o.getFormData() : void 0) ?? o.formData ?? k, w = O(String(l.titleTemplate || ""), K), f = O(String(l.bodyTemplate || ""), K), m = U(f);
258
+ return /* @__PURE__ */ y("div", { className: s.previewCollapse, children: [
259
+ _ ? /* @__PURE__ */ t(D.Text, { type: "secondary", children: _ }) : null,
260
+ /* @__PURE__ */ t(
261
+ X,
253
262
  {
254
263
  ghost: !0,
255
264
  size: "small",
@@ -257,15 +266,15 @@ const K = {
257
266
  {
258
267
  key: "preview",
259
268
  label: "效果预览",
260
- children: /* @__PURE__ */ y("div", { className: t.previewCard, children: [
261
- /* @__PURE__ */ s("div", { className: t.previewTitle, children: g.trim() || /* @__PURE__ */ s("span", { className: t.previewEmpty, children: "(无标题)" }) }),
262
- m ? /* @__PURE__ */ s(
269
+ children: /* @__PURE__ */ y("div", { className: s.previewCard, children: [
270
+ /* @__PURE__ */ t("div", { className: s.previewTitle, children: w.trim() || /* @__PURE__ */ t("span", { className: s.previewEmpty, children: "(无标题)" }) }),
271
+ m ? /* @__PURE__ */ t(
263
272
  "div",
264
273
  {
265
- className: t.previewBody,
274
+ className: s.previewBody,
266
275
  dangerouslySetInnerHTML: { __html: m }
267
276
  }
268
- ) : /* @__PURE__ */ s("div", { className: `${t.previewBody} ${t.previewEmpty}`, children: "(无正文)" })
277
+ ) : /* @__PURE__ */ t("div", { className: `${s.previewBody} ${s.previewEmpty}`, children: "(无正文)" })
269
278
  ] })
270
279
  }
271
280
  ]
@@ -278,6 +287,6 @@ const K = {
278
287
  );
279
288
  };
280
289
  export {
281
- ye as TemplateFormModal
290
+ ve as TemplateFormModal
282
291
  };
283
292
  //# sourceMappingURL=TemplateFormModal.js.map