@seafile/sdoc-editor 0.1.91 → 0.1.92
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/api/sdoc-server-api.js +58 -0
- package/dist/api/seafile-api.js +14 -1
- package/dist/basic-sdk/comment/comment/comment-editor.js +53 -0
- package/dist/basic-sdk/comment/{comment-item.js → comment/comment-item-content.js} +29 -14
- package/dist/basic-sdk/comment/comment/comment-item-reply.js +112 -0
- package/dist/basic-sdk/comment/comment/comment-item-wrapper.js +208 -0
- package/dist/basic-sdk/comment/{comment-list.js → comment/comment-list.js} +58 -71
- package/dist/basic-sdk/comment/{comment.js → comment/index.js} +4 -4
- package/dist/basic-sdk/comment/{style.css → comment/style.css} +43 -8
- package/dist/basic-sdk/comment/dialogs/delete-comment-dialog.js +11 -4
- package/dist/basic-sdk/comment/hooks/use-comment-mount.js +5 -1
- package/dist/basic-sdk/comment/reducer/comment-reducer.js +82 -0
- package/dist/basic-sdk/editor.js +3 -4
- package/dist/basic-sdk/extension/commons/color-menu/index.js +6 -5
- package/dist/basic-sdk/extension/plugins/table/helpers.js +85 -30
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/cell-bg-color-menu.js +35 -0
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/cell-text-align-menu.js +43 -0
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/index.js +31 -171
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/remove-table-menu.js +26 -0
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/table-column-menu.js +35 -0
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/table-row-menu.js +35 -0
- package/dist/basic-sdk/extension/plugins/table/popover/table-size-popover/index.js +1 -0
- package/dist/basic-sdk/extension/plugins/text-style/menu/index.js +6 -8
- package/dist/basic-sdk/hooks/use-color-context.js +48 -0
- package/dist/components/common-loading/index.css +54 -0
- package/dist/components/common-loading/index.js +8 -0
- package/dist/components/doc-info/index.js +5 -2
- package/dist/components/doc-operations/revision-operations/index.js +2 -1
- package/dist/components/doc-operations/revision-operations/revisions/index.css +16 -0
- package/dist/components/doc-operations/revision-operations/revisions/index.js +49 -0
- package/dist/components/doc-operations/revision-operations/revisions/revisions-dialog/index.css +120 -0
- package/dist/components/doc-operations/revision-operations/revisions/revisions-dialog/index.js +174 -0
- package/dist/components/doc-operations/style.css +13 -0
- package/dist/context.js +27 -0
- package/dist/model/index.js +2 -0
- package/dist/model/revision.js +35 -0
- package/package.json +1 -1
- package/public/locales/en/sdoc-editor.json +11 -1
- package/public/locales/zh-CN/sdoc-editor.json +11 -1
- package/dist/basic-sdk/comment/comment-editor.js +0 -73
- package/dist/basic-sdk/hooks/use-font-color-context.js +0 -28
- package/dist/basic-sdk/hooks/use-highlight-color-context.js +0 -28
|
@@ -472,16 +472,14 @@ export var getCellColumn = function getCellColumn(editor, cellElement) {
|
|
|
472
472
|
var tablePath = cellPath.slice(0, -2);
|
|
473
473
|
var tableElement = getNode(editor, tablePath);
|
|
474
474
|
var columns = tableElement.columns;
|
|
475
|
+
var columnsCount = tableElement.children[0].children.length;
|
|
476
|
+
var pageEditAreaWidth = editor.width || PAGE_EDIT_AREA_WIDTH;
|
|
475
477
|
if (columns) {
|
|
476
478
|
column = columns[cellIndex];
|
|
477
|
-
} else {
|
|
478
|
-
var columnsCount = tableElement.children[0].children.length;
|
|
479
|
-
var pageEditAreaWidth = editor.width || PAGE_EDIT_AREA_WIDTH;
|
|
480
|
-
column = {
|
|
481
|
-
width: Math.max(TABLE_CELL_MIN_WIDTH, parseInt(pageEditAreaWidth / columnsCount))
|
|
482
|
-
};
|
|
483
479
|
}
|
|
484
|
-
return column
|
|
480
|
+
return column || {
|
|
481
|
+
width: Math.max(TABLE_CELL_MIN_WIDTH, parseInt(pageEditAreaWidth / columnsCount))
|
|
482
|
+
};
|
|
485
483
|
};
|
|
486
484
|
export var getFirstTableCell = function getFirstTableCell(element) {
|
|
487
485
|
var tableCellElement = element;
|
|
@@ -712,19 +710,42 @@ export var focusCell = function focusCell(editor, event) {
|
|
|
712
710
|
rowIndex = _getSelectedInfo8.rowIndex,
|
|
713
711
|
cellIndex = _getSelectedInfo8.cellIndex,
|
|
714
712
|
cell = _getSelectedInfo8.cell;
|
|
715
|
-
var
|
|
713
|
+
var tableParentPath = tablePath.slice(0, -1);
|
|
714
|
+
var tableIndex = tablePath[tablePath.length - 1];
|
|
716
715
|
var selection = editor.selection;
|
|
717
716
|
var focus = selection.focus;
|
|
718
717
|
if (keyboardName === KEYBOARD.UP) {
|
|
719
|
-
if (!isCursorAtCellStart(focus.offset))
|
|
718
|
+
if (!isCursorAtCellStart(focus.offset)) {
|
|
719
|
+
setTimeout(function () {
|
|
720
|
+
if (getSelectedNodeByType(editor, ELEMENT_TYPE.TABLE)) {
|
|
721
|
+
var _getSelectedInfo9 = getSelectedInfo(editor),
|
|
722
|
+
newCellIndex = _getSelectedInfo9.cellIndex;
|
|
723
|
+
if (Math.abs(newCellIndex - cellIndex) !== 0) {
|
|
724
|
+
if (rowIndex === 0) {
|
|
725
|
+
if (tableIndex !== 0) {
|
|
726
|
+
focusEditor(editor, [].concat(_toConsumableArray(tableParentPath), [tableIndex - 1]));
|
|
727
|
+
}
|
|
728
|
+
return;
|
|
729
|
+
}
|
|
730
|
+
focusEditor(editor, [].concat(_toConsumableArray(tableParentPath), [tableIndex, rowIndex - 1, cellIndex]));
|
|
731
|
+
var _newFocus = editor.selection.focus;
|
|
732
|
+
Transforms.select(editor, {
|
|
733
|
+
focus: _newFocus,
|
|
734
|
+
anchor: _newFocus
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
}, 2);
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
720
741
|
event.preventDefault();
|
|
721
742
|
if (rowIndex === 0) {
|
|
722
743
|
if (tableIndex !== 0) {
|
|
723
|
-
focusEditor(editor, [tableIndex - 1]);
|
|
744
|
+
focusEditor(editor, [].concat(_toConsumableArray(tableParentPath), [tableIndex - 1]));
|
|
724
745
|
}
|
|
725
746
|
return;
|
|
726
747
|
}
|
|
727
|
-
focusEditor(editor, [tableIndex, rowIndex - 1, cellIndex]);
|
|
748
|
+
focusEditor(editor, [].concat(_toConsumableArray(tableParentPath), [tableIndex, rowIndex - 1, cellIndex]));
|
|
728
749
|
var newFocus = editor.selection.focus;
|
|
729
750
|
Transforms.select(editor, {
|
|
730
751
|
focus: newFocus,
|
|
@@ -735,13 +756,13 @@ export var focusCell = function focusCell(editor, event) {
|
|
|
735
756
|
if (!isCursorAtCellEnd(cell, focus.offset)) return;
|
|
736
757
|
event.preventDefault();
|
|
737
758
|
if (rowIndex === tableSize[0] - 1 && cellIndex === tableSize[1] - 1) {
|
|
738
|
-
focusEditor(editor, [tableIndex + 1]);
|
|
759
|
+
focusEditor(editor, [].concat(_toConsumableArray(tableParentPath), [tableIndex + 1]));
|
|
739
760
|
return;
|
|
740
761
|
}
|
|
741
762
|
if (cellIndex === tableSize[1] - 1) {
|
|
742
|
-
focusEditor(editor, [tableIndex, rowIndex + 1, 0]);
|
|
763
|
+
focusEditor(editor, [].concat(_toConsumableArray(tableParentPath), [tableIndex, rowIndex + 1, 0]));
|
|
743
764
|
} else {
|
|
744
|
-
focusEditor(editor, [tableIndex, rowIndex, cellIndex + 1]);
|
|
765
|
+
focusEditor(editor, [].concat(_toConsumableArray(tableParentPath), [tableIndex, rowIndex, cellIndex + 1]));
|
|
745
766
|
}
|
|
746
767
|
var newAnchor = editor.selection.anchor;
|
|
747
768
|
Transforms.select(editor, {
|
|
@@ -750,17 +771,41 @@ export var focusCell = function focusCell(editor, event) {
|
|
|
750
771
|
});
|
|
751
772
|
}
|
|
752
773
|
if (keyboardName === KEYBOARD.DOWN) {
|
|
753
|
-
if (!isCursorAtCellEnd(cell, focus.offset))
|
|
774
|
+
if (!isCursorAtCellEnd(cell, focus.offset)) {
|
|
775
|
+
setTimeout(function () {
|
|
776
|
+
if (getSelectedNodeByType(editor, ELEMENT_TYPE.TABLE)) {
|
|
777
|
+
var _getSelectedInfo10 = getSelectedInfo(editor),
|
|
778
|
+
newCellIndex = _getSelectedInfo10.cellIndex;
|
|
779
|
+
if (Math.abs(newCellIndex - cellIndex) !== 0) {
|
|
780
|
+
if (rowIndex === tableSize[0] - 1) {
|
|
781
|
+
var nextNode = getNode(editor, [].concat(_toConsumableArray(tableParentPath), [tableIndex + 1]));
|
|
782
|
+
if (!nextNode) return;
|
|
783
|
+
focusEditor(editor, [].concat(_toConsumableArray(tableParentPath), [tableIndex + 1]));
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
786
|
+
focusEditor(editor, [].concat(_toConsumableArray(tableParentPath), [tableIndex, rowIndex + 1, cellIndex]));
|
|
787
|
+
var _newAnchor = editor.selection.anchor;
|
|
788
|
+
Transforms.select(editor, {
|
|
789
|
+
focus: _newAnchor,
|
|
790
|
+
anchor: _newAnchor
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
}, 2);
|
|
795
|
+
return;
|
|
796
|
+
}
|
|
754
797
|
event.preventDefault();
|
|
755
798
|
if (rowIndex === tableSize[0] - 1) {
|
|
756
|
-
|
|
799
|
+
var nextNode = getNode([].concat(_toConsumableArray(tableParentPath), [tableIndex + 1]));
|
|
800
|
+
if (!nextNode) return;
|
|
801
|
+
focusEditor(editor, [].concat(_toConsumableArray(tableParentPath), [tableIndex + 1]));
|
|
757
802
|
return;
|
|
758
803
|
}
|
|
759
|
-
focusEditor(editor, [tableIndex, rowIndex + 1, cellIndex]);
|
|
760
|
-
var
|
|
804
|
+
focusEditor(editor, [].concat(_toConsumableArray(tableParentPath), [tableIndex, rowIndex + 1, cellIndex]));
|
|
805
|
+
var _newAnchor2 = editor.selection.anchor;
|
|
761
806
|
Transforms.select(editor, {
|
|
762
|
-
focus:
|
|
763
|
-
anchor:
|
|
807
|
+
focus: _newAnchor2,
|
|
808
|
+
anchor: _newAnchor2
|
|
764
809
|
});
|
|
765
810
|
}
|
|
766
811
|
if (keyboardName === KEYBOARD.LEFT) {
|
|
@@ -768,35 +813,45 @@ export var focusCell = function focusCell(editor, event) {
|
|
|
768
813
|
event.preventDefault();
|
|
769
814
|
if (rowIndex === 0 && cellIndex === 0) {
|
|
770
815
|
if (tableIndex !== 0) {
|
|
771
|
-
focusEditor(editor, [tableIndex - 1]);
|
|
816
|
+
focusEditor(editor, [].concat(_toConsumableArray(tableParentPath), [tableIndex - 1]));
|
|
772
817
|
}
|
|
773
818
|
return;
|
|
774
819
|
}
|
|
775
820
|
if (cellIndex === 0) {
|
|
776
|
-
focusEditor(editor, [tableIndex, rowIndex - 1, tableSize[1] - 1]);
|
|
821
|
+
focusEditor(editor, [].concat(_toConsumableArray(tableParentPath), [tableIndex, rowIndex - 1, tableSize[1] - 1]));
|
|
777
822
|
} else {
|
|
778
|
-
focusEditor(editor, [tableIndex, rowIndex, cellIndex - 1]);
|
|
823
|
+
focusEditor(editor, [].concat(_toConsumableArray(tableParentPath), [tableIndex, rowIndex, cellIndex - 1]));
|
|
779
824
|
}
|
|
780
|
-
var
|
|
825
|
+
var _newFocus2 = editor.selection.focus;
|
|
781
826
|
Transforms.select(editor, {
|
|
782
|
-
focus:
|
|
783
|
-
anchor:
|
|
827
|
+
focus: _newFocus2,
|
|
828
|
+
anchor: _newFocus2
|
|
784
829
|
});
|
|
785
830
|
}
|
|
786
831
|
};
|
|
787
832
|
export var isLastTableCell = function isLastTableCell(editor, cellNode) {
|
|
788
833
|
if (cellNode[0].type !== ELEMENT_TYPE.TABLE_CELL) return false;
|
|
789
|
-
var
|
|
790
|
-
tableSize =
|
|
834
|
+
var _getSelectedInfo11 = getSelectedInfo(editor),
|
|
835
|
+
tableSize = _getSelectedInfo11.tableSize;
|
|
791
836
|
var lastRowIndex = tableSize[0] - 1;
|
|
792
837
|
var lastColumnIndex = tableSize[1] - 1;
|
|
793
838
|
var cellNodePath = cellNode[1];
|
|
794
839
|
var cellNodePathDeep = cellNodePath.length;
|
|
795
840
|
return cellNodePath[cellNodePathDeep - 1] === lastColumnIndex && cellNodePath[cellNodePathDeep - 2] === lastRowIndex;
|
|
796
841
|
};
|
|
842
|
+
var getValidColor = function getValidColor(color) {
|
|
843
|
+
if (!color) return '';
|
|
844
|
+
var validColor = color.length === 4 ? '#' + color.slice(1, 4).repeat(2) : color;
|
|
845
|
+
return validColor.toUpperCase();
|
|
846
|
+
};
|
|
797
847
|
export var colorBlend = function colorBlend(c1, c2, ratio) {
|
|
798
|
-
var color1 = c1
|
|
799
|
-
var color2 = c2
|
|
848
|
+
var color1 = getValidColor(c1);
|
|
849
|
+
var color2 = getValidColor(c2);
|
|
850
|
+
if (!color1 && !color2) return 'unset';
|
|
851
|
+
if (color1 && !color2) return color1;
|
|
852
|
+
if (!color1 && color2) return color2;
|
|
853
|
+
if (color1 === '#FFFFFF') return color2;
|
|
854
|
+
if (color2 === '#FFFFFF') return color1;
|
|
800
855
|
var validRatio = Math.max(Math.min(Number(ratio), 1), 0);
|
|
801
856
|
var r1 = parseInt(color1.substring(1, 3), 16);
|
|
802
857
|
var g1 = parseInt(color1.substring(3, 5), 16);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import React, { useCallback } from 'react';
|
|
3
|
+
import { ColorMenu } from '../../../../commons';
|
|
4
|
+
import { MENUS_CONFIG_MAP, BG_COLOR, RECENT_USED_TABLE_CELL_BG_COLORS_KEY } from '../../../../constants';
|
|
5
|
+
import { setCellStyle } from '../../helpers';
|
|
6
|
+
import { useColorContext } from '../../../../../hooks/use-color-context';
|
|
7
|
+
var CellBgColorMenu = function CellBgColorMenu(_ref) {
|
|
8
|
+
var isRichEditor = _ref.isRichEditor,
|
|
9
|
+
className = _ref.className,
|
|
10
|
+
editor = _ref.editor;
|
|
11
|
+
var _useColorContext = useColorContext(),
|
|
12
|
+
lastUsedTableCellBgColor = _useColorContext.lastUsedTableCellBgColor,
|
|
13
|
+
updateLastUsedTableCellBgColor = _useColorContext.updateLastUsedTableCellBgColor;
|
|
14
|
+
var menuConfig = MENUS_CONFIG_MAP[BG_COLOR];
|
|
15
|
+
var setColor = useCallback(function (color) {
|
|
16
|
+
setCellStyle(editor, {
|
|
17
|
+
bg_color: color
|
|
18
|
+
});
|
|
19
|
+
}, [editor]);
|
|
20
|
+
var props = _objectSpread(_objectSpread({
|
|
21
|
+
isRichEditor: isRichEditor,
|
|
22
|
+
className: className,
|
|
23
|
+
disabled: false,
|
|
24
|
+
isActive: false
|
|
25
|
+
}, menuConfig), {}, {
|
|
26
|
+
onMouseDown: function onMouseDown() {},
|
|
27
|
+
setColor: setColor,
|
|
28
|
+
recentUsedColorsKey: RECENT_USED_TABLE_CELL_BG_COLORS_KEY,
|
|
29
|
+
lastUsedColor: lastUsedTableCellBgColor,
|
|
30
|
+
updateLastUsedColor: updateLastUsedTableCellBgColor,
|
|
31
|
+
popoverClassName: 'sdoc-table-cell-bg-colors-popover'
|
|
32
|
+
});
|
|
33
|
+
return /*#__PURE__*/React.createElement(ColorMenu, props);
|
|
34
|
+
};
|
|
35
|
+
export default CellBgColorMenu;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React, { useCallback, useRef } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import CommonMenu from './common-menu';
|
|
4
|
+
import { setCellStyle } from '../../helpers';
|
|
5
|
+
var CellTextAlignMenu = function CellTextAlignMenu(_ref) {
|
|
6
|
+
var editor = _ref.editor;
|
|
7
|
+
var textAlignRef = useRef(null);
|
|
8
|
+
var _useTranslation = useTranslation(),
|
|
9
|
+
t = _useTranslation.t;
|
|
10
|
+
var setTextAlignStyle = useCallback(function (textAlign) {
|
|
11
|
+
setCellStyle(editor, {
|
|
12
|
+
textAlign: textAlign
|
|
13
|
+
});
|
|
14
|
+
textAlignRef.current && textAlignRef.current.hidePopover();
|
|
15
|
+
}, [editor]);
|
|
16
|
+
return /*#__PURE__*/React.createElement(CommonMenu, {
|
|
17
|
+
id: "text-align",
|
|
18
|
+
iconClass: "sdocfont sdoc-align-left",
|
|
19
|
+
ref: textAlignRef
|
|
20
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
21
|
+
className: "sdoc-dropdown-menu-item",
|
|
22
|
+
onClick: function onClick() {
|
|
23
|
+
return setTextAlignStyle('left');
|
|
24
|
+
}
|
|
25
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
26
|
+
className: "sdocfont sdoc-align-left mr-2"
|
|
27
|
+
}), t('Left')), /*#__PURE__*/React.createElement("div", {
|
|
28
|
+
className: "sdoc-dropdown-menu-item",
|
|
29
|
+
onClick: function onClick() {
|
|
30
|
+
return setTextAlignStyle('center');
|
|
31
|
+
}
|
|
32
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
33
|
+
className: "sdocfont sdoc-align-center mr-2"
|
|
34
|
+
}), t('Center')), /*#__PURE__*/React.createElement("div", {
|
|
35
|
+
className: "sdoc-dropdown-menu-item",
|
|
36
|
+
onClick: function onClick() {
|
|
37
|
+
return setTextAlignStyle('right');
|
|
38
|
+
}
|
|
39
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
40
|
+
className: "sdocfont sdoc-align-right mr-2"
|
|
41
|
+
}), t('Right')));
|
|
42
|
+
};
|
|
43
|
+
export default CellTextAlignMenu;
|
|
@@ -1,174 +1,34 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
-
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
7
|
-
import React, { Component } from 'react';
|
|
1
|
+
import React from 'react';
|
|
8
2
|
import { withTranslation } from 'react-i18next';
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
3
|
+
import { MenuGroup } from '../../../../commons';
|
|
4
|
+
import { isAllInTable } from '../../helpers';
|
|
5
|
+
import CellBgColorMenu from './cell-bg-color-menu';
|
|
6
|
+
import CellTextAlignMenu from './cell-text-align-menu';
|
|
7
|
+
import RemoveTable from './remove-table-menu';
|
|
8
|
+
import TableColumnMenu from './table-column-menu';
|
|
9
|
+
import TableRowMenu from './table-row-menu';
|
|
15
10
|
import './index.css';
|
|
16
|
-
var ActiveTableMenu =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (type === TABLE_ELEMENT.ROW) {
|
|
40
|
-
_this.tableRowRef.hidePopover();
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
_this.tableColumnRef.hidePopover();
|
|
44
|
-
};
|
|
45
|
-
_this.removeTableElement = function (type) {
|
|
46
|
-
var editor = _this.props.editor;
|
|
47
|
-
removeTableElement(editor, type);
|
|
48
|
-
if (type === TABLE_ELEMENT.ROW) {
|
|
49
|
-
_this.tableRowRef.hidePopover();
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
_this.tableColumnRef.hidePopover();
|
|
53
|
-
};
|
|
54
|
-
_this.removeTable = function () {
|
|
55
|
-
var editor = _this.props.editor;
|
|
56
|
-
removeTableElement(editor, TABLE_ELEMENT.TABLE);
|
|
57
|
-
};
|
|
58
|
-
_this.renderTextAlign = function () {
|
|
59
|
-
var t = _this.props.t;
|
|
60
|
-
return /*#__PURE__*/React.createElement(CommonMenu, {
|
|
61
|
-
id: "text-align",
|
|
62
|
-
iconClass: "sdocfont sdoc-align-left",
|
|
63
|
-
ref: function ref(_ref) {
|
|
64
|
-
return _this.textAlignRef = _ref;
|
|
65
|
-
}
|
|
66
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
67
|
-
className: "sdoc-dropdown-menu-item",
|
|
68
|
-
onClick: _this.setTextAlignStyle.bind(_assertThisInitialized(_this), 'left')
|
|
69
|
-
}, /*#__PURE__*/React.createElement("i", {
|
|
70
|
-
className: "sdocfont sdoc-align-left mr-2"
|
|
71
|
-
}), t('Left')), /*#__PURE__*/React.createElement("div", {
|
|
72
|
-
className: "sdoc-dropdown-menu-item",
|
|
73
|
-
onClick: _this.setTextAlignStyle.bind(_assertThisInitialized(_this), 'center')
|
|
74
|
-
}, /*#__PURE__*/React.createElement("i", {
|
|
75
|
-
className: "sdocfont sdoc-align-center mr-2"
|
|
76
|
-
}), t('Center')), /*#__PURE__*/React.createElement("div", {
|
|
77
|
-
className: "sdoc-dropdown-menu-item",
|
|
78
|
-
onClick: _this.setTextAlignStyle.bind(_assertThisInitialized(_this), 'right')
|
|
79
|
-
}, /*#__PURE__*/React.createElement("i", {
|
|
80
|
-
className: "sdocfont sdoc-align-right mr-2"
|
|
81
|
-
}), t('Right')));
|
|
82
|
-
};
|
|
83
|
-
_this.renderTableColumn = function () {
|
|
84
|
-
var t = _this.props.t;
|
|
85
|
-
return /*#__PURE__*/React.createElement(CommonMenu, {
|
|
86
|
-
id: "table-column",
|
|
87
|
-
iconClass: "sdocfont sdoc-column",
|
|
88
|
-
ref: function ref(_ref2) {
|
|
89
|
-
return _this.tableColumnRef = _ref2;
|
|
90
|
-
}
|
|
91
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
92
|
-
className: "sdoc-dropdown-menu-item",
|
|
93
|
-
onClick: _this.insertTableElement.bind(_assertThisInitialized(_this), TABLE_ELEMENT.COLUMN)
|
|
94
|
-
}, t('Insert_column')), /*#__PURE__*/React.createElement("div", {
|
|
95
|
-
className: "sdoc-dropdown-menu-item",
|
|
96
|
-
onClick: _this.removeTableElement.bind(_assertThisInitialized(_this), TABLE_ELEMENT.COLUMN)
|
|
97
|
-
}, t('Remove_column')));
|
|
98
|
-
};
|
|
99
|
-
_this.renderTableRow = function () {
|
|
100
|
-
var t = _this.props.t;
|
|
101
|
-
return /*#__PURE__*/React.createElement(CommonMenu, {
|
|
102
|
-
id: "table-row",
|
|
103
|
-
iconClass: "sdocfont sdoc-row",
|
|
104
|
-
ref: function ref(_ref3) {
|
|
105
|
-
return _this.tableRowRef = _ref3;
|
|
106
|
-
}
|
|
107
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
108
|
-
className: "sdoc-dropdown-menu-item",
|
|
109
|
-
onClick: _this.insertTableElement.bind(_assertThisInitialized(_this), TABLE_ELEMENT.ROW)
|
|
110
|
-
}, t('Insert_row')), /*#__PURE__*/React.createElement("div", {
|
|
111
|
-
className: "sdoc-dropdown-menu-item",
|
|
112
|
-
onClick: _this.removeTableElement.bind(_assertThisInitialized(_this), TABLE_ELEMENT.ROW)
|
|
113
|
-
}, t('Remove_row')));
|
|
114
|
-
};
|
|
115
|
-
_this.renderRemoveTable = function () {
|
|
116
|
-
var _this$props = _this.props,
|
|
117
|
-
isRichEditor = _this$props.isRichEditor,
|
|
118
|
-
className = _this$props.className;
|
|
119
|
-
var menuConfig = MENUS_CONFIG_MAP[REMOVE_TABLE];
|
|
120
|
-
var props = _objectSpread(_objectSpread({
|
|
121
|
-
isRichEditor: isRichEditor,
|
|
122
|
-
className: classnames(className, 'sdoc-remove-table menu-group-item'),
|
|
123
|
-
disabled: false,
|
|
124
|
-
isActive: false
|
|
125
|
-
}, menuConfig), {}, {
|
|
126
|
-
onMouseDown: _this.removeTable
|
|
127
|
-
});
|
|
128
|
-
return /*#__PURE__*/React.createElement(MenuItem, props);
|
|
129
|
-
};
|
|
130
|
-
_this.setColor = function (color) {
|
|
131
|
-
var editor = _this.props.editor;
|
|
132
|
-
setCellStyle(editor, {
|
|
133
|
-
bg_color: color
|
|
134
|
-
});
|
|
135
|
-
};
|
|
136
|
-
_this.renderBgColor = function () {
|
|
137
|
-
var _this$props2 = _this.props,
|
|
138
|
-
isRichEditor = _this$props2.isRichEditor,
|
|
139
|
-
className = _this$props2.className;
|
|
140
|
-
var menuConfig = MENUS_CONFIG_MAP[BG_COLOR];
|
|
141
|
-
var lastUsedColor = _this.state.lastUsedColor;
|
|
142
|
-
var props = _objectSpread(_objectSpread({
|
|
143
|
-
isRichEditor: isRichEditor,
|
|
144
|
-
className: className,
|
|
145
|
-
disabled: false,
|
|
146
|
-
isActive: false
|
|
147
|
-
}, menuConfig), {}, {
|
|
148
|
-
onMouseDown: function onMouseDown() {},
|
|
149
|
-
setColor: _this.setColor,
|
|
150
|
-
recentUsedColorsKey: RECENT_USED_TABLE_CELL_BG_COLORS_KEY,
|
|
151
|
-
lastUsedColor: lastUsedColor,
|
|
152
|
-
updateLastUsedColor: _this.updateLastUsedColor,
|
|
153
|
-
popoverClassName: 'sdoc-table-cell-bg-colors-popover'
|
|
154
|
-
});
|
|
155
|
-
return /*#__PURE__*/React.createElement(ColorMenu, props);
|
|
156
|
-
};
|
|
157
|
-
_this.state = {
|
|
158
|
-
lastUsedColor: DEFAULT_LAST_USED_TABLE_CELL_BG_COLOR
|
|
159
|
-
};
|
|
160
|
-
return _this;
|
|
161
|
-
}
|
|
162
|
-
_createClass(ActiveTableMenu, [{
|
|
163
|
-
key: "render",
|
|
164
|
-
value: function render() {
|
|
165
|
-
var editor = this.props.editor;
|
|
166
|
-
if (!isAllInTable(editor)) return null;
|
|
167
|
-
return /*#__PURE__*/React.createElement(MenuGroup, {
|
|
168
|
-
className: "menu-group sdoc-table-menu-group"
|
|
169
|
-
}, this.renderTextAlign(), this.renderTableColumn(), this.renderTableRow(), this.renderBgColor(), this.renderRemoveTable());
|
|
170
|
-
}
|
|
171
|
-
}]);
|
|
172
|
-
return ActiveTableMenu;
|
|
173
|
-
}(Component);
|
|
11
|
+
var ActiveTableMenu = function ActiveTableMenu(_ref) {
|
|
12
|
+
var isRichEditor = _ref.isRichEditor,
|
|
13
|
+
className = _ref.className,
|
|
14
|
+
editor = _ref.editor;
|
|
15
|
+
if (!isAllInTable(editor)) return null;
|
|
16
|
+
return /*#__PURE__*/React.createElement(MenuGroup, {
|
|
17
|
+
className: "menu-group sdoc-table-menu-group"
|
|
18
|
+
}, /*#__PURE__*/React.createElement(CellTextAlignMenu, {
|
|
19
|
+
editor: editor
|
|
20
|
+
}), /*#__PURE__*/React.createElement(TableColumnMenu, {
|
|
21
|
+
editor: editor
|
|
22
|
+
}), /*#__PURE__*/React.createElement(TableRowMenu, {
|
|
23
|
+
editor: editor
|
|
24
|
+
}), /*#__PURE__*/React.createElement(CellBgColorMenu, {
|
|
25
|
+
editor: editor,
|
|
26
|
+
isRichEditor: isRichEditor,
|
|
27
|
+
className: className
|
|
28
|
+
}), /*#__PURE__*/React.createElement(RemoveTable, {
|
|
29
|
+
editor: editor,
|
|
30
|
+
isRichEditor: isRichEditor,
|
|
31
|
+
className: className
|
|
32
|
+
}));
|
|
33
|
+
};
|
|
174
34
|
export default withTranslation('sdoc-editor')(ActiveTableMenu);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import React, { useCallback } from 'react';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import { MenuItem } from '../../../../commons';
|
|
5
|
+
import { MENUS_CONFIG_MAP, REMOVE_TABLE } from '../../../../constants';
|
|
6
|
+
import { removeTableElement } from '../../helpers';
|
|
7
|
+
import { TABLE_ELEMENT } from '../../constants';
|
|
8
|
+
var RemoveTable = function RemoveTable(_ref) {
|
|
9
|
+
var isRichEditor = _ref.isRichEditor,
|
|
10
|
+
className = _ref.className,
|
|
11
|
+
editor = _ref.editor;
|
|
12
|
+
var removeTable = useCallback(function () {
|
|
13
|
+
removeTableElement(editor, TABLE_ELEMENT.TABLE);
|
|
14
|
+
}, [editor]);
|
|
15
|
+
var menuConfig = MENUS_CONFIG_MAP[REMOVE_TABLE];
|
|
16
|
+
var props = _objectSpread(_objectSpread({
|
|
17
|
+
isRichEditor: isRichEditor,
|
|
18
|
+
className: classnames(className, 'sdoc-remove-table menu-group-item'),
|
|
19
|
+
disabled: false,
|
|
20
|
+
isActive: false
|
|
21
|
+
}, menuConfig), {}, {
|
|
22
|
+
onMouseDown: removeTable
|
|
23
|
+
});
|
|
24
|
+
return /*#__PURE__*/React.createElement(MenuItem, props);
|
|
25
|
+
};
|
|
26
|
+
export default RemoveTable;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { useCallback, useRef } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import CommonMenu from './common-menu';
|
|
4
|
+
import { insertTableElement, removeTableElement } from '../../helpers';
|
|
5
|
+
import { TABLE_ELEMENT } from '../../constants';
|
|
6
|
+
var TableColumnMenu = function TableColumnMenu(_ref) {
|
|
7
|
+
var editor = _ref.editor;
|
|
8
|
+
var tableColumnRef = useRef(null);
|
|
9
|
+
var _useTranslation = useTranslation(),
|
|
10
|
+
t = _useTranslation.t;
|
|
11
|
+
var insertColumn = useCallback(function (type) {
|
|
12
|
+
insertTableElement(editor, type);
|
|
13
|
+
tableColumnRef.current && tableColumnRef.current.hidePopover();
|
|
14
|
+
}, [editor]);
|
|
15
|
+
var removeColumn = useCallback(function (type) {
|
|
16
|
+
removeTableElement(editor, type);
|
|
17
|
+
tableColumnRef.current && tableColumnRef.current.hidePopover();
|
|
18
|
+
}, [editor]);
|
|
19
|
+
return /*#__PURE__*/React.createElement(CommonMenu, {
|
|
20
|
+
id: "table-column",
|
|
21
|
+
iconClass: "sdocfont sdoc-column",
|
|
22
|
+
ref: tableColumnRef
|
|
23
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
24
|
+
className: "sdoc-dropdown-menu-item",
|
|
25
|
+
onClick: function onClick() {
|
|
26
|
+
return insertColumn(TABLE_ELEMENT.COLUMN);
|
|
27
|
+
}
|
|
28
|
+
}, t('Insert_column')), /*#__PURE__*/React.createElement("div", {
|
|
29
|
+
className: "sdoc-dropdown-menu-item",
|
|
30
|
+
onClick: function onClick() {
|
|
31
|
+
return removeColumn(TABLE_ELEMENT.COLUMN);
|
|
32
|
+
}
|
|
33
|
+
}, t('Remove_column')));
|
|
34
|
+
};
|
|
35
|
+
export default TableColumnMenu;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { useCallback, useRef } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import CommonMenu from './common-menu';
|
|
4
|
+
import { insertTableElement, removeTableElement } from '../../helpers';
|
|
5
|
+
import { TABLE_ELEMENT } from '../../constants';
|
|
6
|
+
var TableRowMenu = function TableRowMenu(_ref) {
|
|
7
|
+
var editor = _ref.editor;
|
|
8
|
+
var tableRowRef = useRef(null);
|
|
9
|
+
var _useTranslation = useTranslation(),
|
|
10
|
+
t = _useTranslation.t;
|
|
11
|
+
var insertRow = useCallback(function (type) {
|
|
12
|
+
insertTableElement(editor, type);
|
|
13
|
+
tableRowRef.current && tableRowRef.current.hidePopover();
|
|
14
|
+
}, [editor]);
|
|
15
|
+
var removeRow = useCallback(function (type) {
|
|
16
|
+
removeTableElement(editor, type);
|
|
17
|
+
tableRowRef.current && tableRowRef.current.hidePopover();
|
|
18
|
+
}, [editor]);
|
|
19
|
+
return /*#__PURE__*/React.createElement(CommonMenu, {
|
|
20
|
+
id: "table-row",
|
|
21
|
+
iconClass: "sdocfont sdoc-row",
|
|
22
|
+
ref: tableRowRef
|
|
23
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
24
|
+
className: "sdoc-dropdown-menu-item",
|
|
25
|
+
onClick: function onClick() {
|
|
26
|
+
return insertRow(TABLE_ELEMENT.ROW);
|
|
27
|
+
}
|
|
28
|
+
}, t('Insert_row')), /*#__PURE__*/React.createElement("div", {
|
|
29
|
+
className: "sdoc-dropdown-menu-item",
|
|
30
|
+
onClick: function onClick() {
|
|
31
|
+
return removeRow(TABLE_ELEMENT.ROW);
|
|
32
|
+
}
|
|
33
|
+
}, t('Remove_row')));
|
|
34
|
+
};
|
|
35
|
+
export default TableRowMenu;
|
|
@@ -113,6 +113,7 @@ var TableSizePopover = /*#__PURE__*/function (_Component) {
|
|
|
113
113
|
trigger: "legacy",
|
|
114
114
|
placement: "bottom-start",
|
|
115
115
|
hideArrow: true,
|
|
116
|
+
fade: false,
|
|
116
117
|
ref: this.setRef
|
|
117
118
|
}, /*#__PURE__*/React.createElement("div", {
|
|
118
119
|
className: "sdoc-selected-table-size-container w-100 h-100 d-flex flex-column"
|
|
@@ -6,20 +6,18 @@ import { TEXT_STYLE, TEXT_STYLE_MORE, MENUS_CONFIG_MAP, ELEMENT_TYPE } from '../
|
|
|
6
6
|
import { focusEditor } from '../../../core';
|
|
7
7
|
import { MenuItem, ColorMenu, MoreDropdown } from '../../../commons';
|
|
8
8
|
import { getValue, isMenuDisabled, addMark, removeMark } from '../helpers';
|
|
9
|
-
import {
|
|
10
|
-
import { useHighlightColorContext } from '../../../../hooks/use-highlight-color-context';
|
|
9
|
+
import { useColorContext } from '../../../../hooks/use-color-context';
|
|
11
10
|
var TextStyleMenuList = function TextStyleMenuList(_ref) {
|
|
12
11
|
var editor = _ref.editor,
|
|
13
12
|
t = _ref.t,
|
|
14
13
|
isRichEditor = _ref.isRichEditor,
|
|
15
14
|
className = _ref.className,
|
|
16
15
|
idPrefix = _ref.idPrefix;
|
|
17
|
-
var
|
|
18
|
-
lastUsedFontColor =
|
|
19
|
-
updateLastUsedFontColor =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
updateLastUsedHighlightColor = _useHighlightColorCon.updateColor;
|
|
16
|
+
var _useColorContext = useColorContext(),
|
|
17
|
+
lastUsedFontColor = _useColorContext.lastUsedFontColor,
|
|
18
|
+
updateLastUsedFontColor = _useColorContext.updateLastUsedFontColor,
|
|
19
|
+
lastUsedHighlightColor = _useColorContext.lastUsedHighlightColor,
|
|
20
|
+
updateLastUsedHighlightColor = _useColorContext.updateLastUsedHighlightColor;
|
|
23
21
|
var isActive = useCallback(function (type) {
|
|
24
22
|
var isMark = getValue(editor, type);
|
|
25
23
|
return !!isMark;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import React, { useContext, useState } from 'react';
|
|
3
|
+
import { DEFAULT_LAST_USED_FONT_COLOR, DEFAULT_LAST_USED_HIGHLIGHT_COLOR, DEFAULT_LAST_USED_TABLE_CELL_BG_COLOR } from '../extension/constants';
|
|
4
|
+
var ColorContext = React.createContext(null);
|
|
5
|
+
export var ColorProvider = function ColorProvider(props) {
|
|
6
|
+
var _useState = useState(DEFAULT_LAST_USED_FONT_COLOR),
|
|
7
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
8
|
+
lastUsedFontColor = _useState2[0],
|
|
9
|
+
updateLastUsedFontColor = _useState2[1];
|
|
10
|
+
var _useState3 = useState(DEFAULT_LAST_USED_HIGHLIGHT_COLOR),
|
|
11
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
12
|
+
lastUsedHighlightColor = _useState4[0],
|
|
13
|
+
updateLastUsedHighlightColor = _useState4[1];
|
|
14
|
+
var _useState5 = useState(DEFAULT_LAST_USED_TABLE_CELL_BG_COLOR),
|
|
15
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
16
|
+
lastUsedTableCellBgColor = _useState6[0],
|
|
17
|
+
updateLastUsedTableCellBgColor = _useState6[1];
|
|
18
|
+
return /*#__PURE__*/React.createElement(ColorContext.Provider, {
|
|
19
|
+
value: {
|
|
20
|
+
lastUsedFontColor: lastUsedFontColor,
|
|
21
|
+
updateLastUsedFontColor: updateLastUsedFontColor,
|
|
22
|
+
lastUsedHighlightColor: lastUsedHighlightColor,
|
|
23
|
+
updateLastUsedHighlightColor: updateLastUsedHighlightColor,
|
|
24
|
+
lastUsedTableCellBgColor: lastUsedTableCellBgColor,
|
|
25
|
+
updateLastUsedTableCellBgColor: updateLastUsedTableCellBgColor
|
|
26
|
+
}
|
|
27
|
+
}, props.children);
|
|
28
|
+
};
|
|
29
|
+
export var useColorContext = function useColorContext() {
|
|
30
|
+
var context = useContext(ColorContext);
|
|
31
|
+
if (!context) {
|
|
32
|
+
throw new Error('\'ColorContext\' is null');
|
|
33
|
+
}
|
|
34
|
+
var lastUsedFontColor = context.lastUsedFontColor,
|
|
35
|
+
lastUsedHighlightColor = context.lastUsedHighlightColor,
|
|
36
|
+
lastUsedTableCellBgColor = context.lastUsedTableCellBgColor,
|
|
37
|
+
updateLastUsedFontColor = context.updateLastUsedFontColor,
|
|
38
|
+
updateLastUsedHighlightColor = context.updateLastUsedHighlightColor,
|
|
39
|
+
updateLastUsedTableCellBgColor = context.updateLastUsedTableCellBgColor;
|
|
40
|
+
return {
|
|
41
|
+
lastUsedFontColor: lastUsedFontColor,
|
|
42
|
+
updateLastUsedFontColor: updateLastUsedFontColor,
|
|
43
|
+
lastUsedHighlightColor: lastUsedHighlightColor,
|
|
44
|
+
updateLastUsedHighlightColor: updateLastUsedHighlightColor,
|
|
45
|
+
lastUsedTableCellBgColor: lastUsedTableCellBgColor,
|
|
46
|
+
updateLastUsedTableCellBgColor: updateLastUsedTableCellBgColor
|
|
47
|
+
};
|
|
48
|
+
};
|