@seafile/sdoc-editor 2.0.7 → 2.0.9
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/dropdown-menu.css +14 -1
- package/dist/basic-sdk/extension/constants/index.js +2 -6
- package/dist/basic-sdk/extension/constants/menus-config.js +15 -0
- package/dist/basic-sdk/extension/plugins/multi-column/constants/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/multi-column/helper.js +24 -7
- package/dist/basic-sdk/extension/plugins/multi-column/render/index.css +1 -3
- package/dist/basic-sdk/extension/plugins/multi-column/render/index.js +7 -2
- package/dist/basic-sdk/extension/plugins/multi-column/resize-handlers/index.js +2 -2
- package/dist/basic-sdk/extension/plugins/seatable-tables/menu/seatable-list.js +35 -2
- package/dist/basic-sdk/extension/plugins/seatable-tables/op-menu/index.css +19 -4
- package/dist/basic-sdk/extension/plugins/seatable-tables/op-menu/index.js +39 -9
- package/dist/basic-sdk/extension/plugins/seatable-tables/render-element/seatable-table.js +2 -1
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/hide-column-setter/hide-column-popover.js +2 -4
- package/dist/basic-sdk/extension/plugins/table/helpers.js +1 -0
- package/dist/basic-sdk/extension/toolbar/insert-element-toolbar/index.js +7 -0
- package/dist/basic-sdk/extension/toolbar/side-toolbar/helpers.js +51 -1
- package/dist/basic-sdk/extension/toolbar/side-toolbar/index.js +116 -20
- package/dist/basic-sdk/utils/full-width-mode.js +1 -1
- package/package.json +2 -2
|
@@ -8,10 +8,23 @@
|
|
|
8
8
|
background-color: #ffff;
|
|
9
9
|
max-height: 300px;
|
|
10
10
|
max-width: 200px;
|
|
11
|
-
overflow: auto;
|
|
12
11
|
padding: 8px 0px;
|
|
13
12
|
}
|
|
14
13
|
|
|
14
|
+
.sdoc-dropdown-menu .sdoc-seatable-selected-table-list-wrapper .sdoc-seatable-list-search-wrapper {
|
|
15
|
+
padding: 12px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.sdoc-dropdown-menu .sdoc-seatable-selected-table-list-wrapper .sdoc-seatable-list-search-wrapper>input {
|
|
19
|
+
font-size: 12px;
|
|
20
|
+
max-height: 30px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.sdoc-dropdown-menu .sdoc-seatable-selected-table-list-wrapper .sdoc-seatable-list-wrapper {
|
|
24
|
+
max-height: 230px;
|
|
25
|
+
overflow-y: auto;
|
|
26
|
+
}
|
|
27
|
+
|
|
15
28
|
.sdoc-dropdown-menu .sdoc-dropdown-menu-divider {
|
|
16
29
|
width: 100%;
|
|
17
30
|
height: 0;
|
|
@@ -128,12 +128,6 @@ Object.defineProperty(exports, "FILE_LINK_INSET_INPUT_TEMP", {
|
|
|
128
128
|
}
|
|
129
129
|
});
|
|
130
130
|
exports.FILE_TYPE = void 0;
|
|
131
|
-
Object.defineProperty(exports, "FIVE_COLUMN", {
|
|
132
|
-
enumerable: true,
|
|
133
|
-
get: function () {
|
|
134
|
-
return _elementType.FIVE_COLUMN;
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
131
|
Object.defineProperty(exports, "FONT", {
|
|
138
132
|
enumerable: true,
|
|
139
133
|
get: function () {
|
|
@@ -276,6 +270,7 @@ Object.defineProperty(exports, "MULTI_COLUMN", {
|
|
|
276
270
|
return _elementType.MULTI_COLUMN;
|
|
277
271
|
}
|
|
278
272
|
});
|
|
273
|
+
exports.MULTI_COLUMN_TYPE = void 0;
|
|
279
274
|
Object.defineProperty(exports, "ORDERED_LIST", {
|
|
280
275
|
enumerable: true,
|
|
281
276
|
get: function () {
|
|
@@ -532,6 +527,7 @@ const INSERT_POSITION = exports.INSERT_POSITION = {
|
|
|
532
527
|
};
|
|
533
528
|
const LOCAL_IMAGE = exports.LOCAL_IMAGE = 'local-image';
|
|
534
529
|
const LOCAL_VIDEO = exports.LOCAL_VIDEO = 'local-video';
|
|
530
|
+
const MULTI_COLUMN_TYPE = exports.MULTI_COLUMN_TYPE = [_elementType.TWO_COLUMN, _elementType.THREE_COLUMN, _elementType.FOUR_COLUMN];
|
|
535
531
|
const LIST_TYPE_ARRAY = exports.LIST_TYPE_ARRAY = [_elementType.UNORDERED_LIST, _elementType.ORDERED_LIST];
|
|
536
532
|
const LIST_ITEM_CORRELATION_TYPE = exports.LIST_ITEM_CORRELATION_TYPE = [_elementType.UNORDERED_LIST, _elementType.ORDERED_LIST, _elementType.LIST_ITEM];
|
|
537
533
|
const LIST_ITEM_SUPPORTED_TRANSFORMATION = exports.LIST_ITEM_SUPPORTED_TRANSFORMATION = [_elementType.UNORDERED_LIST, _elementType.ORDERED_LIST, 'left', 'center', 'right', _elementType.BLOCKQUOTE];
|
|
@@ -297,6 +297,21 @@ const SIDE_TRANSFORM_MENUS_CONFIG = exports.SIDE_TRANSFORM_MENUS_CONFIG = [{
|
|
|
297
297
|
iconClass: 'sdocfont sdoc-callout',
|
|
298
298
|
type: _elementType.CALL_OUT,
|
|
299
299
|
text: 'Callout'
|
|
300
|
+
}, {
|
|
301
|
+
id: _elementType.TWO_COLUMN,
|
|
302
|
+
iconClass: 'sdocfont sdoc-multi-column',
|
|
303
|
+
type: _elementType.TWO_COLUMN,
|
|
304
|
+
text: 'Two_column'
|
|
305
|
+
}, {
|
|
306
|
+
id: _elementType.THREE_COLUMN,
|
|
307
|
+
iconClass: 'sdocfont sdoc-multi-column',
|
|
308
|
+
type: _elementType.THREE_COLUMN,
|
|
309
|
+
text: 'Three_column'
|
|
310
|
+
}, {
|
|
311
|
+
id: _elementType.FOUR_COLUMN,
|
|
312
|
+
iconClass: 'sdocfont sdoc-multi-column',
|
|
313
|
+
type: _elementType.FOUR_COLUMN,
|
|
314
|
+
text: 'Four_column'
|
|
300
315
|
}];
|
|
301
316
|
const SIDE_TRANSFORM_MENUS_SEARCH_MAP = exports.SIDE_TRANSFORM_MENUS_SEARCH_MAP = {
|
|
302
317
|
[_elementType.PARAGRAPH]: 'Paragraph',
|
|
@@ -11,6 +11,9 @@ var _slateReact = require("@seafile/slate-react");
|
|
|
11
11
|
var _constants = require("../../constants");
|
|
12
12
|
var _constants2 = require("./constants");
|
|
13
13
|
var _core = require("../../core");
|
|
14
|
+
var _localStorageUtils = _interopRequireDefault(require("../../../../utils/local-storage-utils"));
|
|
15
|
+
var _constants3 = require("../../../constants");
|
|
16
|
+
var _fullWidthMode = require("../../../utils/full-width-mode");
|
|
14
17
|
const insertMultiColumn = function (editor, selection) {
|
|
15
18
|
let position = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _constants.INSERT_POSITION.CURRENT;
|
|
16
19
|
let type = arguments.length > 3 ? arguments[3] : undefined;
|
|
@@ -40,7 +43,7 @@ const generateEmptyMultiColumn = (editor, MultiColumnType) => {
|
|
|
40
43
|
default:
|
|
41
44
|
break;
|
|
42
45
|
}
|
|
43
|
-
const currentPageWidth = getCurrentPageWidth();
|
|
46
|
+
const currentPageWidth = getCurrentPageWidth(editor);
|
|
44
47
|
const initialColumnWidth = Math.max(_constants2.COLUMN_MIN_WIDTH, parseInt(currentPageWidth / multiColumnNumber));
|
|
45
48
|
for (let i = 0; i < multiColumnNumber; i++) {
|
|
46
49
|
const columnWidthKey = _slugid.default.nice();
|
|
@@ -139,12 +142,13 @@ const handleInsertMultiColumn = (editor, insertPosition, path, multiColumnNode)
|
|
|
139
142
|
_slateReact.ReactEditor.focus(editor);
|
|
140
143
|
};
|
|
141
144
|
exports.handleInsertMultiColumn = handleInsertMultiColumn;
|
|
142
|
-
const updateColumnWidthOnDeletion = (editor, selection, column, deletionDirection)
|
|
143
|
-
|
|
145
|
+
const updateColumnWidthOnDeletion = function (editor, selection, column, deletionDirection) {
|
|
146
|
+
let isDragged = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
147
|
+
const multiColumnPath = !isDragged ? [selection.anchor.path[0]] : [selection[0]];
|
|
144
148
|
const newMultiColumnNode = _slate.Node.get(editor, multiColumnPath);
|
|
145
|
-
const targetColumnIndex = selection.anchor.path[1] + (deletionDirection === 'deleteForward' ? 1 : 0);
|
|
149
|
+
const targetColumnIndex = !isDragged ? selection.anchor.path[1] + (deletionDirection === 'deleteForward' ? 1 : 0) : selection[1] + (deletionDirection === 'deleteForward' ? 1 : 0);
|
|
146
150
|
const remainingColumn = column.filter((_, index) => index !== targetColumnIndex);
|
|
147
|
-
const currentPageWidth = getCurrentPageWidth();
|
|
151
|
+
const currentPageWidth = getCurrentPageWidth(editor);
|
|
148
152
|
const columnWidth = Math.max(_constants2.COLUMN_MIN_WIDTH, parseInt(currentPageWidth / remainingColumn.length));
|
|
149
153
|
|
|
150
154
|
// Recalculate width of every left column
|
|
@@ -156,9 +160,22 @@ const updateColumnWidthOnDeletion = (editor, selection, column, deletionDirectio
|
|
|
156
160
|
updateColumnWidth(editor, newMultiColumnNode, newColumn, multiColumnPath);
|
|
157
161
|
};
|
|
158
162
|
exports.updateColumnWidthOnDeletion = updateColumnWidthOnDeletion;
|
|
159
|
-
const getCurrentPageWidth =
|
|
163
|
+
const getCurrentPageWidth = editor => {
|
|
160
164
|
const sdocEditorPage = document.getElementById('sdoc-editor');
|
|
161
|
-
|
|
165
|
+
let pageWidth;
|
|
166
|
+
pageWidth = sdocEditorPage === null || sdocEditorPage === void 0 ? void 0 : sdocEditorPage.getBoundingClientRect().width;
|
|
167
|
+
|
|
168
|
+
// Get pageWidth if on is_full_width mode
|
|
169
|
+
if (_localStorageUtils.default.getItem(_constants3.FULL_WIDTH_MODE)) {
|
|
170
|
+
var _getStyleByFullWidthM;
|
|
171
|
+
const sdocEditorPageContent = document.getElementsByClassName('sdoc-editor-page-content')[0];
|
|
172
|
+
const pageContentWidth = sdocEditorPageContent === null || sdocEditorPageContent === void 0 ? void 0 : sdocEditorPageContent.getBoundingClientRect().width;
|
|
173
|
+
const pageWidthString = (_getStyleByFullWidthM = (0, _fullWidthMode.getStyleByFullWidthMode)(undefined, editor)) === null || _getStyleByFullWidthM === void 0 ? void 0 : _getStyleByFullWidthM.width;
|
|
174
|
+
const numbers = pageWidthString.match(/\d+/g).map(Number);
|
|
175
|
+
|
|
176
|
+
// 120 is padding and 2 is border width of 'sdoc-editor' dom;
|
|
177
|
+
pageWidth = pageContentWidth - numbers.slice(1).reduce((sum, num) => sum + num, 0) - 120 - 2;
|
|
178
|
+
}
|
|
162
179
|
return pageWidth;
|
|
163
180
|
};
|
|
164
181
|
exports.getCurrentPageWidth = getCurrentPageWidth;
|
|
@@ -16,16 +16,14 @@
|
|
|
16
16
|
.sdoc-multicolumn-wrapper .column {
|
|
17
17
|
display: flex;
|
|
18
18
|
left: 3px;
|
|
19
|
-
line-height: 1.5;
|
|
20
19
|
align-items: flex-start;
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
.sdoc-column-container {
|
|
24
|
-
width: calc(100% -
|
|
23
|
+
width: calc(100% - 50px);
|
|
25
24
|
max-width: 100%;
|
|
26
25
|
position: relative;
|
|
27
26
|
padding: 5px 5px 5px 0px;
|
|
28
|
-
margin-left: 15px;
|
|
29
27
|
box-sizing: border-box;
|
|
30
28
|
word-wrap: break-word;
|
|
31
29
|
white-space: pre-wrap;
|
|
@@ -26,10 +26,15 @@ const MultiColumn = _ref => {
|
|
|
26
26
|
...element.style
|
|
27
27
|
} : {});
|
|
28
28
|
const multiColumnContainerClassName = (0, _classnames.default)('sdoc-multicolumn-container', className);
|
|
29
|
-
const [pageWidth, setPageWidth] = (0, _react.useState)((0, _helper.getCurrentPageWidth)());
|
|
29
|
+
const [pageWidth, setPageWidth] = (0, _react.useState)((0, _helper.getCurrentPageWidth)(editor));
|
|
30
30
|
const handleResizeColumn = newColumn => {
|
|
31
31
|
(0, _helper.updateColumnWidth)(editor, element, newColumn);
|
|
32
32
|
};
|
|
33
|
+
(0, _react.useEffect)(() => {
|
|
34
|
+
setPageWidth((0, _helper.getCurrentPageWidth)(editor));
|
|
35
|
+
}
|
|
36
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
37
|
+
, []);
|
|
33
38
|
(0, _react.useEffect)(() => {
|
|
34
39
|
const sdocEditorPage = document.getElementById('sdoc-editor');
|
|
35
40
|
if (!sdocEditorPage) return;
|
|
@@ -37,7 +42,7 @@ const MultiColumn = _ref => {
|
|
|
37
42
|
var _entries$;
|
|
38
43
|
const newPageWidth = (_entries$ = entries[0]) === null || _entries$ === void 0 ? void 0 : _entries$.contentRect.width;
|
|
39
44
|
// Check if sdocPageWidth changes
|
|
40
|
-
if (newPageWidth !== pageWidth) {
|
|
45
|
+
if (pageWidth && newPageWidth !== pageWidth) {
|
|
41
46
|
const scaleFactor = newPageWidth / pageWidth;
|
|
42
47
|
const updatedColumns = element.column.map(item => ({
|
|
43
48
|
...item,
|
|
@@ -129,14 +129,14 @@ const ResizeHandlers = _ref => {
|
|
|
129
129
|
}, index === 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
130
130
|
className: "column-width-just",
|
|
131
131
|
style: {
|
|
132
|
-
left: '
|
|
132
|
+
left: '-15px'
|
|
133
133
|
}
|
|
134
134
|
}), /*#__PURE__*/_react.default.createElement(_columnResizeHandler.default, {
|
|
135
135
|
key: index,
|
|
136
136
|
index: index,
|
|
137
137
|
handleMouseDown: handleMouseDown,
|
|
138
138
|
style: {
|
|
139
|
-
left: `${left}px`
|
|
139
|
+
left: `${left - 15}px`
|
|
140
140
|
},
|
|
141
141
|
adjustingCell: adjustingCell,
|
|
142
142
|
isDraggingResizeHandler: isDraggingResizeHandler,
|
|
@@ -6,15 +6,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _reactstrap = require("reactstrap");
|
|
10
|
+
var _reactI18next = require("react-i18next");
|
|
9
11
|
var _utils = require("../../../utils");
|
|
10
12
|
const SeaTableList = _ref => {
|
|
11
13
|
let {
|
|
12
14
|
editor,
|
|
13
15
|
onViewClick
|
|
14
16
|
} = _ref;
|
|
17
|
+
const {
|
|
18
|
+
t
|
|
19
|
+
} = (0, _reactI18next.useTranslation)('sdoc-editor');
|
|
15
20
|
const seatableRef = (0, _react.useRef)(null);
|
|
21
|
+
const isComposingRef = (0, _react.useRef)(null);
|
|
16
22
|
const [computedStyle, setComputedStyle] = (0, _react.useState)({});
|
|
17
|
-
const tables = editor.tables;
|
|
23
|
+
const [tables, setTables] = (0, _react.useState)(editor.tables || []);
|
|
18
24
|
(0, _react.useEffect)(() => {
|
|
19
25
|
if (seatableRef.current) {
|
|
20
26
|
// bottom overflow
|
|
@@ -29,16 +35,43 @@ const SeaTableList = _ref => {
|
|
|
29
35
|
});
|
|
30
36
|
}
|
|
31
37
|
}, []);
|
|
38
|
+
const onChange = (0, _react.useCallback)(event => {
|
|
39
|
+
if (isComposingRef.current) return;
|
|
40
|
+
const value = event.target.value.trim().toUpperCase();
|
|
41
|
+
if (value) {
|
|
42
|
+
const list = editor.tables.filter(item => item.name.toUpperCase().includes(value));
|
|
43
|
+
setTables(list);
|
|
44
|
+
} else {
|
|
45
|
+
setTables(editor.tables);
|
|
46
|
+
}
|
|
47
|
+
}, [editor.tables]);
|
|
48
|
+
const onCompositionStart = (0, _react.useCallback)(() => {
|
|
49
|
+
isComposingRef.current = true;
|
|
50
|
+
}, []);
|
|
51
|
+
const onCompositionEnd = (0, _react.useCallback)(e => {
|
|
52
|
+
isComposingRef.current = false;
|
|
53
|
+
onChange(e);
|
|
54
|
+
}, [onChange]);
|
|
32
55
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
33
56
|
ref: seatableRef,
|
|
34
57
|
className: "sdoc-dropdown-menu-container sdoc-seatable-selected-table-list-wrapper",
|
|
35
58
|
style: computedStyle
|
|
59
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
60
|
+
className: "sdoc-seatable-list-search-wrapper"
|
|
61
|
+
}, /*#__PURE__*/_react.default.createElement(_reactstrap.Input, {
|
|
62
|
+
placeholder: t('Search_action'),
|
|
63
|
+
onChange: onChange,
|
|
64
|
+
autoFocus: true,
|
|
65
|
+
onCompositionStart: onCompositionStart,
|
|
66
|
+
onCompositionEnd: onCompositionEnd
|
|
67
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
68
|
+
className: "sdoc-seatable-list-wrapper"
|
|
36
69
|
}, tables.map(item => {
|
|
37
70
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
38
71
|
key: item._id,
|
|
39
72
|
className: "sdoc-dropdown-menu-item text-truncate d-block",
|
|
40
73
|
onClick: () => onViewClick(item)
|
|
41
74
|
}, item.name);
|
|
42
|
-
}));
|
|
75
|
+
})));
|
|
43
76
|
};
|
|
44
77
|
var _default = exports.default = SeaTableList;
|
|
@@ -113,22 +113,34 @@
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
.sdoc-seatable-hover-menu-container .hover-menu-container .sdoc-seatable-setting-popover .tables-list-empty {
|
|
116
|
-
padding:
|
|
116
|
+
padding: 0px 16px;
|
|
117
117
|
width: 100%;
|
|
118
118
|
font-size: 13px;
|
|
119
|
-
text-align: center;
|
|
120
119
|
line-height: 30px;
|
|
121
120
|
vertical-align: middle;
|
|
122
121
|
}
|
|
123
122
|
|
|
124
123
|
.sdoc-seatable-hover-menu-container .hover-menu-container .sdoc-seatable-setting-popover .seatable-setting-container {
|
|
125
124
|
list-style: none;
|
|
126
|
-
overflow-y: auto;
|
|
127
125
|
max-height: 280px;
|
|
128
126
|
min-height: 80px;
|
|
129
127
|
padding: 8px 0px;
|
|
130
128
|
}
|
|
131
129
|
|
|
130
|
+
.sdoc-seatable-hover-menu-container .hover-menu-container .sdoc-seatable-setting-popover .seatable-setting-container .seatable-setting-input-wrapper {
|
|
131
|
+
padding: 0px 10px 8px 10px;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.sdoc-seatable-hover-menu-container .hover-menu-container .sdoc-seatable-setting-popover .seatable-setting-container .seatable-setting-input-wrapper input {
|
|
135
|
+
max-height: 28px;
|
|
136
|
+
font-size: 14px;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.sdoc-seatable-hover-menu-container .hover-menu-container .sdoc-seatable-setting-popover .seatable-setting-container .seatable-setting-list-wrapper {
|
|
140
|
+
max-height: 228px;
|
|
141
|
+
overflow-y: auto;
|
|
142
|
+
}
|
|
143
|
+
|
|
132
144
|
.sdoc-seatable-hover-menu-container .hover-menu-container .sdoc-seatable-setting-popover .seatable-setting-container .seatable-setting-item {
|
|
133
145
|
position: relative;
|
|
134
146
|
white-space: nowrap;
|
|
@@ -191,6 +203,9 @@
|
|
|
191
203
|
left: 158px !important;
|
|
192
204
|
transform: unset !important;
|
|
193
205
|
max-height: 350px;
|
|
194
|
-
overflow: auto;
|
|
195
206
|
margin-top: 0px !important;
|
|
196
207
|
}
|
|
208
|
+
|
|
209
|
+
.sdoc-seatable-setting-hide-column-popover-wrapper .field-settings .field-settings-body {
|
|
210
|
+
max-height: 278px;
|
|
211
|
+
}
|
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.default = OpMenu;
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _reactI18next = require("react-i18next");
|
|
11
|
+
var _reactstrap = require("reactstrap");
|
|
11
12
|
var _commons = require("../../../commons");
|
|
12
13
|
var _tooltip = _interopRequireDefault(require("../../../../../components/tooltip"));
|
|
13
14
|
var _customSwitch = _interopRequireDefault(require("../seatable-settings/custom-switch"));
|
|
@@ -22,18 +23,26 @@ const TablesList = _ref => {
|
|
|
22
23
|
let {
|
|
23
24
|
tablesData,
|
|
24
25
|
onSelectTable,
|
|
25
|
-
selectedTableText
|
|
26
|
+
selectedTableText,
|
|
27
|
+
onChange,
|
|
28
|
+
onCompositionStart,
|
|
29
|
+
onCompositionEnd
|
|
26
30
|
} = _ref;
|
|
27
31
|
const {
|
|
28
32
|
t
|
|
29
33
|
} = (0, _reactI18next.useTranslation)('sdoc-editor');
|
|
30
|
-
if (!tablesData.length) {
|
|
31
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
32
|
-
className: "tables-list-empty"
|
|
33
|
-
}, /*#__PURE__*/_react.default.createElement("span", null, t('Search_not_found')));
|
|
34
|
-
}
|
|
35
34
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
36
35
|
className: "seatable-setting-container"
|
|
36
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
37
|
+
className: "seatable-setting-input-wrapper"
|
|
38
|
+
}, /*#__PURE__*/_react.default.createElement(_reactstrap.Input, {
|
|
39
|
+
autoFocus: true,
|
|
40
|
+
placeholder: t('Search_action'),
|
|
41
|
+
onChange: onChange,
|
|
42
|
+
onCompositionStart: onCompositionStart,
|
|
43
|
+
onCompositionEnd: onCompositionEnd
|
|
44
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
45
|
+
className: "seatable-setting-list-wrapper"
|
|
37
46
|
}, tablesData.map(item => {
|
|
38
47
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
39
48
|
className: `seatable-setting-item ${selectedTableText === item.name ? 'active' : ''}`,
|
|
@@ -49,7 +58,9 @@ const TablesList = _ref => {
|
|
|
49
58
|
}, /*#__PURE__*/_react.default.createElement("i", {
|
|
50
59
|
className: "sdocfont sdoc-check-mark icon-font"
|
|
51
60
|
})));
|
|
52
|
-
})
|
|
61
|
+
}), !tablesData.length && /*#__PURE__*/_react.default.createElement("div", {
|
|
62
|
+
className: "tables-list-empty"
|
|
63
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, t('Search_not_found')))));
|
|
53
64
|
};
|
|
54
65
|
const TablesSettings = _ref2 => {
|
|
55
66
|
let {
|
|
@@ -97,7 +108,8 @@ function OpMenu(_ref3) {
|
|
|
97
108
|
} = (0, _reactI18next.useTranslation)('sdoc-editor');
|
|
98
109
|
const scrollRef = (0, _useScrollContext.useScrollContext)();
|
|
99
110
|
const timer = (0, _react.useRef)(null);
|
|
100
|
-
const
|
|
111
|
+
const hoverMenuRef = (0, _react.useRef)(null);
|
|
112
|
+
const [tablesData, setTablesData] = (0, _react.useState)(editor.tables || []);
|
|
101
113
|
const [isShowTooltip, setIsShowTooltip] = (0, _react.useState)(false);
|
|
102
114
|
const [selectedTable, setSelectedTable] = (0, _react.useState)({});
|
|
103
115
|
const [selectedTableText, setSelectedTableText] = (0, _react.useState)('');
|
|
@@ -242,8 +254,23 @@ function OpMenu(_ref3) {
|
|
|
242
254
|
onCloseOther(['tableList', 'tableSort', 'tableColumnHidden', 'tableFilter']);
|
|
243
255
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
244
256
|
}, [isShowSeaTableSetting]);
|
|
257
|
+
const onChange = (0, _react.useCallback)(e => {
|
|
258
|
+
if (!hoverMenuRef.current.isInputtingChinese) {
|
|
259
|
+
const value = e.target.value.trim().toUpperCase();
|
|
260
|
+
const newTablesData = editor.tables.filter(item => item.name.toUpperCase().includes(value));
|
|
261
|
+
setTablesData(newTablesData);
|
|
262
|
+
}
|
|
263
|
+
}, [editor.tables]);
|
|
264
|
+
const onCompositionStart = (0, _react.useCallback)(() => {
|
|
265
|
+
hoverMenuRef.current.isInputtingChinese = true;
|
|
266
|
+
}, []);
|
|
267
|
+
const onCompositionEnd = (0, _react.useCallback)(e => {
|
|
268
|
+
hoverMenuRef.current.isInputtingChinese = false;
|
|
269
|
+
onChange(e);
|
|
270
|
+
}, [onChange]);
|
|
245
271
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_commons.ElementPopover, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
246
272
|
id: "sdoc-seatable-hover-menu-container",
|
|
273
|
+
ref: hoverMenuRef,
|
|
247
274
|
className: "sdoc-seatable-hover-menu-container",
|
|
248
275
|
style: menuPosition
|
|
249
276
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -317,7 +344,10 @@ function OpMenu(_ref3) {
|
|
|
317
344
|
}, /*#__PURE__*/_react.default.createElement(TablesList, {
|
|
318
345
|
tablesData: tablesData,
|
|
319
346
|
onSelectTable: onSelectTable,
|
|
320
|
-
selectedTableText: selectedTableText
|
|
347
|
+
selectedTableText: selectedTableText,
|
|
348
|
+
onChange: onChange,
|
|
349
|
+
onCompositionStart: onCompositionStart,
|
|
350
|
+
onCompositionEnd: onCompositionEnd
|
|
321
351
|
})), /*#__PURE__*/_react.default.createElement(_filterSetter.default, {
|
|
322
352
|
target: "sdoc_seatable_filter",
|
|
323
353
|
container: document.getElementById('sdoc-seatable-hover-menu-container'),
|
|
@@ -311,7 +311,8 @@ function SeaTableTable(_ref) {
|
|
|
311
311
|
}), isLoading && /*#__PURE__*/_react.default.createElement(_loading.default, null), !isLoading && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("table", {
|
|
312
312
|
className: (0, _classnames.default)('seatable-view-records', {
|
|
313
313
|
'no_alternate_color': !element.alternate_color
|
|
314
|
-
})
|
|
314
|
+
}),
|
|
315
|
+
contentEditable: false
|
|
315
316
|
}, /*#__PURE__*/_react.default.createElement("thead", null, /*#__PURE__*/_react.default.createElement(_recordHeader.default, {
|
|
316
317
|
editor: editor,
|
|
317
318
|
element: element,
|
|
@@ -171,6 +171,7 @@ class HideColumnPopover extends _react.default.Component {
|
|
|
171
171
|
}, /*#__PURE__*/_react.default.createElement("input", {
|
|
172
172
|
className: "form-control",
|
|
173
173
|
type: "text",
|
|
174
|
+
autoFocus: true,
|
|
174
175
|
placeholder: t('Search_column'),
|
|
175
176
|
value: this.state.searchVal,
|
|
176
177
|
onChange: this.onChangeSearch
|
|
@@ -179,10 +180,7 @@ class HideColumnPopover extends _react.default.Component {
|
|
|
179
180
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
180
181
|
className: "empty-hidden-columns-list"
|
|
181
182
|
}, t('No_columns_available_to_be_hidden'))), !isEmpty && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
182
|
-
className: "field-settings-body"
|
|
183
|
-
style: {
|
|
184
|
-
maxHeight: window.innerHeight - 400 + 'px'
|
|
185
|
-
}
|
|
183
|
+
className: "field-settings-body"
|
|
186
184
|
}, fieldSettings.map(setting => {
|
|
187
185
|
return /*#__PURE__*/_react.default.createElement(_hideColumnItem.default, {
|
|
188
186
|
key: setting.key,
|
|
@@ -42,6 +42,7 @@ const isTableMenuDisabled = (editor, readonly) => {
|
|
|
42
42
|
if (type === _constants.ELEMENT_TYPE.TABLE_CELL) return true;
|
|
43
43
|
if (type === _constants.ELEMENT_TYPE.TABLE_ROW) return true;
|
|
44
44
|
if (type === _constants.ELEMENT_TYPE.CALL_OUT) return true;
|
|
45
|
+
if (type === _constants.ELEMENT_TYPE.MULTI_COLUMN) return true;
|
|
45
46
|
if (_slate.Editor.isVoid(editor, n)) return true;
|
|
46
47
|
return false;
|
|
47
48
|
},
|
|
@@ -138,6 +138,12 @@ const QuickInsertBlockMenu = _ref => {
|
|
|
138
138
|
});
|
|
139
139
|
return !!callout;
|
|
140
140
|
}, [editor]);
|
|
141
|
+
const isDisableTable = (0, _react.useMemo)(() => {
|
|
142
|
+
const callout = (0, _core.getAboveBlockNode)(editor, {
|
|
143
|
+
match: n => [_constants.ELEMENT_TYPE.ORDERED_LIST, _constants.ELEMENT_TYPE.UNORDERED_LIST, _constants.ELEMENT_TYPE.CHECK_LIST_ITEM, _constants.ELEMENT_TYPE.MULTI_COLUMN].includes(n.type)
|
|
144
|
+
});
|
|
145
|
+
return !!callout;
|
|
146
|
+
}, [editor]);
|
|
141
147
|
const createMultiColumn = (0, _react.useCallback)(type => {
|
|
142
148
|
callback && callback();
|
|
143
149
|
const newInsertPosition = slateNode.type === _constants.ELEMENT_TYPE.LIST_ITEM ? _constants.INSERT_POSITION.AFTER : insertPosition;
|
|
@@ -168,6 +174,7 @@ const QuickInsertBlockMenu = _ref => {
|
|
|
168
174
|
// eslint-disable-next-line react/jsx-indent
|
|
169
175
|
_react.default.createElement(_dropdownMenuItem.default, {
|
|
170
176
|
isHidden: !quickInsertMenuSearchMap[_constants.TABLE],
|
|
177
|
+
disabled: isDisableTable,
|
|
171
178
|
key: "sdoc-insert-menu-table",
|
|
172
179
|
menuConfig: {
|
|
173
180
|
..._constants.SIDE_INSERT_MENUS_CONFIG[_constants.ELEMENT_TYPE.TABLE]
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.setSelection = exports.onWrapMultiListItemToNonListTypeTarget = exports.onWrapMultiListItem = exports.onWrapListItem = exports.onSetNodeType = exports.onDeleteNode = exports.onCopyNode = exports.normalizeCopyData = exports.isVoidNode = exports.isNotSupportTransform = exports.isMultiColumn = exports.isListItem = exports.isList = exports.isInMultiColumnNode = exports.isBlockquote = exports.insertEmptyListNodeAtTarget = exports.insertElement = exports.getTransformMenusConfig = exports.getTopValue = exports.getSearchedOperations = exports.getNodeEntry = exports.getListNode = exports.deleteNodesFromBack = exports.createDragPreviewContainer = void 0;
|
|
7
|
+
exports.setSelection = exports.onWrapMultiListItemToNonListTypeTarget = exports.onWrapMultiListItem = exports.onWrapListItemFromMultiColumn = exports.onWrapListItem = exports.onSetNodeType = exports.onDeleteNode = exports.onCopyNode = exports.normalizeCopyData = exports.isVoidNode = exports.isNotSupportTransform = exports.isMultiColumn = exports.isListItem = exports.isList = exports.isInMultiColumnNode = exports.isBlockquote = exports.insertEmptyListNodeAtTarget = exports.insertElement = exports.getTransformMenusConfig = exports.getTopValue = exports.getSearchedOperations = exports.getNodeEntry = exports.getListNodeFromMultiColumn = exports.getListNode = exports.deleteNodesFromBack = exports.createDragPreviewContainer = void 0;
|
|
8
8
|
var _slate = require("@seafile/slate");
|
|
9
9
|
var _slugid = _interopRequireDefault(require("slugid"));
|
|
10
10
|
var _slateReact = require("@seafile/slate-react");
|
|
@@ -20,6 +20,7 @@ var _helpers2 = require("../../plugins/check-list/helpers");
|
|
|
20
20
|
var _constants3 = require("../../../constants");
|
|
21
21
|
var _helpers3 = require("../../../node-id/helpers");
|
|
22
22
|
var _documentUtils = require("../../../utils/document-utils");
|
|
23
|
+
var _helper2 = require("../../plugins/multi-column/helper");
|
|
23
24
|
const onSetNodeType = (editor, element, type) => {
|
|
24
25
|
if (!type) return;
|
|
25
26
|
if (type === _constants.CALL_OUT) {
|
|
@@ -53,6 +54,32 @@ const onSetNodeType = (editor, element, type) => {
|
|
|
53
54
|
});
|
|
54
55
|
return;
|
|
55
56
|
}
|
|
57
|
+
|
|
58
|
+
// Transform to multi_column and put content into first column
|
|
59
|
+
if (_constants.MULTI_COLUMN_TYPE.includes(type)) {
|
|
60
|
+
const path = (0, _core.findPath)(editor, element);
|
|
61
|
+
const multiColumnNode = (0, _helper2.generateEmptyMultiColumn)(editor, type);
|
|
62
|
+
_slate.Transforms.insertNodes(editor, multiColumnNode, {
|
|
63
|
+
at: [path[0] + 1]
|
|
64
|
+
});
|
|
65
|
+
const nodeIndex = path[0];
|
|
66
|
+
const highestNode = editor.children[nodeIndex];
|
|
67
|
+
if (path.length > 1 && [_constants.BLOCKQUOTE, _constants.ORDERED_LIST, _constants.UNORDERED_LIST, _constants.CODE_BLOCK].includes(highestNode.type)) {
|
|
68
|
+
_slate.Transforms.moveNodes(editor, {
|
|
69
|
+
at: [path[0]],
|
|
70
|
+
to: [path[0] + 1, 0, 0]
|
|
71
|
+
});
|
|
72
|
+
} else {
|
|
73
|
+
_slate.Transforms.moveNodes(editor, {
|
|
74
|
+
at: path,
|
|
75
|
+
to: [path[0] + 1, 0, 0]
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
_slate.Transforms.removeNodes(editor, {
|
|
79
|
+
at: [path[0], 0, 1]
|
|
80
|
+
});
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
56
83
|
_slate.Transforms.setNodes(editor, {
|
|
57
84
|
type: type
|
|
58
85
|
});
|
|
@@ -220,6 +247,25 @@ const getListNode = (editor, path) => {
|
|
|
220
247
|
return listNode;
|
|
221
248
|
};
|
|
222
249
|
exports.getListNode = getListNode;
|
|
250
|
+
const getListNodeFromMultiColumn = (editor, path) => {
|
|
251
|
+
let listType = _slate.Editor.node(editor, path.slice(0, 3))[0].type;
|
|
252
|
+
const listItem = _slate.Editor.node(editor, path)[0];
|
|
253
|
+
const listNode = (0, _model.generateEmptyList)(listType);
|
|
254
|
+
listNode.children[0] = listItem;
|
|
255
|
+
return listNode;
|
|
256
|
+
};
|
|
257
|
+
exports.getListNodeFromMultiColumn = getListNodeFromMultiColumn;
|
|
258
|
+
const onWrapListItemFromMultiColumn = (editor, targetPath, sourcePath) => {
|
|
259
|
+
const nextPath = _slate.Path.next(targetPath);
|
|
260
|
+
const listNode = getListNodeFromMultiColumn(editor, sourcePath.slice(0, 4));
|
|
261
|
+
_slate.Transforms.removeNodes(editor, {
|
|
262
|
+
at: sourcePath.slice(0, 4)
|
|
263
|
+
});
|
|
264
|
+
_slate.Transforms.insertNodes(editor, listNode, {
|
|
265
|
+
at: nextPath
|
|
266
|
+
});
|
|
267
|
+
};
|
|
268
|
+
exports.onWrapListItemFromMultiColumn = onWrapListItemFromMultiColumn;
|
|
223
269
|
const onWrapListItem = (editor, targetPath, sourcePath) => {
|
|
224
270
|
const nextPath = _slate.Path.next(targetPath);
|
|
225
271
|
const listNode = getListNode(editor, sourcePath);
|
|
@@ -274,6 +320,10 @@ const getTransformMenusConfig = (editor, slateNode) => {
|
|
|
274
320
|
if (highestNode.type === _constants.BLOCKQUOTE) {
|
|
275
321
|
newSideMenusConfig = _constants.SIDE_TRANSFORM_MENUS_CONFIG.filter(item => item.type !== _constants.CALL_OUT);
|
|
276
322
|
}
|
|
323
|
+
// Element in Multi_column can not be converted to multi_column type
|
|
324
|
+
if (highestNode.type === _constants.MULTI_COLUMN) {
|
|
325
|
+
newSideMenusConfig = _constants.SIDE_TRANSFORM_MENUS_CONFIG.filter(item => !_constants.MULTI_COLUMN_TYPE.includes(item.type));
|
|
326
|
+
}
|
|
277
327
|
}
|
|
278
328
|
|
|
279
329
|
// headers can't be nested by quote block
|
|
@@ -20,6 +20,7 @@ var _constants = require("../../../constants");
|
|
|
20
20
|
var _constants2 = require("../../constants");
|
|
21
21
|
var _helper = require("../../plugins/callout/helper");
|
|
22
22
|
var _event = require("./event");
|
|
23
|
+
var _helper2 = require("../../plugins/multi-column/helper");
|
|
23
24
|
require("./index.css");
|
|
24
25
|
let sourceElement = null;
|
|
25
26
|
let targetElement = null;
|
|
@@ -88,6 +89,9 @@ const SideToolbar = () => {
|
|
|
88
89
|
let dom = e.target;
|
|
89
90
|
while (((_dom = dom) === null || _dom === void 0 ? void 0 : (_dom$dataset = _dom.dataset) === null || _dom$dataset === void 0 ? void 0 : _dom$dataset.root) !== 'true') {
|
|
90
91
|
var _dom, _dom$dataset;
|
|
92
|
+
if (dom.className === 'column') {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
91
95
|
if (!dom.parentNode) return;
|
|
92
96
|
dom = dom.parentNode;
|
|
93
97
|
}
|
|
@@ -106,6 +110,20 @@ const SideToolbar = () => {
|
|
|
106
110
|
} = document.querySelector('.sdoc-editor-container').getBoundingClientRect();
|
|
107
111
|
left = editorLeft - containerLeft - 40;
|
|
108
112
|
}
|
|
113
|
+
const path = (0, _core.findPath)(editor, node);
|
|
114
|
+
// Add side-tool-bar for paragraphs in multi_column
|
|
115
|
+
if (path.length > 2 && (0, _helpers.isInMultiColumnNode)(editor, node)) {
|
|
116
|
+
let domLeft;
|
|
117
|
+
domLeft = document.querySelector(`[data-id="${dom.dataset.id}"]`) && document.querySelector(`[data-id="${dom.dataset.id}"]`).getBoundingClientRect().left;
|
|
118
|
+
const parentNode = _slate.Editor.node(editor, path.slice(0, 3))[0];
|
|
119
|
+
if ([_constants2.ORDERED_LIST, _constants2.UNORDERED_LIST, _constants2.BLOCKQUOTE].includes(parentNode.type)) {
|
|
120
|
+
domLeft = document.querySelector(`[data-id="${parentNode.id}"]`) && document.querySelector(`[data-id="${parentNode.id}"]`).getBoundingClientRect().left;
|
|
121
|
+
}
|
|
122
|
+
const {
|
|
123
|
+
left: containerLeft
|
|
124
|
+
} = document.querySelector('.sdoc-editor__article').getBoundingClientRect();
|
|
125
|
+
left = domLeft - containerLeft - 41;
|
|
126
|
+
}
|
|
109
127
|
setTimeout(() => {
|
|
110
128
|
// wait animation
|
|
111
129
|
setSidePosition({
|
|
@@ -247,6 +265,7 @@ const SideToolbar = () => {
|
|
|
247
265
|
leaveElement.classList.remove('sdoc-draging');
|
|
248
266
|
}, []);
|
|
249
267
|
const drop = (0, _react.useCallback)(event => {
|
|
268
|
+
var _parentNode$children$;
|
|
250
269
|
targetElement = event.currentTarget;
|
|
251
270
|
targetElement.classList.remove('sdoc-draging');
|
|
252
271
|
const dragTypes = event.dataTransfer.types;
|
|
@@ -326,11 +345,17 @@ const SideToolbar = () => {
|
|
|
326
345
|
return;
|
|
327
346
|
}
|
|
328
347
|
|
|
329
|
-
//
|
|
348
|
+
// Dragging into callout is not supported
|
|
330
349
|
if ([_constants2.CALL_OUT, _constants2.CODE_BLOCK, _constants2.TABLE].includes(sourceNode.type) && (0, _helper.getCalloutEntry)(editor, targetPath)) {
|
|
331
350
|
return;
|
|
332
351
|
}
|
|
333
352
|
|
|
353
|
+
// Dragging multi_column's child into multi_column is not supported
|
|
354
|
+
const isInMultiColumn = (0, _helpers.isInMultiColumnNode)(editor, sourceNode);
|
|
355
|
+
if (isInMultiColumn && (0, _helpers.isMultiColumn)(editor, [targetPath[0]])) {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
|
|
334
359
|
// Drag list
|
|
335
360
|
if ((0, _helpers.isList)(editor, sourcePath)) {
|
|
336
361
|
// ordinary list items
|
|
@@ -380,32 +405,103 @@ const SideToolbar = () => {
|
|
|
380
405
|
}
|
|
381
406
|
}
|
|
382
407
|
|
|
383
|
-
//
|
|
384
|
-
|
|
385
|
-
|
|
408
|
+
// Dragging element from multi_column to other nodes
|
|
409
|
+
const currentSourceNode = _slate.Editor.node(editor, sourcePath.slice(0, 3))[0];
|
|
410
|
+
if (isInMultiColumn && sourceNode.type === _constants2.PARAGRAPH) {
|
|
411
|
+
// Dragging list
|
|
412
|
+
if ([_constants2.ORDERED_LIST, _constants2.UNORDERED_LIST].includes(currentSourceNode.type)) {
|
|
413
|
+
// Drag ordinary list items to places other than list and quoteBlock
|
|
414
|
+
if (!(0, _helpers.isList)(editor, targetPath) && !(0, _helpers.isBlockquote)(editor, [targetPath[0]])) {
|
|
415
|
+
(0, _helpers.onWrapListItemFromMultiColumn)(editor, targetPath, sourcePath);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
// Drag ordinary list items to list
|
|
419
|
+
if ((0, _helpers.isList)(editor, targetPath)) {
|
|
420
|
+
_slate.Transforms.moveNodes(editor, {
|
|
421
|
+
at: sourcePath.slice(0, 4),
|
|
422
|
+
to: _slate.Path.next(targetPath)
|
|
423
|
+
});
|
|
424
|
+
}
|
|
386
425
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
426
|
+
// Drag ordinary list items into the quoteBlock
|
|
427
|
+
if ((0, _helpers.isBlockquote)(editor, [targetPath[0]])) {
|
|
428
|
+
// Drag and drop ordinary list items onto the list within the quoteBlock
|
|
429
|
+
if ((0, _helpers.isList)(editor, targetPath)) {
|
|
430
|
+
_slate.Transforms.moveNodes(editor, {
|
|
431
|
+
at: sourcePath.slice(0, 4),
|
|
432
|
+
to: _slate.Path.next(targetPath)
|
|
433
|
+
});
|
|
434
|
+
} else {
|
|
435
|
+
(0, _helpers.onWrapListItemFromMultiColumn)(editor, targetPath, sourcePath);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
390
438
|
}
|
|
391
439
|
|
|
392
|
-
//
|
|
393
|
-
if (
|
|
394
|
-
|
|
440
|
+
// Dragging quoteBlock's children element from multi_column is not supported
|
|
441
|
+
if (currentSourceNode.type === _constants2.BLOCKQUOTE) {
|
|
442
|
+
return;
|
|
395
443
|
}
|
|
396
|
-
_slate.Transforms.moveNodes(editor, {
|
|
397
|
-
at: sourcePath,
|
|
398
|
-
to: toPath
|
|
399
|
-
});
|
|
400
444
|
}
|
|
401
445
|
|
|
402
|
-
//
|
|
446
|
+
// Handling drag situations including non-multi_column or non-list item dragged from multiColumn
|
|
447
|
+
if (!isInMultiColumn || isInMultiColumn && ![_constants2.ORDERED_LIST, _constants2.UNORDERED_LIST].includes(currentSourceNode.type)) {
|
|
448
|
+
// Drag backward
|
|
449
|
+
if (_slate.Path.isAfter(targetPath, sourcePath)) {
|
|
450
|
+
let toPath = targetPath.slice(0);
|
|
451
|
+
|
|
452
|
+
// Drag elements outside the quoteBlock into the quoteBlock
|
|
453
|
+
if (!(0, _helpers.isBlockquote)(editor, [sourcePath[0]]) && (0, _helpers.isBlockquote)(editor, [targetPath[0]]) && targetPath.length > 1) {
|
|
454
|
+
toPath = _slate.Path.next(targetPath);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
// Drag into list
|
|
458
|
+
if ((0, _helpers.isList)(editor, targetPath)) {
|
|
459
|
+
toPath = _slate.Path.next(targetPath);
|
|
460
|
+
}
|
|
461
|
+
_slate.Transforms.moveNodes(editor, {
|
|
462
|
+
at: sourcePath,
|
|
463
|
+
to: toPath
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// Drag forward
|
|
468
|
+
if (_slate.Path.isBefore(targetPath, sourcePath)) {
|
|
469
|
+
const toPath = _slate.Path.next(targetPath);
|
|
470
|
+
_slate.Transforms.moveNodes(editor, {
|
|
471
|
+
at: sourcePath,
|
|
472
|
+
to: toPath
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
let selectedSourcePath = sourcePath;
|
|
477
|
+
// Handling drag forward situation for multi_column update
|
|
403
478
|
if (_slate.Path.isBefore(targetPath, sourcePath)) {
|
|
404
|
-
const
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
479
|
+
const targetNode = _slate.Editor.node(editor, [targetPath[0]])[0];
|
|
480
|
+
if (![_constants2.ORDERED_LIST, _constants2.UNORDERED_LIST].includes(targetNode.type)) {
|
|
481
|
+
selectedSourcePath[0] += 1;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// Dragging childNodes from multi_column
|
|
486
|
+
const nodeIndex = selectedSourcePath[0];
|
|
487
|
+
const highestNode = editor.children[nodeIndex];
|
|
488
|
+
const [parentNode] = _slate.Editor.parent(editor, selectedSourcePath.slice(0, 3));
|
|
489
|
+
if (selectedSourcePath.length > 1 && highestNode.type === _constants2.MULTI_COLUMN && !((_parentNode$children$ = parentNode.children[0]) !== null && _parentNode$children$ !== void 0 && _parentNode$children$.type)) {
|
|
490
|
+
if (highestNode.children.length <= 2) {
|
|
491
|
+
_slate.Transforms.removeNodes(editor, {
|
|
492
|
+
at: selectedSourcePath.slice(0, 2)
|
|
493
|
+
});
|
|
494
|
+
_slate.Transforms.unwrapNodes(editor, {
|
|
495
|
+
at: [selectedSourcePath[0]]
|
|
496
|
+
});
|
|
497
|
+
} else {
|
|
498
|
+
const topNodesColumnAttribute = highestNode.column;
|
|
499
|
+
_slate.Transforms.removeNodes(editor, {
|
|
500
|
+
at: selectedSourcePath.slice(0, 2)
|
|
501
|
+
});
|
|
502
|
+
const isDragged = true;
|
|
503
|
+
(0, _helper2.updateColumnWidthOnDeletion)(editor, selectedSourcePath, topNodesColumnAttribute, 'deleteBackward', isDragged);
|
|
504
|
+
}
|
|
409
505
|
}
|
|
410
506
|
|
|
411
507
|
// reset
|
|
@@ -17,7 +17,7 @@ const getStyleByFullWidthMode = (scrollRef, editor) => {
|
|
|
17
17
|
containerStyle['minWidth'] = _constants.ARTICLE_FULL_MIN_WIDTH;
|
|
18
18
|
|
|
19
19
|
// Has outline
|
|
20
|
-
if (isShowOutline && editor.editorType !== _constants.WIKI_EDITOR) {
|
|
20
|
+
if (isShowOutline && (editor === null || editor === void 0 ? void 0 : editor.editorType) !== _constants.WIKI_EDITOR) {
|
|
21
21
|
containerStyle['marginLeft'] = `${_constants.LEFT_OUTLINE_WIDTH}px`;
|
|
22
22
|
const adjustWidth = ` - ${_constants.LEFT_OUTLINE_WIDTH - 50}px`; // One side is 50
|
|
23
23
|
containerStyle['width'] = containerStyle['width'].slice(0, -1) + adjustWidth;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seafile/sdoc-editor",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "This is a sdoc editor",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"@seafile/slate": "0.91.8",
|
|
11
11
|
"@seafile/slate-history": "0.86.2",
|
|
12
12
|
"@seafile/slate-hyperscript": "0.81.7",
|
|
13
|
-
"@seafile/slate-react": "0.92.
|
|
13
|
+
"@seafile/slate-react": "0.92.8",
|
|
14
14
|
"axios": "^1.7.4",
|
|
15
15
|
"classnames": "2.3.2",
|
|
16
16
|
"copy-to-clipboard": "^3.3.3",
|