@seafile/seafile-editor 0.4.2 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/index.js +10 -36
  2. package/package.json +4 -5
  3. package/dist/assets/css/new-editor.css +0 -9
  4. package/dist/new-editors/editor.js +0 -81
  5. package/dist/slate-extension/constants/index.js +0 -38
  6. package/dist/slate-extension/core/index.js +0 -3
  7. package/dist/slate-extension/core/queries/index.js +0 -298
  8. package/dist/slate-extension/core/transforms/focus-editor.js +0 -11
  9. package/dist/slate-extension/core/transforms/index.js +0 -2
  10. package/dist/slate-extension/core/transforms/move-children.js +0 -28
  11. package/dist/slate-extension/core/utils/index.js +0 -17
  12. package/dist/slate-extension/index.js +0 -15
  13. package/dist/slate-extension/menu/index.js +0 -3
  14. package/dist/slate-extension/menu/menu-group.js +0 -24
  15. package/dist/slate-extension/menu/menu-item.js +0 -81
  16. package/dist/slate-extension/plugins/blockquote/index.js +0 -14
  17. package/dist/slate-extension/plugins/blockquote/menu/index.js +0 -86
  18. package/dist/slate-extension/plugins/blockquote/model.js +0 -11
  19. package/dist/slate-extension/plugins/blockquote/plugin.js +0 -50
  20. package/dist/slate-extension/plugins/blockquote/render-elem.js +0 -7
  21. package/dist/slate-extension/plugins/check-list/helper.js +0 -8
  22. package/dist/slate-extension/plugins/check-list/index.js +0 -7
  23. package/dist/slate-extension/plugins/check-list/plugin.js +0 -26
  24. package/dist/slate-extension/plugins/check-list/render-elem.js +0 -69
  25. package/dist/slate-extension/plugins/header/index.js +0 -10
  26. package/dist/slate-extension/plugins/header/plugin.js +0 -51
  27. package/dist/slate-extension/plugins/header/render-elem.js +0 -9
  28. package/dist/slate-extension/plugins/index.js +0 -8
  29. package/dist/slate-extension/plugins/list/index.js +0 -11
  30. package/dist/slate-extension/plugins/list/menu/index.js +0 -104
  31. package/dist/slate-extension/plugins/list/model.js +0 -11
  32. package/dist/slate-extension/plugins/list/plugin/insert-break-list.js +0 -23
  33. package/dist/slate-extension/plugins/list/plugin/normalize-list.js +0 -88
  34. package/dist/slate-extension/plugins/list/plugin/on-tab-handle.js +0 -45
  35. package/dist/slate-extension/plugins/list/plugin/toggle-list.js +0 -160
  36. package/dist/slate-extension/plugins/list/queries/index.js +0 -47
  37. package/dist/slate-extension/plugins/list/render-elem.js +0 -22
  38. package/dist/slate-extension/plugins/list/transforms/index.js +0 -10
  39. package/dist/slate-extension/plugins/list/transforms/insert-list-item.js +0 -98
  40. package/dist/slate-extension/plugins/list/transforms/move-list-item-down.js +0 -46
  41. package/dist/slate-extension/plugins/list/transforms/move-list-item-up.js +0 -127
  42. package/dist/slate-extension/plugins/list/transforms/move-list-items-to-list.js +0 -56
  43. package/dist/slate-extension/plugins/list/transforms/move-list-items.js +0 -67
  44. package/dist/slate-extension/plugins/list/transforms/normalize-list-item.js +0 -123
  45. package/dist/slate-extension/plugins/list/transforms/normalize-nested-list.js +0 -33
  46. package/dist/slate-extension/plugins/list/transforms/remove-first-list-item.js +0 -17
  47. package/dist/slate-extension/plugins/list/transforms/unwrap-list.js +0 -55
  48. package/dist/slate-extension/plugins/list/with-list.js +0 -34
  49. package/dist/slate-extension/plugins/text-style/index.js +0 -5
  50. package/dist/slate-extension/plugins/text-style/model.js +0 -11
  51. package/dist/slate-extension/plugins/text-style/render-elem.js +0 -29
  52. package/dist/slate-extension/render/render-element.js +0 -55
  53. package/dist/slate-extension/render/render-leaf.js +0 -8
  54. package/dist/slate-extension/toolbar/index.js +0 -37
package/dist/index.js CHANGED
@@ -1,36 +1,10 @@
1
- // import Toolbar from './components/toolbar';
2
- // import Outline from './components/outline';
3
- // import UserHelp from './components/user-help';
4
- // import EditorContext from './containers/editor-context';
5
- // import { deserialize, serialize } from './utils/slate2markdown';
6
- // import { processor } from './utils/seafile-markdown2html';
7
- // import { replaceColumnData } from './utils/utils';
8
- // import {
9
- // MarkdownEditor,
10
- // SimpleEditor,
11
- // PlainMarkdownEditor,
12
- // SeatableEditor
13
- // } from './editors';
14
- // import {
15
- // DiffViewer,
16
- // MarkdownViewer,
17
- // SeatableViewer
18
- // } from './viewer';
19
- import NewEditor from './new-editors/editor';
20
- export {
21
- // EditorContext,
22
- // MarkdownEditor,
23
- // SimpleEditor,
24
- // PlainMarkdownEditor,
25
- // DiffViewer,
26
- // MarkdownViewer,
27
- // SeatableViewer,
28
- // Toolbar,
29
- // Outline,
30
- // UserHelp,
31
- // deserialize,
32
- // serialize,
33
- // processor,
34
- // SeatableEditor,
35
- // replaceColumnData,
36
- NewEditor };
1
+ import Toolbar from './components/toolbar';
2
+ import Outline from './components/outline';
3
+ import UserHelp from './components/user-help';
4
+ import EditorContext from './containers/editor-context';
5
+ import { deserialize, serialize } from './utils/slate2markdown';
6
+ import { processor } from './utils/seafile-markdown2html';
7
+ import { replaceColumnData } from './utils/utils';
8
+ import { MarkdownEditor, SimpleEditor, PlainMarkdownEditor, SeatableEditor } from './editors';
9
+ import { DiffViewer, MarkdownViewer, SeatableViewer } from './viewer';
10
+ export { EditorContext, MarkdownEditor, SimpleEditor, PlainMarkdownEditor, DiffViewer, MarkdownViewer, SeatableViewer, Toolbar, Outline, UserHelp, deserialize, serialize, processor, SeatableEditor, replaceColumnData };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/seafile-editor",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "private": false,
5
5
  "description": "This is a custom markdown editor",
6
6
  "main": "dist/index.js",
@@ -27,10 +27,9 @@
27
27
  "remark-parse": "^5.0.0",
28
28
  "remark-rehype": "^3.0.0",
29
29
  "remark-slug": "^5.0.0",
30
- "slate": "0.88.1",
31
- "slate-history": "0.86.0",
32
- "slate-hyperscript": "0.77.0",
33
- "slate-react": "0.88.2",
30
+ "slate": "^0.54.2",
31
+ "slate-history": "^0.54.2",
32
+ "slate-hyperscript": "0.54.2",
34
33
  "unified": "7.0.0",
35
34
  "url-parse": "^1.4.3",
36
35
  "xtend": "^4.0.1"
@@ -1,9 +0,0 @@
1
- .dlThau {
2
- margin: 0;
3
- padding-inline-start: 24px;
4
- }
5
-
6
- .editor-container div[data-slate-editor='true'] {
7
- min-width: 980px;
8
- background: #f0f0f0;
9
- }
@@ -1,81 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _inherits from "@babel/runtime/helpers/esm/inherits";
4
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
- import React from 'react';
6
- import { Editable, Slate } from 'slate-react';
7
- import isHotkey from 'is-hotkey';
8
- import editor, { renderLeaf as _renderLeaf, renderElement as _renderElement, Toolbar } from '../slate-extension';
9
- import '../assets/css/new-editor.css';
10
- var NewEditor = /*#__PURE__*/function (_React$Component) {
11
- _inherits(NewEditor, _React$Component);
12
- var _super = _createSuper(NewEditor);
13
- function NewEditor(props) {
14
- var _this;
15
- _classCallCheck(this, NewEditor);
16
- _this = _super.call(this, props);
17
- _this.onChange = function (slateValue) {
18
- var onValueChanged = _this.props.onValueChanged;
19
- _this.setState({
20
- slateValue: slateValue
21
- });
22
- onValueChanged && onValueChanged(slateValue);
23
- };
24
- _this.getStyle = function () {
25
- return {
26
- with: 980,
27
- height: '100%',
28
- margin: '0 auto'
29
- };
30
- };
31
- _this.state = {
32
- slateValue: props.value,
33
- isLoading: true
34
- };
35
- _this.editor = editor;
36
- return _this;
37
- }
38
- _createClass(NewEditor, [{
39
- key: "componentDidMount",
40
- value: function componentDidMount() {
41
- var value = this.props.value;
42
- var slateValue = value;
43
- this.setState({
44
- slateValue: slateValue,
45
- isLoading: false
46
- });
47
- }
48
- }, {
49
- key: "render",
50
- value: function render() {
51
- var _this2 = this;
52
- var slateValue = this.state.slateValue;
53
- return /*#__PURE__*/React.createElement("div", {
54
- className: "editor-container",
55
- style: this.getStyle()
56
- }, /*#__PURE__*/React.createElement(Toolbar, {
57
- editor: this.editor
58
- }), /*#__PURE__*/React.createElement(Slate, {
59
- editor: this.editor,
60
- value: slateValue,
61
- onChange: this.onChange
62
- }, /*#__PURE__*/React.createElement(Editable, {
63
- placeholder: "Enter some text...",
64
- renderElement: function renderElement(props) {
65
- return _renderElement(props, _this2.editor);
66
- },
67
- renderLeaf: function renderLeaf(props) {
68
- return _renderLeaf(props, _this2.editor);
69
- },
70
- onDOMBeforeInput: function onDOMBeforeInput(event) {},
71
- onKeyDown: function onKeyDown(event) {
72
- if (isHotkey('tab', event) || isHotkey('shift+tab', event)) {
73
- editor.handleTab && editor.handleTab(event);
74
- }
75
- }
76
- })));
77
- }
78
- }]);
79
- return NewEditor;
80
- }(React.Component);
81
- export default NewEditor;
@@ -1,38 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- var _MENUS_CONFIG_MAP;
3
- // extension plugin
4
- export var BLOCKQUOTE = 'blockquote';
5
- export var BLOB = 'blob';
6
- export var HEADER = 'header';
7
- export var ORDERED_LIST = 'ordered_list';
8
- export var UNORDERED_LIST = 'unordered_list'; // unordered_list can not work
9
- export var LIST_ITEM = 'list-item';
10
- export var LIST_LIC = 'list-lic'; // placeholder
11
- export var CHECK_LIST = 'check-list';
12
- export var CHECK_LIST_ITEM = 'check-list-item';
13
- export var PARAGRAPH = 'paragraph';
14
- export var LINK = 'link';
15
- export var HTML = 'html';
16
- export var CODE_BLOCK = 'code-block';
17
- export var CODE_LINE = 'code-line';
18
- export var IMAGE = 'image';
19
- export var TABLE = 'table';
20
- export var TABLE_CELL = 'table-cell';
21
- export var TABLE_ROW = 'table-row';
22
- export var FORMULA = 'formula';
23
- export var COLUMN = 'column';
24
-
25
- // menus config
26
- export var MENUS_CONFIG_MAP = (_MENUS_CONFIG_MAP = {}, _defineProperty(_MENUS_CONFIG_MAP, BLOCKQUOTE, {
27
- id: 'BLOCKQUOTE',
28
- iconClass: 'iconfont icon-quote-left',
29
- text: 'quote'
30
- }), _defineProperty(_MENUS_CONFIG_MAP, ORDERED_LIST, {
31
- id: ORDERED_LIST,
32
- iconClass: 'iconfont icon-list-ol',
33
- text: 'ordered_list'
34
- }), _defineProperty(_MENUS_CONFIG_MAP, UNORDERED_LIST, {
35
- id: UNORDERED_LIST,
36
- iconClass: 'iconfont icon-list-ul',
37
- text: 'unordered_list'
38
- }), _MENUS_CONFIG_MAP);
@@ -1,3 +0,0 @@
1
- export * from './queries/index';
2
- export * from './transforms/index';
3
- export * from './utils/index';
@@ -1,298 +0,0 @@
1
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
- import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
4
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
5
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
6
- var _excluded = ["at"];
7
- import { Editor, Text, Path, Span, Element, Node, Range } from 'slate';
8
- import { match } from '../utils';
9
-
10
- // options
11
- export var getQueryOptions = function getQueryOptions(editor, options) {
12
- var _match = options.match,
13
- block = options.block;
14
- var newMatch = undefined;
15
- if (_match || block) {
16
- newMatch = function newMatch(n, path) {
17
- return match(n, path, _match) && (!block || Editor.isBlock(editor, n));
18
- };
19
- }
20
- return _objectSpread(_objectSpread({}, options), {}, {
21
- match: newMatch
22
- });
23
- };
24
-
25
- // get node
26
- export var getNode = function getNode(editor, path) {
27
- var node = null;
28
- try {
29
- node = Node.get(editor, path);
30
- } catch (err) {
31
- node = null;
32
- }
33
- return node;
34
- };
35
- export var getNodeType = function getNodeType(node) {
36
- return Element.isElement(node) ? node.type : '';
37
- };
38
- export var getSelectedNodeByType = function getSelectedNodeByType(editor, type) {
39
- var match = function match(n) {
40
- return getNodeType(n) === type;
41
- };
42
- var _Editor$nodes = Editor.nodes(editor, {
43
- match: match,
44
- universal: true
45
- }),
46
- _Editor$nodes2 = _slicedToArray(_Editor$nodes, 1),
47
- nodeEntry = _Editor$nodes2[0];
48
- return nodeEntry ? nodeEntry[0] : null;
49
- };
50
- export var getSelectedNodeEntryByType = function getSelectedNodeEntryByType(editor, type) {
51
- var match = function match(n) {
52
- return getNodeType(n) === type;
53
- };
54
- var _Editor$nodes3 = Editor.nodes(editor, {
55
- match: match,
56
- universal: false
57
- }),
58
- _Editor$nodes4 = _slicedToArray(_Editor$nodes3, 1),
59
- nodeEntry = _Editor$nodes4[0];
60
- return nodeEntry ? nodeEntry : null;
61
- };
62
- export var getNodeEntries = function getNodeEntries(editor, options) {
63
- return Editor.nodes(editor, getQueryOptions(editor, options));
64
- };
65
-
66
- // children & child
67
- export var getChildren = function getChildren(nodeEntry) {
68
- var _nodeEntry = _slicedToArray(nodeEntry, 2),
69
- node = _nodeEntry[0],
70
- path = _nodeEntry[1];
71
- if (Element.isAncestor(node)) {
72
- var children = node.children;
73
- return children.map(function (child, index) {
74
- var childPath = path.concat([index]);
75
- return [child, childPath];
76
- });
77
- }
78
- return [];
79
- };
80
- export var getLastChild = function getLastChild(nodeEntry) {
81
- var _nodeEntry2 = _slicedToArray(nodeEntry, 2),
82
- node = _nodeEntry2[0],
83
- path = _nodeEntry2[1];
84
- if (Text.isText(node)) return null;
85
- if (!node.children.length) return null;
86
- var children = node.children;
87
- return [children[children.length - 1], path.concat([children.length - 1])];
88
- };
89
- export var getDeepInlineChildren = function getDeepInlineChildren(editor, _ref) {
90
- var children = _ref.children;
91
- var inlineChildren = [];
92
- var _iterator = _createForOfIteratorHelper(children),
93
- _step;
94
- try {
95
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
96
- var child = _step.value;
97
- if (Editor.isBlock(editor, child[0])) {
98
- inlineChildren.push.apply(inlineChildren, _toConsumableArray(getDeepInlineChildren(editor, {
99
- children: getChildren(child)
100
- })));
101
- } else {
102
- inlineChildren.push(child);
103
- }
104
- }
105
- } catch (err) {
106
- _iterator.e(err);
107
- } finally {
108
- _iterator.f();
109
- }
110
- return inlineChildren;
111
- };
112
- export var getLastChildPath = function getLastChildPath(nodeEntry) {
113
- var lastChild = getLastChild(nodeEntry);
114
- if (!lastChild) return nodeEntry[1].concat([-1]);
115
- return lastChild[1];
116
- };
117
- export var getPreviousPath = function getPreviousPath(path) {
118
- if (path.length === 0) return;
119
- var last = path[path.length - 1];
120
- if (last <= 0) return;
121
- return path.slice(0, -1).concat(last - 1);
122
- };
123
- export var isLastChild = function isLastChild(nodeEntry, childPath) {
124
- var lastChildPath = getLastChildPath(nodeEntry);
125
- return Path.equals(lastChildPath, childPath);
126
- };
127
-
128
- // siblings
129
- export var getNextSiblingNodes = function getNextSiblingNodes(ancestorEntry, path) {
130
- var _ancestorEntry = _slicedToArray(ancestorEntry, 2),
131
- ancestor = _ancestorEntry[0],
132
- ancestorPath = _ancestorEntry[1];
133
- var leafIndex = path[ancestorPath.length];
134
- var siblings = [];
135
- var ancestorChildren = ancestor.children;
136
- if (leafIndex + 1 < ancestor.children.length) {
137
- for (var i = leafIndex + 1; i < ancestor.children.length; i++) {
138
- siblings.push(ancestorChildren[i]);
139
- }
140
- }
141
- return siblings;
142
- };
143
-
144
- // parent
145
- export var getAboveNode = function getAboveNode(editor, options) {
146
- return Editor.above(editor, getQueryOptions(editor, options));
147
- };
148
- export var getAboveBlockNode = function getAboveBlockNode(editor, options) {
149
- return getAboveNode(editor, _objectSpread(_objectSpread({}, options), {}, {
150
- block: true
151
- }));
152
- };
153
-
154
- // find node
155
- export var findNode = function findNode(editor, options) {
156
- var nodeEntries = Editor.nodes(editor, _objectSpread({
157
- at: editor.selection || []
158
- }, getQueryOptions(editor, options)));
159
- var _nodeEntries = Array.from(nodeEntries);
160
- if (_nodeEntries[0]) {
161
- return _nodeEntries[0];
162
- }
163
- return undefined;
164
- };
165
- export var findDescendant = function findDescendant(editor, options) {
166
- var _options$at = options.at,
167
- at = _options$at === void 0 ? editor.selection : _options$at,
168
- _options$reverse = options.reverse,
169
- reverse = _options$reverse === void 0 ? false : _options$reverse,
170
- _options$voids = options.voids,
171
- voids = _options$voids === void 0 ? false : _options$voids,
172
- _match = options.match;
173
- if (!at) return;
174
- var from;
175
- var to;
176
- if (Span.isSpan(at)) {
177
- var _at = _slicedToArray(at, 2);
178
- from = _at[0];
179
- to = _at[1];
180
- } else if (Range.isRange(at)) {
181
- var first = Editor.first(editor, at);
182
- var last = Editor.last(editor, at);
183
- from = reverse ? last : first;
184
- to = reverse ? first : last;
185
- }
186
- var root = [editor, []];
187
- if (Path.isPath(at)) {
188
- root = Editor.node(editor, at);
189
- }
190
- var nodeEntries = Node.descendants(root[0], {
191
- from: from,
192
- to: to,
193
- reverse: reverse,
194
- pass: function pass(_ref2) {
195
- var _ref3 = _slicedToArray(_ref2, 1),
196
- n = _ref3[0];
197
- return voids ? false : Editor.isVoid(editor, n);
198
- }
199
- });
200
- var _iterator2 = _createForOfIteratorHelper(nodeEntries),
201
- _step2;
202
- try {
203
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
204
- var _step2$value = _slicedToArray(_step2.value, 2),
205
- node = _step2$value[0],
206
- path = _step2$value[1];
207
- if (match(node, path, _match)) {
208
- return [node, at.concat(path)];
209
- }
210
- }
211
- } catch (err) {
212
- _iterator2.e(err);
213
- } finally {
214
- _iterator2.f();
215
- }
216
- return undefined;
217
- };
218
-
219
- // is
220
- export var isStartPoint = function isStartPoint(editor, point, at) {
221
- return !!point && Editor.isStart(editor, point, at);
222
- };
223
- export var isEndPoint = function isEndPoint(editor, point, at) {
224
- return !!point && Editor.isEnd(editor, point, at);
225
- };
226
- export var isBlockTextEmptyAfterSelection = function isBlockTextEmptyAfterSelection(editor) {
227
- if (!editor.selection) return false;
228
- var blockAbove = Editor.above(editor, {
229
- block: true
230
- });
231
- if (!blockAbove) return false;
232
- var cursor = editor.selection.focus;
233
- var selectionParentEntry = Editor.parent(editor, editor.selection);
234
- if (!selectionParentEntry) return false;
235
- var _selectionParentEntry = _slicedToArray(selectionParentEntry, 2),
236
- selectionParentPath = _selectionParentEntry[1];
237
- if (!isEndPoint(editor, cursor, selectionParentPath)) return false;
238
- var siblingNodes = getNextSiblingNodes(blockAbove, cursor.path);
239
- if (siblingNodes.length) {
240
- // 子节点包含 文本节点
241
- var _iterator3 = _createForOfIteratorHelper(siblingNodes),
242
- _step3;
243
- try {
244
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
245
- var siblingNode = _step3.value;
246
- if (Text.isText(siblingNode) && siblingNode.text) {
247
- return false;
248
- }
249
- }
250
- } catch (err) {
251
- _iterator3.e(err);
252
- } finally {
253
- _iterator3.f();
254
- }
255
- } else {
256
- return isEndPoint(editor, cursor, blockAbove[1]);
257
- }
258
- return true;
259
- };
260
- export var isRangeAcrossBlocks = function isRangeAcrossBlocks(editor) {
261
- var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
262
- var at = _ref4.at,
263
- options = _objectWithoutProperties(_ref4, _excluded);
264
- if (!at) at = editor.selection;
265
- if (!at) return;
266
- var _Range$edges = Range.edges(at),
267
- _Range$edges2 = _slicedToArray(_Range$edges, 2),
268
- start = _Range$edges2[0],
269
- end = _Range$edges2[1];
270
- var startBlock = getAboveBlockNode(editor, _objectSpread({
271
- at: start
272
- }, options));
273
- var endBlock = getAboveBlockNode(editor, _objectSpread({
274
- at: end
275
- }, options));
276
- if (!startBlock && !endBlock) return;
277
- if (!startBlock || !endBlock) return true;
278
- return !Path.equals(startBlock[1], endBlock[1]);
279
- };
280
- export var isAncestorEmpty = function isAncestorEmpty(editor, node) {
281
- return !Node.string(node) && !node.children.some(function (n) {
282
- return Editor.isInline(editor, node);
283
- });
284
- };
285
- export var isBlockAboveEmpty = function isBlockAboveEmpty(editor) {
286
- var _getAboveBlockNode;
287
- var block = (_getAboveBlockNode = getAboveBlockNode(editor)) === null || _getAboveBlockNode === void 0 ? void 0 : _getAboveBlockNode[0];
288
- if (!block) return false;
289
- return isAncestorEmpty(editor, block);
290
- };
291
- export var isSelectionAtBlockStart = function isSelectionAtBlockStart(editor, options) {
292
- var _getAboveBlockNode2;
293
- var selection = editor.selection;
294
- if (!selection) return false;
295
- var path = (_getAboveBlockNode2 = getAboveBlockNode(editor, options)) === null || _getAboveBlockNode2 === void 0 ? void 0 : _getAboveBlockNode2[1];
296
- if (!path) return false;
297
- return isStartPoint(editor, selection.focus, path) || Range.isExpanded(editor.selection) && isStartPoint(editor, selection.anchor, path);
298
- };
@@ -1,11 +0,0 @@
1
- import { Editor, Transforms } from 'slate';
2
- import { ReactEditor } from 'slate-react';
3
- export var focusEditor = function focusEditor(editor, target) {
4
- if (target) {
5
- Editor.withoutNormalizing(editor, function () {
6
- Transforms.deselect(editor);
7
- Transforms.select(editor, target);
8
- });
9
- }
10
- ReactEditor.focus(editor);
11
- };
@@ -1,2 +0,0 @@
1
- export * from './move-children';
2
- export * from './focus-editor';
@@ -1,28 +0,0 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
- import { Editor, Path, Transforms } from 'slate';
3
- import { getNode } from '../queries';
4
- export var moveChildren = function moveChildren(editor, _ref) {
5
- var at = _ref.at,
6
- to = _ref.to,
7
- match = _ref.match,
8
- _ref$fromStartIndex = _ref.fromStartIndex,
9
- fromStartIndex = _ref$fromStartIndex === void 0 ? 0 : _ref$fromStartIndex;
10
- var moved = 0;
11
- var parentPath = Path.isPath(at) ? at : at[1];
12
- var parentNode = Path.isPath(at) ? getNode(editor, parentPath) : at[0];
13
-
14
- // There have none children in a not block element
15
- if (!Editor.isBlock(editor, parentNode)) return moved;
16
- for (var i = parentNode.children.length - 1; i >= fromStartIndex; i--) {
17
- var childPath = [].concat(_toConsumableArray(parentPath), [i]);
18
- var childNode = getNode(editor, childPath);
19
- if (!match || childNode && match([childNode, childPath])) {
20
- Transforms.moveNodes(editor, {
21
- at: childPath,
22
- to: to
23
- });
24
- moved++;
25
- }
26
- }
27
- return moved;
28
- };
@@ -1,17 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- export var match = function match(node, path, predicate) {
3
- if (!predicate) return true;
4
- if (typeof predicate === 'object') {
5
- return Object.entries(predicate).every(function (_ref) {
6
- var _ref2 = _slicedToArray(_ref, 2),
7
- key = _ref2[0],
8
- value = _ref2[1];
9
- if (value && !Array.isArray(value)) {
10
- return node[key] === value;
11
- }
12
- value = value ? value : [];
13
- return value.includes(node[key]);
14
- });
15
- }
16
- return predicate(node, path);
17
- };
@@ -1,15 +0,0 @@
1
- import { createEditor } from 'slate';
2
- import { withReact } from 'slate-react';
3
- import Plugins from './plugins';
4
- import renderElement from './render/render-element';
5
- import renderLeaf from './render/render-leaf';
6
- import Toolbar from './toolbar';
7
- var editor = Plugins.reduce(function (editor, pluginItem) {
8
- var withPlugin = pluginItem.editorPlugin;
9
- if (withPlugin) {
10
- return withPlugin(editor);
11
- }
12
- return editor;
13
- }, withReact(createEditor()));
14
- export default editor;
15
- export { renderLeaf, renderElement, Toolbar };
@@ -1,3 +0,0 @@
1
- import MenuGroup from './menu-group';
2
- import MenuItem from './menu-item';
3
- export { MenuGroup, MenuItem };
@@ -1,24 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _inherits from "@babel/runtime/helpers/esm/inherits";
4
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
- import React from 'react';
6
- var MenuGroup = /*#__PURE__*/function (_React$PureComponent) {
7
- _inherits(MenuGroup, _React$PureComponent);
8
- var _super = _createSuper(MenuGroup);
9
- function MenuGroup() {
10
- _classCallCheck(this, MenuGroup);
11
- return _super.apply(this, arguments);
12
- }
13
- _createClass(MenuGroup, [{
14
- key: "render",
15
- value: function render() {
16
- return /*#__PURE__*/React.createElement("div", {
17
- className: 'btn-group ' + this.props.className,
18
- role: 'group'
19
- }, this.props.children);
20
- }
21
- }]);
22
- return MenuGroup;
23
- }(React.PureComponent);
24
- export default MenuGroup;