@seafile/seafile-editor 0.3.76

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 (156) hide show
  1. package/README.md +119 -0
  2. package/TODO.md +55 -0
  3. package/dist/components/add-formula-dialog.js +135 -0
  4. package/dist/components/add-image-dialog.js +78 -0
  5. package/dist/components/add-link-dialog.js +148 -0
  6. package/dist/components/comment-dialog.js +107 -0
  7. package/dist/components/comment-panel.js +452 -0
  8. package/dist/components/context-menu.js +112 -0
  9. package/dist/components/detail-list-view.js +119 -0
  10. package/dist/components/generate-share-link.js +412 -0
  11. package/dist/components/internal-link-dialog.js +96 -0
  12. package/dist/components/loading.js +32 -0
  13. package/dist/components/markdown-lint.js +87 -0
  14. package/dist/components/modal-portal.js +46 -0
  15. package/dist/components/outline.js +130 -0
  16. package/dist/components/participants-list.js +126 -0
  17. package/dist/components/related-files-list.js +75 -0
  18. package/dist/components/shortcut-dialog.js +167 -0
  19. package/dist/components/side-panel.js +175 -0
  20. package/dist/components/toast/alert.js +150 -0
  21. package/dist/components/toast/index.js +3 -0
  22. package/dist/components/toast/toast.js +179 -0
  23. package/dist/components/toast/toastManager.js +158 -0
  24. package/dist/components/toast/toaster.js +76 -0
  25. package/dist/components/toolbar.js +235 -0
  26. package/dist/components/topbar-component/button-group.js +31 -0
  27. package/dist/components/topbar-component/editor-toolbar.js +545 -0
  28. package/dist/components/topbar-component/file-info.js +65 -0
  29. package/dist/components/topbar-component/header-list.js +128 -0
  30. package/dist/components/topbar-component/icon-button.js +99 -0
  31. package/dist/components/topbar-component/insert-file.js +67 -0
  32. package/dist/components/topbar-component/table-toolbar.js +175 -0
  33. package/dist/components/topbar-component/upload-img.js +122 -0
  34. package/dist/components/user-help.js +205 -0
  35. package/dist/css/diff-viewer.css +105 -0
  36. package/dist/css/history-viewer.css +104 -0
  37. package/dist/css/keyboard-shortcuts.css +59 -0
  38. package/dist/css/layout.css +110 -0
  39. package/dist/css/markdown-viewer-slate/file-tags-list.css +76 -0
  40. package/dist/css/markdown-viewer.css +69 -0
  41. package/dist/css/plaineditor/markdown-editor.css +12 -0
  42. package/dist/css/react-mentions-default-style.js +72 -0
  43. package/dist/css/related-files-list.css +56 -0
  44. package/dist/css/richeditor/comments-list.css +184 -0
  45. package/dist/css/richeditor/detail-list-view.css +114 -0
  46. package/dist/css/richeditor/document-info.css +57 -0
  47. package/dist/css/richeditor/formula.css +19 -0
  48. package/dist/css/richeditor/image.css +141 -0
  49. package/dist/css/richeditor/link.css +7 -0
  50. package/dist/css/richeditor/navbar-imgbutton.css +79 -0
  51. package/dist/css/richeditor/participants-list.css +22 -0
  52. package/dist/css/richeditor/rich-editor-main.css +42 -0
  53. package/dist/css/richeditor/right-panel.css +84 -0
  54. package/dist/css/richeditor/side-panel.css +190 -0
  55. package/dist/css/richeditor/table.css +57 -0
  56. package/dist/css/richeditor/textlink-hovermenu.css +47 -0
  57. package/dist/css/richeditor/tree-view.css +67 -0
  58. package/dist/css/topbar.css +400 -0
  59. package/dist/editor/code-highlight-package.js +27 -0
  60. package/dist/editor/controller/block-element-controller.js +376 -0
  61. package/dist/editor/controller/inline-element-controller.js +129 -0
  62. package/dist/editor/controller/normalize-controller.js +107 -0
  63. package/dist/editor/controller/shortcut-controller.js +394 -0
  64. package/dist/editor/controller/void-element-controller.js +12 -0
  65. package/dist/editor/custom/custom.js +17 -0
  66. package/dist/editor/custom/get-event-transfer.js +34 -0
  67. package/dist/editor/custom/getNodesByTypeAtRange.js +69 -0
  68. package/dist/editor/custom/insertNodes.js +140 -0
  69. package/dist/editor/custom/is-empty-paragraph.js +13 -0
  70. package/dist/editor/custom/set-event-transfer.js +31 -0
  71. package/dist/editor/custom/split-nodes-at-point.js +162 -0
  72. package/dist/editor/custom/unwrap-node-by-type-at-range.js +81 -0
  73. package/dist/editor/editor-component/check-list-item.js +64 -0
  74. package/dist/editor/editor-component/code-block.js +150 -0
  75. package/dist/editor/editor-component/formula.js +79 -0
  76. package/dist/editor/editor-component/image.js +215 -0
  77. package/dist/editor/editor-component/link.js +11 -0
  78. package/dist/editor/editor-component/table.js +172 -0
  79. package/dist/editor/editor-component/textlink-hovermenu.js +136 -0
  80. package/dist/editor/editor-plugin.js +249 -0
  81. package/dist/editor/editor-utils/block-element-utils/blockquote-utils.js +96 -0
  82. package/dist/editor/editor-utils/block-element-utils/code-utils.js +162 -0
  83. package/dist/editor/editor-utils/block-element-utils/formula-utils.js +58 -0
  84. package/dist/editor/editor-utils/block-element-utils/index.js +38 -0
  85. package/dist/editor/editor-utils/block-element-utils/list-utils.js +398 -0
  86. package/dist/editor/editor-utils/block-element-utils/table-utils.js +418 -0
  87. package/dist/editor/editor-utils/common-editor-utils.js +587 -0
  88. package/dist/editor/editor-utils/inline-element-utils/index.js +95 -0
  89. package/dist/editor/editor-utils/mark-utils.js +25 -0
  90. package/dist/editor/editor-utils/range-utils.js +9 -0
  91. package/dist/editor/editor-utils/selection-utils.js +33 -0
  92. package/dist/editor/editor-utils/text-utils.js +130 -0
  93. package/dist/editor/editor.js +66 -0
  94. package/dist/editor/element-model/blockquote.js +16 -0
  95. package/dist/editor/element-model/image.js +19 -0
  96. package/dist/editor/element-model/link.js +19 -0
  97. package/dist/editor/element-model/table.js +50 -0
  98. package/dist/editor/element-model/text.js +13 -0
  99. package/dist/editor/load-script.js +83 -0
  100. package/dist/editor/plain-markdown-editor.js +324 -0
  101. package/dist/editor/rich-markdown-editor.js +580 -0
  102. package/dist/editor/seafile-editor.js +326 -0
  103. package/dist/editor/simple-editor.js +245 -0
  104. package/dist/editor-api.js +261 -0
  105. package/dist/index.css +97 -0
  106. package/dist/lib/slate-hyperscript/creators.js +263 -0
  107. package/dist/lib/slate-hyperscript/hyperscript.js +92 -0
  108. package/dist/lib/slate-hyperscript/index.js +3 -0
  109. package/dist/lib/slate-hyperscript/tokens.js +102 -0
  110. package/dist/lib/unified/index.js +470 -0
  111. package/dist/lib/vfile/core.js +172 -0
  112. package/dist/lib/vfile/index.js +48 -0
  113. package/dist/seafile-editor-chooser.js +45 -0
  114. package/dist/seafile-markdown-editor.js +301 -0
  115. package/dist/seafile-markdown-viewer.js +79 -0
  116. package/dist/seafile-simple-editor.js +56 -0
  117. package/dist/utils/copy-to-clipboard.js +47 -0
  118. package/dist/utils/deserialize-html.js +282 -0
  119. package/dist/utils/diff/compare-strings.js +46 -0
  120. package/dist/utils/diff/diff.js +855 -0
  121. package/dist/utils/diff/index.js +2 -0
  122. package/dist/utils/render-slate.js +219 -0
  123. package/dist/utils/seafile-markdown2html.js +62 -0
  124. package/dist/utils/slate2markdown/deserialize.js +689 -0
  125. package/dist/utils/slate2markdown/index.js +3 -0
  126. package/dist/utils/slate2markdown/serialize.js +407 -0
  127. package/dist/utils/utils.js +28 -0
  128. package/dist/viewer/diff-viewer.js +98 -0
  129. package/dist/viewer/markdown-viewer.js +139 -0
  130. package/dist/viewer/slate-viewer.js +73 -0
  131. package/dist/viewer/viewer-formula.js +67 -0
  132. package/dist/viewer/viewer-image.js +93 -0
  133. package/dist/viewer/viewer-outline.js +118 -0
  134. package/package.json +215 -0
  135. package/public/favicon.ico +0 -0
  136. package/public/index.html +45 -0
  137. package/public/locales/cs/seafile-editor.json +169 -0
  138. package/public/locales/de/seafile-editor.json +169 -0
  139. package/public/locales/en/seafile-editor.json +222 -0
  140. package/public/locales/es/seafile-editor.json +169 -0
  141. package/public/locales/es-AR/seafile-editor.json +169 -0
  142. package/public/locales/es-MX/seafile-editor.json +169 -0
  143. package/public/locales/fr/seafile-editor.json +169 -0
  144. package/public/locales/it/seafile-editor.json +169 -0
  145. package/public/locales/ru/seafile-editor.json +169 -0
  146. package/public/locales/zh-CN/seafile-editor.json +219 -0
  147. package/public/manifest.json +15 -0
  148. package/public/media/scripts/mathjax/tex-svg.js +1 -0
  149. package/public/media/seafile-editor-font/iconfont.eot +0 -0
  150. package/public/media/seafile-editor-font/iconfont.svg +164 -0
  151. package/public/media/seafile-editor-font/iconfont.ttf +0 -0
  152. package/public/media/seafile-editor-font/iconfont.woff +0 -0
  153. package/public/media/seafile-editor-font/iconfont.woff2 +0 -0
  154. package/public/media/seafile-editor-font.css +201 -0
  155. package/public/media/seafile-logo.png +0 -0
  156. package/public/media/seafile-ui.css +11169 -0
@@ -0,0 +1,31 @@
1
+ import { Node } from 'slate';
2
+ var TRANSFER_TYPES = {
3
+ fragment: 'application/x-slate-fragment',
4
+ html: 'text/html',
5
+ text: 'text/plain'
6
+ }; // tranfrom slate fragment and write to clipboard
7
+
8
+ function setEventTransfer(event, type, content) {
9
+ var mime = TRANSFER_TYPES[type];
10
+ var transfer = event.dataTransfer || event.clipboardData;
11
+
12
+ if (type === 'fragment') {
13
+ // use the same encoding as slate
14
+ var encodedContent = window.btoa(encodeURIComponent(JSON.stringify(content)));
15
+ transfer.setData(mime, encodedContent);
16
+ var texts = '';
17
+ var textItem = '';
18
+ content.forEach(function (element) {
19
+ textItem = Node.text(element).replace(/\ufeff/, '');
20
+ texts += textItem + '\r\n';
21
+ });
22
+ transfer.setData('text', texts);
23
+ } else if (type === 'html') {
24
+ transfer.setData(mime, content);
25
+ transfer.setData('text', transfer.getData('text'));
26
+ } else {
27
+ transfer.setData('text', content);
28
+ }
29
+ }
30
+
31
+ export default setEventTransfer;
@@ -0,0 +1,162 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
+ import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
3
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
5
+ import { Element, Editor, Range, Path } from 'slate'; // modified on the basic of slate function Editor.SplitNodes
6
+ // todo: split the node which nearest to the selection
7
+
8
+ var splitNodesAtPoint = function splitNodesAtPoint(editor) {
9
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
10
+ Editor.withoutNormalizing(editor, function () {
11
+ var match = options.match,
12
+ _options$at = options.at,
13
+ at = _options$at === void 0 ? editor.selection : _options$at,
14
+ _options$height = options.height,
15
+ height = _options$height === void 0 ? 0 : _options$height,
16
+ _options$always = options.always,
17
+ always = _options$always === void 0 ? false : _options$always,
18
+ _options$voids = options.voids,
19
+ voids = _options$voids === void 0 ? false : _options$voids;
20
+
21
+ if (match == null) {
22
+ match = 'block';
23
+ }
24
+
25
+ if (Range.isRange(at)) {
26
+ at = deleteRange(editor, at);
27
+ }
28
+
29
+ if (!at) {
30
+ return;
31
+ }
32
+
33
+ var beforeRef = Editor.pointRef(editor, at, {
34
+ affinity: 'backward'
35
+ });
36
+ var nodes = Editor.nodes(editor, {
37
+ at: at,
38
+ match: match,
39
+ voids: voids
40
+ });
41
+
42
+ var highest = _toConsumableArray(nodes).pop();
43
+
44
+ if (!highest) {
45
+ return;
46
+ }
47
+
48
+ var voidMatch = Editor.match(editor, at, 'void');
49
+ var nudge = 0;
50
+
51
+ if (!voids && voidMatch) {
52
+ var _voidMatch = _slicedToArray(voidMatch, 2),
53
+ voidNode = _voidMatch[0],
54
+ voidPath = _voidMatch[1];
55
+
56
+ if (Element.isElement(voidNode) && editor.isInline(voidNode)) {
57
+ var after = Editor.after(editor, voidPath);
58
+
59
+ if (!after) {
60
+ var text = {
61
+ text: ''
62
+ };
63
+ var afterPath = Path.next(voidPath);
64
+ Editor.insertNodes(editor, text, {
65
+ at: afterPath,
66
+ voids: voids
67
+ });
68
+ after = Editor.point(editor, afterPath);
69
+ }
70
+
71
+ at = after;
72
+ always = true;
73
+ }
74
+
75
+ var siblingHeight = at.path.length - voidPath.length;
76
+ height = siblingHeight + 1;
77
+ always = true;
78
+ }
79
+
80
+ var afterRef = Editor.pointRef(editor, at);
81
+ var depth = at.path.length - height;
82
+
83
+ var _highest = _slicedToArray(highest, 2),
84
+ highestPath = _highest[1];
85
+
86
+ var lowestPath = at.path.slice(0, depth);
87
+ var position = height === 0 ? at.offset : at.path[depth] + nudge;
88
+ var target = null;
89
+
90
+ var _iterator = _createForOfIteratorHelper(Editor.levels(editor, {
91
+ at: lowestPath,
92
+ reverse: true,
93
+ voids: voids
94
+ })),
95
+ _step;
96
+
97
+ try {
98
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
99
+ var _step$value = _slicedToArray(_step.value, 2),
100
+ node = _step$value[0],
101
+ path = _step$value[1];
102
+
103
+ var split = false;
104
+
105
+ if (path.length < highestPath.length || path.length === 0 || !voids && Element.isElement(node) && editor.isVoid(node)) {
106
+ break;
107
+ }
108
+
109
+ var _point = beforeRef.current;
110
+ var isEnd = Editor.isEnd(editor, _point, path);
111
+
112
+ if (always || !beforeRef || !Editor.isEdge(editor, _point, path)) {
113
+ split = true;
114
+
115
+ var _text = node.text,
116
+ children = node.children,
117
+ properties = _objectWithoutProperties(node, ["text", "children"]);
118
+
119
+ editor.apply({
120
+ type: 'split_node',
121
+ path: path,
122
+ position: position,
123
+ target: target,
124
+ properties: properties
125
+ });
126
+ }
127
+
128
+ target = position;
129
+ position = path[path.length - 1] + (split || isEnd ? 1 : 0);
130
+ }
131
+ } catch (err) {
132
+ _iterator.e(err);
133
+ } finally {
134
+ _iterator.f();
135
+ }
136
+
137
+ if (options.at == null) {
138
+ var point = afterRef.current || Editor.end(editor, []);
139
+ Editor.select(editor, point);
140
+ }
141
+
142
+ beforeRef.unref();
143
+ afterRef.unref();
144
+ });
145
+ },
146
+ deleteRange = function deleteRange(editor, range) {
147
+ if (Range.isCollapsed(range)) {
148
+ return range.anchor;
149
+ } else {
150
+ var _Range$edges = Range.edges(range),
151
+ _Range$edges2 = _slicedToArray(_Range$edges, 2),
152
+ end = _Range$edges2[1];
153
+
154
+ var pointRef = Editor.pointRef(editor, end);
155
+ Editor.delete(editor, {
156
+ at: range
157
+ });
158
+ return pointRef.unref();
159
+ }
160
+ };
161
+
162
+ export default splitNodesAtPoint;
@@ -0,0 +1,81 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
3
+ import { Editor, Range } from 'slate'; // modified on the basic of slate function Editor.unwrapNodes
4
+ // todo: split the unwrap by type the node which nearest to the selection
5
+
6
+ var unwrapNodesByTypeAtRange = function unwrapNodesByTypeAtRange(editor) {
7
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
8
+ Editor.withoutNormalizing(editor, function () {
9
+ var _options$split = options.split,
10
+ split = _options$split === void 0 ? false : _options$split,
11
+ _options$voids = options.voids,
12
+ voids = _options$voids === void 0 ? false : _options$voids,
13
+ _options$mode = options.mode,
14
+ mode = _options$mode === void 0 ? 'all' : _options$mode,
15
+ _options$at = options.at,
16
+ at = _options$at === void 0 ? editor.selection : _options$at;
17
+ var match = options.match;
18
+
19
+ if (!at) {
20
+ return;
21
+ }
22
+
23
+ var matches = Editor.nodes(editor, {
24
+ at: at,
25
+ match: match,
26
+ mode: mode,
27
+ voids: voids
28
+ });
29
+ var node;
30
+
31
+ var _iterator = _createForOfIteratorHelper(matches),
32
+ _step;
33
+
34
+ try {
35
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
36
+ match = _step.value;
37
+ node = match;
38
+ }
39
+ } catch (err) {
40
+ _iterator.e(err);
41
+ } finally {
42
+ _iterator.f();
43
+ }
44
+
45
+ var pathRefs = Array.from([node], function (_ref) {
46
+ var _ref2 = _slicedToArray(_ref, 2),
47
+ p = _ref2[1];
48
+
49
+ return Editor.pathRef(editor, p);
50
+ });
51
+
52
+ var _loop = function _loop() {
53
+ var pathRef = _pathRefs[_i];
54
+ var path = pathRef.unref();
55
+
56
+ var _Editor$node = Editor.node(editor, path),
57
+ _Editor$node2 = _slicedToArray(_Editor$node, 1),
58
+ node = _Editor$node2[0];
59
+
60
+ var range = Editor.range(editor, path);
61
+
62
+ if (split && Range.isRange(range)) {
63
+ range = Range.intersection(at, range);
64
+ }
65
+
66
+ Editor.liftNodes(editor, {
67
+ at: range,
68
+ match: function match(n) {
69
+ return node.children.includes(n);
70
+ },
71
+ voids: voids
72
+ });
73
+ };
74
+
75
+ for (var _i = 0, _pathRefs = pathRefs; _i < _pathRefs.length; _i++) {
76
+ _loop();
77
+ }
78
+ });
79
+ };
80
+
81
+ export default unwrapNodesByTypeAtRange;
@@ -0,0 +1,64 @@
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 { Editor } from 'slate';
7
+ import { ReactEditor } from '@seafile/slate-react';
8
+
9
+ var CheckListItem = /*#__PURE__*/function (_React$PureComponent) {
10
+ _inherits(CheckListItem, _React$PureComponent);
11
+
12
+ var _super = _createSuper(CheckListItem);
13
+
14
+ function CheckListItem() {
15
+ var _this;
16
+
17
+ _classCallCheck(this, CheckListItem);
18
+
19
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
20
+ args[_key] = arguments[_key];
21
+ }
22
+
23
+ _this = _super.call.apply(_super, [this].concat(args));
24
+
25
+ _this.onChange = function (event) {
26
+ var editor = _this.props.editor;
27
+ var checked = event.target.checked;
28
+ var path = ReactEditor.findPath(editor, _this.props.element);
29
+ Editor.setNodes(editor, {
30
+ data: {
31
+ checked: checked
32
+ }
33
+ }, {
34
+ at: path
35
+ });
36
+ };
37
+
38
+ return _this;
39
+ }
40
+
41
+ _createClass(CheckListItem, [{
42
+ key: "render",
43
+ value: function render() {
44
+ var _this$props = this.props,
45
+ attributes = _this$props.attributes,
46
+ children = _this$props.children,
47
+ element = _this$props.element;
48
+ var checked = element.data.checked;
49
+ return /*#__PURE__*/React.createElement("li", Object.assign({}, attributes, {
50
+ className: 'task-list-item ' + this.props.className
51
+ }), /*#__PURE__*/React.createElement("div", {
52
+ contentEditable: false
53
+ }, /*#__PURE__*/React.createElement("input", {
54
+ type: "checkbox",
55
+ checked: checked,
56
+ onChange: this.onChange
57
+ })), children);
58
+ }
59
+ }]);
60
+
61
+ return CheckListItem;
62
+ }(React.PureComponent);
63
+
64
+ export default CheckListItem;
@@ -0,0 +1,150 @@
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 { Editor } from 'slate';
7
+
8
+ var CodeBlock = /*#__PURE__*/function (_React$PureComponent) {
9
+ _inherits(CodeBlock, _React$PureComponent);
10
+
11
+ var _super = _createSuper(CodeBlock);
12
+
13
+ function CodeBlock() {
14
+ var _this;
15
+
16
+ _classCallCheck(this, CodeBlock);
17
+
18
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
19
+ args[_key] = arguments[_key];
20
+ }
21
+
22
+ _this = _super.call.apply(_super, [this].concat(args));
23
+
24
+ _this.onChange = function (event) {
25
+ var editor = _this.props.editor;
26
+ var language = event.target.value;
27
+ Editor.setNodes(editor, {
28
+ data: {
29
+ syntax: language
30
+ }
31
+ }, {
32
+ match: {
33
+ type: 'code_block'
34
+ }
35
+ });
36
+ };
37
+
38
+ return _this;
39
+ }
40
+
41
+ _createClass(CodeBlock, [{
42
+ key: "render",
43
+ value: function render() {
44
+ var _this$props = this.props,
45
+ attributes = _this$props.attributes,
46
+ children = _this$props.children,
47
+ node = _this$props.node,
48
+ isSelected = _this$props.isSelected,
49
+ readOnly = _this$props.readOnly;
50
+ var language = node.data.syntax;
51
+ return /*#__PURE__*/React.createElement("div", {
52
+ className: 'code-container'
53
+ }, /*#__PURE__*/React.createElement("pre", Object.assign({
54
+ className: 'code'
55
+ }, attributes), /*#__PURE__*/React.createElement("code", null, children)), isSelected ? /*#__PURE__*/React.createElement(LanguageSet, {
56
+ disabled: readOnly,
57
+ language: language,
58
+ onChange: this.onChange
59
+ }) : null);
60
+ }
61
+ }]);
62
+
63
+ return CodeBlock;
64
+ }(React.PureComponent);
65
+
66
+ var LanguageSet = /*#__PURE__*/function (_React$PureComponent2) {
67
+ _inherits(LanguageSet, _React$PureComponent2);
68
+
69
+ var _super2 = _createSuper(LanguageSet);
70
+
71
+ function LanguageSet() {
72
+ var _this2;
73
+
74
+ _classCallCheck(this, LanguageSet);
75
+
76
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
77
+ args[_key2] = arguments[_key2];
78
+ }
79
+
80
+ _this2 = _super2.call.apply(_super2, [this].concat(args));
81
+
82
+ _this2.stopPropagation = function (event) {
83
+ event.stopPropagation();
84
+ };
85
+
86
+ return _this2;
87
+ }
88
+
89
+ _createClass(LanguageSet, [{
90
+ key: "componentDidMount",
91
+ value: function componentDidMount() {
92
+ // Compat chrome browser in windows, stop propagation to prevent emit the click event added to document
93
+ this.selector.addEventListener('click', this.stopPropagation);
94
+ }
95
+ }, {
96
+ key: "componentWillUnmount",
97
+ value: function componentWillUnmount() {
98
+ this.selector.removeEventListener('click', this.stopPropagation);
99
+ }
100
+ }, {
101
+ key: "render",
102
+ value: function render() {
103
+ var _this3 = this;
104
+
105
+ return /*#__PURE__*/React.createElement("div", {
106
+ contentEditable: false,
107
+ className: "language-type"
108
+ }, /*#__PURE__*/React.createElement("select", {
109
+ ref: function ref(_ref) {
110
+ return _this3.selector = _ref;
111
+ },
112
+ value: this.props.language,
113
+ disabled: this.props.disabled,
114
+ name: "language",
115
+ onInput: function onInput(event) {
116
+ return event.stopPropagation();
117
+ },
118
+ onChange: this.props.onChange
119
+ }, /*#__PURE__*/React.createElement("option", {
120
+ value: "none"
121
+ }, "Text"), /*#__PURE__*/React.createElement("option", {
122
+ value: "html"
123
+ }, "HTML"), /*#__PURE__*/React.createElement("option", {
124
+ value: "css"
125
+ }, "CSS"), /*#__PURE__*/React.createElement("option", {
126
+ value: "javascript"
127
+ }, "Javascript"), /*#__PURE__*/React.createElement("option", {
128
+ value: "c"
129
+ }, "C"), /*#__PURE__*/React.createElement("option", {
130
+ value: "cpp"
131
+ }, "C++"), /*#__PURE__*/React.createElement("option", {
132
+ value: "csharp"
133
+ }, "C#"), /*#__PURE__*/React.createElement("option", {
134
+ value: "java"
135
+ }, "Java"), /*#__PURE__*/React.createElement("option", {
136
+ value: "python"
137
+ }, "Python"), /*#__PURE__*/React.createElement("option", {
138
+ value: "sql"
139
+ }, "Sql"), /*#__PURE__*/React.createElement("option", {
140
+ value: "swift"
141
+ }, "Swift"), /*#__PURE__*/React.createElement("option", {
142
+ value: "json"
143
+ }, "JSON")));
144
+ }
145
+ }]);
146
+
147
+ return LanguageSet;
148
+ }(React.PureComponent);
149
+
150
+ export default CodeBlock;
@@ -0,0 +1,79 @@
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 '../../css/richeditor/formula.css';
7
+
8
+ var Formula = /*#__PURE__*/function (_React$Component) {
9
+ _inherits(Formula, _React$Component);
10
+
11
+ var _super = _createSuper(Formula);
12
+
13
+ function Formula() {
14
+ var _this;
15
+
16
+ _classCallCheck(this, Formula);
17
+
18
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
19
+ args[_key] = arguments[_key];
20
+ }
21
+
22
+ _this = _super.call.apply(_super, [this].concat(args));
23
+
24
+ _this.toggleFormulaEditor = function () {
25
+ window.richMarkdownEditor.onToggleFormulaDialog();
26
+ };
27
+
28
+ _this.renderFormula = function () {
29
+ var node = _this.props.node;
30
+ _this.formulaContainer.innerHTML = '';
31
+ var formula = node.data.formula;
32
+ var dom = window.MathJax.tex2svg(formula);
33
+
34
+ _this.formulaContainer.appendChild(dom);
35
+ };
36
+
37
+ return _this;
38
+ }
39
+
40
+ _createClass(Formula, [{
41
+ key: "componentDidMount",
42
+ value: function componentDidMount() {
43
+ var node = this.props.node;
44
+ if (!node.data.formula) return;
45
+ this.renderFormula();
46
+ }
47
+ }, {
48
+ key: "componentDidUpdate",
49
+ value: function componentDidUpdate(preProps) {
50
+ if (preProps.node.data.formula === this.props.node.data.formula) return;
51
+ this.renderFormula();
52
+ }
53
+ }, {
54
+ key: "render",
55
+ value: function render() {
56
+ var _this2 = this;
57
+
58
+ var _this$props = this.props,
59
+ attributes = _this$props.attributes,
60
+ children = _this$props.children,
61
+ isSelected = _this$props.isSelected;
62
+ return /*#__PURE__*/React.createElement("span", Object.assign({
63
+ onDoubleClick: this.toggleFormulaEditor,
64
+ className: 'block-formula ' + (isSelected ? ' selected-formula' : '')
65
+ }, attributes), /*#__PURE__*/React.createElement("span", {
66
+ contentEditable: false,
67
+ ref: function ref(_ref) {
68
+ return _this2.formulaContainer = _ref;
69
+ }
70
+ }), /*#__PURE__*/React.createElement("span", {
71
+ contentEditable: false
72
+ }, children));
73
+ }
74
+ }]);
75
+
76
+ return Formula;
77
+ }(React.Component);
78
+
79
+ export default Formula;