@seafile/sdoc-editor 0.5.46 → 0.5.47

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.
@@ -17,7 +17,7 @@ export const isMenuDisabled = (editor, readonly) => {
17
17
  if (hasVoid) return true;
18
18
  const isMatch = selectedElems.some(elem => {
19
19
  const type = getNodeType(elem);
20
- if (type === CODE_BLOCK || type === PARAGRAPH) return true;
20
+ if (type === PARAGRAPH) return true;
21
21
  return false;
22
22
  });
23
23
  if (isMatch) return false; // enable
@@ -2,7 +2,8 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import slugid from 'slugid';
3
3
  import isHotkey from 'is-hotkey';
4
4
  import { Transforms, Node, Range, Editor } from '@seafile/slate';
5
- import { getNodeType, isLastNode, getSelectedNodeByType, generateEmptyElement, isSelectionAtBlockStart } from '../../core';
5
+ import { ReactEditor } from '@seafile/slate-react';
6
+ import { getNodeType, isLastNode, getSelectedNodeByType, generateEmptyElement, isSelectionAtBlockStart, getSelectedElems } from '../../core';
6
7
  import { deleteBackwardByLength } from './helpers';
7
8
  import { CODE_BLOCK, PARAGRAPH, CODE_LINE, BLOCKQUOTE } from '../../constants';
8
9
  const withCodeBlock = editor => {
@@ -168,7 +169,25 @@ const withCodeBlock = editor => {
168
169
  }
169
170
  }
170
171
  if (isHotkey('tab', event)) {
171
- newEditor.insertText(' ');
172
+ const {
173
+ selection
174
+ } = newEditor;
175
+ event.preventDefault();
176
+ // By default, tab key will insert 4 spaces
177
+ const indent = ' '.repeat(4);
178
+ if (Range.isCollapsed(selection)) {
179
+ newEditor.insertText(indent);
180
+ } else {
181
+ const selectedElements = getSelectedElems(newEditor);
182
+ selectedElements.forEach(elem => {
183
+ if (elem.type !== CODE_LINE) return;
184
+ const text = indent + Node.string(elem);
185
+ const insertPoint = ReactEditor.findPath(newEditor, elem);
186
+ Transforms.insertText(editor, text, {
187
+ at: insertPoint
188
+ });
189
+ });
190
+ }
172
191
  }
173
192
  if (isHotkey('shift+tab', event)) {
174
193
  const range = {
@@ -92,14 +92,24 @@ export const insertMention = (editor, collaborator) => {
92
92
  export const sortCollaborators = function (collaborators) {
93
93
  let participants = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
94
94
  const loginEmail = context.getUserInfo().email;
95
+ const lastModifyUser = context.getSetting('last_modify_user');
96
+ let stickyCollaborator = null;
95
97
  const participantsMap = {};
96
98
  participants.forEach(item => {
97
99
  if (item.email === loginEmail) return;
98
100
  participantsMap[item.email] = item;
99
101
  });
100
- const newCollaborators = collaborators.filter(item => !participantsMap[item.email] && item.email !== loginEmail);
102
+ const newCollaborators = collaborators.filter(item => {
103
+ const isValidCollaborator = !participantsMap[item.email] && item.email !== loginEmail;
104
+ if (isValidCollaborator && lastModifyUser === item.email) {
105
+ stickyCollaborator = item;
106
+ return false;
107
+ }
108
+ return isValidCollaborator;
109
+ });
101
110
  const newParticipants = Object.values(participantsMap);
102
- return [...newParticipants, ...newCollaborators];
111
+ const resCollaborators = stickyCollaborator ? [stickyCollaborator, ...newParticipants, ...newCollaborators] : [...newParticipants, ...newCollaborators];
112
+ return resCollaborators;
103
113
  };
104
114
  export const transformToText = function (editor) {
105
115
  let isFocusEnd = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
@@ -53,16 +53,15 @@
53
53
  flex: 1;
54
54
  display: flex;
55
55
  flex-direction: column;
56
+ word-break: break-all;
56
57
  overflow-x: hidden;
57
- overflow-y: hidden;
58
- }
59
-
60
- .sdoc-outline-list-container:hover {
61
58
  overflow-y: auto;
62
59
  }
63
60
 
64
61
  .sdoc-outline-item {
65
62
  padding: 4px 0;
63
+ padding-right: 6px;
64
+ overflow-wrap: anywhere;
66
65
  cursor: pointer;
67
66
  }
68
67
 
package/dist/context.js CHANGED
@@ -97,7 +97,10 @@ class Context {
97
97
  return this.config;
98
98
  }
99
99
  getFileContent() {
100
- return this.sdocServerApi.getDocContent();
100
+ return this.sdocServerApi.getDocContent().then(res => {
101
+ this.settings['last_modify_user'] = res.data.last_modify_user;
102
+ return res;
103
+ });
101
104
  }
102
105
  normalizeSdocContent() {
103
106
  return this.sdocServerApi.normalizeSdocContent();
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.5.46",
3
+ "version": "0.5.47",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
7
7
  "dependencies": {
8
- "@seafile/print-js": "1.6.4",
8
+ "@seafile/print-js": "1.6.5",
9
9
  "@seafile/react-image-lightbox": "2.0.4",
10
10
  "@seafile/slate": "0.91.8",
11
11
  "@seafile/slate-history": "0.86.2",