@seafile/sdoc-editor 0.1.154 → 0.1.155
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/comment/comment-decorate.js +1 -1
- package/dist/basic-sdk/extension/constants/color.js +2 -2
- package/dist/basic-sdk/extension/constants/diff-view.js +2 -2
- package/dist/basic-sdk/extension/constants/index.js +2 -2
- package/dist/basic-sdk/extension/constants/menus-config.js +0 -5
- package/dist/basic-sdk/extension/plugins/file-link/render-elem.js +2 -2
- package/dist/basic-sdk/extension/plugins/sdoc-link/render-elem.js +2 -2
- package/dist/basic-sdk/extension/plugins/table/constants/index.js +3 -3
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/cell-bg-color-menu.js +13 -9
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/index.js +2 -2
- package/dist/basic-sdk/extension/plugins/table/render/render-cell.js +11 -11
- package/dist/basic-sdk/extension/plugins/text-style/render-elem.js +2 -2
- package/dist/basic-sdk/hooks/use-color-context.js +10 -10
- package/dist/basic-sdk/views/diff-viewer.js +1 -1
- package/package.json +1 -1
|
@@ -23,7 +23,7 @@ export var commentDecorate = function commentDecorate(editor) {
|
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
// rgba prevents occlusion of the cursor
|
|
26
|
-
decoration['
|
|
26
|
+
decoration['computed_background_color'] = 'rgba(129, 237, 247, 0.5)';
|
|
27
27
|
decoration['comment_count'] = unresolvedComments === null || unresolvedComments === void 0 ? void 0 : unresolvedComments.length;
|
|
28
28
|
decorations.push(decoration);
|
|
29
29
|
}
|
|
@@ -268,9 +268,9 @@ export var DEFAULT_FONT_COLOR = '#333333';
|
|
|
268
268
|
// default last used color
|
|
269
269
|
export var DEFAULT_LAST_USED_FONT_COLOR = '#FFFF00';
|
|
270
270
|
export var DEFAULT_LAST_USED_HIGHLIGHT_COLOR = '#FF0000';
|
|
271
|
-
export var
|
|
271
|
+
export var DEFAULT_LAST_USED_TABLE_CELL_BACKGROUND_COLOR = '#FF0000';
|
|
272
272
|
|
|
273
273
|
// recent used colors key
|
|
274
274
|
export var RECENT_USED_HIGHLIGHT_COLORS_KEY = 'sdoc-recent-used-highlight-colors';
|
|
275
275
|
export var RECENT_USED_FONT_COLORS_KEY = 'sdoc-recent-used-font-colors';
|
|
276
|
-
export var
|
|
276
|
+
export var RECENT_USED_TABLE_CELL_BACKGROUND_COLORS_KEY = 'sdoc-recent-used-bg-colors';
|
|
@@ -5,10 +5,10 @@ export var DIFF_TYPE = {
|
|
|
5
5
|
COMMON: 'common'
|
|
6
6
|
};
|
|
7
7
|
export var DELETED_STYLE = {
|
|
8
|
-
|
|
8
|
+
computed_background_color: '#ffeef0',
|
|
9
9
|
color: 'rgb(165, 32, 21)'
|
|
10
10
|
};
|
|
11
11
|
export var ADDED_STYLE = {
|
|
12
|
-
|
|
12
|
+
computed_background_color: '#e6ffed',
|
|
13
13
|
color: 'rgb(137, 181, 66)'
|
|
14
14
|
};
|
|
@@ -3,11 +3,11 @@ var _HEADER_TITLE_MAP;
|
|
|
3
3
|
// extension plugin
|
|
4
4
|
import * as ELEMENT_TYPE from './element-type';
|
|
5
5
|
import { BLOCKQUOTE, TITLE, SUBTITLE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM, LIST_LIC, CHECK_LIST_ITEM, CODE_BLOCK, CODE_LINE, TABLE, TABLE_CELL, TABLE_ROW, LINK, SDOC_LINK, FILE_LINK, IMAGE } from './element-type';
|
|
6
|
-
export { DEFAULT_COLORS, STANDARD_COLORS, DEFAULT_RECENT_USED_LIST, DEFAULT_FONT_COLOR, RECENT_USED_HIGHLIGHT_COLORS_KEY, RECENT_USED_FONT_COLORS_KEY,
|
|
6
|
+
export { DEFAULT_COLORS, STANDARD_COLORS, DEFAULT_RECENT_USED_LIST, DEFAULT_FONT_COLOR, RECENT_USED_HIGHLIGHT_COLORS_KEY, RECENT_USED_FONT_COLORS_KEY, RECENT_USED_TABLE_CELL_BACKGROUND_COLORS_KEY, DEFAULT_LAST_USED_FONT_COLOR, DEFAULT_LAST_USED_HIGHLIGHT_COLOR, DEFAULT_LAST_USED_TABLE_CELL_BACKGROUND_COLOR } from './color';
|
|
7
7
|
export { FONT_SIZE, DEFAULT_FONT, FONT, GOOGLE_FONT_CLASS, RECENT_USED_FONTS_KEY, SDOC_FONT_SIZE } from './font';
|
|
8
8
|
export { DIFF_TYPE, ADDED_STYLE, DELETED_STYLE } from './diff-view';
|
|
9
9
|
export { KEYBOARD, MAC_HOTKEYS, WIN_HOTKEYS } from './keyboard';
|
|
10
|
-
export { UNDO, REDO, TEXT_STYLE, TEXT_STYLE_MAP, TEXT_STYLE_MORE, TEXT_ALIGN, REMOVE_TABLE,
|
|
10
|
+
export { UNDO, REDO, TEXT_STYLE, TEXT_STYLE_MAP, TEXT_STYLE_MORE, TEXT_ALIGN, REMOVE_TABLE, CLEAR_FORMAT, MENUS_CONFIG_MAP, SIDE_MENUS_CONFIG } from './menus-config';
|
|
11
11
|
export var HEADERS = [HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6];
|
|
12
12
|
export var HEADER_TITLE_MAP = (_HEADER_TITLE_MAP = {}, _defineProperty(_HEADER_TITLE_MAP, TITLE, 'Title'), _defineProperty(_HEADER_TITLE_MAP, SUBTITLE, 'Subtitle'), _defineProperty(_HEADER_TITLE_MAP, HEADER1, 'Header_one'), _defineProperty(_HEADER_TITLE_MAP, HEADER2, 'Header_two'), _defineProperty(_HEADER_TITLE_MAP, HEADER3, 'Header_three'), _defineProperty(_HEADER_TITLE_MAP, HEADER4, 'Header_four'), _defineProperty(_HEADER_TITLE_MAP, HEADER5, 'Header_five'), _defineProperty(_HEADER_TITLE_MAP, HEADER6, 'Header_six'), _defineProperty(_HEADER_TITLE_MAP, PARAGRAPH, 'Paragraph'), _HEADER_TITLE_MAP);
|
|
13
13
|
export var LIST_TYPE_ARRAY = ['unordered_list', 'ordered_list'];
|
|
@@ -6,7 +6,6 @@ export var UNDO = 'undo';
|
|
|
6
6
|
export var REDO = 'redo';
|
|
7
7
|
export var CLEAR_FORMAT = 'clear_format';
|
|
8
8
|
export var REMOVE_TABLE = 'remove_table';
|
|
9
|
-
export var BG_COLOR = 'bg_color';
|
|
10
9
|
|
|
11
10
|
// text style
|
|
12
11
|
var ITALIC = 'italic';
|
|
@@ -142,10 +141,6 @@ export var MENUS_CONFIG_MAP = (_MENUS_CONFIG_MAP = {}, _defineProperty(_MENUS_CO
|
|
|
142
141
|
iconClass: 'sdocfont sdoc-redo',
|
|
143
142
|
text: 'Redo',
|
|
144
143
|
type: 'redo'
|
|
145
|
-
}), _defineProperty(_MENUS_CONFIG_MAP, BG_COLOR, {
|
|
146
|
-
id: "sdoc_".concat(BG_COLOR),
|
|
147
|
-
iconClass: 'sdocfont sdoc-bg-color',
|
|
148
|
-
text: 'Background_color'
|
|
149
144
|
}), _defineProperty(_MENUS_CONFIG_MAP, CLEAR_FORMAT, {
|
|
150
145
|
id: "sdoc_".concat(CLEAR_FORMAT),
|
|
151
146
|
iconClass: 'sdocfont sdoc-format-clear',
|
|
@@ -98,8 +98,8 @@ var FileLink = function FileLink(_ref) {
|
|
|
98
98
|
} else if (element.DELETE) {
|
|
99
99
|
style = _objectSpread({}, DELETED_STYLE);
|
|
100
100
|
}
|
|
101
|
-
if (style.
|
|
102
|
-
style['backgroundColor'] = style.
|
|
101
|
+
if (style.computed_background_color) {
|
|
102
|
+
style['backgroundColor'] = style.computed_background_color;
|
|
103
103
|
}
|
|
104
104
|
return /*#__PURE__*/React.createElement("span", Object.assign({}, attributes, {
|
|
105
105
|
"data-id": element.id,
|
|
@@ -97,8 +97,8 @@ var SdocFileLink = function SdocFileLink(_ref) {
|
|
|
97
97
|
} else if (element.DELETE) {
|
|
98
98
|
style = _objectSpread({}, DELETED_STYLE);
|
|
99
99
|
}
|
|
100
|
-
if (style.
|
|
101
|
-
style['backgroundColor'] = style.
|
|
100
|
+
if (style.computed_background_color) {
|
|
101
|
+
style['backgroundColor'] = style.computed_background_color;
|
|
102
102
|
}
|
|
103
103
|
return /*#__PURE__*/React.createElement("span", Object.assign({}, attributes, {
|
|
104
104
|
"data-id": element.id,
|
|
@@ -21,8 +21,8 @@ export var TABLE_ELEMENT_POSITION = {
|
|
|
21
21
|
AFTER: 'after',
|
|
22
22
|
BEFORE: 'before'
|
|
23
23
|
};
|
|
24
|
-
export var
|
|
25
|
-
export var
|
|
24
|
+
export var SELECTED_TABLE_CELL_BACKGROUND_COLOR = '#dee8fe';
|
|
25
|
+
export var TABLE_CELL_STYLE = {
|
|
26
26
|
TEXT_ALIGN: 'textAlign',
|
|
27
|
-
|
|
27
|
+
BACKGROUND_COLOR: 'bg_color'
|
|
28
28
|
};
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import React, { useCallback } from 'react';
|
|
3
3
|
import { ColorMenu } from '../../../../commons';
|
|
4
|
-
import {
|
|
4
|
+
import { RECENT_USED_TABLE_CELL_BACKGROUND_COLORS_KEY } from '../../../../constants';
|
|
5
5
|
import { setCellStyle } from '../../helpers';
|
|
6
6
|
import { useColorContext } from '../../../../../hooks/use-color-context';
|
|
7
|
-
var
|
|
7
|
+
var menuConfig = {
|
|
8
|
+
id: 'sdoc_background_color',
|
|
9
|
+
iconClass: 'sdocfont sdoc-bg-color',
|
|
10
|
+
text: 'Background_color'
|
|
11
|
+
};
|
|
12
|
+
var CellBackgroundColorMenu = function CellBackgroundColorMenu(_ref) {
|
|
8
13
|
var isRichEditor = _ref.isRichEditor,
|
|
9
14
|
className = _ref.className,
|
|
10
15
|
editor = _ref.editor;
|
|
11
16
|
var _useColorContext = useColorContext(),
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var menuConfig = MENUS_CONFIG_MAP[BG_COLOR];
|
|
17
|
+
lastUsedTableCellBackgroundColor = _useColorContext.lastUsedTableCellBackgroundColor,
|
|
18
|
+
updateLastUsedTableCellBackgroundColor = _useColorContext.updateLastUsedTableCellBackgroundColor;
|
|
15
19
|
var setColor = useCallback(function (color) {
|
|
16
20
|
setCellStyle(editor, {
|
|
17
21
|
bg_color: color
|
|
@@ -25,11 +29,11 @@ var CellBgColorMenu = function CellBgColorMenu(_ref) {
|
|
|
25
29
|
}, menuConfig), {}, {
|
|
26
30
|
onMouseDown: function onMouseDown() {},
|
|
27
31
|
setColor: setColor,
|
|
28
|
-
recentUsedColorsKey:
|
|
29
|
-
lastUsedColor:
|
|
30
|
-
updateLastUsedColor:
|
|
32
|
+
recentUsedColorsKey: RECENT_USED_TABLE_CELL_BACKGROUND_COLORS_KEY,
|
|
33
|
+
lastUsedColor: lastUsedTableCellBackgroundColor,
|
|
34
|
+
updateLastUsedColor: updateLastUsedTableCellBackgroundColor,
|
|
31
35
|
popoverClassName: 'sdoc-table-cell-bg-colors-popover'
|
|
32
36
|
});
|
|
33
37
|
return /*#__PURE__*/React.createElement(ColorMenu, props);
|
|
34
38
|
};
|
|
35
|
-
export default
|
|
39
|
+
export default CellBackgroundColorMenu;
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { withTranslation } from 'react-i18next';
|
|
3
3
|
import { MenuGroup } from '../../../../commons';
|
|
4
4
|
import { isAllInTable } from '../../helpers';
|
|
5
|
-
import
|
|
5
|
+
import CellBackgroundColorMenu from './cell-bg-color-menu';
|
|
6
6
|
import CellTextAlignMenu from './cell-text-align-menu';
|
|
7
7
|
import RemoveTable from './remove-table-menu';
|
|
8
8
|
import TableColumnMenu from './table-column-menu';
|
|
@@ -25,7 +25,7 @@ var ActiveTableMenu = function ActiveTableMenu(_ref) {
|
|
|
25
25
|
}), /*#__PURE__*/React.createElement(TableRowMenu, {
|
|
26
26
|
editor: editor,
|
|
27
27
|
readonly: readonly
|
|
28
|
-
}), /*#__PURE__*/React.createElement(
|
|
28
|
+
}), /*#__PURE__*/React.createElement(CellBackgroundColorMenu, {
|
|
29
29
|
editor: editor,
|
|
30
30
|
isRichEditor: isRichEditor,
|
|
31
31
|
className: className,
|
|
@@ -6,7 +6,7 @@ import { Transforms } from '@seafile/slate';
|
|
|
6
6
|
import ObjectUtils from '../../../../utils/object-utils';
|
|
7
7
|
import { findPath, focusEditor } from '../../../core';
|
|
8
8
|
import { useResizeHandlersContext, useTableSelectedRangeContext } from './hooks';
|
|
9
|
-
import { EMPTY_SELECTED_RANGE,
|
|
9
|
+
import { EMPTY_SELECTED_RANGE, SELECTED_TABLE_CELL_BACKGROUND_COLOR, TABLE_CELL_STYLE } from '../constants';
|
|
10
10
|
import { getTableColumns, getCellColumn, colorBlend } from '../helpers';
|
|
11
11
|
var TableCell = function TableCell(_ref) {
|
|
12
12
|
var attributes = _ref.attributes,
|
|
@@ -39,16 +39,16 @@ var TableCell = function TableCell(_ref) {
|
|
|
39
39
|
});
|
|
40
40
|
}, [editor, element]);
|
|
41
41
|
var style = attributes.style || {};
|
|
42
|
-
if (ObjectUtils.hasProperty(element.style,
|
|
43
|
-
style[
|
|
42
|
+
if (ObjectUtils.hasProperty(element.style, TABLE_CELL_STYLE.TEXT_ALIGN)) {
|
|
43
|
+
style[TABLE_CELL_STYLE.TEXT_ALIGN] = element.style[TABLE_CELL_STYLE.TEXT_ALIGN];
|
|
44
44
|
}
|
|
45
45
|
if (isSelected) {
|
|
46
|
-
style['backgroundColor'] =
|
|
46
|
+
style['backgroundColor'] = SELECTED_TABLE_CELL_BACKGROUND_COLOR;
|
|
47
47
|
}
|
|
48
|
-
if (ObjectUtils.hasProperty(element.style,
|
|
49
|
-
var color = element.style[
|
|
48
|
+
if (ObjectUtils.hasProperty(element.style, TABLE_CELL_STYLE.BACKGROUND_COLOR)) {
|
|
49
|
+
var color = element.style[TABLE_CELL_STYLE.BACKGROUND_COLOR];
|
|
50
50
|
if (color && color !== 'transparent' && color !== 'unset') {
|
|
51
|
-
style['backgroundColor'] = isSelected ? colorBlend(
|
|
51
|
+
style['backgroundColor'] = isSelected ? colorBlend(SELECTED_TABLE_CELL_BACKGROUND_COLOR, color, 0.9) : color;
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
return /*#__PURE__*/React.createElement("div", Object.assign({}, attributes, {
|
|
@@ -85,11 +85,11 @@ function renderTableCell(props) {
|
|
|
85
85
|
|
|
86
86
|
// const cellValue = element;
|
|
87
87
|
var style = attributes.style || {};
|
|
88
|
-
if (ObjectUtils.hasProperty(element.style,
|
|
89
|
-
style[
|
|
88
|
+
if (ObjectUtils.hasProperty(element.style, TABLE_CELL_STYLE.TEXT_ALIGN)) {
|
|
89
|
+
style[TABLE_CELL_STYLE.TEXT_ALIGN] = element[TABLE_CELL_STYLE.TEXT_ALIGN];
|
|
90
90
|
}
|
|
91
|
-
if (ObjectUtils.hasProperty(element.style,
|
|
92
|
-
style['backgroundColor'] = element.style[
|
|
91
|
+
if (ObjectUtils.hasProperty(element.style, TABLE_CELL_STYLE.BACKGROUND_COLOR) && element.style[TABLE_CELL_STYLE.BACKGROUND_COLOR]) {
|
|
92
|
+
style['backgroundColor'] = element.style[TABLE_CELL_STYLE.BACKGROUND_COLOR];
|
|
93
93
|
}
|
|
94
94
|
var column = getCellColumn(editor, element);
|
|
95
95
|
var width = column.width;
|
|
@@ -17,8 +17,8 @@ var renderText = function renderText(props, editor) {
|
|
|
17
17
|
style['display'] = 'inline-block';
|
|
18
18
|
style['minWidth'] = '2px';
|
|
19
19
|
}
|
|
20
|
-
if (leaf.
|
|
21
|
-
style['backgroundColor'] = leaf.
|
|
20
|
+
if (leaf.computed_background_color) {
|
|
21
|
+
style['backgroundColor'] = leaf.computed_background_color;
|
|
22
22
|
}
|
|
23
23
|
if (leaf.color) {
|
|
24
24
|
style['color'] = leaf.color;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import React, { useContext, useState } from 'react';
|
|
3
|
-
import { DEFAULT_LAST_USED_FONT_COLOR, DEFAULT_LAST_USED_HIGHLIGHT_COLOR,
|
|
3
|
+
import { DEFAULT_LAST_USED_FONT_COLOR, DEFAULT_LAST_USED_HIGHLIGHT_COLOR, DEFAULT_LAST_USED_TABLE_CELL_BACKGROUND_COLOR } from '../extension/constants';
|
|
4
4
|
var ColorContext = React.createContext(null);
|
|
5
5
|
export var ColorProvider = function ColorProvider(props) {
|
|
6
6
|
var _useState = useState(DEFAULT_LAST_USED_FONT_COLOR),
|
|
@@ -11,18 +11,18 @@ export var ColorProvider = function ColorProvider(props) {
|
|
|
11
11
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
12
12
|
lastUsedHighlightColor = _useState4[0],
|
|
13
13
|
updateLastUsedHighlightColor = _useState4[1];
|
|
14
|
-
var _useState5 = useState(
|
|
14
|
+
var _useState5 = useState(DEFAULT_LAST_USED_TABLE_CELL_BACKGROUND_COLOR),
|
|
15
15
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
lastUsedTableCellBackgroundColor = _useState6[0],
|
|
17
|
+
updateLastUsedTableCellBackgroundColor = _useState6[1];
|
|
18
18
|
return /*#__PURE__*/React.createElement(ColorContext.Provider, {
|
|
19
19
|
value: {
|
|
20
20
|
lastUsedFontColor: lastUsedFontColor,
|
|
21
21
|
updateLastUsedFontColor: updateLastUsedFontColor,
|
|
22
22
|
lastUsedHighlightColor: lastUsedHighlightColor,
|
|
23
23
|
updateLastUsedHighlightColor: updateLastUsedHighlightColor,
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
lastUsedTableCellBackgroundColor: lastUsedTableCellBackgroundColor,
|
|
25
|
+
updateLastUsedTableCellBackgroundColor: updateLastUsedTableCellBackgroundColor
|
|
26
26
|
}
|
|
27
27
|
}, props.children);
|
|
28
28
|
};
|
|
@@ -33,16 +33,16 @@ export var useColorContext = function useColorContext() {
|
|
|
33
33
|
}
|
|
34
34
|
var lastUsedFontColor = context.lastUsedFontColor,
|
|
35
35
|
lastUsedHighlightColor = context.lastUsedHighlightColor,
|
|
36
|
-
|
|
36
|
+
lastUsedTableCellBackgroundColor = context.lastUsedTableCellBackgroundColor,
|
|
37
37
|
updateLastUsedFontColor = context.updateLastUsedFontColor,
|
|
38
38
|
updateLastUsedHighlightColor = context.updateLastUsedHighlightColor,
|
|
39
|
-
|
|
39
|
+
updateLastUsedTableCellBackgroundColor = context.updateLastUsedTableCellBackgroundColor;
|
|
40
40
|
return {
|
|
41
41
|
lastUsedFontColor: lastUsedFontColor,
|
|
42
42
|
updateLastUsedFontColor: updateLastUsedFontColor,
|
|
43
43
|
lastUsedHighlightColor: lastUsedHighlightColor,
|
|
44
44
|
updateLastUsedHighlightColor: updateLastUsedHighlightColor,
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
lastUsedTableCellBackgroundColor: lastUsedTableCellBackgroundColor,
|
|
46
|
+
updateLastUsedTableCellBackgroundColor: updateLastUsedTableCellBackgroundColor
|
|
47
47
|
};
|
|
48
48
|
};
|
|
@@ -29,7 +29,7 @@ var DiffViewer = function DiffViewer(_ref) {
|
|
|
29
29
|
return /*#__PURE__*/React.createElement("span", {
|
|
30
30
|
className: "d-inline-block p-1",
|
|
31
31
|
style: {
|
|
32
|
-
backgroundColor: style.
|
|
32
|
+
backgroundColor: style.computed_background_color,
|
|
33
33
|
width: 'fit-content',
|
|
34
34
|
height: 'fit-content'
|
|
35
35
|
}
|