@hkyhy/marsun-components-core 0.1.99 → 0.1.100
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.
- package/dist/components/Editor/RichTextEditor/RichTextEditor.js +36 -45
- package/dist/components/Editor/RichTextEditor/RichTextEditor.js.map +1 -1
- package/dist/components/Editor/msgVarTokenPlugin.js +14 -19
- package/dist/components/Editor/msgVarTokenPlugin.js.map +1 -1
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/MessageTemplateAdmin.js +193 -145
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/MessageTemplateAdmin.js.map +1 -1
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/PushRulesPanel/index.d.ts +18 -0
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/PushRulesPanel/index.js +315 -0
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/PushRulesPanel/index.js.map +1 -0
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/VariablesPanel/index.d.ts +14 -0
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/VariablesPanel/index.js +183 -0
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/VariablesPanel/index.js.map +1 -0
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/index.d.ts +1 -1
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/types.d.ts +26 -0
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/types.js +5 -3
- package/dist/components/Tools/MessageCenter/MessageTemplateAdmin/types.js.map +1 -1
- package/dist/components/Tools/MessageCenter/index.d.ts +1 -1
- package/dist/components/Tools/MessageCenter/utils/adminGuards.d.ts +14 -0
- package/dist/components/Tools/MessageCenter/utils/adminGuards.js +12 -0
- package/dist/components/Tools/MessageCenter/utils/adminGuards.js.map +1 -0
- package/package.json +1 -1
- package/dist/node_modules/@ckeditor/ckeditor5-basic-styles/dist/index.js +0 -301
- package/dist/node_modules/@ckeditor/ckeditor5-basic-styles/dist/index.js.map +0 -1
- package/dist/node_modules/@ckeditor/ckeditor5-clipboard/dist/index.js +0 -1256
- package/dist/node_modules/@ckeditor/ckeditor5-clipboard/dist/index.js.map +0 -1
- package/dist/node_modules/@ckeditor/ckeditor5-core/dist/index.js +0 -2107
- package/dist/node_modules/@ckeditor/ckeditor5-core/dist/index.js.map +0 -1
- package/dist/node_modules/@ckeditor/ckeditor5-editor-classic/dist/index.js +0 -259
- package/dist/node_modules/@ckeditor/ckeditor5-editor-classic/dist/index.js.map +0 -1
- package/dist/node_modules/@ckeditor/ckeditor5-engine/dist/index.js +0 -23990
- package/dist/node_modules/@ckeditor/ckeditor5-engine/dist/index.js.map +0 -1
- package/dist/node_modules/@ckeditor/ckeditor5-enter/dist/index.js +0 -249
- package/dist/node_modules/@ckeditor/ckeditor5-enter/dist/index.js.map +0 -1
- package/dist/node_modules/@ckeditor/ckeditor5-essentials/dist/index.js +0 -47
- package/dist/node_modules/@ckeditor/ckeditor5-essentials/dist/index.js.map +0 -1
- package/dist/node_modules/@ckeditor/ckeditor5-font/dist/index.js +0 -100
- package/dist/node_modules/@ckeditor/ckeditor5-font/dist/index.js.map +0 -1
- package/dist/node_modules/@ckeditor/ckeditor5-icons/dist/index.js +0 -31
- package/dist/node_modules/@ckeditor/ckeditor5-icons/dist/index.js.map +0 -1
- package/dist/node_modules/@ckeditor/ckeditor5-integrations-common/dist/index.js +0 -194
- package/dist/node_modules/@ckeditor/ckeditor5-integrations-common/dist/index.js.map +0 -1
- package/dist/node_modules/@ckeditor/ckeditor5-list/dist/index.js +0 -2042
- package/dist/node_modules/@ckeditor/ckeditor5-list/dist/index.js.map +0 -1
- package/dist/node_modules/@ckeditor/ckeditor5-mention/dist/index.js +0 -9
- package/dist/node_modules/@ckeditor/ckeditor5-mention/dist/index.js.map +0 -1
- package/dist/node_modules/@ckeditor/ckeditor5-paragraph/dist/index.js +0 -167
- package/dist/node_modules/@ckeditor/ckeditor5-paragraph/dist/index.js.map +0 -1
- package/dist/node_modules/@ckeditor/ckeditor5-react/dist/index.js +0 -471
- package/dist/node_modules/@ckeditor/ckeditor5-react/dist/index.js.map +0 -1
- package/dist/node_modules/@ckeditor/ckeditor5-select-all/dist/index.js +0 -139
- package/dist/node_modules/@ckeditor/ckeditor5-select-all/dist/index.js.map +0 -1
- package/dist/node_modules/@ckeditor/ckeditor5-typing/dist/index.js +0 -755
- package/dist/node_modules/@ckeditor/ckeditor5-typing/dist/index.js.map +0 -1
- package/dist/node_modules/@ckeditor/ckeditor5-ui/dist/index.js +0 -7838
- package/dist/node_modules/@ckeditor/ckeditor5-ui/dist/index.js.map +0 -1
- package/dist/node_modules/@ckeditor/ckeditor5-ui/node_modules/color-convert/conversions.js +0 -422
- package/dist/node_modules/@ckeditor/ckeditor5-ui/node_modules/color-convert/conversions.js.map +0 -1
- package/dist/node_modules/@ckeditor/ckeditor5-ui/node_modules/color-convert/index.js +0 -33
- package/dist/node_modules/@ckeditor/ckeditor5-ui/node_modules/color-convert/index.js.map +0 -1
- package/dist/node_modules/@ckeditor/ckeditor5-ui/node_modules/color-convert/route.js +0 -47
- package/dist/node_modules/@ckeditor/ckeditor5-ui/node_modules/color-convert/route.js.map +0 -1
- package/dist/node_modules/@ckeditor/ckeditor5-ui/node_modules/color-name/index.js +0 -156
- package/dist/node_modules/@ckeditor/ckeditor5-ui/node_modules/color-name/index.js.map +0 -1
- package/dist/node_modules/@ckeditor/ckeditor5-undo/dist/index.js +0 -313
- package/dist/node_modules/@ckeditor/ckeditor5-undo/dist/index.js.map +0 -1
- package/dist/node_modules/@ckeditor/ckeditor5-utils/dist/index.js +0 -2942
- package/dist/node_modules/@ckeditor/ckeditor5-utils/dist/index.js.map +0 -1
- package/dist/node_modules/@ckeditor/ckeditor5-watchdog/dist/index.js +0 -892
- package/dist/node_modules/@ckeditor/ckeditor5-watchdog/dist/index.js.map +0 -1
- package/dist/node_modules/@ckeditor/ckeditor5-widget/dist/index.js +0 -1047
- package/dist/node_modules/@ckeditor/ckeditor5-widget/dist/index.js.map +0 -1
- package/dist/node_modules/color-parse/node_modules/color-name/index.js +0 -153
- package/dist/node_modules/color-parse/node_modules/color-name/index.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/_internal/globalThis.js +0 -7
- package/dist/node_modules/es-toolkit/dist/_internal/globalThis.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/_internal/isUnsafeProperty.js +0 -7
- package/dist/node_modules/es-toolkit/dist/_internal/isUnsafeProperty.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/_internal/isUnsafeToWriteProperty.js +0 -7
- package/dist/node_modules/es-toolkit/dist/_internal/isUnsafeToWriteProperty.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/_internal/assignValue.js +0 -9
- package/dist/node_modules/es-toolkit/dist/compat/_internal/assignValue.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/_internal/getSymbols.js +0 -7
- package/dist/node_modules/es-toolkit/dist/compat/_internal/getSymbols.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/_internal/getTag.js +0 -7
- package/dist/node_modules/es-toolkit/dist/compat/_internal/getTag.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/_internal/isDeepKey.js +0 -16
- package/dist/node_modules/es-toolkit/dist/compat/_internal/isDeepKey.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/_internal/isIndex.js +0 -15
- package/dist/node_modules/es-toolkit/dist/compat/_internal/isIndex.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/_internal/isKey.js +0 -9
- package/dist/node_modules/es-toolkit/dist/compat/_internal/isKey.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/_internal/isPrototype.js +0 -8
- package/dist/node_modules/es-toolkit/dist/compat/_internal/isPrototype.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/_internal/tags.js +0 -30
- package/dist/node_modules/es-toolkit/dist/compat/_internal/tags.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/_internal/toKey.js +0 -8
- package/dist/node_modules/es-toolkit/dist/compat/_internal/toKey.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/function/debounce.js +0 -17
- package/dist/node_modules/es-toolkit/dist/compat/function/debounce.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/function/throttle.js +0 -13
- package/dist/node_modules/es-toolkit/dist/compat/function/throttle.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/object/assignIn.js +0 -17
- package/dist/node_modules/es-toolkit/dist/compat/object/assignIn.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/object/clone.js +0 -102
- package/dist/node_modules/es-toolkit/dist/compat/object/clone.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/object/cloneDeep.js +0 -8
- package/dist/node_modules/es-toolkit/dist/compat/object/cloneDeep.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/object/cloneDeepWith.js +0 -33
- package/dist/node_modules/es-toolkit/dist/compat/object/cloneDeepWith.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/object/get.js +0 -39
- package/dist/node_modules/es-toolkit/dist/compat/object/get.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/object/has.js +0 -21
- package/dist/node_modules/es-toolkit/dist/compat/object/has.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/object/keysIn.js +0 -33
- package/dist/node_modules/es-toolkit/dist/compat/object/keysIn.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/object/mapValues.js +0 -10
- package/dist/node_modules/es-toolkit/dist/compat/object/mapValues.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/object/merge.js +0 -9
- package/dist/node_modules/es-toolkit/dist/compat/object/merge.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/object/mergeWith.js +0 -53
- package/dist/node_modules/es-toolkit/dist/compat/object/mergeWith.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/object/property.js +0 -10
- package/dist/node_modules/es-toolkit/dist/compat/object/property.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/object/set.js +0 -9
- package/dist/node_modules/es-toolkit/dist/compat/object/set.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/object/updateWith.js +0 -31
- package/dist/node_modules/es-toolkit/dist/compat/object/updateWith.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isArguments.js +0 -8
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isArguments.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isArray.js +0 -7
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isArray.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isArrayLike.js +0 -8
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isArrayLike.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isArrayLikeObject.js +0 -9
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isArrayLikeObject.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isElement.js +0 -9
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isElement.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isEqualWith.js +0 -15
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isEqualWith.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isFunction.js +0 -7
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isFunction.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isMatch.js +0 -9
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isMatch.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isMatchWith.js +0 -81
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isMatchWith.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isObject.js +0 -7
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isObject.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isObjectLike.js +0 -7
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isObjectLike.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isPlainObject.js +0 -16
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isPlainObject.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isString.js +0 -7
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isString.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isSymbol.js +0 -7
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isSymbol.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isTypedArray.js +0 -8
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isTypedArray.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/predicate/matches.js +0 -9
- package/dist/node_modules/es-toolkit/dist/compat/predicate/matches.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/predicate/matchesProperty.js +0 -23
- package/dist/node_modules/es-toolkit/dist/compat/predicate/matchesProperty.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/util/eq.js +0 -7
- package/dist/node_modules/es-toolkit/dist/compat/util/eq.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/util/iteratee.js +0 -19
- package/dist/node_modules/es-toolkit/dist/compat/util/iteratee.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/util/times.js +0 -11
- package/dist/node_modules/es-toolkit/dist/compat/util/times.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/util/toFinite.js +0 -8
- package/dist/node_modules/es-toolkit/dist/compat/util/toFinite.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/util/toInteger.js +0 -9
- package/dist/node_modules/es-toolkit/dist/compat/util/toInteger.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/util/toNumber.js +0 -8
- package/dist/node_modules/es-toolkit/dist/compat/util/toNumber.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/util/toPath.js +0 -37
- package/dist/node_modules/es-toolkit/dist/compat/util/toPath.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/compat/util/toString.js +0 -15
- package/dist/node_modules/es-toolkit/dist/compat/util/toString.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/function/after.js +0 -11
- package/dist/node_modules/es-toolkit/dist/function/after.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/function/debounce.js +0 -30
- package/dist/node_modules/es-toolkit/dist/function/debounce.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/function/identity.js +0 -7
- package/dist/node_modules/es-toolkit/dist/function/identity.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/function/noop.js +0 -6
- package/dist/node_modules/es-toolkit/dist/function/noop.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/object/clone.js +0 -27
- package/dist/node_modules/es-toolkit/dist/object/clone.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/object/cloneDeep.js +0 -8
- package/dist/node_modules/es-toolkit/dist/object/cloneDeep.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/object/cloneDeepWith.js +0 -121
- package/dist/node_modules/es-toolkit/dist/object/cloneDeepWith.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/object/mapValues.js +0 -12
- package/dist/node_modules/es-toolkit/dist/object/mapValues.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/predicate/isBuffer.js +0 -8
- package/dist/node_modules/es-toolkit/dist/predicate/isBuffer.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/predicate/isEqual.js +0 -9
- package/dist/node_modules/es-toolkit/dist/predicate/isEqual.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/predicate/isEqualWith.js +0 -110
- package/dist/node_modules/es-toolkit/dist/predicate/isEqualWith.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/predicate/isLength.js +0 -7
- package/dist/node_modules/es-toolkit/dist/predicate/isLength.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/predicate/isPlainObject.js +0 -9
- package/dist/node_modules/es-toolkit/dist/predicate/isPlainObject.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/predicate/isPrimitive.js +0 -7
- package/dist/node_modules/es-toolkit/dist/predicate/isPrimitive.js.map +0 -1
- package/dist/node_modules/es-toolkit/dist/predicate/isTypedArray.js +0 -7
- package/dist/node_modules/es-toolkit/dist/predicate/isTypedArray.js.map +0 -1
|
@@ -1,85 +1,76 @@
|
|
|
1
|
-
import { jsxs as K, jsx as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import "
|
|
4
|
-
import "
|
|
5
|
-
import { Bold as x, Italic as R } from "../../../node_modules/@ckeditor/ckeditor5-basic-styles/dist/index.js";
|
|
6
|
-
import { Widget as T } from "../../../node_modules/@ckeditor/ckeditor5-widget/dist/index.js";
|
|
7
|
-
import { Undo as $ } from "../../../node_modules/@ckeditor/ckeditor5-undo/dist/index.js";
|
|
8
|
-
import { ClassicEditor as W } from "../../../node_modules/@ckeditor/ckeditor5-editor-classic/dist/index.js";
|
|
9
|
-
import { Essentials as k } from "../../../node_modules/@ckeditor/ckeditor5-essentials/dist/index.js";
|
|
10
|
-
import { Paragraph as v } from "../../../node_modules/@ckeditor/ckeditor5-paragraph/dist/index.js";
|
|
11
|
-
import { List as P } from "../../../node_modules/@ckeditor/ckeditor5-list/dist/index.js";
|
|
12
|
-
import "../../../node_modules/@ckeditor/ckeditor5-mention/dist/index.js";
|
|
13
|
-
import { CKEditor as b } from "../../../node_modules/@ckeditor/ckeditor5-react/dist/index.js";
|
|
1
|
+
import { jsxs as K, jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as e, useMemo as N } from "react";
|
|
3
|
+
import { Essentials as x, Paragraph as R, Bold as $, Italic as k, List as v, Undo as P, Widget as T, ClassicEditor as W } from "ckeditor5";
|
|
4
|
+
import { CKEditor as b } from "@ckeditor/ckeditor5-react";
|
|
14
5
|
/* empty css */
|
|
15
6
|
import { wrapVarTokensForDisplay as q } from "../variableMention.js";
|
|
16
7
|
import { MsgVarWidget as w, insertMsgVar as B } from "../msgVarTokenPlugin.js";
|
|
17
8
|
import { VariablePicker as F } from "../VariablePicker.js";
|
|
18
|
-
import
|
|
19
|
-
const
|
|
20
|
-
value:
|
|
21
|
-
onChange:
|
|
22
|
-
disabled:
|
|
23
|
-
readOnly:
|
|
24
|
-
placeholder:
|
|
9
|
+
import r from "./style.module.scss.js";
|
|
10
|
+
const Q = ({
|
|
11
|
+
value: d = "",
|
|
12
|
+
onChange: a,
|
|
13
|
+
disabled: l = !1,
|
|
14
|
+
readOnly: u = !1,
|
|
15
|
+
placeholder: m,
|
|
25
16
|
minHeight: E = 140,
|
|
26
|
-
className:
|
|
17
|
+
className: f,
|
|
27
18
|
enableVariableMention: o = !1,
|
|
28
19
|
variables: L,
|
|
29
20
|
catalogError: C
|
|
30
21
|
}) => {
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
o ? q(
|
|
22
|
+
const p = e(null), g = e(null), s = e(a);
|
|
23
|
+
s.current = a;
|
|
24
|
+
const n = e(!1), D = e(
|
|
25
|
+
o ? q(d || "") : d || ""
|
|
35
26
|
), j = N(() => ({
|
|
36
27
|
licenseKey: "GPL",
|
|
37
28
|
toolbar: ["undo", "redo", "|", "bold", "italic", "|", "bulletedList", "numberedList"],
|
|
38
|
-
placeholder:
|
|
39
|
-
plugins: o ? [
|
|
40
|
-
}), [o,
|
|
29
|
+
placeholder: m,
|
|
30
|
+
plugins: o ? [x, R, $, k, v, P, T, w] : [x, R, $, k, v, P]
|
|
31
|
+
}), [o, m]), h = l || u;
|
|
41
32
|
return /* @__PURE__ */ K(
|
|
42
33
|
"div",
|
|
43
34
|
{
|
|
44
|
-
ref:
|
|
45
|
-
className:
|
|
35
|
+
ref: p,
|
|
36
|
+
className: f ? `${r.root} ${r["rich-text-editor"]} ${f}` : `${r.root} ${r["rich-text-editor"]}`,
|
|
46
37
|
style: { "--rte-min-height": `${E}px` },
|
|
47
|
-
"data-disabled":
|
|
48
|
-
"data-readonly":
|
|
38
|
+
"data-disabled": l ? "1" : "0",
|
|
39
|
+
"data-readonly": u ? "1" : "0",
|
|
49
40
|
"data-var-mention": o ? "1" : "0",
|
|
50
41
|
children: [
|
|
51
|
-
o ? /* @__PURE__ */
|
|
42
|
+
o ? /* @__PURE__ */ c("div", { className: r["var-toolbar"], children: /* @__PURE__ */ c(
|
|
52
43
|
F,
|
|
53
44
|
{
|
|
54
45
|
variables: L,
|
|
55
46
|
catalogError: C,
|
|
56
47
|
disabled: h,
|
|
57
|
-
getPopupContainer: () =>
|
|
58
|
-
onPick: (
|
|
59
|
-
const
|
|
60
|
-
|
|
48
|
+
getPopupContainer: () => p.current || document.body,
|
|
49
|
+
onPick: (t) => {
|
|
50
|
+
const i = g.current;
|
|
51
|
+
i && B(i, t);
|
|
61
52
|
}
|
|
62
53
|
}
|
|
63
54
|
) }) : null,
|
|
64
|
-
/* @__PURE__ */
|
|
55
|
+
/* @__PURE__ */ c("div", { className: r["editor-host"], children: /* @__PURE__ */ c(
|
|
65
56
|
b,
|
|
66
57
|
{
|
|
67
58
|
editor: W,
|
|
68
59
|
config: j,
|
|
69
60
|
disabled: h,
|
|
70
|
-
onReady: (
|
|
71
|
-
g.current =
|
|
61
|
+
onReady: (t) => {
|
|
62
|
+
g.current = t, n.current = !0;
|
|
72
63
|
try {
|
|
73
|
-
|
|
64
|
+
t.setData(D.current);
|
|
74
65
|
} finally {
|
|
75
66
|
queueMicrotask(() => {
|
|
76
|
-
|
|
67
|
+
n.current = !1;
|
|
77
68
|
});
|
|
78
69
|
}
|
|
79
70
|
},
|
|
80
|
-
onChange: (
|
|
71
|
+
onChange: (t, i) => {
|
|
81
72
|
var y;
|
|
82
|
-
|
|
73
|
+
n.current || (y = s.current) == null || y.call(s, i.getData());
|
|
83
74
|
}
|
|
84
75
|
}
|
|
85
76
|
) })
|
|
@@ -88,6 +79,6 @@ const or = ({
|
|
|
88
79
|
);
|
|
89
80
|
};
|
|
90
81
|
export {
|
|
91
|
-
|
|
82
|
+
Q as RichTextEditor
|
|
92
83
|
};
|
|
93
84
|
//# sourceMappingURL=RichTextEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextEditor.js","sources":["../../../../src/components/Editor/RichTextEditor/RichTextEditor.tsx"],"sourcesContent":["import React, { useMemo, useRef } from 'react';\nimport {\n Bold,\n ClassicEditor,\n Essentials,\n Italic,\n List,\n Paragraph,\n Undo,\n Widget,\n type Editor,\n} from 'ckeditor5';\nimport { CKEditor } from '@ckeditor/ckeditor5-react';\nimport 'ckeditor5/ckeditor5.css';\nimport { wrapVarTokensForDisplay, type VariableMentionItem } from '../variableMention';\nimport { MsgVarWidget, insertMsgVar } from '../msgVarTokenPlugin';\nimport { VariablePicker } from '../VariablePicker';\nimport styles from './style.module.scss';\n\nexport type RichTextEditorProps = {\n value?: string;\n onChange?: (html: string) => void;\n disabled?: boolean;\n readOnly?: boolean;\n placeholder?: string;\n minHeight?: number;\n className?: string;\n /**\n * 开启变量色块 +「插入变量」按钮(catalog 注入;禁 FE DEFAULT_VARS)。\n * 无 `/` 触发;色块为原子 widget。\n */\n enableVariableMention?: boolean;\n variables?: VariableMentionItem[];\n /** catalog 失败短文案(按钮 disabled 提示) */\n catalogError?: string;\n};\n\n/**\n * CKEditor 5 + Coze/Dify 风「插入变量」按钮;正文 msgVar 原子色块。\n */\nexport const RichTextEditor: React.FC<RichTextEditorProps> = ({\n value = '',\n onChange,\n disabled = false,\n readOnly = false,\n placeholder,\n minHeight = 140,\n className,\n enableVariableMention = false,\n variables,\n catalogError,\n}) => {\n const rootRef = useRef<HTMLDivElement>(null);\n const editorRef = useRef<Editor | null>(null);\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n const suppressChangeRef = useRef(false);\n\n const initialHtmlRef = useRef(\n enableVariableMention ? wrapVarTokensForDisplay(value || '') : value || '',\n );\n\n const config = useMemo(() => {\n const plugins = enableVariableMention\n ? [Essentials, Paragraph, Bold, Italic, List, Undo, Widget, MsgVarWidget]\n : [Essentials, Paragraph, Bold, Italic, List, Undo];\n return {\n licenseKey: 'GPL' as const,\n toolbar: ['undo', 'redo', '|', 'bold', 'italic', '|', 'bulletedList', 'numberedList'],\n placeholder,\n plugins,\n };\n }, [enableVariableMention, placeholder]);\n\n const locked = disabled || readOnly;\n\n return (\n <div\n ref={rootRef}\n className={\n className\n ? `${styles.root} ${styles['rich-text-editor']} ${className}`\n : `${styles.root} ${styles['rich-text-editor']}`\n }\n style={{ ['--rte-min-height' as string]: `${minHeight}px` }}\n data-disabled={disabled ? '1' : '0'}\n data-readonly={readOnly ? '1' : '0'}\n data-var-mention={enableVariableMention ? '1' : '0'}\n >\n {enableVariableMention ? (\n <div className={styles['var-toolbar']}>\n <VariablePicker\n variables={variables}\n catalogError={catalogError}\n disabled={locked}\n getPopupContainer={() => rootRef.current || document.body}\n onPick={(key) => {\n const editor = editorRef.current;\n if (!editor) return;\n insertMsgVar(editor, key);\n }}\n />\n </div>\n ) : null}\n <div className={styles['editor-host']}>\n <CKEditor\n editor={ClassicEditor}\n config={config}\n disabled={locked}\n onReady={(editor) => {\n editorRef.current = editor;\n suppressChangeRef.current = true;\n try {\n editor.setData(initialHtmlRef.current);\n } finally {\n queueMicrotask(() => {\n suppressChangeRef.current = false;\n });\n }\n }}\n onChange={(_evt, editor) => {\n if (suppressChangeRef.current) return;\n onChangeRef.current?.(editor.getData());\n }}\n />\n </div>\n </div>\n );\n};\n\nexport default RichTextEditor;\n"],"names":["RichTextEditor","value","onChange","disabled","readOnly","placeholder","minHeight","className","enableVariableMention","variables","catalogError","rootRef","useRef","editorRef","onChangeRef","suppressChangeRef","initialHtmlRef","wrapVarTokensForDisplay","config","useMemo","Essentials","Paragraph","Bold","Italic","List","Undo","Widget","MsgVarWidget","locked","jsxs","styles","jsx","VariablePicker","key","editor","insertMsgVar","CKEditor","ClassicEditor","_evt","_a"],"mappings":"
|
|
1
|
+
{"version":3,"file":"RichTextEditor.js","sources":["../../../../src/components/Editor/RichTextEditor/RichTextEditor.tsx"],"sourcesContent":["import React, { useMemo, useRef } from 'react';\nimport {\n Bold,\n ClassicEditor,\n Essentials,\n Italic,\n List,\n Paragraph,\n Undo,\n Widget,\n type Editor,\n} from 'ckeditor5';\nimport { CKEditor } from '@ckeditor/ckeditor5-react';\nimport 'ckeditor5/ckeditor5.css';\nimport { wrapVarTokensForDisplay, type VariableMentionItem } from '../variableMention';\nimport { MsgVarWidget, insertMsgVar } from '../msgVarTokenPlugin';\nimport { VariablePicker } from '../VariablePicker';\nimport styles from './style.module.scss';\n\nexport type RichTextEditorProps = {\n value?: string;\n onChange?: (html: string) => void;\n disabled?: boolean;\n readOnly?: boolean;\n placeholder?: string;\n minHeight?: number;\n className?: string;\n /**\n * 开启变量色块 +「插入变量」按钮(catalog 注入;禁 FE DEFAULT_VARS)。\n * 无 `/` 触发;色块为原子 widget。\n */\n enableVariableMention?: boolean;\n variables?: VariableMentionItem[];\n /** catalog 失败短文案(按钮 disabled 提示) */\n catalogError?: string;\n};\n\n/**\n * CKEditor 5 + Coze/Dify 风「插入变量」按钮;正文 msgVar 原子色块。\n */\nexport const RichTextEditor: React.FC<RichTextEditorProps> = ({\n value = '',\n onChange,\n disabled = false,\n readOnly = false,\n placeholder,\n minHeight = 140,\n className,\n enableVariableMention = false,\n variables,\n catalogError,\n}) => {\n const rootRef = useRef<HTMLDivElement>(null);\n const editorRef = useRef<Editor | null>(null);\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n const suppressChangeRef = useRef(false);\n\n const initialHtmlRef = useRef(\n enableVariableMention ? wrapVarTokensForDisplay(value || '') : value || '',\n );\n\n const config = useMemo(() => {\n const plugins = enableVariableMention\n ? [Essentials, Paragraph, Bold, Italic, List, Undo, Widget, MsgVarWidget]\n : [Essentials, Paragraph, Bold, Italic, List, Undo];\n return {\n licenseKey: 'GPL' as const,\n toolbar: ['undo', 'redo', '|', 'bold', 'italic', '|', 'bulletedList', 'numberedList'],\n placeholder,\n plugins,\n };\n }, [enableVariableMention, placeholder]);\n\n const locked = disabled || readOnly;\n\n return (\n <div\n ref={rootRef}\n className={\n className\n ? `${styles.root} ${styles['rich-text-editor']} ${className}`\n : `${styles.root} ${styles['rich-text-editor']}`\n }\n style={{ ['--rte-min-height' as string]: `${minHeight}px` }}\n data-disabled={disabled ? '1' : '0'}\n data-readonly={readOnly ? '1' : '0'}\n data-var-mention={enableVariableMention ? '1' : '0'}\n >\n {enableVariableMention ? (\n <div className={styles['var-toolbar']}>\n <VariablePicker\n variables={variables}\n catalogError={catalogError}\n disabled={locked}\n getPopupContainer={() => rootRef.current || document.body}\n onPick={(key) => {\n const editor = editorRef.current;\n if (!editor) return;\n insertMsgVar(editor, key);\n }}\n />\n </div>\n ) : null}\n <div className={styles['editor-host']}>\n <CKEditor\n editor={ClassicEditor}\n config={config}\n disabled={locked}\n onReady={(editor) => {\n editorRef.current = editor;\n suppressChangeRef.current = true;\n try {\n editor.setData(initialHtmlRef.current);\n } finally {\n queueMicrotask(() => {\n suppressChangeRef.current = false;\n });\n }\n }}\n onChange={(_evt, editor) => {\n if (suppressChangeRef.current) return;\n onChangeRef.current?.(editor.getData());\n }}\n />\n </div>\n </div>\n );\n};\n\nexport default RichTextEditor;\n"],"names":["RichTextEditor","value","onChange","disabled","readOnly","placeholder","minHeight","className","enableVariableMention","variables","catalogError","rootRef","useRef","editorRef","onChangeRef","suppressChangeRef","initialHtmlRef","wrapVarTokensForDisplay","config","useMemo","Essentials","Paragraph","Bold","Italic","List","Undo","Widget","MsgVarWidget","locked","jsxs","styles","jsx","VariablePicker","key","editor","insertMsgVar","CKEditor","ClassicEditor","_evt","_a"],"mappings":";;;;;;;;;AAwCO,MAAMA,IAAgD,CAAC;AAAA,EAC5D,OAAAC,IAAQ;AAAA,EACR,UAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EAC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AA,YACC,WAAAvB;AAAA,YACA,cAAAC;AAAA,YACA,UAAUkB;AAAA,YACV,mBAAmB,MAAMjB,EAAQ,WAAW,SAAS;AAAA,YACrD,QAAQ,CAACsB,MAAQ;AACf,oBAAMC,IAASrB,EAAU;AACzB,cAAKqB,KACLC,EAAaD,GAAQD,CAAG;AAAA,YAC1B;AAAA,UAAA;AAAA,QAAA,GAEJ,IACE;AAAA,QACJ,gBAAAF,EAAC,OAAA,EAAI,WAAWD,EAAO,aAAa,GAClC,UAAA,gBAAAC;AAAA,UAACK;AAAA,UAAA;AAAA,YACC,QAAQC;AAAA,YACR,QAAAnB;AAAA,YACA,UAAUU;AAAA,YACV,SAAS,CAACM,MAAW;AACnB,cAAArB,EAAU,UAAUqB,GACpBnB,EAAkB,UAAU;AAC5B,kBAAI;AACF,gBAAAmB,EAAO,QAAQlB,EAAe,OAAO;AAAA,cACvC,UAAA;AACE,+BAAe,MAAM;AACnB,kBAAAD,EAAkB,UAAU;AAAA,gBAC9B,CAAC;AAAA,cACH;AAAA,YACF;AAAA,YACA,UAAU,CAACuB,GAAMJ,MAAW;;AAC1B,cAAInB,EAAkB,YACtBwB,IAAAzB,EAAY,YAAZ,QAAAyB,EAAA,KAAAzB,GAAsBoB,EAAO;YAC/B;AAAA,UAAA;AAAA,QAAA,EACF,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -1,33 +1,28 @@
|
|
|
1
|
-
var
|
|
1
|
+
var c = (e) => {
|
|
2
2
|
throw TypeError(e);
|
|
3
3
|
};
|
|
4
|
-
var f = (e, n, t) => n.has(e) ||
|
|
5
|
-
var
|
|
4
|
+
var f = (e, n, t) => n.has(e) || c("Cannot " + t);
|
|
5
|
+
var m = (e, n, t) => n.has(e) ? c("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(e) : n.set(e, t);
|
|
6
6
|
var a = (e, n, t) => (f(e, n, "access private method"), t);
|
|
7
|
-
import { Plugin as h } from "
|
|
8
|
-
import "
|
|
9
|
-
import "../../node_modules/@ckeditor/ckeditor5-engine/dist/index.js";
|
|
10
|
-
import { Widget as p, viewToModelPositionOutsideModelElement as v, toWidget as V } from "../../node_modules/@ckeditor/ckeditor5-widget/dist/index.js";
|
|
11
|
-
import "../../node_modules/@ckeditor/ckeditor5-list/dist/index.js";
|
|
12
|
-
import "../../node_modules/@ckeditor/ckeditor5-mention/dist/index.js";
|
|
13
|
-
import { toVarToken as k } from "./variableMention.js";
|
|
7
|
+
import { Plugin as h, Widget as v, viewToModelPositionOutsideModelElement as V, toWidget as k } from "ckeditor5";
|
|
8
|
+
import { toVarToken as p } from "./variableMention.js";
|
|
14
9
|
var s, g, d;
|
|
15
|
-
class
|
|
10
|
+
class E extends h {
|
|
16
11
|
constructor() {
|
|
17
12
|
super(...arguments);
|
|
18
|
-
|
|
13
|
+
m(this, s);
|
|
19
14
|
}
|
|
20
15
|
static get pluginName() {
|
|
21
16
|
return "MsgVarWidget";
|
|
22
17
|
}
|
|
23
18
|
static get requires() {
|
|
24
|
-
return [
|
|
19
|
+
return [v];
|
|
25
20
|
}
|
|
26
21
|
init() {
|
|
27
22
|
const t = this.editor;
|
|
28
23
|
a(this, s, g).call(this), a(this, s, d).call(this), t.editing.mapper.on(
|
|
29
24
|
"viewToModelPosition",
|
|
30
|
-
|
|
25
|
+
V(
|
|
31
26
|
t.model,
|
|
32
27
|
(r) => r.hasClass("msg-var-token")
|
|
33
28
|
)
|
|
@@ -45,7 +40,7 @@ s = new WeakSet(), g = function() {
|
|
|
45
40
|
model: "msgVar",
|
|
46
41
|
view: (r, { writer: o }) => {
|
|
47
42
|
const i = String(r.getAttribute("key") || ""), u = l(o, i);
|
|
48
|
-
return
|
|
43
|
+
return k(u, o, { label: `变量 ${i}` });
|
|
49
44
|
}
|
|
50
45
|
}), t.for("dataDowncast").elementToElement({
|
|
51
46
|
model: "msgVar",
|
|
@@ -69,7 +64,7 @@ function l(e, n) {
|
|
|
69
64
|
class: "msg-var-token",
|
|
70
65
|
"data-var": n
|
|
71
66
|
});
|
|
72
|
-
return e.insert(e.createPositionAt(t, 0), e.createText(
|
|
67
|
+
return e.insert(e.createPositionAt(t, 0), e.createText(p(n))), t;
|
|
73
68
|
}
|
|
74
69
|
function w(e) {
|
|
75
70
|
const n = String(e.getAttribute("data-var") || "").trim();
|
|
@@ -80,7 +75,7 @@ function w(e) {
|
|
|
80
75
|
const r = t.match(/^\{\{(\w+)\}\}$/);
|
|
81
76
|
return (r == null ? void 0 : r[1]) ?? "";
|
|
82
77
|
}
|
|
83
|
-
function
|
|
78
|
+
function M(e, n) {
|
|
84
79
|
const t = String(n || "").trim();
|
|
85
80
|
t && (e.model.change((r) => {
|
|
86
81
|
const o = r.createElement("msgVar", { key: t });
|
|
@@ -88,7 +83,7 @@ function S(e, n) {
|
|
|
88
83
|
}), e.editing.view.focus());
|
|
89
84
|
}
|
|
90
85
|
export {
|
|
91
|
-
|
|
92
|
-
|
|
86
|
+
E as MsgVarWidget,
|
|
87
|
+
M as insertMsgVar
|
|
93
88
|
};
|
|
94
89
|
//# sourceMappingURL=msgVarTokenPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"msgVarTokenPlugin.js","sources":["../../../src/components/Editor/msgVarTokenPlugin.ts"],"sourcesContent":["import {\n Plugin,\n Widget,\n toWidget,\n viewToModelPositionOutsideModelElement,\n type Editor,\n type ViewDowncastWriter,\n type ViewElement,\n} from 'ckeditor5';\nimport { toVarToken } from './variableMention';\n\n/**\n * 正文变量原子色块:isObject inline widget。\n * 不可改内部字符;Backspace/Delete 整颗删(对齐 Coze/Dify chip)。\n */\nexport class MsgVarWidget extends Plugin {\n public static get pluginName() {\n return 'MsgVarWidget' as const;\n }\n\n public static get requires() {\n return [Widget] as const;\n }\n\n public init(): void {\n const editor = this.editor;\n this.#defineSchema();\n this.#defineConverters();\n\n editor.editing.mapper.on(\n 'viewToModelPosition',\n viewToModelPositionOutsideModelElement(editor.model, (viewElement) =>\n viewElement.hasClass('msg-var-token'),\n ),\n );\n }\n\n #defineSchema(): void {\n const schema = this.editor.model.schema;\n schema.register('msgVar', {\n inheritAllFrom: '$inlineObject',\n allowAttributes: ['key'],\n });\n }\n\n #defineConverters(): void {\n const conversion = this.editor.conversion;\n\n conversion.for('editingDowncast').elementToElement({\n model: 'msgVar',\n view: (modelItem, { writer }) => {\n const key = String(modelItem.getAttribute('key') || '');\n const widgetElement = createMsgVarView(writer, key);\n return toWidget(widgetElement, writer, { label: `变量 ${key}` });\n },\n });\n\n conversion.for('dataDowncast').elementToElement({\n model: 'msgVar',\n view: (modelItem, { writer }) => {\n const key = String(modelItem.getAttribute('key') || '');\n return createMsgVarView(writer, key);\n },\n });\n\n conversion.for('upcast').elementToElement({\n view: {\n name: 'span',\n classes: ['msg-var-token'],\n },\n model: (viewElement, { writer }) => {\n const key = resolveKeyFromView(viewElement);\n if (!key) return null;\n return writer.createElement('msgVar', { key });\n },\n });\n }\n}\n\nfunction createMsgVarView(writer: ViewDowncastWriter, key: string): ViewElement {\n const span = writer.createContainerElement('span', {\n class: 'msg-var-token',\n 'data-var': key,\n });\n writer.insert(writer.createPositionAt(span, 0), writer.createText(toVarToken(key)));\n return span;\n}\n\nfunction resolveKeyFromView(viewElement: ViewElement): string {\n const fromAttr = String(viewElement.getAttribute('data-var') || '').trim();\n if (fromAttr) return fromAttr;\n let text = '';\n for (const child of viewElement.getChildren()) {\n if (child.is('$text') || child.is('$textProxy')) {\n text += child.data;\n }\n }\n const m = text.match(/^\\{\\{(\\w+)\\}\\}$/);\n return m?.[1] ?? '';\n}\n\n/** 在选区插入原子变量色块,并焦点回编辑器 */\nexport function insertMsgVar(editor: Editor, key: string): void {\n const k = String(key || '').trim();\n if (!k) return;\n editor.model.change((writer) => {\n const el = writer.createElement('msgVar', { key: k });\n editor.model.insertContent(el);\n });\n editor.editing.view.focus();\n}\n"],"names":["MsgVarWidget","Plugin","__privateAdd","_MsgVarWidget_instances","Widget","editor","__privateMethod","defineSchema_fn","defineConverters_fn","viewToModelPositionOutsideModelElement","viewElement","conversion","modelItem","writer","key","widgetElement","createMsgVarView","toWidget","resolveKeyFromView","span","toVarToken","fromAttr","text","child","m","insertMsgVar","k","el"],"mappings":"
|
|
1
|
+
{"version":3,"file":"msgVarTokenPlugin.js","sources":["../../../src/components/Editor/msgVarTokenPlugin.ts"],"sourcesContent":["import {\n Plugin,\n Widget,\n toWidget,\n viewToModelPositionOutsideModelElement,\n type Editor,\n type ViewDowncastWriter,\n type ViewElement,\n} from 'ckeditor5';\nimport { toVarToken } from './variableMention';\n\n/**\n * 正文变量原子色块:isObject inline widget。\n * 不可改内部字符;Backspace/Delete 整颗删(对齐 Coze/Dify chip)。\n */\nexport class MsgVarWidget extends Plugin {\n public static get pluginName() {\n return 'MsgVarWidget' as const;\n }\n\n public static get requires() {\n return [Widget] as const;\n }\n\n public init(): void {\n const editor = this.editor;\n this.#defineSchema();\n this.#defineConverters();\n\n editor.editing.mapper.on(\n 'viewToModelPosition',\n viewToModelPositionOutsideModelElement(editor.model, (viewElement) =>\n viewElement.hasClass('msg-var-token'),\n ),\n );\n }\n\n #defineSchema(): void {\n const schema = this.editor.model.schema;\n schema.register('msgVar', {\n inheritAllFrom: '$inlineObject',\n allowAttributes: ['key'],\n });\n }\n\n #defineConverters(): void {\n const conversion = this.editor.conversion;\n\n conversion.for('editingDowncast').elementToElement({\n model: 'msgVar',\n view: (modelItem, { writer }) => {\n const key = String(modelItem.getAttribute('key') || '');\n const widgetElement = createMsgVarView(writer, key);\n return toWidget(widgetElement, writer, { label: `变量 ${key}` });\n },\n });\n\n conversion.for('dataDowncast').elementToElement({\n model: 'msgVar',\n view: (modelItem, { writer }) => {\n const key = String(modelItem.getAttribute('key') || '');\n return createMsgVarView(writer, key);\n },\n });\n\n conversion.for('upcast').elementToElement({\n view: {\n name: 'span',\n classes: ['msg-var-token'],\n },\n model: (viewElement, { writer }) => {\n const key = resolveKeyFromView(viewElement);\n if (!key) return null;\n return writer.createElement('msgVar', { key });\n },\n });\n }\n}\n\nfunction createMsgVarView(writer: ViewDowncastWriter, key: string): ViewElement {\n const span = writer.createContainerElement('span', {\n class: 'msg-var-token',\n 'data-var': key,\n });\n writer.insert(writer.createPositionAt(span, 0), writer.createText(toVarToken(key)));\n return span;\n}\n\nfunction resolveKeyFromView(viewElement: ViewElement): string {\n const fromAttr = String(viewElement.getAttribute('data-var') || '').trim();\n if (fromAttr) return fromAttr;\n let text = '';\n for (const child of viewElement.getChildren()) {\n if (child.is('$text') || child.is('$textProxy')) {\n text += child.data;\n }\n }\n const m = text.match(/^\\{\\{(\\w+)\\}\\}$/);\n return m?.[1] ?? '';\n}\n\n/** 在选区插入原子变量色块,并焦点回编辑器 */\nexport function insertMsgVar(editor: Editor, key: string): void {\n const k = String(key || '').trim();\n if (!k) return;\n editor.model.change((writer) => {\n const el = writer.createElement('msgVar', { key: k });\n editor.model.insertContent(el);\n });\n editor.editing.view.focus();\n}\n"],"names":["MsgVarWidget","Plugin","__privateAdd","_MsgVarWidget_instances","Widget","editor","__privateMethod","defineSchema_fn","defineConverters_fn","viewToModelPositionOutsideModelElement","viewElement","conversion","modelItem","writer","key","widgetElement","createMsgVarView","toWidget","resolveKeyFromView","span","toVarToken","fromAttr","text","child","m","insertMsgVar","k","el"],"mappings":";;;;;;;;;AAeO,MAAMA,UAAqBC,EAAO;AAAA,EAAlC;AAAA;AAAA,IAAAC,EAAA,MAAAC;AAAA;AAAA,EACL,WAAkB,aAAa;AAC7B,WAAO;AAAA,EACT;AAAA,EAEA,WAAkB,WAAW;AAC3B,WAAO,CAACC,CAAM;AAAA,EAChB;AAAA,EAEO,OAAa;AAClB,UAAMC,IAAS,KAAK;AACpB,IAAAC,EAAA,MAAKH,GAAAI,GAAL,YACAD,EAAA,MAAKH,GAAAK,GAAL,YAEAH,EAAO,QAAQ,OAAO;AAAA,MACpB;AAAA,MACAI;AAAA,QAAuCJ,EAAO;AAAA,QAAO,CAACK,MACpDA,EAAY,SAAS,eA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