@seafile/sdoc-editor 0.5.18 → 0.5.19

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.
@@ -1720,7 +1720,7 @@ export const generateDragMoveElement = tipText => {
1720
1720
  let canvas = document.getElementById(canvasId);
1721
1721
  if (!canvas) {
1722
1722
  canvas = document.createElement('canvas');
1723
- canvas.width = 150;
1723
+ canvas.width = 115;
1724
1724
  canvas.height = 30;
1725
1725
  canvas.id = canvasId;
1726
1726
  document.body.appendChild(canvas);
@@ -1730,18 +1730,27 @@ export const generateDragMoveElement = tipText => {
1730
1730
  const context = canvas.getContext('2d');
1731
1731
  context.clearRect(0, 0, canvas.width, canvas.height);
1732
1732
  context.textAlign = 'center';
1733
- context.fillStyle = 'rgb(66, 129, 219)';
1733
+ context.fillStyle = 'rgb(241,243,246)';
1734
1734
  context.fillRect(0, 0, canvas.width, canvas.height);
1735
1735
  context.font = '12px';
1736
1736
  context.textBaseline = 'middle';
1737
- context.fillStyle = 'white';
1737
+ context.fillStyle = 'black';
1738
1738
  context.fillText(tipText, canvas.width / 2, canvas.height / 2);
1739
1739
  return canvas;
1740
1740
  };
1741
- export const isHideDragHandlerLine = (editor, displayType, table, cellPath) => {
1741
+ export const isHideDragHandlerLine = (editor, displayType, table, cellPath, isDragOverCellHalf) => {
1742
1742
  const pathLength = cellPath.length;
1743
- const rowIndex = cellPath[pathLength - 2];
1744
- const cellIndex = cellPath[pathLength - 1];
1743
+ let rowIndex = cellPath[pathLength - 2];
1744
+ let cellIndex = cellPath[pathLength - 1];
1745
+ if (isDragOverCellHalf) {
1746
+ if (displayType === DRAG_HANDLER_COLUMN) {
1747
+ cellIndex = cellIndex + 1;
1748
+ } else {
1749
+ rowIndex = rowIndex + 1;
1750
+ }
1751
+ }
1752
+ const isEndOfRowOrColumn = displayType === DRAG_HANDLER_COLUMN && cellIndex === table.columns.length || displayType === DRAG_HANDLER_ROW && rowIndex === table.children.length;
1753
+ if (isEndOfRowOrColumn) return false;
1745
1754
  let preCellDom = null;
1746
1755
  if (displayType === DRAG_HANDLER_COLUMN && cellIndex > 1) {
1747
1756
  const prevCell = table.children[rowIndex].children[cellIndex - 1];
@@ -1750,18 +1759,28 @@ export const isHideDragHandlerLine = (editor, displayType, table, cellPath) => {
1750
1759
  const prevCell = table.children[rowIndex - 1].children[cellIndex];
1751
1760
  preCellDom = ReactEditor.toDOMNode(editor, prevCell);
1752
1761
  }
1753
- const isPrevCellSelected = preCellDom ? preCellDom.classList.contains(CELL_SELECTED) : false;
1762
+
1763
+ // Check is above cell selected
1764
+ const currentCellDom = ReactEditor.toDOMNode(editor, table.children[rowIndex].children[cellIndex]);
1765
+ const isCurrentCellSelected = currentCellDom.classList.contains(CELL_SELECTED);
1766
+ if (isCurrentCellSelected) return true;
1754
1767
 
1755
1768
  // Check if the previous cell is selected
1769
+ const isPrevCellSelected = preCellDom && preCellDom.classList.contains(CELL_SELECTED);
1756
1770
  if (isPrevCellSelected) return true;
1757
-
1771
+ let isCombined = false;
1758
1772
  // Check if the combined cell
1759
1773
  if (displayType === DRAG_HANDLER_COLUMN) {
1760
- const isCombined = table.children.some(row => row.children[cellIndex].is_combined);
1761
- return isCombined;
1774
+ isCombined = table.children.some(row => row.children[cellIndex - isDragOverCellHalf].is_combined);
1762
1775
  } else {
1763
- const isCombined = table.children[rowIndex].children.some(cell => cell.is_combined);
1764
- return isCombined;
1776
+ isCombined = table.children[rowIndex - isDragOverCellHalf].children.some(cell => cell.is_combined);
1777
+ }
1778
+ if (isCombined) return true;
1779
+
1780
+ // Check is the last column
1781
+ if (displayType === DRAG_HANDLER_COLUMN) {
1782
+ const isLastColumn = cellIndex === table.columns.length - 1;
1783
+ if (isLastColumn) return false;
1765
1784
  }
1766
1785
  };
1767
1786
  export const getTableRowSelectedRange = (table, rowIndex) => {
@@ -14,7 +14,7 @@ const DragHandlers = _ref => {
14
14
  });
15
15
  const [displayType, setDisplayType] = useState('');
16
16
  const tableID = table.id;
17
- const handleShowResizeHandler = useCallback(_ref2 => {
17
+ const handleShowDragHandler = useCallback(_ref2 => {
18
18
  let {
19
19
  displayType,
20
20
  left,
@@ -31,11 +31,11 @@ const DragHandlers = _ref => {
31
31
  }, [tableID]);
32
32
  useEffect(() => {
33
33
  const eventBus = EventBus.getInstance();
34
- const unsubscribe = eventBus.subscribe(INTERNAL_EVENT.TABLE_SHOW_DRAG_HANDLER, handleShowResizeHandler);
34
+ const unsubscribe = eventBus.subscribe(INTERNAL_EVENT.TABLE_SHOW_DRAG_HANDLER, handleShowDragHandler);
35
35
  return () => {
36
36
  unsubscribe();
37
37
  };
38
- }, [handleShowResizeHandler]);
38
+ }, [handleShowDragHandler]);
39
39
  return /*#__PURE__*/React.createElement(React.Fragment, null, displayType === DRAG_HANDLER_ROW && /*#__PURE__*/React.createElement(RowDragHandler, {
40
40
  top: linePosition.top
41
41
  }), displayType === DRAG_HANDLER_COLUMN && /*#__PURE__*/React.createElement(ColumnDragHandler, {
@@ -40,6 +40,7 @@ const TableCell = _ref => {
40
40
  const eventBus = EventBus.getInstance();
41
41
  const tableId = tableEntry[0].id;
42
42
  const canDrop = useRef(false);
43
+ const isDragOverHalfCell = useRef(false);
43
44
  const onContextMenu = useCallback(event => {
44
45
  const path = findPath(editor, element);
45
46
  focusEditor(editor, path);
@@ -100,7 +101,34 @@ const TableCell = _ref => {
100
101
  mouseDownEvent: event,
101
102
  tableId
102
103
  });
103
- const isHideHandleLine = isHideDragHandlerLine(editor, displayType, table, cellPath);
104
+ if (cellInfo.displayType === DRAG_HANDLER_COLUMN) {
105
+ const offsetX = cellInfo.mouseDownEvent.nativeEvent.offsetX;
106
+ const cellWidth = cellInfo.width;
107
+ const cellIndex = cellInfo.cellIndex;
108
+ // To avoid the drag handler line being covered by the table border
109
+ if (cellIndex === 0) cellInfo.left += 1;
110
+ if (cellIndex === table.children[0].children.length - 1) cellInfo.left -= 2;
111
+ if (offsetX >= cellWidth / 2) {
112
+ cellInfo.left = cellInfo.left + cellWidth;
113
+ isDragOverHalfCell.current = true;
114
+ } else {
115
+ isDragOverHalfCell.current = false;
116
+ }
117
+ } else {
118
+ const offsetY = cellInfo.mouseDownEvent.nativeEvent.offsetY;
119
+ const cellHeight = cellInfo.height;
120
+ const rowIndex = cellInfo.rowIndex;
121
+ // To avoid the drag handler line being covered by the table border
122
+ if (rowIndex === 0) cellInfo.top += 1;
123
+ if (rowIndex === table.children.length - 1) cellInfo.top -= 2;
124
+ if (offsetY >= cellHeight / 2) {
125
+ cellInfo.top = cellInfo.top + cellHeight;
126
+ isDragOverHalfCell.current = true;
127
+ } else {
128
+ isDragOverHalfCell.current = false;
129
+ }
130
+ }
131
+ const isHideHandleLine = isHideDragHandlerLine(editor, displayType, table, cellPath, isDragOverHalfCell.current);
104
132
  canDrop.current = !isHideHandleLine;
105
133
  if (target.classList.contains(CELL_SELECTED) || isHideHandleLine) {
106
134
  cellInfo.top = -9999;
@@ -120,6 +148,7 @@ const TableCell = _ref => {
120
148
  if (!dragDataJson) return;
121
149
  const dragData = JSON.parse(dragDataJson);
122
150
  if (dragData) {
151
+ const offset = isDragOverHalfCell.current ? 1 : 0;
123
152
  const {
124
153
  tableId: dragTableId,
125
154
  startIndex,
@@ -127,8 +156,8 @@ const TableCell = _ref => {
127
156
  dragType
128
157
  } = dragData;
129
158
  if (dragTableId !== tableId) return;
130
- dragType === DRAG_HANDLER_COLUMN ? moveColumns(editor, cellIndex, startIndex, endIndex) : moveRows(editor, rowIndex, startIndex, endIndex);
131
- const range = dragType === DRAG_HANDLER_COLUMN ? getTableSelectedRangeAfterDrag(tableEntry[0], dragType, cellIndex, startIndex, endIndex) : getTableSelectedRangeAfterDrag(tableEntry[0], dragType, rowIndex, startIndex, endIndex);
159
+ dragType === DRAG_HANDLER_COLUMN ? moveColumns(editor, cellIndex + offset, startIndex, endIndex) : moveRows(editor, rowIndex + offset, startIndex, endIndex);
160
+ const range = dragType === DRAG_HANDLER_COLUMN ? getTableSelectedRangeAfterDrag(tableEntry[0], dragType, cellIndex + offset, startIndex, endIndex) : getTableSelectedRangeAfterDrag(tableEntry[0], dragType, rowIndex + offset, startIndex, endIndex);
132
161
  eventBus.dispatch(INTERNAL_EVENT.SET_TABLE_SELECT_RANGE, tableEntry[0], range);
133
162
  }
134
163
  }, [cellIndex, editor, eventBus, rowIndex, tableEntry, tableId]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.5.18",
3
+ "version": "0.5.19",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
@@ -18,8 +18,8 @@
18
18
  "Unordered_list": "Neseřazený seznam",
19
19
  "Check_list_item": "Check list item",
20
20
  "Insert_image": "Insert image",
21
- "Insert_formula": "Insert formula",
22
- "Formula": "Formula",
21
+ "Insert_formula": "Vložit vzorec",
22
+ "Formula": "Vzorec",
23
23
  "Insert_file": "Insert file",
24
24
  "Code": "Řádkový kód",
25
25
  "Code_block": "Code block",
@@ -42,8 +42,8 @@
42
42
  "Delete_table": "Delete table",
43
43
  "Delete_row": "Delete row",
44
44
  "Delete_column": "Delete column",
45
- "Insert_row": "Insert row",
46
- "Insert_column": "Insert column",
45
+ "Insert_row": "Vložit řádek",
46
+ "Insert_column": "Vložit sloupec",
47
47
  "Set_align": "Nastavit zarovnání",
48
48
  "Left": "Vlevo",
49
49
  "Center": "Střed",
@@ -140,10 +140,10 @@
140
140
  "Insert_library_image": "Vložit obrázek knihovny",
141
141
  "Size": "Velikost",
142
142
  "Location": "Umístění",
143
- "Last_update": "Last update",
143
+ "Last_update": "Poslední aktualizace",
144
144
  "Tags": "Štítky",
145
145
  "Add_participants": "Přidat účastníky",
146
- "Clear_format": "Clear format",
146
+ "Clear_format": "Jasný formát",
147
147
  "MarkdownLint": {
148
148
  "missing_h1": {
149
149
  "description": "V dokumentu není žádný h1",
@@ -158,7 +158,7 @@
158
158
  "issue": "Problém s úrovní nadpisu"
159
159
  }
160
160
  },
161
- "Shortcut_help": "Shortcut help",
161
+ "Shortcut_help": "Zkratka nápovědy",
162
162
  "User_help": {
163
163
  "title": "Klávesové zkratky",
164
164
  "userHelpData": [
@@ -209,7 +209,7 @@
209
209
  {
210
210
  "shortcutType": "Zkratky vzorečku",
211
211
  "shortcutData": {
212
- "Insert_Formula": "Insert Formula"
212
+ "Insert_Formula": "Vložit vzorec"
213
213
  }
214
214
  },
215
215
  {
@@ -448,5 +448,7 @@
448
448
  "Create": "Vytvořit",
449
449
  "Top_align": "Top",
450
450
  "Center_align": "Middle",
451
- "Bottom_align": "Bottom"
451
+ "Bottom_align": "Bottom",
452
+ "Move_column_count": "Moving {{count}} column(s)",
453
+ "Move_row_count": "Moving {{count}} row(s)"
452
454
  }
@@ -18,7 +18,7 @@
18
18
  "Unordered_list": "Ungeordnete Liste",
19
19
  "Check_list_item": "Check list item",
20
20
  "Insert_image": "Insert image",
21
- "Insert_formula": "Insert formula",
21
+ "Insert_formula": "Formel einfügen",
22
22
  "Formula": "Formel",
23
23
  "Insert_file": "Insert file",
24
24
  "Code": "Inline-Code",
@@ -42,8 +42,8 @@
42
42
  "Delete_table": "Delete table",
43
43
  "Delete_row": "Delete row",
44
44
  "Delete_column": "Delete column",
45
- "Insert_row": "Insert row",
46
- "Insert_column": "Insert column",
45
+ "Insert_row": "Zeile einfügen",
46
+ "Insert_column": "Spalte einfügen",
47
47
  "Set_align": "Ausrichtung festlegen",
48
48
  "Left": "Links",
49
49
  "Center": "Zentrieren",
@@ -140,10 +140,10 @@
140
140
  "Insert_library_image": "Bild aus Bibliothek einfügen",
141
141
  "Size": "Größe",
142
142
  "Location": "Ort",
143
- "Last_update": "Last update",
143
+ "Last_update": "Letzte Änderung",
144
144
  "Tags": "Tags",
145
145
  "Add_participants": "Teilnehmer hinzufügen",
146
- "Clear_format": "Clear format",
146
+ "Clear_format": "Formatierung löschen",
147
147
  "MarkdownLint": {
148
148
  "missing_h1": {
149
149
  "description": "Es gibt keine Hauptüberschrift (h1) in dem Text",
@@ -288,7 +288,7 @@
288
288
  "Load_doc_content_error": "Load doc content error",
289
289
  "Sdoc_format_invalid": "The content of the document does not conform to the sdoc specification",
290
290
  "Draft": "Entwurf",
291
- "Unmark_as_draft": "Unmark as draft",
291
+ "Unmark_as_draft": "Entwurfsmarkierung entfernen",
292
292
  "Background_color": "Background color",
293
293
  "No_color": "No color",
294
294
  "Standard_color": "Standard color",
@@ -367,10 +367,10 @@
367
367
  "Table": "Tabelle",
368
368
  "Link": "Link",
369
369
  "Transform_to": "Transform to",
370
- "Last_modification": "Last modification",
371
- "Next_modification": "Next modification",
370
+ "Last_modification": "Letzte Änderung",
371
+ "Next_modification": "Nächste Änderung",
372
372
  "Changes": "Änderungen",
373
- "No_changes": "No changes",
373
+ "No_changes": "Keine Änderungen",
374
374
  "Title": "Titel",
375
375
  "Subtitle": "Subtitle",
376
376
  "Link_sdoc": "Link sdoc",
@@ -402,10 +402,10 @@
402
402
  "No_collaborators_available": "No_collaborators_available",
403
403
  "Find_a_collaborator": "Find a collaborator",
404
404
  "Doc_comments": "Document comments",
405
- "Tag_not_found": "Tag not found",
405
+ "Tag_not_found": "Der Tag wurde nicht gefunden",
406
406
  "Create_a_new_tag": "Neues Tag erstellen",
407
407
  "Search_tags": "Search tags",
408
- "No_options_available": "Tag not found",
408
+ "No_options_available": "Der Tag wurde nicht gefunden",
409
409
  "Add_option": "Neues Tag erstellen",
410
410
  "Find_an_option": "Search tags",
411
411
  "Copy_link_of_section": "Copy link of section",
@@ -448,5 +448,7 @@
448
448
  "Create": "Erstellen",
449
449
  "Top_align": "Top",
450
450
  "Center_align": "Middle",
451
- "Bottom_align": "Bottom"
451
+ "Bottom_align": "Bottom",
452
+ "Move_column_count": "Moving {{count}} column(s)",
453
+ "Move_row_count": "Moving {{count}} row(s)"
452
454
  }
@@ -448,5 +448,7 @@
448
448
  "Create": "Crear",
449
449
  "Top_align": "Top",
450
450
  "Center_align": "Middle",
451
- "Bottom_align": "Bottom"
451
+ "Bottom_align": "Bottom",
452
+ "Move_column_count": "Moving {{count}} column(s)",
453
+ "Move_row_count": "Moving {{count}} row(s)"
452
454
  }
@@ -448,5 +448,7 @@
448
448
  "Create": "Créer",
449
449
  "Top_align": "Top",
450
450
  "Center_align": "Middle",
451
- "Bottom_align": "Bottom"
451
+ "Bottom_align": "Bottom",
452
+ "Move_column_count": "Moving {{count}} column(s)",
453
+ "Move_row_count": "Moving {{count}} row(s)"
452
454
  }
@@ -448,5 +448,7 @@
448
448
  "Create": "Crea",
449
449
  "Top_align": "Top",
450
450
  "Center_align": "Middle",
451
- "Bottom_align": "Bottom"
451
+ "Bottom_align": "Bottom",
452
+ "Move_column_count": "Moving {{count}} column(s)",
453
+ "Move_row_count": "Moving {{count}} row(s)"
452
454
  }
@@ -446,7 +446,9 @@
446
446
  "The_document_does_not_exist": "Документ не существует",
447
447
  "Create_a_new_sdoc_file": "Создать новый файл sdoc",
448
448
  "Create": "Создать",
449
- "Top_align": "Top",
450
- "Center_align": "Middle",
451
- "Bottom_align": "Bottom"
449
+ "Top_align": "Верх",
450
+ "Center_align": "Середина",
451
+ "Bottom_align": "Низ",
452
+ "Move_column_count": "Перемещение {{count}} столбцов",
453
+ "Move_row_count": "Перемещение {{count}} строк"
452
454
  }
@@ -449,6 +449,6 @@
449
449
  "Top_align": "顶端对齐",
450
450
  "Center_align": "居中对齐",
451
451
  "Bottom_align": "底端对齐",
452
- "Move_column_count": "正在移动{{count}}列",
453
- "Move_row_count": "正在移动{{count}}行"
452
+ "Move_column_count": "移动{{count}}列",
453
+ "Move_row_count": "移动{{count}}行"
454
454
  }