@seafile/sdoc-editor 1.0.198-test0.3 → 1.0.198-test0.4

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.
@@ -61,7 +61,7 @@ const SelectSdocFileDialog = _ref => {
61
61
  insertSdocFileLinkCallback && insertSdocFileLinkCallback(editor, fileInfo.name, fileInfo.file_uuid);
62
62
  break;
63
63
  case _constants.ELEMENT_TYPE.WHITEBOARD:
64
- insertWhiteboardFile && insertWhiteboardFile(editor, fileInfo.name, fileInfo.file_uuid);
64
+ insertWhiteboardFile && insertWhiteboardFile(editor, fileInfo.name, fileInfo.path);
65
65
  break;
66
66
  default:
67
67
  break;
@@ -75,7 +75,6 @@ const SelectSdocFileDialog = _ref => {
75
75
  let fileInfo = {
76
76
  ...currentSelectedFile
77
77
  };
78
- console.log(3, fileInfo);
79
78
  // File has no id
80
79
  if (!file_uuid || file_uuid === '') {
81
80
  _context.default.getSdocLocalFileId(currentSelectedFile.path).then(res => {
@@ -85,7 +84,6 @@ const SelectSdocFileDialog = _ref => {
85
84
  file_uuid: res.data.file_uuid
86
85
  };
87
86
  }
88
- console.log(99, res, fileInfo);
89
87
  insertFile(fileInfo);
90
88
  closeDialog();
91
89
  }).catch(error => {
@@ -4,8 +4,9 @@ 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"));
@@ -42,8 +43,44 @@ const isInsertWhiteboardMenuDisabled = (editor, readonly) => {
42
43
  return false;
43
44
  };
44
45
  exports.isInsertWhiteboardMenuDisabled = isInsertWhiteboardMenuDisabled;
45
- const insertWhiteboard = function (editor, videoFiles, srcList, selection) {
46
- let position = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _constants.INSERT_POSITION.CURRENT;
46
+ const generateWhiteboardNode = function (repoID) {
47
+ let filename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
48
+ let filePath = arguments.length > 2 ? arguments[2] : undefined;
49
+ const whiteboardNode = {
50
+ id: _slugid.default.nice(),
51
+ type: _constants.WHITEBOARD,
52
+ repoID: repoID,
53
+ title: filename,
54
+ filePath: filePath,
55
+ children: [{
56
+ id: _slugid.default.nice(),
57
+ text: ''
58
+ }]
59
+ };
60
+ return whiteboardNode;
61
+ };
62
+ exports.generateWhiteboardNode = generateWhiteboardNode;
63
+ const insertWhiteboard = (editor, filename, filePath) => {
64
+ if (isInsertWhiteboardMenuDisabled(editor)) return;
65
+ const {
66
+ repoID
67
+ } = window.app.pageOptions;
68
+ const {
69
+ selection
70
+ } = editor;
71
+ if (selection == null) return;
72
+ // const isCollapsed = Range.isCollapsed(selection);
73
+
74
+ const whiteboardNode = generateWhiteboardNode(repoID, filename, filePath);
75
+ let path = _slate.Editor.path(editor, editor.selection);
76
+ const position = 'after';
77
+ if (position === _constants.INSERT_POSITION.AFTER) {
78
+ _slate.Transforms.insertNodes(editor, whiteboardNode, {
79
+ at: [path[0] + 1]
80
+ });
81
+ (0, _core.focusEditor)(editor, [path[0] + 1, 2]);
82
+ return;
83
+ }
47
84
  };
48
85
  exports.insertWhiteboard = insertWhiteboard;
49
86
  const onCreateWhiteboardFile = editor => {
@@ -38,6 +38,7 @@ const Whiteboard = _ref => {
38
38
  }, tldraw);
39
39
  };
40
40
  function renderWhiteboard(props, editor) {
41
+ console.log(3, editor, props);
41
42
  return /*#__PURE__*/_react.default.createElement(Whiteboard, Object.assign({}, props, {
42
43
  editor: editor
43
44
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "1.0.198-test0.3",
3
+ "version": "1.0.198-test0.4",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",