@seafile/sdoc-editor 0.4.4 → 0.4.6-1
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/sdoc-wiki-viewer.css +29 -0
- package/dist/basic-sdk/index.js +2 -2
- package/dist/basic-sdk/views/index.js +2 -1
- package/dist/basic-sdk/views/sdoc-wiki-viewer.js +46 -0
- package/dist/basic-sdk/wiki-outline/index.js +70 -0
- package/dist/basic-sdk/wiki-outline/outline-item.js +24 -0
- package/dist/basic-sdk/wiki-outline/style.css +45 -0
- package/dist/components/doc-info/index.js +15 -11
- package/dist/index.js +2 -1
- package/dist/pages/wiki-viewer.js +19 -0
- package/package.json +1 -1
- package/public/locales/cs/sdoc-editor.json +5 -2
- package/public/locales/de/sdoc-editor.json +5 -2
- package/public/locales/en/sdoc-editor.json +1 -1
- package/public/locales/es/sdoc-editor.json +5 -2
- package/public/locales/fr/sdoc-editor.json +5 -2
- package/public/locales/it/sdoc-editor.json +5 -2
- package/public/locales/ru/sdoc-editor.json +5 -2
- package/public/locales/zh_CN/sdoc-editor.json +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
.sdoc-editor-container {
|
|
2
|
+
flex: 1;
|
|
3
|
+
display: flex;
|
|
4
|
+
min-height: 0;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.sdoc-wiki-scroll-container {
|
|
8
|
+
display: flex;
|
|
9
|
+
overflow: auto;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.sdoc-wiki-scroll-container .sdoc-article-container {
|
|
13
|
+
width: 100%;
|
|
14
|
+
margin: 0 340px 0 40px !important;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.sdoc-wiki-scroll-container .sdoc-article-container .article .sdoc-header-2 {
|
|
18
|
+
border-bottom: 1px solid #ccc;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.sdoc-wiki-outline-container {
|
|
22
|
+
height: 80%;
|
|
23
|
+
overflow-y: auto;
|
|
24
|
+
padding-right: 1rem;
|
|
25
|
+
position: fixed;
|
|
26
|
+
right: 0;
|
|
27
|
+
top: 97px;
|
|
28
|
+
width: 300px;
|
|
29
|
+
}
|
package/dist/basic-sdk/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import SDocEditor from './editor/sdoc-editor';
|
|
2
2
|
import RevisionEditor from './editor/revision-editor';
|
|
3
|
-
import { DiffViewer, SDocViewer, PublishedRevisionDiffViewer } from './views';
|
|
3
|
+
import { DiffViewer, SDocViewer, PublishedRevisionDiffViewer, SDocWikiViewer } from './views';
|
|
4
4
|
import SDocOutline from './outline';
|
|
5
5
|
import EventBus from './utils/event-bus';
|
|
6
|
-
export { SDocEditor, RevisionEditor, SDocViewer, SDocOutline, EventBus, DiffViewer, PublishedRevisionDiffViewer };
|
|
6
|
+
export { SDocEditor, RevisionEditor, SDocViewer, SDocOutline, EventBus, DiffViewer, PublishedRevisionDiffViewer, SDocWikiViewer };
|
|
@@ -2,4 +2,5 @@ import SDocViewer from './sdoc-viewer';
|
|
|
2
2
|
import DiffViewer from './sdoc-diff-viewer';
|
|
3
3
|
import RevisionDiffViewer from './revision-diff-viewer';
|
|
4
4
|
import PublishedRevisionDiffViewer from './published-revision-diff-viewer';
|
|
5
|
-
|
|
5
|
+
import SDocWikiViewer from './sdoc-wiki-viewer';
|
|
6
|
+
export { SDocViewer, DiffViewer, RevisionDiffViewer, PublishedRevisionDiffViewer, SDocWikiViewer };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import { createDefaultEditor } from '../extension';
|
|
3
|
+
import withNodeId from '../node-id';
|
|
4
|
+
import { generateDefaultDocContent } from '../../utils';
|
|
5
|
+
import { EditorContainer } from '../layout';
|
|
6
|
+
import ReadOnlyArticle from './readonly-article';
|
|
7
|
+
import { ColorProvider } from '../hooks/use-color-context';
|
|
8
|
+
import { ScrollContext } from '../hooks/use-scroll-context';
|
|
9
|
+
import Outline from '../wiki-outline';
|
|
10
|
+
import '../assets/css/sdoc-wiki-viewer.css';
|
|
11
|
+
const SDocMdViewer = _ref => {
|
|
12
|
+
let {
|
|
13
|
+
editor,
|
|
14
|
+
document,
|
|
15
|
+
showOutline,
|
|
16
|
+
scrollRef: propsScrollRef
|
|
17
|
+
} = _ref;
|
|
18
|
+
const validEditor = editor || withNodeId(createDefaultEditor());
|
|
19
|
+
const slateValue = (document || generateDefaultDocContent()).children;
|
|
20
|
+
const scrollRef = useRef(null);
|
|
21
|
+
const currentScrollRef = propsScrollRef || scrollRef;
|
|
22
|
+
return /*#__PURE__*/React.createElement(EditorContainer, {
|
|
23
|
+
editor: validEditor,
|
|
24
|
+
readonly: true
|
|
25
|
+
}, /*#__PURE__*/React.createElement(ColorProvider, null, /*#__PURE__*/React.createElement("div", {
|
|
26
|
+
ref: scrollRef,
|
|
27
|
+
className: "sdoc-wiki-scroll-container"
|
|
28
|
+
}, /*#__PURE__*/React.createElement(ScrollContext.Provider, {
|
|
29
|
+
value: {
|
|
30
|
+
scrollRef: currentScrollRef
|
|
31
|
+
}
|
|
32
|
+
}, /*#__PURE__*/React.createElement(ReadOnlyArticle, {
|
|
33
|
+
editor: validEditor,
|
|
34
|
+
slateValue: slateValue,
|
|
35
|
+
isShowComment: false
|
|
36
|
+
}), showOutline && /*#__PURE__*/React.createElement("div", {
|
|
37
|
+
className: "sdoc-wiki-outline-container"
|
|
38
|
+
}, /*#__PURE__*/React.createElement(Outline, {
|
|
39
|
+
editor: validEditor
|
|
40
|
+
}))))));
|
|
41
|
+
};
|
|
42
|
+
SDocMdViewer.defaultProps = {
|
|
43
|
+
showToolbar: false,
|
|
44
|
+
showOutline: false
|
|
45
|
+
};
|
|
46
|
+
export default SDocMdViewer;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import OutlineItem from './outline-item';
|
|
4
|
+
import { useScrollContext } from '../hooks/use-scroll-context';
|
|
5
|
+
import './style.css';
|
|
6
|
+
const getHeaderList = children => {
|
|
7
|
+
const headerList = [];
|
|
8
|
+
children.forEach(node => {
|
|
9
|
+
if (node.type === 'header2' || node.type === 'header3') {
|
|
10
|
+
headerList.push(node);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
return headerList;
|
|
14
|
+
};
|
|
15
|
+
const Outline = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
editor
|
|
18
|
+
} = _ref;
|
|
19
|
+
const {
|
|
20
|
+
t
|
|
21
|
+
} = useTranslation();
|
|
22
|
+
const scrollRef = useScrollContext();
|
|
23
|
+
const [headerList, setHeaderList] = useState([]);
|
|
24
|
+
const [activeId, setActiveId] = useState('');
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const headerList = getHeaderList(editor.children);
|
|
27
|
+
setHeaderList(headerList);
|
|
28
|
+
}, [editor.children]);
|
|
29
|
+
const handleScroll = useCallback(e => {
|
|
30
|
+
const scrollTop = scrollRef.current.scrollTop;
|
|
31
|
+
const styles = getComputedStyle(scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current);
|
|
32
|
+
const paddingTop = parseInt(styles.paddingTop);
|
|
33
|
+
for (let i = 0; i < headerList.length; i++) {
|
|
34
|
+
const headerItem = headerList[i];
|
|
35
|
+
const dom = document.getElementById(headerItem.id);
|
|
36
|
+
const {
|
|
37
|
+
offsetTop,
|
|
38
|
+
offsetHeight
|
|
39
|
+
} = dom;
|
|
40
|
+
const styles = getComputedStyle(dom);
|
|
41
|
+
const marginTop = parseInt(styles.marginTop);
|
|
42
|
+
if (offsetTop + offsetHeight + marginTop > scrollTop - paddingTop) {
|
|
43
|
+
setActiveId(headerItem.id);
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}, [headerList, scrollRef]);
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
let observerRefValue = null;
|
|
50
|
+
if (scrollRef.current) {
|
|
51
|
+
scrollRef.current.addEventListener('scroll', handleScroll);
|
|
52
|
+
observerRefValue = scrollRef.current;
|
|
53
|
+
}
|
|
54
|
+
return () => {
|
|
55
|
+
observerRefValue.removeEventListener('scroll', handleScroll);
|
|
56
|
+
};
|
|
57
|
+
}, [handleScroll, scrollRef]);
|
|
58
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
59
|
+
className: "sdoc-wiki-viewer-outline"
|
|
60
|
+
}, headerList.length === 0 && /*#__PURE__*/React.createElement("div", {
|
|
61
|
+
className: "empty-container"
|
|
62
|
+
}, t('No_out_line')), headerList.length > 0 && headerList.map((node, index) => {
|
|
63
|
+
return /*#__PURE__*/React.createElement(OutlineItem, {
|
|
64
|
+
key: index,
|
|
65
|
+
node: node,
|
|
66
|
+
activeId: activeId
|
|
67
|
+
});
|
|
68
|
+
}));
|
|
69
|
+
};
|
|
70
|
+
export default Outline;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
const OutlineItem = _ref => {
|
|
4
|
+
let {
|
|
5
|
+
node,
|
|
6
|
+
activeId
|
|
7
|
+
} = _ref;
|
|
8
|
+
const onItemClick = useCallback(() => {
|
|
9
|
+
const {
|
|
10
|
+
id
|
|
11
|
+
} = node;
|
|
12
|
+
document.getElementById(id).scrollIntoView();
|
|
13
|
+
}, [node]);
|
|
14
|
+
const className = classNames({
|
|
15
|
+
'outline-h2': node.type === 'header2',
|
|
16
|
+
'outline-h3': node.type === 'header3',
|
|
17
|
+
'active': node.id === activeId
|
|
18
|
+
});
|
|
19
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
20
|
+
className: className,
|
|
21
|
+
onClick: onItemClick
|
|
22
|
+
}, node.children.map(child => child.text).join(''));
|
|
23
|
+
};
|
|
24
|
+
export default OutlineItem;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
.sdoc-wiki-viewer-outline {
|
|
2
|
+
border-left: 1px solid #ddd;
|
|
3
|
+
padding: .5rem 1rem .5rem 0;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.sdoc-wiki-viewer-outline .outline-h2,
|
|
7
|
+
.sdoc-wiki-viewer-outline .outline-h3 {
|
|
8
|
+
white-space: nowrap;
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
text-overflow: ellipsis;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.sdoc-wiki-viewer-outline .outline-h2 {
|
|
14
|
+
margin-left: 20px;
|
|
15
|
+
line-height: 2.5;
|
|
16
|
+
color:#364149;
|
|
17
|
+
white-space: nowrap;
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.sdoc-wiki-viewer-outline .outline-h2:hover {
|
|
22
|
+
color: #eb8205;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.sdoc-wiki-viewer-outline .outline-h3 {
|
|
26
|
+
margin-left: 40px;
|
|
27
|
+
line-height: 2.5;
|
|
28
|
+
color:#364149;
|
|
29
|
+
white-space: nowrap;
|
|
30
|
+
cursor:pointer;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.sdoc-wiki-viewer-outline .outline-h3:hover {
|
|
34
|
+
color: #eb8205;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.sdoc-wiki-viewer-outline .empty-container {
|
|
38
|
+
margin-top: 10px;
|
|
39
|
+
text-align: center;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.sdoc-wiki-viewer-outline .outline-h2.active,
|
|
43
|
+
.sdoc-wiki-viewer-outline .outline-h3.active {
|
|
44
|
+
color: #eb8205;
|
|
45
|
+
}
|
|
@@ -17,12 +17,23 @@ const DocInfo = _ref => {
|
|
|
17
17
|
isEditMode,
|
|
18
18
|
isPublished = false
|
|
19
19
|
} = _ref;
|
|
20
|
+
const isSdocRevision = context.getSetting('isSdocRevision');
|
|
21
|
+
const docName = context.getSetting('docName');
|
|
22
|
+
const {
|
|
23
|
+
isShowInternalLink,
|
|
24
|
+
isStarIconShown,
|
|
25
|
+
isFreezed
|
|
26
|
+
} = context.getSettings();
|
|
20
27
|
const onInternalLinkClick = useCallback(() => {
|
|
21
28
|
const eventBus = EventBus.getInstance();
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
if (isSdocRevision) {
|
|
30
|
+
eventBus.dispatch(EXTERNAL_EVENT.INTERNAL_LINK_CLICK, {
|
|
31
|
+
internalLink: window.location.href
|
|
32
|
+
});
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
eventBus.dispatch(EXTERNAL_EVENT.INTERNAL_LINK_CLICK);
|
|
36
|
+
}, [isSdocRevision]);
|
|
26
37
|
const toggleStar = useCallback(() => {
|
|
27
38
|
const eventBus = EventBus.getInstance();
|
|
28
39
|
eventBus.dispatch(EXTERNAL_EVENT.TOGGLE_STAR);
|
|
@@ -31,13 +42,6 @@ const DocInfo = _ref => {
|
|
|
31
42
|
const originFileURL = context.getSetting('originFileURL');
|
|
32
43
|
window.open(originFileURL, '_blank');
|
|
33
44
|
}, []);
|
|
34
|
-
const isSdocRevision = context.getSetting('isSdocRevision');
|
|
35
|
-
const docName = context.getSetting('docName');
|
|
36
|
-
const {
|
|
37
|
-
isShowInternalLink,
|
|
38
|
-
isStarIconShown,
|
|
39
|
-
isFreezed
|
|
40
|
-
} = context.getSettings();
|
|
41
45
|
const docInfo = /*#__PURE__*/React.createElement(React.Fragment, null, isDraft && /*#__PURE__*/React.createElement(DraftDropdown, null), isStarIconShown && /*#__PURE__*/React.createElement("button", {
|
|
42
46
|
className: "doc-icon sdocfont ".concat(isStarred ? 'sdoc-starred' : 'sdoc-unstarred', " border-0 p-0 bg-transparent"),
|
|
43
47
|
title: isStarred ? t('Starred') : t('Unstarred'),
|
package/dist/index.js
CHANGED
|
@@ -4,4 +4,5 @@ import SimpleEditor from './pages/simple-editor';
|
|
|
4
4
|
import SimpleViewer from './pages/simple-viewer';
|
|
5
5
|
import DiffViewer from './pages/diff-viewer';
|
|
6
6
|
import PublishedRevisionViewer from './pages/published-revision-viewer';
|
|
7
|
-
|
|
7
|
+
import WikiViewer from './pages/wiki-viewer';
|
|
8
|
+
export { SDocViewer, SimpleEditor, SimpleViewer, EventBus, EXTERNAL_EVENT, DiffViewer, PublishedRevisionViewer, WikiViewer };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import context from '../context';
|
|
3
|
+
import ErrorBoundary from './error-boundary';
|
|
4
|
+
import { SDocWikiViewer } from '../basic-sdk';
|
|
5
|
+
import '../assets/css/simple-viewer.css';
|
|
6
|
+
const WikiViewer = _ref => {
|
|
7
|
+
let {
|
|
8
|
+
document,
|
|
9
|
+
showOutline,
|
|
10
|
+
scrollRef
|
|
11
|
+
} = _ref;
|
|
12
|
+
context.initApi();
|
|
13
|
+
return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(SDocWikiViewer, {
|
|
14
|
+
document: document,
|
|
15
|
+
showOutline: showOutline,
|
|
16
|
+
scrollRef: scrollRef
|
|
17
|
+
}));
|
|
18
|
+
};
|
|
19
|
+
export default WikiViewer;
|
package/package.json
CHANGED
|
@@ -424,6 +424,9 @@
|
|
|
424
424
|
"Row_number": "Row number",
|
|
425
425
|
"Column_number": "Column number",
|
|
426
426
|
"The_maximum_row_number_is_{number}": "The maximum row number is {number}",
|
|
427
|
-
"Freeze_Document": "Freeze
|
|
428
|
-
"Unfreeze": "Unfreeze"
|
|
427
|
+
"Freeze_Document": "Freeze document",
|
|
428
|
+
"Unfreeze": "Unfreeze",
|
|
429
|
+
"Other_modification": "Other's modification",
|
|
430
|
+
"My_modification": "My modification",
|
|
431
|
+
"Document_history": "Document history"
|
|
429
432
|
}
|
|
@@ -424,6 +424,9 @@
|
|
|
424
424
|
"Row_number": "Row number",
|
|
425
425
|
"Column_number": "Column number",
|
|
426
426
|
"The_maximum_row_number_is_{number}": "The maximum row number is {number}",
|
|
427
|
-
"Freeze_Document": "Freeze
|
|
428
|
-
"Unfreeze": "Unfreeze"
|
|
427
|
+
"Freeze_Document": "Freeze document",
|
|
428
|
+
"Unfreeze": "Unfreeze",
|
|
429
|
+
"Other_modification": "Other's modification",
|
|
430
|
+
"My_modification": "My modification",
|
|
431
|
+
"Document_history": "Document history"
|
|
429
432
|
}
|
|
@@ -424,7 +424,7 @@
|
|
|
424
424
|
"Row_number": "Row number",
|
|
425
425
|
"Column_number": "Column number",
|
|
426
426
|
"The_maximum_row_number_is_{number}": "The maximum row number is {number}",
|
|
427
|
-
"Freeze_Document": "Freeze
|
|
427
|
+
"Freeze_Document": "Freeze document",
|
|
428
428
|
"Unfreeze": "Unfreeze",
|
|
429
429
|
"Other_modification": "Other's modification",
|
|
430
430
|
"My_modification": "My modification",
|
|
@@ -424,6 +424,9 @@
|
|
|
424
424
|
"Row_number": "Row number",
|
|
425
425
|
"Column_number": "Column number",
|
|
426
426
|
"The_maximum_row_number_is_{number}": "The maximum row number is {number}",
|
|
427
|
-
"Freeze_Document": "Freeze
|
|
428
|
-
"Unfreeze": "Unfreeze"
|
|
427
|
+
"Freeze_Document": "Freeze document",
|
|
428
|
+
"Unfreeze": "Unfreeze",
|
|
429
|
+
"Other_modification": "Other's modification",
|
|
430
|
+
"My_modification": "My modification",
|
|
431
|
+
"Document_history": "Document history"
|
|
429
432
|
}
|
|
@@ -424,6 +424,9 @@
|
|
|
424
424
|
"Row_number": "Row number",
|
|
425
425
|
"Column_number": "Column number",
|
|
426
426
|
"The_maximum_row_number_is_{number}": "The maximum row number is {number}",
|
|
427
|
-
"Freeze_Document": "Freeze
|
|
428
|
-
"Unfreeze": "Unfreeze"
|
|
427
|
+
"Freeze_Document": "Freeze document",
|
|
428
|
+
"Unfreeze": "Unfreeze",
|
|
429
|
+
"Other_modification": "Other's modification",
|
|
430
|
+
"My_modification": "My modification",
|
|
431
|
+
"Document_history": "Document history"
|
|
429
432
|
}
|
|
@@ -424,6 +424,9 @@
|
|
|
424
424
|
"Row_number": "Row number",
|
|
425
425
|
"Column_number": "Column number",
|
|
426
426
|
"The_maximum_row_number_is_{number}": "The maximum row number is {number}",
|
|
427
|
-
"Freeze_Document": "Freeze
|
|
428
|
-
"Unfreeze": "Unfreeze"
|
|
427
|
+
"Freeze_Document": "Freeze document",
|
|
428
|
+
"Unfreeze": "Unfreeze",
|
|
429
|
+
"Other_modification": "Other's modification",
|
|
430
|
+
"My_modification": "My modification",
|
|
431
|
+
"Document_history": "Document history"
|
|
429
432
|
}
|
|
@@ -424,6 +424,9 @@
|
|
|
424
424
|
"Row_number": "Номер строки",
|
|
425
425
|
"Column_number": "Номер столбца",
|
|
426
426
|
"The_maximum_row_number_is_{number}": "Максимальное количество строк - {number}",
|
|
427
|
-
"Freeze_Document": "
|
|
428
|
-
"Unfreeze": "Разморозить"
|
|
427
|
+
"Freeze_Document": "Freeze document",
|
|
428
|
+
"Unfreeze": "Разморозить",
|
|
429
|
+
"Other_modification": "Другая модификация",
|
|
430
|
+
"My_modification": "Моя модификация",
|
|
431
|
+
"Document_history": "История документа"
|
|
429
432
|
}
|