@seafile/sdoc-editor 0.1.80-beta → 0.1.80-beta1
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.js
CHANGED
|
@@ -9,7 +9,7 @@ import SDocOutline from './outline';
|
|
|
9
9
|
import EventProxy from './utils/event-handler';
|
|
10
10
|
import { useCursors } from './cursor/use-cursors';
|
|
11
11
|
import EventBus from './utils/event-bus';
|
|
12
|
-
import { EXTERNAL_EVENT } from '../constants';
|
|
12
|
+
import { EXTERNAL_EVENT, PAGE_EDIT_AREA_WIDTH } from '../constants';
|
|
13
13
|
import { isAllInTable } from './extension/plugins/table/helpers';
|
|
14
14
|
import { SetNodeToDecorations } from './highlight-decorate/setNodeToDecorations';
|
|
15
15
|
import { ScrollContext } from './hooks/use-scroll-context';
|
|
@@ -17,7 +17,6 @@ import CommentContextProvider from './comment/comment-context-provider';
|
|
|
17
17
|
import CommentWrapper from './comment';
|
|
18
18
|
import { usePipDecorate } from './decorates';
|
|
19
19
|
import { getCursorPosition, getDomHeight, getDomMarginTop } from './utils/dom-utils';
|
|
20
|
-
import { ArticleContext } from './hooks/use-article-width';
|
|
21
20
|
import './assets/css/layout.css';
|
|
22
21
|
import './assets/css/sdoc-editor-plugins.css';
|
|
23
22
|
var SDocEditor = function SDocEditor(_ref) {
|
|
@@ -31,6 +30,7 @@ var SDocEditor = function SDocEditor(_ref) {
|
|
|
31
30
|
}));
|
|
32
31
|
var cursors = document.cursors;
|
|
33
32
|
newEditor.cursors = cursors || {};
|
|
33
|
+
newEditor.width = PAGE_EDIT_AREA_WIDTH; // default width
|
|
34
34
|
return newEditor;
|
|
35
35
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
36
36
|
}, []);
|
|
@@ -62,7 +62,6 @@ var SDocEditor = function SDocEditor(_ref) {
|
|
|
62
62
|
// useMount: init socket connection
|
|
63
63
|
useEffect(function () {
|
|
64
64
|
editor.openConnection();
|
|
65
|
-
editor.width = articleRef.current.children[0].clientWidth;
|
|
66
65
|
return function () {
|
|
67
66
|
editor.closeConnection();
|
|
68
67
|
};
|
|
@@ -72,6 +71,8 @@ var SDocEditor = function SDocEditor(_ref) {
|
|
|
72
71
|
// useMount: focus editor
|
|
73
72
|
useEffect(function () {
|
|
74
73
|
var timer = setTimeout(function () {
|
|
74
|
+
// real width
|
|
75
|
+
editor.width = articleRef.current.children[0].clientWidth;
|
|
75
76
|
focusEditor(editor);
|
|
76
77
|
}, 300);
|
|
77
78
|
return function () {
|
|
@@ -1,37 +1,60 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
|
+
import React from 'react';
|
|
3
7
|
import { withTranslation } from 'react-i18next';
|
|
4
8
|
import { insertTable, isTableMenuDisabled } from '../../helpers';
|
|
5
9
|
import { TABLE, MENUS_CONFIG_MAP } from '../../../../constants';
|
|
6
10
|
import { MenuItem } from '../../../../menu';
|
|
7
11
|
import TableSizePopover from '../../popover/table-size-popover';
|
|
8
|
-
var TableMenu = function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
12
|
+
var TableMenu = /*#__PURE__*/function (_React$Component) {
|
|
13
|
+
_inherits(TableMenu, _React$Component);
|
|
14
|
+
var _super = _createSuper(TableMenu);
|
|
15
|
+
function TableMenu() {
|
|
16
|
+
var _this;
|
|
17
|
+
_classCallCheck(this, TableMenu);
|
|
18
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
19
|
+
args[_key] = arguments[_key];
|
|
20
|
+
}
|
|
21
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
22
|
+
_this.isActive = function () {
|
|
23
|
+
return false;
|
|
24
|
+
};
|
|
25
|
+
_this.isDisabled = function () {
|
|
26
|
+
var editor = _this.props.editor;
|
|
27
|
+
return isTableMenuDisabled(editor);
|
|
28
|
+
};
|
|
29
|
+
_this.createTable = function (size) {
|
|
30
|
+
var editor = _this.props.editor;
|
|
31
|
+
insertTable(editor, size, _this.selection);
|
|
32
|
+
};
|
|
33
|
+
return _this;
|
|
34
|
+
}
|
|
35
|
+
_createClass(TableMenu, [{
|
|
36
|
+
key: "render",
|
|
37
|
+
value: function render() {
|
|
38
|
+
var _this$props = this.props,
|
|
39
|
+
isRichEditor = _this$props.isRichEditor,
|
|
40
|
+
className = _this$props.className;
|
|
41
|
+
var menuConfig = MENUS_CONFIG_MAP[TABLE];
|
|
42
|
+
var props = _objectSpread(_objectSpread({
|
|
43
|
+
isRichEditor: isRichEditor,
|
|
44
|
+
className: className
|
|
45
|
+
}, menuConfig), {}, {
|
|
46
|
+
disabled: this.isDisabled(),
|
|
47
|
+
isActive: this.isActive(),
|
|
48
|
+
onMouseDown: function onMouseDown() {}
|
|
49
|
+
});
|
|
50
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
51
|
+
className: "table-menu"
|
|
52
|
+
}, /*#__PURE__*/React.createElement(MenuItem, props)), /*#__PURE__*/React.createElement(TableSizePopover, {
|
|
53
|
+
target: menuConfig.id,
|
|
54
|
+
createTable: this.createTable
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
}]);
|
|
58
|
+
return TableMenu;
|
|
59
|
+
}(React.Component);
|
|
37
60
|
export default withTranslation('sdoc-editor')(TableMenu);
|
package/package.json
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
2
|
-
export var ArticleContext = React.createContext(null);
|
|
3
|
-
export var useArticleWidth = function useArticleWidth() {
|
|
4
|
-
var context = useContext(ArticleContext);
|
|
5
|
-
if (!context) {
|
|
6
|
-
throw new Error('The \`useArticleWidth\` hook must be used inside the <ArticleContext> component\'s context.');
|
|
7
|
-
}
|
|
8
|
-
var articleRef = context.articleRef;
|
|
9
|
-
if (!articleRef.current) return 0;
|
|
10
|
-
return articleRef.current.firstChild.clientWidth;
|
|
11
|
-
};
|