@seafile/sdoc-editor 0.5.70 → 0.5.72
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/editor/editable-article.js +4 -3
- package/dist/basic-sdk/extension/commons/file-insert-dialog/index.js +39 -13
- package/dist/basic-sdk/extension/commons/insert-element-dialog/index.js +12 -2
- package/dist/basic-sdk/extension/constants/element-type.js +2 -0
- package/dist/basic-sdk/extension/constants/index.js +3 -3
- package/dist/basic-sdk/extension/constants/menus-config.js +8 -2
- package/dist/basic-sdk/extension/plugins/index.js +5 -3
- package/dist/basic-sdk/extension/plugins/link/dialog/add-link-dialog/index.js +5 -2
- package/dist/basic-sdk/extension/plugins/link/plugin.js +26 -11
- package/dist/basic-sdk/extension/plugins/sdoc-link/hover-menu/index.js +4 -3
- package/dist/basic-sdk/extension/plugins/sdoc-link/plugin.js +3 -2
- package/dist/basic-sdk/extension/plugins/sdoc-link/render/render-elem.js +8 -2
- package/dist/basic-sdk/extension/plugins/{column → seatable-column}/helpers.js +59 -8
- package/dist/basic-sdk/extension/plugins/{column → seatable-column}/index.js +2 -4
- package/dist/basic-sdk/extension/plugins/seatable-column/menu/column-list-menu.css +35 -0
- package/dist/basic-sdk/extension/plugins/seatable-column/menu/column-list-menu.js +47 -0
- package/dist/basic-sdk/extension/plugins/seatable-column/menu/index.js +31 -0
- package/dist/basic-sdk/extension/plugins/seatable-column/model.js +12 -0
- package/dist/basic-sdk/extension/plugins/seatable-column/render-elem.js +48 -0
- package/dist/basic-sdk/extension/plugins/seatable-views/helpers.js +50 -0
- package/dist/basic-sdk/extension/plugins/seatable-views/index.js +14 -0
- package/dist/basic-sdk/extension/plugins/seatable-views/menu/index.js +40 -0
- package/dist/basic-sdk/extension/plugins/seatable-views/model.js +12 -0
- package/dist/basic-sdk/extension/plugins/seatable-views/plugin.js +52 -0
- package/dist/basic-sdk/extension/plugins/seatable-views/render-element/index.css +20 -0
- package/dist/basic-sdk/extension/plugins/seatable-views/render-element/index.js +8 -0
- package/dist/basic-sdk/extension/plugins/seatable-views/render-element/record-header.js +19 -0
- package/dist/basic-sdk/extension/plugins/seatable-views/render-element/record-item.js +22 -0
- package/dist/basic-sdk/extension/plugins/seatable-views/render-element/record-list.js +19 -0
- package/dist/basic-sdk/extension/plugins/seatable-views/render-element/seatable-view.js +57 -0
- package/dist/basic-sdk/extension/plugins/table/render/table-header/rows-header/index.js +0 -1
- package/dist/basic-sdk/extension/plugins/wiki-link/helpers.js +60 -0
- package/dist/basic-sdk/extension/plugins/wiki-link/index.js +9 -0
- package/dist/basic-sdk/extension/render/custom-element.js +16 -7
- package/dist/basic-sdk/extension/toolbar/header-toolbar/index.js +1 -6
- package/dist/basic-sdk/extension/toolbar/header-toolbar/insert-toolbar/index.js +3 -2
- package/dist/constants/index.js +2 -0
- package/dist/index.js +1 -2
- package/dist/pages/document-plugin-editor.js +25 -5
- package/package.json +1 -1
- package/public/locales/cs/sdoc-editor.json +2 -1
- package/public/locales/de/sdoc-editor.json +2 -1
- package/public/locales/en/sdoc-editor.json +4 -2
- package/public/locales/es/sdoc-editor.json +2 -1
- package/public/locales/es_AR/sdoc-editor.json +465 -0
- package/public/locales/es_MX/sdoc-editor.json +465 -0
- package/public/locales/fr/sdoc-editor.json +2 -1
- package/public/locales/it/sdoc-editor.json +2 -1
- package/public/locales/ru/sdoc-editor.json +5 -4
- package/public/locales/zh_CN/sdoc-editor.json +2 -1
- package/dist/basic-sdk/extension/plugins/column/menu/index.js +0 -28
- package/dist/basic-sdk/extension/plugins/column/model.js +0 -14
- package/dist/basic-sdk/extension/plugins/column/render-elem.js +0 -111
- package/dist/pages/document-plugin-viewer.js +0 -55
- package/public/locales/es-AR/sdoc-editor.json +0 -169
- package/public/locales/es-MX/sdoc-editor.json +0 -169
- /package/dist/basic-sdk/extension/plugins/{column → seatable-column}/constants/cell-types.js +0 -0
- /package/dist/basic-sdk/extension/plugins/{column → seatable-column}/constants/column.js +0 -0
- /package/dist/basic-sdk/extension/plugins/{column → seatable-column}/plugin.js +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MENUS_CONFIG_MAP, ELEMENT_TYPE } from '../../../constants';
|
|
3
|
+
import DropdownMenuItem from '../../../commons/dropdown-menu-item';
|
|
4
|
+
import ColumnListMenu from './column-list-menu';
|
|
5
|
+
import { UncontrolledPopover } from 'reactstrap';
|
|
6
|
+
import { isMenuDisabled } from '../helpers';
|
|
7
|
+
const SeaTableColumnMenu = _ref => {
|
|
8
|
+
let {
|
|
9
|
+
editor,
|
|
10
|
+
readonly
|
|
11
|
+
} = _ref;
|
|
12
|
+
const disabled = isMenuDisabled(editor, readonly);
|
|
13
|
+
const menuConfig = MENUS_CONFIG_MAP[ELEMENT_TYPE.COLUMN];
|
|
14
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DropdownMenuItem, {
|
|
15
|
+
disabled: disabled,
|
|
16
|
+
menuConfig: menuConfig,
|
|
17
|
+
className: "pr-2"
|
|
18
|
+
}, !disabled && /*#__PURE__*/React.createElement("i", {
|
|
19
|
+
className: "sdocfont sdoc-right-slide sdoc-dropdown-item-right-icon"
|
|
20
|
+
})), !disabled && /*#__PURE__*/React.createElement(UncontrolledPopover, {
|
|
21
|
+
target: menuConfig.id,
|
|
22
|
+
trigger: "hover",
|
|
23
|
+
placement: "right-start",
|
|
24
|
+
hideArrow: true,
|
|
25
|
+
fade: false
|
|
26
|
+
}, /*#__PURE__*/React.createElement(ColumnListMenu, {
|
|
27
|
+
editor: editor,
|
|
28
|
+
readonly: readonly
|
|
29
|
+
})));
|
|
30
|
+
};
|
|
31
|
+
export default SeaTableColumnMenu;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import React, { useState, useEffect } from 'react';
|
|
3
|
+
import { useReadOnly, useSelected } from '@seafile/slate-react';
|
|
4
|
+
const Column = _ref => {
|
|
5
|
+
let {
|
|
6
|
+
props,
|
|
7
|
+
editor
|
|
8
|
+
} = _ref;
|
|
9
|
+
const {
|
|
10
|
+
attributes,
|
|
11
|
+
element,
|
|
12
|
+
children
|
|
13
|
+
} = props;
|
|
14
|
+
const isReadOnly = useReadOnly();
|
|
15
|
+
const isSelected = useSelected();
|
|
16
|
+
const data = element.data || {};
|
|
17
|
+
const {
|
|
18
|
+
key: columnKey,
|
|
19
|
+
name: columnName
|
|
20
|
+
} = data;
|
|
21
|
+
let displayValue = columnName ? "{".concat(columnName, "}") : '';
|
|
22
|
+
if (editor.getColumnCellValue) {
|
|
23
|
+
displayValue = editor.getColumnCellValue(columnKey) || 'null';
|
|
24
|
+
}
|
|
25
|
+
const [isClicked, setIsClicked] = useState(false);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (isSelected && !isReadOnly) {
|
|
28
|
+
setIsClicked(true);
|
|
29
|
+
} else {
|
|
30
|
+
setIsClicked(false);
|
|
31
|
+
}
|
|
32
|
+
}, [isSelected, isReadOnly]);
|
|
33
|
+
const style = _objectSpread(_objectSpread({}, isClicked && {
|
|
34
|
+
border: '1px solid red'
|
|
35
|
+
}), {}, {
|
|
36
|
+
margin: '0 10px'
|
|
37
|
+
});
|
|
38
|
+
return /*#__PURE__*/React.createElement("span", Object.assign({}, attributes, {
|
|
39
|
+
style: style
|
|
40
|
+
}), displayValue, children);
|
|
41
|
+
};
|
|
42
|
+
const renderColumn = (props, editor) => {
|
|
43
|
+
return /*#__PURE__*/React.createElement(Column, {
|
|
44
|
+
props: props,
|
|
45
|
+
editor: editor
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
export default renderColumn;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Editor, Transforms } from '@seafile/slate';
|
|
2
|
+
import slugId from 'slugid';
|
|
3
|
+
import { getNodeType, isTextNode, getParentNode, generateDefaultText } from '../../core';
|
|
4
|
+
import { ELEMENT_TYPE, SEATABLE_VIEW } from '../../constants';
|
|
5
|
+
export const isInsertSeaTableViewDisabled = (editor, readonly) => {
|
|
6
|
+
if (readonly) return true;
|
|
7
|
+
const {
|
|
8
|
+
selection
|
|
9
|
+
} = editor;
|
|
10
|
+
if (selection === null) return true;
|
|
11
|
+
const [match] = Editor.nodes(editor, {
|
|
12
|
+
match: n => {
|
|
13
|
+
let type = getNodeType(n);
|
|
14
|
+
if (!type && isTextNode(n) && n.id) {
|
|
15
|
+
const parentNode = getParentNode(editor.children, n.id);
|
|
16
|
+
type = getNodeType(parentNode);
|
|
17
|
+
}
|
|
18
|
+
if (type.startsWith('header')) return true;
|
|
19
|
+
if (type === ELEMENT_TYPE.CODE_BLOCK) return true;
|
|
20
|
+
if (type === ELEMENT_TYPE.ORDERED_LIST) return true;
|
|
21
|
+
if (type === ELEMENT_TYPE.UNORDERED_LIST) return true;
|
|
22
|
+
if (type === ELEMENT_TYPE.BLOCKQUOTE) return true;
|
|
23
|
+
if (type === ELEMENT_TYPE.LIST_ITEM) return true;
|
|
24
|
+
if (type === ELEMENT_TYPE.TABLE) return true;
|
|
25
|
+
if (type === ELEMENT_TYPE.TABLE_CELL) return true;
|
|
26
|
+
if (type === ELEMENT_TYPE.TABLE_ROW) return true;
|
|
27
|
+
if (type === ELEMENT_TYPE.CALL_OUT) return true;
|
|
28
|
+
if (Editor.isVoid(editor, n)) return true;
|
|
29
|
+
return false;
|
|
30
|
+
},
|
|
31
|
+
universal: true
|
|
32
|
+
});
|
|
33
|
+
if (match) return true;
|
|
34
|
+
return false;
|
|
35
|
+
};
|
|
36
|
+
export const generateSeaTableView = (table_id, view_id) => {
|
|
37
|
+
return {
|
|
38
|
+
id: slugId.nice(),
|
|
39
|
+
type: SEATABLE_VIEW,
|
|
40
|
+
table_id,
|
|
41
|
+
view_id,
|
|
42
|
+
children: [generateDefaultText()]
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
export const insertSeaTableView = (editor, item) => {
|
|
46
|
+
const table_id = editor.table_id;
|
|
47
|
+
const view_id = item._id;
|
|
48
|
+
const node = generateSeaTableView(table_id, view_id);
|
|
49
|
+
Transforms.setNodes(editor, node);
|
|
50
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SEATABLE_VIEW } from '../../constants';
|
|
2
|
+
import ImageMenu from './menu';
|
|
3
|
+
import SeaTableView from './model';
|
|
4
|
+
import withSeaTableView from './plugin';
|
|
5
|
+
import renderSeaTableView from './render-element';
|
|
6
|
+
const SeaTableViewsPlugin = {
|
|
7
|
+
type: SEATABLE_VIEW,
|
|
8
|
+
nodeType: 'element',
|
|
9
|
+
model: SeaTableView,
|
|
10
|
+
editorMenus: [ImageMenu],
|
|
11
|
+
editorPlugin: withSeaTableView,
|
|
12
|
+
renderElements: [renderSeaTableView]
|
|
13
|
+
};
|
|
14
|
+
export default SeaTableViewsPlugin;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { UncontrolledPopover } from 'reactstrap';
|
|
3
|
+
import { insertSeaTableView, isInsertSeaTableViewDisabled } from '../helpers';
|
|
4
|
+
import { MENUS_CONFIG_MAP, SEATABLE_VIEW } from '../../../constants';
|
|
5
|
+
import DropdownMenuItem from '../../../commons/dropdown-menu-item';
|
|
6
|
+
const SeaTableViewMenu = _ref => {
|
|
7
|
+
let {
|
|
8
|
+
editor,
|
|
9
|
+
readonly
|
|
10
|
+
} = _ref;
|
|
11
|
+
const disabled = isInsertSeaTableViewDisabled(editor, readonly);
|
|
12
|
+
const menuConfig = MENUS_CONFIG_MAP[SEATABLE_VIEW];
|
|
13
|
+
const views = editor.views;
|
|
14
|
+
const onViewClick = useCallback(item => {
|
|
15
|
+
insertSeaTableView(editor, item);
|
|
16
|
+
}, [editor]);
|
|
17
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DropdownMenuItem, {
|
|
18
|
+
disabled: disabled,
|
|
19
|
+
menuConfig: menuConfig,
|
|
20
|
+
className: "pr-2"
|
|
21
|
+
}, !disabled && /*#__PURE__*/React.createElement("i", {
|
|
22
|
+
className: "sdocfont sdoc-right-slide sdoc-dropdown-item-right-icon"
|
|
23
|
+
})), !disabled && /*#__PURE__*/React.createElement(UncontrolledPopover, {
|
|
24
|
+
target: menuConfig.id,
|
|
25
|
+
trigger: "hover",
|
|
26
|
+
className: "sdoc-menu-popover sdoc-dropdown-menu sdoc-sub-dropdown-menu",
|
|
27
|
+
placement: "right-start",
|
|
28
|
+
hideArrow: true,
|
|
29
|
+
fade: false
|
|
30
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
31
|
+
className: "sdoc-dropdown-menu-container"
|
|
32
|
+
}, views.map(item => {
|
|
33
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
34
|
+
key: item._id,
|
|
35
|
+
className: "sdoc-dropdown-menu-item",
|
|
36
|
+
onClick: () => onViewClick(item)
|
|
37
|
+
}, item.name);
|
|
38
|
+
}))));
|
|
39
|
+
};
|
|
40
|
+
export default SeaTableViewMenu;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SEATABLE_VIEW } from '../../constants/element-type';
|
|
2
|
+
class SeaTableView {
|
|
3
|
+
constructor(options) {
|
|
4
|
+
this.type = options.type || SEATABLE_VIEW;
|
|
5
|
+
this.table_id = options.table_id;
|
|
6
|
+
this.view_id = options.view_id;
|
|
7
|
+
this.children = options.children || [{
|
|
8
|
+
text: ''
|
|
9
|
+
}];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export default SeaTableView;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Transforms, Path, Editor, Element, Range } from '@seafile/slate';
|
|
2
|
+
import { focusEditor, isBlockAboveEmpty } from '../../core';
|
|
3
|
+
import { SEATABLE_VIEW } from '../../constants/element-type';
|
|
4
|
+
const withSeaTableView = editor => {
|
|
5
|
+
const {
|
|
6
|
+
isVoid,
|
|
7
|
+
deleteBackward
|
|
8
|
+
} = editor;
|
|
9
|
+
const newEditor = editor;
|
|
10
|
+
|
|
11
|
+
// rewrite isVoid
|
|
12
|
+
newEditor.isVoid = elem => {
|
|
13
|
+
const {
|
|
14
|
+
type
|
|
15
|
+
} = elem;
|
|
16
|
+
if (type === SEATABLE_VIEW) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
return isVoid(elem);
|
|
20
|
+
};
|
|
21
|
+
newEditor.deleteBackward = unit => {
|
|
22
|
+
const {
|
|
23
|
+
selection
|
|
24
|
+
} = editor;
|
|
25
|
+
const focusPoint = Editor.before(editor, selection);
|
|
26
|
+
const point = Editor.before(editor, selection, {
|
|
27
|
+
distance: 1
|
|
28
|
+
});
|
|
29
|
+
if (!point) return deleteBackward(unit);
|
|
30
|
+
const [node, path] = Editor.node(editor, [point.path[0], point.path[1]]);
|
|
31
|
+
const isPerviousSeaTableView = node.type === SEATABLE_VIEW;
|
|
32
|
+
if (isPerviousSeaTableView && Range.isCollapsed(selection) && isBlockAboveEmpty(editor) && !Path.isCommon(path, selection.anchor.path)) {
|
|
33
|
+
deleteBackward(unit);
|
|
34
|
+
focusEditor(newEditor, Editor.end(newEditor, focusPoint));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (Element.isElement(node) && node.type === SEATABLE_VIEW) {
|
|
38
|
+
// If the wrapping element is image_block, delete the wrapping element
|
|
39
|
+
const [parentNode, p] = Editor.node(editor, [path[0]]);
|
|
40
|
+
if (parentNode.type === SEATABLE_VIEW) {
|
|
41
|
+
Transforms.removeNodes(editor, {
|
|
42
|
+
at: p
|
|
43
|
+
});
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
focusEditor(editor, Path.next(path));
|
|
47
|
+
}
|
|
48
|
+
deleteBackward(unit);
|
|
49
|
+
};
|
|
50
|
+
return newEditor;
|
|
51
|
+
};
|
|
52
|
+
export default withSeaTableView;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
.seatable-view-container {
|
|
2
|
+
width: 100%;
|
|
3
|
+
height: 400px;
|
|
4
|
+
overflow: auto;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.seatable-view-container.selected {
|
|
8
|
+
border: 1px solid red;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.seatable-view-container .seatable-view-records {
|
|
12
|
+
margin: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.seatable-view-body-column-cell {
|
|
16
|
+
white-space: nowrap;
|
|
17
|
+
text-overflow: ellipsis;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
word-break: break-all;
|
|
20
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import SeaTableView from './seatable-view';
|
|
3
|
+
const renderSeaTableView = (props, editor) => {
|
|
4
|
+
return /*#__PURE__*/React.createElement(SeaTableView, Object.assign({}, props, {
|
|
5
|
+
editor: editor
|
|
6
|
+
}));
|
|
7
|
+
};
|
|
8
|
+
export default renderSeaTableView;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { getColumnWidth } from '../../seatable-column/helpers';
|
|
3
|
+
export default function RecordHeader(_ref) {
|
|
4
|
+
let {
|
|
5
|
+
columns
|
|
6
|
+
} = _ref;
|
|
7
|
+
return /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", {
|
|
8
|
+
className: "seatable-view-column-header-row"
|
|
9
|
+
}, columns.map(column => {
|
|
10
|
+
const width = getColumnWidth(column);
|
|
11
|
+
return /*#__PURE__*/React.createElement("th", {
|
|
12
|
+
className: "seatable-view-column-header-cell",
|
|
13
|
+
key: column.key,
|
|
14
|
+
style: {
|
|
15
|
+
width
|
|
16
|
+
}
|
|
17
|
+
}, column.name);
|
|
18
|
+
})));
|
|
19
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { getColumnWidth } from '../../seatable-column/helpers';
|
|
3
|
+
export default function RecordItem(_ref) {
|
|
4
|
+
let {
|
|
5
|
+
editor,
|
|
6
|
+
record,
|
|
7
|
+
columns,
|
|
8
|
+
getViewCellValue
|
|
9
|
+
} = _ref;
|
|
10
|
+
return /*#__PURE__*/React.createElement("tr", {
|
|
11
|
+
className: "seatable-view-body-column-row"
|
|
12
|
+
}, columns.map(column => {
|
|
13
|
+
const width = getColumnWidth(column);
|
|
14
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
15
|
+
className: "seatable-view-body-column-cell",
|
|
16
|
+
key: record._id + '_' + column.key,
|
|
17
|
+
style: {
|
|
18
|
+
width
|
|
19
|
+
}
|
|
20
|
+
}, getViewCellValue(record, column));
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import RecordItem from './record-item';
|
|
3
|
+
export default function RecordList(_ref) {
|
|
4
|
+
let {
|
|
5
|
+
records,
|
|
6
|
+
columns,
|
|
7
|
+
editor,
|
|
8
|
+
getViewCellValue
|
|
9
|
+
} = _ref;
|
|
10
|
+
return /*#__PURE__*/React.createElement("tbody", null, records.map(record => {
|
|
11
|
+
return /*#__PURE__*/React.createElement(RecordItem, {
|
|
12
|
+
key: record._id,
|
|
13
|
+
record: record,
|
|
14
|
+
columns: columns,
|
|
15
|
+
editor: editor,
|
|
16
|
+
getViewCellValue: getViewCellValue
|
|
17
|
+
});
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { useSelected } from '@seafile/slate-react';
|
|
4
|
+
import Loading from '../../../../../components/loading';
|
|
5
|
+
import RecordHeader from './record-header';
|
|
6
|
+
import RecordList from './record-list';
|
|
7
|
+
import './index.css';
|
|
8
|
+
function SeaTableView(_ref) {
|
|
9
|
+
let {
|
|
10
|
+
element,
|
|
11
|
+
className,
|
|
12
|
+
attributes,
|
|
13
|
+
children,
|
|
14
|
+
editor,
|
|
15
|
+
t
|
|
16
|
+
} = _ref;
|
|
17
|
+
const isSelected = useSelected();
|
|
18
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
19
|
+
const [records, setRecords] = useState([]);
|
|
20
|
+
const [columns, setColumns] = useState([]);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const {
|
|
23
|
+
table_id,
|
|
24
|
+
view_id
|
|
25
|
+
} = element;
|
|
26
|
+
const rows = editor.getViewRowsById(table_id, view_id);
|
|
27
|
+
const columns = editor.getViewColsById(table_id, view_id);
|
|
28
|
+
setRecords(rows);
|
|
29
|
+
setColumns(columns);
|
|
30
|
+
setIsLoading(false);
|
|
31
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
|
+
}, [element]);
|
|
33
|
+
const containerClass = classNames('seatable-view-container', {
|
|
34
|
+
selected: isSelected
|
|
35
|
+
});
|
|
36
|
+
const getViewCellValue = useCallback((row, column) => {
|
|
37
|
+
const {
|
|
38
|
+
table_id,
|
|
39
|
+
view_id
|
|
40
|
+
} = element;
|
|
41
|
+
return editor.getViewCellValue(table_id, view_id, row, column);
|
|
42
|
+
}, [editor, element]);
|
|
43
|
+
return /*#__PURE__*/React.createElement("div", Object.assign({}, attributes, {
|
|
44
|
+
className: containerClass,
|
|
45
|
+
contentEditable: false
|
|
46
|
+
}), isLoading && /*#__PURE__*/React.createElement(Loading, null), !isLoading && /*#__PURE__*/React.createElement("table", {
|
|
47
|
+
className: "seatable-view-records"
|
|
48
|
+
}, /*#__PURE__*/React.createElement(RecordHeader, {
|
|
49
|
+
columns: columns
|
|
50
|
+
}), /*#__PURE__*/React.createElement(RecordList, {
|
|
51
|
+
editor: editor,
|
|
52
|
+
records: records,
|
|
53
|
+
columns: columns,
|
|
54
|
+
getViewCellValue: getViewCellValue
|
|
55
|
+
})), children);
|
|
56
|
+
}
|
|
57
|
+
export default SeaTableView;
|
|
@@ -64,7 +64,6 @@ const RowsHeader = _ref => {
|
|
|
64
64
|
className: classnames('position-fixed sdoc-table-add-element-icon-content', {
|
|
65
65
|
'background-color-tip-blue': isHoverInAddIcon
|
|
66
66
|
}),
|
|
67
|
-
contentEditable: false,
|
|
68
67
|
style: addIconPosition,
|
|
69
68
|
onMouseEnter: () => onMouseEnter(addIconPosition),
|
|
70
69
|
onMouseLeave: onMouseLeave,
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Editor, Transforms, Range } from '@seafile/slate';
|
|
2
|
+
import slugid from 'slugid';
|
|
3
|
+
import { INSERT_FILE_DISPLAY_TYPE } from '../../constants';
|
|
4
|
+
import { isMenuDisabled, removeShortCutSymbol } from '../sdoc-link/helpers';
|
|
5
|
+
import { WIKI_LINK } from '../../constants/element-type';
|
|
6
|
+
export const insertWikiPageLink = (editor, text, wikiRepoId, pageId) => {
|
|
7
|
+
if (isMenuDisabled(editor)) return;
|
|
8
|
+
// Selection folded or not
|
|
9
|
+
const {
|
|
10
|
+
selection
|
|
11
|
+
} = editor;
|
|
12
|
+
if (selection == null) return;
|
|
13
|
+
const isCollapsed = Range.isCollapsed(selection);
|
|
14
|
+
|
|
15
|
+
// Remove shortcut symbol,if trigger by shortcut
|
|
16
|
+
removeShortCutSymbol(editor);
|
|
17
|
+
const wikiLinkNode = generateSdocFileNode(wikiRepoId, pageId, text);
|
|
18
|
+
if (isCollapsed) {
|
|
19
|
+
Transforms.insertNodes(editor, wikiLinkNode);
|
|
20
|
+
} else {
|
|
21
|
+
const selectedText = Editor.string(editor, selection); // Selected text
|
|
22
|
+
if (selectedText !== text) {
|
|
23
|
+
// If the selected text is different from the typed text, delete the text and insert the link
|
|
24
|
+
editor.deleteFragment();
|
|
25
|
+
Transforms.insertNodes(editor, wikiLinkNode);
|
|
26
|
+
} else {
|
|
27
|
+
// If the selected text is the same as the entered text, only the link can be wrapped
|
|
28
|
+
Transforms.wrapNodes(editor, wikiLinkNode, {
|
|
29
|
+
split: true
|
|
30
|
+
});
|
|
31
|
+
Transforms.collapse(editor, {
|
|
32
|
+
edge: 'end'
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
export const generateSdocFileNode = function (wikiRepoId, pageId) {
|
|
38
|
+
let title = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
39
|
+
const wikiPageLinkNode = {
|
|
40
|
+
id: slugid.nice(),
|
|
41
|
+
type: WIKI_LINK,
|
|
42
|
+
wiki_repo_id: wikiRepoId,
|
|
43
|
+
page_id: pageId,
|
|
44
|
+
title: title,
|
|
45
|
+
display_type: INSERT_FILE_DISPLAY_TYPE[1],
|
|
46
|
+
children: [{
|
|
47
|
+
id: slugid.nice(),
|
|
48
|
+
text: title
|
|
49
|
+
}]
|
|
50
|
+
};
|
|
51
|
+
return wikiPageLinkNode;
|
|
52
|
+
};
|
|
53
|
+
export const getWikiUrl = (wikiRepoId, pageId) => {
|
|
54
|
+
const {
|
|
55
|
+
origin,
|
|
56
|
+
pathname
|
|
57
|
+
} = window.location;
|
|
58
|
+
const pathName = pathname.replace(/\d+\/$/, "".concat(wikiRepoId, "/"));
|
|
59
|
+
return "".concat(origin).concat(pathName, "?page_id=").concat(pageId);
|
|
60
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { WIKI_LINK } from '../../constants/element-type';
|
|
2
|
+
import withSdocLink from '../sdoc-link/plugin';
|
|
3
|
+
import renderWikiLink from '../sdoc-link/render/render-elem';
|
|
4
|
+
const WikiLinkPlugin = {
|
|
5
|
+
type: WIKI_LINK,
|
|
6
|
+
editorPlugin: withSdocLink,
|
|
7
|
+
renderElements: [renderWikiLink]
|
|
8
|
+
};
|
|
9
|
+
export default WikiLinkPlugin;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import { useReadOnly, useSlateStatic } from '@seafile/slate-react';
|
|
3
3
|
import { BLOCKQUOTE, LINK, CHECK_LIST_ITEM, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, LIST_ITEM, ORDERED_LIST, PARAGRAPH, UNORDERED_LIST, CODE_BLOCK, CODE_LINE, IMAGE, IMAGE_BLOCK, ELEMENT_TYPE, SDOC_LINK, FILE_LINK, TITLE, SUBTITLE, CALL_OUT, SUPPORTED_SIDE_OPERATION_TYPE, MENTION, MENTION_TEMP, FILE_LINK_INSET_INPUT_TEMP, QUICK_INSERT } from '../constants';
|
|
4
|
-
import { BlockquotePlugin, LinkPlugin, CheckListPlugin, HeaderPlugin, ListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, SdocLinkPlugin, ParagraphPlugin, FileLinkPlugin, CalloutPlugin, MentionPlugin, QuickInsertPlugin,
|
|
4
|
+
import { BlockquotePlugin, LinkPlugin, CheckListPlugin, HeaderPlugin, ListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, SdocLinkPlugin, ParagraphPlugin, FileLinkPlugin, CalloutPlugin, MentionPlugin, QuickInsertPlugin, WikiLinkPlugin, SeaTableColumnPlugin, SeaTableViewsPlugin } from '../plugins';
|
|
5
5
|
import { onDragOver, onDragLeave, onDrop } from '../toolbar/side-toolbar/event';
|
|
6
6
|
import { getParentNode } from '../core';
|
|
7
7
|
import { setDataRoot, setMouseEnter } from './helper';
|
|
8
|
-
import { COLUMN } from '../constants/element-type';
|
|
8
|
+
import { COLUMN, WIKI_LINK, SEATABLE_VIEW } from '../constants/element-type';
|
|
9
9
|
import { WIKI_EDITOR, DIFF_VIEWER } from '../../constants';
|
|
10
10
|
const CustomRenderElement = props => {
|
|
11
11
|
const editor = useSlateStatic();
|
|
@@ -28,7 +28,8 @@ const CustomRenderElement = props => {
|
|
|
28
28
|
case PARAGRAPH:
|
|
29
29
|
{
|
|
30
30
|
const parentNode = getParentNode(editor.children, element.id);
|
|
31
|
-
|
|
31
|
+
let placeholder = undefined;
|
|
32
|
+
if (editor.editorType === DIFF_VIEWER) placeholder = '';
|
|
32
33
|
if (parentNode && parentNode.type === LIST_ITEM) {
|
|
33
34
|
const [renderParagraph] = ParagraphPlugin.renderElements;
|
|
34
35
|
return renderParagraph(_objectSpread(_objectSpread({}, props), {}, {
|
|
@@ -36,9 +37,7 @@ const CustomRenderElement = props => {
|
|
|
36
37
|
}));
|
|
37
38
|
}
|
|
38
39
|
// Update the placeholder for the wiki editor
|
|
39
|
-
if (editor.editorType === WIKI_EDITOR)
|
|
40
|
-
placeholder: 'Enter_text_or_press_forward_slash_to_insert_element'
|
|
41
|
-
});
|
|
40
|
+
if (editor.editorType === WIKI_EDITOR) placeholder = 'Enter_text_or_press_forward_slash_to_insert_element';
|
|
42
41
|
const [renderParagraph] = ParagraphPlugin.renderElements;
|
|
43
42
|
return renderParagraph(_objectSpread(_objectSpread({}, props), {}, {
|
|
44
43
|
placeholder
|
|
@@ -170,11 +169,21 @@ const CustomRenderElement = props => {
|
|
|
170
169
|
const [renderQuickInsert] = QuickInsertPlugin.renderElements;
|
|
171
170
|
return renderQuickInsert(props, editor);
|
|
172
171
|
}
|
|
172
|
+
case WIKI_LINK:
|
|
173
|
+
{
|
|
174
|
+
const [renderWikiLink] = WikiLinkPlugin.renderElements;
|
|
175
|
+
return renderWikiLink(props, editor);
|
|
176
|
+
}
|
|
173
177
|
case COLUMN:
|
|
174
178
|
{
|
|
175
|
-
const [renderColumn] =
|
|
179
|
+
const [renderColumn] = SeaTableColumnPlugin.renderElements;
|
|
176
180
|
return renderColumn(props, editor);
|
|
177
181
|
}
|
|
182
|
+
case SEATABLE_VIEW:
|
|
183
|
+
{
|
|
184
|
+
const [renderSeaTableView] = SeaTableViewsPlugin.renderElements;
|
|
185
|
+
return renderSeaTableView(props, editor);
|
|
186
|
+
}
|
|
178
187
|
default:
|
|
179
188
|
{
|
|
180
189
|
const [renderParagraph] = ParagraphPlugin.renderElements;
|
|
@@ -16,12 +16,10 @@ import ActiveTableMenu from '../../plugins/table/menu/active-table-menu';
|
|
|
16
16
|
import CalloutMenu from '../../plugins/callout/menu';
|
|
17
17
|
import SearchReplaceMenu from '../../plugins/search-replace/menu';
|
|
18
18
|
import { getSelectedNodeByType } from '../../core';
|
|
19
|
-
import ColumnMenu from '../../plugins/column/menu';
|
|
20
19
|
const HeaderToolbar = _ref => {
|
|
21
20
|
let {
|
|
22
21
|
editor,
|
|
23
|
-
readonly
|
|
24
|
-
columns
|
|
22
|
+
readonly
|
|
25
23
|
} = _ref;
|
|
26
24
|
useSelectionUpdate();
|
|
27
25
|
const isSelectTableCell = getSelectedNodeByType(editor, TABLE_CELL);
|
|
@@ -65,9 +63,6 @@ const HeaderToolbar = _ref => {
|
|
|
65
63
|
}), /*#__PURE__*/React.createElement(CalloutMenu, {
|
|
66
64
|
editor: editor,
|
|
67
65
|
readonly: readonly
|
|
68
|
-
}), editor.columns && /*#__PURE__*/React.createElement(ColumnMenu, {
|
|
69
|
-
editor: editor,
|
|
70
|
-
readonly: readonly
|
|
71
66
|
})), /*#__PURE__*/React.createElement(ActiveTableMenu, {
|
|
72
67
|
editor: editor,
|
|
73
68
|
readonly: readonly
|
|
@@ -8,6 +8,8 @@ import LinkMenu from '../../../plugins/link/menu';
|
|
|
8
8
|
import CodeBlockMenu from '../../../plugins/code-block/menu';
|
|
9
9
|
import SdocLinkMenu from '../../../plugins/sdoc-link/menu';
|
|
10
10
|
import FileLinkMenu from '../../../plugins/file-link/menu';
|
|
11
|
+
import SeaTableColumnMenu from '../../../plugins/seatable-column/menu';
|
|
12
|
+
import SeaTableViewMenu from '../../../plugins/seatable-views/menu';
|
|
11
13
|
import EventBus from '../../../../utils/event-bus';
|
|
12
14
|
import './index.css';
|
|
13
15
|
const InsertToolbar = _ref => {
|
|
@@ -31,7 +33,6 @@ const InsertToolbar = _ref => {
|
|
|
31
33
|
const toggle = useCallback(event => {
|
|
32
34
|
popoverRef.current && popoverRef.current.toggle();
|
|
33
35
|
setMenuShow(!isShowMenu);
|
|
34
|
-
|
|
35
36
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
36
37
|
}, [isShowMenu]);
|
|
37
38
|
const validClassName = classnames(className, 'sdoc-menu-with-dropdown sdoc-insert-toolbar-btn', {
|
|
@@ -86,7 +87,7 @@ const InsertToolbar = _ref => {
|
|
|
86
87
|
}
|
|
87
88
|
}, /*#__PURE__*/React.createElement(ImageMenu, props), /*#__PURE__*/React.createElement(TableMenu, props), /*#__PURE__*/React.createElement(LinkMenu, props), /*#__PURE__*/React.createElement(CodeBlockMenu, props), /*#__PURE__*/React.createElement("div", {
|
|
88
89
|
className: "sdoc-dropdown-menu-divider"
|
|
89
|
-
}), /*#__PURE__*/React.createElement(SdocLinkMenu, props), /*#__PURE__*/React.createElement(FileLinkMenu, props))));
|
|
90
|
+
}), editor.columns && /*#__PURE__*/React.createElement(SeaTableColumnMenu, props), editor.views && /*#__PURE__*/React.createElement(SeaTableViewMenu, props), /*#__PURE__*/React.createElement(SdocLinkMenu, props), /*#__PURE__*/React.createElement(FileLinkMenu, props))));
|
|
90
91
|
};
|
|
91
92
|
InsertToolbar.defaultProps = {
|
|
92
93
|
isRichEditor: true,
|
package/dist/constants/index.js
CHANGED
|
@@ -19,6 +19,8 @@ export const EXTERNAL_EVENT = {
|
|
|
19
19
|
PARTICIPANT_ADDED: 'participant-added',
|
|
20
20
|
PARTICIPANT_REMOVED: 'participant-removed',
|
|
21
21
|
CREATE_SDOC_FILE: 'create_sdoc_file',
|
|
22
|
+
CREATE_WIKI_PAGE: 'create_wiki_page',
|
|
23
|
+
// wiki
|
|
22
24
|
INSERT_LINK: 'insert_link'
|
|
23
25
|
};
|
|
24
26
|
export const TIP_TYPE = {
|
package/dist/index.js
CHANGED
|
@@ -7,5 +7,4 @@ import PublishedRevisionViewer from './pages/published-revision-viewer';
|
|
|
7
7
|
import WikiViewer from './pages/wiki-viewer';
|
|
8
8
|
import SdocWikiViewer from './pages/sdoc-wiki-viewer';
|
|
9
9
|
import DocumentPluginEditor from './pages/document-plugin-editor';
|
|
10
|
-
|
|
11
|
-
export { SDocViewer, SimpleEditor, SimpleViewer, EventBus, EXTERNAL_EVENT, DiffViewer, PublishedRevisionViewer, WikiViewer, SdocWikiViewer, DocumentPluginEditor, DocumentPluginViewer };
|
|
10
|
+
export { SDocViewer, SimpleEditor, SimpleViewer, EventBus, EXTERNAL_EVENT, DiffViewer, PublishedRevisionViewer, WikiViewer, SdocWikiViewer, DocumentPluginEditor };
|