@seafile/sdoc-editor 1.0.184-alpha.0 → 1.0.185

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.
@@ -31,7 +31,7 @@ const CommentList = _ref => {
31
31
  } = (0, _useCommentContext.useCommentContext)();
32
32
  const [showEditor, setShowEditor] = (0, _react.useState)(false);
33
33
  const [inputContent, setInputContent] = (0, _react.useState)(null);
34
- const [top, setTop] = (0, _react.useState)('-999px');
34
+ const [translateY, setTranslateY] = (0, _react.useState)(0);
35
35
  const isEmptyComment = Object.keys(commentDetail).length ? false : true;
36
36
  const isCollapseCommentEditor = !isEmptyComment && !showEditor;
37
37
  const insertComment = (0, _react.useCallback)(async (elementId, comment) => {
@@ -80,26 +80,29 @@ const CommentList = _ref => {
80
80
  setShowEditor(false);
81
81
  }, []);
82
82
  (0, _react.useEffect)(() => {
83
- console.log('position.y', position.y);
84
- setTop(`${position.y}px`);
85
- if (commentPopover !== null && commentPopover !== void 0 && commentPopover.current) {
86
- const {
87
- height
88
- } = commentPopover.current.getBoundingClientRect();
89
- const popoverBottomY = position.y + height;
90
- const viewportHeight = window.innerHeight;
91
- if (popoverBottomY > viewportHeight) {
92
- console.log('超出');
83
+ queueMicrotask(() => {
84
+ if (commentPopover !== null && commentPopover !== void 0 && commentPopover.current) {
85
+ const {
86
+ bottom
87
+ } = commentPopover.current.getBoundingClientRect();
88
+ const viewportHeight = window.innerHeight;
89
+ if (bottom > viewportHeight) {
90
+ const overflowY = bottom - viewportHeight;
91
+ setTranslateY(-(overflowY + 16));
92
+ } else {
93
+ setTranslateY(0);
94
+ }
93
95
  }
94
- }
95
- }, [position.y]);
96
+ });
97
+ }, [activeElement]);
96
98
  return /*#__PURE__*/_react.default.createElement("div", {
97
99
  ref: commentPopover,
98
100
  id: "sdoc-comment-list-container",
99
101
  className: "sdoc-comment-list-container sdoc-comment-list-container-popover",
100
102
  style: {
101
- top,
102
- width: '300px'
103
+ top: position.y,
104
+ width: '300px',
105
+ transform: `translateY(${translateY}px)`
103
106
  }
104
107
  }, /*#__PURE__*/_react.default.createElement(_commentItemWrapper.default, {
105
108
  commentDetailRef: commentDetailRef,
@@ -25,14 +25,16 @@
25
25
 
26
26
  .sdoc-file-card-link .sdoc-file-link-icon {
27
27
  position: absolute;
28
- top: 6px;
29
28
  left: 12px;
29
+ top: 50%;
30
+ transform: translateY(-50%);
30
31
  }
31
32
 
32
33
  .sdoc-file-card-link .sdoc-file-text-link {
33
34
  position: absolute;
34
- top: 16px;
35
35
  left: 42px;
36
+ top: 50%;
37
+ transform: translateY(-50%);
36
38
  width: 330px;
37
39
  overflow: hidden;
38
40
  text-overflow: ellipsis;
@@ -26,16 +26,17 @@
26
26
 
27
27
  .sdoc-file-card-link .sdoc-file-link-icon {
28
28
  position: absolute;
29
- top: 12px;
30
29
  left: 12px;
30
+ top: 50%;
31
+ transform: translateY(-50%);
31
32
  }
32
33
 
33
- .sdoc-file-render:not(.sdoc-file-card-link) .sdoc-file-link-icon .file-link-img {
34
- width: 21.6px;
34
+ .sdoc-file-render .sdoc-file-link-icon .file-link-img {
35
+ width: 20px;
35
36
  }
36
37
 
37
38
  .sdoc-file-card-link .sdoc-file-link-icon .file-link-img {
38
- width: 26px;
39
+ width: 28px;
39
40
  }
40
41
 
41
42
  .sdoc-file-render .sdoc-file-text-link.sdoc-no-file-link-icon a {
@@ -47,8 +48,13 @@
47
48
 
48
49
  .sdoc-file-card-link .sdoc-file-text-link {
49
50
  position: absolute;
50
- top: 14px;
51
51
  left: 42px;
52
+ top: 50%;
53
+ transform: translateY(-50%);
54
+ width: 330px;
55
+ overflow: hidden;
56
+ text-overflow: ellipsis;
57
+ white-space: nowrap;
52
58
  }
53
59
 
54
60
  .sdoc-file-card-link .sdoc-file-text-link a {
@@ -123,11 +123,6 @@ const TextStyleMenuList = _ref => {
123
123
  let list = getTextStyleList(_constants.TEXT_STYLE);
124
124
  const dropdownList = getTextStyleList(_constants.TEXT_STYLE_MORE);
125
125
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, list.map((itemProps, index) => {
126
- if (itemProps.type === _constants.LINK && editor.editorType !== _constants2.WIKI_EDITOR) {
127
- return /*#__PURE__*/_react.default.createElement(_react.Fragment, {
128
- key: index
129
- });
130
- }
131
126
  const Component = itemProps.isColor ? _commons.ColorMenu : _commons.MenuItem;
132
127
  return /*#__PURE__*/_react.default.createElement(Component, Object.assign({
133
128
  key: index
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "1.0.184-alpha.0",
3
+ "version": "1.0.185",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
7
7
  "dependencies": {
8
8
  "@seafile/print-js": "1.6.6",
9
- "@seafile/react-image-lightbox": "3.0.4",
9
+ "@seafile/react-image-lightbox": "2.0.5",
10
10
  "@seafile/slate": "0.91.8",
11
11
  "@seafile/slate-history": "0.86.2",
12
12
  "@seafile/slate-hyperscript": "0.81.7",