@seafile/sdoc-editor 1.0.198-test0.3 → 1.0.198-test0.5
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/commons/insert-element-dialog/index.js +3 -0
- package/dist/basic-sdk/extension/commons/select-file-dialog/index.js +3 -3
- package/dist/basic-sdk/extension/plugins/whiteboard/helpers.js +42 -3
- package/dist/basic-sdk/extension/plugins/whiteboard/menu/index.js +4 -4
- package/dist/basic-sdk/extension/plugins/whiteboard/render-elem.js +13 -8
- package/dist/basic-sdk/extension/toolbar/header-toolbar/insert-toolbar/index.js +1 -0
- package/package.json +1 -1
|
@@ -27,6 +27,7 @@ const InsertElementDialog = _ref => {
|
|
|
27
27
|
let {
|
|
28
28
|
editor
|
|
29
29
|
} = _ref;
|
|
30
|
+
console.log(3, editor);
|
|
30
31
|
const [dialogType, setDialogType] = (0, _react.useState)('');
|
|
31
32
|
const [element, setElement] = (0, _react.useState)('');
|
|
32
33
|
const [insertPosition, setInsertPosition] = (0, _react.useState)(_constants2.INSERT_POSITION.CURRENT);
|
|
@@ -97,6 +98,7 @@ const InsertElementDialog = _ref => {
|
|
|
97
98
|
// link shortcut wrapping link
|
|
98
99
|
handleSubmit
|
|
99
100
|
} = _ref2;
|
|
101
|
+
console.log(5, insertWhiteboard, paramEditor);
|
|
100
102
|
setInsertPosition(insertPosition);
|
|
101
103
|
setSlateNode(slateNode);
|
|
102
104
|
setElement(element);
|
|
@@ -181,6 +183,7 @@ const InsertElementDialog = _ref => {
|
|
|
181
183
|
insertWhiteboardFile,
|
|
182
184
|
closeDialog
|
|
183
185
|
};
|
|
186
|
+
console.log(555, editor, insertWhiteboardFile);
|
|
184
187
|
return /*#__PURE__*/_react.default.createElement(_index.default, whiteboardProps);
|
|
185
188
|
}
|
|
186
189
|
case _constants2.LOCAL_IMAGE:
|
|
@@ -24,6 +24,7 @@ const SelectSdocFileDialog = _ref => {
|
|
|
24
24
|
insertLinkCallback,
|
|
25
25
|
insertWhiteboardFile
|
|
26
26
|
} = _ref;
|
|
27
|
+
console.log(3, insertWhiteboardFile);
|
|
27
28
|
const {
|
|
28
29
|
t
|
|
29
30
|
} = (0, _reactI18next.useTranslation)('sdoc-editor');
|
|
@@ -61,7 +62,8 @@ const SelectSdocFileDialog = _ref => {
|
|
|
61
62
|
insertSdocFileLinkCallback && insertSdocFileLinkCallback(editor, fileInfo.name, fileInfo.file_uuid);
|
|
62
63
|
break;
|
|
63
64
|
case _constants.ELEMENT_TYPE.WHITEBOARD:
|
|
64
|
-
|
|
65
|
+
console.log(12, dialogType, editor);
|
|
66
|
+
insertWhiteboardFile && insertWhiteboardFile(editor, fileInfo.name, fileInfo.path);
|
|
65
67
|
break;
|
|
66
68
|
default:
|
|
67
69
|
break;
|
|
@@ -75,7 +77,6 @@ const SelectSdocFileDialog = _ref => {
|
|
|
75
77
|
let fileInfo = {
|
|
76
78
|
...currentSelectedFile
|
|
77
79
|
};
|
|
78
|
-
console.log(3, fileInfo);
|
|
79
80
|
// File has no id
|
|
80
81
|
if (!file_uuid || file_uuid === '') {
|
|
81
82
|
_context.default.getSdocLocalFileId(currentSelectedFile.path).then(res => {
|
|
@@ -85,7 +86,6 @@ const SelectSdocFileDialog = _ref => {
|
|
|
85
86
|
file_uuid: res.data.file_uuid
|
|
86
87
|
};
|
|
87
88
|
}
|
|
88
|
-
console.log(99, res, fileInfo);
|
|
89
89
|
insertFile(fileInfo);
|
|
90
90
|
closeDialog();
|
|
91
91
|
}).catch(error => {
|
|
@@ -4,14 +4,16 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.onCreateWhiteboardFile = exports.isInsertWhiteboardMenuDisabled = exports.insertWhiteboard = void 0;
|
|
7
|
+
exports.onCreateWhiteboardFile = exports.isInsertWhiteboardMenuDisabled = exports.insertWhiteboard = exports.generateWhiteboardNode = void 0;
|
|
8
8
|
var _slate = require("@seafile/slate");
|
|
9
|
+
var _slugid = _interopRequireDefault(require("slugid"));
|
|
9
10
|
var _core = require("../../core");
|
|
10
11
|
var _constants = require("../../constants");
|
|
11
12
|
var _eventBus = _interopRequireDefault(require("../../../utils/event-bus"));
|
|
12
13
|
var _constants2 = require("../../../../constants");
|
|
13
14
|
const isInsertWhiteboardMenuDisabled = (editor, readonly) => {
|
|
14
15
|
if (readonly) return true;
|
|
16
|
+
console.log(9, editor);
|
|
15
17
|
const {
|
|
16
18
|
selection
|
|
17
19
|
} = editor;
|
|
@@ -42,8 +44,45 @@ const isInsertWhiteboardMenuDisabled = (editor, readonly) => {
|
|
|
42
44
|
return false;
|
|
43
45
|
};
|
|
44
46
|
exports.isInsertWhiteboardMenuDisabled = isInsertWhiteboardMenuDisabled;
|
|
45
|
-
const
|
|
46
|
-
let
|
|
47
|
+
const generateWhiteboardNode = function (repoID) {
|
|
48
|
+
let filename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
49
|
+
let filePath = arguments.length > 2 ? arguments[2] : undefined;
|
|
50
|
+
const whiteboardNode = {
|
|
51
|
+
id: _slugid.default.nice(),
|
|
52
|
+
type: _constants.WHITEBOARD,
|
|
53
|
+
repoID: repoID,
|
|
54
|
+
title: filename,
|
|
55
|
+
filePath: filePath,
|
|
56
|
+
children: [{
|
|
57
|
+
id: _slugid.default.nice(),
|
|
58
|
+
text: ''
|
|
59
|
+
}]
|
|
60
|
+
};
|
|
61
|
+
return whiteboardNode;
|
|
62
|
+
};
|
|
63
|
+
exports.generateWhiteboardNode = generateWhiteboardNode;
|
|
64
|
+
const insertWhiteboard = (editor, filename, filePath) => {
|
|
65
|
+
console.log(8, editor);
|
|
66
|
+
if (isInsertWhiteboardMenuDisabled(editor)) return;
|
|
67
|
+
const {
|
|
68
|
+
repoID
|
|
69
|
+
} = window.app.pageOptions;
|
|
70
|
+
const {
|
|
71
|
+
selection
|
|
72
|
+
} = editor;
|
|
73
|
+
if (selection == null) return;
|
|
74
|
+
// const isCollapsed = Range.isCollapsed(selection);
|
|
75
|
+
|
|
76
|
+
const whiteboardNode = generateWhiteboardNode(repoID, filename, filePath);
|
|
77
|
+
let path = _slate.Editor.path(editor, editor.selection);
|
|
78
|
+
const position = 'after';
|
|
79
|
+
if (position === _constants.INSERT_POSITION.AFTER) {
|
|
80
|
+
_slate.Transforms.insertNodes(editor, whiteboardNode, {
|
|
81
|
+
at: [path[0] + 1]
|
|
82
|
+
});
|
|
83
|
+
(0, _core.focusEditor)(editor, [path[0] + 1, 2]);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
47
86
|
};
|
|
48
87
|
exports.insertWhiteboard = insertWhiteboard;
|
|
49
88
|
const onCreateWhiteboardFile = editor => {
|
|
@@ -20,22 +20,22 @@ const WhiteboardMenu = _ref => {
|
|
|
20
20
|
eventBus,
|
|
21
21
|
toggle
|
|
22
22
|
} = _ref;
|
|
23
|
+
console.log(1, editor, readonly);
|
|
23
24
|
const disabled = (0, _helpers.isInsertWhiteboardMenuDisabled)(editor, readonly);
|
|
24
25
|
const menuConfig = _constants.MENUS_CONFIG_MAP[_constants.WHITEBOARD];
|
|
25
26
|
const {
|
|
26
27
|
t
|
|
27
|
-
} = (0, _reactI18next.useTranslation)();
|
|
28
|
+
} = (0, _reactI18next.useTranslation)('sdoc-editor');
|
|
28
29
|
const onCreateFile = () => {
|
|
29
30
|
(0, _helpers.onCreateWhiteboardFile)(editor);
|
|
30
31
|
};
|
|
31
32
|
const openSelectSdocFileDialog = (0, _react.useCallback)(() => {
|
|
32
33
|
eventBus.dispatch(_constants2.INTERNAL_EVENT.INSERT_ELEMENT, {
|
|
33
34
|
type: _constants.ELEMENT_TYPE.WHITEBOARD,
|
|
34
|
-
insertWhiteboard: _helpers.insertWhiteboard
|
|
35
|
+
insertWhiteboard: _helpers.insertWhiteboard,
|
|
36
|
+
paramEditor: editor || null
|
|
35
37
|
});
|
|
36
38
|
toggle && toggle();
|
|
37
|
-
|
|
38
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
39
39
|
}, [toggle, eventBus]);
|
|
40
40
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
|
|
41
41
|
disabled: disabled,
|
|
@@ -16,14 +16,14 @@ const Whiteboard = _ref => {
|
|
|
16
16
|
repoID,
|
|
17
17
|
filePath
|
|
18
18
|
} = _ref;
|
|
19
|
-
|
|
19
|
+
const whiteboardRef = (0, _react.useRef)();
|
|
20
20
|
const [tldraw, setTldraw] = (0, _react.useState)(null);
|
|
21
|
+
console.log(33, repoID, filePath);
|
|
21
22
|
const renderWhiteboardEditor = Tldraw => {
|
|
22
|
-
console.log(4, Tldraw);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}));
|
|
23
|
+
console.log(4, Tldraw, repoID, filePath);
|
|
24
|
+
if (Tldraw) {
|
|
25
|
+
setTldraw(() => Tldraw);
|
|
26
|
+
}
|
|
27
27
|
};
|
|
28
28
|
(0, _react.useEffect)(() => {
|
|
29
29
|
const eventBus = _eventBus.default.getInstance();
|
|
@@ -34,10 +34,15 @@ const Whiteboard = _ref => {
|
|
|
34
34
|
};
|
|
35
35
|
}, []);
|
|
36
36
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
37
|
-
id: "sdoc-whiteboard-container"
|
|
38
|
-
|
|
37
|
+
id: "sdoc-whiteboard-container",
|
|
38
|
+
ref: whiteboardRef
|
|
39
|
+
}, tldraw && /*#__PURE__*/_react.default.createElement("tldraw", {
|
|
40
|
+
repoID: repoID,
|
|
41
|
+
filePath: filePath
|
|
42
|
+
}));
|
|
39
43
|
};
|
|
40
44
|
function renderWhiteboard(props, editor) {
|
|
45
|
+
console.log(3, editor, props);
|
|
41
46
|
return /*#__PURE__*/_react.default.createElement(Whiteboard, Object.assign({}, props, {
|
|
42
47
|
editor: editor
|
|
43
48
|
}));
|
|
@@ -66,6 +66,7 @@ const InsertToolbar = _ref => {
|
|
|
66
66
|
readonly,
|
|
67
67
|
toggle
|
|
68
68
|
};
|
|
69
|
+
console.log(9, props.editor);
|
|
69
70
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("button", {
|
|
70
71
|
type: "button",
|
|
71
72
|
className: validClassName,
|