@seafile/sdoc-editor 1.0.144 → 1.0.146-alpha.0
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/basic-sdk/assets/css/layout.css +0 -1
- package/dist/basic-sdk/comment/components/comment-list.js +1 -18
- package/dist/basic-sdk/comment/components/editor-comment.js +14 -3
- package/dist/basic-sdk/constants/index.js +2 -1
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/filter-setter/filter-popover-widgets/filters-list.css +2 -0
- package/dist/basic-sdk/extension/plugins/table/helpers.js +19 -1
- package/dist/basic-sdk/extension/plugins/table/plugin.js +1 -1
- package/dist/basic-sdk/extension/toolbar/side-toolbar/helpers.js +0 -4
- package/dist/basic-sdk/layout/article-container.js +6 -26
- package/dist/basic-sdk/outline/index.js +4 -4
- package/dist/basic-sdk/right-panel/index.css +1 -1
- package/dist/basic-sdk/right-panel/index.js +10 -3
- package/dist/basic-sdk/utils/default-mode.js +36 -0
- package/dist/basic-sdk/utils/full-width-mode.js +8 -6
- package/dist/components/doc-operations/more-operations.js +1 -3
- package/package.json +1 -1
|
@@ -21,8 +21,7 @@ const CommentList = _ref => {
|
|
|
21
21
|
editor,
|
|
22
22
|
comments,
|
|
23
23
|
activeElement,
|
|
24
|
-
hiddenComment
|
|
25
|
-
deleteUnseenNotifications
|
|
24
|
+
hiddenComment
|
|
26
25
|
} = _ref;
|
|
27
26
|
const commentRef = (0, _react.useRef)(null);
|
|
28
27
|
const position = (0, _useSelectionPosition.useCommentListPosition)(activeElement);
|
|
@@ -66,22 +65,6 @@ const CommentList = _ref => {
|
|
|
66
65
|
insertComment(elementId, comment);
|
|
67
66
|
setIsShowCommentDetail(true);
|
|
68
67
|
}, [insertComment, activeElement === null || activeElement === void 0 ? void 0 : activeElement.id]);
|
|
69
|
-
const onClickOutSide = (0, _react.useCallback)(e => {
|
|
70
|
-
const commentWrapper = commentRef.current;
|
|
71
|
-
const clickIsInComment = commentWrapper && commentWrapper.contains(e.target) && commentWrapper !== e.target;
|
|
72
|
-
if (clickIsInComment) return;
|
|
73
|
-
hiddenComment();
|
|
74
|
-
}, [hiddenComment]);
|
|
75
|
-
(0, _react.useEffect)(() => {
|
|
76
|
-
document.addEventListener('click', onClickOutSide);
|
|
77
|
-
commentRef.current.scrollIntoView({
|
|
78
|
-
behavior: 'smooth',
|
|
79
|
-
block: 'nearest'
|
|
80
|
-
});
|
|
81
|
-
return () => {
|
|
82
|
-
document.removeEventListener('click', onClickOutSide);
|
|
83
|
-
};
|
|
84
|
-
}, [onClickOutSide]);
|
|
85
68
|
const setCurrentCommentGroup = (0, _react.useCallback)(() => {
|
|
86
69
|
setIsShowCommentDetail(true);
|
|
87
70
|
}, []);
|
|
@@ -15,6 +15,7 @@ var _useSelectionElement = require("../../hooks/use-selection-element");
|
|
|
15
15
|
var _useCommentContext = require("../hooks/comment-hooks/use-comment-context");
|
|
16
16
|
var _elementsCommentCount = _interopRequireDefault(require("./elements-comment-count"));
|
|
17
17
|
var _eventBus = _interopRequireDefault(require("../../../basic-sdk/utils/event-bus"));
|
|
18
|
+
var _localStorageUtils = _interopRequireDefault(require("../../../utils/local-storage-utils"));
|
|
18
19
|
var _index = require("../utils/index");
|
|
19
20
|
var _constants = require("../../extension/constants");
|
|
20
21
|
var _constants2 = require("../../constants");
|
|
@@ -68,11 +69,21 @@ const EditorComment = _ref => {
|
|
|
68
69
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
69
70
|
}, [element_comments_map]);
|
|
70
71
|
(0, _react.useEffect)(() => {
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
const settings = _localStorageUtils.default.getItem(_constants3.SDOC_STORAGE) || {};
|
|
73
|
+
_localStorageUtils.default.setItem(_constants3.SDOC_STORAGE, {
|
|
74
|
+
...settings,
|
|
75
|
+
isShowComments
|
|
74
76
|
});
|
|
77
|
+
const eventBus = _eventBus.default.getInstance();
|
|
78
|
+
eventBus.dispatch(_constants3.INTERNAL_EVENT.RESIZE_ARTICLE);
|
|
75
79
|
}, [isShowComments]);
|
|
80
|
+
(0, _react.useEffect)(() => {
|
|
81
|
+
// Close when the currently selected element changes
|
|
82
|
+
if (isShowComments) {
|
|
83
|
+
hiddenComment();
|
|
84
|
+
}
|
|
85
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
86
|
+
}, [currentSelectionElement]);
|
|
76
87
|
const cursor = (0, _helper.useCursorPosition)();
|
|
77
88
|
const style = (0, _react.useMemo)(() => {
|
|
78
89
|
var _Node$string;
|
|
@@ -17,7 +17,7 @@ Object.defineProperty(exports, "PLUGIN_DISPLAY_TYPE", {
|
|
|
17
17
|
return _plugin.PLUGIN_DISPLAY_TYPE;
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
exports.Z_INDEX = exports.WIKI_OUTLINE = exports.WIKI_EDITOR = exports.RIGHT_COMMENT_WIDTH = exports.REVISION_DIFF_VALUE = exports.REVISION_DIFF_KEY = exports.REBASE_TYPES = exports.REBASE_TYPE = exports.REBASE_ORIGIN = exports.REBASE_MARK_KEY = exports.REBASE_MARKS = void 0;
|
|
20
|
+
exports.Z_INDEX = exports.WIKI_OUTLINE = exports.WIKI_EDITOR = exports.SDOC_STORAGE = exports.RIGHT_COMMENT_WIDTH = exports.REVISION_DIFF_VALUE = exports.REVISION_DIFF_KEY = exports.REBASE_TYPES = exports.REBASE_TYPE = exports.REBASE_ORIGIN = exports.REBASE_MARK_KEY = exports.REBASE_MARKS = void 0;
|
|
21
21
|
var Z_INDEX = _interopRequireWildcard(require("./z-index"));
|
|
22
22
|
exports.Z_INDEX = Z_INDEX;
|
|
23
23
|
var _plugin = require("./plugin");
|
|
@@ -86,6 +86,7 @@ const REBASE_ORIGIN = exports.REBASE_ORIGIN = {
|
|
|
86
86
|
const REBASE_MARKS = exports.REBASE_MARKS = [REBASE_MARK_KEY.ORIGIN, REBASE_MARK_KEY.REBASE_TYPE, REBASE_MARK_KEY.MODIFY_TYPE, REBASE_MARK_KEY.OLD_ELEMENT];
|
|
87
87
|
const DIFF_VIEWER = exports.DIFF_VIEWER = 'diff_viewer';
|
|
88
88
|
const FULL_WIDTH_MODE = exports.FULL_WIDTH_MODE = 'full-width-mode';
|
|
89
|
+
const SDOC_STORAGE = exports.SDOC_STORAGE = 'sdoc';
|
|
89
90
|
|
|
90
91
|
// left outline and right comment width
|
|
91
92
|
const LEFT_OUTLINE_WIDTH = exports.LEFT_OUTLINE_WIDTH = 280;
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.updateTableRowHeight = exports.updateColumnWidth = exports.splitCell = exports.setTableSelectedRange = exports.setTableFragmentData = exports.setCellStyle = exports.removeTableElement = exports.removeTable = exports.normalizeTableELement = exports.moveRows = exports.moveColumns = exports.isTableWidthFitScreen = exports.isTableMenuDisabled = exports.isTableLocation = exports.isSelectedAllCell = exports.isPreventResetTableSelectedRange = exports.isLastTableCell = exports.isInTable = exports.isHideDragHandlerLine = exports.isCursorAtCellStart = exports.isCursorAtCellEnd = exports.isCombineCellsDisabled = exports.isAllInTable = exports.insertTableRow = exports.insertTableElement = exports.insertTableColumn = exports.insertTableByTemplate = exports.insertTable = exports.insertMultipleRowsAndColumns = exports.handleInsertTable = exports.handleCombinedCellsBeforeDeleteTableRow = exports.handleCombinedCellsBeforeDeleteTableColumn = exports.handleCombinedCellsAfterInsertTableRow = exports.handleCombinedCellsAfterInsertTableColumn = exports.getTableSelectedRangeAfterDrag = exports.getTableRowSelectedRange = exports.getTableDragType = exports.getTableColumnsWidth = exports.getTableColumnsAfterInsertColumn = exports.getTableColumns = exports.getTableColumnSelectedRange = exports.getSelectedInfo = exports.getRowHeight = exports.getRowDomHeight = exports.getResizeMaskCellInfo = exports.getInsertPosition = exports.getHighlightClass = exports.getFirstTableCell = exports.getCellInheritStyles = exports.getCellHighlightClassName = exports.getCellColumn = exports.generateTableRow = exports.generateTableCell = exports.generateInheritStyle = exports.generateEmptyTable = exports.generateDragMoveElement = exports.focusClosestCellWhenJustifyCellSize = exports.focusCell = exports.fitTableColumnToScreen = exports.elementHasImage = exports.deleteTableSelectCells = exports.deleteTableRangeData = exports.deleteHandler = exports.combineCells = exports.colorBlend = exports.adjustCombinedCellRange = void 0;
|
|
7
|
+
exports.updateTableRowHeight = exports.updateColumnWidth = exports.splitCell = exports.setTableSelectedRange = exports.setTableFragmentData = exports.setCellStyle = exports.removeTableElement = exports.removeTable = exports.normalizeTableELement = exports.moveRows = exports.moveColumns = exports.isTableWidthFitScreen = exports.isTableMenuDisabled = exports.isTableLocation = exports.isSelectedAllCell = exports.isPreventResetTableSelectedRange = exports.isLastTableCell = exports.isInTableSameCell = exports.isInTable = exports.isHideDragHandlerLine = exports.isCursorAtCellStart = exports.isCursorAtCellEnd = exports.isCombineCellsDisabled = exports.isAllInTable = exports.insertTableRow = exports.insertTableElement = exports.insertTableColumn = exports.insertTableByTemplate = exports.insertTable = exports.insertMultipleRowsAndColumns = exports.handleInsertTable = exports.handleCombinedCellsBeforeDeleteTableRow = exports.handleCombinedCellsBeforeDeleteTableColumn = exports.handleCombinedCellsAfterInsertTableRow = exports.handleCombinedCellsAfterInsertTableColumn = exports.getTableSelectedRangeAfterDrag = exports.getTableRowSelectedRange = exports.getTableDragType = exports.getTableColumnsWidth = exports.getTableColumnsAfterInsertColumn = exports.getTableColumns = exports.getTableColumnSelectedRange = exports.getSelectedInfo = exports.getRowHeight = exports.getRowDomHeight = exports.getResizeMaskCellInfo = exports.getInsertPosition = exports.getHighlightClass = exports.getFirstTableCell = exports.getCellInheritStyles = exports.getCellHighlightClassName = exports.getCellColumn = exports.generateTableRow = exports.generateTableCell = exports.generateInheritStyle = exports.generateEmptyTable = exports.generateDragMoveElement = exports.focusClosestCellWhenJustifyCellSize = exports.focusCell = exports.fitTableColumnToScreen = exports.elementHasImage = exports.deleteTableSelectCells = exports.deleteTableRangeData = exports.deleteHandler = exports.combineCells = exports.colorBlend = exports.adjustCombinedCellRange = void 0;
|
|
8
8
|
var _slugid = _interopRequireDefault(require("slugid"));
|
|
9
9
|
var _slate = require("@seafile/slate");
|
|
10
10
|
var _slateReact = require("@seafile/slate-react");
|
|
@@ -192,6 +192,24 @@ const isAllInTable = editor => {
|
|
|
192
192
|
return selectedNodes.slice(1).every(node => [_constants.ELEMENT_TYPE.TABLE_ROW, _constants.ELEMENT_TYPE.TABLE_CELL].includes(node.type)); // same table element
|
|
193
193
|
};
|
|
194
194
|
exports.isAllInTable = isAllInTable;
|
|
195
|
+
const isInTableSameCell = editor => {
|
|
196
|
+
const {
|
|
197
|
+
anchor,
|
|
198
|
+
focus
|
|
199
|
+
} = editor.selection;
|
|
200
|
+
const match = n => n.type === _constants.ELEMENT_TYPE.TABLE_CELL;
|
|
201
|
+
const anchorNode = (0, _core.getAboveBlockNode)(editor, {
|
|
202
|
+
at: anchor,
|
|
203
|
+
match
|
|
204
|
+
});
|
|
205
|
+
const focusNode = (0, _core.getAboveBlockNode)(editor, {
|
|
206
|
+
at: focus,
|
|
207
|
+
match
|
|
208
|
+
});
|
|
209
|
+
if (!anchorNode || !focusNode) return false;
|
|
210
|
+
return _slate.Path.equals(anchorNode[1], focusNode[1]);
|
|
211
|
+
};
|
|
212
|
+
exports.isInTableSameCell = isInTableSameCell;
|
|
195
213
|
const setCellStyle = (editor, style) => {
|
|
196
214
|
// Select single cell
|
|
197
215
|
if (_objectUtils.default.isSameObject(editor.tableSelectedRange, _constants2.EMPTY_SELECTED_RANGE)) {
|
|
@@ -278,7 +278,7 @@ const withTable = editor => {
|
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
|
-
if (_slate.Range.isRange(selection) && (0, _helpers.isAllInTable)(editor)) {
|
|
281
|
+
if (_slate.Range.isRange(selection) && (0, _helpers.isAllInTable)(editor) && !(0, _helpers.isInTableSameCell)(editor)) {
|
|
282
282
|
const [node] = (0, _core.getTopLevelBlockNode)(editor);
|
|
283
283
|
if (_slate.Range.isRange(selection) && (node === null || node === void 0 ? void 0 : node.type) === _constants.ELEMENT_TYPE.TABLE) {
|
|
284
284
|
newEditor.deleteBackward();
|
|
@@ -93,10 +93,6 @@ const onCopyNode = (editor, element) => {
|
|
|
93
93
|
};
|
|
94
94
|
exports.onCopyNode = onCopyNode;
|
|
95
95
|
const onDeleteNode = (editor, element) => {
|
|
96
|
-
if (element.type === _constants.CALL_OUT) {
|
|
97
|
-
(0, _helper.unwrapCallout)(editor);
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
96
|
const path = _slateReact.ReactEditor.findPath(editor, element);
|
|
101
97
|
_slate.Transforms.removeNodes(editor, {
|
|
102
98
|
at: path
|
|
@@ -7,11 +7,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = ArticleContainer;
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _outline = require("../outline");
|
|
11
10
|
var _eventBus = _interopRequireDefault(require("../utils/event-bus"));
|
|
12
11
|
var _useScrollContext = require("../hooks/use-scroll-context");
|
|
13
12
|
var _localStorageUtils = _interopRequireDefault(require("../../utils/local-storage-utils"));
|
|
14
13
|
var _fullWidthMode = require("../utils/full-width-mode");
|
|
14
|
+
var _defaultMode = require("../utils/default-mode");
|
|
15
15
|
var _constants = require("../constants");
|
|
16
16
|
function ArticleContainer(_ref) {
|
|
17
17
|
let {
|
|
@@ -20,45 +20,25 @@ function ArticleContainer(_ref) {
|
|
|
20
20
|
} = _ref;
|
|
21
21
|
const scrollRef = (0, _useScrollContext.useScrollContext)();
|
|
22
22
|
const articleRef = (0, _react.useRef)(null);
|
|
23
|
-
const articleFullWidthModeRef = (0, _react.useRef)({});
|
|
24
23
|
const [containerStyle, setContainerStyle] = (0, _react.useState)({});
|
|
25
24
|
(0, _react.useEffect)(() => {
|
|
26
25
|
editor.width = articleRef.current.children[0].clientWidth;
|
|
27
26
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
28
27
|
}, []);
|
|
29
|
-
const handleWidthModeSize = (0, _react.useCallback)(() => {
|
|
30
|
-
const isFullWidth = _localStorageUtils.default.getItem(_constants.FULL_WIDTH_MODE);
|
|
31
|
-
if (!isFullWidth) return;
|
|
32
|
-
const containerStyle = (0, _fullWidthMode.getStyleByFullWidthMode)(articleFullWidthModeRef, scrollRef, editor);
|
|
33
|
-
setContainerStyle(containerStyle);
|
|
34
|
-
}, [editor, scrollRef]);
|
|
35
28
|
const handleWindowResize = (0, _react.useCallback)(function () {
|
|
36
29
|
let {
|
|
37
30
|
scrollIntoArticle = false,
|
|
38
|
-
isFullWidth = _localStorageUtils.default.getItem(_constants.FULL_WIDTH_MODE)
|
|
39
|
-
isHasComments
|
|
31
|
+
isFullWidth = _localStorageUtils.default.getItem(_constants.FULL_WIDTH_MODE)
|
|
40
32
|
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
41
|
-
const isShowOutline = (0, _outline.getOutlineSetting)();
|
|
42
|
-
|
|
43
33
|
// Full width mode
|
|
44
34
|
if (isFullWidth) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
handleWidthModeSize();
|
|
35
|
+
const containerStyle = (0, _fullWidthMode.getStyleByFullWidthMode)(scrollRef, editor);
|
|
36
|
+
setContainerStyle(containerStyle);
|
|
48
37
|
return;
|
|
49
38
|
}
|
|
50
39
|
|
|
51
|
-
//
|
|
52
|
-
const containerStyle =
|
|
53
|
-
width: _constants.ARTICLE_MIN_WIDTH
|
|
54
|
-
};
|
|
55
|
-
const rect = scrollRef.current.getBoundingClientRect();
|
|
56
|
-
const articleRect = articleRef.current.getBoundingClientRect();
|
|
57
|
-
if (isShowOutline && editor.editorType !== _constants.WIKI_EDITOR && (rect.width - articleRect.width) / 2 < 280) {
|
|
58
|
-
containerStyle['marginLeft'] = '280px';
|
|
59
|
-
} else {
|
|
60
|
-
containerStyle['marginLeft'] = 'auto';
|
|
61
|
-
}
|
|
40
|
+
// Default mode
|
|
41
|
+
const containerStyle = (0, _defaultMode.getStyleByDefaultMode)(scrollRef, editor);
|
|
62
42
|
setContainerStyle(containerStyle);
|
|
63
43
|
if (scrollIntoArticle) {
|
|
64
44
|
articleRef.current.scrollIntoView({
|
|
@@ -15,7 +15,7 @@ var _outlineItem = _interopRequireDefault(require("./outline-item"));
|
|
|
15
15
|
var _tooltip = _interopRequireDefault(require("../../components/tooltip"));
|
|
16
16
|
require("./style.css");
|
|
17
17
|
const getOutlineSetting = () => {
|
|
18
|
-
const currentValue = localStorage.getItem(
|
|
18
|
+
const currentValue = localStorage.getItem(_constants.SDOC_STORAGE);
|
|
19
19
|
const config = currentValue ? JSON.parse(currentValue) : {};
|
|
20
20
|
const {
|
|
21
21
|
outlineOpen = false
|
|
@@ -24,10 +24,10 @@ const getOutlineSetting = () => {
|
|
|
24
24
|
};
|
|
25
25
|
exports.getOutlineSetting = getOutlineSetting;
|
|
26
26
|
const setOutlineSetting = isShown => {
|
|
27
|
-
const currentValue = localStorage.getItem(
|
|
27
|
+
const currentValue = localStorage.getItem(_constants.SDOC_STORAGE);
|
|
28
28
|
const config = currentValue ? JSON.parse(currentValue) : {};
|
|
29
29
|
config['outlineOpen'] = isShown;
|
|
30
|
-
localStorage.setItem(
|
|
30
|
+
localStorage.setItem(_constants.SDOC_STORAGE, JSON.stringify(config));
|
|
31
31
|
};
|
|
32
32
|
exports.setOutlineSetting = setOutlineSetting;
|
|
33
33
|
const SDocOutline = _ref => {
|
|
@@ -41,7 +41,7 @@ const SDocOutline = _ref => {
|
|
|
41
41
|
setIsShown(state);
|
|
42
42
|
setOutlineSetting(state);
|
|
43
43
|
const eventBus = _eventBus.default.getInstance();
|
|
44
|
-
eventBus.dispatch(_constants.INTERNAL_EVENT.OUTLINE_STATE_CHANGED
|
|
44
|
+
eventBus.dispatch(_constants.INTERNAL_EVENT.OUTLINE_STATE_CHANGED);
|
|
45
45
|
}, []);
|
|
46
46
|
(0, _react.useEffect)(() => {
|
|
47
47
|
const outlineState = getOutlineSetting();
|
|
@@ -9,6 +9,7 @@ exports.default = void 0;
|
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _hooks = require("../../hooks");
|
|
11
11
|
var _resizeWidth = _interopRequireDefault(require("./resize-width"));
|
|
12
|
+
var _localStorageUtils = _interopRequireDefault(require("../../utils/local-storage-utils"));
|
|
12
13
|
var _constants = require("../constants");
|
|
13
14
|
var _eventBus = _interopRequireDefault(require("../utils/event-bus"));
|
|
14
15
|
require("./index.css");
|
|
@@ -41,8 +42,8 @@ const RightPanel = _ref => {
|
|
|
41
42
|
setWidth(width);
|
|
42
43
|
}, []);
|
|
43
44
|
const resizeWidthEnd = (0, _react.useCallback)(width => {
|
|
44
|
-
const settings = JSON.parse(window.localStorage.getItem(
|
|
45
|
-
window.localStorage.setItem(
|
|
45
|
+
const settings = JSON.parse(window.localStorage.getItem(_constants.SDOC_STORAGE) || '{}');
|
|
46
|
+
window.localStorage.setItem(_constants.SDOC_STORAGE, JSON.stringify({
|
|
46
47
|
...settings,
|
|
47
48
|
panelWidth: width
|
|
48
49
|
}));
|
|
@@ -50,7 +51,7 @@ const RightPanel = _ref => {
|
|
|
50
51
|
eventBus.dispatch(_constants.INTERNAL_EVENT.RESIZE_ARTICLE);
|
|
51
52
|
}, []);
|
|
52
53
|
(0, _react.useEffect)(() => {
|
|
53
|
-
const settings = JSON.parse(window.localStorage.getItem(
|
|
54
|
+
const settings = JSON.parse(window.localStorage.getItem(_constants.SDOC_STORAGE, '{}')) || {};
|
|
54
55
|
const {
|
|
55
56
|
panelWidth
|
|
56
57
|
} = settings;
|
|
@@ -58,6 +59,12 @@ const RightPanel = _ref => {
|
|
|
58
59
|
setWidth(width);
|
|
59
60
|
}, []);
|
|
60
61
|
(0, _react.useEffect)(() => {
|
|
62
|
+
const isShowGlobalComments = displayPluginName === 'sdoc-comment' ? true : false;
|
|
63
|
+
const settings = _localStorageUtils.default.getItem(_constants.SDOC_STORAGE) || {};
|
|
64
|
+
_localStorageUtils.default.setItem(_constants.SDOC_STORAGE, {
|
|
65
|
+
...settings,
|
|
66
|
+
isShowGlobalComments
|
|
67
|
+
});
|
|
61
68
|
const eventBus = _eventBus.default.getInstance();
|
|
62
69
|
eventBus.dispatch(_constants.INTERNAL_EVENT.RESIZE_ARTICLE);
|
|
63
70
|
}, [displayPluginName]);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getStyleByDefaultMode = void 0;
|
|
8
|
+
var _localStorageUtils = _interopRequireDefault(require("../../utils/local-storage-utils"));
|
|
9
|
+
var _constants = require("../constants");
|
|
10
|
+
const getStyleByDefaultMode = (scrollRef, editor) => {
|
|
11
|
+
const sdocStorage = _localStorageUtils.default.getItem(_constants.SDOC_STORAGE) || {};
|
|
12
|
+
const {
|
|
13
|
+
outlineOpen: isShowOutline,
|
|
14
|
+
isShowComments
|
|
15
|
+
} = sdocStorage;
|
|
16
|
+
const containerStyle = {
|
|
17
|
+
width: _constants.ARTICLE_MIN_WIDTH
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// Has outline
|
|
21
|
+
if (isShowOutline && editor.editorType !== _constants.WIKI_EDITOR) {
|
|
22
|
+
const rect = scrollRef.current.getBoundingClientRect();
|
|
23
|
+
if (isShowComments) {
|
|
24
|
+
const outlineRightWidth = Number(_constants.ARTICLE_MIN_WIDTH.slice(0, 3)) + _constants.RIGHT_COMMENT_WIDTH;
|
|
25
|
+
if (rect.width - outlineRightWidth < 280) {
|
|
26
|
+
containerStyle['marginLeft'] = `${_constants.LEFT_OUTLINE_WIDTH}px`;
|
|
27
|
+
return containerStyle;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if ((rect.width - Number(_constants.ARTICLE_MIN_WIDTH.slice(0, 3))) / 2 < 280) {
|
|
31
|
+
containerStyle['marginLeft'] = `${_constants.LEFT_OUTLINE_WIDTH}px`;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return containerStyle;
|
|
35
|
+
};
|
|
36
|
+
exports.getStyleByDefaultMode = getStyleByDefaultMode;
|
|
@@ -6,13 +6,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.getStyleByFullWidthMode = void 0;
|
|
8
8
|
var _localStorageUtils = _interopRequireDefault(require("../../utils/local-storage-utils"));
|
|
9
|
+
var _defaultMode = require("./default-mode");
|
|
9
10
|
var _constants = require("../constants");
|
|
10
|
-
const getStyleByFullWidthMode = (
|
|
11
|
+
const getStyleByFullWidthMode = (scrollRef, editor) => {
|
|
12
|
+
const sdocStorage = _localStorageUtils.default.getItem(_constants.SDOC_STORAGE) || {};
|
|
11
13
|
const {
|
|
12
|
-
isShowOutline,
|
|
13
|
-
isHasComments
|
|
14
|
-
} =
|
|
15
|
-
|
|
14
|
+
outlineOpen: isShowOutline,
|
|
15
|
+
isShowComments: isHasComments
|
|
16
|
+
} = sdocStorage;
|
|
17
|
+
let containerStyle = {};
|
|
16
18
|
containerStyle['width'] = _constants.ARTICLE_FULL_WIDTH;
|
|
17
19
|
|
|
18
20
|
// Has outline and comments
|
|
@@ -26,8 +28,8 @@ const getStyleByFullWidthMode = (articleFullWidthModeRef, scrollRef, editor) =>
|
|
|
26
28
|
containerStyle['marginLeft'] = `${_constants.LEFT_OUTLINE_WIDTH}px`;
|
|
27
29
|
containerStyle['width'] = containerStyle['width'].slice(0, -1) + ` - ${leftWidth + rightWidth}px`;
|
|
28
30
|
} else {
|
|
29
|
-
containerStyle['width'] = _constants.ARTICLE_MIN_WIDTH;
|
|
30
31
|
_localStorageUtils.default.setItem(_constants.FULL_WIDTH_MODE, false);
|
|
32
|
+
containerStyle = (0, _defaultMode.getStyleByDefaultMode)(scrollRef, editor);
|
|
31
33
|
}
|
|
32
34
|
return containerStyle;
|
|
33
35
|
}
|
|
@@ -80,9 +80,7 @@ const MoreOperations = _ref => {
|
|
|
80
80
|
const newMode = !isFullWidthMode;
|
|
81
81
|
_localStorageUtils.default.setItem(_constants2.FULL_WIDTH_MODE, newMode);
|
|
82
82
|
const eventBus = _basicSdk.EventBus.getInstance();
|
|
83
|
-
eventBus.dispatch(_constants2.INTERNAL_EVENT.RESIZE_ARTICLE
|
|
84
|
-
isFullWidth: newMode
|
|
85
|
-
});
|
|
83
|
+
eventBus.dispatch(_constants2.INTERNAL_EVENT.RESIZE_ARTICLE);
|
|
86
84
|
setIsFullWidthMode(newMode);
|
|
87
85
|
}, [isFullWidthMode]);
|
|
88
86
|
return /*#__PURE__*/_react.default.createElement(_reactstrap.Dropdown, {
|