@seafile/sdoc-editor 0.1.72 → 0.1.74
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/basic-sdk/comment/comment-decorate.js +1 -1
- package/dist/basic-sdk/editor.js +48 -0
- package/dist/basic-sdk/extension/constants/index.js +2 -2
- package/dist/basic-sdk/extension/plugins/header/plugin.js +2 -2
- package/dist/basic-sdk/extension/plugins/text-style/render-elem.js +2 -5
- package/dist/basic-sdk/views/diff-viewer.js +1 -1
- package/package.json +1 -1
|
@@ -20,7 +20,7 @@ export var commentDecorate = function commentDecorate(editor) {
|
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
// rgba prevents occlusion of the cursor
|
|
23
|
-
decoration['
|
|
23
|
+
decoration['computed_bg_color'] = 'rgba(129, 237, 247, 0.5)';
|
|
24
24
|
decoration['comment_count'] = editor.comments_map[node.id].length;
|
|
25
25
|
decorations.push(decoration);
|
|
26
26
|
}
|
package/dist/basic-sdk/editor.js
CHANGED
|
@@ -136,6 +136,54 @@ var SDocEditor = function SDocEditor(_ref) {
|
|
|
136
136
|
scrollRef.current.scroll(0, Math.max(0, scrollTop + _domHeight));
|
|
137
137
|
return;
|
|
138
138
|
}
|
|
139
|
+
if (event.key === 'Backspace') {
|
|
140
|
+
var _getCursorPosition3 = getCursorPosition(),
|
|
141
|
+
_y2 = _getCursorPosition3.y;
|
|
142
|
+
|
|
143
|
+
// above viewport
|
|
144
|
+
if (_y2 < 0) {
|
|
145
|
+
var newY = Math.abs(_y2);
|
|
146
|
+
if (isSelectionAtBlockStart(editor)) {
|
|
147
|
+
var _prevNode = getPrevNode(editor);
|
|
148
|
+
if (!_prevNode) return;
|
|
149
|
+
var _domNode2 = ReactEditor.toDOMNode(editor, _prevNode[0]);
|
|
150
|
+
var _domHeight2 = getDomHeight(_domNode2);
|
|
151
|
+
scrollRef.current.scroll(0, Math.max(0, scrollTop - (newY + _domHeight2)));
|
|
152
|
+
} else {
|
|
153
|
+
scrollRef.current.scroll(0, Math.max(0, scrollTop - newY));
|
|
154
|
+
}
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// insider viewport
|
|
159
|
+
if (_y2 >= 0 && _y2 <= clientHeight) {
|
|
160
|
+
if (isSelectionAtBlockStart(editor)) {
|
|
161
|
+
var _prevNode2 = getPrevNode(editor);
|
|
162
|
+
if (!_prevNode2) return;
|
|
163
|
+
var _domNode3 = ReactEditor.toDOMNode(editor, _prevNode2[0]);
|
|
164
|
+
var _domHeight3 = getDomHeight(_domNode3);
|
|
165
|
+
if (_y2 >= _domHeight3) return;
|
|
166
|
+
// Scroll up the height of the previous block
|
|
167
|
+
scrollRef.current.scroll(0, Math.max(0, scrollTop - _domHeight3));
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// below viewport
|
|
173
|
+
if (_y2 > clientHeight) {
|
|
174
|
+
if (isSelectionAtBlockStart(editor)) {
|
|
175
|
+
// y: text top border
|
|
176
|
+
scrollRef.current.scroll(0, Math.max(0, scrollTop + (_y2 - clientHeight)));
|
|
177
|
+
} else {
|
|
178
|
+
var marginBottom = 11.2;
|
|
179
|
+
var _getCursorPosition4 = getCursorPosition(false),
|
|
180
|
+
_newY = _getCursorPosition4.y;
|
|
181
|
+
var rectBottom = _newY + marginBottom; // text bottom border
|
|
182
|
+
scrollRef.current.scroll(0, Math.max(0, scrollTop + (rectBottom - clientHeight)));
|
|
183
|
+
}
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
139
187
|
eventProxy.onKeyDown(event);
|
|
140
188
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
141
189
|
}, []);
|
|
@@ -114,11 +114,11 @@ export var TABLE_ELEMENT_POSITION = {
|
|
|
114
114
|
BEFORE: 'before'
|
|
115
115
|
};
|
|
116
116
|
export var DELETED_STYLE = {
|
|
117
|
-
|
|
117
|
+
computed_bg_color: '#ffeef0',
|
|
118
118
|
color: 'rgb(165, 32, 21)'
|
|
119
119
|
};
|
|
120
120
|
export var ADDED_STYLE = {
|
|
121
|
-
|
|
121
|
+
computed_bg_color: '#e6ffed',
|
|
122
122
|
color: 'rgb(137, 181, 66)'
|
|
123
123
|
};
|
|
124
124
|
export { BLOCKQUOTE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, BOLD, ITALIC, UNDERLINE, STRIKETHROUGH, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM, LIST_LIC, CHECK_LIST, CHECK_LIST_ITEM, LINK, HTML, CODE_BLOCK, CODE_LINE, IMAGE, TABLE, TABLE_CELL, TABLE_ROW, FORMULA, COLUMN, TEXT_STYLE, BOLD_ITALIC, TEXT_ALIGN, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER, ELEMENT_TYPE, KEYBOARD };
|
|
@@ -27,10 +27,11 @@ var withHeader = function withHeader(editor) {
|
|
|
27
27
|
insertBreak();
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
+
var isAtLineEnd = isSelectionAtLineEnd(editor, match[1]);
|
|
30
31
|
var nextNode = Editor.next(editor, {
|
|
31
32
|
at: match[1]
|
|
32
33
|
});
|
|
33
|
-
if (nextNode) {
|
|
34
|
+
if (isAtLineEnd && nextNode && editor.children.length === 2) {
|
|
34
35
|
var _nextNode = _slicedToArray(nextNode, 2),
|
|
35
36
|
node = _nextNode[0],
|
|
36
37
|
path = _nextNode[1];
|
|
@@ -39,7 +40,6 @@ var withHeader = function withHeader(editor) {
|
|
|
39
40
|
return;
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
|
-
var isAtLineEnd = isSelectionAtLineEnd(editor, match[1]);
|
|
43
43
|
|
|
44
44
|
// If an empty p is inserted at the end of the line, otherwise wrap normally
|
|
45
45
|
if (isAtLineEnd) {
|
|
@@ -15,8 +15,8 @@ var renderText = function renderText(props, editor) {
|
|
|
15
15
|
style['display'] = 'inline-block';
|
|
16
16
|
style['minWidth'] = '2px';
|
|
17
17
|
}
|
|
18
|
-
if (leaf.
|
|
19
|
-
style['backgroundColor'] = leaf.
|
|
18
|
+
if (leaf.computed_bg_color) {
|
|
19
|
+
style['backgroundColor'] = leaf.computed_bg_color;
|
|
20
20
|
}
|
|
21
21
|
if (leaf.color) {
|
|
22
22
|
style['color'] = leaf.color;
|
|
@@ -55,9 +55,6 @@ var renderText = function renderText(props, editor) {
|
|
|
55
55
|
className: "token ".concat(leaf.type)
|
|
56
56
|
}, markedChildren);
|
|
57
57
|
}
|
|
58
|
-
if (leaf.bg_color) {
|
|
59
|
-
style['backgroundColor'] = leaf.bg_color;
|
|
60
|
-
}
|
|
61
58
|
return /*#__PURE__*/React.createElement("span", Object.assign({
|
|
62
59
|
"data-id": leaf.id
|
|
63
60
|
}, attributes, {
|
|
@@ -30,7 +30,7 @@ var DiffViewer = function DiffViewer(_ref) {
|
|
|
30
30
|
return /*#__PURE__*/React.createElement("span", {
|
|
31
31
|
className: "d-inline-block p-1",
|
|
32
32
|
style: {
|
|
33
|
-
backgroundColor: style.
|
|
33
|
+
backgroundColor: style.computed_bg_color,
|
|
34
34
|
width: 'fit-content',
|
|
35
35
|
height: 'fit-content'
|
|
36
36
|
}
|