@seafile/sdoc-editor 0.1.0 → 0.1.2

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.
Files changed (149) hide show
  1. package/dist/{new-editors/editor.js → editor.js} +38 -17
  2. package/dist/index.js +2 -36
  3. package/dist/slate-extension/core/transforms/move-children.js +1 -1
  4. package/dist/slate-extension/plugins/blockquote/helpers.js +3 -3
  5. package/dist/slate-extension/plugins/index.js +3 -2
  6. package/dist/slate-extension/plugins/list/transforms/normalize-list-item.js +2 -2
  7. package/dist/slate-extension/plugins/list/transforms/toggle-list.js +6 -8
  8. package/dist/slate-extension/plugins/socket/index.js +6 -0
  9. package/dist/slate-extension/plugins/socket/plugin.js +23 -0
  10. package/dist/slate-extension/socket/socket-client.js +94 -0
  11. package/dist/slate-extension/socket/socket-manager.js +63 -0
  12. package/dist/slate-extension/toolbar/index.js +1 -1
  13. package/dist/utils/event-bus.js +39 -0
  14. package/package.json +5 -25
  15. package/dist/assets/css/comment-dialog.css +0 -50
  16. package/dist/assets/css/diff-viewer.css +0 -105
  17. package/dist/assets/css/formula.css +0 -19
  18. package/dist/assets/css/history-viewer.css +0 -104
  19. package/dist/assets/css/image.css +0 -134
  20. package/dist/assets/css/issue-card.css +0 -43
  21. package/dist/assets/css/keyboard-shortcuts.css +0 -58
  22. package/dist/assets/css/link.css +0 -7
  23. package/dist/assets/css/markdown-editor.css +0 -12
  24. package/dist/assets/css/markdown-viewer.css +0 -69
  25. package/dist/assets/css/navbar-imgbutton.css +0 -83
  26. package/dist/assets/css/outline.css +0 -29
  27. package/dist/assets/css/table.css +0 -57
  28. package/dist/assets/css/textlink-hovermenu.css +0 -47
  29. package/dist/assets/css/topbar.css +0 -350
  30. package/dist/assets/css/tree-view.css +0 -67
  31. package/dist/assets/css/user-help.css +0 -84
  32. package/dist/assets/editor/plain-editor.css +0 -30
  33. package/dist/assets/editor/seatable-editor.css +0 -77
  34. package/dist/assets/editor/simple-editor.css +0 -77
  35. package/dist/components/click-outside.js +0 -46
  36. package/dist/components/context-menu.js +0 -97
  37. package/dist/components/dialogs/add-formula-dialog.js +0 -116
  38. package/dist/components/dialogs/add-image-dialog.js +0 -69
  39. package/dist/components/dialogs/add-link-dialog.js +0 -133
  40. package/dist/components/dialogs/comment-dialog.js +0 -97
  41. package/dist/components/dialogs/shortcut-dialog.js +0 -131
  42. package/dist/components/error-boundary.js +0 -28
  43. package/dist/components/load-script/index.js +0 -69
  44. package/dist/components/loading.js +0 -25
  45. package/dist/components/markdown-lint.js +0 -72
  46. package/dist/components/menu/index.js +0 -4
  47. package/dist/components/menu/item.js +0 -49
  48. package/dist/components/menu/menu.js +0 -38
  49. package/dist/components/menu/style.css +0 -42
  50. package/dist/components/modal-portal.js +0 -38
  51. package/dist/components/outline/index.js +0 -92
  52. package/dist/components/outline/outline-item.js +0 -58
  53. package/dist/components/select/_option.js +0 -44
  54. package/dist/components/select/field-setting.js +0 -106
  55. package/dist/components/select/index.js +0 -149
  56. package/dist/components/select/style.css +0 -144
  57. package/dist/components/svg-icons/check-mark-icon.js +0 -14
  58. package/dist/components/svg-icons/column-icon.js +0 -17
  59. package/dist/components/svg-icons/text-icon.js +0 -34
  60. package/dist/components/text-link-hover-menu/index.js +0 -123
  61. package/dist/components/toast/alert.js +0 -138
  62. package/dist/components/toast/index.js +0 -3
  63. package/dist/components/toast/toast.js +0 -159
  64. package/dist/components/toast/toastManager.js +0 -139
  65. package/dist/components/toast/toaster.js +0 -65
  66. package/dist/components/toolbar/header-list.js +0 -114
  67. package/dist/components/toolbar/help-group.js +0 -33
  68. package/dist/components/toolbar/index.js +0 -4
  69. package/dist/components/toolbar/insert-image.js +0 -106
  70. package/dist/components/toolbar/insert-table.js +0 -136
  71. package/dist/components/toolbar/table-group.js +0 -74
  72. package/dist/components/toolbar/toolbar.js +0 -317
  73. package/dist/components/toolbar/widgets/button-group.js +0 -24
  74. package/dist/components/toolbar/widgets/button-item.js +0 -129
  75. package/dist/components/toolbar/widgets/drop-list.js +0 -88
  76. package/dist/components/user-help/index.js +0 -179
  77. package/dist/config-0.js +0 -15
  78. package/dist/config.js +0 -16
  79. package/dist/constants/cell-types.js +0 -29
  80. package/dist/constants/column.js +0 -4
  81. package/dist/containers/code-highlight-package.js +0 -14
  82. package/dist/containers/controller/block-element-controller.js +0 -375
  83. package/dist/containers/controller/index.js +0 -5
  84. package/dist/containers/controller/inline-element-controller.js +0 -134
  85. package/dist/containers/controller/normalize-controller.js +0 -95
  86. package/dist/containers/controller/shortcut-controller.js +0 -385
  87. package/dist/containers/controller/void-element-controller.js +0 -9
  88. package/dist/containers/custom/custom.js +0 -18
  89. package/dist/containers/custom/get-event-transfer.js +0 -33
  90. package/dist/containers/custom/getNodesByTypeAtRange.js +0 -57
  91. package/dist/containers/custom/insertNodes.js +0 -120
  92. package/dist/containers/custom/is-empty-paragraph.js +0 -9
  93. package/dist/containers/custom/set-event-transfer.js +0 -30
  94. package/dist/containers/custom/split-nodes-at-point.js +0 -136
  95. package/dist/containers/custom/unwrap-node-by-type-at-range.js +0 -70
  96. package/dist/containers/editor-context.js +0 -85
  97. package/dist/containers/editor-utils/block-element-utils/blockquote-utils.js +0 -80
  98. package/dist/containers/editor-utils/block-element-utils/code-utils.js +0 -145
  99. package/dist/containers/editor-utils/block-element-utils/formula-utils.js +0 -51
  100. package/dist/containers/editor-utils/block-element-utils/index.js +0 -31
  101. package/dist/containers/editor-utils/block-element-utils/list-utils.js +0 -395
  102. package/dist/containers/editor-utils/block-element-utils/table-utils.js +0 -412
  103. package/dist/containers/editor-utils/clear-format-utils.js +0 -84
  104. package/dist/containers/editor-utils/common-editor-utils.js +0 -492
  105. package/dist/containers/editor-utils/inline-element-utils/index.js +0 -95
  106. package/dist/containers/editor-utils/mark-utils.js +0 -20
  107. package/dist/containers/editor-utils/range-utils.js +0 -7
  108. package/dist/containers/editor-utils/selection-utils.js +0 -30
  109. package/dist/containers/editor-utils/text-utils.js +0 -117
  110. package/dist/containers/editor-widgets/check-list-item.js +0 -53
  111. package/dist/containers/editor-widgets/code-block.js +0 -128
  112. package/dist/containers/editor-widgets/column.js +0 -100
  113. package/dist/containers/editor-widgets/formula.js +0 -67
  114. package/dist/containers/editor-widgets/image.js +0 -237
  115. package/dist/containers/editor-widgets/link.js +0 -9
  116. package/dist/containers/editor-widgets/table.js +0 -144
  117. package/dist/containers/element-model/blockquote.js +0 -13
  118. package/dist/containers/element-model/column.js +0 -19
  119. package/dist/containers/element-model/image.js +0 -16
  120. package/dist/containers/element-model/link.js +0 -16
  121. package/dist/containers/element-model/table.js +0 -57
  122. package/dist/containers/element-model/text.js +0 -10
  123. package/dist/containers/render-utils/common-utils.js +0 -80
  124. package/dist/containers/render-utils/editor-utils.js +0 -133
  125. package/dist/containers/render-utils/viewer-utils.js +0 -198
  126. package/dist/containers/viewer-widgets/viewer-formula/index.js +0 -54
  127. package/dist/containers/viewer-widgets/viewer-image/index.js +0 -70
  128. package/dist/containers/viewer-widgets/viewer-image/viewer-image.css +0 -3
  129. package/dist/editors/index.js +0 -78
  130. package/dist/editors/markdown-editor.js +0 -280
  131. package/dist/editors/plain-markdown-editor.js +0 -285
  132. package/dist/editors/seatable-editor.js +0 -210
  133. package/dist/editors/simple-editor.js +0 -200
  134. package/dist/utils/deserialize-html.js +0 -260
  135. package/dist/utils/diff/compare-strings.js +0 -35
  136. package/dist/utils/diff/diff.js +0 -769
  137. package/dist/utils/diff/index.js +0 -2
  138. package/dist/utils/seafile-markdown2html.js +0 -52
  139. package/dist/utils/slate2markdown/deserialize.js +0 -588
  140. package/dist/utils/slate2markdown/index.js +0 -3
  141. package/dist/utils/slate2markdown/serialize.js +0 -366
  142. package/dist/utils/utils.js +0 -69
  143. package/dist/viewer/diff-viewer.js +0 -85
  144. package/dist/viewer/index.js +0 -4
  145. package/dist/viewer/markdown-viewer.js +0 -121
  146. package/dist/viewer/seatable-viewer.js +0 -63
  147. package/dist/viewer/slate-viewer.js +0 -71
  148. /package/dist/assets/css/{new-editor-toolbar.css → sdoc-editor-toolbar.css} +0 -0
  149. /package/dist/assets/css/{new-editor.css → sdoc-editor.css} +0 -0
@@ -1,133 +0,0 @@
1
- import React from 'react';
2
- import { useSelected } from '@seafile/slate-react';
3
- import Link from '../editor-widgets/link';
4
- import Image from '../editor-widgets/image';
5
- import CheckListItem from '../editor-widgets/check-list-item';
6
- import CodeBlock from '../editor-widgets/code-block';
7
- import Formula from '../editor-widgets/formula';
8
- import TableContainer from '../editor-widgets/table';
9
- import Column from '../editor-widgets/column';
10
- import { decorationNode } from './common-utils';
11
- function WithSelectedState(props) {
12
- var isSelected = useSelected();
13
- var SlateNode = props.SlateNode;
14
- return /*#__PURE__*/React.createElement(SlateNode, {
15
- editor: props.editor,
16
- attributes: props.attributes,
17
- children: props.children,
18
- isSelected: isSelected,
19
- node: props.element
20
- });
21
- }
22
- function renderNode(props, editor) {
23
- var attributes = props.attributes,
24
- children = props.children,
25
- node = props.element;
26
- switch (node.type) {
27
- case 'paragraph':
28
- return /*#__PURE__*/React.createElement("p", attributes, children);
29
- case 'header_one':
30
- return /*#__PURE__*/React.createElement("h1", Object.assign({}, attributes, {
31
- id: 'user-content-' + node.children[0].text
32
- }), children);
33
- case 'header_two':
34
- return /*#__PURE__*/React.createElement("h2", Object.assign({}, attributes, {
35
- id: 'user-content-' + node.children[0].text
36
- }), children);
37
- case 'header_three':
38
- return /*#__PURE__*/React.createElement("h3", Object.assign({}, attributes, {
39
- id: 'user-content-' + node.children[0].text
40
- }), children);
41
- case 'header_four':
42
- return /*#__PURE__*/React.createElement("h4", attributes, children);
43
- case 'header_five':
44
- return /*#__PURE__*/React.createElement("h5", attributes, children);
45
- case 'header_six':
46
- return /*#__PURE__*/React.createElement("h6", attributes, children);
47
- case 'link':
48
- return /*#__PURE__*/React.createElement(Link, {
49
- attributes: attributes,
50
- children: children,
51
- node: node
52
- });
53
- case 'image':
54
- return /*#__PURE__*/React.createElement(WithSelectedState, Object.assign({}, props, {
55
- SlateNode: Image
56
- }));
57
- case 'blockquote':
58
- return /*#__PURE__*/React.createElement("blockquote", attributes, children);
59
- case 'list_item':
60
- var checked = node.data.checked;
61
- if (checked === undefined) return /*#__PURE__*/React.createElement("li", attributes, children);
62
- return /*#__PURE__*/React.createElement(CheckListItem, Object.assign({
63
- editor: editor
64
- }, props));
65
- case 'code_block':
66
- return /*#__PURE__*/React.createElement(WithSelectedState, Object.assign({}, props, {
67
- editor: editor,
68
- SlateNode: CodeBlock
69
- }));
70
- case 'code_line':
71
- return /*#__PURE__*/React.createElement("p", attributes, children);
72
- case 'unordered_list':
73
- return /*#__PURE__*/React.createElement("ul", attributes, children);
74
- case 'ordered_list':
75
- return /*#__PURE__*/React.createElement("ol", attributes, children);
76
- case 'table':
77
- return /*#__PURE__*/React.createElement(TableContainer, Object.assign({
78
- editor: editor
79
- }, props));
80
- case 'table_row':
81
- return /*#__PURE__*/React.createElement("tr", attributes, children);
82
- case 'table_cell':
83
- var align = node.data.align;
84
- align = ['left', 'right', 'center'].find(function (item) {
85
- return item === align;
86
- }) ? align : 'left';
87
- return /*#__PURE__*/React.createElement("td", Object.assign({
88
- style: {
89
- textAlign: align
90
- }
91
- }, attributes), children);
92
- case 'formula':
93
- return /*#__PURE__*/React.createElement(WithSelectedState, Object.assign({}, props, {
94
- editor: editor,
95
- SlateNode: Formula
96
- }));
97
- case 'column':
98
- return /*#__PURE__*/React.createElement(WithSelectedState, Object.assign({}, props, {
99
- editor: editor,
100
- SlateNode: Column
101
- }));
102
- default:
103
- return /*#__PURE__*/React.createElement("p", attributes, children);
104
- }
105
- }
106
- var renderLeaf = function renderLeaf(_ref) {
107
- var attributes = _ref.attributes,
108
- children = _ref.children,
109
- leaf = _ref.leaf;
110
- var markedChildren = React.cloneElement(children);
111
- if (leaf.BOLD) {
112
- markedChildren = /*#__PURE__*/React.createElement("strong", null, markedChildren);
113
- }
114
- if (leaf.CODE) {
115
- markedChildren = /*#__PURE__*/React.createElement("code", null, markedChildren);
116
- }
117
- if (leaf.ITALIC) {
118
- markedChildren = /*#__PURE__*/React.createElement("i", null, markedChildren);
119
- }
120
- if (leaf.DELETE) {
121
- markedChildren = /*#__PURE__*/React.createElement("del", null, markedChildren);
122
- }
123
- if (leaf.ADD) {
124
- markedChildren = /*#__PURE__*/React.createElement("ins", null, markedChildren);
125
- }
126
- if (leaf.decoration) {
127
- markedChildren = /*#__PURE__*/React.createElement("span", {
128
- className: "token ".concat(leaf.type)
129
- }, markedChildren);
130
- }
131
- return /*#__PURE__*/React.createElement("span", attributes, markedChildren);
132
- };
133
- export { renderNode, renderLeaf, decorationNode };
@@ -1,198 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _inherits from "@babel/runtime/helpers/esm/inherits";
4
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
- import React from 'react';
6
- import isUrl from 'is-url';
7
- import CheckListItem from '../editor-widgets/check-list-item';
8
- import ViewerImage from '../viewer-widgets/viewer-image';
9
- import ViewerFormula from '../viewer-widgets/viewer-formula';
10
- import { decorationNode } from './common-utils';
11
- function renderNode(_ref) {
12
- var attributes = _ref.attributes,
13
- children = _ref.children,
14
- element = _ref.element;
15
- var node = element;
16
- var data = node.data ? node.data : {};
17
- var checked = data.checked;
18
- var align = data.align;
19
- var href = data.href;
20
- var diffClass = data.diff_state;
21
- var diffIndex = data.new_index;
22
- align = ['left', 'right', 'center'].indexOf(align) === -1 ? 'left' : align;
23
- switch (node.type) {
24
- case 'paragraph':
25
- return /*#__PURE__*/React.createElement("p", Object.assign({
26
- className: diffClass ? diffClass + ' ' + (data['paragraph_state'] ? data['paragraph_state'] : '') : ''
27
- }, attributes), children);
28
- case 'blockquote':
29
- return /*#__PURE__*/React.createElement("blockquote", attributes, children);
30
- case 'header_one':
31
- return /*#__PURE__*/React.createElement("h1", Object.assign({}, attributes, {
32
- id: 'user-content-' + node.children[0].text
33
- }), children);
34
- case 'header_two':
35
- return /*#__PURE__*/React.createElement("h2", Object.assign({}, attributes, {
36
- id: 'user-content-' + node.children[0].text
37
- }), children);
38
- case 'header_three':
39
- return /*#__PURE__*/React.createElement("h3", Object.assign({}, attributes, {
40
- id: 'user-content-' + node.children[0].text
41
- }), children);
42
- case 'header_four':
43
- return /*#__PURE__*/React.createElement("h4", attributes, children);
44
- case 'header_five':
45
- return /*#__PURE__*/React.createElement("h5", attributes, children);
46
- case 'header_six':
47
- return /*#__PURE__*/React.createElement("h6", attributes, children);
48
- case 'list_item':
49
- if (checked === undefined) return /*#__PURE__*/React.createElement("li", Object.assign({
50
- value: diffIndex ? diffIndex >= 0 ? diffIndex + 1 : data['old_index'] + 1 : '',
51
- className: diffClass ? diffClass : ''
52
- }, attributes), children);
53
- return /*#__PURE__*/React.createElement(CheckListItem, {
54
- className: diffClass ? diffClass : '',
55
- attributes: attributes,
56
- children: children,
57
- element: element
58
- });
59
- case 'unordered_list':
60
- return /*#__PURE__*/React.createElement("ul", Object.assign({
61
- className: diffClass ? diffClass : ''
62
- }, attributes), children);
63
- case 'ordered_list':
64
- return /*#__PURE__*/React.createElement("ol", Object.assign({
65
- className: diffClass ? diffClass : ''
66
- }, attributes), children);
67
- case 'image':
68
- return /*#__PURE__*/React.createElement(ViewerImage, {
69
- attributes: attributes,
70
- children: children,
71
- node: node
72
- });
73
- case 'code_block':
74
- return /*#__PURE__*/React.createElement("pre", {
75
- className: 'code-container'
76
- }, /*#__PURE__*/React.createElement("code", Object.assign({
77
- className: 'code'
78
- }, attributes), children), /*#__PURE__*/React.createElement(LanguageSet, {
79
- disabled: true,
80
- lang: node.data.syntax
81
- }));
82
- case 'code_line':
83
- return /*#__PURE__*/React.createElement("p", attributes, children);
84
- case 'table':
85
- return /*#__PURE__*/React.createElement("table", null, /*#__PURE__*/React.createElement("tbody", attributes, children));
86
- case 'table_row':
87
- return /*#__PURE__*/React.createElement("tr", Object.assign({
88
- className: diffClass ? diffClass : ''
89
- }, attributes), children);
90
- case 'table_cell':
91
- return /*#__PURE__*/React.createElement("td", Object.assign({
92
- className: diffClass ? diffClass : '',
93
- style: {
94
- textAlign: align
95
- }
96
- }, attributes), children);
97
- case 'link':
98
- if (isUrl(href)) {
99
- return /*#__PURE__*/React.createElement("a", Object.assign({
100
- className: diffClass ? diffClass : ''
101
- }, attributes, {
102
- href: href
103
- }), children);
104
- }
105
- return /*#__PURE__*/React.createElement("a", Object.assign({
106
- className: diffClass ? diffClass : ''
107
- }, attributes, {
108
- href: href,
109
- onClick: function onClick(e) {
110
- return e.preventDefault();
111
- }
112
- }), children);
113
- case 'hr':
114
- return /*#__PURE__*/React.createElement("hr", attributes);
115
- case 'formula':
116
- return /*#__PURE__*/React.createElement(ViewerFormula, Object.assign({
117
- className: diffClass ? diffClass : '',
118
- node: node,
119
- children: children
120
- }, attributes));
121
- case 'column':
122
- var columnName = data.name;
123
- var displayValue = columnName ? "{".concat(columnName, "}") : '';
124
- return /*#__PURE__*/React.createElement("span", attributes, displayValue);
125
- default:
126
- return /*#__PURE__*/React.createElement("p", attributes, children);
127
- }
128
- }
129
- var renderLeaf = function renderLeaf(_ref2) {
130
- var attributes = _ref2.attributes,
131
- children = _ref2.children,
132
- leaf = _ref2.leaf;
133
- if (leaf.BOLD) {
134
- children = /*#__PURE__*/React.createElement("strong", null, children);
135
- }
136
- if (leaf.CODE) {
137
- children = /*#__PURE__*/React.createElement("code", null, children);
138
- }
139
- if (leaf.ITALIC) {
140
- children = /*#__PURE__*/React.createElement("i", null, children);
141
- }
142
- if (leaf.DELETE) {
143
- children = /*#__PURE__*/React.createElement("del", null, children);
144
- }
145
- if (leaf.ADD) {
146
- children = /*#__PURE__*/React.createElement("ins", null, children);
147
- }
148
- if (leaf.decoration) {
149
- return /*#__PURE__*/React.createElement("span", {
150
- className: "token ".concat(leaf.type)
151
- }, children);
152
- }
153
- return /*#__PURE__*/React.createElement("span", attributes, children);
154
- };
155
- var LanguageSet = /*#__PURE__*/function (_React$PureComponent) {
156
- _inherits(LanguageSet, _React$PureComponent);
157
- var _super = _createSuper(LanguageSet);
158
- function LanguageSet() {
159
- _classCallCheck(this, LanguageSet);
160
- return _super.apply(this, arguments);
161
- }
162
- _createClass(LanguageSet, [{
163
- key: "render",
164
- value: function render() {
165
- return /*#__PURE__*/React.createElement("div", {
166
- className: "language-type"
167
- }, /*#__PURE__*/React.createElement("select", {
168
- value: this.props.lang,
169
- disabled: true,
170
- name: "language"
171
- }, /*#__PURE__*/React.createElement("option", {
172
- value: "none"
173
- }, "Text"), /*#__PURE__*/React.createElement("option", {
174
- value: "html"
175
- }, "HTML"), /*#__PURE__*/React.createElement("option", {
176
- value: "css"
177
- }, "CSS"), /*#__PURE__*/React.createElement("option", {
178
- value: "javascript"
179
- }, "Javascript"), /*#__PURE__*/React.createElement("option", {
180
- value: "c"
181
- }, "C"), /*#__PURE__*/React.createElement("option", {
182
- value: "cpp"
183
- }, "C++"), /*#__PURE__*/React.createElement("option", {
184
- value: "csharp"
185
- }, "C#"), /*#__PURE__*/React.createElement("option", {
186
- value: "java"
187
- }, "Java"), /*#__PURE__*/React.createElement("option", {
188
- value: "python"
189
- }, "Python"), /*#__PURE__*/React.createElement("option", {
190
- value: "sql"
191
- }, "Sql"), /*#__PURE__*/React.createElement("option", {
192
- value: "swift"
193
- }, "Swift")));
194
- }
195
- }]);
196
- return LanguageSet;
197
- }(React.PureComponent);
198
- export { renderNode, renderLeaf, decorationNode };
@@ -1,54 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _inherits from "@babel/runtime/helpers/esm/inherits";
4
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
- import React from 'react';
6
- import '../../../assets/css/formula.css';
7
- var ViewerFormula = /*#__PURE__*/function (_React$Component) {
8
- _inherits(ViewerFormula, _React$Component);
9
- var _super = _createSuper(ViewerFormula);
10
- function ViewerFormula() {
11
- var _this;
12
- _classCallCheck(this, ViewerFormula);
13
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
14
- args[_key] = arguments[_key];
15
- }
16
- _this = _super.call.apply(_super, [this].concat(args));
17
- _this.renderFormula = function () {
18
- var node = _this.props.node;
19
- _this.formulaContainer.innerHTML = '';
20
- var formula = node.data.formula;
21
- var dom = window.MathJax.tex2svg(formula);
22
- _this.formulaContainer.appendChild(dom);
23
- };
24
- return _this;
25
- }
26
- _createClass(ViewerFormula, [{
27
- key: "componentDidMount",
28
- value: function componentDidMount() {
29
- var node = this.props.node;
30
- if (!node.data.formula) return;
31
- this.renderFormula();
32
- }
33
- }, {
34
- key: "render",
35
- value: function render() {
36
- var _this2 = this;
37
- var _this$props = this.props,
38
- attributes = _this$props.attributes,
39
- children = _this$props.children;
40
- return /*#__PURE__*/React.createElement("span", Object.assign({
41
- className: 'block-formula'
42
- }, attributes), /*#__PURE__*/React.createElement("span", {
43
- contentEditable: false,
44
- ref: function ref(_ref) {
45
- return _this2.formulaContainer = _ref;
46
- }
47
- }), /*#__PURE__*/React.createElement("span", {
48
- contentEditable: false
49
- }, children));
50
- }
51
- }]);
52
- return ViewerFormula;
53
- }(React.Component);
54
- export default ViewerFormula;
@@ -1,70 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _inherits from "@babel/runtime/helpers/esm/inherits";
4
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
- import React from 'react';
6
- import Lightbox from '@seafile/react-image-lightbox';
7
- import './viewer-image.css';
8
- var ViewerImage = /*#__PURE__*/function (_React$Component) {
9
- _inherits(ViewerImage, _React$Component);
10
- var _super = _createSuper(ViewerImage);
11
- function ViewerImage(props) {
12
- var _this;
13
- _classCallCheck(this, ViewerImage);
14
- _this = _super.call(this, props);
15
- _this.toggleBigImage = function (event) {
16
- event && event.preventDefault();
17
- _this.setState({
18
- isShowBigImage: !_this.state.isShowBigImage
19
- });
20
- };
21
- _this.renderBigImage = function (src) {
22
- return /*#__PURE__*/React.createElement(Lightbox, {
23
- wrapperClassName: "sf-editor-image-previewer",
24
- mainSrc: src,
25
- imagePadding: 70,
26
- onCloseRequest: _this.toggleBigImage,
27
- reactModalStyle: {
28
- overlay: {
29
- zIndex: 1071
30
- }
31
- }
32
- });
33
- };
34
- _this.state = {
35
- isShowBigImage: false
36
- };
37
- return _this;
38
- }
39
- _createClass(ViewerImage, [{
40
- key: "render",
41
- value: function render() {
42
- var _this$props = this.props,
43
- attributes = _this$props.attributes,
44
- node = _this$props.node;
45
- var data = node.data;
46
- var isShowBigImage = this.state.isShowBigImage;
47
- var src = data.src;
48
- if (!src) {
49
- return /*#__PURE__*/React.createElement("span", attributes, "Loading...");
50
- }
51
- return /*#__PURE__*/React.createElement("span", {
52
- className: "seafile-ed-image seafile-ed-image-viwer"
53
- }, /*#__PURE__*/React.createElement("img", Object.assign({
54
- draggable: false,
55
- src: src,
56
- alt: ""
57
- }, attributes, {
58
- width: data.width,
59
- height: data.height
60
- })), /*#__PURE__*/React.createElement("span", {
61
- onClick: this.toggleBigImage,
62
- className: "image-full-button"
63
- }, /*#__PURE__*/React.createElement("i", {
64
- className: 'iconfont icon-fullscreen'
65
- })), isShowBigImage && this.renderBigImage(src));
66
- }
67
- }]);
68
- return ViewerImage;
69
- }(React.Component);
70
- export default ViewerImage;
@@ -1,3 +0,0 @@
1
- .sf-editor-image-previewer .ril__caption {
2
- justify-content: center !important;
3
- }
@@ -1,78 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _inherits from "@babel/runtime/helpers/esm/inherits";
4
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
- import React from 'react';
6
- import LoadScript from '../components/load-script';
7
- import MarkdownEditor from './markdown-editor';
8
- import PlainMarkdownEditor from './plain-markdown-editor';
9
- import SeatableEditor from './seatable-editor';
10
- import SimpleEditor from './simple-editor';
11
- var SimpleEditorWithErrorBoundary = /*#__PURE__*/function (_React$Component) {
12
- _inherits(SimpleEditorWithErrorBoundary, _React$Component);
13
- var _super = _createSuper(SimpleEditorWithErrorBoundary);
14
- function SimpleEditorWithErrorBoundary() {
15
- _classCallCheck(this, SimpleEditorWithErrorBoundary);
16
- return _super.apply(this, arguments);
17
- }
18
- _createClass(SimpleEditorWithErrorBoundary, [{
19
- key: "componentDidCatch",
20
- value: function componentDidCatch(error) {
21
- console.error(error);
22
- this.forceUpdate();
23
- }
24
- }, {
25
- key: "render",
26
- value: function render() {
27
- return /*#__PURE__*/React.createElement(SimpleEditor, this.props);
28
- }
29
- }]);
30
- return SimpleEditorWithErrorBoundary;
31
- }(React.Component);
32
- var MarkdownEditorWithErrorBoundary = /*#__PURE__*/function (_React$Component2) {
33
- _inherits(MarkdownEditorWithErrorBoundary, _React$Component2);
34
- var _super2 = _createSuper(MarkdownEditorWithErrorBoundary);
35
- function MarkdownEditorWithErrorBoundary() {
36
- _classCallCheck(this, MarkdownEditorWithErrorBoundary);
37
- return _super2.apply(this, arguments);
38
- }
39
- _createClass(MarkdownEditorWithErrorBoundary, [{
40
- key: "componentDidCatch",
41
- value: function componentDidCatch(error) {
42
- console.error(error);
43
- this.forceUpdate();
44
- }
45
- }, {
46
- key: "render",
47
- value: function render() {
48
- return /*#__PURE__*/React.createElement(LoadScript, {
49
- scriptSource: this.props.scriptSource
50
- }, /*#__PURE__*/React.createElement(MarkdownEditor, this.props));
51
- }
52
- }]);
53
- return MarkdownEditorWithErrorBoundary;
54
- }(React.Component);
55
- var PlainMarkdownEditorWithErrorBoundary = /*#__PURE__*/function (_React$Component3) {
56
- _inherits(PlainMarkdownEditorWithErrorBoundary, _React$Component3);
57
- var _super3 = _createSuper(PlainMarkdownEditorWithErrorBoundary);
58
- function PlainMarkdownEditorWithErrorBoundary() {
59
- _classCallCheck(this, PlainMarkdownEditorWithErrorBoundary);
60
- return _super3.apply(this, arguments);
61
- }
62
- _createClass(PlainMarkdownEditorWithErrorBoundary, [{
63
- key: "componentDidCatch",
64
- value: function componentDidCatch(error) {
65
- console.error(error);
66
- this.forceUpdate();
67
- }
68
- }, {
69
- key: "render",
70
- value: function render() {
71
- return /*#__PURE__*/React.createElement(LoadScript, {
72
- scriptSource: this.props.scriptSource
73
- }, /*#__PURE__*/React.createElement(PlainMarkdownEditor, this.props));
74
- }
75
- }]);
76
- return PlainMarkdownEditorWithErrorBoundary;
77
- }(React.Component);
78
- export { SeatableEditor, MarkdownEditorWithErrorBoundary as MarkdownEditor, SimpleEditorWithErrorBoundary as SimpleEditor, PlainMarkdownEditorWithErrorBoundary as PlainMarkdownEditor };