pro-comp-x 0.0.1 → 0.0.2
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/README.md +57 -12
- package/compiled/@ant-design/icons/index.js +1 -0
- package/compiled/@ant-design/icons/package.json +1 -0
- package/compiled/antd/index.d.ts +482 -0
- package/compiled/antd/index.js +29 -0
- package/compiled/antd/package.json +1 -0
- package/compiled/classnames/index.js +7 -0
- package/compiled/classnames/package.json +1 -0
- package/compiled/dayjs/index.js +1 -0
- package/compiled/dayjs/package.json +1 -0
- package/dist/404.html +36 -0
- package/dist/esm/antd-alias/antd.less +30 -0
- package/dist/esm/antd-alias/button.d.ts +2 -0
- package/dist/esm/antd-alias/button.js +2 -0
- package/dist/esm/antd-alias/cascader.d.ts +2 -0
- package/dist/esm/antd-alias/cascader.js +2 -0
- package/dist/esm/antd-alias/checkbox.d.ts +2 -0
- package/dist/esm/antd-alias/checkbox.js +2 -0
- package/dist/esm/antd-alias/col.d.ts +2 -0
- package/dist/esm/antd-alias/col.js +2 -0
- package/dist/esm/antd-alias/config-provider.d.ts +2 -0
- package/dist/esm/antd-alias/config-provider.js +2 -0
- package/dist/esm/antd-alias/date-picker.d.ts +2 -0
- package/dist/esm/antd-alias/date-picker.js +2 -0
- package/dist/esm/antd-alias/form.d.ts +2 -0
- package/dist/esm/antd-alias/form.js +2 -0
- package/dist/esm/antd-alias/index.d.ts +36 -0
- package/dist/esm/antd-alias/index.js +48 -0
- package/dist/esm/antd-alias/input-number.d.ts +2 -0
- package/dist/esm/antd-alias/input-number.js +2 -0
- package/dist/esm/antd-alias/input.d.ts +2 -0
- package/dist/esm/antd-alias/input.js +2 -0
- package/dist/esm/antd-alias/mentions.d.ts +2 -0
- package/dist/esm/antd-alias/mentions.js +2 -0
- package/dist/esm/antd-alias/modal.d.ts +2 -0
- package/dist/esm/antd-alias/modal.js +2 -0
- package/dist/esm/antd-alias/pagination.d.ts +2 -0
- package/dist/esm/antd-alias/pagination.js +2 -0
- package/dist/esm/antd-alias/popover.d.ts +2 -0
- package/dist/esm/antd-alias/popover.js +2 -0
- package/dist/esm/antd-alias/radio.d.ts +2 -0
- package/dist/esm/antd-alias/radio.js +2 -0
- package/dist/esm/antd-alias/row.d.ts +2 -0
- package/dist/esm/antd-alias/row.js +2 -0
- package/dist/esm/antd-alias/select.d.ts +2 -0
- package/dist/esm/antd-alias/select.js +2 -0
- package/dist/esm/antd-alias/slider.d.ts +2 -0
- package/dist/esm/antd-alias/slider.js +2 -0
- package/dist/esm/antd-alias/spin.d.ts +2 -0
- package/dist/esm/antd-alias/spin.js +2 -0
- package/dist/esm/antd-alias/switch.d.ts +2 -0
- package/dist/esm/antd-alias/switch.js +2 -0
- package/dist/esm/antd-alias/table.d.ts +2 -0
- package/dist/esm/antd-alias/table.js +2 -0
- package/dist/esm/antd-alias/tabs.d.ts +2 -0
- package/dist/esm/antd-alias/tabs.js +2 -0
- package/dist/esm/antd-alias/time-picker.d.ts +2 -0
- package/dist/esm/antd-alias/time-picker.js +2 -0
- package/dist/esm/antd-alias/tooltip.d.ts +2 -0
- package/dist/esm/antd-alias/tooltip.js +2 -0
- package/dist/esm/antd-alias/tree-select.d.ts +2 -0
- package/dist/esm/antd-alias/tree-select.js +2 -0
- package/dist/esm/antd-alias/upload.d.ts +2 -0
- package/dist/esm/antd-alias/upload.js +2 -0
- package/dist/esm/components/ComponentExtends/DatePicker/index.d.ts +9 -0
- package/dist/esm/components/ComponentExtends/DatePicker/index.js +5 -12
- package/dist/esm/components/ComponentExtends/InputBox/index.d.ts +31 -0
- package/dist/esm/components/ComponentExtends/InputBox/index.js +3 -4
- package/dist/esm/components/ComponentExtends/InputSearch/index.d.ts +9 -0
- package/dist/esm/components/ComponentExtends/InputSearch/index.js +3 -10
- package/dist/esm/components/ComponentExtends/InputTooltip/index.d.ts +11 -0
- package/dist/esm/components/ComponentExtends/InputTooltip/index.js +18 -28
- package/dist/esm/components/ComponentExtends/Modal/index.d.ts +15 -0
- package/dist/esm/components/ComponentExtends/Modal/index.js +4 -13
- package/dist/esm/components/ComponentExtends/NumberRange/index.d.ts +13 -0
- package/dist/esm/components/ComponentExtends/NumberRange/index.js +21 -30
- package/dist/esm/components/ComponentExtends/Raido/index.d.ts +10 -0
- package/dist/esm/components/ComponentExtends/Raido/index.js +3 -10
- package/dist/esm/components/ComponentExtends/SelectQuery/index.d.ts +32 -0
- package/dist/esm/components/ComponentExtends/SelectQuery/index.js +40 -51
- package/dist/esm/components/ComponentExtends/TableEditCell/index.d.ts +20 -0
- package/dist/esm/components/ComponentExtends/TableEditCell/index.js +5 -19
- package/dist/esm/components/ComponentExtends/Tabs/index.d.ts +8 -0
- package/dist/esm/components/ComponentExtends/Tabs/index.js +11 -16
- package/dist/esm/components/ComponentExtends/Text/index.d.ts +4 -0
- package/dist/esm/components/ComponentExtends/Text/index.js +1 -4
- package/dist/esm/components/ComponentExtends/TimePicker/index.d.ts +6 -0
- package/dist/esm/components/ComponentExtends/TimePicker/index.js +5 -12
- package/dist/esm/components/ComponentExtends/UploadImages/index.d.ts +8 -0
- package/dist/esm/components/ComponentExtends/UploadImages/index.js +10 -23
- package/dist/esm/components/ComponentExtends/index.d.ts +15 -0
- package/dist/esm/components/DndProvider/index.d.ts +7 -0
- package/dist/esm/components/DndProvider/index.js +15 -0
- package/dist/esm/components/DraggableBodyRow/DraggableBodyRow.less +16 -14
- package/dist/esm/components/DraggableBodyRow/index.d.ts +18 -0
- package/dist/esm/components/DraggableBodyRow/index.js +2 -2
- package/dist/esm/components/DraggableCell/index.d.ts +40 -0
- package/dist/esm/components/DraggableCell/index.js +23 -10
- package/dist/esm/components/DraggableTabNode/index.d.ts +7 -0
- package/dist/esm/components/DraggableTabNode/index.js +3 -5
- package/dist/esm/components/DraggableTable/DraggableTable.less +31 -0
- package/dist/esm/components/DraggableTable/index.d.ts +23 -0
- package/dist/esm/components/DraggableTable/index.js +170 -0
- package/dist/esm/components/PageList/FilterForm/index.d.ts +53 -0
- package/dist/esm/components/PageList/FilterForm/index.js +52 -66
- package/dist/esm/components/PageList/index.d.ts +76 -0
- package/dist/esm/components/PageList/index.js +148 -138
- package/dist/esm/components/PageWraper/index.d.ts +13 -0
- package/dist/esm/components/PageWraper/index.js +8 -13
- package/dist/esm/components/Panel/Panel.less +2 -0
- package/dist/esm/components/Panel/index.d.ts +20 -0
- package/dist/esm/components/Panel/index.js +17 -27
- package/dist/esm/components/ProConfigProvider/context.d.ts +17 -0
- package/dist/esm/components/ProConfigProvider/context.js +6 -1
- package/dist/esm/components/ProConfigProvider/index.d.ts +10 -0
- package/dist/esm/components/ProConfigProvider/index.js +4 -9
- package/dist/esm/components/RenderForm/RenderForm.less +19 -0
- package/dist/esm/components/RenderForm/index.d.ts +64 -0
- package/dist/esm/components/RenderForm/index.js +106 -103
- package/dist/esm/index.d.ts +25 -0
- package/dist/esm/index.js +4 -17
- package/dist/esm/styles/antd-custom.less +5 -0
- package/dist/esm/styles/base.less +3 -6
- package/dist/esm/styles/dumi.less +17 -0
- package/dist/esm/styles/index.less +1 -0
- package/dist/esm/utils/getClassPrefix.d.ts +2 -0
- package/dist/index.css +26895 -0
- package/dist/index.html +36 -0
- package/dist/pro-components-dark.css +1 -0
- package/dist/pro-components-default.css +1 -0
- package/dist/umi.css +2 -0
- package/dist/umi.js +1 -0
- package/package.json +29 -30
- package/public/pro-components-dark.css +19 -0
- package/public/pro-components-default.css +23 -0
- package/dist/esm/components/ActionConfigForm/index.js +0 -129
- package/dist/esm/components/ColorPalette/ColorPalette.less +0 -9
- package/dist/esm/components/ColorPalette/index.js +0 -88
- package/dist/esm/components/MarkdownView/MarkdownView.less +0 -93
- package/dist/esm/components/MarkdownView/index.js +0 -142
- package/dist/esm/components/MdPlainText/MdPlainText.less +0 -118
- package/dist/esm/components/MdPlainText/constants.js +0 -2
- package/dist/esm/components/MdPlainText/index.js +0 -717
- package/dist/esm/components/MdPlainText/planinShortcuts.js +0 -18
- package/dist/esm/components/MdPlainText/textContent.js +0 -4
- package/dist/esm/components/MdPlainText/utils.js +0 -159
- package/dist/esm/components/PlainText/index.js +0 -122
- package/dist/esm/components/PlainTextBox/PlainTextBox.less +0 -94
- package/dist/esm/components/PlainTextBox/index.js +0 -264
|
@@ -1,717 +0,0 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
import "antd/es/select/style";
|
|
3
|
-
import _Select from "antd/es/select";
|
|
4
|
-
import "antd/es/tooltip/style";
|
|
5
|
-
import _Tooltip from "antd/es/tooltip";
|
|
6
|
-
import "antd/es/button/style";
|
|
7
|
-
import _Button from "antd/es/button";
|
|
8
|
-
import "antd/es/message/style";
|
|
9
|
-
import _message from "antd/es/message";
|
|
10
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
14
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
16
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
17
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
18
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
19
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
20
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
21
|
-
import React, { useMemo, useState, useCallback, useImperativeHandle, forwardRef, memo, useEffect } from 'react';
|
|
22
|
-
import { createEditor, Transforms, Range, Editor, Text, Node as SlateNode } from 'slate';
|
|
23
|
-
import { Slate, Editable, ReactEditor, withReact } from 'slate-react';
|
|
24
|
-
import { isKeyHotkey } from 'is-hotkey';
|
|
25
|
-
import classnames from 'classnames';
|
|
26
|
-
import { withHistory, HistoryEditor } from 'slate-history';
|
|
27
|
-
import { serialize, deserialize, splitWords } from "./utils";
|
|
28
|
-
import { withInlines } from "./planinShortcuts";
|
|
29
|
-
import { STYLE_ATTR } from "./constants";
|
|
30
|
-
import MarkdownView from "../MarkdownView";
|
|
31
|
-
import { FontColorsOutlined, HighlightOutlined, ItalicOutlined, StrikethroughOutlined, BoldOutlined, EyeInvisibleOutlined, ApiOutlined, EyeOutlined, ClearOutlined, RedoOutlined, UndoOutlined } from '@ant-design/icons';
|
|
32
|
-
import ActionConfigForm from "../ActionConfigForm";
|
|
33
|
-
import ColorPalette from "../ColorPalette";
|
|
34
|
-
import { ConfigContext } from 'antd/es/config-provider';
|
|
35
|
-
import getClassPrefix from "../../utils/getClassPrefix";
|
|
36
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
37
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
38
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
39
|
-
var MdPlainText = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
40
|
-
var prefixCls = _ref.prefixCls,
|
|
41
|
-
value = _ref.value,
|
|
42
|
-
_onChange = _ref.onChange,
|
|
43
|
-
className = _ref.className,
|
|
44
|
-
onCompositionStart = _ref.onCompositionStart,
|
|
45
|
-
onCompositionEnd = _ref.onCompositionEnd,
|
|
46
|
-
onKeyDown = _ref.onKeyDown,
|
|
47
|
-
onFocus = _ref.onFocus,
|
|
48
|
-
onBlur = _ref.onBlur,
|
|
49
|
-
hotKeys = _ref.hotKeys,
|
|
50
|
-
setPopverOpen = _ref.setPopverOpen,
|
|
51
|
-
actionWidgetItems = _ref.actionWidgetItems,
|
|
52
|
-
_ref$tools = _ref.tools,
|
|
53
|
-
tools = _ref$tools === void 0 ? ['color', 'backgroundColor', 'title', 'bold', 'italic', 'delete', 'fontSize', 'preview', 'clear', 'action', 'redo', 'undo'] : _ref$tools,
|
|
54
|
-
_ref$readOnly = _ref.readOnly,
|
|
55
|
-
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
56
|
-
_ref$disabled = _ref.disabled,
|
|
57
|
-
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
58
|
-
_ref$preview = _ref.preview,
|
|
59
|
-
preview = _ref$preview === void 0 ? true : _ref$preview,
|
|
60
|
-
_ref$placeholder = _ref.placeholder,
|
|
61
|
-
placeholder = _ref$placeholder === void 0 ? '请输入' : _ref$placeholder,
|
|
62
|
-
toggleMouseWheel = _ref.toggleMouseWheel,
|
|
63
|
-
extra = _ref.extra;
|
|
64
|
-
var _useState = useState(false),
|
|
65
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
66
|
-
actionFormVisible = _useState2[0],
|
|
67
|
-
setActionFormVisible = _useState2[1];
|
|
68
|
-
var _useState3 = useState({}),
|
|
69
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
70
|
-
actionValues = _useState4[0],
|
|
71
|
-
setActionValues = _useState4[1];
|
|
72
|
-
var _React$useContext = React.useContext(ConfigContext),
|
|
73
|
-
antGetPrefixCls = _React$useContext.getPrefixCls;
|
|
74
|
-
var antPrefixCls = antGetPrefixCls(prefixCls);
|
|
75
|
-
var clsPrefix = getClassPrefix(antPrefixCls, 'plain-markdown');
|
|
76
|
-
var _useState5 = useState(''),
|
|
77
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
78
|
-
markdownContent = _useState6[0],
|
|
79
|
-
setMarkdownContent = _useState6[1];
|
|
80
|
-
var _useState7 = useState(false),
|
|
81
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
82
|
-
showPreview = _useState8[0],
|
|
83
|
-
setShowPreview = _useState8[1];
|
|
84
|
-
var editor = useMemo(function () {
|
|
85
|
-
return withInlines(withHistory(withReact(createEditor())));
|
|
86
|
-
}, []);
|
|
87
|
-
var isDisabled = useMemo(function () {
|
|
88
|
-
return readOnly || disabled;
|
|
89
|
-
}, [readOnly, disabled]);
|
|
90
|
-
var initialValue = useMemo(function () {
|
|
91
|
-
var initValue = value || '';
|
|
92
|
-
setMarkdownContent(initValue);
|
|
93
|
-
return deserialize(initValue);
|
|
94
|
-
}, []);
|
|
95
|
-
var onHandleKeyDown = function onHandleKeyDown(event) {
|
|
96
|
-
var selection = editor.selection;
|
|
97
|
-
if (event.key === 'Tab') {
|
|
98
|
-
event.preventDefault();
|
|
99
|
-
Transforms.insertText(editor, ' ');
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
if (onKeyDown) {
|
|
103
|
-
onKeyDown(event);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* 默认左/右行为为 unit:'character'.
|
|
108
|
-
* 无法区分两个游标位置, 如:
|
|
109
|
-
* <inline>foo<cursor/></inline> vs <inline>foo</inline><cursor/>
|
|
110
|
-
* 这里我们将行为修改为 unit:'offset'
|
|
111
|
-
*/
|
|
112
|
-
if (selection && Range.isCollapsed(selection)) {
|
|
113
|
-
var nativeEvent = event.nativeEvent;
|
|
114
|
-
if (isKeyHotkey('left', nativeEvent)) {
|
|
115
|
-
event.preventDefault();
|
|
116
|
-
Transforms.move(editor, {
|
|
117
|
-
unit: 'offset',
|
|
118
|
-
reverse: true
|
|
119
|
-
});
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
if (isKeyHotkey('right', nativeEvent)) {
|
|
123
|
-
event.preventDefault();
|
|
124
|
-
Transforms.move(editor, {
|
|
125
|
-
unit: 'offset'
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
// 监听文本坐标变化
|
|
132
|
-
var watchPreviousCharacter = function watchPreviousCharacter() {
|
|
133
|
-
var selection = editor.selection;
|
|
134
|
-
if (!selection) return;
|
|
135
|
-
// 获取当前路径上的文本节点
|
|
136
|
-
var textNode = Editor.node(editor, selection)[0];
|
|
137
|
-
if (Text.isText(textNode)) {
|
|
138
|
-
var _selection$focus;
|
|
139
|
-
var nodeStr = SlateNode.string(textNode);
|
|
140
|
-
var lastStr = nodeStr && nodeStr.length > 0 ? nodeStr[(selection === null || selection === void 0 || (_selection$focus = selection.focus) === null || _selection$focus === void 0 ? void 0 : _selection$focus.offset) - 1] : null;
|
|
141
|
-
if (Array.isArray(hotKeys) && hotKeys.length > 0 && lastStr && hotKeys.includes(lastStr)) {
|
|
142
|
-
setPopverOpen === null || setPopverOpen === void 0 || setPopverOpen(true);
|
|
143
|
-
} else {
|
|
144
|
-
setPopverOpen === null || setPopverOpen === void 0 || setPopverOpen(false);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
var getEditorMarks = function getEditorMarks(editor) {
|
|
149
|
-
var marks = Editor.marks(editor);
|
|
150
|
-
return marks;
|
|
151
|
-
};
|
|
152
|
-
var InlineChromiumBugfix = function InlineChromiumBugfix() {
|
|
153
|
-
return /*#__PURE__*/_jsx("span", {
|
|
154
|
-
contentEditable: false,
|
|
155
|
-
className: "".concat(clsPrefix, "-inline-chromium-bug-fix"),
|
|
156
|
-
children: String.fromCodePoint(160) /* Non-breaking space */
|
|
157
|
-
});
|
|
158
|
-
};
|
|
159
|
-
var getLeafStyle = function getLeafStyle(leafProps) {
|
|
160
|
-
var styleResult = {};
|
|
161
|
-
STYLE_ATTR.forEach(function (item) {
|
|
162
|
-
if (leafProps !== null && leafProps !== void 0 && leafProps[item]) {
|
|
163
|
-
styleResult[item] = leafProps === null || leafProps === void 0 ? void 0 : leafProps[item];
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
return styleResult;
|
|
167
|
-
};
|
|
168
|
-
var renderLeaf = function renderLeaf(props) {
|
|
169
|
-
var attributes = props.attributes,
|
|
170
|
-
children = props.children,
|
|
171
|
-
leaf = props.leaf;
|
|
172
|
-
if (leaf !== null && leaf !== void 0 && leaf.action) {
|
|
173
|
-
var attrsObj = {};
|
|
174
|
-
Object.keys(leaf === null || leaf === void 0 ? void 0 : leaf.action).forEach(function (item) {
|
|
175
|
-
var _leaf$action;
|
|
176
|
-
attrsObj["data-".concat(item)] = leaf === null || leaf === void 0 || (_leaf$action = leaf.action) === null || _leaf$action === void 0 ? void 0 : _leaf$action[item];
|
|
177
|
-
});
|
|
178
|
-
var styles = getLeafStyle(leaf);
|
|
179
|
-
return /*#__PURE__*/_jsxs("a", _objectSpread(_objectSpread(_objectSpread({}, attributes), attrsObj), {}, {
|
|
180
|
-
onClick: function onClick(ev) {
|
|
181
|
-
ev.stopPropagation();
|
|
182
|
-
ev.preventDefault();
|
|
183
|
-
},
|
|
184
|
-
style: styles,
|
|
185
|
-
children: [/*#__PURE__*/_jsx(InlineChromiumBugfix, {}), children, /*#__PURE__*/_jsx(InlineChromiumBugfix, {})]
|
|
186
|
-
}));
|
|
187
|
-
}
|
|
188
|
-
if (leaf !== null && leaf !== void 0 && leaf.color || leaf !== null && leaf !== void 0 && leaf.backgroundColor || leaf !== null && leaf !== void 0 && leaf.fontSize) {
|
|
189
|
-
var _styles = getLeafStyle(leaf);
|
|
190
|
-
return /*#__PURE__*/_jsxs("span", _objectSpread(_objectSpread({}, attributes), {}, {
|
|
191
|
-
style: _styles,
|
|
192
|
-
children: [/*#__PURE__*/_jsx(InlineChromiumBugfix, {}), children, /*#__PURE__*/_jsx(InlineChromiumBugfix, {})]
|
|
193
|
-
}));
|
|
194
|
-
}
|
|
195
|
-
return /*#__PURE__*/_jsx("span", _objectSpread(_objectSpread({}, attributes), {}, {
|
|
196
|
-
className: leaf.highlight ? "".concat(clsPrefix, "-badge") : '',
|
|
197
|
-
children: children
|
|
198
|
-
}));
|
|
199
|
-
};
|
|
200
|
-
var onWrapText = function onWrapText(textCont) {
|
|
201
|
-
var selection = editor.selection;
|
|
202
|
-
if (textCont && selection) {
|
|
203
|
-
var selectedText = Editor.string(editor, selection);
|
|
204
|
-
if (selectedText && selectedText.length > 0) {
|
|
205
|
-
Transforms.delete(editor);
|
|
206
|
-
Transforms.insertText(editor, "".concat(textCont).concat(selectedText).concat(textCont));
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
var checkSyntax = function checkSyntax(callback) {
|
|
211
|
-
var selection = editor.selection;
|
|
212
|
-
if (!selection) {
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
var selectedText = Editor.string(editor, selection);
|
|
216
|
-
var selectedMatch = selectedText.trim().match(/^\#{1,6}|\>|[-\+\*\|]|\d+\./);
|
|
217
|
-
if (selectedMatch) {
|
|
218
|
-
var _selectedMatch$;
|
|
219
|
-
_message.warn("\u8BF7\u4E0D\u8981\u9009\u4E2D".concat(selectedMatch === null || selectedMatch === void 0 || (_selectedMatch$ = selectedMatch[0]) === null || _selectedMatch$ === void 0 ? void 0 : _selectedMatch$.trim(), ",\u5426\u5219\u683C\u5F0F\u5C06\u5931\u6548,\u9009\u62E9\u666E\u901A\u6587\u672C"));
|
|
220
|
-
} else if (callback) {
|
|
221
|
-
callback();
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
var renderTools = function renderTools() {
|
|
225
|
-
var toolBtnProps = {
|
|
226
|
-
type: 'text',
|
|
227
|
-
size: 'small',
|
|
228
|
-
disabled: isDisabled
|
|
229
|
-
};
|
|
230
|
-
var toolTooltipProps = {
|
|
231
|
-
placement: 'top'
|
|
232
|
-
};
|
|
233
|
-
var marks = getEditorMarks(editor);
|
|
234
|
-
var toolItems = [{
|
|
235
|
-
type: 'color',
|
|
236
|
-
content: /*#__PURE__*/_jsx(ColorPalette, {
|
|
237
|
-
disabled: isDisabled,
|
|
238
|
-
onChange: function onChange(val) {
|
|
239
|
-
checkSyntax(function () {
|
|
240
|
-
Editor.addMark(editor, 'color', val);
|
|
241
|
-
});
|
|
242
|
-
},
|
|
243
|
-
onClear: function onClear() {
|
|
244
|
-
if (marks !== null && marks !== void 0 && marks.color) {
|
|
245
|
-
Editor.removeMark(editor, 'color');
|
|
246
|
-
}
|
|
247
|
-
},
|
|
248
|
-
children: /*#__PURE__*/_jsx(_Tooltip, _objectSpread(_objectSpread({}, toolTooltipProps), {}, {
|
|
249
|
-
title: "\u6587\u5B57\u989C\u8272",
|
|
250
|
-
children: /*#__PURE__*/_jsx(_Button, _objectSpread(_objectSpread({}, toolBtnProps), {}, {
|
|
251
|
-
icon: /*#__PURE__*/_jsx(FontColorsOutlined, {})
|
|
252
|
-
}))
|
|
253
|
-
}))
|
|
254
|
-
})
|
|
255
|
-
}, {
|
|
256
|
-
type: 'backgroundColor',
|
|
257
|
-
content: /*#__PURE__*/_jsx(ColorPalette, {
|
|
258
|
-
disabled: isDisabled,
|
|
259
|
-
onClear: function onClear() {
|
|
260
|
-
if (marks !== null && marks !== void 0 && marks.backgroundColor) {
|
|
261
|
-
Editor.removeMark(editor, 'backgroundColor');
|
|
262
|
-
}
|
|
263
|
-
},
|
|
264
|
-
onChange: function onChange(val) {
|
|
265
|
-
checkSyntax(function () {
|
|
266
|
-
if (!(marks !== null && marks !== void 0 && marks.backgroundColor)) {
|
|
267
|
-
Editor.addMark(editor, 'backgroundColor', val);
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
},
|
|
271
|
-
children: /*#__PURE__*/_jsx(_Tooltip, _objectSpread(_objectSpread({}, toolTooltipProps), {}, {
|
|
272
|
-
title: "\u6587\u5B57\u80CC\u666F",
|
|
273
|
-
children: /*#__PURE__*/_jsx(_Button, _objectSpread(_objectSpread({}, toolBtnProps), {}, {
|
|
274
|
-
icon: /*#__PURE__*/_jsx(HighlightOutlined, {})
|
|
275
|
-
}))
|
|
276
|
-
}))
|
|
277
|
-
})
|
|
278
|
-
}, {
|
|
279
|
-
type: 'bold',
|
|
280
|
-
content: /*#__PURE__*/_jsx(_Tooltip, _objectSpread(_objectSpread({}, toolTooltipProps), {}, {
|
|
281
|
-
title: "\u52A0\u7C97",
|
|
282
|
-
children: /*#__PURE__*/_jsx(_Button, _objectSpread(_objectSpread({}, toolBtnProps), {}, {
|
|
283
|
-
icon: /*#__PURE__*/_jsx(BoldOutlined, {}),
|
|
284
|
-
onClick: function onClick() {
|
|
285
|
-
onWrapText('**');
|
|
286
|
-
}
|
|
287
|
-
}))
|
|
288
|
-
}))
|
|
289
|
-
}, {
|
|
290
|
-
type: 'italic',
|
|
291
|
-
content: /*#__PURE__*/_jsx(_Tooltip, _objectSpread(_objectSpread({}, toolTooltipProps), {}, {
|
|
292
|
-
title: "\u659C\u4F53",
|
|
293
|
-
children: /*#__PURE__*/_jsx(_Button, _objectSpread(_objectSpread({}, toolBtnProps), {}, {
|
|
294
|
-
icon: /*#__PURE__*/_jsx(ItalicOutlined, {}),
|
|
295
|
-
onClick: function onClick() {
|
|
296
|
-
onWrapText('*');
|
|
297
|
-
}
|
|
298
|
-
}))
|
|
299
|
-
}))
|
|
300
|
-
}, {
|
|
301
|
-
type: 'delete',
|
|
302
|
-
content: /*#__PURE__*/_jsx(_Tooltip, _objectSpread(_objectSpread({}, toolTooltipProps), {}, {
|
|
303
|
-
title: "\u5220\u9664",
|
|
304
|
-
children: /*#__PURE__*/_jsx(_Button, _objectSpread(_objectSpread({}, toolBtnProps), {}, {
|
|
305
|
-
icon: /*#__PURE__*/_jsx(StrikethroughOutlined, {}),
|
|
306
|
-
onClick: function onClick() {
|
|
307
|
-
onWrapText('~~');
|
|
308
|
-
}
|
|
309
|
-
}))
|
|
310
|
-
}))
|
|
311
|
-
}, {
|
|
312
|
-
type: 'title',
|
|
313
|
-
content: /*#__PURE__*/_jsx(_Tooltip, _objectSpread(_objectSpread({}, toolTooltipProps), {}, {
|
|
314
|
-
title: "\u6807\u9898",
|
|
315
|
-
children: /*#__PURE__*/_jsx(_Select, {
|
|
316
|
-
disabled: isDisabled,
|
|
317
|
-
bordered: false,
|
|
318
|
-
defaultValue: "default",
|
|
319
|
-
className: "".concat(clsPrefix, "-font-size"),
|
|
320
|
-
size: "small",
|
|
321
|
-
options: [{
|
|
322
|
-
label: '正文',
|
|
323
|
-
value: 'default'
|
|
324
|
-
}, {
|
|
325
|
-
label: 'H1',
|
|
326
|
-
value: '1'
|
|
327
|
-
}, {
|
|
328
|
-
label: 'H2',
|
|
329
|
-
value: '2'
|
|
330
|
-
}, {
|
|
331
|
-
label: 'H3',
|
|
332
|
-
value: '3'
|
|
333
|
-
}, {
|
|
334
|
-
label: 'H4',
|
|
335
|
-
value: '4'
|
|
336
|
-
}, {
|
|
337
|
-
label: 'H5',
|
|
338
|
-
value: '5'
|
|
339
|
-
}, {
|
|
340
|
-
label: 'H6',
|
|
341
|
-
value: '6'
|
|
342
|
-
}],
|
|
343
|
-
onChange: function onChange(selected) {
|
|
344
|
-
var _matchTit$;
|
|
345
|
-
if (!editor.selection) return;
|
|
346
|
-
var start = Range.start(editor.selection);
|
|
347
|
-
var startPoint = Editor.start(editor, start.path);
|
|
348
|
-
var range = {
|
|
349
|
-
anchor: startPoint,
|
|
350
|
-
focus: start
|
|
351
|
-
};
|
|
352
|
-
var currentLineText = Editor.string(editor, range);
|
|
353
|
-
var titReg = /^\#{1,6} /;
|
|
354
|
-
var matchTit = currentLineText.match(titReg);
|
|
355
|
-
if (matchTit && matchTit !== null && matchTit !== void 0 && (_matchTit$ = matchTit[0]) !== null && _matchTit$ !== void 0 && _matchTit$.length) {
|
|
356
|
-
var _matchTit$2;
|
|
357
|
-
Transforms.delete(editor, {
|
|
358
|
-
at: _objectSpread(_objectSpread({}, range), {}, {
|
|
359
|
-
focus: _objectSpread(_objectSpread({}, range === null || range === void 0 ? void 0 : range.focus), {}, {
|
|
360
|
-
offset: matchTit === null || matchTit === void 0 || (_matchTit$2 = matchTit[0]) === null || _matchTit$2 === void 0 ? void 0 : _matchTit$2.length
|
|
361
|
-
})
|
|
362
|
-
})
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
|
-
if (selected !== 'default' && !isNaN(Number(selected))) {
|
|
366
|
-
var symbols = '#'.repeat(Number(selected));
|
|
367
|
-
Transforms.insertText(editor, "".concat(symbols, " "), {
|
|
368
|
-
at: startPoint
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
})
|
|
373
|
-
}))
|
|
374
|
-
}, {
|
|
375
|
-
type: 'fontSize',
|
|
376
|
-
content: /*#__PURE__*/_jsx(_Tooltip, _objectSpread(_objectSpread({}, toolTooltipProps), {}, {
|
|
377
|
-
title: "\u5B57\u53F7",
|
|
378
|
-
children: /*#__PURE__*/_jsx(_Select, {
|
|
379
|
-
disabled: isDisabled,
|
|
380
|
-
bordered: false,
|
|
381
|
-
defaultValue: "default",
|
|
382
|
-
className: "".concat(clsPrefix, "-font-size"),
|
|
383
|
-
size: "small",
|
|
384
|
-
options: [{
|
|
385
|
-
label: '默认',
|
|
386
|
-
value: 'default'
|
|
387
|
-
}, {
|
|
388
|
-
label: '12px',
|
|
389
|
-
value: '12px'
|
|
390
|
-
}, {
|
|
391
|
-
label: '16px',
|
|
392
|
-
value: '16px'
|
|
393
|
-
}, {
|
|
394
|
-
label: '18px',
|
|
395
|
-
value: '18px'
|
|
396
|
-
}, {
|
|
397
|
-
label: '20px',
|
|
398
|
-
value: '20px'
|
|
399
|
-
}, {
|
|
400
|
-
label: '24px',
|
|
401
|
-
value: '24px'
|
|
402
|
-
}, {
|
|
403
|
-
label: '28px',
|
|
404
|
-
value: '28px'
|
|
405
|
-
}, {
|
|
406
|
-
label: '32px',
|
|
407
|
-
value: '32px'
|
|
408
|
-
}, {
|
|
409
|
-
label: '40px',
|
|
410
|
-
value: '40px'
|
|
411
|
-
}],
|
|
412
|
-
onChange: function onChange(selectedSize) {
|
|
413
|
-
if (selectedSize === 'default' && marks !== null && marks !== void 0 && marks.fontSize) {
|
|
414
|
-
Editor.removeMark(editor, 'fontSize');
|
|
415
|
-
} else {
|
|
416
|
-
checkSyntax(function () {
|
|
417
|
-
Editor.addMark(editor, 'fontSize', selectedSize);
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
})
|
|
422
|
-
}))
|
|
423
|
-
}, {
|
|
424
|
-
type: 'action',
|
|
425
|
-
content: /*#__PURE__*/_jsx(_Tooltip, _objectSpread(_objectSpread({}, toolTooltipProps), {}, {
|
|
426
|
-
title: "\u4E8B\u4EF6",
|
|
427
|
-
children: /*#__PURE__*/_jsx(_Button, _objectSpread(_objectSpread({}, toolBtnProps), {}, {
|
|
428
|
-
icon: /*#__PURE__*/_jsx(ApiOutlined, {}),
|
|
429
|
-
onClick: function onClick() {
|
|
430
|
-
try {
|
|
431
|
-
checkSyntax(function () {
|
|
432
|
-
var selection = editor.selection;
|
|
433
|
-
var selectedText = Editor.string(editor, selection);
|
|
434
|
-
var marks = Editor.marks(editor);
|
|
435
|
-
if (selectedText) {
|
|
436
|
-
if (marks !== null && marks !== void 0 && marks.action) {
|
|
437
|
-
setActionValues(marks === null || marks === void 0 ? void 0 : marks.action);
|
|
438
|
-
} else {
|
|
439
|
-
setActionValues({
|
|
440
|
-
message: selectedText
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
setActionFormVisible(true);
|
|
444
|
-
} else {
|
|
445
|
-
throw Error();
|
|
446
|
-
}
|
|
447
|
-
});
|
|
448
|
-
} catch (_unused) {
|
|
449
|
-
_message.warn('请先选择文本');
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
}))
|
|
453
|
-
}))
|
|
454
|
-
}, {
|
|
455
|
-
type: 'preview',
|
|
456
|
-
content: /*#__PURE__*/_jsx(_Tooltip, _objectSpread(_objectSpread({}, toolTooltipProps), {}, {
|
|
457
|
-
title: "\u9884\u89C8",
|
|
458
|
-
children: /*#__PURE__*/_jsx(_Button, _objectSpread(_objectSpread({}, toolBtnProps), {}, {
|
|
459
|
-
icon: showPreview ? /*#__PURE__*/_jsx(EyeInvisibleOutlined, {}) : /*#__PURE__*/_jsx(EyeOutlined, {}),
|
|
460
|
-
onClick: function onClick() {
|
|
461
|
-
setShowPreview(!showPreview);
|
|
462
|
-
}
|
|
463
|
-
}))
|
|
464
|
-
}))
|
|
465
|
-
}, {
|
|
466
|
-
type: 'clear',
|
|
467
|
-
content: /*#__PURE__*/_jsx(_Tooltip, _objectSpread(_objectSpread({}, toolTooltipProps), {}, {
|
|
468
|
-
title: "\u683C\u5F0F\u626B",
|
|
469
|
-
children: /*#__PURE__*/_jsx(_Button, _objectSpread(_objectSpread({}, toolBtnProps), {}, {
|
|
470
|
-
icon: /*#__PURE__*/_jsx(ClearOutlined, {}),
|
|
471
|
-
onClick: function onClick() {
|
|
472
|
-
var marks = getEditorMarks(editor);
|
|
473
|
-
if (marks) {
|
|
474
|
-
Object.keys(marks).forEach(function (mKey) {
|
|
475
|
-
Editor.removeMark(editor, mKey);
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
}))
|
|
480
|
-
}))
|
|
481
|
-
}, {
|
|
482
|
-
type: 'undo',
|
|
483
|
-
content: /*#__PURE__*/_jsx(_Tooltip, _objectSpread(_objectSpread({}, toolTooltipProps), {}, {
|
|
484
|
-
title: "\u64A4\u9500",
|
|
485
|
-
children: /*#__PURE__*/_jsx(_Button, _objectSpread(_objectSpread({}, toolBtnProps), {}, {
|
|
486
|
-
disabled: editor.history.undos.length <= 0,
|
|
487
|
-
icon: /*#__PURE__*/_jsx(UndoOutlined, {}),
|
|
488
|
-
onClick: function onClick() {
|
|
489
|
-
if (editor.history.undos.length > 0) {
|
|
490
|
-
HistoryEditor.undo(editor);
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
}))
|
|
494
|
-
}))
|
|
495
|
-
}, {
|
|
496
|
-
type: 'redo',
|
|
497
|
-
content: /*#__PURE__*/_jsx(_Tooltip, _objectSpread(_objectSpread({}, toolTooltipProps), {}, {
|
|
498
|
-
title: "\u91CD\u505A",
|
|
499
|
-
children: /*#__PURE__*/_jsx(_Button, _objectSpread(_objectSpread({}, toolBtnProps), {}, {
|
|
500
|
-
disabled: editor.history.redos.length <= 0,
|
|
501
|
-
icon: /*#__PURE__*/_jsx(RedoOutlined, {}),
|
|
502
|
-
onClick: function onClick() {
|
|
503
|
-
if (editor.history.redos.length > 0) {
|
|
504
|
-
HistoryEditor.redo(editor);
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
}))
|
|
508
|
-
}))
|
|
509
|
-
}];
|
|
510
|
-
var renderToolsBtn = function renderToolsBtn(btnRecord) {
|
|
511
|
-
if (Array.isArray(tools) && tools.includes(btnRecord === null || btnRecord === void 0 ? void 0 : btnRecord.type)) {
|
|
512
|
-
if (!(marks !== null && marks !== void 0 && marks[btnRecord === null || btnRecord === void 0 ? void 0 : btnRecord.type]) && btnRecord !== null && btnRecord !== void 0 && btnRecord.wraper) {
|
|
513
|
-
return btnRecord === null || btnRecord === void 0 ? void 0 : btnRecord.wraper(btnRecord === null || btnRecord === void 0 ? void 0 : btnRecord.content);
|
|
514
|
-
}
|
|
515
|
-
return btnRecord === null || btnRecord === void 0 ? void 0 : btnRecord.content;
|
|
516
|
-
}
|
|
517
|
-
return null;
|
|
518
|
-
};
|
|
519
|
-
return !isDisabled && (Array.isArray(tools) && tools.length > 0 || extra) ? /*#__PURE__*/_jsxs("div", {
|
|
520
|
-
className: "".concat(clsPrefix, "-header"),
|
|
521
|
-
children: [/*#__PURE__*/_jsx("div", {
|
|
522
|
-
className: "".concat(clsPrefix, "-header-cell"),
|
|
523
|
-
children: toolItems.map(function (item) {
|
|
524
|
-
return renderToolsBtn(item);
|
|
525
|
-
})
|
|
526
|
-
}), extra && /*#__PURE__*/_jsx("div", {
|
|
527
|
-
children: extra
|
|
528
|
-
})]
|
|
529
|
-
}) : null;
|
|
530
|
-
};
|
|
531
|
-
|
|
532
|
-
// 插入文字
|
|
533
|
-
var onInsertText = function onInsertText(textContent) {
|
|
534
|
-
var _selection$focus2;
|
|
535
|
-
var deleteBackward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
536
|
-
var selection = editor.selection;
|
|
537
|
-
if (!selection || !textContent) {
|
|
538
|
-
return;
|
|
539
|
-
}
|
|
540
|
-
var newOffsetLength = (selection === null || selection === void 0 || (_selection$focus2 = selection.focus) === null || _selection$focus2 === void 0 ? void 0 : _selection$focus2.offset) + textContent.length;
|
|
541
|
-
if (deleteBackward) {
|
|
542
|
-
newOffsetLength -= 1;
|
|
543
|
-
editor.deleteBackward(editor, {
|
|
544
|
-
unit: 'word'
|
|
545
|
-
});
|
|
546
|
-
}
|
|
547
|
-
Transforms.insertText(editor, textContent);
|
|
548
|
-
// 创建新的选区
|
|
549
|
-
var newSelection = {
|
|
550
|
-
anchor: {
|
|
551
|
-
path: selection.anchor.path,
|
|
552
|
-
offset: newOffsetLength
|
|
553
|
-
},
|
|
554
|
-
focus: {
|
|
555
|
-
path: selection.focus.path,
|
|
556
|
-
offset: newOffsetLength
|
|
557
|
-
}
|
|
558
|
-
};
|
|
559
|
-
// 设置新的选区
|
|
560
|
-
Transforms.select(editor, newSelection);
|
|
561
|
-
ReactEditor.focus(editor);
|
|
562
|
-
};
|
|
563
|
-
|
|
564
|
-
// 插入节点
|
|
565
|
-
var onInsertNode = function onInsertNode(node) {
|
|
566
|
-
var deleteBackward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
567
|
-
var selection = editor.selection;
|
|
568
|
-
if (!selection || !node) {
|
|
569
|
-
return;
|
|
570
|
-
}
|
|
571
|
-
if (deleteBackward) {
|
|
572
|
-
editor.deleteBackward(editor, {
|
|
573
|
-
unit: 'character'
|
|
574
|
-
});
|
|
575
|
-
}
|
|
576
|
-
Transforms.insertNodes(editor, node);
|
|
577
|
-
};
|
|
578
|
-
|
|
579
|
-
// 文本内容装饰器,处理markdown文本语法及变量高亮
|
|
580
|
-
var decorate = useCallback(function (_ref2) {
|
|
581
|
-
var _ref3 = _slicedToArray(_ref2, 2),
|
|
582
|
-
node = _ref3[0],
|
|
583
|
-
path = _ref3[1];
|
|
584
|
-
try {
|
|
585
|
-
var ranges = [];
|
|
586
|
-
if (!Text.isText(node)) {
|
|
587
|
-
return ranges;
|
|
588
|
-
}
|
|
589
|
-
// 对文字分片装饰
|
|
590
|
-
var tokens = splitWords(node.text);
|
|
591
|
-
var start = 0;
|
|
592
|
-
tokens.forEach(function (token, idx) {
|
|
593
|
-
var _token$text;
|
|
594
|
-
var length = (token === null || token === void 0 || (_token$text = token.text) === null || _token$text === void 0 ? void 0 : _token$text.length) || 0;
|
|
595
|
-
var end = start + length;
|
|
596
|
-
var tokenObj = {
|
|
597
|
-
anchor: {
|
|
598
|
-
path: path,
|
|
599
|
-
offset: start
|
|
600
|
-
},
|
|
601
|
-
focus: {
|
|
602
|
-
path: path,
|
|
603
|
-
offset: end
|
|
604
|
-
}
|
|
605
|
-
};
|
|
606
|
-
if (token !== null && token !== void 0 && token.highlight) {
|
|
607
|
-
tokenObj.highlight = token === null || token === void 0 ? void 0 : token.highlight;
|
|
608
|
-
}
|
|
609
|
-
ranges.push(tokenObj);
|
|
610
|
-
start = end;
|
|
611
|
-
});
|
|
612
|
-
return ranges;
|
|
613
|
-
} catch (err) {
|
|
614
|
-
console.log(err);
|
|
615
|
-
return [];
|
|
616
|
-
}
|
|
617
|
-
}, []);
|
|
618
|
-
var imperactiveHandle = {
|
|
619
|
-
onInsertText: onInsertText,
|
|
620
|
-
onInsertNode: onInsertNode
|
|
621
|
-
};
|
|
622
|
-
var previewContent = /*#__PURE__*/_jsx("div", {
|
|
623
|
-
className: "".concat(clsPrefix, "-main"),
|
|
624
|
-
children: /*#__PURE__*/_jsx(MarkdownView, {
|
|
625
|
-
content: markdownContent
|
|
626
|
-
})
|
|
627
|
-
});
|
|
628
|
-
useImperativeHandle(ref, function () {
|
|
629
|
-
return imperactiveHandle;
|
|
630
|
-
});
|
|
631
|
-
useEffect(function () {
|
|
632
|
-
if (preview) {
|
|
633
|
-
setShowPreview(true);
|
|
634
|
-
}
|
|
635
|
-
}, []);
|
|
636
|
-
var onMouseEnter = function onMouseEnter(e) {
|
|
637
|
-
var _e$currentTarget = e.currentTarget,
|
|
638
|
-
scrollTop = _e$currentTarget.scrollTop,
|
|
639
|
-
scrollHeight = _e$currentTarget.scrollHeight,
|
|
640
|
-
clientHeight = _e$currentTarget.clientHeight;
|
|
641
|
-
toggleMouseWheel === null || toggleMouseWheel === void 0 || toggleMouseWheel(false, scrollTop + scrollHeight > clientHeight);
|
|
642
|
-
};
|
|
643
|
-
var onMouseLeave = function onMouseLeave(e) {
|
|
644
|
-
var _e$currentTarget2 = e.currentTarget,
|
|
645
|
-
scrollTop = _e$currentTarget2.scrollTop,
|
|
646
|
-
scrollHeight = _e$currentTarget2.scrollHeight,
|
|
647
|
-
clientHeight = _e$currentTarget2.clientHeight;
|
|
648
|
-
toggleMouseWheel === null || toggleMouseWheel === void 0 || toggleMouseWheel(true, scrollTop + scrollHeight > clientHeight);
|
|
649
|
-
};
|
|
650
|
-
return /*#__PURE__*/_jsxs("div", {
|
|
651
|
-
className: classnames("".concat(clsPrefix, "-wrap"), className),
|
|
652
|
-
children: [renderTools(), /*#__PURE__*/_jsx("div", {
|
|
653
|
-
className: classnames("".concat(clsPrefix, "-container"), isDisabled ? 'onlyPreview' : '', !showPreview ? 'onlyEditer' : ''),
|
|
654
|
-
children: !isDisabled ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
655
|
-
children: [/*#__PURE__*/_jsx("div", {
|
|
656
|
-
className: "".concat(clsPrefix, "-main"),
|
|
657
|
-
children: /*#__PURE__*/_jsx(Slate, {
|
|
658
|
-
editor: editor,
|
|
659
|
-
initialValue: initialValue,
|
|
660
|
-
onChange: function onChange(nodes) {
|
|
661
|
-
var textContent = serialize(nodes);
|
|
662
|
-
// console.log('nodes', nodes);
|
|
663
|
-
// console.log('serialize', textContent, textContent.includes('\n'));
|
|
664
|
-
// console.log('deserialize', deserialize(textContent));
|
|
665
|
-
setMarkdownContent(textContent);
|
|
666
|
-
watchPreviousCharacter();
|
|
667
|
-
if (_onChange) {
|
|
668
|
-
_onChange(textContent, nodes);
|
|
669
|
-
}
|
|
670
|
-
},
|
|
671
|
-
children: /*#__PURE__*/_jsx(Editable, {
|
|
672
|
-
autoFocus: true,
|
|
673
|
-
spellCheck: true,
|
|
674
|
-
className: "".concat(clsPrefix, "-text"),
|
|
675
|
-
onCompositionStart: onCompositionStart,
|
|
676
|
-
onCompositionEnd: onCompositionEnd,
|
|
677
|
-
decorate: decorate,
|
|
678
|
-
placeholder: placeholder,
|
|
679
|
-
onKeyDown: onHandleKeyDown,
|
|
680
|
-
renderLeaf: renderLeaf,
|
|
681
|
-
renderElement: function renderElement(_ref4) {
|
|
682
|
-
var attributes = _ref4.attributes,
|
|
683
|
-
children = _ref4.children,
|
|
684
|
-
element = _ref4.element;
|
|
685
|
-
return /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({}, attributes), {}, {
|
|
686
|
-
style: (element === null || element === void 0 ? void 0 : element.style) || {},
|
|
687
|
-
children: children
|
|
688
|
-
}));
|
|
689
|
-
},
|
|
690
|
-
onFocus: onFocus,
|
|
691
|
-
onBlur: onBlur,
|
|
692
|
-
onClick: function onClick() {
|
|
693
|
-
ReactEditor.focus(editor);
|
|
694
|
-
},
|
|
695
|
-
onMouseEnter: onMouseEnter,
|
|
696
|
-
onMouseLeave: onMouseLeave,
|
|
697
|
-
readOnly: readOnly
|
|
698
|
-
})
|
|
699
|
-
})
|
|
700
|
-
}), showPreview && previewContent]
|
|
701
|
-
}) : previewContent
|
|
702
|
-
}), /*#__PURE__*/_jsx(ActionConfigForm, {
|
|
703
|
-
widgetItems: actionWidgetItems,
|
|
704
|
-
initValues: actionValues,
|
|
705
|
-
open: actionFormVisible,
|
|
706
|
-
onCancel: function onCancel() {
|
|
707
|
-
setActionFormVisible(false);
|
|
708
|
-
},
|
|
709
|
-
onOk: function onOk(vals) {
|
|
710
|
-
checkSyntax(function () {
|
|
711
|
-
Editor.addMark(editor, 'action', vals);
|
|
712
|
-
});
|
|
713
|
-
}
|
|
714
|
-
})]
|
|
715
|
-
});
|
|
716
|
-
});
|
|
717
|
-
export default /*#__PURE__*/memo(MdPlainText);
|