@seafile/sdoc-editor 0.3.19 → 0.3.21
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/assets/css/sdoc-editor-plugins.css +21 -6
- package/dist/basic-sdk/extension/plugins/check-list/plugin.js +32 -3
- package/dist/basic-sdk/extension/plugins/check-list/render-elem.js +6 -4
- package/dist/basic-sdk/extension/plugins/image/plugin.js +12 -1
- package/dist/basic-sdk/extension/plugins/image/render-elem.js +1 -1
- package/dist/basic-sdk/extension/plugins/table/helpers.js +5 -5
- package/dist/basic-sdk/extension/plugins/text-style/caret.js +2 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* header */
|
|
1
|
+
/* header */
|
|
2
2
|
.sdoc-editor-container .article .sdoc-header-title,
|
|
3
3
|
.sdoc-editor-container .article .sdoc-header-subtitle,
|
|
4
4
|
.sdoc-editor-container .article .sdoc-header-1,
|
|
@@ -24,16 +24,28 @@
|
|
|
24
24
|
/* list */
|
|
25
25
|
.sdoc-editor-container .article .list-container {
|
|
26
26
|
margin: 0;
|
|
27
|
-
|
|
27
|
+
/* override seafile-ui padding */
|
|
28
|
+
padding-left: 1.2em !important;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
/* check list */
|
|
32
|
+
.sdoc-editor-container .article .sdoc-checkbox-container {
|
|
33
|
+
padding: 0px 2px;
|
|
34
|
+
}
|
|
35
|
+
|
|
31
36
|
.sdoc-editor-container .article .sdoc-checkbox-container .sdoc-checkbox-input-wrapper {
|
|
32
|
-
|
|
37
|
+
display: flex;
|
|
38
|
+
align-items: baseline;
|
|
33
39
|
}
|
|
34
40
|
|
|
35
|
-
.sdoc-editor-container .article .sdoc-checkbox-container .sdoc-checkbox-input-wrapper
|
|
41
|
+
.sdoc-editor-container .article .sdoc-checkbox-container .sdoc-checkbox-input-wrapper .sdoc-checkbox-input {
|
|
36
42
|
vertical-align: middle;
|
|
43
|
+
margin-right: 5px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.sdoc-editor-container .article .sdoc-checkbox-container .sdoc-checkbox-input-wrapper .sdoc-checkbox-content-container {
|
|
47
|
+
word-break:normal;
|
|
48
|
+
width: calc(100% - 1em);
|
|
37
49
|
}
|
|
38
50
|
|
|
39
51
|
/* image */
|
|
@@ -103,7 +115,7 @@
|
|
|
103
115
|
border-radius: 3px;
|
|
104
116
|
border: 1px solid rgba(0, 40, 100, 0.12);
|
|
105
117
|
background-color: #fff;
|
|
106
|
-
user-select: none!important;
|
|
118
|
+
user-select: none !important;
|
|
107
119
|
z-index: 1000;
|
|
108
120
|
}
|
|
109
121
|
|
|
@@ -130,6 +142,10 @@
|
|
|
130
142
|
}
|
|
131
143
|
|
|
132
144
|
/* caret */
|
|
145
|
+
.sdoc-editor-container .article .caret-item .caret-name::before {
|
|
146
|
+
content: attr(name);
|
|
147
|
+
}
|
|
148
|
+
|
|
133
149
|
.sdoc-editor-container .article .caret-item .caret-name {
|
|
134
150
|
display: none;
|
|
135
151
|
}
|
|
@@ -146,4 +162,3 @@
|
|
|
146
162
|
.sdoc-editor-container .article .virtual-link:hover {
|
|
147
163
|
text-decoration: underline;
|
|
148
164
|
}
|
|
149
|
-
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { Node, Range, Transforms } from '@seafile/slate';
|
|
1
|
+
import { Editor, Node, Range, Transforms } from '@seafile/slate';
|
|
2
|
+
import isHotkey from 'is-hotkey';
|
|
2
3
|
import { CHECK_LIST_ITEM, PARAGRAPH } from '../../constants';
|
|
3
|
-
import { generateDefaultText, getSelectedNodeByType } from '../../core';
|
|
4
|
+
import { focusEditor, generateDefaultText, getSelectedNodeByType } from '../../core';
|
|
4
5
|
const withCheckList = editor => {
|
|
5
6
|
const {
|
|
6
7
|
insertBreak,
|
|
7
|
-
deleteBackward
|
|
8
|
+
deleteBackward,
|
|
9
|
+
onHotKeyDown
|
|
8
10
|
} = editor;
|
|
9
11
|
const newEditor = editor;
|
|
10
12
|
newEditor.insertBreak = () => {
|
|
@@ -61,6 +63,33 @@ const withCheckList = editor => {
|
|
|
61
63
|
}
|
|
62
64
|
deleteBackward(unit);
|
|
63
65
|
};
|
|
66
|
+
newEditor.onHotKeyDown = event => {
|
|
67
|
+
const selectedTodo = getSelectedNodeByType(editor, CHECK_LIST_ITEM);
|
|
68
|
+
if (selectedTodo) {
|
|
69
|
+
if (isHotkey('shift+enter', event)) {
|
|
70
|
+
event.preventDefault();
|
|
71
|
+
const {
|
|
72
|
+
selection
|
|
73
|
+
} = newEditor;
|
|
74
|
+
const insertPoint = Editor.start(editor, selection);
|
|
75
|
+
Transforms.insertText(editor, '\n', {
|
|
76
|
+
at: insertPoint
|
|
77
|
+
});
|
|
78
|
+
focusEditor(editor, {
|
|
79
|
+
anchor: {
|
|
80
|
+
path: insertPoint.path,
|
|
81
|
+
offset: insertPoint.offset + 1
|
|
82
|
+
},
|
|
83
|
+
focus: {
|
|
84
|
+
path: insertPoint.path,
|
|
85
|
+
offset: insertPoint.offset + 1
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
return onHotKeyDown && onHotKeyDown(event);
|
|
92
|
+
};
|
|
64
93
|
return newEditor;
|
|
65
94
|
};
|
|
66
95
|
export default withCheckList;
|
|
@@ -38,14 +38,16 @@ class CheckListItem extends React.PureComponent {
|
|
|
38
38
|
}, attributes, {
|
|
39
39
|
className: "sdoc-checkbox-container ".concat(attributes.className),
|
|
40
40
|
style: style
|
|
41
|
-
}), /*#__PURE__*/React.createElement("
|
|
42
|
-
className: "sdoc-checkbox-input-wrapper"
|
|
43
|
-
contentEditable: false
|
|
41
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
42
|
+
className: "sdoc-checkbox-input-wrapper"
|
|
44
43
|
}, /*#__PURE__*/React.createElement("input", {
|
|
44
|
+
className: "sdoc-checkbox-input",
|
|
45
45
|
type: "checkbox",
|
|
46
46
|
onChange: this.onChange,
|
|
47
47
|
checked: checked
|
|
48
|
-
})
|
|
48
|
+
}), /*#__PURE__*/React.createElement("p", {
|
|
49
|
+
className: "sdoc-checkbox-content-container"
|
|
50
|
+
}, children)));
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
53
|
export const renderCheckListItem = (props, editor) => {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { Transforms, Path, Editor, Element } from '@seafile/slate';
|
|
2
2
|
import toaster from '../../../../components/toast';
|
|
3
3
|
import context from '../../../../context';
|
|
4
|
+
import EventBus from '../../../utils/event-bus';
|
|
4
5
|
import { insertImage, hasSdocImages, getImageData, queryCopyMoveProgressView, resetCursor, isSingleImage } from './helpers';
|
|
5
6
|
import { focusEditor } from '../../core';
|
|
6
7
|
import { getErrorMsg } from '../../../../utils';
|
|
7
8
|
import { getSlateFragmentAttribute } from '../../../utils/document-utils';
|
|
8
9
|
import { INSERT_POSITION, CLIPBOARD_FORMAT_KEY, CLIPBOARD_ORIGIN_SDOC_KEY, IMAGE } from '../../constants';
|
|
10
|
+
import { INTERNAL_EVENT } from '../../../constants';
|
|
9
11
|
const withImage = editor => {
|
|
10
12
|
const {
|
|
11
13
|
isInline,
|
|
@@ -47,7 +49,16 @@ const withImage = editor => {
|
|
|
47
49
|
const imageData = getImageData(fragmentData);
|
|
48
50
|
context.copyImage(originSdocUuid, imageData).then(res => {
|
|
49
51
|
if (res.status === 200) {
|
|
50
|
-
|
|
52
|
+
// Task_id is an empty character and is copied from the same database.
|
|
53
|
+
if (res.data.task_id.length === 0) {
|
|
54
|
+
// Reload image
|
|
55
|
+
setTimeout(() => {
|
|
56
|
+
const eventBus = EventBus.getInstance();
|
|
57
|
+
eventBus.dispatch(INTERNAL_EVENT.RELOAD_IMAGE);
|
|
58
|
+
}, 300);
|
|
59
|
+
} else {
|
|
60
|
+
queryCopyMoveProgressView(res.data.task_id);
|
|
61
|
+
}
|
|
51
62
|
}
|
|
52
63
|
}).catch(error => {
|
|
53
64
|
const errorMessage = getErrorMsg(error);
|
|
@@ -166,7 +166,7 @@ const Image = _ref => {
|
|
|
166
166
|
setIsShowImageHoverMenu(true);
|
|
167
167
|
}, [setPosition]);
|
|
168
168
|
const reloadImage = useCallback(() => {
|
|
169
|
-
if (imageRef) {
|
|
169
|
+
if (imageRef.current) {
|
|
170
170
|
imageRef.current['src'] = getImageURL(data.src);
|
|
171
171
|
}
|
|
172
172
|
}, [data.src]);
|
|
@@ -387,7 +387,7 @@ export const insertTableElement = function (editor, type) {
|
|
|
387
387
|
at: targetPath
|
|
388
388
|
});
|
|
389
389
|
// handle combined cells
|
|
390
|
-
if (!(rowIndex
|
|
390
|
+
if (!(rowIndex === 0 && position === TABLE_ELEMENT_POSITION.BEFORE)) {
|
|
391
391
|
const targetRowIndex = position === TABLE_ELEMENT_POSITION.AFTER ? rowIndex : rowIndex - 1;
|
|
392
392
|
const currentTable = getSelectedNodeByType(editor, ELEMENT_TYPE.TABLE);
|
|
393
393
|
handleCombinedCellsAfterInsertTableRow(editor, tablePath, currentTable, targetRowIndex);
|
|
@@ -412,7 +412,7 @@ export const insertTableElement = function (editor, type) {
|
|
|
412
412
|
});
|
|
413
413
|
}
|
|
414
414
|
// handle combined cells
|
|
415
|
-
if (!(cellIndex
|
|
415
|
+
if (!(cellIndex === 0 && position === TABLE_ELEMENT_POSITION.BEFORE)) {
|
|
416
416
|
const targetColumnIndex = position === TABLE_ELEMENT_POSITION.AFTER ? cellIndex : cellIndex - 1;
|
|
417
417
|
const currentTable = getSelectedNodeByType(editor, ELEMENT_TYPE.TABLE);
|
|
418
418
|
handleCombinedCellsAfterInsertTableColumn(editor, tablePath, currentTable, targetColumnIndex);
|
|
@@ -454,7 +454,7 @@ export const combineCells = editor => {
|
|
|
454
454
|
newCell.children = newCellContent;
|
|
455
455
|
newCell.rowspan = maxRowIndex - minRowIndex + 1;
|
|
456
456
|
newCell.colspan = maxColIndex - minColIndex + 1;
|
|
457
|
-
// keep row.
|
|
457
|
+
// keep row.children.length not changed
|
|
458
458
|
Transforms.removeNodes(editor, {
|
|
459
459
|
at: targetCellPath
|
|
460
460
|
});
|
|
@@ -468,7 +468,7 @@ export const combineCells = editor => {
|
|
|
468
468
|
eventBus.dispatch(INTERNAL_EVENT.CANCEL_TABLE_SELECT_RANGE);
|
|
469
469
|
};
|
|
470
470
|
export const splitCell = (editor, rowNumber, columnNumber) => {
|
|
471
|
-
if (rowNumber
|
|
471
|
+
if (rowNumber === 1 && columnNumber === 1) {
|
|
472
472
|
return;
|
|
473
473
|
}
|
|
474
474
|
const {
|
|
@@ -505,7 +505,7 @@ export const splitCell = (editor, rowNumber, columnNumber) => {
|
|
|
505
505
|
const newRowIndex = rowIndex + rowspanSum;
|
|
506
506
|
const newCellIndex = cellIndex + colspanSum;
|
|
507
507
|
const targetCellPath = [...tablePath, newRowIndex, newCellIndex];
|
|
508
|
-
if (i
|
|
508
|
+
if (i === 0 && j === 0) {
|
|
509
509
|
firstNewCell = newCell;
|
|
510
510
|
} else {
|
|
511
511
|
Transforms.removeNodes(editor, {
|
|
@@ -43,9 +43,10 @@ const Caret = _ref => {
|
|
|
43
43
|
position: 'relative'
|
|
44
44
|
}
|
|
45
45
|
}, /*#__PURE__*/React.createElement("span", {
|
|
46
|
+
name: name,
|
|
46
47
|
className: "caret-name",
|
|
47
48
|
contentEditable: false,
|
|
48
49
|
style: cursorStyles
|
|
49
|
-
}
|
|
50
|
+
}))));
|
|
50
51
|
};
|
|
51
52
|
export default Caret;
|