@sdata/web-vue 3.18.0 → 3.20.0
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/sd.css +489 -0
- package/dist/sd.min.css +2 -2
- package/es/_components/icon-hover.vue.d.ts +1 -1
- package/es/_components/input-label/input-label.d.ts +13 -1
- package/es/_components/input-label/input-label.js +35 -5
- package/es/_components/input-label/style/index.css +6 -0
- package/es/_components/input-label/style/input-label.scss +8 -0
- package/es/_components/picker/input-range.vue.d.ts +24 -1
- package/es/_components/picker/input-range.vue_vue_type_script_setup_true_lang.js +42 -6
- package/es/_components/picker/input.vue.d.ts +24 -1
- package/es/_components/picker/input.vue_vue_type_script_setup_true_lang.js +31 -4
- package/es/_components/picker/style/index.scss +8 -0
- package/es/_components/select-view/select-view.d.ts +15 -3
- package/es/_components/select-view/select-view.js +10 -1
- package/es/_components/select-view/style/index.css +12 -0
- package/es/_components/virtual-list/virtual-list.vue.d.ts +6 -6
- package/es/_hooks/use-fit-width.d.ts +22 -0
- package/es/_hooks/use-fit-width.js +76 -0
- package/es/_hooks/use-form-item.d.ts +1 -1
- package/es/_hooks/use-size.d.ts +1 -1
- package/es/anchor/anchor.vue.d.ts +1 -1
- package/es/anchor/index.d.ts +3 -3
- package/es/auto-complete/auto-complete.d.ts +20 -2
- package/es/auto-complete/auto-complete.js +18 -0
- package/es/auto-complete/index.d.ts +36 -6
- package/es/basic-crud-table/basic-crud-table.vue.d.ts +2 -2
- package/es/basic-crud-table/basic-crud-table.vue_vue_type_script_setup_true_lang.js +6 -4
- package/es/basic-crud-table/index.d.ts +5 -5
- package/es/basic-crud-table/types.d.ts +2 -0
- package/es/button/button.vue.d.ts +2 -2
- package/es/button/index.d.ts +6 -6
- package/es/card/card.d.ts +25 -3
- package/es/card/card.js +11 -2
- package/es/card/index.d.ts +45 -6
- package/es/carousel/carousel-indicator.vue.d.ts +1 -1
- package/es/cascader/base-cascader-panel.d.ts +4 -1
- package/es/cascader/base-cascader-panel.js +2 -1
- package/es/cascader/cascader-option.d.ts +1 -1
- package/es/cascader/cascader-panel.vue.d.ts +1 -1
- package/es/cascader/cascader-search-panel.d.ts +4 -1
- package/es/cascader/cascader-search-panel.js +2 -1
- package/es/cascader/cascader.vue.d.ts +7 -5
- package/es/cascader/cascader.vue_vue_type_script_setup_true_lang.js +22 -2
- package/es/cascader/types.d.ts +4 -1
- package/es/checkbox/checkbox.d.ts +3 -3
- package/es/checkbox/index.d.ts +6 -6
- package/es/collapse/collapse-item.d.ts +3 -3
- package/es/collapse/index.d.ts +3 -3
- package/es/color-picker/color-picker.d.ts +2 -2
- package/es/color-picker/index.d.ts +6 -6
- package/es/components.d.ts +4 -0
- package/es/config-provider/config-provider.vue.d.ts +68 -1
- package/es/config-provider/config-provider.vue_vue_type_script_setup_true_lang.js +67 -1
- package/es/config-provider/context.d.ts +12 -0
- package/es/config-provider/index.d.ts +102 -3
- package/es/date-picker/index.d.ts +87 -23
- package/es/date-picker/interface.d.ts +2 -1
- package/es/date-picker/picker-panel.vue.d.ts +1 -1
- package/es/date-picker/picker.vue.d.ts +39 -17
- package/es/date-picker/picker.vue_vue_type_script_setup_true_lang.js +30 -1
- package/es/date-picker/pickers/date-picker.d.ts +18 -0
- package/es/date-picker/pickers/date-picker.js +16 -0
- package/es/date-picker/range-picker-panel.vue.d.ts +1 -1
- package/es/date-picker/range-picker.vue.d.ts +39 -17
- package/es/date-picker/range-picker.vue_vue_type_script_setup_true_lang.js +27 -1
- package/es/date-picker/style/index.css +6 -0
- package/es/descriptions/descriptions.d.ts +3 -3
- package/es/descriptions/index.d.ts +9 -9
- package/es/divider/divider.d.ts +1 -1
- package/es/divider/index.d.ts +3 -3
- package/es/drawer/drawer.vue.d.ts +4 -4
- package/es/drawer/drawer.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/drawer/index.d.ts +11 -11
- package/es/dropdown/dropdown-button.vue.d.ts +2 -2
- package/es/dropdown/dropdown-option.vue.d.ts +1 -1
- package/es/dropdown/dropdown-submenu.vue.d.ts +2 -2
- package/es/dropdown/dropdown.vue.d.ts +1 -1
- package/es/dropdown/index.d.ts +21 -21
- package/es/ellipsis/ellipsis.vue.d.ts +1 -1
- package/es/ellipsis/index.d.ts +6 -6
- package/es/ellipsis/performant-ellipsis.vue.d.ts +1 -1
- package/es/form/form-item.vue.d.ts +1 -1
- package/es/form/form.vue.d.ts +1 -1
- package/es/form/index.d.ts +9 -9
- package/es/grid/grid-row.vue.d.ts +3 -3
- package/es/grid/index.d.ts +9 -9
- package/es/icon/icon-arrow-up/icon-arrow-up.js +5 -0
- package/es/icon/icon-arrow-up/icon-arrow-up.vue_vue_type_script_setup_true_lang.js +52 -0
- package/es/icon/icon-arrow-up/index.js +9 -0
- package/es/icon/icon-mute/icon-mute.js +5 -0
- package/es/icon/icon-mute/icon-mute.vue_vue_type_script_setup_true_lang.js +52 -0
- package/es/icon/icon-mute/index.js +9 -0
- package/es/icon/icon-voice/icon-voice.js +5 -0
- package/es/icon/icon-voice/icon-voice.vue_vue_type_script_setup_true_lang.js +52 -0
- package/es/icon/icon-voice/index.js +9 -0
- package/es/image/preview-action.d.ts +6 -6
- package/es/image/preview-group.vue.d.ts +1 -1
- package/es/index.css +489 -0
- package/es/index.d.ts +6 -1
- package/es/index.js +5 -1
- package/es/index.scss +2 -0
- package/es/input/index.d.ts +99 -6
- package/es/input/input-password.vue.d.ts +18 -0
- package/es/input/input-password.vue_vue_type_script_setup_true_lang.js +24 -2
- package/es/input/input-search.d.ts +18 -0
- package/es/input/input-search.js +20 -2
- package/es/input/input.d.ts +29 -2
- package/es/input/input.js +45 -3
- package/es/input/style/index.css +16 -0
- package/es/input/style/index.scss +21 -0
- package/es/input-number/index.d.ts +36 -6
- package/es/input-number/input-number.d.ts +20 -2
- package/es/input-number/input-number.js +19 -0
- package/es/input-tag/index.d.ts +36 -6
- package/es/input-tag/input-tag.d.ts +20 -2
- package/es/input-tag/input-tag.js +35 -4
- package/es/input-tag/style/index.css +6 -0
- package/es/input-tag/style/input-tag.scss +8 -0
- package/es/kv-list/index.d.ts +72 -32
- package/es/link/index.d.ts +6 -6
- package/es/link/link.vue.d.ts +2 -2
- package/es/list/index.d.ts +9 -0
- package/es/list/list.d.ts +7 -0
- package/es/list/list.js +8 -2
- package/es/locale/interface.d.ts +22 -0
- package/es/locale/lang/ar-eg.js +21 -1
- package/es/locale/lang/de-de.js +21 -1
- package/es/locale/lang/en-us.js +21 -1
- package/es/locale/lang/es-es.js +21 -1
- package/es/locale/lang/fr-fr.js +21 -1
- package/es/locale/lang/id-id.js +21 -1
- package/es/locale/lang/it-it.js +21 -1
- package/es/locale/lang/ja-jp.js +21 -1
- package/es/locale/lang/km-kh.js +21 -1
- package/es/locale/lang/ko-kr.js +21 -1
- package/es/locale/lang/ms-my.js +21 -1
- package/es/locale/lang/nl-nl.js +21 -1
- package/es/locale/lang/pt-pt.js +21 -1
- package/es/locale/lang/ru-ru.js +21 -1
- package/es/locale/lang/th-th.js +21 -1
- package/es/locale/lang/vi-vn.js +21 -1
- package/es/locale/lang/zh-cn.js +21 -1
- package/es/locale/lang/zh-tw.js +21 -1
- package/es/mention/index.d.ts +39 -9
- package/es/mention/mention.d.ts +21 -3
- package/es/mention/mention.js +24 -1
- package/es/mention/style/index.css +6 -0
- package/es/mention/style/index.scss +8 -0
- package/es/menu/item.d.ts +1 -1
- package/es/message/message-list.d.ts +1 -1
- package/es/modal/index.d.ts +9 -9
- package/es/modal/modal.vue.d.ts +3 -3
- package/es/modal/modal.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/popconfirm/index.d.ts +3 -3
- package/es/popconfirm/popconfirm.vue.d.ts +1 -1
- package/es/popover/index.d.ts +6 -6
- package/es/popover/popover.vue.d.ts +2 -2
- package/es/progress/circle.vue.d.ts +1 -1
- package/es/progress/line.vue.d.ts +1 -1
- package/es/qr-code/index.d.ts +27 -21
- package/es/qr-code/qr-code.vue.d.ts +8 -6
- package/es/qr-code/qr-code.vue_vue_type_script_setup_true_lang.js +5 -2
- package/es/radio/index.d.ts +6 -6
- package/es/radio/radio.d.ts +3 -3
- package/es/rate/index.d.ts +3 -3
- package/es/rate/rate.d.ts +1 -1
- package/es/resize-box/index.d.ts +5 -5
- package/es/resize-box/resize-box.vue.d.ts +3 -3
- package/es/rich-text-editor/built-in-components.d.ts +5 -0
- package/es/rich-text-editor/built-in-components.js +6 -0
- package/es/rich-text-editor/index.d.ts +195 -0
- package/es/rich-text-editor/index.js +12 -0
- package/es/rich-text-editor/nodes/inline-component-node.d.ts +30 -0
- package/es/rich-text-editor/nodes/inline-component-node.js +86 -0
- package/es/rich-text-editor/rich-text-editor.js +5 -0
- package/es/rich-text-editor/rich-text-editor.vue.d.ts +76 -0
- package/es/rich-text-editor/rich-text-editor.vue_vue_type_script_setup_true_lang.js +630 -0
- package/es/rich-text-editor/rich-text-node-renderer.js +5 -0
- package/es/rich-text-editor/rich-text-node-renderer.vue.d.ts +28 -0
- package/es/rich-text-editor/rich-text-node-renderer.vue_vue_type_script_setup_true_lang.js +133 -0
- package/es/rich-text-editor/style/css.js +2 -0
- package/es/rich-text-editor/style/index.css +164 -0
- package/es/rich-text-editor/style/index.d.ts +2 -0
- package/es/rich-text-editor/style/index.js +2 -0
- package/es/rich-text-editor/style/index.scss +193 -0
- package/es/rich-text-editor/style/token.scss +36 -0
- package/es/rich-text-editor/types.d.ts +148 -0
- package/es/sd-vue.js +6 -0
- package/es/select/index.d.ts +117 -54
- package/es/select/interface.d.ts +2 -1
- package/es/select/select-dropdown.vue.d.ts +3 -0
- package/es/select/select-dropdown.vue_vue_type_script_setup_true_lang.js +2 -4
- package/es/select/select.d.ts +62 -25
- package/es/select/select.js +28 -1
- package/es/sender/context.d.ts +8 -0
- package/es/sender/context.js +4 -0
- package/es/sender/index.d.ts +119 -0
- package/es/sender/index.js +20 -0
- package/es/sender/sender-header.js +5 -0
- package/es/sender/sender-header.vue.d.ts +28 -0
- package/es/sender/sender-header.vue_vue_type_script_setup_true_lang.js +127 -0
- package/es/sender/sender-switch.js +5 -0
- package/es/sender/sender-switch.vue.d.ts +32 -0
- package/es/sender/sender-switch.vue_vue_type_script_setup_true_lang.js +95 -0
- package/es/sender/sender.js +5 -0
- package/es/sender/sender.vue_vue_type_script_setup_true_lang.js +895 -0
- package/es/sender/style/css.js +3 -0
- package/es/sender/style/index.css +301 -0
- package/es/sender/style/index.d.ts +3 -0
- package/es/sender/style/index.js +3 -0
- package/es/sender/style/index.scss +359 -0
- package/es/sender/style/token.scss +43 -0
- package/es/sender/types.d.ts +228 -0
- package/es/sender/use-speech.d.ts +19 -0
- package/es/sender/use-speech.js +338 -0
- package/es/slider/index.d.ts +3 -3
- package/es/slider/slider-input.vue.d.ts +1 -1
- package/es/slider/slider.vue.d.ts +1 -1
- package/es/space/index.d.ts +9 -9
- package/es/space/space.d.ts +2 -2
- package/es/spin/index.d.ts +18 -3
- package/es/spin/spin.d.ts +10 -1
- package/es/spin/spin.js +72 -10
- package/es/statistic/index.d.ts +3 -3
- package/es/statistic/statistic.vue.d.ts +1 -1
- package/es/steps/index.d.ts +5 -5
- package/es/steps/step.vue.d.ts +2 -2
- package/es/steps/steps.vue.d.ts +1 -1
- package/es/table/index.d.ts +68 -23
- package/es/table/interface.d.ts +3 -0
- package/es/table/table-column.d.ts +1 -1
- package/es/table/table-operation-td.d.ts +12 -12
- package/es/table/table-td.d.ts +2 -2
- package/es/table/table.d.ts +27 -8
- package/es/table/table.js +7 -2
- package/es/tabs/index.d.ts +12 -12
- package/es/tabs/tabs-nav.d.ts +1 -1
- package/es/tabs/tabs.d.ts +4 -4
- package/es/tag/index.d.ts +6 -6
- package/es/tag/tag.vue.d.ts +2 -2
- package/es/textarea/index.d.ts +38 -8
- package/es/textarea/style/index.css +6 -0
- package/es/textarea/style/index.scss +8 -0
- package/es/textarea/textarea.vue.d.ts +21 -3
- package/es/textarea/textarea.vue_vue_type_script_setup_true_lang.js +36 -3
- package/es/time-picker/index.d.ts +36 -6
- package/es/time-picker/interface.d.ts +2 -1
- package/es/time-picker/range-panel.js +58 -0
- package/es/time-picker/time-picker.vue.d.ts +20 -2
- package/es/time-picker/time-picker.vue_vue_type_script_setup_true_lang.js +30 -1
- package/es/timeline/index.d.ts +45 -6
- package/es/timeline/timeline.d.ts +25 -3
- package/es/timeline/timeline.js +11 -2
- package/es/toolbar/toolbar.vue_vue_type_script_setup_true_lang.js +9 -5
- package/es/toolbar/types.d.ts +2 -0
- package/es/tooltip/index.d.ts +6 -6
- package/es/tooltip/tooltip.vue.d.ts +2 -2
- package/es/tour/index.d.ts +3 -3
- package/es/tour/tour.vue.d.ts +1 -1
- package/es/transfer/index.d.ts +3 -3
- package/es/transfer/transfer.vue.d.ts +1 -1
- package/es/tree/tree.vue.d.ts +4 -4
- package/es/tree-select/interface.d.ts +2 -1
- package/es/tree-select/tree-select.vue.d.ts +32 -7
- package/es/tree-select/tree-select.vue_vue_type_script_setup_true_lang.js +27 -1
- package/es/trigger/index.d.ts +12 -12
- package/es/trigger/trigger.d.ts +4 -4
- package/es/typography/base.d.ts +4 -4
- package/es/typography/edit-content.vue.d.ts +2 -2
- package/es/upload/index.d.ts +6 -6
- package/es/upload/upload-button.d.ts +1 -1
- package/es/upload/upload.d.ts +2 -2
- package/es/verification-code/index.d.ts +3 -3
- package/es/verification-code/verification-code.d.ts +1 -1
- package/es/watermark/index.d.ts +3 -3
- package/es/watermark/watermark.d.ts +1 -1
- package/json/vetur-attributes.json +295 -2
- package/json/vetur-tags.json +103 -3
- package/json/web-types.json +746 -53
- package/package.json +10 -1
|
@@ -0,0 +1,630 @@
|
|
|
1
|
+
import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import { getPrefixCls } from "../_utils/global-config.js";
|
|
3
|
+
import { useI18n } from "../locale/index.js";
|
|
4
|
+
import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/objectWithoutProperties.js";
|
|
5
|
+
import { $createInlineComponentNode, $isInlineComponentNode, InlineComponentNode } from "./nodes/inline-component-node.js";
|
|
6
|
+
import rich_text_node_renderer_default from "./rich-text-node-renderer.js";
|
|
7
|
+
import { Fragment, Teleport, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, getCurrentInstance, nextTick, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, renderList, renderSlot, shallowRef, toDisplayString, unref, watch, withCtx } from "vue";
|
|
8
|
+
import { CodeHighlightNode, CodeNode } from "@lexical/code";
|
|
9
|
+
import { createEmptyHistoryState, registerHistory } from "@lexical/history";
|
|
10
|
+
import { $generateHtmlFromNodes, $generateNodesFromDOM } from "@lexical/html";
|
|
11
|
+
import { AutoLinkNode, LinkNode } from "@lexical/link";
|
|
12
|
+
import { ListItemNode, ListNode } from "@lexical/list";
|
|
13
|
+
import { $convertFromMarkdownString, $convertToMarkdownString, TRANSFORMERS } from "@lexical/markdown";
|
|
14
|
+
import { HeadingNode, QuoteNode, registerRichText } from "@lexical/rich-text";
|
|
15
|
+
import { $createLineBreakNode, $createParagraphNode, $createTextNode, $getNodeByKey, $getRoot, $getSelection, $isElementNode, $isLineBreakNode, $isRangeSelection, $isTextNode, $nodesOfType, $setSelection, CAN_REDO_COMMAND, CAN_UNDO_COMMAND, COMMAND_PRIORITY_LOW, FORMAT_TEXT_COMMAND, REDO_COMMAND, SKIP_SCROLL_INTO_VIEW_TAG, UNDO_COMMAND, createEditor } from "lexical";
|
|
16
|
+
//#region components/rich-text-editor/rich-text-editor.vue?vue&type=script&setup=true&lang.ts
|
|
17
|
+
var _excluded = ["position", "replaceCharacters"];
|
|
18
|
+
var _excluded2 = ["position", "replaceCharacters"];
|
|
19
|
+
var _excluded3 = ["selection", "preventScroll"];
|
|
20
|
+
var _hoisted_1 = [
|
|
21
|
+
"aria-label",
|
|
22
|
+
"aria-disabled",
|
|
23
|
+
"aria-readonly",
|
|
24
|
+
"spellcheck",
|
|
25
|
+
"contenteditable"
|
|
26
|
+
];
|
|
27
|
+
var rich_text_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent(_objectSpread2(_objectSpread2({}, { name: "RichTextEditor" }), {}, {
|
|
28
|
+
__name: "rich-text-editor",
|
|
29
|
+
props: {
|
|
30
|
+
modelValue: {},
|
|
31
|
+
defaultValue: {},
|
|
32
|
+
editorConfig: {},
|
|
33
|
+
plugins: { default: () => [] },
|
|
34
|
+
transformers: { default: () => TRANSFORMERS },
|
|
35
|
+
placeholder: {},
|
|
36
|
+
disabled: { type: Boolean },
|
|
37
|
+
readonly: { type: Boolean },
|
|
38
|
+
history: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: true
|
|
41
|
+
},
|
|
42
|
+
historyDelay: { default: 300 },
|
|
43
|
+
historyMaxDepth: { default: null },
|
|
44
|
+
autoSize: {
|
|
45
|
+
type: [Boolean, Object],
|
|
46
|
+
default: true
|
|
47
|
+
},
|
|
48
|
+
spellcheck: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
default: true
|
|
51
|
+
},
|
|
52
|
+
ariaLabel: {},
|
|
53
|
+
classNames: { default: () => ({}) },
|
|
54
|
+
styles: { default: () => ({}) }
|
|
55
|
+
},
|
|
56
|
+
emits: [
|
|
57
|
+
"update:modelValue",
|
|
58
|
+
"change",
|
|
59
|
+
"update",
|
|
60
|
+
"ready",
|
|
61
|
+
"focus",
|
|
62
|
+
"blur",
|
|
63
|
+
"error"
|
|
64
|
+
],
|
|
65
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
66
|
+
const props = __props;
|
|
67
|
+
const emit = __emit;
|
|
68
|
+
const { t } = useI18n();
|
|
69
|
+
const resolvedAriaLabel = computed(() => {
|
|
70
|
+
var _props$ariaLabel;
|
|
71
|
+
return (_props$ariaLabel = props.ariaLabel) !== null && _props$ariaLabel !== void 0 ? _props$ariaLabel : t("richTextEditor.ariaLabel");
|
|
72
|
+
});
|
|
73
|
+
const instance = getCurrentInstance();
|
|
74
|
+
const hasStateListeners = () => {
|
|
75
|
+
var _instance$vnode$props, _instance$vnode$props2;
|
|
76
|
+
return Boolean((instance === null || instance === void 0 || (_instance$vnode$props = instance.vnode.props) === null || _instance$vnode$props === void 0 ? void 0 : _instance$vnode$props["onUpdate:modelValue"]) || (instance === null || instance === void 0 || (_instance$vnode$props2 = instance.vnode.props) === null || _instance$vnode$props2 === void 0 ? void 0 : _instance$vnode$props2.onChange));
|
|
77
|
+
};
|
|
78
|
+
const prefixCls = getPrefixCls("rich-text-editor");
|
|
79
|
+
const containerRef = shallowRef();
|
|
80
|
+
const rootRef = shallowRef();
|
|
81
|
+
const editorRef = shallowRef(null);
|
|
82
|
+
const isEmpty = shallowRef(true);
|
|
83
|
+
const canUndo = shallowRef(false);
|
|
84
|
+
const canRedo = shallowRef(false);
|
|
85
|
+
const cleanups = [];
|
|
86
|
+
let lastSerialized = "";
|
|
87
|
+
let applyingExternalValue = false;
|
|
88
|
+
const componentHosts = shallowRef([]);
|
|
89
|
+
const rootClass = computed(() => [
|
|
90
|
+
prefixCls,
|
|
91
|
+
props.classNames.root,
|
|
92
|
+
{
|
|
93
|
+
[`${prefixCls}-disabled`]: props.disabled,
|
|
94
|
+
[`${prefixCls}-readonly`]: props.readonly,
|
|
95
|
+
[`${prefixCls}-focusable`]: !props.disabled && !props.readonly
|
|
96
|
+
}
|
|
97
|
+
]);
|
|
98
|
+
const contentStyle = computed(() => {
|
|
99
|
+
if (!props.autoSize) return {};
|
|
100
|
+
if (props.autoSize === true) return { minHeight: "1.5715em" };
|
|
101
|
+
return {
|
|
102
|
+
minHeight: props.autoSize.minRows ? `${props.autoSize.minRows}lh` : void 0,
|
|
103
|
+
maxHeight: props.autoSize.maxRows ? `${props.autoSize.maxRows}lh` : void 0,
|
|
104
|
+
overflowY: props.autoSize.maxRows ? "auto" : void 0
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
const serializeEditorState = (editorState) => editorState.toJSON();
|
|
108
|
+
const serializeValue = (value) => JSON.stringify(value);
|
|
109
|
+
const withDiscreteUpdate = (options) => _objectSpread2({ discrete: true }, options);
|
|
110
|
+
const updateEmptyState = (editorState) => {
|
|
111
|
+
isEmpty.value = editorState.read(() => $getRoot().getTextContentSize() === 0 && $nodesOfType(InlineComponentNode).length === 0);
|
|
112
|
+
};
|
|
113
|
+
const refreshComponentHosts = () => {
|
|
114
|
+
const editor = editorRef.value;
|
|
115
|
+
if (!editor) return;
|
|
116
|
+
const hosts = [];
|
|
117
|
+
editor.getEditorState().read(() => {
|
|
118
|
+
for (const node of $nodesOfType(InlineComponentNode)) {
|
|
119
|
+
const nodeKey = node.getKey();
|
|
120
|
+
const element = editor.getElementByKey(nodeKey);
|
|
121
|
+
if (element) {
|
|
122
|
+
element.classList.toggle(`${prefixCls}-component-selected`, node.isSelected());
|
|
123
|
+
hosts.push({
|
|
124
|
+
nodeKey,
|
|
125
|
+
element,
|
|
126
|
+
node: node.getData(),
|
|
127
|
+
editor
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
componentHosts.value = hosts;
|
|
133
|
+
};
|
|
134
|
+
const handleUpdate = (payload) => {
|
|
135
|
+
const editor = editorRef.value;
|
|
136
|
+
if (!editor) return;
|
|
137
|
+
const context = {
|
|
138
|
+
editor,
|
|
139
|
+
editorState: payload.editorState,
|
|
140
|
+
tags: payload.tags
|
|
141
|
+
};
|
|
142
|
+
emit("update", context);
|
|
143
|
+
updateEmptyState(payload.editorState);
|
|
144
|
+
queueMicrotask(refreshComponentHosts);
|
|
145
|
+
if (payload.dirtyElements.size === 0 && payload.dirtyLeaves.size === 0) return;
|
|
146
|
+
if (props.modelValue === void 0 && !hasStateListeners()) return;
|
|
147
|
+
const value = serializeEditorState(payload.editorState);
|
|
148
|
+
lastSerialized = serializeValue(value);
|
|
149
|
+
if (!applyingExternalValue) {
|
|
150
|
+
emit("update:modelValue", value);
|
|
151
|
+
emit("change", value, context);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const createContentNodes = (content) => {
|
|
155
|
+
const nodes = [];
|
|
156
|
+
for (const item of content) {
|
|
157
|
+
if (typeof item !== "string") {
|
|
158
|
+
nodes.push($createInlineComponentNode(item));
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
item.split("\n").forEach((line, index) => {
|
|
162
|
+
if (index) nodes.push($createLineBreakNode());
|
|
163
|
+
if (line) nodes.push($createTextNode(line));
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return nodes;
|
|
167
|
+
};
|
|
168
|
+
const setContent = (content, options) => {
|
|
169
|
+
var _editorRef$value;
|
|
170
|
+
(_editorRef$value = editorRef.value) === null || _editorRef$value === void 0 || _editorRef$value.update(() => {
|
|
171
|
+
const paragraph = $createParagraphNode();
|
|
172
|
+
paragraph.append(...createContentNodes(content));
|
|
173
|
+
$getRoot().clear().append(paragraph);
|
|
174
|
+
paragraph.selectEnd();
|
|
175
|
+
}, withDiscreteUpdate(options));
|
|
176
|
+
};
|
|
177
|
+
const setPlainText = (text, options) => {
|
|
178
|
+
setContent([text], options);
|
|
179
|
+
};
|
|
180
|
+
const getContent = () => {
|
|
181
|
+
var _editorRef$value$getE, _editorRef$value2;
|
|
182
|
+
return (_editorRef$value$getE = (_editorRef$value2 = editorRef.value) === null || _editorRef$value2 === void 0 ? void 0 : _editorRef$value2.getEditorState().read(() => {
|
|
183
|
+
const content = [];
|
|
184
|
+
const appendText = (value) => {
|
|
185
|
+
if (!value) return;
|
|
186
|
+
const previous = content.at(-1);
|
|
187
|
+
if (typeof previous === "string") content[content.length - 1] = previous + value;
|
|
188
|
+
else content.push(value);
|
|
189
|
+
};
|
|
190
|
+
const visit = (node) => {
|
|
191
|
+
if ($isTextNode(node)) {
|
|
192
|
+
appendText(node.getTextContent());
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if ($isLineBreakNode(node)) {
|
|
196
|
+
appendText("\n");
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if ($isInlineComponentNode(node)) {
|
|
200
|
+
content.push(node.getData());
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if ($isElementNode(node)) node.getChildren().forEach(visit);
|
|
204
|
+
};
|
|
205
|
+
$getRoot().getChildren().forEach((node, index) => {
|
|
206
|
+
if (index) appendText("\n");
|
|
207
|
+
visit(node);
|
|
208
|
+
});
|
|
209
|
+
return content;
|
|
210
|
+
})) !== null && _editorRef$value$getE !== void 0 ? _editorRef$value$getE : [];
|
|
211
|
+
};
|
|
212
|
+
const insertContent = (content, options = {}) => {
|
|
213
|
+
var _editorRef$value3;
|
|
214
|
+
const { position = "cursor", replaceCharacters } = options, updateOptions = _objectWithoutProperties(options, _excluded);
|
|
215
|
+
(_editorRef$value3 = editorRef.value) === null || _editorRef$value3 === void 0 || _editorRef$value3.update(() => {
|
|
216
|
+
const root = $getRoot();
|
|
217
|
+
if (position === "start") root.selectStart();
|
|
218
|
+
if (position === "end") root.selectEnd();
|
|
219
|
+
const selection = $getSelection();
|
|
220
|
+
if ($isRangeSelection(selection)) {
|
|
221
|
+
if (replaceCharacters && selection.isCollapsed()) {
|
|
222
|
+
const anchorNode = selection.anchor.getNode();
|
|
223
|
+
const offset = selection.anchor.offset;
|
|
224
|
+
if ($isTextNode(anchorNode) && anchorNode.getTextContent().slice(0, offset).endsWith(replaceCharacters)) {
|
|
225
|
+
const start = offset - replaceCharacters.length;
|
|
226
|
+
anchorNode.spliceText(start, replaceCharacters.length, "", true);
|
|
227
|
+
anchorNode.select(start, start);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
selection.insertNodes(createContentNodes(content));
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
const paragraph = $createParagraphNode();
|
|
234
|
+
paragraph.append(...createContentNodes(content));
|
|
235
|
+
root.append(paragraph);
|
|
236
|
+
paragraph.selectEnd();
|
|
237
|
+
}, withDiscreteUpdate(updateOptions));
|
|
238
|
+
};
|
|
239
|
+
const setJSON = (value, options) => {
|
|
240
|
+
const editor = editorRef.value;
|
|
241
|
+
if (!editor) return;
|
|
242
|
+
try {
|
|
243
|
+
const editorState = editor.parseEditorState(value);
|
|
244
|
+
editor.setEditorState(editorState, options);
|
|
245
|
+
lastSerialized = JSON.stringify(editorState.toJSON());
|
|
246
|
+
} catch (error) {
|
|
247
|
+
var _props$editorConfig, _props$editorConfig$o;
|
|
248
|
+
const normalizedError = error instanceof Error ? error : new Error(String(error));
|
|
249
|
+
emit("error", normalizedError);
|
|
250
|
+
(_props$editorConfig = props.editorConfig) === null || _props$editorConfig === void 0 || (_props$editorConfig$o = _props$editorConfig.onError) === null || _props$editorConfig$o === void 0 || _props$editorConfig$o.call(_props$editorConfig, normalizedError);
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
const applyInitialValue = () => {
|
|
254
|
+
const defaultValue = props.defaultValue;
|
|
255
|
+
if (props.modelValue) {
|
|
256
|
+
setJSON(props.modelValue, { tag: "sd-rich-text-initial" });
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
if (Array.isArray(defaultValue)) {
|
|
260
|
+
setContent(defaultValue, { tag: "sd-rich-text-initial" });
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
if (typeof defaultValue === "string") {
|
|
264
|
+
setPlainText(defaultValue, { tag: "sd-rich-text-initial" });
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
if (defaultValue) {
|
|
268
|
+
setJSON(defaultValue, { tag: "sd-rich-text-initial" });
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
setPlainText("", { tag: "sd-rich-text-initial" });
|
|
272
|
+
};
|
|
273
|
+
const updateComponent = (nodeKey, value, options) => {
|
|
274
|
+
var _editorRef$value4;
|
|
275
|
+
(_editorRef$value4 = editorRef.value) === null || _editorRef$value4 === void 0 || _editorRef$value4.update(() => {
|
|
276
|
+
const node = $getNodeByKey(nodeKey);
|
|
277
|
+
if ($isInlineComponentNode(node)) node.setValue(value);
|
|
278
|
+
}, withDiscreteUpdate(options));
|
|
279
|
+
};
|
|
280
|
+
const removeComponent = (nodeKey, options) => {
|
|
281
|
+
var _editorRef$value5;
|
|
282
|
+
(_editorRef$value5 = editorRef.value) === null || _editorRef$value5 === void 0 || _editorRef$value5.update(() => {
|
|
283
|
+
const node = $getNodeByKey(nodeKey);
|
|
284
|
+
if ($isInlineComponentNode(node)) node.remove();
|
|
285
|
+
}, withDiscreteUpdate(options));
|
|
286
|
+
};
|
|
287
|
+
const insertText = (text, options = {}) => {
|
|
288
|
+
var _editorRef$value6;
|
|
289
|
+
const { position = "cursor", replaceCharacters } = options, updateOptions = _objectWithoutProperties(options, _excluded2);
|
|
290
|
+
(_editorRef$value6 = editorRef.value) === null || _editorRef$value6 === void 0 || _editorRef$value6.update(() => {
|
|
291
|
+
const root = $getRoot();
|
|
292
|
+
if (position === "start") root.selectStart();
|
|
293
|
+
if (position === "end") root.selectEnd();
|
|
294
|
+
const selection = $getSelection();
|
|
295
|
+
if ($isRangeSelection(selection)) {
|
|
296
|
+
if (replaceCharacters && selection.isCollapsed()) {
|
|
297
|
+
const anchorNode = selection.anchor.getNode();
|
|
298
|
+
const offset = selection.anchor.offset;
|
|
299
|
+
if ($isTextNode(anchorNode) && anchorNode.getTextContent().slice(0, offset).endsWith(replaceCharacters)) {
|
|
300
|
+
const start = offset - replaceCharacters.length;
|
|
301
|
+
anchorNode.spliceText(start, replaceCharacters.length, "", true);
|
|
302
|
+
anchorNode.select(start, start);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
selection.insertText(text);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
const paragraph = $createParagraphNode().append($createTextNode(text));
|
|
309
|
+
root.append(paragraph);
|
|
310
|
+
paragraph.selectEnd();
|
|
311
|
+
}, withDiscreteUpdate(updateOptions));
|
|
312
|
+
};
|
|
313
|
+
const insertComponent = (data, options) => insertContent([data], options);
|
|
314
|
+
const clear = () => {
|
|
315
|
+
setPlainText("", { tag: "sd-rich-text-clear" });
|
|
316
|
+
};
|
|
317
|
+
const getJSON = () => {
|
|
318
|
+
var _editorRef$value7;
|
|
319
|
+
return (_editorRef$value7 = editorRef.value) === null || _editorRef$value7 === void 0 ? void 0 : _editorRef$value7.getEditorState().toJSON();
|
|
320
|
+
};
|
|
321
|
+
const getText = () => {
|
|
322
|
+
var _editorRef$value$getE2, _editorRef$value8;
|
|
323
|
+
return (_editorRef$value$getE2 = (_editorRef$value8 = editorRef.value) === null || _editorRef$value8 === void 0 ? void 0 : _editorRef$value8.getEditorState().read(() => $getRoot().getTextContent())) !== null && _editorRef$value$getE2 !== void 0 ? _editorRef$value$getE2 : "";
|
|
324
|
+
};
|
|
325
|
+
const getHTML = () => {
|
|
326
|
+
var _editor$getEditorStat;
|
|
327
|
+
const editor = editorRef.value;
|
|
328
|
+
return (_editor$getEditorStat = editor === null || editor === void 0 ? void 0 : editor.getEditorState().read(() => $generateHtmlFromNodes(editor))) !== null && _editor$getEditorStat !== void 0 ? _editor$getEditorStat : "";
|
|
329
|
+
};
|
|
330
|
+
const setHTML = (html, options) => {
|
|
331
|
+
const editor = editorRef.value;
|
|
332
|
+
if (!editor) return;
|
|
333
|
+
editor.update(() => {
|
|
334
|
+
const dom = new DOMParser().parseFromString(html, "text/html");
|
|
335
|
+
const nodes = $generateNodesFromDOM(editor, dom);
|
|
336
|
+
$getRoot().clear().append(...nodes);
|
|
337
|
+
}, withDiscreteUpdate(options));
|
|
338
|
+
};
|
|
339
|
+
const getMarkdown = (transformers = props.transformers) => {
|
|
340
|
+
var _editorRef$value$getE3, _editorRef$value9;
|
|
341
|
+
return (_editorRef$value$getE3 = (_editorRef$value9 = editorRef.value) === null || _editorRef$value9 === void 0 ? void 0 : _editorRef$value9.getEditorState().read(() => $convertToMarkdownString([...transformers]))) !== null && _editorRef$value$getE3 !== void 0 ? _editorRef$value$getE3 : "";
|
|
342
|
+
};
|
|
343
|
+
const setMarkdown = (markdown, transformers = props.transformers, options) => {
|
|
344
|
+
var _editorRef$value10;
|
|
345
|
+
(_editorRef$value10 = editorRef.value) === null || _editorRef$value10 === void 0 || _editorRef$value10.update(() => $convertFromMarkdownString(markdown, [...transformers]), withDiscreteUpdate(options));
|
|
346
|
+
};
|
|
347
|
+
const formatText = (format) => {
|
|
348
|
+
var _editorRef$value$disp, _editorRef$value11;
|
|
349
|
+
return (_editorRef$value$disp = (_editorRef$value11 = editorRef.value) === null || _editorRef$value11 === void 0 ? void 0 : _editorRef$value11.dispatchCommand(FORMAT_TEXT_COMMAND, format)) !== null && _editorRef$value$disp !== void 0 ? _editorRef$value$disp : false;
|
|
350
|
+
};
|
|
351
|
+
const undo = () => {
|
|
352
|
+
var _editorRef$value$disp2, _editorRef$value12;
|
|
353
|
+
return (_editorRef$value$disp2 = (_editorRef$value12 = editorRef.value) === null || _editorRef$value12 === void 0 ? void 0 : _editorRef$value12.dispatchCommand(UNDO_COMMAND, void 0)) !== null && _editorRef$value$disp2 !== void 0 ? _editorRef$value$disp2 : false;
|
|
354
|
+
};
|
|
355
|
+
const redo = () => {
|
|
356
|
+
var _editorRef$value$disp3, _editorRef$value13;
|
|
357
|
+
return (_editorRef$value$disp3 = (_editorRef$value13 = editorRef.value) === null || _editorRef$value13 === void 0 ? void 0 : _editorRef$value13.dispatchCommand(REDO_COMMAND, void 0)) !== null && _editorRef$value$disp3 !== void 0 ? _editorRef$value$disp3 : false;
|
|
358
|
+
};
|
|
359
|
+
function dispatchCommand(command, payload) {
|
|
360
|
+
var _editorRef$value$disp4, _editorRef$value14;
|
|
361
|
+
return (_editorRef$value$disp4 = (_editorRef$value14 = editorRef.value) === null || _editorRef$value14 === void 0 ? void 0 : _editorRef$value14.dispatchCommand(command, payload)) !== null && _editorRef$value$disp4 !== void 0 ? _editorRef$value$disp4 : false;
|
|
362
|
+
}
|
|
363
|
+
const warnNotReady = (method) => {
|
|
364
|
+
console.warn(`[RichTextEditor] ${method}() was called before the editor is ready; call it after the \`ready\` event.`);
|
|
365
|
+
};
|
|
366
|
+
function registerCommand(command, listener, priority) {
|
|
367
|
+
var _editorRef$value$regi, _editorRef$value15;
|
|
368
|
+
if (!editorRef.value) warnNotReady("registerCommand");
|
|
369
|
+
return (_editorRef$value$regi = (_editorRef$value15 = editorRef.value) === null || _editorRef$value15 === void 0 ? void 0 : _editorRef$value15.registerCommand(command, listener, priority)) !== null && _editorRef$value$regi !== void 0 ? _editorRef$value$regi : (() => {});
|
|
370
|
+
}
|
|
371
|
+
const registerUpdateListener = (listener) => {
|
|
372
|
+
var _editorRef$value$regi2, _editorRef$value16;
|
|
373
|
+
if (!editorRef.value) warnNotReady("registerUpdateListener");
|
|
374
|
+
return (_editorRef$value$regi2 = (_editorRef$value16 = editorRef.value) === null || _editorRef$value16 === void 0 ? void 0 : _editorRef$value16.registerUpdateListener(listener)) !== null && _editorRef$value$regi2 !== void 0 ? _editorRef$value$regi2 : (() => {});
|
|
375
|
+
};
|
|
376
|
+
const registerMutationListener = (klass, listener, options) => {
|
|
377
|
+
var _editorRef$value$regi3, _editorRef$value17;
|
|
378
|
+
if (!editorRef.value) warnNotReady("registerMutationListener");
|
|
379
|
+
return (_editorRef$value$regi3 = (_editorRef$value17 = editorRef.value) === null || _editorRef$value17 === void 0 ? void 0 : _editorRef$value17.registerMutationListener(klass, listener, options)) !== null && _editorRef$value$regi3 !== void 0 ? _editorRef$value$regi3 : (() => {});
|
|
380
|
+
};
|
|
381
|
+
function registerNodeTransform(klass, listener) {
|
|
382
|
+
var _editorRef$value$regi4, _editorRef$value18;
|
|
383
|
+
if (!editorRef.value) warnNotReady("registerNodeTransform");
|
|
384
|
+
return (_editorRef$value$regi4 = (_editorRef$value18 = editorRef.value) === null || _editorRef$value18 === void 0 ? void 0 : _editorRef$value18.registerNodeTransform(klass, listener)) !== null && _editorRef$value$regi4 !== void 0 ? _editorRef$value$regi4 : (() => {});
|
|
385
|
+
}
|
|
386
|
+
onMounted(() => {
|
|
387
|
+
var _props$editorConfig$n, _props$editorConfig2, _props$editorConfig$n2, _props$editorConfig3, _props$editorConfig5;
|
|
388
|
+
if (!rootRef.value) return;
|
|
389
|
+
const configuredNodes = (_props$editorConfig$n = (_props$editorConfig2 = props.editorConfig) === null || _props$editorConfig2 === void 0 ? void 0 : _props$editorConfig2.nodes) !== null && _props$editorConfig$n !== void 0 ? _props$editorConfig$n : [];
|
|
390
|
+
const editor = createEditor(_objectSpread2(_objectSpread2({}, props.editorConfig), {}, {
|
|
391
|
+
namespace: (_props$editorConfig$n2 = (_props$editorConfig3 = props.editorConfig) === null || _props$editorConfig3 === void 0 ? void 0 : _props$editorConfig3.namespace) !== null && _props$editorConfig$n2 !== void 0 ? _props$editorConfig$n2 : "SdRichTextEditor",
|
|
392
|
+
editable: !props.disabled && !props.readonly,
|
|
393
|
+
nodes: [
|
|
394
|
+
HeadingNode,
|
|
395
|
+
QuoteNode,
|
|
396
|
+
CodeNode,
|
|
397
|
+
CodeHighlightNode,
|
|
398
|
+
ListNode,
|
|
399
|
+
ListItemNode,
|
|
400
|
+
LinkNode,
|
|
401
|
+
AutoLinkNode,
|
|
402
|
+
InlineComponentNode,
|
|
403
|
+
...configuredNodes
|
|
404
|
+
],
|
|
405
|
+
onError: (error) => {
|
|
406
|
+
var _props$editorConfig4, _props$editorConfig4$;
|
|
407
|
+
emit("error", error);
|
|
408
|
+
(_props$editorConfig4 = props.editorConfig) === null || _props$editorConfig4 === void 0 || (_props$editorConfig4$ = _props$editorConfig4.onError) === null || _props$editorConfig4$ === void 0 || _props$editorConfig4$.call(_props$editorConfig4, error);
|
|
409
|
+
},
|
|
410
|
+
theme: _objectSpread2({
|
|
411
|
+
paragraph: `${prefixCls}-paragraph`,
|
|
412
|
+
quote: `${prefixCls}-quote`,
|
|
413
|
+
heading: {
|
|
414
|
+
h1: `${prefixCls}-heading-h1`,
|
|
415
|
+
h2: `${prefixCls}-heading-h2`,
|
|
416
|
+
h3: `${prefixCls}-heading-h3`,
|
|
417
|
+
h4: `${prefixCls}-heading-h4`,
|
|
418
|
+
h5: `${prefixCls}-heading-h5`,
|
|
419
|
+
h6: `${prefixCls}-heading-h6`
|
|
420
|
+
},
|
|
421
|
+
list: {
|
|
422
|
+
listitem: `${prefixCls}-list-item`,
|
|
423
|
+
nested: { listitem: `${prefixCls}-list-item-nested` },
|
|
424
|
+
ol: `${prefixCls}-list-ordered`,
|
|
425
|
+
ul: `${prefixCls}-list-unordered`
|
|
426
|
+
},
|
|
427
|
+
link: `${prefixCls}-link`,
|
|
428
|
+
code: `${prefixCls}-code`,
|
|
429
|
+
text: {
|
|
430
|
+
bold: `${prefixCls}-text-bold`,
|
|
431
|
+
italic: `${prefixCls}-text-italic`,
|
|
432
|
+
underline: `${prefixCls}-text-underline`,
|
|
433
|
+
strikethrough: `${prefixCls}-text-strikethrough`,
|
|
434
|
+
code: `${prefixCls}-text-code`
|
|
435
|
+
}
|
|
436
|
+
}, (_props$editorConfig5 = props.editorConfig) === null || _props$editorConfig5 === void 0 ? void 0 : _props$editorConfig5.theme)
|
|
437
|
+
}));
|
|
438
|
+
editorRef.value = editor;
|
|
439
|
+
editor.setRootElement(rootRef.value);
|
|
440
|
+
cleanups.push(registerRichText(editor));
|
|
441
|
+
cleanups.push(editor.registerUpdateListener(handleUpdate));
|
|
442
|
+
cleanups.push(editor.registerCommand(CAN_UNDO_COMMAND, (value) => {
|
|
443
|
+
canUndo.value = value;
|
|
444
|
+
return false;
|
|
445
|
+
}, COMMAND_PRIORITY_LOW), editor.registerCommand(CAN_REDO_COMMAND, (value) => {
|
|
446
|
+
canRedo.value = value;
|
|
447
|
+
return false;
|
|
448
|
+
}, COMMAND_PRIORITY_LOW));
|
|
449
|
+
if (props.history) cleanups.push(registerHistory(editor, createEmptyHistoryState(), props.historyDelay, Date.now, void 0, props.historyMaxDepth));
|
|
450
|
+
for (const plugin of props.plugins) {
|
|
451
|
+
const cleanup = plugin(editor, { rootElement: rootRef.value });
|
|
452
|
+
if (cleanup) cleanups.push(cleanup);
|
|
453
|
+
}
|
|
454
|
+
applyInitialValue();
|
|
455
|
+
emit("ready", editor);
|
|
456
|
+
nextTick(refreshComponentHosts);
|
|
457
|
+
});
|
|
458
|
+
watch(() => props.modelValue, (value) => {
|
|
459
|
+
if (!value || !editorRef.value) return;
|
|
460
|
+
if (serializeValue(value) === lastSerialized) return;
|
|
461
|
+
applyingExternalValue = true;
|
|
462
|
+
setJSON(value, { tag: "sd-rich-text-external" });
|
|
463
|
+
queueMicrotask(() => {
|
|
464
|
+
applyingExternalValue = false;
|
|
465
|
+
});
|
|
466
|
+
}, { deep: true });
|
|
467
|
+
watch(() => [props.disabled, props.readonly], ([disabled, readonly]) => {
|
|
468
|
+
var _editorRef$value19;
|
|
469
|
+
(_editorRef$value19 = editorRef.value) === null || _editorRef$value19 === void 0 || _editorRef$value19.setEditable(!disabled && !readonly);
|
|
470
|
+
});
|
|
471
|
+
onBeforeUnmount(() => {
|
|
472
|
+
var _cleanups$pop, _editorRef$value20;
|
|
473
|
+
while (cleanups.length) (_cleanups$pop = cleanups.pop()) === null || _cleanups$pop === void 0 || _cleanups$pop();
|
|
474
|
+
(_editorRef$value20 = editorRef.value) === null || _editorRef$value20 === void 0 || _editorRef$value20.setRootElement(null);
|
|
475
|
+
editorRef.value = null;
|
|
476
|
+
componentHosts.value = [];
|
|
477
|
+
});
|
|
478
|
+
__expose({
|
|
479
|
+
get editor() {
|
|
480
|
+
return editorRef.value;
|
|
481
|
+
},
|
|
482
|
+
get editorState() {
|
|
483
|
+
var _editorRef$value$getE4, _editorRef$value21;
|
|
484
|
+
return (_editorRef$value$getE4 = (_editorRef$value21 = editorRef.value) === null || _editorRef$value21 === void 0 ? void 0 : _editorRef$value21.getEditorState()) !== null && _editorRef$value$getE4 !== void 0 ? _editorRef$value$getE4 : null;
|
|
485
|
+
},
|
|
486
|
+
get rootElement() {
|
|
487
|
+
var _rootRef$value;
|
|
488
|
+
return (_rootRef$value = rootRef.value) !== null && _rootRef$value !== void 0 ? _rootRef$value : null;
|
|
489
|
+
},
|
|
490
|
+
get canUndo() {
|
|
491
|
+
return canUndo.value;
|
|
492
|
+
},
|
|
493
|
+
get canRedo() {
|
|
494
|
+
return canRedo.value;
|
|
495
|
+
},
|
|
496
|
+
focus: (callback, options = {}) => {
|
|
497
|
+
const { selection, preventScroll } = options, focusOptions = _objectWithoutProperties(options, _excluded3);
|
|
498
|
+
const editor = editorRef.value;
|
|
499
|
+
if (preventScroll) {
|
|
500
|
+
editor === null || editor === void 0 || editor.update(() => {
|
|
501
|
+
const root = $getRoot();
|
|
502
|
+
if (selection === "start") root.selectStart();
|
|
503
|
+
else if (selection === "end") root.selectEnd();
|
|
504
|
+
else if (selection === "all") root.select(0, root.getChildrenSize());
|
|
505
|
+
else {
|
|
506
|
+
const currentSelection = $getSelection();
|
|
507
|
+
if (currentSelection) $setSelection(currentSelection.clone());
|
|
508
|
+
else if (root.getChildrenSize()) if (focusOptions.defaultSelection === "rootStart") root.selectStart();
|
|
509
|
+
else root.selectEnd();
|
|
510
|
+
}
|
|
511
|
+
}, {
|
|
512
|
+
discrete: true,
|
|
513
|
+
onUpdate: callback,
|
|
514
|
+
tag: SKIP_SCROLL_INTO_VIEW_TAG
|
|
515
|
+
});
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
if (selection) editor === null || editor === void 0 || editor.update(() => {
|
|
519
|
+
const root = $getRoot();
|
|
520
|
+
if (selection === "start") root.selectStart();
|
|
521
|
+
if (selection === "end") root.selectEnd();
|
|
522
|
+
if (selection === "all") root.select(0, root.getChildrenSize());
|
|
523
|
+
}, { discrete: true });
|
|
524
|
+
editor === null || editor === void 0 || editor.focus(callback, focusOptions);
|
|
525
|
+
},
|
|
526
|
+
blur: () => {
|
|
527
|
+
var _editorRef$value22;
|
|
528
|
+
return (_editorRef$value22 = editorRef.value) === null || _editorRef$value22 === void 0 ? void 0 : _editorRef$value22.blur();
|
|
529
|
+
},
|
|
530
|
+
clear,
|
|
531
|
+
undo,
|
|
532
|
+
redo,
|
|
533
|
+
getJSON,
|
|
534
|
+
setJSON,
|
|
535
|
+
getContent,
|
|
536
|
+
setContent,
|
|
537
|
+
insertContent,
|
|
538
|
+
getText,
|
|
539
|
+
getHTML,
|
|
540
|
+
setHTML,
|
|
541
|
+
getMarkdown,
|
|
542
|
+
setMarkdown,
|
|
543
|
+
insertText,
|
|
544
|
+
insertComponent,
|
|
545
|
+
updateComponent,
|
|
546
|
+
removeComponent,
|
|
547
|
+
formatText,
|
|
548
|
+
read: (callback) => {
|
|
549
|
+
var _editorRef$value23;
|
|
550
|
+
return (_editorRef$value23 = editorRef.value) === null || _editorRef$value23 === void 0 ? void 0 : _editorRef$value23.getEditorState().read(callback);
|
|
551
|
+
},
|
|
552
|
+
update: (callback, options) => {
|
|
553
|
+
var _editorRef$value24;
|
|
554
|
+
return (_editorRef$value24 = editorRef.value) === null || _editorRef$value24 === void 0 ? void 0 : _editorRef$value24.update(callback, options);
|
|
555
|
+
},
|
|
556
|
+
dispatchCommand,
|
|
557
|
+
registerCommand,
|
|
558
|
+
registerUpdateListener,
|
|
559
|
+
registerMutationListener,
|
|
560
|
+
registerNodeTransform
|
|
561
|
+
});
|
|
562
|
+
return (_ctx, _cache) => {
|
|
563
|
+
var _props$styles, _props$classNames, _props$styles2, _props$classNames2, _props$styles3;
|
|
564
|
+
return openBlock(), createElementBlock("div", {
|
|
565
|
+
ref_key: "containerRef",
|
|
566
|
+
ref: containerRef,
|
|
567
|
+
class: normalizeClass(rootClass.value),
|
|
568
|
+
style: normalizeStyle((_props$styles = __props.styles) === null || _props$styles === void 0 ? void 0 : _props$styles.root)
|
|
569
|
+
}, [
|
|
570
|
+
createElementVNode("div", {
|
|
571
|
+
ref_key: "rootRef",
|
|
572
|
+
ref: rootRef,
|
|
573
|
+
class: normalizeClass([`${unref(prefixCls)}-content`, (_props$classNames = __props.classNames) === null || _props$classNames === void 0 ? void 0 : _props$classNames.content]),
|
|
574
|
+
style: normalizeStyle([contentStyle.value, (_props$styles2 = __props.styles) === null || _props$styles2 === void 0 ? void 0 : _props$styles2.content]),
|
|
575
|
+
role: "textbox",
|
|
576
|
+
"aria-multiline": "true",
|
|
577
|
+
"aria-label": resolvedAriaLabel.value,
|
|
578
|
+
"aria-disabled": __props.disabled || void 0,
|
|
579
|
+
"aria-readonly": __props.readonly || void 0,
|
|
580
|
+
spellcheck: __props.spellcheck,
|
|
581
|
+
contenteditable: !__props.disabled && !__props.readonly,
|
|
582
|
+
onFocus: _cache[0] || (_cache[0] = ($event) => emit("focus", $event)),
|
|
583
|
+
onBlur: _cache[1] || (_cache[1] = ($event) => emit("blur", $event))
|
|
584
|
+
}, null, 46, _hoisted_1),
|
|
585
|
+
isEmpty.value ? (openBlock(), createElementBlock("div", {
|
|
586
|
+
key: 0,
|
|
587
|
+
class: normalizeClass([`${unref(prefixCls)}-placeholder`, (_props$classNames2 = __props.classNames) === null || _props$classNames2 === void 0 ? void 0 : _props$classNames2.placeholder]),
|
|
588
|
+
style: normalizeStyle((_props$styles3 = __props.styles) === null || _props$styles3 === void 0 ? void 0 : _props$styles3.placeholder),
|
|
589
|
+
"aria-hidden": "true"
|
|
590
|
+
}, [renderSlot(_ctx.$slots, "placeholder", {}, () => [createTextVNode(toDisplayString(__props.placeholder), 1)])], 6)) : createCommentVNode("", true),
|
|
591
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(componentHosts.value, (host) => {
|
|
592
|
+
var _props$classNames3, _props$styles4;
|
|
593
|
+
return openBlock(), createBlock(Teleport, {
|
|
594
|
+
key: host.nodeKey,
|
|
595
|
+
to: host.element
|
|
596
|
+
}, [createElementVNode("span", {
|
|
597
|
+
class: normalizeClass((_props$classNames3 = __props.classNames) === null || _props$classNames3 === void 0 ? void 0 : _props$classNames3.component),
|
|
598
|
+
style: normalizeStyle((_props$styles4 = __props.styles) === null || _props$styles4 === void 0 ? void 0 : _props$styles4.component)
|
|
599
|
+
}, [_ctx.$slots[`node-${host.node.name}`] ? renderSlot(_ctx.$slots, `node-${host.node.name}`, {
|
|
600
|
+
nodeKey: host.nodeKey,
|
|
601
|
+
node: host.node,
|
|
602
|
+
disabled: __props.disabled,
|
|
603
|
+
readonly: __props.readonly,
|
|
604
|
+
update: (value) => updateComponent(host.nodeKey, value),
|
|
605
|
+
remove: () => removeComponent(host.nodeKey),
|
|
606
|
+
editor: host.editor
|
|
607
|
+
}, void 0, void 0, 0) : (openBlock(), createBlock(rich_text_node_renderer_default, {
|
|
608
|
+
key: 1,
|
|
609
|
+
node: host.node,
|
|
610
|
+
disabled: __props.disabled,
|
|
611
|
+
readonly: __props.readonly,
|
|
612
|
+
onUpdate: ($event) => updateComponent(host.nodeKey, $event),
|
|
613
|
+
onRemove: ($event) => removeComponent(host.nodeKey)
|
|
614
|
+
}, {
|
|
615
|
+
default: withCtx(() => [createElementVNode("span", { class: normalizeClass(`${unref(prefixCls)}-component-fallback`) }, toDisplayString(host.node.textValue), 3)]),
|
|
616
|
+
_: 2
|
|
617
|
+
}, 1032, [
|
|
618
|
+
"node",
|
|
619
|
+
"disabled",
|
|
620
|
+
"readonly",
|
|
621
|
+
"onUpdate",
|
|
622
|
+
"onRemove"
|
|
623
|
+
]))], 6)], 8, ["to"]);
|
|
624
|
+
}), 128))
|
|
625
|
+
], 6);
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
}));
|
|
629
|
+
//#endregion
|
|
630
|
+
export { rich_text_editor_vue_vue_type_script_setup_true_lang_default as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import rich_text_node_renderer_vue_vue_type_script_setup_true_lang_default from "./rich-text-node-renderer.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
//#region components/rich-text-editor/rich-text-node-renderer.vue
|
|
3
|
+
var rich_text_node_renderer_default = rich_text_node_renderer_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { rich_text_node_renderer_default as default };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { JsonValue } from 'type-fest';
|
|
2
|
+
import type { RichTextEditorComponentNodeSnapshot } from './types';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
node: RichTextEditorComponentNodeSnapshot;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
readonly?: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare var __VLS_10: {}, __VLS_27: {};
|
|
9
|
+
type __VLS_Slots = {} & {
|
|
10
|
+
default?: (props: typeof __VLS_10) => any;
|
|
11
|
+
} & {
|
|
12
|
+
default?: (props: typeof __VLS_27) => any;
|
|
13
|
+
};
|
|
14
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
15
|
+
update: (value: JsonValue) => any;
|
|
16
|
+
remove: () => any;
|
|
17
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
18
|
+
onUpdate?: ((value: JsonValue) => any) | undefined;
|
|
19
|
+
onRemove?: (() => any) | undefined;
|
|
20
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
21
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
22
|
+
declare const _default: typeof __VLS_export;
|
|
23
|
+
export default _default;
|
|
24
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
25
|
+
new (): {
|
|
26
|
+
$slots: S;
|
|
27
|
+
};
|
|
28
|
+
};
|