@seafile/sdoc-editor 1.0.83 → 1.0.85
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/extension/core/utils/index.js +2 -0
- package/dist/basic-sdk/extension/plugins/image/helpers.js +22 -1
- package/dist/basic-sdk/extension/plugins/image/render-elem.js +21 -4
- package/dist/basic-sdk/extension/plugins/quick-insert/render-elem.js +1 -0
- package/dist/basic-sdk/extension/plugins/seatable-column/helpers.js +37 -10
- package/dist/basic-sdk/extension/plugins/seatable-tables/formatter/link-formatter/utils.js +2 -1
- package/dist/constants/index.js +2 -1
- package/dist/pages/document-plugin-editor.js +2 -0
- package/package.json +1 -1
|
@@ -60,6 +60,8 @@ function Placeholder(props) {
|
|
|
60
60
|
t
|
|
61
61
|
} = (0, _reactI18next.useTranslation)();
|
|
62
62
|
return /*#__PURE__*/_react.default.createElement("span", {
|
|
63
|
+
contentEditable: "false",
|
|
64
|
+
suppressContentEditableWarning: true,
|
|
63
65
|
style: {
|
|
64
66
|
position: 'absolute',
|
|
65
67
|
top: `${top}px`,
|
|
@@ -9,10 +9,12 @@ var _urlJoin = _interopRequireDefault(require("url-join"));
|
|
|
9
9
|
var _slate = require("@seafile/slate");
|
|
10
10
|
var _slateReact = require("@seafile/slate-react");
|
|
11
11
|
var _slugid = _interopRequireDefault(require("slugid"));
|
|
12
|
+
var _dtableUtils = require("dtable-utils");
|
|
12
13
|
var _context = _interopRequireDefault(require("../../../../context"));
|
|
13
14
|
var _eventBus = _interopRequireDefault(require("../../../utils/event-bus"));
|
|
14
15
|
var _core = require("../../core");
|
|
15
16
|
var _helpers = require("../../toolbar/side-toolbar/helpers");
|
|
17
|
+
var _helpers2 = require("../seatable-column/helpers");
|
|
16
18
|
var _constants = require("../../../constants");
|
|
17
19
|
var _constants2 = require("../../constants");
|
|
18
20
|
var _base64ToUnit8array = _interopRequireDefault(require("../../../../utils/base64-to-unit8array"));
|
|
@@ -129,7 +131,26 @@ const updateImage = (editor, data) => {
|
|
|
129
131
|
});
|
|
130
132
|
};
|
|
131
133
|
exports.updateImage = updateImage;
|
|
132
|
-
const getImageURL =
|
|
134
|
+
const getImageURL = (data, editor) => {
|
|
135
|
+
const {
|
|
136
|
+
src: url,
|
|
137
|
+
column_key
|
|
138
|
+
} = data;
|
|
139
|
+
if (column_key) {
|
|
140
|
+
const column = (0, _helpers2.getColumnByKey)(editor.columns || [], column_key);
|
|
141
|
+
const {
|
|
142
|
+
type
|
|
143
|
+
} = column || {};
|
|
144
|
+
if (type === _dtableUtils.CellType.IMAGE) {
|
|
145
|
+
const imgUrl = editor.getColumnCellValue(column_key) || '';
|
|
146
|
+
const firstSrc = imgUrl.split(',')[0];
|
|
147
|
+
return firstSrc;
|
|
148
|
+
} else if (type === _dtableUtils.CellType.DIGITAL_SIGN) {
|
|
149
|
+
const partUrl = editor.getColumnCellValue(column_key) || '';
|
|
150
|
+
const imgUrl = (0, _helpers2.getDigitalSignImgUrl)(partUrl);
|
|
151
|
+
return imgUrl;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
133
154
|
if (url && url.startsWith('http')) return url;
|
|
134
155
|
const serviceUrl = _context.default.getSetting('serviceUrl');
|
|
135
156
|
const assetsUrl = _context.default.getSetting('assetsUrl');
|
|
@@ -19,6 +19,7 @@ var _hoverMenu = _interopRequireDefault(require("./hover-menu"));
|
|
|
19
19
|
var _useScrollContext = require("../../../hooks/use-scroll-context");
|
|
20
20
|
var _constants2 = require("./constants");
|
|
21
21
|
var _constants3 = require("../../constants");
|
|
22
|
+
var _constants4 = require("../../../../constants");
|
|
22
23
|
var _imagePlaceholder = _interopRequireDefault(require("../../../assets/images/image-placeholder.png"));
|
|
23
24
|
const Image = _ref => {
|
|
24
25
|
var _imageRef$current, _imageRef$current2;
|
|
@@ -37,7 +38,8 @@ const Image = _ref => {
|
|
|
37
38
|
border_type = _constants2.IMAGE_BORDER_TYPE[0].type
|
|
38
39
|
} = element;
|
|
39
40
|
const {
|
|
40
|
-
show_caption = false
|
|
41
|
+
show_caption = false,
|
|
42
|
+
column_key
|
|
41
43
|
} = data;
|
|
42
44
|
const path = _slateReact.ReactEditor.findPath(editor, element);
|
|
43
45
|
const nodeEntry = _slate.Editor.node(editor, [path[0]]);
|
|
@@ -158,6 +160,21 @@ const Image = _ref => {
|
|
|
158
160
|
};
|
|
159
161
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
160
162
|
}, [isShowImageHoverMenu, onHideImageHoverMenu]);
|
|
163
|
+
const onImageColumnToggle = (0, _react.useCallback)(() => {
|
|
164
|
+
// Handle switching to empty data and switching back
|
|
165
|
+
setIsShowImagePlaceholder(false);
|
|
166
|
+
}, []);
|
|
167
|
+
(0, _react.useEffect)(() => {
|
|
168
|
+
let unsubscribeImageColumnToggle = null;
|
|
169
|
+
if (column_key) {
|
|
170
|
+
const eventBus = _eventBus.default.getInstance();
|
|
171
|
+
unsubscribeImageColumnToggle = eventBus.subscribe(_constants4.EXTERNAL_EVENT.IMAGE_COLUMN_TOGGLE, onImageColumnToggle);
|
|
172
|
+
}
|
|
173
|
+
return () => {
|
|
174
|
+
unsubscribeImageColumnToggle && unsubscribeImageColumnToggle();
|
|
175
|
+
};
|
|
176
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
177
|
+
}, [column_key]);
|
|
161
178
|
const setPosition = (0, _react.useCallback)(() => {
|
|
162
179
|
if (imageRef.current) {
|
|
163
180
|
const {
|
|
@@ -176,10 +193,10 @@ const Image = _ref => {
|
|
|
176
193
|
}, [setPosition]);
|
|
177
194
|
const reloadImage = (0, _react.useCallback)(() => {
|
|
178
195
|
if (imageRef.current) {
|
|
179
|
-
imageRef.current['src'] = (0, _helpers.getImageURL)(data
|
|
196
|
+
imageRef.current['src'] = (0, _helpers.getImageURL)(data, editor);
|
|
180
197
|
setIsShowImagePlaceholder(false);
|
|
181
198
|
}
|
|
182
|
-
}, [data
|
|
199
|
+
}, [data, editor]);
|
|
183
200
|
const onImageLoadError = (0, _react.useCallback)(() => {
|
|
184
201
|
// Check is due to the image is pasted from the clipboard in base64
|
|
185
202
|
if (data.src.startsWith('data:image/jpeg;base64')) {
|
|
@@ -244,7 +261,7 @@ const Image = _ref => {
|
|
|
244
261
|
}),
|
|
245
262
|
onClick: onClickImage,
|
|
246
263
|
ref: imageRef,
|
|
247
|
-
src: (0, _helpers.getImageURL)(data
|
|
264
|
+
src: (0, _helpers.getImageURL)(data, editor),
|
|
248
265
|
style: getImageStyle(),
|
|
249
266
|
draggable: false,
|
|
250
267
|
onError: onImageLoadError,
|
|
@@ -40,6 +40,7 @@ const RenderQuickInsert = (_ref, editor) => {
|
|
|
40
40
|
}
|
|
41
41
|
}, [editor, element]);
|
|
42
42
|
const genStyle = (top, left) => {
|
|
43
|
+
if (editor.isRemote) return null;
|
|
43
44
|
const overflowY = top + sideMenuRef.current.offsetHeight - document.body.clientHeight;
|
|
44
45
|
if (overflowY > 0) {
|
|
45
46
|
top = top - overflowY - 10;
|
|
@@ -5,12 +5,14 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.setSeaTableColumn = exports.isMenuDisabled = exports.insertSeaTableColumn = exports.getColumnWidth = exports.getColumnType = exports.getColumnByKey = void 0;
|
|
8
|
+
exports.setSeaTableColumn = exports.isMenuDisabled = exports.insertSeaTableColumn = exports.getDigitalSignImgUrl = exports.getColumnWidth = exports.getColumnType = exports.getColumnByKey = void 0;
|
|
9
9
|
var _slate = require("@seafile/slate");
|
|
10
10
|
var _slugid = _interopRequireDefault(require("slugid"));
|
|
11
|
+
var _context = _interopRequireDefault(require("../../../../context"));
|
|
11
12
|
var _elementType = require("../../constants/element-type");
|
|
12
13
|
var _constants = require("../../constants");
|
|
13
14
|
var _core = require("../../core");
|
|
15
|
+
var _helpers = require("../image/helpers");
|
|
14
16
|
var _model = _interopRequireDefault(require("./model"));
|
|
15
17
|
var CellType = _interopRequireWildcard(require("./constants/cell-types"));
|
|
16
18
|
const isMenuDisabled = (editor, readonly) => {
|
|
@@ -56,15 +58,45 @@ const getColumnType = editor => {
|
|
|
56
58
|
return (0, _core.getNodeType)(n);
|
|
57
59
|
};
|
|
58
60
|
exports.getColumnType = getColumnType;
|
|
61
|
+
const getDigitalSignImgUrl = partUrl => {
|
|
62
|
+
const server = _context.default.getSetting('serviceUrl');
|
|
63
|
+
const workspaceID = _context.default.getSetting('workspaceID');
|
|
64
|
+
const dtableUuid = _context.default.getSetting('dtableUuid');
|
|
65
|
+
if (!partUrl || typeof partUrl !== 'string') return '';
|
|
66
|
+
return `${server}/workspace/${workspaceID}/asset/${dtableUuid}${partUrl}`;
|
|
67
|
+
};
|
|
68
|
+
exports.getDigitalSignImgUrl = getDigitalSignImgUrl;
|
|
69
|
+
const getColumnByKey = (columns, key) => {
|
|
70
|
+
const column = columns.find(item => item.key === key);
|
|
71
|
+
return column || null;
|
|
72
|
+
};
|
|
73
|
+
exports.getColumnByKey = getColumnByKey;
|
|
59
74
|
const insertSeaTableColumn = function (editor, active, option) {
|
|
60
75
|
let insertPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _constants.INSERT_POSITION.CURRENT;
|
|
61
76
|
if (!active) {
|
|
62
|
-
const
|
|
63
|
-
|
|
77
|
+
const {
|
|
78
|
+
value
|
|
79
|
+
} = option;
|
|
80
|
+
const column = getColumnByKey(editor.columns || [], value);
|
|
81
|
+
const {
|
|
82
|
+
type,
|
|
83
|
+
key
|
|
84
|
+
} = column || {};
|
|
85
|
+
let columnNode = {};
|
|
86
|
+
if (type === CellType.IMAGE) {
|
|
87
|
+
columnNode = (0, _helpers.generateImageNode)('');
|
|
88
|
+
columnNode['data']['column_key'] = key;
|
|
89
|
+
} else if (type === CellType.DIGITAL_SIGN) {
|
|
90
|
+
columnNode = (0, _helpers.generateImageNode)('');
|
|
91
|
+
columnNode['data']['column_key'] = key;
|
|
92
|
+
} else {
|
|
93
|
+
columnNode = new _model.default(option);
|
|
94
|
+
columnNode.id = _slugid.default.nice();
|
|
95
|
+
}
|
|
64
96
|
if (insertPosition === _constants.INSERT_POSITION.AFTER) {
|
|
65
97
|
const path = _slate.Editor.path(editor, editor.selection);
|
|
66
98
|
path && _slate.Transforms.insertNodes(editor, {
|
|
67
|
-
...
|
|
99
|
+
...columnNode
|
|
68
100
|
}, {
|
|
69
101
|
at: [path[0] + 1]
|
|
70
102
|
});
|
|
@@ -72,7 +104,7 @@ const insertSeaTableColumn = function (editor, active, option) {
|
|
|
72
104
|
return;
|
|
73
105
|
}
|
|
74
106
|
_slate.Transforms.insertNodes(editor, {
|
|
75
|
-
...
|
|
107
|
+
...columnNode
|
|
76
108
|
});
|
|
77
109
|
}
|
|
78
110
|
(0, _core.focusEditor)(editor);
|
|
@@ -87,11 +119,6 @@ const setSeaTableColumn = (editor, data) => {
|
|
|
87
119
|
});
|
|
88
120
|
};
|
|
89
121
|
exports.setSeaTableColumn = setSeaTableColumn;
|
|
90
|
-
const getColumnByKey = (columns, key) => {
|
|
91
|
-
const column = columns.find(item => item.key === key);
|
|
92
|
-
return column || null;
|
|
93
|
-
};
|
|
94
|
-
exports.getColumnByKey = getColumnByKey;
|
|
95
122
|
const getColumnWidth = column => {
|
|
96
123
|
let {
|
|
97
124
|
type,
|
|
@@ -16,7 +16,7 @@ const isValidCellValue = value => {
|
|
|
16
16
|
return true;
|
|
17
17
|
};
|
|
18
18
|
exports.isValidCellValue = isValidCellValue;
|
|
19
|
-
const getCellDisplayValue = (record, column, collaborators) => {
|
|
19
|
+
const getCellDisplayValue = (record, column, collaborators, formulaRows) => {
|
|
20
20
|
const {
|
|
21
21
|
type,
|
|
22
22
|
data,
|
|
@@ -25,6 +25,7 @@ const getCellDisplayValue = (record, column, collaborators) => {
|
|
|
25
25
|
return (0, _dtableUtils.getCellValueDisplayString)(record, type, key, {
|
|
26
26
|
data,
|
|
27
27
|
collaborators,
|
|
28
|
+
formulaRows,
|
|
28
29
|
geolocationHyphen: ' '
|
|
29
30
|
});
|
|
30
31
|
};
|
package/dist/constants/index.js
CHANGED
|
@@ -39,7 +39,8 @@ const EXTERNAL_EVENT = exports.EXTERNAL_EVENT = {
|
|
|
39
39
|
// wiki
|
|
40
40
|
INSERT_LINK: 'insert_link',
|
|
41
41
|
// document
|
|
42
|
-
COLLABORATORS_UPDATED: 'collaborators_updated'
|
|
42
|
+
COLLABORATORS_UPDATED: 'collaborators_updated',
|
|
43
|
+
IMAGE_COLUMN_TOGGLE: 'Image_column_toggle'
|
|
43
44
|
};
|
|
44
45
|
const TIP_TYPE = exports.TIP_TYPE = {
|
|
45
46
|
DELETE_NO_CHANGES_REVISION: 'delete_no_changes_revision',
|
|
@@ -32,6 +32,7 @@ const DocumentPluginEditor = _ref => {
|
|
|
32
32
|
tables,
|
|
33
33
|
getTableById,
|
|
34
34
|
collaborators,
|
|
35
|
+
formulaRows,
|
|
35
36
|
getTableFormulaResults,
|
|
36
37
|
getArticleStyle
|
|
37
38
|
} = _ref;
|
|
@@ -63,6 +64,7 @@ const DocumentPluginEditor = _ref => {
|
|
|
63
64
|
newEditor.tables = tables || [];
|
|
64
65
|
newEditor.getTableById = getTableById;
|
|
65
66
|
newEditor.collaborators = collaborators;
|
|
67
|
+
newEditor.formulaRows = formulaRows;
|
|
66
68
|
newEditor.getTableFormulaResults = getTableFormulaResults;
|
|
67
69
|
newEditor.cursors = cursors || {};
|
|
68
70
|
newEditor.width = _constants.PAGE_EDIT_AREA_WIDTH; // default width
|