@seafile/sdoc-editor 1.0.97 → 1.0.99
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/constants/index.js +10 -3
- package/dist/basic-sdk/editor/wiki-editor.js +4 -1
- package/dist/basic-sdk/extension/plugins/code-block/hover-menu/index.css +4 -4
- package/dist/basic-sdk/extension/plugins/code-block/hover-menu/index.js +65 -11
- package/dist/basic-sdk/layout/article-container.js +7 -3
- package/dist/basic-sdk/outline/outline-item.js +46 -10
- package/dist/basic-sdk/outline/style.css +65 -0
- package/dist/basic-sdk/outline/wiki-outline.js +109 -0
- package/dist/basic-sdk/right-panel/index.js +17 -7
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.PAGE_EDIT_AREA_WIDTH = exports.MODIFY_TYPE = exports.INTERNAL_EVENT = exports.DOCUMENT_PLUGIN_EDITOR = exports.DIFF_VIEWER = exports.COMMENT_EDITOR_EDIT_AREA_WIDTH = exports.COMMENT_EDITOR = void 0;
|
|
7
|
+
exports.PAGE_EDIT_AREA_WIDTH = exports.MODIFY_TYPE = exports.INTERNAL_EVENT = exports.HEADER_OUTLINE_WIDTH_MAPPING = exports.DOCUMENT_PLUGIN_EDITOR = exports.DIFF_VIEWER = exports.COMMENT_EDITOR_EDIT_AREA_WIDTH = exports.COMMENT_EDITOR = void 0;
|
|
8
8
|
Object.defineProperty(exports, "PLUGIN_BTN_POSITION", {
|
|
9
9
|
enumerable: true,
|
|
10
10
|
get: function () {
|
|
@@ -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_EDITOR = 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.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");
|
|
@@ -45,7 +45,8 @@ const INTERNAL_EVENT = exports.INTERNAL_EVENT = {
|
|
|
45
45
|
TABLE_HIDE_DRAG_HANDLER: 'table_show_drag_handler',
|
|
46
46
|
ON_PRINT: 'on_print',
|
|
47
47
|
COMMENT_EDITOR_POST_COMMENT: 'comment_editor_post_comment',
|
|
48
|
-
CLOSE_FILE_INSET_DIALOG: 'close_file_insert_dialog'
|
|
48
|
+
CLOSE_FILE_INSET_DIALOG: 'close_file_insert_dialog',
|
|
49
|
+
RESIZE_ARTICLE: 'resize_article'
|
|
49
50
|
};
|
|
50
51
|
const REVISION_DIFF_KEY = exports.REVISION_DIFF_KEY = 'diff';
|
|
51
52
|
const REVISION_DIFF_VALUE = exports.REVISION_DIFF_VALUE = '1';
|
|
@@ -54,6 +55,12 @@ const COMMENT_EDITOR_EDIT_AREA_WIDTH = exports.COMMENT_EDITOR_EDIT_AREA_WIDTH =
|
|
|
54
55
|
const COMMENT_EDITOR = exports.COMMENT_EDITOR = 'comment_editor';
|
|
55
56
|
const WIKI_EDITOR = exports.WIKI_EDITOR = 'wiki_editor';
|
|
56
57
|
const DOCUMENT_PLUGIN_EDITOR = exports.DOCUMENT_PLUGIN_EDITOR = 'document_plugin_editor';
|
|
58
|
+
const WIKI_OUTLINE = exports.WIKI_OUTLINE = 'wiki-outline';
|
|
59
|
+
const HEADER_OUTLINE_WIDTH_MAPPING = exports.HEADER_OUTLINE_WIDTH_MAPPING = {
|
|
60
|
+
header1: '16px',
|
|
61
|
+
header2: '12px',
|
|
62
|
+
header3: '8px'
|
|
63
|
+
};
|
|
57
64
|
const MODIFY_TYPE = exports.MODIFY_TYPE = {
|
|
58
65
|
ADD: 'add',
|
|
59
66
|
DELETE: 'delete',
|
|
@@ -20,6 +20,7 @@ var _core = require("../extension/core");
|
|
|
20
20
|
var _insertElementDialog = _interopRequireDefault(require("../extension/commons/insert-element-dialog"));
|
|
21
21
|
var _layout = require("../layout");
|
|
22
22
|
var _editableArticle = _interopRequireDefault(require("./editable-article"));
|
|
23
|
+
var _wikiOutline = _interopRequireDefault(require("../outline/wiki-outline"));
|
|
23
24
|
var _useColorContext = require("../hooks/use-color-context");
|
|
24
25
|
var _readonlyArticle = _interopRequireDefault(require("../views/readonly-article"));
|
|
25
26
|
var _utils = require("../../utils");
|
|
@@ -177,7 +178,9 @@ const WikiEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
177
178
|
slateValue: slateValue,
|
|
178
179
|
updateSlateValue: onValueChange,
|
|
179
180
|
showComment: false
|
|
180
|
-
}))
|
|
181
|
+
})), /*#__PURE__*/_react.default.createElement(_wikiOutline.default, {
|
|
182
|
+
doc: slateValue
|
|
183
|
+
}))))), /*#__PURE__*/_react.default.createElement(_insertElementDialog.default, {
|
|
181
184
|
editor: validEditor
|
|
182
185
|
}));
|
|
183
186
|
});
|
|
@@ -130,12 +130,12 @@
|
|
|
130
130
|
justify-content: space-between;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
.sdoc-langs-list-container .langs-list-ul .langs-list-li
|
|
134
|
-
background-color: #f5f5f5
|
|
133
|
+
.sdoc-langs-list-container .langs-list-ul .langs-list-li.active {
|
|
134
|
+
background-color: #f5f5f5;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
.sdoc-langs-list-container .langs-list-ul .langs-list-li
|
|
138
|
-
background-color: #f5f5f5
|
|
137
|
+
.sdoc-langs-list-container .langs-list-ul .langs-list-li.hover {
|
|
138
|
+
background-color: #f5f5f5;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
.sdoc-langs-list-container .langs-list-ul .langs-list-li .li-check-mark {
|
|
@@ -14,11 +14,12 @@ var _commons = require("../../../commons/");
|
|
|
14
14
|
var _prismjs = require("../prismjs");
|
|
15
15
|
var _helpers = require("../helpers");
|
|
16
16
|
require("./index.css");
|
|
17
|
-
const LangList = _ref => {
|
|
17
|
+
const LangList = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
18
18
|
let {
|
|
19
19
|
langsData,
|
|
20
20
|
onSelectLang,
|
|
21
|
-
selectedLanguageText
|
|
21
|
+
selectedLanguageText,
|
|
22
|
+
selectedIndex
|
|
22
23
|
} = _ref;
|
|
23
24
|
const {
|
|
24
25
|
t
|
|
@@ -30,13 +31,14 @@ const LangList = _ref => {
|
|
|
30
31
|
}
|
|
31
32
|
return /*#__PURE__*/_react.default.createElement("ul", {
|
|
32
33
|
className: "langs-list-ul"
|
|
33
|
-
}, langsData.map(item => {
|
|
34
|
+
}, langsData.map((item, index) => {
|
|
34
35
|
return /*#__PURE__*/_react.default.createElement("li", {
|
|
35
|
-
|
|
36
|
+
ref: el => ref.current[index] = el,
|
|
37
|
+
className: `langs-list-li ${selectedLanguageText === item.text ? 'active' : ''} ${selectedIndex === index ? 'hover' : ''}`,
|
|
36
38
|
id: item.value,
|
|
37
39
|
key: item.value,
|
|
38
40
|
onClick: () => {
|
|
39
|
-
onSelectLang(item);
|
|
41
|
+
onSelectLang(item, index);
|
|
40
42
|
}
|
|
41
43
|
}, item.text, /*#__PURE__*/_react.default.createElement("span", {
|
|
42
44
|
className: `li-check-mark ${selectedLanguageText === item.text ? 'li-checked' : ''}`
|
|
@@ -44,7 +46,7 @@ const LangList = _ref => {
|
|
|
44
46
|
className: "sdocfont sdoc-check-mark icon-font"
|
|
45
47
|
})));
|
|
46
48
|
}));
|
|
47
|
-
};
|
|
49
|
+
});
|
|
48
50
|
const CodeBlockHoverMenu = _ref2 => {
|
|
49
51
|
let {
|
|
50
52
|
style,
|
|
@@ -63,6 +65,11 @@ const CodeBlockHoverMenu = _ref2 => {
|
|
|
63
65
|
const [selectedLanguageText, setSelectedLanguageText] = (0, _react.useState)('');
|
|
64
66
|
const [langsData, setLangsData] = (0, _react.useState)((0, _prismjs.genCodeLangs)());
|
|
65
67
|
const [isShowTooltip, setIsShowTooltip] = (0, _react.useState)(false);
|
|
68
|
+
const [selectedIndex, setSelectedIndex] = (0, _react.useState)(0);
|
|
69
|
+
const langRefs = (0, _react.useRef)([]);
|
|
70
|
+
(0, _react.useEffect)(() => {
|
|
71
|
+
langRefs.current = Array(langsData.length).fill().map((_, i) => langRefs.current[i] || /*#__PURE__*/_react.default.createRef());
|
|
72
|
+
}, [langsData]);
|
|
66
73
|
const onHiddenLangsList = (0, _react.useCallback)(e => {
|
|
67
74
|
if (!e.target.parentNode.className.includes('sdoc-search-langs')) {
|
|
68
75
|
setIsShowlangsList(false);
|
|
@@ -79,9 +86,10 @@ const CodeBlockHoverMenu = _ref2 => {
|
|
|
79
86
|
}, []);
|
|
80
87
|
const onShowLangs = (0, _react.useCallback)(e => {
|
|
81
88
|
e.stopPropagation();
|
|
89
|
+
setSelectedIndex(langsData.findIndex(lang => lang.text === selectedLanguageText));
|
|
82
90
|
setIsShowlangsList(!isShowlangsList);
|
|
83
91
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
84
|
-
}, [isShowlangsList]);
|
|
92
|
+
}, [isShowlangsList, selectedLanguageText]);
|
|
85
93
|
const onAutoLineWrap = (0, _react.useCallback)(() => {
|
|
86
94
|
if (white_space === 'normal') {
|
|
87
95
|
onChangeAutoLineWrap('nowrap');
|
|
@@ -94,14 +102,22 @@ const CodeBlockHoverMenu = _ref2 => {
|
|
|
94
102
|
onDeleteCodeBlock();
|
|
95
103
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
96
104
|
}, []);
|
|
97
|
-
const onSelectLang = (0, _react.useCallback)(lang => {
|
|
105
|
+
const onSelectLang = (0, _react.useCallback)((lang, index) => {
|
|
98
106
|
const {
|
|
99
107
|
text
|
|
100
108
|
} = lang;
|
|
101
109
|
setSelectedLanguageText(text);
|
|
110
|
+
setSelectedIndex(index);
|
|
102
111
|
onChangeLanguage(lang);
|
|
112
|
+
const selectedLangRef = langRefs.current[index];
|
|
113
|
+
if (selectedLangRef) {
|
|
114
|
+
selectedLangRef.scrollIntoView({
|
|
115
|
+
behavior: 'smooth',
|
|
116
|
+
block: 'nearest'
|
|
117
|
+
});
|
|
118
|
+
}
|
|
103
119
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
104
|
-
}, []);
|
|
120
|
+
}, [onChangeLanguage]);
|
|
105
121
|
(0, _react.useEffect)(() => {
|
|
106
122
|
// Compatible with legacy code
|
|
107
123
|
let selectedLanguage = language;
|
|
@@ -126,6 +142,41 @@ const CodeBlockHoverMenu = _ref2 => {
|
|
|
126
142
|
setLangsData(filterData);
|
|
127
143
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
128
144
|
}, []);
|
|
145
|
+
const onKeyDown = (0, _react.useCallback)(e => {
|
|
146
|
+
const {
|
|
147
|
+
key
|
|
148
|
+
} = e;
|
|
149
|
+
switch (key) {
|
|
150
|
+
case 'ArrowUp':
|
|
151
|
+
e.preventDefault();
|
|
152
|
+
setSelectedIndex(prevIndex => {
|
|
153
|
+
const newIndex = Math.max(prevIndex - 1, 0);
|
|
154
|
+
scrollToLang(newIndex);
|
|
155
|
+
return newIndex;
|
|
156
|
+
});
|
|
157
|
+
break;
|
|
158
|
+
case 'ArrowDown':
|
|
159
|
+
e.preventDefault();
|
|
160
|
+
setSelectedIndex(prevIndex => {
|
|
161
|
+
const newIndex = Math.min(prevIndex + 1, langsData.length - 1);
|
|
162
|
+
scrollToLang(newIndex);
|
|
163
|
+
return newIndex;
|
|
164
|
+
});
|
|
165
|
+
break;
|
|
166
|
+
case 'Enter':
|
|
167
|
+
onSelectLang(langsData[selectedIndex], selectedIndex);
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}, [langsData, selectedIndex, onSelectLang]);
|
|
171
|
+
const scrollToLang = index => {
|
|
172
|
+
const selectedLangRef = langRefs.current[index];
|
|
173
|
+
if (selectedLangRef) {
|
|
174
|
+
selectedLangRef.scrollIntoView({
|
|
175
|
+
behavior: 'smooth',
|
|
176
|
+
block: 'nearest'
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
};
|
|
129
180
|
return /*#__PURE__*/_react.default.createElement(_commons.ElementPopover, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
130
181
|
className: "sdoc-code-block-hover-menu-container",
|
|
131
182
|
style: menuPosition
|
|
@@ -191,11 +242,14 @@ const CodeBlockHoverMenu = _ref2 => {
|
|
|
191
242
|
}, /*#__PURE__*/_react.default.createElement(_reactstrap.Input, {
|
|
192
243
|
autoFocus: true,
|
|
193
244
|
placeholder: t('Search_language'),
|
|
194
|
-
onChange: onChange
|
|
245
|
+
onChange: onChange,
|
|
246
|
+
onKeyDown: onKeyDown
|
|
195
247
|
})), /*#__PURE__*/_react.default.createElement(LangList, {
|
|
196
248
|
langsData: langsData,
|
|
197
249
|
onSelectLang: onSelectLang,
|
|
198
|
-
selectedLanguageText: selectedLanguageText
|
|
250
|
+
selectedLanguageText: selectedLanguageText,
|
|
251
|
+
selectedIndex: selectedIndex,
|
|
252
|
+
ref: langRefs
|
|
199
253
|
})))));
|
|
200
254
|
};
|
|
201
255
|
var _default = exports.default = (0, _reactI18next.withTranslation)('sdoc-editor')(CodeBlockHoverMenu);
|
|
@@ -31,7 +31,7 @@ function ArticleContainer(_ref) {
|
|
|
31
31
|
const articleRect = articleRef.current.getBoundingClientRect();
|
|
32
32
|
// get state from local storage
|
|
33
33
|
const isShowOutline = (0, _outline.getOutlineSetting)();
|
|
34
|
-
if (isShowOutline && (rect.width - articleRect.width) / 2 < 280) {
|
|
34
|
+
if (isShowOutline && editor.editorType !== _constants.WIKI_EDITOR && (rect.width - articleRect.width) / 2 < 280) {
|
|
35
35
|
setContainerStyle({
|
|
36
36
|
marginLeft: '280px'
|
|
37
37
|
});
|
|
@@ -44,7 +44,7 @@ function ArticleContainer(_ref) {
|
|
|
44
44
|
block: 'nearest'
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
}, [scrollRef]);
|
|
47
|
+
}, [editor.editorType, scrollRef]);
|
|
48
48
|
const handelArticleClick = (0, _react.useCallback)(event => {
|
|
49
49
|
if (!articleRef.current.contains(event.target)) return;
|
|
50
50
|
const eventBus = _eventBus.default.getInstance();
|
|
@@ -53,7 +53,11 @@ function ArticleContainer(_ref) {
|
|
|
53
53
|
(0, _react.useEffect)(() => {
|
|
54
54
|
const eventBus = _eventBus.default.getInstance();
|
|
55
55
|
const unsubscribeOutline = eventBus.subscribe(_constants.INTERNAL_EVENT.OUTLINE_STATE_CHANGED, handleWindowResize);
|
|
56
|
-
|
|
56
|
+
const unsubscribeResizeArticle = eventBus.subscribe(_constants.INTERNAL_EVENT.RESIZE_ARTICLE, handleWindowResize);
|
|
57
|
+
return () => {
|
|
58
|
+
unsubscribeOutline();
|
|
59
|
+
unsubscribeResizeArticle();
|
|
60
|
+
};
|
|
57
61
|
}, [handleWindowResize]);
|
|
58
62
|
(0, _react.useEffect)(() => {
|
|
59
63
|
if (editor.editorType === _constants.WIKI_EDITOR) return;
|
|
@@ -8,6 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/defineProperty"));
|
|
9
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
var _constants = require("../constants");
|
|
11
12
|
class OutlineItem extends _react.default.PureComponent {
|
|
12
13
|
constructor(props) {
|
|
13
14
|
super(props);
|
|
@@ -30,26 +31,61 @@ class OutlineItem extends _react.default.PureComponent {
|
|
|
30
31
|
isHighlighted: false
|
|
31
32
|
});
|
|
32
33
|
});
|
|
34
|
+
(0, _defineProperty2.default)(this, "getOutlineItemClass", () => {
|
|
35
|
+
const {
|
|
36
|
+
isHighlighted
|
|
37
|
+
} = this.state;
|
|
38
|
+
const {
|
|
39
|
+
item,
|
|
40
|
+
isDisplayHorizontalBar
|
|
41
|
+
} = this.props;
|
|
42
|
+
const {
|
|
43
|
+
type,
|
|
44
|
+
isActive
|
|
45
|
+
} = item;
|
|
46
|
+
let outlineItemClass = null;
|
|
47
|
+
outlineItemClass = (0, _classnames.default)('sdoc-outline-item', {
|
|
48
|
+
'pl-5': type === 'header2',
|
|
49
|
+
'pl-7': type === 'header3',
|
|
50
|
+
'active': isHighlighted,
|
|
51
|
+
'wiki-outline-active': isActive
|
|
52
|
+
});
|
|
53
|
+
if (isDisplayHorizontalBar) {
|
|
54
|
+
outlineItemClass = (0, _classnames.default)('sdoc-outline-item', {
|
|
55
|
+
'pl-1': type === 'header2',
|
|
56
|
+
'pl-2': type === 'header3',
|
|
57
|
+
'active': isHighlighted
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return outlineItemClass;
|
|
61
|
+
});
|
|
33
62
|
this.state = {
|
|
34
63
|
isHighlighted: false
|
|
35
64
|
};
|
|
36
65
|
}
|
|
37
66
|
render() {
|
|
38
67
|
const {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const {
|
|
42
|
-
item
|
|
68
|
+
item,
|
|
69
|
+
isDisplayHorizontalBar
|
|
43
70
|
} = this.props;
|
|
44
71
|
const {
|
|
45
72
|
type,
|
|
46
|
-
children
|
|
73
|
+
children,
|
|
74
|
+
isActive
|
|
47
75
|
} = item;
|
|
48
|
-
const outlineItemClass = (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
76
|
+
const outlineItemClass = this.getOutlineItemClass();
|
|
77
|
+
if (isDisplayHorizontalBar) {
|
|
78
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
79
|
+
className: outlineItemClass
|
|
80
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
81
|
+
className: (0, _classnames.default)('wiki-outline-context', {
|
|
82
|
+
'active': isActive
|
|
83
|
+
}),
|
|
84
|
+
style: {
|
|
85
|
+
width: _constants.HEADER_OUTLINE_WIDTH_MAPPING[type]
|
|
86
|
+
}
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
53
89
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
54
90
|
className: outlineItemClass,
|
|
55
91
|
onClick: this.onItemClick,
|
|
@@ -13,6 +13,71 @@
|
|
|
13
13
|
pointer-events: all;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
.wiki-outline-wrapper {
|
|
17
|
+
position: fixed;
|
|
18
|
+
right: 0;
|
|
19
|
+
margin: 0;
|
|
20
|
+
pointer-events: unset !important;
|
|
21
|
+
flex: none;
|
|
22
|
+
max-height: 400px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.wiki-outline-wrapper .sdoc-outline {
|
|
26
|
+
width: 59px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.wiki-outline-wrapper .sdoc-outline .sdoc-outline-list-container {
|
|
30
|
+
flex: none;
|
|
31
|
+
max-height: 400px;
|
|
32
|
+
overflow-y: hidden;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.wiki-outline-wrapper .sdoc-outline .sdoc-outline-list-container .sdoc-outline-item .wiki-outline-context {
|
|
36
|
+
background-color: rgb(227, 226, 224);
|
|
37
|
+
height: 2px;
|
|
38
|
+
box-shadow: none;
|
|
39
|
+
border-radius: 2px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.wiki-outline-wrapper .sdoc-outline .sdoc-outline-list-container .sdoc-outline-item .active {
|
|
43
|
+
background-color: rgb(50, 48, 44);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.wiki-outline-wrapper .wiki-outline-popver {
|
|
47
|
+
position: absolute;
|
|
48
|
+
right: 0;
|
|
49
|
+
width: 242px;
|
|
50
|
+
max-height: 538px;
|
|
51
|
+
padding: 12px;
|
|
52
|
+
margin-right: 10px;
|
|
53
|
+
background-color: white;
|
|
54
|
+
box-shadow: rgba(15, 15, 15, 0.04) 0px 0px 0px 1px, rgba(15, 15, 15, 0.03) 0px 3px 6px, rgba(15, 15, 15, 0.06) 0px 9px 24px;
|
|
55
|
+
border: 1px solid rgba(55, 53, 47, 0.06);
|
|
56
|
+
border-radius: 14px;
|
|
57
|
+
overflow-y: auto;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.wiki-outline-wrapper .wiki-outline-popver .sdoc-outline-list-container {
|
|
61
|
+
padding: 6px;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.wiki-outline-wrapper .wiki-outline-popver .sdoc-outline-list-container .sdoc-outline-item {
|
|
65
|
+
color: rgb(120, 119, 116);
|
|
66
|
+
transition: color 0.15s;
|
|
67
|
+
cursor: pointer;
|
|
68
|
+
padding: 4px 6px 4px 4px;
|
|
69
|
+
font-size: 14px;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.wiki-outline-wrapper .wiki-outline-popver .sdoc-outline-list-container .wiki-outline-active {
|
|
73
|
+
color: rgb(35, 131, 226)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.wiki-outline-wrapper .wiki-outline-popver .sdoc-outline-list-container .sdoc-outline-item:hover {
|
|
77
|
+
background: rgba(55, 53, 47, 0.06);
|
|
78
|
+
border-radius: 6px;
|
|
79
|
+
}
|
|
80
|
+
|
|
16
81
|
.sdoc-outline {
|
|
17
82
|
flex: 1;
|
|
18
83
|
width: 220px;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _lodash = _interopRequireDefault(require("lodash.throttle"));
|
|
11
|
+
var _reactI18next = require("react-i18next");
|
|
12
|
+
var _useScrollContext = require("../hooks/use-scroll-context");
|
|
13
|
+
var _outlineItem = _interopRequireDefault(require("./outline-item"));
|
|
14
|
+
require("./style.css");
|
|
15
|
+
const WikiOutline = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
doc = []
|
|
18
|
+
} = _ref;
|
|
19
|
+
const scrollRef = (0, _useScrollContext.useScrollContext)();
|
|
20
|
+
const wikiOutlineRef = (0, _react.useRef)(null);
|
|
21
|
+
const [wikiOutlineList, setWikiOutlineList] = (0, _react.useState)([]);
|
|
22
|
+
const [isShowOutlinePopver, setIsShowOutlinePopver] = (0, _react.useState)(false);
|
|
23
|
+
const onMouseOver = (0, _react.useCallback)(() => {
|
|
24
|
+
if (!isShowOutlinePopver) {
|
|
25
|
+
setIsShowOutlinePopver(true);
|
|
26
|
+
}
|
|
27
|
+
}, [isShowOutlinePopver]);
|
|
28
|
+
const updateWikiOutlineList = (0, _react.useCallback)(() => {
|
|
29
|
+
const list = doc.filter(item => ['header1', 'header2', 'header3'].includes(item.type));
|
|
30
|
+
if (list.length === 0) return;
|
|
31
|
+
const newList = JSON.parse(JSON.stringify(list)); // The slateValue value in the document cannot be operated, so copy it for operation
|
|
32
|
+
const index = list.findIndex(item => {
|
|
33
|
+
const {
|
|
34
|
+
id
|
|
35
|
+
} = item;
|
|
36
|
+
const el = document.getElementById(id);
|
|
37
|
+
if (el) {
|
|
38
|
+
const {
|
|
39
|
+
bottom
|
|
40
|
+
} = el.getBoundingClientRect();
|
|
41
|
+
if (bottom >= 43) {
|
|
42
|
+
// 43 is Top toolbar height
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// There is a title in the visible area
|
|
50
|
+
if (index !== -1) {
|
|
51
|
+
newList[index]['isActive'] = true;
|
|
52
|
+
}
|
|
53
|
+
// There is no title in the visible area
|
|
54
|
+
if (index === -1) {
|
|
55
|
+
const lastItemId = list[list.length - 1].id;
|
|
56
|
+
const lastItemEl = document.getElementById(lastItemId);
|
|
57
|
+
if (lastItemEl) {
|
|
58
|
+
const {
|
|
59
|
+
top
|
|
60
|
+
} = lastItemEl.getBoundingClientRect();
|
|
61
|
+
if (top < 0) {
|
|
62
|
+
newList[newList.length - 1]['isActive'] = true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
setWikiOutlineList([...newList]);
|
|
67
|
+
}, [doc]);
|
|
68
|
+
const onScroll = (0, _lodash.default)(() => {
|
|
69
|
+
updateWikiOutlineList();
|
|
70
|
+
}, 200);
|
|
71
|
+
(0, _react.useEffect)(() => {
|
|
72
|
+
updateWikiOutlineList();
|
|
73
|
+
let curRef = null;
|
|
74
|
+
curRef = scrollRef.current;
|
|
75
|
+
scrollRef.current.addEventListener('scroll', onScroll);
|
|
76
|
+
return () => {
|
|
77
|
+
curRef && curRef.removeEventListener('scroll', onScroll);
|
|
78
|
+
};
|
|
79
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80
|
+
}, [doc]);
|
|
81
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
82
|
+
className: "sdoc-outline-wrapper wiki-outline-wrapper",
|
|
83
|
+
onMouseLeave: () => {
|
|
84
|
+
setIsShowOutlinePopver(false);
|
|
85
|
+
}
|
|
86
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
87
|
+
className: "sdoc-outline"
|
|
88
|
+
}, wikiOutlineList.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
89
|
+
className: "sdoc-outline-list-container",
|
|
90
|
+
onMouseOver: onMouseOver
|
|
91
|
+
}, wikiOutlineList.map((item, index) => {
|
|
92
|
+
return /*#__PURE__*/_react.default.createElement(_outlineItem.default, {
|
|
93
|
+
key: index,
|
|
94
|
+
item: item,
|
|
95
|
+
isDisplayHorizontalBar: true
|
|
96
|
+
});
|
|
97
|
+
}))), isShowOutlinePopver && /*#__PURE__*/_react.default.createElement("div", {
|
|
98
|
+
className: "wiki-outline-popver",
|
|
99
|
+
ref: wikiOutlineRef
|
|
100
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
101
|
+
className: "sdoc-outline-list-container"
|
|
102
|
+
}, wikiOutlineList.map((item, index) => {
|
|
103
|
+
return /*#__PURE__*/_react.default.createElement(_outlineItem.default, {
|
|
104
|
+
key: index,
|
|
105
|
+
item: item
|
|
106
|
+
});
|
|
107
|
+
}))));
|
|
108
|
+
};
|
|
109
|
+
var _default = exports.default = (0, _reactI18next.withTranslation)('sdoc-editor')(WikiOutline);
|
|
@@ -10,6 +10,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
10
10
|
var _hooks = require("../../hooks");
|
|
11
11
|
var _resizeWidth = _interopRequireDefault(require("./resize-width"));
|
|
12
12
|
var _constants = require("../constants");
|
|
13
|
+
var _eventBus = _interopRequireDefault(require("../utils/event-bus"));
|
|
13
14
|
require("./index.css");
|
|
14
15
|
const MIN_PANEL_WIDTH = 360;
|
|
15
16
|
const MAX_PANEL_WIDTH = 620;
|
|
@@ -40,17 +41,26 @@ const RightPanel = _ref => {
|
|
|
40
41
|
setWidth(width);
|
|
41
42
|
}, []);
|
|
42
43
|
const resizeWidthEnd = (0, _react.useCallback)(width => {
|
|
43
|
-
window.localStorage.
|
|
44
|
+
const settings = JSON.parse(window.localStorage.getItem('sdoc') || '{}');
|
|
45
|
+
window.localStorage.setItem('sdoc', JSON.stringify({
|
|
46
|
+
...settings,
|
|
47
|
+
panelWidth: width
|
|
48
|
+
}));
|
|
49
|
+
const eventBus = _eventBus.default.getInstance();
|
|
50
|
+
eventBus.dispatch(_constants.INTERNAL_EVENT.RESIZE_ARTICLE);
|
|
44
51
|
}, []);
|
|
45
52
|
(0, _react.useEffect)(() => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
}
|
|
53
|
+
const settings = JSON.parse(window.localStorage.getItem('sdoc', '{}')) || {};
|
|
54
|
+
const {
|
|
55
|
+
panelWidth
|
|
56
|
+
} = settings;
|
|
57
|
+
const width = Math.max(MIN_PANEL_WIDTH, Math.min(parseInt(panelWidth, 10) || MIN_PANEL_WIDTH, MAX_PANEL_WIDTH));
|
|
52
58
|
setWidth(width);
|
|
53
59
|
}, []);
|
|
60
|
+
(0, _react.useEffect)(() => {
|
|
61
|
+
const eventBus = _eventBus.default.getInstance();
|
|
62
|
+
eventBus.dispatch(_constants.INTERNAL_EVENT.RESIZE_ARTICLE);
|
|
63
|
+
}, [displayPluginName]);
|
|
54
64
|
if (!displayPluginName) return null;
|
|
55
65
|
const plugin = plugins.find(p => p.name === displayPluginName);
|
|
56
66
|
if (!plugin) return null;
|