@seafile/sdoc-editor 3.0.107 → 3.0.109

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.
@@ -54,7 +54,8 @@
54
54
  overflow: hidden;
55
55
  }
56
56
 
57
- .menu-group .menu-group-item.sdoc-menu-with-dropdown.disabled {
57
+ .menu-group .menu-group-item.sdoc-menu-with-dropdown.disabled,
58
+ .menu-group .menu-group-item.sdoc-menu-with-dropdown.disabled .sdocfont {
58
59
  color: #C2C2C2;
59
60
  }
60
61
 
@@ -67,6 +67,16 @@ var insertLink = exports.insertLink = function insertLink(editor, title, url) {
67
67
  var slateNode = arguments.length > 4 ? arguments[4] : undefined;
68
68
  var linkedNodeId = arguments.length > 5 ? arguments[5] : undefined;
69
69
  var selectedPageId = arguments.length > 6 ? arguments[6] : undefined;
70
+ var selectedElems = (0, _core.getSelectedElems)(editor);
71
+ var isCodeContext = selectedElems.some(function (elem) {
72
+ return [_constants2.CODE_BLOCK, _constants2.CODE_LINE].includes(elem === null || elem === void 0 ? void 0 : elem.type);
73
+ });
74
+ if (position === _constants2.INSERT_POSITION.CURRENT && isCodeContext) {
75
+ if (title) {
76
+ _slate.Editor.insertText(editor, title);
77
+ }
78
+ return;
79
+ }
70
80
  if (position === _constants2.INSERT_POSITION.CURRENT && isMenuDisabled(editor)) return;
71
81
  if (!title || !url && !linkedNodeId && !selectedPageId) return;
72
82
  var linkNode = genLinkNode(url, title);
@@ -43,37 +43,47 @@ var withLink = function withLink(editor) {
43
43
  };
44
44
  newEditor.insertData = /*#__PURE__*/function () {
45
45
  var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regenerator2["default"])().m(function _callee(data) {
46
- var text, res, fileName, fileUuid, _fileName, fileParentPath, filePath, repoId, _fileName2, _fileUuid, url, pathname, _context$getSetting, parts, wikiPageId, title, wikiPageList, page, linkedNodeId, _title, params, link, _link, _link2, _Editor$next, _Editor$next2, focusPath, focusPoint, _t;
46
+ var text, selectedElems, isCodeContext, res, fileName, fileUuid, _fileName, fileParentPath, filePath, repoId, _fileName2, _fileUuid, url, pathname, _context$getSetting, parts, wikiPageId, title, wikiPageList, page, linkedNodeId, _title, params, link, _link, _link2, _Editor$next, _Editor$next2, focusPath, focusPoint, _t;
47
47
  return (0, _regenerator2["default"])().w(function (_context) {
48
48
  while (1) switch (_context.p = _context.n) {
49
49
  case 0:
50
50
  // Paste link content
51
- text = data.getData('text/plain'); // Internal link, insert sdoc file link
51
+ text = data.getData('text/plain');
52
+ selectedElems = (0, _core.getSelectedElems)(newEditor);
53
+ isCodeContext = selectedElems.some(function (elem) {
54
+ return [_constants2.CODE_BLOCK, _constants2.CODE_LINE].includes(elem === null || elem === void 0 ? void 0 : elem.type);
55
+ });
56
+ if (!isCodeContext) {
57
+ _context.n = 1;
58
+ break;
59
+ }
60
+ return _context.a(2, insertData(data));
61
+ case 1:
52
62
  if (!((0, _isUrl["default"])(text) && !(0, _utils.isImage)(text))) {
53
- _context.n = 14;
63
+ _context.n = 15;
54
64
  break;
55
65
  }
56
66
  if (!(0, _utils.isSameDomain)(text, _context2["default"].getSetting('serviceUrl'))) {
57
- _context.n = 12;
67
+ _context.n = 13;
58
68
  break;
59
69
  }
60
- _context.p = 1;
61
- _context.n = 2;
70
+ _context.p = 2;
71
+ _context.n = 3;
62
72
  return _context2["default"].getLinkFilesInfo([text]);
63
- case 2:
73
+ case 3:
64
74
  res = _context.v;
65
75
  if (!(0, _helpers4.isSdocFile)(res, text)) {
66
- _context.n = 3;
76
+ _context.n = 4;
67
77
  break;
68
78
  }
69
79
  fileName = res.data.files_info[text].name;
70
80
  fileUuid = res.data.files_info[text].file_uuid;
71
81
  (0, _helpers2.insertSdocFileLink)(editor, fileName, fileUuid);
72
- _context.n = 9;
82
+ _context.n = 10;
73
83
  break;
74
- case 3:
84
+ case 4:
75
85
  if (!(0, _helpers4.isExdrawFile)(res, text)) {
76
- _context.n = 4;
86
+ _context.n = 5;
77
87
  break;
78
88
  }
79
89
  _fileName = res.data.files_info[text].name;
@@ -81,52 +91,52 @@ var withLink = function withLink(editor) {
81
91
  filePath = fileParentPath + '/' + _fileName;
82
92
  repoId = res.data.files_info[text].repo_id;
83
93
  (0, _helper.insertWhiteboard)(editor, _fileName, filePath, repoId);
84
- _context.n = 9;
94
+ _context.n = 10;
85
95
  break;
86
- case 4:
96
+ case 5:
87
97
  if (!(0, _helpers4.isCommonFile)(res, text)) {
88
- _context.n = 5;
98
+ _context.n = 6;
89
99
  break;
90
100
  }
91
101
  _fileName2 = res.data.files_info[text].name;
92
102
  _fileUuid = res.data.files_info[text].file_uuid;
93
103
  (0, _helpers.insertFileLink)(editor, _fileName2, _fileUuid);
94
- _context.n = 9;
104
+ _context.n = 10;
95
105
  break;
96
- case 5:
106
+ case 6:
97
107
  url = new URL(text); // Insert wiki page as link in wiki
98
108
  pathname = url.pathname;
99
109
  if (!(editor.editorType === _constants.WIKI_EDITOR && pathname.includes('/wikis/'))) {
100
- _context.n = 7;
110
+ _context.n = 8;
101
111
  break;
102
112
  }
103
113
  parts = pathname.split('/');
104
114
  wikiPageId = parts[parts.length - 2];
105
115
  if (!(editor.selection && !_slate.Range.isCollapsed(editor.selection))) {
106
- _context.n = 6;
116
+ _context.n = 7;
107
117
  break;
108
118
  }
109
119
  title = (0, _core.getEditorString)(editor, editor.selection);
110
120
  (0, _helpers4.insertLink)(editor, title, text, _constants2.INSERT_POSITION.CURRENT, null, '', wikiPageId);
111
121
  return _context.a(2);
112
- case 6:
122
+ case 7:
113
123
  wikiPageList = (_context$getSetting = _context2["default"].getSetting('navConfig')) === null || _context$getSetting === void 0 ? void 0 : _context$getSetting.pages;
114
124
  page = wikiPageList === null || wikiPageList === void 0 ? void 0 : wikiPageList.find(function (p) {
115
125
  return p.id === wikiPageId;
116
126
  });
117
127
  page && (0, _helpers3.insertWikiPageLink)(editor, page.name, page.wikiRepoId, page.id);
118
128
  return _context.a(2);
119
- case 7:
129
+ case 8:
120
130
  // Insert block element as link
121
131
  linkedNodeId = url.hash.replace(/^#/, '');
122
132
  if (!(editor.selection && !_slate.Range.isCollapsed(editor.selection))) {
123
- _context.n = 8;
133
+ _context.n = 9;
124
134
  break;
125
135
  }
126
136
  _title = (0, _core.getEditorString)(editor, editor.selection);
127
137
  (0, _helpers4.insertLink)(editor, _title, text, _constants2.INSERT_POSITION.CURRENT, null, linkedNodeId);
128
138
  return _context.a(2);
129
- case 8:
139
+ case 9:
130
140
  params = new URLSearchParams(url.search);
131
141
  if (params.get('from') === 'copy-block') {
132
142
  link = (0, _helpers4.genLinkNode)(text, text, linkedNodeId);
@@ -134,32 +144,32 @@ var withLink = function withLink(editor) {
134
144
  link = (0, _helpers4.genLinkNode)(text, text);
135
145
  }
136
146
  _slate.Transforms.insertNodes(newEditor, link);
137
- case 9:
138
- _context.n = 11;
139
- break;
140
147
  case 10:
141
- _context.p = 10;
148
+ _context.n = 12;
149
+ break;
150
+ case 11:
151
+ _context.p = 11;
142
152
  _t = _context.v;
143
153
  _link = (0, _helpers4.genLinkNode)(text, text);
144
154
  _slate.Transforms.insertNodes(newEditor, _link);
145
- case 11:
146
- _context.n = 13;
147
- break;
148
155
  case 12:
156
+ _context.n = 14;
157
+ break;
158
+ case 13:
149
159
  _link2 = (0, _helpers4.genLinkNode)(text, text);
150
160
  _slate.Transforms.insertNodes(newEditor, _link2);
151
- case 13:
161
+ case 14:
152
162
  // Void merging text from link
153
163
  _Editor$next = _slate.Editor.next(newEditor), _Editor$next2 = (0, _slicedToArray2["default"])(_Editor$next, 2), focusPath = _Editor$next2[1];
154
164
  focusPoint = _slate.Editor.start(newEditor, focusPath);
155
165
  _slate.Transforms.select(newEditor, focusPoint);
156
166
  return _context.a(2);
157
- case 14:
158
- insertData(data);
159
167
  case 15:
168
+ insertData(data);
169
+ case 16:
160
170
  return _context.a(2);
161
171
  }
162
- }, _callee, null, [[1, 10]]);
172
+ }, _callee, null, [[2, 11]]);
163
173
  }));
164
174
  return function (_x) {
165
175
  return _ref.apply(this, arguments);
@@ -5,14 +5,12 @@
5
5
  justify-content: space-between;
6
6
  }
7
7
 
8
- .menu-group .menu-group-item.sdoc-insert-toolbar-btn .text-truncate {
9
- color: #212529;
8
+ .menu-group .menu-group-item.sdoc-insert-toolbar-btn.disabled .text-truncate {
9
+ color: #C2C2C2;
10
10
  }
11
11
 
12
- .menu-group .menu-group-item.sdoc-insert-toolbar-btn.disabled {
13
- /* 64: 76 - 12 */
14
- width: 64px !important;
15
- color: #BDBDBD;
12
+ .menu-group .menu-group-item.sdoc-insert-toolbar-btn .text-truncate {
13
+ color: #212529;
16
14
  }
17
15
 
18
16
  .menu-group .sdoc-insert-toolbar-btn .sdoc-menu-with-dropdown-icon {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "3.0.107",
3
+ "version": "3.0.109",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -72,5 +72,5 @@
72
72
  "publishConfig": {
73
73
  "access": "public"
74
74
  },
75
- "gitHead": "404b9fbe5fe442913a09f10bd7772eea3be2995e"
75
+ "gitHead": "4a8285a53eabfec83270dba964008de6aa47bbd9"
76
76
  }