@seafile/sdoc-editor 1.0.204 → 1.0.206-test0.0.1

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.
@@ -14,7 +14,7 @@ var _commentEditor = _interopRequireDefault(require("./comment-editor"));
14
14
  var _tooltip = _interopRequireDefault(require("../../../components/tooltip"));
15
15
  var _notificationHooks = require("../hooks/notification-hooks");
16
16
  var _mdToHtml = _interopRequireDefault(require("../../../slate-convert/md-to-html"));
17
- const CommentItem = _ref => {
17
+ const CommentItemContent = _ref => {
18
18
  let {
19
19
  isActive,
20
20
  container,
@@ -96,7 +96,9 @@ const CommentItem = _ref => {
96
96
  className: "name"
97
97
  }, comment.user_name), /*#__PURE__*/_react.default.createElement("span", {
98
98
  className: "time"
99
- }, (0, _dayjs.default)(comment.updated_at).format('MM-DD HH:mm')))), isUnseen && !isActive && /*#__PURE__*/_react.default.createElement("span", {
99
+ }, (0, _dayjs.default)(comment.updated_at).format('MM-DD HH:mm'), (comment === null || comment === void 0 ? void 0 : comment.resolved) && /*#__PURE__*/_react.default.createElement("span", {
100
+ className: "comment-success-resolved sdocfont sdoc-mark-as-resolved"
101
+ })))), isUnseen && !isActive && /*#__PURE__*/_react.default.createElement("span", {
100
102
  className: "sdoc-unread-message-tip"
101
103
  }), isActive && /*#__PURE__*/_react.default.createElement("div", {
102
104
  className: "d-flex comment-item-operation-wrapper"
@@ -149,4 +151,4 @@ const CommentItem = _ref => {
149
151
  setIsEditing: setIsEditing
150
152
  }));
151
153
  };
152
- var _default = exports.default = (0, _reactI18next.withTranslation)('sdoc-editor')(CommentItem);
154
+ var _default = exports.default = (0, _reactI18next.withTranslation)('sdoc-editor')(CommentItemContent);
@@ -424,20 +424,24 @@ const isRangeAcrossBlocks = function (editor) {
424
424
  at,
425
425
  ...options
426
426
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
427
- if (!at) at = editor.selection;
428
- if (!at) return;
429
- const [start, end] = _slate.Range.edges(at);
430
- const startBlock = getAboveBlockNode(editor, {
431
- at: start,
432
- ...options
433
- });
434
- const endBlock = getAboveBlockNode(editor, {
435
- at: end,
436
- ...options
437
- });
438
- if (!startBlock && !endBlock) return;
439
- if (!startBlock || !endBlock) return true;
440
- return !_slate.Path.equals(startBlock[1], endBlock[1]);
427
+ try {
428
+ if (!at) at = editor.selection;
429
+ if (!at) return;
430
+ const [start, end] = _slate.Range.edges(at);
431
+ const startBlock = getAboveBlockNode(editor, {
432
+ at: start,
433
+ ...options
434
+ });
435
+ const endBlock = getAboveBlockNode(editor, {
436
+ at: end,
437
+ ...options
438
+ });
439
+ if (!startBlock && !endBlock) return;
440
+ if (!startBlock || !endBlock) return true;
441
+ return !_slate.Path.equals(startBlock[1], endBlock[1]);
442
+ } catch (error) {
443
+ return true;
444
+ }
441
445
  };
442
446
  exports.isRangeAcrossBlocks = isRangeAcrossBlocks;
443
447
  const isAncestorEmpty = (editor, node) => {
@@ -26,12 +26,12 @@ const isMenuDisabled = (editor, readonly) => {
26
26
  } = editor;
27
27
  if (!selection) return true;
28
28
  const selectedElements = (0, _core.getSelectedElems)(editor);
29
- const isRangeAcrossBlock = (0, _core.isRangeAcrossBlocks)(editor);
30
29
  // If it's not the top list item, disable callout menu
31
30
  const [node] = (0, _core.getTopLevelBlockNode)(editor) || [];
32
31
  if (node && [_elementType.ORDERED_LIST, _elementType.UNORDERED_LIST].includes(node === null || node === void 0 ? void 0 : node.type)) {
33
32
  if (!(0, _core.isTopLevelListItem)(editor)) return true;
34
33
  }
34
+ const isRangeAcrossBlock = (0, _core.isRangeAcrossBlocks)(editor);
35
35
  // If selected multiple block element contains callout, disable callout menu
36
36
  const isAllSelectedElementsInAllowTypes = selectedElements.length && selectedElements.every(element => {
37
37
  if (element.type === _elementType.CALL_OUT && isRangeAcrossBlock) return false;
@@ -39,6 +39,7 @@ const getFontSize = editor => {
39
39
  return marks[_constants.TEXT_STYLE_MAP.FONT_SIZE];
40
40
  }
41
41
  if (!selection) return _constants.SDOC_FONT_SIZE.DEFAULT;
42
+ if ((0, _core.isRangeAcrossBlocks)(editor)) return _constants.SDOC_FONT_SIZE.DEFAULT;
42
43
  const [match] = _slate.Editor.nodes(editor, {
43
44
  at: _slate.Editor.unhangRange(editor, selection),
44
45
  match: n => {
@@ -95,6 +96,9 @@ const getFont = editor => {
95
96
  return marks[_constants.TEXT_STYLE_MAP.FONT];
96
97
  }
97
98
  if (!selection) return _constants.DEFAULT_FONT;
99
+ if ((0, _core.isRangeAcrossBlocks)(editor, {
100
+ at: selection
101
+ })) return _constants.DEFAULT_FONT;
98
102
  const [match] = _slate.Editor.nodes(editor, {
99
103
  at: _slate.Editor.unhangRange(editor, selection),
100
104
  match: n => !_slate.Editor.isEditor(n) && !_slate.Element.isElement(n) && n['font']
@@ -56,6 +56,11 @@ const getBeforeText = editor => {
56
56
  anchor,
57
57
  focus
58
58
  } = selection;
59
+ const lastIndex = focus.path[focus.path.length - 1];
60
+ if (lastIndex !== 0) return {
61
+ beforeText: '',
62
+ range: null
63
+ };
59
64
  const range = {
60
65
  anchor,
61
66
  focus: {
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.setAlignType = exports.isMenuDisabled = exports.getAlignType = void 0;
7
7
  var _slate = require("@seafile/slate");
8
8
  var _constants = require("../../constants");
9
+ var _core = require("../../core");
9
10
  const isMenuDisabled = (editor, readonly) => {
10
11
  if (readonly) return true;
11
12
  if (!editor.selection) return true;
@@ -33,6 +34,7 @@ const getAlignType = editor => {
33
34
  if (!selection) {
34
35
  return defaultType;
35
36
  }
37
+ if ((0, _core.isRangeAcrossBlocks)(editor)) return defaultType;
36
38
  const [match] = _slate.Editor.nodes(editor, {
37
39
  at: _slate.Editor.unhangRange(editor, selection),
38
40
  match: n => !_slate.Editor.isEditor(n) && _slate.Element.isElement(n) && n['align']
@@ -13,6 +13,7 @@ var _helpers = require("../helpers");
13
13
  var _constants = require("../../../constants");
14
14
  var _constants2 = require("../../../../constants");
15
15
  var _dropdownMenuItem = _interopRequireDefault(require("../../../commons/dropdown-menu-item"));
16
+ var _constants3 = require("../../../../../constants");
16
17
  const VideoMenu = _ref => {
17
18
  let {
18
19
  editor,
@@ -30,6 +31,9 @@ const VideoMenu = _ref => {
30
31
  editor
31
32
  });
32
33
  }, [editor, eventBus]);
34
+ const addVideoLink = (0, _react.useCallback)(() => {
35
+ eventBus.dispatch(_constants3.EXTERNAL_EVENT.ADD_VIDEO_LINK);
36
+ }, [eventBus]);
33
37
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
34
38
  disabled: disabled,
35
39
  menuConfig: menuConfig,
@@ -48,6 +52,12 @@ const VideoMenu = _ref => {
48
52
  }, /*#__PURE__*/_react.default.createElement("div", {
49
53
  className: "sdoc-dropdown-menu-item",
50
54
  onClick: openLocalVideoDialog
51
- }, t('Upload_local_video')))));
55
+ }, t('Upload_local_video')), /*#__PURE__*/_react.default.createElement("div", {
56
+ className: "sdoc-dropdown-menu-item",
57
+ onClick: addVideoLink
58
+ }, t('Add_video_link')), /*#__PURE__*/_react.default.createElement("div", {
59
+ className: "sdoc-dropdown-menu-item",
60
+ onClick: openLocalVideoDialog
61
+ }, t('Link_to_Seafile_video_file')))));
52
62
  };
53
63
  var _default = exports.default = VideoMenu;
@@ -36,6 +36,7 @@ const EXTERNAL_EVENT = exports.EXTERNAL_EVENT = {
36
36
  PARTICIPANT_REMOVED: 'participant-removed',
37
37
  CREATE_SDOC_FILE: 'create_sdoc_file',
38
38
  CREATE_WIKI_PAGE: 'create_wiki_page',
39
+ ADD_VIDEO_LINK: 'add_video_link',
39
40
  // wiki
40
41
  INSERT_LINK: 'insert_link',
41
42
  // document
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "1.0.204",
3
+ "version": "1.0.206-test0.0.1",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",