@seafile/sdoc-editor 0.2.13-beta3 → 0.2.14

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 (37) hide show
  1. package/dist/basic-sdk/assets/css/sdoc-editor-plugins.css +26 -0
  2. package/dist/basic-sdk/comment/comment/comment-item-content.js +5 -10
  3. package/dist/basic-sdk/comment/comment/comment-list.css +6 -10
  4. package/dist/basic-sdk/extension/commons/color-menu/index.js +1 -1
  5. package/dist/basic-sdk/extension/commons/menu/menu-item.js +1 -1
  6. package/dist/basic-sdk/extension/plugins/code-block/render-elem.js +3 -2
  7. package/dist/basic-sdk/extension/plugins/font/menu/font-family/index.js +1 -1
  8. package/dist/basic-sdk/extension/plugins/font/menu/font-size/font-size-scale.js +1 -1
  9. package/dist/basic-sdk/extension/plugins/font/menu/font-size/index.js +1 -1
  10. package/dist/basic-sdk/extension/plugins/header/menu/index.js +1 -1
  11. package/dist/basic-sdk/extension/plugins/image/hover-menu/index.js +16 -2
  12. package/dist/basic-sdk/extension/plugins/image/render-elem.js +66 -22
  13. package/dist/basic-sdk/extension/plugins/table/helpers.js +60 -0
  14. package/dist/basic-sdk/node-id/index.js +3 -2
  15. package/dist/basic-sdk/outline/index.js +2 -2
  16. package/dist/basic-sdk/utils/document-utils.js +11 -1
  17. package/dist/components/doc-operations/revision-operations/changes-count/index.js +1 -1
  18. package/dist/components/doc-operations/revision-operations/view-changes/index.js +3 -4
  19. package/dist/components/tooltip/index.js +31 -0
  20. package/dist/hooks/use-document.js +5 -1
  21. package/package.json +1 -1
  22. package/public/locales/cs/sdoc-editor.json +2 -1
  23. package/public/locales/de/sdoc-editor.json +2 -1
  24. package/public/locales/en/sdoc-editor.json +4 -1
  25. package/public/locales/es/sdoc-editor.json +2 -1
  26. package/public/locales/fr/sdoc-editor.json +2 -1
  27. package/public/locales/it/sdoc-editor.json +2 -1
  28. package/public/locales/ru/sdoc-editor.json +2 -1
  29. package/public/locales/zh_CN/sdoc-editor.json +5 -1
  30. package/public/media/sdoc-editor-font/iconfont.eot +0 -0
  31. package/public/media/sdoc-editor-font/iconfont.svg +2 -0
  32. package/public/media/sdoc-editor-font/iconfont.ttf +0 -0
  33. package/public/media/sdoc-editor-font/iconfont.woff +0 -0
  34. package/public/media/sdoc-editor-font/iconfont.woff2 +0 -0
  35. package/public/media/sdoc-editor-font.css +10 -6
  36. package/dist/basic-sdk/extension/commons/tooltip/index.js +0 -21
  37. /package/dist/{basic-sdk/extension/commons → components}/tooltip/index.css +0 -0
@@ -48,6 +48,32 @@
48
48
  display: inline-block;
49
49
  }
50
50
 
51
+ .sdoc-editor-container .article .sdoc-image-content {
52
+ display: flex;
53
+ flex-direction: column;
54
+ align-items: center;
55
+ }
56
+
57
+ .sdoc-editor-container .article .sdoc-image-content :first-child {
58
+ position: relative;
59
+ }
60
+
61
+ .sdoc-editor-container .article .sdoc-image-content .sdoc-image-caption-input-wrapper {
62
+ border: 0px;
63
+ width: 120px;
64
+ margin-top: 8px;
65
+ color: #8A8F8D;
66
+ background-color: transparent;
67
+ text-align: center;
68
+ overflow: hidden;
69
+ text-overflow: ellipsis;
70
+ white-space: nowrap;
71
+ }
72
+
73
+ .sdoc-editor-container .article .sdoc-image-content .sdoc-image-caption-input-wrapper::placeholder {
74
+ color: #bec0bf
75
+ }
76
+
51
77
  .sdoc-editor-container .article .image-selected {
52
78
  box-shadow: 0 0 0 2px #007bff;
53
79
  }
@@ -2,9 +2,10 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  import React, { useCallback, useMemo, useState } from 'react';
4
4
  import { withTranslation } from 'react-i18next';
5
- import { Dropdown, DropdownItem, DropdownMenu, DropdownToggle, UncontrolledTooltip } from 'reactstrap';
5
+ import { Dropdown, DropdownItem, DropdownMenu, DropdownToggle } from 'reactstrap';
6
6
  import dayjs from 'dayjs';
7
7
  import CommentEditor from './comment-editor';
8
+ import Tooltip from '../../../components/tooltip';
8
9
  var CommentItem = function CommentItem(_ref) {
9
10
  var isActive = _ref.isActive,
10
11
  container = _ref.container,
@@ -82,19 +83,13 @@ var CommentItem = function CommentItem(_ref) {
82
83
  }, dayjs(comment.updated_at).format('MM-DD HH:mm')))), isActive && /*#__PURE__*/React.createElement("div", {
83
84
  className: "d-flex"
84
85
  }, !comment.resolved && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
86
+ id: "tooltip_".concat(menuId),
85
87
  className: "comment-operation mr-2",
86
88
  onClick: markAsResolved
87
89
  }, /*#__PURE__*/React.createElement("i", {
88
- id: "tooltip_".concat(menuId),
89
90
  className: "sdocfont sdoc-confirm"
90
- })), /*#__PURE__*/React.createElement(UncontrolledTooltip, {
91
- target: "tooltip_".concat(menuId),
92
- delay: {
93
- show: 0,
94
- hide: 0
95
- },
96
- fade: false,
97
- placement: "bottom"
91
+ })), /*#__PURE__*/React.createElement(Tooltip, {
92
+ target: "tooltip_".concat(menuId)
98
93
  }, t('Resolved_tip'))), /*#__PURE__*/React.createElement(Dropdown, {
99
94
  isOpen: isDropdownOpen,
100
95
  toggle: function toggle() {
@@ -103,25 +103,21 @@
103
103
  line-height: 16px;
104
104
  }
105
105
 
106
- .sdoc-comment-list-container .comment-header .comment-operation {
107
- line-height: 20px;
108
- font-size: 20px;
109
- color: rgb(70, 77, 90);
110
- width: 20px;
111
- height: 20px;
112
- cursor: pointer;
113
- }
114
-
115
106
  .sdoc-comment-list-container .comment-ui-container .comment-operation {
116
107
  width: 32px;
117
108
  height: 32px;
109
+ padding: 0 !important;
118
110
  display: flex;
119
111
  align-items: center;
120
112
  justify-content: center;
113
+ border-radius: 50%;
114
+ background-color: #fff;
115
+ color: rgb(70, 77, 90);
116
+ overflow: hidden;
121
117
  }
122
118
 
123
119
  .sdoc-comment-list-container .comment-ui-container.active .comment-operation:hover {
124
- border-radius: 100%;
120
+ cursor: pointer;
125
121
  background-color: #f0f0f0;
126
122
  }
127
123
 
@@ -8,7 +8,7 @@ import { DEFAULT_COLORS, STANDARD_COLORS, DEFAULT_RECENT_USED_LIST } from '../..
8
8
  import { LocalStorage } from '../../../../utils';
9
9
  import { eventStopPropagation } from '../../../utils/mouse-event';
10
10
  import ColorItem from './color-item';
11
- import Tooltip from '../tooltip';
11
+ import Tooltip from '../../../../components/tooltip';
12
12
  import './index.css';
13
13
  var ColorMenu = function ColorMenu(_ref) {
14
14
  var iconClass = _ref.iconClass,
@@ -1,6 +1,6 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
- import Tooltip from '../tooltip';
3
+ import Tooltip from '../../../../components/tooltip';
4
4
  import classnames from 'classnames';
5
5
  import { SDOC_LINK } from '../../constants';
6
6
  var MenuItem = function MenuItem(_ref) {
@@ -119,8 +119,9 @@ var CodeBlock = function CodeBlock(_ref) {
119
119
  };
120
120
  }, [onScroll, readOnly, scrollRef]);
121
121
  var onHiddenHoverMenu = useCallback(function () {
122
- setShowHoverMenu(false);
123
- // eslint-disable-next-line react-hooks/exhaustive-deps
122
+ if (codeBlockRef.current) {
123
+ setShowHoverMenu(false);
124
+ }
124
125
  }, []);
125
126
  useEffect(function () {
126
127
  var eventBus = EventBus.getInstance();
@@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next';
6
6
  import classnames from 'classnames';
7
7
  import { isMenuDisabled, getFont, setFont } from '../../helpers';
8
8
  import { FONT, RECENT_USED_FONTS_KEY, DEFAULT_FONT } from '../../../../constants';
9
- import Tooltip from '../../../../commons/tooltip';
9
+ import Tooltip from '../../../../../../components/tooltip';
10
10
  import LocalStorage from '../../../../../../utils/local-storage-utils';
11
11
  import context from '../../../../../../context';
12
12
  import FontItem from './font-item';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import classnames from 'classnames';
3
- import Tooltip from '../../../../commons/tooltip';
3
+ import Tooltip from '../../../../../../components/tooltip';
4
4
  var FontSizeScale = function FontSizeScale(_ref) {
5
5
  var children = _ref.children,
6
6
  id = _ref.id,
@@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next';
5
5
  import classnames from 'classnames';
6
6
  import { isMenuDisabled, getFontSize, setFontSize } from '../../helpers';
7
7
  import { FONT_SIZE } from '../../../../constants';
8
- import Tooltip from '../../../../commons/tooltip';
8
+ import Tooltip from '../../../../../../components/tooltip';
9
9
  import './index.css';
10
10
  var FontSize = function FontSize(_ref) {
11
11
  var isRichEditor = _ref.isRichEditor,
@@ -8,7 +8,7 @@ import { withTranslation } from 'react-i18next';
8
8
  import classnames from 'classnames';
9
9
  import { getHeaderType, isMenuDisabled, setHeaderType } from '../helpers';
10
10
  import { HEADERS, HEADER_TITLE_MAP, MAC_HOTKEYS, PARAGRAPH, SDOC_FONT_SIZE, SUBTITLE, TITLE, WIN_HOTKEYS } from '../../../constants';
11
- import Tooltip from '../../../commons/tooltip';
11
+ import Tooltip from '../../../../../components/tooltip';
12
12
  import { focusEditor } from '../../../core';
13
13
  import './style.css';
14
14
  var HeaderMenu = /*#__PURE__*/function (_React$Component) {
@@ -6,7 +6,7 @@ import { ReactEditor } from '@seafile/slate-react';
6
6
  import { withTranslation } from 'react-i18next';
7
7
  import classnames from 'classnames';
8
8
  import { ElementPopover } from '../../../commons';
9
- import Tooltip from '../../../commons/tooltip';
9
+ import Tooltip from '../../../../../components/tooltip';
10
10
  import ImagePreviewer from '../dialogs/image-previewer';
11
11
  import { getImageURL } from '../helpers';
12
12
  import { IMAGE_DISPLAY_TYPE, IMAGE_BORDER_TYPE } from '../constants';
@@ -17,6 +17,7 @@ var ImageHoverMenu = function ImageHoverMenu(_ref) {
17
17
  menuPosition = _ref.menuPosition,
18
18
  element = _ref.element,
19
19
  onHideImageHoverMenu = _ref.onHideImageHoverMenu,
20
+ onShowCaption = _ref.onShowCaption,
20
21
  t = _ref.t;
21
22
  var data = element.data,
22
23
  _element$display_type = element.display_type,
@@ -116,7 +117,20 @@ var ImageHoverMenu = function ImageHoverMenu(_ref) {
116
117
  target: "sdoc_image_border",
117
118
  placement: "top",
118
119
  fade: true
119
- }, t('Image_border')))), /*#__PURE__*/React.createElement("span", {
120
+ }, t('Image_border'))), display_type === IMAGE_DISPLAY_TYPE[1] && /*#__PURE__*/React.createElement("span", {
121
+ id: "sdoc_image_caption",
122
+ role: "button",
123
+ className: classnames('op-item', 'ml-1'),
124
+ onClick: function onClick() {
125
+ onShowCaption();
126
+ }
127
+ }, /*#__PURE__*/React.createElement("i", {
128
+ className: "sdocfont sdoc-describe icon-font mr-1"
129
+ }), isShowTooltip && /*#__PURE__*/React.createElement(Tooltip, {
130
+ target: "sdoc_image_caption",
131
+ placement: "top",
132
+ fade: true
133
+ }, t('Insert_caption')))), /*#__PURE__*/React.createElement("span", {
120
134
  className: "op-group-item"
121
135
  }, /*#__PURE__*/React.createElement("span", {
122
136
  id: "sdoc_image_full_screen_mode",
@@ -1,7 +1,8 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  import React, { useState, useCallback, useRef, useEffect } from 'react';
4
- import { useSelected, useReadOnly } from '@seafile/slate-react';
4
+ import { ReactEditor, useSelected, useReadOnly } from '@seafile/slate-react';
5
+ import { Transforms } from '@seafile/slate';
5
6
  import classNames from 'classnames';
6
7
  import { withTranslation } from 'react-i18next';
7
8
  import { getImageURL, updateImage } from './helpers';
@@ -27,9 +28,10 @@ var Image = function Image(_ref) {
27
28
  border_type = _element$border_type === void 0 ? IMAGE_BORDER_TYPE[0].type : _element$border_type;
28
29
  var imageWrapStyle = {
29
30
  display: display_type === 'Block' ? 'block' : 'inline-block',
31
+ paddingTop: display_type === 'Block' ? '8px' : '',
30
32
  textAlign: display_type === 'Block' ? align : ''
31
33
  };
32
- var imageInnerStyle = {
34
+ var imageStyle = {
33
35
  border: IMAGE_BORDER_TYPE.find(function (item) {
34
36
  return item.type === border_type;
35
37
  }).value
@@ -58,6 +60,14 @@ var Image = function Image(_ref) {
58
60
  _useState10 = _slicedToArray(_useState9, 2),
59
61
  menuPosition = _useState10[0],
60
62
  setMenuPosition = _useState10[1];
63
+ var _useState11 = useState((data === null || data === void 0 ? void 0 : data.caption) || ''),
64
+ _useState12 = _slicedToArray(_useState11, 2),
65
+ caption = _useState12[0],
66
+ setCaption = _useState12[1];
67
+ var _useState13 = useState(false),
68
+ _useState14 = _slicedToArray(_useState13, 2),
69
+ isShowCaption = _useState14[0],
70
+ setIsShowCaption = _useState14[1];
61
71
  var registerEvent = useCallback(function (eventList) {
62
72
  eventList.forEach(function (element) {
63
73
  document.addEventListener(element.eventName, element.event);
@@ -92,12 +102,19 @@ var Image = function Image(_ref) {
92
102
  width: imageRef.current.width
93
103
  });
94
104
  updateImage(editor, newData);
95
- setIsResizing(false);
105
+
106
+ // Reset hover menu position
107
+ setTimeout(function () {
108
+ setIsResizing(false);
109
+ setIsShowImageHoverMenu(true);
110
+ setPosition();
111
+ }, 100);
96
112
  // eslint-disable-next-line react-hooks/exhaustive-deps
97
- }, [editor, element.data]);
113
+ }, [editor, element.data, imageRef.current]);
98
114
  var onResizeStart = useCallback(function (event) {
99
115
  event.preventDefault();
100
116
  event.stopPropagation();
117
+ setIsShowImageHoverMenu(false);
101
118
  setIsResizing(true);
102
119
  registerEvent([{
103
120
  'eventName': 'mousemove',
@@ -115,15 +132,16 @@ var Image = function Image(_ref) {
115
132
  };
116
133
  }, [element.data, movingWidth]);
117
134
  var onScroll = useCallback(function () {
118
- setPosition(imageRef.current);
135
+ setPosition();
119
136
  // eslint-disable-next-line react-hooks/exhaustive-deps
120
137
  }, []);
121
138
  var onHideImageHoverMenu = useCallback(function (e) {
122
139
  var _imagePreviewer$;
140
+ if (isResizing) return;
123
141
  var imagePreviewer = document.getElementsByClassName('sf-editor-image-previewer');
124
142
  if (e.target === imageRef.current || ((_imagePreviewer$ = imagePreviewer[0]) === null || _imagePreviewer$ === void 0 ? void 0 : _imagePreviewer$.contains(e.target))) return;
125
143
  setIsShowImageHoverMenu(false);
126
- }, []);
144
+ }, [isResizing]);
127
145
  useEffect(function () {
128
146
  var observerRefValue = null;
129
147
  if (isShowImageHoverMenu) {
@@ -151,23 +169,19 @@ var Image = function Image(_ref) {
151
169
  };
152
170
  // eslint-disable-next-line react-hooks/exhaustive-deps
153
171
  }, [isShowImageHoverMenu, onHideImageHoverMenu]);
154
- var setPosition = useCallback(function (elem) {
155
- if (elem) {
156
- var _elem$getBoundingClie = elem.getBoundingClientRect(),
157
- top = _elem$getBoundingClie.top,
158
- left = _elem$getBoundingClie.left,
159
- width = _elem$getBoundingClie.width;
160
- var menuTop = top - 42;
161
- var menuLeft = left - 222 / 2 + width / 2; // left = left distance - (menu width / 2) + (image with / 2)
172
+ var setPosition = useCallback(function () {
173
+ if (imageRef.current) {
174
+ var _imageRef$current$get = imageRef.current.getBoundingClientRect(),
175
+ top = _imageRef$current$get.top,
176
+ left = _imageRef$current$get.left;
162
177
  setMenuPosition({
163
- top: menuTop,
164
- left: menuLeft
178
+ top: top - 42,
179
+ left: left - 3
165
180
  });
166
181
  }
167
- // eslint-disable-next-line react-hooks/exhaustive-deps
168
182
  }, []);
169
183
  var onClickImage = useCallback(function (e) {
170
- setPosition(e.currentTarget);
184
+ setPosition();
171
185
  setIsShowImageHoverMenu(true);
172
186
  }, [setPosition]);
173
187
  var reloadImage = useCallback(function () {
@@ -184,6 +198,19 @@ var Image = function Image(_ref) {
184
198
  }
185
199
  // eslint-disable-next-line react-hooks/exhaustive-deps
186
200
  }, []);
201
+ var onSetCaption = useCallback(function (e) {
202
+ var path = ReactEditor.findPath(editor, element);
203
+ var newData = _objectSpread(_objectSpread({}, data), {}, {
204
+ caption: e.target.value.trim()
205
+ });
206
+ if (path) {
207
+ Transforms.setNodes(editor, {
208
+ data: newData
209
+ }, {
210
+ at: path
211
+ });
212
+ }
213
+ }, [data, editor, element]);
187
214
  return /*#__PURE__*/React.createElement(React.Fragment, null, isShowImagePlaceholder && /*#__PURE__*/React.createElement("span", Object.assign({
188
215
  className: classNames('sdoc-image-wrapper', className)
189
216
  }, attributes), /*#__PURE__*/React.createElement("img", {
@@ -197,13 +224,16 @@ var Image = function Image(_ref) {
197
224
  }, attributes, {
198
225
  style: imageWrapStyle
199
226
  }), /*#__PURE__*/React.createElement("span", {
200
- className: "sdoc-image-inner",
201
- onClick: onClickImage,
202
- style: imageInnerStyle
227
+ className: "sdoc-image-inner"
228
+ }, /*#__PURE__*/React.createElement("span", {
229
+ className: "sdoc-image-content"
230
+ }, /*#__PURE__*/React.createElement("span", {
231
+ style: imageStyle
203
232
  }, /*#__PURE__*/React.createElement("img", {
204
233
  className: classNames({
205
234
  'image-selected': isSelected
206
235
  }),
236
+ onClick: onClickImage,
207
237
  ref: imageRef,
208
238
  src: getImageURL(data.src),
209
239
  style: getImageStyle(),
@@ -217,12 +247,26 @@ var Image = function Image(_ref) {
217
247
  }), isResizing && /*#__PURE__*/React.createElement("span", {
218
248
  className: "image-size",
219
249
  contentEditable: false
220
- }, /*#__PURE__*/React.createElement("span", null, t('Width'), ':', parseInt(movingWidth || imageRef.current.clientWidth)), /*#__PURE__*/React.createElement("span", null, "\xA0\xA0"), /*#__PURE__*/React.createElement("span", null, t('Height'), ':', imageRef.current.clientHeight))), children), isShowImageHoverMenu && !readOnly && /*#__PURE__*/React.createElement(ImageHoverMenu, {
250
+ }, /*#__PURE__*/React.createElement("span", null, t('Width'), ':', parseInt(movingWidth || imageRef.current.clientWidth)), /*#__PURE__*/React.createElement("span", null, "\xA0\xA0"), /*#__PURE__*/React.createElement("span", null, t('Height'), ':', imageRef.current.clientHeight))), display_type === 'Block' && (isShowCaption || (data === null || data === void 0 ? void 0 : data.caption)) && /*#__PURE__*/React.createElement("input", {
251
+ className: "sdoc-image-caption-input-wrapper",
252
+ placeholder: t('Insert_caption'),
253
+ value: caption,
254
+ onBlur: onSetCaption,
255
+ onChange: function onChange(e) {
256
+ setCaption(e.target.value.trim());
257
+ },
258
+ onCompositionStart: function onCompositionStart(e) {
259
+ e.stopPropagation();
260
+ }
261
+ }))), children), isShowImageHoverMenu && !readOnly && /*#__PURE__*/React.createElement(ImageHoverMenu, {
221
262
  editor: editor,
222
263
  menuPosition: menuPosition,
223
264
  element: element,
224
265
  onHideImageHoverMenu: function onHideImageHoverMenu() {
225
266
  setIsShowImageHoverMenu(false);
267
+ },
268
+ onShowCaption: function onShowCaption() {
269
+ setIsShowCaption(true);
226
270
  }
227
271
  })));
228
272
  };
@@ -878,4 +878,64 @@ export var getRowHeight = function getRowHeight(element, rowIndex) {
878
878
  style = _element$style === void 0 ? {} : _element$style;
879
879
  var rowHeight = style[TABLE_ROW_STYLE.MIN_HEIGHT] || TABLE_ROW_MIN_HEIGHT;
880
880
  return rowIndex === 0 ? rowHeight + 1 : rowHeight;
881
+ };
882
+ var normalizeTableCell = function normalizeTableCell(cell) {
883
+ if (!cell) return generateTableCell();
884
+ var newCell = _objectSpread({
885
+ children: [{
886
+ text: '',
887
+ id: slugid.nice()
888
+ }]
889
+ }, cell);
890
+
891
+ // normalize cell children
892
+ var newCellChildren = [];
893
+ newCell.children.forEach(function (cellChild) {
894
+ var cellChildType = cellChild.type;
895
+ if (cellChildType === ELEMENT_TYPE.PARAGRAPH) {
896
+ newCellChildren.push.apply(newCellChildren, _toConsumableArray(cellChild.children));
897
+ } else {
898
+ newCellChildren.push(cellChild);
899
+ }
900
+ });
901
+ newCell.children = newCellChildren.map(function (item) {
902
+ if (item.BOLD) {
903
+ item.bold = item.BOLD;
904
+ delete item['BOLD'];
905
+ }
906
+ if (item.ITALIC) {
907
+ item.italic = item.ITALIC;
908
+ delete item['ITALIC'];
909
+ }
910
+ return item;
911
+ });
912
+
913
+ // normalize cell style
914
+ if (newCell.data) {
915
+ var cellStyle = _objectSpread({}, newCell.data);
916
+ delete newCell['data'];
917
+ Object.keys(cellStyle).forEach(function (cellStyleKey) {
918
+ if (cellStyleKey === 'align') {
919
+ cellStyle['text_align'] = cellStyle['align'];
920
+ delete cellStyle['align'];
921
+ }
922
+ });
923
+ newCell.style = cellStyle;
924
+ }
925
+ return newCell;
926
+ };
927
+ export var normalizeTableELement = function normalizeTableELement(editor, element) {
928
+ if (element.type !== ELEMENT_TYPE.TABLE) {
929
+ var size = [element.children.length, element.children[0].children.length];
930
+ return generateEmptyTable(editor, size);
931
+ }
932
+ var newElement = _objectSpread({}, element);
933
+ for (var i = 0; i < element.children.length; i++) {
934
+ var row = newElement.children[i];
935
+ for (var j = 0; j < row.children.length; j++) {
936
+ row.children[j] = normalizeTableCell(row.children[j]);
937
+ }
938
+ newElement.children[i] = row;
939
+ }
940
+ return newElement;
881
941
  };
@@ -1,5 +1,5 @@
1
1
  import { decorateOperation, replacePastedDataId } from './helpers';
2
- import { getSlateFragmentAttribute } from '../utils/document-utils';
2
+ import { getSlateFragmentAttribute, normalizeCopyNodes } from '../utils/document-utils';
3
3
  import { CLIPBOARD_FORMAT_KEY } from '../extension/constants';
4
4
  var withNodeId = function withNodeId(editor) {
5
5
  var apply = editor.apply;
@@ -16,7 +16,8 @@ var withNodeId = function withNodeId(editor) {
16
16
  var decoded = decodeURIComponent(window.atob(fragment));
17
17
  var parsed = JSON.parse(decoded);
18
18
  var newData = replacePastedDataId(parsed);
19
- newEditor.insertFragment(newData);
19
+ var normalizeNewData = normalizeCopyNodes(newEditor, newData);
20
+ newEditor.insertFragment(normalizeNewData);
20
21
  return newEditor;
21
22
  }
22
23
  };
@@ -1,10 +1,10 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import React, { useCallback, useEffect, useMemo, useState } from 'react';
3
3
  import { withTranslation } from 'react-i18next';
4
- import { UncontrolledTooltip } from 'reactstrap';
5
4
  import { INTERNAL_EVENT } from '../constants';
6
5
  import EventBus from '../utils/event-bus';
7
6
  import OutlineItem from './outline-item';
7
+ import Tooltip from '../../components/tooltip';
8
8
  import './style.css';
9
9
  export var getOutlineSetting = function getOutlineSetting() {
10
10
  var currentValue = localStorage.getItem('sdoc');
@@ -72,7 +72,7 @@ var SDocOutline = function SDocOutline(_ref) {
72
72
  id: "sdoc-outline-menu",
73
73
  className: "sdoc-outline-menu sdocfont sdoc-table-of-content",
74
74
  onClick: toggleShow
75
- }), /*#__PURE__*/React.createElement(UncontrolledTooltip, {
75
+ }), /*#__PURE__*/React.createElement(Tooltip, {
76
76
  placement: "right",
77
77
  target: "sdoc-outline-menu"
78
78
  }, t('Outline'))));
@@ -2,7 +2,8 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import ObjectUtils from './object-utils';
3
3
  import context from '../../context';
4
4
  import { generateDefaultText } from '../../basic-sdk/extension/core/utils/index';
5
- import { CLIPBOARD_ORIGIN_SDOC_KEY } from '../extension/constants';
5
+ import { CLIPBOARD_ORIGIN_SDOC_KEY, ELEMENT_TYPE } from '../extension/constants';
6
+ import { normalizeTableELement } from '../extension/plugins/table/helpers';
6
7
  export var normalizeChildren = function normalizeChildren(children) {
7
8
  // text
8
9
  if (!Array.isArray(children)) return children;
@@ -19,6 +20,15 @@ export var normalizeChildren = function normalizeChildren(children) {
19
20
  return child;
20
21
  });
21
22
  };
23
+ export var normalizeCopyNodes = function normalizeCopyNodes(editor, elements) {
24
+ if (!Array.isArray(elements) || elements.length === 0) return [];
25
+ return elements.map(function (element) {
26
+ if (element.type === ELEMENT_TYPE.TABLE) {
27
+ return normalizeTableELement(editor, element);
28
+ }
29
+ return element;
30
+ });
31
+ };
22
32
  export var setOriginSdocKey = function setOriginSdocKey(event) {
23
33
  var docUuid = context.getSetting('docUuid');
24
34
  event.clipboardData.setData("text/".concat(CLIPBOARD_ORIGIN_SDOC_KEY), docUuid);
@@ -1,7 +1,7 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import React, { useCallback, useState } from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
- import Tooltip from '../../../../basic-sdk/extension/commons/tooltip';
4
+ import Tooltip from '../../../tooltip';
5
5
  import './index.css';
6
6
  var ChangesCount = function ChangesCount(_ref) {
7
7
  var changes = _ref.changes;
@@ -1,7 +1,7 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
- import { UncontrolledTooltip } from 'reactstrap';
4
3
  import Switch from '../../../switch';
4
+ import Tooltip from '../../../tooltip';
5
5
  import './index.css';
6
6
  var ViewChanges = function ViewChanges(_ref) {
7
7
  var isShowChanges = _ref.isShowChanges,
@@ -19,9 +19,8 @@ var ViewChanges = function ViewChanges(_ref) {
19
19
  checked: isShowChanges,
20
20
  onChange: onViewChangesToggle,
21
21
  className: "sdoc-toggle-revision-changes d-flex align-items-center"
22
- })), /*#__PURE__*/React.createElement(UncontrolledTooltip, {
23
- target: "sdoc-toggle-revision-changes-container",
24
- fade: false
22
+ })), /*#__PURE__*/React.createElement(Tooltip, {
23
+ target: "sdoc-toggle-revision-changes-container"
25
24
  }, t('View_changes')));
26
25
  };
27
26
  export default ViewChanges;
@@ -0,0 +1,31 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import React from 'react';
3
+ import { UncontrolledTooltip } from 'reactstrap';
4
+ import classnames from 'classnames';
5
+ import './index.css';
6
+ var Tooltip = function Tooltip(_ref) {
7
+ var target = _ref.target,
8
+ children = _ref.children,
9
+ className = _ref.className,
10
+ modifiers = _ref.modifiers,
11
+ _ref$placement = _ref.placement,
12
+ placement = _ref$placement === void 0 ? 'bottom' : _ref$placement,
13
+ _ref$fade = _ref.fade,
14
+ fade = _ref$fade === void 0 ? false : _ref$fade,
15
+ _ref$delay = _ref.delay,
16
+ delay = _ref$delay === void 0 ? 0 : _ref$delay;
17
+ var props = {
18
+ popperClassName: classnames('sdoc-tooltip', className),
19
+ modifiers: _objectSpread(_objectSpread({}, modifiers), {}, {
20
+ preventOverflow: _objectSpread({
21
+ boundariesElement: window.document.body
22
+ }, modifiers === null || modifiers === void 0 ? void 0 : modifiers.preventOverflow)
23
+ }),
24
+ placement: placement,
25
+ target: target,
26
+ fade: fade,
27
+ delay: delay
28
+ };
29
+ return /*#__PURE__*/React.createElement(UncontrolledTooltip, props, children);
30
+ };
31
+ export default Tooltip;
@@ -12,7 +12,11 @@ export var useDocument = function useDocument() {
12
12
  _useState4 = _slicedToArray(_useState3, 2),
13
13
  isReloading = _useState4[0],
14
14
  setIsReloading = _useState4[1];
15
- var _useState5 = useState(true),
15
+ var _useState5 = useState({
16
+ version: 0,
17
+ children: [],
18
+ cursors: {}
19
+ }),
16
20
  _useState6 = _slicedToArray(_useState5, 2),
17
21
  document = _useState6[0],
18
22
  setDocument = _useState6[1];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.2.13beta3",
3
+ "version": "0.2.14",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
@@ -385,5 +385,6 @@
385
385
  "Image_border": "Image border",
386
386
  "Delete_revision": "Delete revision",
387
387
  "Delete_tip": "Are you sure you want to delete {{content}} ?",
388
- "Revision_deleted": "Revision deleted"
388
+ "Revision_deleted": "Revision deleted",
389
+ "Published": "Zveřejněné"
389
390
  }
@@ -385,5 +385,6 @@
385
385
  "Image_border": "Image border",
386
386
  "Delete_revision": "Delete revision",
387
387
  "Delete_tip": "Are you sure you want to delete {{content}} ?",
388
- "Revision_deleted": "Revision deleted"
388
+ "Revision_deleted": "Revision deleted",
389
+ "Published": "Veröffentlicht"
389
390
  }
@@ -386,5 +386,8 @@
386
386
  "Delete_revision": "Delete revision",
387
387
  "Delete_tip": "Are you sure you want to delete {{content}} ?",
388
388
  "Revision_deleted": "Revision deleted",
389
- "Published": "Published"
389
+ "Published": "Published",
390
+ "Delete_Successfully": "Delete Successfully",
391
+ "Delete_failed": "Delete failed",
392
+ "Insert_caption": "Insert caption"
390
393
  }
@@ -385,5 +385,6 @@
385
385
  "Image_border": "Image border",
386
386
  "Delete_revision": "Delete revision",
387
387
  "Delete_tip": "Are you sure you want to delete {{content}} ?",
388
- "Revision_deleted": "Revision deleted"
388
+ "Revision_deleted": "Revision deleted",
389
+ "Published": "Publicado"
389
390
  }
@@ -385,5 +385,6 @@
385
385
  "Image_border": "Image border",
386
386
  "Delete_revision": "Delete revision",
387
387
  "Delete_tip": "Are you sure you want to delete {{content}} ?",
388
- "Revision_deleted": "Revision deleted"
388
+ "Revision_deleted": "Revision deleted",
389
+ "Published": "Publié"
389
390
  }
@@ -385,5 +385,6 @@
385
385
  "Image_border": "Image border",
386
386
  "Delete_revision": "Delete revision",
387
387
  "Delete_tip": "Are you sure you want to delete {{content}} ?",
388
- "Revision_deleted": "Revision deleted"
388
+ "Revision_deleted": "Revision deleted",
389
+ "Published": "Pubblicato"
389
390
  }
@@ -385,5 +385,6 @@
385
385
  "Image_border": "Граница изображения",
386
386
  "Delete_revision": "Удалить редакцию",
387
387
  "Delete_tip": "Вы уверены, что хотите удалить {{content}} ?",
388
- "Revision_deleted": "Revision deleted"
388
+ "Revision_deleted": "Версия удалена",
389
+ "Published": "Опубликовано"
389
390
  }
@@ -385,5 +385,9 @@
385
385
  "Image_border": "图片边框",
386
386
  "Delete_revision": "删除修订稿",
387
387
  "Delete_tip": "确定要删除 {{content}} 吗?",
388
- "Revision_deleted": "修订稿已删除"
388
+ "Revision_deleted": "修订稿已删除",
389
+ "Published": "已发布",
390
+ "Delete_Successfully": "删除成功",
391
+ "Delete_failed": "删除失败",
392
+ "Insert_caption": "添加图片描述"
389
393
  }
@@ -14,6 +14,8 @@
14
14
  />
15
15
  <missing-glyph />
16
16
 
17
+ <glyph glyph-name="sdoc-describe" unicode="&#58967;" d="M992 352H32c-19.2 0-32 12.8-32 32V832c0 19.2 12.8 32 32 32h960c19.2 0 32-12.8 32-32v-448c0-19.2-12.8-32-32-32zM96 448h832V768H96v-320z m-96-224v-96h1024v96H0z m0-224v-96h576v96H0z" horiz-adv-x="1024" />
18
+
17
19
  <glyph glyph-name="sdoc-add-comment" unicode="&#58939;" d="M960 896c35.2 0 64-28.8 64-64v-704c0-35.2-28.8-64-64-64h-224l-224-192-224 192H64c-35.2 0-64 28.8-64 64V832C0 867.2 28.8 896 64 896h896z m-32-96H96v-640h227.2l188.8-160 188.8 160H928V800zM288 528h448v-96H288zM464 704h96v-448h-96z" horiz-adv-x="1024" />
18
20
 
19
21
  <glyph glyph-name="sdoc-comment-count" unicode="&#58966;" d="M1024 832v-704c0-35.2-28.8-64-64-64h-192l-256-192-224 192H64c-35.2 0-64 28.8-64 64V832C0 867.2 28.8 896 64 896h896c35.2 0 64-28.8 64-64z" horiz-adv-x="1024" />
@@ -1,11 +1,11 @@
1
1
  @font-face {
2
2
  font-family: "sdocfont"; /* Project id 4097705 */
3
- src: url('./sdoc-editor-font/iconfont.eot?t=1696755823394'); /* IE9 */
4
- src: url('./sdoc-editor-font/iconfont.eot?t=1696755823394#iefix') format('embedded-opentype'), /* IE6-IE8 */
5
- url('./sdoc-editor-font/iconfont.woff2?t=1696755823394') format('woff2'),
6
- url('./sdoc-editor-font/iconfont.woff?t=1696755823394') format('woff'),
7
- url('./sdoc-editor-font/iconfont.ttf?t=1696755823394') format('truetype'),
8
- url('./sdoc-editor-font/iconfont.svg?t=1696755823394#sdocfont') format('svg');
3
+ src: url('./sdoc-editor-font/iconfont.eot?t=1698118988223'); /* IE9 */
4
+ src: url('./sdoc-editor-font/iconfont.eot?t=1698118988223#iefix') format('embedded-opentype'), /* IE6-IE8 */
5
+ url('./sdoc-editor-font/iconfont.woff2?t=1698118988223') format('woff2'),
6
+ url('./sdoc-editor-font/iconfont.woff?t=1698118988223') format('woff'),
7
+ url('./sdoc-editor-font/iconfont.ttf?t=1698118988223') format('truetype'),
8
+ url('./sdoc-editor-font/iconfont.svg?t=1698118988223#sdocfont') format('svg');
9
9
  }
10
10
 
11
11
  .sdocfont {
@@ -16,6 +16,10 @@
16
16
  -moz-osx-font-smoothing: grayscale;
17
17
  }
18
18
 
19
+ .sdoc-describe:before {
20
+ content: "\e657";
21
+ }
22
+
19
23
  .sdoc-add-comment:before {
20
24
  content: "\e63b";
21
25
  }
@@ -1,21 +0,0 @@
1
- import React from 'react';
2
- import { UncontrolledTooltip } from 'reactstrap';
3
- import classnames from 'classnames';
4
- import './index.css';
5
- var Tooltip = function Tooltip(_ref) {
6
- var target = _ref.target,
7
- children = _ref.children,
8
- className = _ref.className,
9
- placement = _ref.placement,
10
- _ref$fade = _ref.fade,
11
- fade = _ref$fade === void 0 ? false : _ref$fade;
12
- var popperClassName = classnames('sdoc-tooltip', className);
13
- return /*#__PURE__*/React.createElement(UncontrolledTooltip, {
14
- popperClassName: popperClassName,
15
- target: target,
16
- fade: fade,
17
- placement: placement || 'bottom',
18
- delay: 0
19
- }, children);
20
- };
21
- export default Tooltip;