@seafile/sdoc-editor 0.2.27 → 0.2.29-beta
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/api/seafile-api.js +26 -0
- package/dist/assets/images/content-replaced.png +0 -0
- package/dist/basic-sdk/comment/hooks/use-comment-mount.js +7 -0
- package/dist/basic-sdk/editor/sdoc-editor.js +2 -3
- package/dist/basic-sdk/extension/constants/element-type.js +3 -2
- package/dist/basic-sdk/extension/constants/index.js +2 -2
- package/dist/basic-sdk/extension/plugins/html/helper.js +17 -16
- package/dist/basic-sdk/extension/plugins/html/rules/blockquote.js +0 -1
- package/dist/basic-sdk/extension/plugins/html/rules/check-list.js +0 -2
- package/dist/basic-sdk/extension/plugins/html/rules/code-block.js +0 -10
- package/dist/basic-sdk/extension/plugins/html/rules/header.js +0 -1
- package/dist/basic-sdk/extension/plugins/html/rules/image.js +0 -1
- package/dist/basic-sdk/extension/plugins/html/rules/link.js +0 -2
- package/dist/basic-sdk/extension/plugins/html/rules/list.js +3 -9
- package/dist/basic-sdk/extension/plugins/html/rules/paragraph.js +0 -1
- package/dist/basic-sdk/extension/plugins/html/rules/table.js +0 -3
- package/dist/basic-sdk/extension/plugins/html/rules/text.js +0 -7
- package/dist/basic-sdk/extension/plugins/list/helpers.js +0 -1
- package/dist/basic-sdk/extension/plugins/list/model.js +3 -3
- package/dist/basic-sdk/extension/plugins/list/plugin/insert-fragment-list.js +4 -4
- package/dist/basic-sdk/extension/plugins/list/plugin/normalize-list.js +2 -13
- package/dist/basic-sdk/extension/plugins/list/transforms/insert-list-item.js +13 -11
- package/dist/basic-sdk/extension/plugins/list/transforms/move-list-items.js +2 -2
- package/dist/basic-sdk/extension/plugins/list/transforms/normalize-list-item.js +7 -7
- package/dist/basic-sdk/extension/plugins/list/transforms/toggle-list.js +16 -19
- package/dist/basic-sdk/extension/plugins/list/transforms/unwrap-list.js +5 -13
- package/dist/basic-sdk/extension/plugins/table/helpers.js +0 -1
- package/dist/basic-sdk/extension/render/custom-element.js +14 -14
- package/dist/basic-sdk/socket/socket-client.js +7 -0
- package/dist/basic-sdk/socket/socket-manager.js +3 -0
- package/dist/components/doc-operations/index.js +2 -1
- package/dist/components/doc-operations/notifications-operation/index.css +14 -0
- package/dist/components/doc-operations/notifications-operation/index.js +170 -0
- package/dist/components/doc-operations/notifications-operation/notifications-dialog/index.css +97 -0
- package/dist/components/doc-operations/notifications-operation/notifications-dialog/index.js +107 -0
- package/dist/components/doc-operations/notifications-operation/notifications-dialog/notification.js +25 -0
- package/dist/components/doc-operations/notifications-operation/notifications-popover/index.css +173 -0
- package/dist/components/doc-operations/notifications-operation/notifications-popover/index.js +78 -0
- package/dist/components/doc-operations/notifications-operation/notifications-popover/notification.js +54 -0
- package/dist/components/doc-operations/revision-operations/more-revision-operations/index.js +1 -2
- package/dist/components/doc-operations/tag-operation/tag-popover/index.css +1 -0
- package/dist/components/tip-dialog/index.css +44 -0
- package/dist/components/tip-dialog/index.js +51 -18
- package/dist/constants/index.js +2 -3
- package/dist/context.js +26 -0
- package/dist/layout/index.js +2 -1
- package/dist/layout/other.js +8 -0
- package/dist/model/index.js +2 -1
- package/dist/model/notification.js +21 -0
- package/dist/pages/published-revision-viewer.js +2 -2
- package/dist/pages/simple-editor.js +6 -6
- package/dist/utils/index.js +3 -33
- package/dist/utils/notification-utils.js +46 -0
- package/package.json +1 -1
- package/public/locales/cs/sdoc-editor.json +1 -1
- package/public/locales/de/sdoc-editor.json +1 -1
- package/public/locales/en/sdoc-editor.json +13 -3
- package/public/locales/es/sdoc-editor.json +1 -1
- package/public/locales/fr/sdoc-editor.json +1 -1
- package/public/locales/it/sdoc-editor.json +1 -1
- package/public/locales/ru/sdoc-editor.json +1 -1
- package/public/locales/zh_CN/sdoc-editor.json +4 -2
- package/public/media/sdoc-editor-font/iconfont.eot +0 -0
- package/public/media/sdoc-editor-font/iconfont.svg +2 -0
- package/public/media/sdoc-editor-font/iconfont.ttf +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff2 +0 -0
- package/public/media/sdoc-editor-font.css +4 -0
package/dist/api/seafile-api.js
CHANGED
|
@@ -242,6 +242,32 @@ var SeafileAPI = /*#__PURE__*/function () {
|
|
|
242
242
|
};
|
|
243
243
|
return this.req.put(url, params);
|
|
244
244
|
}
|
|
245
|
+
|
|
246
|
+
// notification
|
|
247
|
+
}, {
|
|
248
|
+
key: "listNotifications",
|
|
249
|
+
value: function listNotifications(docUuid, page, perPage) {
|
|
250
|
+
var url = "/api/v2.1/seadoc/notifications/".concat(docUuid, "/?page=").concat(page, "&per_page=").concat(perPage);
|
|
251
|
+
return this.req.get(url);
|
|
252
|
+
}
|
|
253
|
+
}, {
|
|
254
|
+
key: "markAllNotificationsRead",
|
|
255
|
+
value: function markAllNotificationsRead(docUuid) {
|
|
256
|
+
var url = "/api/v2.1/seadoc/notifications/".concat(docUuid, "/");
|
|
257
|
+
return this.req.put(url);
|
|
258
|
+
}
|
|
259
|
+
}, {
|
|
260
|
+
key: "markNotificationRead",
|
|
261
|
+
value: function markNotificationRead(docUuid, notificationId) {
|
|
262
|
+
var url = "/api/v2.1/seadoc/notifications/".concat(docUuid, "/").concat(notificationId, "/");
|
|
263
|
+
return this.req.put(url);
|
|
264
|
+
}
|
|
265
|
+
}, {
|
|
266
|
+
key: "deleteAllNotifications",
|
|
267
|
+
value: function deleteAllNotifications(docUuid) {
|
|
268
|
+
var url = "/api/v2.1/seadoc/notifications/".concat(docUuid, "/");
|
|
269
|
+
return this.req.delete(url);
|
|
270
|
+
}
|
|
245
271
|
}]);
|
|
246
272
|
return SeafileAPI;
|
|
247
273
|
}();
|
|
Binary file
|
|
@@ -2,6 +2,8 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
|
2
2
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(typeof e + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
3
|
import { useCallback, useEffect } from 'react';
|
|
4
4
|
import context from '../../../context';
|
|
5
|
+
import EventBus from '../../utils/event-bus';
|
|
6
|
+
import { EXTERNAL_EVENT } from '../../../constants';
|
|
5
7
|
export var useCommentsMount = function useCommentsMount(dispatch) {
|
|
6
8
|
var request = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
7
9
|
var res, comments;
|
|
@@ -38,5 +40,10 @@ export var useCommentsMount = function useCommentsMount(dispatch) {
|
|
|
38
40
|
})), []);
|
|
39
41
|
useEffect(function () {
|
|
40
42
|
request();
|
|
43
|
+
var eventBus = EventBus.getInstance();
|
|
44
|
+
var unsubscribeNewNotification = eventBus.subscribe(EXTERNAL_EVENT.NEW_NOTIFICATION, request);
|
|
45
|
+
return function () {
|
|
46
|
+
unsubscribeNewNotification();
|
|
47
|
+
};
|
|
41
48
|
}, [request]);
|
|
42
49
|
};
|
|
@@ -18,7 +18,6 @@ import { ColorProvider } from '../hooks/use-color-context';
|
|
|
18
18
|
import { HeaderToolbar } from '../extension';
|
|
19
19
|
import ReadOnlyArticle from '../views/readonly-article';
|
|
20
20
|
import { isMobile } from '../../utils';
|
|
21
|
-
import { CollaboratorsProvider } from '../../hooks';
|
|
22
21
|
var SdocEditor = forwardRef(function (_ref, ref) {
|
|
23
22
|
var document = _ref.document,
|
|
24
23
|
isReloading = _ref.isReloading;
|
|
@@ -116,7 +115,7 @@ var SdocEditor = forwardRef(function (_ref, ref) {
|
|
|
116
115
|
}
|
|
117
116
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EditorContainer, {
|
|
118
117
|
editor: editor
|
|
119
|
-
}, /*#__PURE__*/React.createElement(
|
|
118
|
+
}, /*#__PURE__*/React.createElement(ColorProvider, null, /*#__PURE__*/React.createElement(HeaderToolbar, {
|
|
120
119
|
editor: editor
|
|
121
120
|
}), /*#__PURE__*/React.createElement(EditorContent, {
|
|
122
121
|
docValue: slateValue,
|
|
@@ -125,7 +124,7 @@ var SdocEditor = forwardRef(function (_ref, ref) {
|
|
|
125
124
|
editor: editor,
|
|
126
125
|
slateValue: slateValue,
|
|
127
126
|
updateSlateValue: _setSlateValue
|
|
128
|
-
}))))
|
|
127
|
+
})))), /*#__PURE__*/React.createElement(InsertElementDialog, {
|
|
129
128
|
editor: editor
|
|
130
129
|
}));
|
|
131
130
|
});
|
|
@@ -11,7 +11,6 @@ export var HEADER6 = 'header6';
|
|
|
11
11
|
export var ORDERED_LIST = 'ordered_list';
|
|
12
12
|
export var UNORDERED_LIST = 'unordered_list';
|
|
13
13
|
export var LIST_ITEM = 'list_item';
|
|
14
|
-
export var LIST_LIC = 'list_lic'; // placeholder
|
|
15
14
|
export var CHECK_LIST_ITEM = 'check_list_item';
|
|
16
15
|
export var PARAGRAPH = 'paragraph';
|
|
17
16
|
export var CODE_BLOCK = 'code_block';
|
|
@@ -27,4 +26,6 @@ export var IMAGE = 'image';
|
|
|
27
26
|
// font
|
|
28
27
|
export var FONT_SIZE = 'font-size';
|
|
29
28
|
export var FONT_SIZE_INCREASE = 'font-size-increase';
|
|
30
|
-
export var FONT_SIZE_REDUCE = 'font-size-reduce';
|
|
29
|
+
export var FONT_SIZE_REDUCE = 'font-size-reduce';
|
|
30
|
+
export var TOP_LEVEL_TYPES = [BLOCKQUOTE, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, ORDERED_LIST, UNORDERED_LIST, CHECK_LIST_ITEM, PARAGRAPH, CODE_BLOCK, TABLE];
|
|
31
|
+
export var INLINE_LEVEL_TYPES = [IMAGE, LINK];
|
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
2
2
|
var _HEADER_TITLE_MAP, _FILE_TYPE;
|
|
3
3
|
// extension plugin
|
|
4
4
|
import * as ELEMENT_TYPE from './element-type';
|
|
5
|
-
import { BLOCKQUOTE, TITLE, SUBTITLE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM,
|
|
5
|
+
import { BLOCKQUOTE, TITLE, SUBTITLE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM, CHECK_LIST_ITEM, CODE_BLOCK, CODE_LINE, TABLE, TABLE_CELL, TABLE_ROW, LINK, SDOC_LINK, FILE_LINK, IMAGE, TOP_LEVEL_TYPES, INLINE_LEVEL_TYPES } from './element-type';
|
|
6
6
|
export { DEFAULT_COLORS, STANDARD_COLORS, DEFAULT_RECENT_USED_LIST, DEFAULT_FONT_COLOR, RECENT_USED_HIGHLIGHT_COLORS_KEY, RECENT_USED_FONT_COLORS_KEY, RECENT_USED_TABLE_CELL_BACKGROUND_COLORS_KEY, DEFAULT_LAST_USED_FONT_COLOR, DEFAULT_LAST_USED_HIGHLIGHT_COLOR, DEFAULT_LAST_USED_TABLE_CELL_BACKGROUND_COLOR } from './color';
|
|
7
7
|
export { FONT_SIZE, DEFAULT_FONT, FONT, GOOGLE_FONT_CLASS, RECENT_USED_FONTS_KEY, SDOC_FONT_SIZE } from './font';
|
|
8
8
|
export { DIFF_TYPE, ADDED_STYLE, DELETED_STYLE } from './diff-view';
|
|
@@ -25,4 +25,4 @@ export var LIST_ITEM_CORRELATION_TYPE = [UNORDERED_LIST, ORDERED_LIST, LIST_ITEM
|
|
|
25
25
|
export var LIST_ITEM_SUPPORTED_TRANSFORMATION = [UNORDERED_LIST, ORDERED_LIST, 'left', 'center', 'right', BLOCKQUOTE];
|
|
26
26
|
export var ADD_POSITION_OFFSET_TYPE = [PARAGRAPH, SUBTITLE, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, CHECK_LIST_ITEM];
|
|
27
27
|
export var FILE_TYPE = (_FILE_TYPE = {}, _defineProperty(_FILE_TYPE, FILE_LINK, 'file'), _defineProperty(_FILE_TYPE, SDOC_LINK, 'sdoc'), _FILE_TYPE);
|
|
28
|
-
export { ELEMENT_TYPE, BLOCKQUOTE, TITLE, SUBTITLE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM,
|
|
28
|
+
export { ELEMENT_TYPE, BLOCKQUOTE, TITLE, SUBTITLE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM, CHECK_LIST_ITEM, CODE_BLOCK, CODE_LINE, TABLE, TABLE_CELL, TABLE_ROW, LINK, SDOC_LINK, FILE_LINK, IMAGE, TOP_LEVEL_TYPES, INLINE_LEVEL_TYPES };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import slugid from 'slugid';
|
|
2
2
|
import typeOf from 'type-of';
|
|
3
|
-
import { LIST_ITEM, PARAGRAPH, UNORDERED_LIST } from '../../constants';
|
|
3
|
+
import { INLINE_LEVEL_TYPES, LIST_ITEM, PARAGRAPH, TOP_LEVEL_TYPES, UNORDERED_LIST } from '../../constants';
|
|
4
4
|
import rules from './rules';
|
|
5
5
|
var cruftNewline = function cruftNewline(element) {
|
|
6
6
|
return !(element.nodeName === '#text' && element.nodeValue === '\n');
|
|
@@ -74,29 +74,31 @@ var deserializeElements = function deserializeElements() {
|
|
|
74
74
|
var formatElementNodes = function formatElementNodes(nodes) {
|
|
75
75
|
if (nodes.length === 0) return nodes;
|
|
76
76
|
nodes = nodes.reduce(function (memo, node) {
|
|
77
|
-
if (node.
|
|
77
|
+
if (TOP_LEVEL_TYPES.includes(node.type)) {
|
|
78
78
|
memo.push(node);
|
|
79
79
|
}
|
|
80
|
-
if (node.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
memo.push(newNode);
|
|
89
|
-
return memo;
|
|
90
|
-
}
|
|
80
|
+
if (node.type === LIST_ITEM) {
|
|
81
|
+
var newNode = {
|
|
82
|
+
id: slugid.nice(),
|
|
83
|
+
type: UNORDERED_LIST,
|
|
84
|
+
children: [node]
|
|
85
|
+
};
|
|
86
|
+
memo.push(newNode);
|
|
87
|
+
return memo;
|
|
91
88
|
}
|
|
92
|
-
|
|
89
|
+
|
|
90
|
+
// The following types will not appear individually during the pasting process
|
|
91
|
+
// code_line
|
|
92
|
+
// table_row | table_cell
|
|
93
|
+
|
|
94
|
+
// text | image | link
|
|
95
|
+
if (!node.type || INLINE_LEVEL_TYPES.includes(node.type)) {
|
|
93
96
|
var prevNode = memo[memo.length - 1];
|
|
94
97
|
if (prevNode && prevNode.type === PARAGRAPH) {
|
|
95
98
|
prevNode.children.push(node);
|
|
96
99
|
return memo;
|
|
97
100
|
}
|
|
98
101
|
var _newNode = {
|
|
99
|
-
level: 'level1',
|
|
100
102
|
id: slugid.nice(),
|
|
101
103
|
type: PARAGRAPH,
|
|
102
104
|
children: [node]
|
|
@@ -121,7 +123,6 @@ export var deserializeHtml = function deserializeHtml(html) {
|
|
|
121
123
|
nodes = formatElementNodes(nodes);
|
|
122
124
|
if (nodes.length === 0) {
|
|
123
125
|
nodes = [{
|
|
124
|
-
level: 'level1',
|
|
125
126
|
id: slugid.nice(),
|
|
126
127
|
type: PARAGRAPH,
|
|
127
128
|
children: [{
|
|
@@ -4,12 +4,10 @@ var checkListRule = function checkListRule(element, parseChild) {
|
|
|
4
4
|
var nodeName = element.nodeName;
|
|
5
5
|
if (nodeName === 'INPUT' && element.getAttribute('type') === 'checkbox') {
|
|
6
6
|
return {
|
|
7
|
-
level: 'level1',
|
|
8
7
|
id: slugid.nice(),
|
|
9
8
|
type: CHECK_LIST_ITEM,
|
|
10
9
|
checked: element.getAttribute('checked') !== null,
|
|
11
10
|
children: [{
|
|
12
|
-
level: 'level3',
|
|
13
11
|
id: slugid.nice(),
|
|
14
12
|
text: ''
|
|
15
13
|
}]
|
|
@@ -15,7 +15,6 @@ var codeBlockRule = function codeBlockRule(element, parseChild) {
|
|
|
15
15
|
return item.value === lang;
|
|
16
16
|
}) || 'plaintext';
|
|
17
17
|
return {
|
|
18
|
-
level: 'level1',
|
|
19
18
|
id: slugid.nice(),
|
|
20
19
|
language: lang,
|
|
21
20
|
type: CODE_BLOCK,
|
|
@@ -26,18 +25,15 @@ var codeBlockRule = function codeBlockRule(element, parseChild) {
|
|
|
26
25
|
var content = childNodes[0].textContent;
|
|
27
26
|
var _children = content.split('\n').map(function (text) {
|
|
28
27
|
return {
|
|
29
|
-
level: 'level2',
|
|
30
28
|
id: slugid.nice(),
|
|
31
29
|
type: CODE_LINE,
|
|
32
30
|
children: [{
|
|
33
|
-
level: 'level3',
|
|
34
31
|
id: slugid.nice(),
|
|
35
32
|
text: text
|
|
36
33
|
}]
|
|
37
34
|
};
|
|
38
35
|
});
|
|
39
36
|
return {
|
|
40
|
-
level: 'level1',
|
|
41
37
|
id: slugid.nice(),
|
|
42
38
|
language: _lang,
|
|
43
39
|
type: CODE_BLOCK,
|
|
@@ -52,11 +48,9 @@ var codeBlockRule = function codeBlockRule(element, parseChild) {
|
|
|
52
48
|
if (childIsP) {
|
|
53
49
|
return Array.from(childNodes).map(function (n) {
|
|
54
50
|
return {
|
|
55
|
-
level: 'level2',
|
|
56
51
|
id: slugid.nice(),
|
|
57
52
|
type: CODE_LINE,
|
|
58
53
|
children: [{
|
|
59
|
-
level: 'level3',
|
|
60
54
|
id: slugid.nice(),
|
|
61
55
|
text: n.textContent
|
|
62
56
|
}]
|
|
@@ -67,11 +61,9 @@ var codeBlockRule = function codeBlockRule(element, parseChild) {
|
|
|
67
61
|
var hasNewLine = _content.indexOf('\n') > -1;
|
|
68
62
|
if (!hasNewLine) {
|
|
69
63
|
return {
|
|
70
|
-
level: 'level2',
|
|
71
64
|
id: slugid.nice(),
|
|
72
65
|
type: CODE_LINE,
|
|
73
66
|
children: [{
|
|
74
|
-
level: 'level3',
|
|
75
67
|
id: slugid.nice(),
|
|
76
68
|
text: element.textContent
|
|
77
69
|
}]
|
|
@@ -80,11 +72,9 @@ var codeBlockRule = function codeBlockRule(element, parseChild) {
|
|
|
80
72
|
var codes = _content.split('\n');
|
|
81
73
|
return codes.map(function (item) {
|
|
82
74
|
return {
|
|
83
|
-
level: 'level2',
|
|
84
75
|
id: slugid.nice(),
|
|
85
76
|
type: CODE_LINE,
|
|
86
77
|
children: [{
|
|
87
|
-
level: 'level3',
|
|
88
78
|
id: slugid.nice(),
|
|
89
79
|
text: item
|
|
90
80
|
}]
|
|
@@ -13,7 +13,6 @@ var headerRule = function headerRule(element, parseChild) {
|
|
|
13
13
|
childNodes = element.childNodes;
|
|
14
14
|
if (nodeName && HEADER_LIST.includes(nodeName)) {
|
|
15
15
|
return {
|
|
16
|
-
level: 'level1',
|
|
17
16
|
id: slugid.nice(),
|
|
18
17
|
type: HEADER_TYPE_MAP[nodeName],
|
|
19
18
|
children: parseChild(childNodes)
|
|
@@ -5,13 +5,11 @@ var linkRule = function linkRule(element, parseChild) {
|
|
|
5
5
|
var content = element.textContent || element.getAttribute('title') || element.getAttribute('href');
|
|
6
6
|
if (nodeName === 'A') {
|
|
7
7
|
return {
|
|
8
|
-
level: 'level3',
|
|
9
8
|
id: slugid.nice(),
|
|
10
9
|
type: LINK,
|
|
11
10
|
href: element.getAttribute('href'),
|
|
12
11
|
title: element.getAttribute('title'),
|
|
13
12
|
children: [{
|
|
14
|
-
level: 'level3',
|
|
15
13
|
id: slugid.nice(),
|
|
16
14
|
text: content
|
|
17
15
|
}]
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import slugid from 'slugid';
|
|
2
|
-
import { LIST_ITEM,
|
|
2
|
+
import { LIST_ITEM, ORDERED_LIST, PARAGRAPH, UNORDERED_LIST } from '../../../constants';
|
|
3
3
|
var PARAGRAPH_TAGS = ['DIV', 'P'];
|
|
4
4
|
var listRule = function listRule(element, parseChild) {
|
|
5
5
|
var nodeName = element.nodeName,
|
|
6
6
|
childNodes = element.childNodes;
|
|
7
7
|
if (nodeName === 'UL') {
|
|
8
8
|
return {
|
|
9
|
-
level: 'level1',
|
|
10
9
|
id: slugid.nice(),
|
|
11
10
|
type: UNORDERED_LIST,
|
|
12
11
|
children: parseChild(childNodes)
|
|
@@ -14,7 +13,6 @@ var listRule = function listRule(element, parseChild) {
|
|
|
14
13
|
}
|
|
15
14
|
if (nodeName === 'OL') {
|
|
16
15
|
return {
|
|
17
|
-
level: 'level1',
|
|
18
16
|
id: slugid.nice(),
|
|
19
17
|
type: ORDERED_LIST,
|
|
20
18
|
children: parseChild(childNodes)
|
|
@@ -22,7 +20,6 @@ var listRule = function listRule(element, parseChild) {
|
|
|
22
20
|
}
|
|
23
21
|
if (nodeName === 'LI' && PARAGRAPH_TAGS.includes(element.firstChild.nodeName)) {
|
|
24
22
|
return {
|
|
25
|
-
level: 'level2',
|
|
26
23
|
id: slugid.nice(),
|
|
27
24
|
type: LIST_ITEM,
|
|
28
25
|
children: parseChild(childNodes)
|
|
@@ -30,22 +27,19 @@ var listRule = function listRule(element, parseChild) {
|
|
|
30
27
|
}
|
|
31
28
|
if (nodeName === 'LI' && !PARAGRAPH_TAGS.includes(element.firstChild.nodeName)) {
|
|
32
29
|
return {
|
|
33
|
-
level: 'level2',
|
|
34
30
|
id: slugid.nice(),
|
|
35
31
|
type: LIST_ITEM,
|
|
36
32
|
children: [{
|
|
37
33
|
id: slugid.nice(),
|
|
38
|
-
|
|
39
|
-
type: LIST_LIC,
|
|
34
|
+
type: PARAGRAPH,
|
|
40
35
|
children: parseChild(childNodes)
|
|
41
36
|
}]
|
|
42
37
|
};
|
|
43
38
|
}
|
|
44
39
|
if (PARAGRAPH_TAGS.includes(nodeName) && element.parentElement.nodeName === 'LI') {
|
|
45
40
|
return {
|
|
46
|
-
level: 'level3',
|
|
47
41
|
id: slugid.nice(),
|
|
48
|
-
type:
|
|
42
|
+
type: PARAGRAPH,
|
|
49
43
|
children: parseChild(childNodes)
|
|
50
44
|
};
|
|
51
45
|
}
|
|
@@ -5,7 +5,6 @@ var paragraphRule = function paragraphRule(element, parseChild) {
|
|
|
5
5
|
childNodes = element.childNodes;
|
|
6
6
|
if (nodeName === 'P' && element.parentElement.nodeName !== 'LI') {
|
|
7
7
|
return {
|
|
8
|
-
level: 'level1',
|
|
9
8
|
id: slugid.nice(),
|
|
10
9
|
type: PARAGRAPH,
|
|
11
10
|
children: parseChild(childNodes)
|
|
@@ -5,7 +5,6 @@ var tableRule = function tableRule(element, parseChild) {
|
|
|
5
5
|
childNodes = element.childNodes;
|
|
6
6
|
if (nodeName === 'TABLE') {
|
|
7
7
|
return {
|
|
8
|
-
level: 'level1',
|
|
9
8
|
id: slugid.nice(),
|
|
10
9
|
type: TABLE,
|
|
11
10
|
children: parseChild(childNodes)
|
|
@@ -16,7 +15,6 @@ var tableRule = function tableRule(element, parseChild) {
|
|
|
16
15
|
}
|
|
17
16
|
if (nodeName === 'TR') {
|
|
18
17
|
return {
|
|
19
|
-
level: 'level2',
|
|
20
18
|
id: slugid.nice(),
|
|
21
19
|
type: TABLE_ROW,
|
|
22
20
|
children: parseChild(childNodes)
|
|
@@ -24,7 +22,6 @@ var tableRule = function tableRule(element, parseChild) {
|
|
|
24
22
|
}
|
|
25
23
|
if (nodeName === 'TH' || nodeName === 'TD') {
|
|
26
24
|
return {
|
|
27
|
-
level: 'level3',
|
|
28
25
|
id: slugid.nice(),
|
|
29
26
|
type: TABLE_CELL,
|
|
30
27
|
children: parseChild(childNodes)
|
|
@@ -4,14 +4,12 @@ var textRule = function textRule(element, parseChild) {
|
|
|
4
4
|
nodeType = element.nodeType;
|
|
5
5
|
if (nodeName === 'SPAN') {
|
|
6
6
|
return {
|
|
7
|
-
level: 'level3',
|
|
8
7
|
id: slugid.nice(),
|
|
9
8
|
text: element.textContent
|
|
10
9
|
};
|
|
11
10
|
}
|
|
12
11
|
if (nodeName === 'STRONG' || nodeName === 'B') {
|
|
13
12
|
return {
|
|
14
|
-
level: 'level3',
|
|
15
13
|
id: slugid.nice(),
|
|
16
14
|
bold: true,
|
|
17
15
|
text: element.textContent
|
|
@@ -19,7 +17,6 @@ var textRule = function textRule(element, parseChild) {
|
|
|
19
17
|
}
|
|
20
18
|
if (nodeName === 'CODE' && element.parentElement.nodeName !== 'PRE') {
|
|
21
19
|
return {
|
|
22
|
-
level: 'level3',
|
|
23
20
|
id: slugid.nice(),
|
|
24
21
|
code: true,
|
|
25
22
|
text: element.textContent
|
|
@@ -27,7 +24,6 @@ var textRule = function textRule(element, parseChild) {
|
|
|
27
24
|
}
|
|
28
25
|
if (nodeName === 'DEL') {
|
|
29
26
|
return {
|
|
30
|
-
level: 'level3',
|
|
31
27
|
id: slugid.nice(),
|
|
32
28
|
delete: true,
|
|
33
29
|
text: element.textContent
|
|
@@ -35,7 +31,6 @@ var textRule = function textRule(element, parseChild) {
|
|
|
35
31
|
}
|
|
36
32
|
if (nodeName === 'I') {
|
|
37
33
|
return {
|
|
38
|
-
level: 'level3',
|
|
39
34
|
id: slugid.nice(),
|
|
40
35
|
italic: true,
|
|
41
36
|
text: element.textContent
|
|
@@ -43,7 +38,6 @@ var textRule = function textRule(element, parseChild) {
|
|
|
43
38
|
}
|
|
44
39
|
if (nodeName === 'INS') {
|
|
45
40
|
return {
|
|
46
|
-
level: 'level3',
|
|
47
41
|
id: slugid.nice(),
|
|
48
42
|
add: true,
|
|
49
43
|
text: element.textContent
|
|
@@ -51,7 +45,6 @@ var textRule = function textRule(element, parseChild) {
|
|
|
51
45
|
}
|
|
52
46
|
if (nodeType === 3) {
|
|
53
47
|
return {
|
|
54
|
-
level: 'level3',
|
|
55
48
|
id: slugid.nice(),
|
|
56
49
|
text: element.textContent
|
|
57
50
|
};
|
|
@@ -2,7 +2,6 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
2
2
|
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
3
3
|
import { Editor, Element, Node, Range, Text } from '@seafile/slate';
|
|
4
4
|
import { CHECK_LIST_ITEM, CODE_BLOCK, CODE_LINE, LIST_ITEM, PARAGRAPH, TABLE } from '../../constants';
|
|
5
|
-
import { isRangeAcrossBlocks } from '../../core';
|
|
6
5
|
import { toggleList } from './transforms';
|
|
7
6
|
import { getListTypes } from './queries';
|
|
8
7
|
export var isMenuDisabled = function isMenuDisabled(editor, readonly) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
2
2
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
3
|
import slugid from 'slugid';
|
|
4
|
-
import { LIST_ITEM,
|
|
4
|
+
import { LIST_ITEM, PARAGRAPH, UNORDERED_LIST } from '../../constants';
|
|
5
5
|
import { generateEmptyElement } from '../../core';
|
|
6
6
|
var List = /*#__PURE__*/_createClass(function List(options) {
|
|
7
7
|
_classCallCheck(this, List);
|
|
@@ -18,8 +18,8 @@ export var generateEmptyListItem = function generateEmptyListItem() {
|
|
|
18
18
|
children: []
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
|
-
export var
|
|
22
|
-
return generateEmptyElement(
|
|
21
|
+
export var generateEmptyListContent = function generateEmptyListContent() {
|
|
22
|
+
return generateEmptyElement(PARAGRAPH);
|
|
23
23
|
};
|
|
24
24
|
export var generateEmptyList = function generateEmptyList(type) {
|
|
25
25
|
return {
|
|
@@ -3,7 +3,7 @@ import _toArray from "@babel/runtime/helpers/esm/toArray";
|
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
4
|
import { Element, Path, Transforms, Node, Editor } from '@seafile/slate';
|
|
5
5
|
import slugid from 'slugid';
|
|
6
|
-
import { LIST_ITEM,
|
|
6
|
+
import { LIST_ITEM, PARAGRAPH } from '../../../constants';
|
|
7
7
|
import { findNode, generateDefaultText, getCommonNode, getNode, getNodes } from '../../../core';
|
|
8
8
|
import { getListTypes } from '../queries';
|
|
9
9
|
var isListRoot = function isListRoot(node) {
|
|
@@ -20,7 +20,7 @@ var getFirstAncestorOfType = function getFirstAncestorOfType(root, entry, _ref)
|
|
|
20
20
|
var findListItemsWithContent = function findListItemsWithContent(first) {
|
|
21
21
|
var prev = null;
|
|
22
22
|
var node = first;
|
|
23
|
-
while (isListRoot(node) || node.type === LIST_ITEM && node.children[0].type !==
|
|
23
|
+
while (isListRoot(node) || node.type === LIST_ITEM && node.children[0].type !== PARAGRAPH) {
|
|
24
24
|
prev = node;
|
|
25
25
|
var _node$children = _slicedToArray(node.children, 1);
|
|
26
26
|
node = _node$children[0];
|
|
@@ -63,7 +63,7 @@ var isSingleLic = function isSingleLic(fragment) {
|
|
|
63
63
|
}).filter(function (_ref4) {
|
|
64
64
|
var _ref5 = _slicedToArray(_ref4, 1),
|
|
65
65
|
node = _ref5[0];
|
|
66
|
-
return node.type ===
|
|
66
|
+
return node.type === PARAGRAPH;
|
|
67
67
|
}).length === 1;
|
|
68
68
|
};
|
|
69
69
|
export var getTextAndListItemNodes = function getTextAndListItemNodes(editor, fragment, liEntry, licEntry) {
|
|
@@ -159,7 +159,7 @@ export var insertFragmentList = function insertFragmentList(editor) {
|
|
|
159
159
|
});
|
|
160
160
|
var licEntry = findNode(editor, {
|
|
161
161
|
match: {
|
|
162
|
-
type:
|
|
162
|
+
type: PARAGRAPH
|
|
163
163
|
},
|
|
164
164
|
mode: 'lowest'
|
|
165
165
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import {
|
|
3
|
-
import { LIST_ITEM
|
|
2
|
+
import { Element, Transforms, Path } from '@seafile/slate';
|
|
3
|
+
import { LIST_ITEM } from '../../../constants';
|
|
4
4
|
import { getChildren, getNode, getPreviousPath, match } from '../../../core';
|
|
5
5
|
import { getListTypes } from '../queries';
|
|
6
6
|
import { moveListItemsToList, normalizeListItem, normalizeNestedList } from '../transforms';
|
|
@@ -71,17 +71,6 @@ export var normalizeList = function normalizeList(editor) {
|
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
if (node.type === LIST_LIC && LIST_LIC !== PARAGRAPH) {
|
|
75
|
-
var _node = Node.parent(editor, path);
|
|
76
|
-
if ((_node === null || _node === void 0 ? void 0 : _node.type) !== LIST_ITEM) {
|
|
77
|
-
Transforms.setNodes(editor, {
|
|
78
|
-
type: PARAGRAPH
|
|
79
|
-
}, {
|
|
80
|
-
at: path
|
|
81
|
-
});
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
74
|
normalizeNode([node, path]);
|
|
86
75
|
};
|
|
87
76
|
};
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
import { Transforms, Editor, Path, Range } from '@seafile/slate';
|
|
4
|
-
import { LIST_ITEM,
|
|
4
|
+
import { LIST_ITEM, PARAGRAPH } from '../../../constants';
|
|
5
5
|
import { getAboveNode, isBlockTextEmptyAfterSelection, isStartPoint } from '../../../core';
|
|
6
|
-
import {
|
|
6
|
+
import { generateEmptyListContent, generateEmptyListItem } from '../model';
|
|
7
|
+
|
|
8
|
+
// list > list_item > paragraph
|
|
7
9
|
export var insertListItem = function insertListItem(editor) {
|
|
8
|
-
var
|
|
10
|
+
var paragraphEntry = getAboveNode(editor, {
|
|
9
11
|
match: {
|
|
10
|
-
type:
|
|
12
|
+
type: PARAGRAPH
|
|
11
13
|
}
|
|
12
14
|
});
|
|
13
|
-
if (!
|
|
14
|
-
var
|
|
15
|
-
paragraphPath =
|
|
15
|
+
if (!paragraphEntry) return false;
|
|
16
|
+
var _paragraphEntry = _slicedToArray(paragraphEntry, 2),
|
|
17
|
+
paragraphPath = _paragraphEntry[1];
|
|
16
18
|
var listItemEntry = Editor.parent(editor, paragraphPath);
|
|
17
19
|
if (!listItemEntry) return false;
|
|
18
20
|
var _listItemEntry = _slicedToArray(listItemEntry, 2),
|
|
@@ -34,8 +36,8 @@ export var insertListItem = function insertListItem(editor) {
|
|
|
34
36
|
var nextListItemPath = Path.next(listItemPath);
|
|
35
37
|
if (_isStartPoint) {
|
|
36
38
|
// listItem 有内容,光标在开始
|
|
37
|
-
var
|
|
38
|
-
Transforms.insertNodes(editor,
|
|
39
|
+
var itemContent = generateEmptyListContent();
|
|
40
|
+
Transforms.insertNodes(editor, itemContent, {
|
|
39
41
|
at: listItemPath
|
|
40
42
|
});
|
|
41
43
|
var listItem = generateEmptyListItem();
|
|
@@ -65,8 +67,8 @@ export var insertListItem = function insertListItem(editor) {
|
|
|
65
67
|
var _Editor$marks;
|
|
66
68
|
// listItem 有内容,光标在结尾
|
|
67
69
|
var marks = (_Editor$marks = Editor.marks(editor)) === null || _Editor$marks === void 0 ? void 0 : _Editor$marks.key;
|
|
68
|
-
var
|
|
69
|
-
Transforms.insertNodes(editor, _objectSpread(_objectSpread({},
|
|
70
|
+
var _itemContent = generateEmptyListContent();
|
|
71
|
+
Transforms.insertNodes(editor, _objectSpread(_objectSpread({}, _itemContent), marks), {
|
|
70
72
|
at: nextListItemPath
|
|
71
73
|
});
|
|
72
74
|
var _listItem2 = generateEmptyListItem();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Editor, Path } from '@seafile/slate';
|
|
2
|
-
import {
|
|
2
|
+
import { PARAGRAPH } from '../../../constants';
|
|
3
3
|
import { getNodeEntries } from '../../../core';
|
|
4
4
|
import { isListNested } from '../queries';
|
|
5
5
|
import { movedListItemDown } from './move-list-item-down';
|
|
@@ -15,7 +15,7 @@ export var moveListItems = function moveListItems(editor) {
|
|
|
15
15
|
var _nodes = getNodeEntries(editor, {
|
|
16
16
|
at: at,
|
|
17
17
|
match: {
|
|
18
|
-
type: [
|
|
18
|
+
type: [PARAGRAPH]
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
21
|
var lics = Array.from(_nodes);
|