@seafile/sea-email-editor 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (266) hide show
  1. package/README.md +1 -0
  2. package/dist/assets/icons/align-center.svg +1 -0
  3. package/dist/assets/icons/align-left.svg +1 -0
  4. package/dist/assets/icons/align-right.svg +1 -0
  5. package/dist/assets/icons/arrow-down.svg +1 -0
  6. package/dist/assets/icons/arrow-right.svg +1 -0
  7. package/dist/assets/icons/arrow-up.svg +1 -0
  8. package/dist/assets/icons/bold.svg +1 -0
  9. package/dist/assets/icons/callout-color.svg +1 -0
  10. package/dist/assets/icons/check-mark-option.svg +3 -0
  11. package/dist/assets/icons/check-square.svg +1 -0
  12. package/dist/assets/icons/clear-format.svg +1 -0
  13. package/dist/assets/icons/close.svg +3 -0
  14. package/dist/assets/icons/code-block.svg +1 -0
  15. package/dist/assets/icons/image.svg +1 -0
  16. package/dist/assets/icons/inline-code.svg +1 -0
  17. package/dist/assets/icons/insert.svg +1 -0
  18. package/dist/assets/icons/italic.svg +1 -0
  19. package/dist/assets/icons/link.svg +1 -0
  20. package/dist/assets/icons/more.svg +1 -0
  21. package/dist/assets/icons/ol.svg +1 -0
  22. package/dist/assets/icons/quote.svg +1 -0
  23. package/dist/assets/icons/rename.svg +4 -0
  24. package/dist/assets/icons/strikethrough.svg +1 -0
  25. package/dist/assets/icons/table.svg +1 -0
  26. package/dist/assets/icons/ul.svg +1 -0
  27. package/dist/assets/icons/underline.svg +1 -0
  28. package/dist/assets/icons/unlink.svg +1 -0
  29. package/dist/components/browser-tip/index.css +18 -0
  30. package/dist/components/browser-tip/index.js +28 -0
  31. package/dist/components/centered-loading.js +23 -0
  32. package/dist/components/icon/index.css +7 -0
  33. package/dist/components/icon/index.js +30 -0
  34. package/dist/components/icon-button/index.css +33 -0
  35. package/dist/components/icon-button/index.js +71 -0
  36. package/dist/components/index.js +92 -0
  37. package/dist/components/loading/index.css +54 -0
  38. package/dist/components/loading/index.js +15 -0
  39. package/dist/components/modal/index.css +0 -0
  40. package/dist/components/modal/index.js +27 -0
  41. package/dist/components/modal-header/index.css +22 -0
  42. package/dist/components/modal-header/index.js +36 -0
  43. package/dist/components/option/index.css +20 -0
  44. package/dist/components/option/index.js +39 -0
  45. package/dist/components/options-editor/container/index.css +49 -0
  46. package/dist/components/options-editor/container/index.js +122 -0
  47. package/dist/components/options-editor/index.css +26 -0
  48. package/dist/components/options-editor/index.js +70 -0
  49. package/dist/components/options-editor/options/index.css +5 -0
  50. package/dist/components/options-editor/options/index.js +138 -0
  51. package/dist/components/options-editor/options/option/index.css +54 -0
  52. package/dist/components/options-editor/options/option/index.js +138 -0
  53. package/dist/components/popover/index.js +85 -0
  54. package/dist/components/popover/utils.js +76 -0
  55. package/dist/components/search-input/index.css +52 -0
  56. package/dist/components/search-input/index.js +148 -0
  57. package/dist/components/selector-display/index.css +86 -0
  58. package/dist/components/selector-display/index.js +66 -0
  59. package/dist/components/toolbar/index.js +20 -0
  60. package/dist/components/toolbar/toolbar-group/index.css +13 -0
  61. package/dist/components/toolbar/toolbar-group/index.js +22 -0
  62. package/dist/components/toolbar/toolbar-item/index.css +3 -0
  63. package/dist/components/toolbar/toolbar-item/index.js +53 -0
  64. package/dist/components/tooltip/index.css +68 -0
  65. package/dist/components/tooltip/index.js +46 -0
  66. package/dist/components/tooltip/shortcut-key/index.css +7 -0
  67. package/dist/components/tooltip/shortcut-key/index.js +20 -0
  68. package/dist/constants/event-types.js +25 -0
  69. package/dist/constants/index.js +40 -0
  70. package/dist/constants/key-codes.js +104 -0
  71. package/dist/editor/index.css +44 -0
  72. package/dist/editor/index.js +50 -0
  73. package/dist/editor/main/index.css +19 -0
  74. package/dist/editor/main/index.js +166 -0
  75. package/dist/editor/with-props-editor.js +20 -0
  76. package/dist/extension/commons/dropdown-menu-item/index.css +52 -0
  77. package/dist/extension/commons/dropdown-menu-item/index.js +62 -0
  78. package/dist/extension/commons/index.js +5 -0
  79. package/dist/extension/commons/insert-element-dialog/index.js +91 -0
  80. package/dist/extension/commons/menu/index.js +3 -0
  81. package/dist/extension/commons/menu/menu-drop-down.js +98 -0
  82. package/dist/extension/commons/menu-shortcut-indicator/index.js +24 -0
  83. package/dist/extension/commons/menu-shortcut-indicator/style.css +18 -0
  84. package/dist/extension/constants/element-default-style.js +78 -0
  85. package/dist/extension/constants/element-types.js +33 -0
  86. package/dist/extension/constants/index.js +63 -0
  87. package/dist/extension/constants/keyboard.js +33 -0
  88. package/dist/extension/constants/menus-config.js +142 -0
  89. package/dist/extension/core/index.js +38 -0
  90. package/dist/extension/core/queries/index.js +507 -0
  91. package/dist/extension/core/transforms/focus-editor.js +18 -0
  92. package/dist/extension/core/transforms/index.js +49 -0
  93. package/dist/extension/core/transforms/move-children.js +35 -0
  94. package/dist/extension/core/transforms/remove-node-children.js +19 -0
  95. package/dist/extension/core/transforms/replace-node-children.js +24 -0
  96. package/dist/extension/core/utils/index.js +120 -0
  97. package/dist/extension/event-transfer/get-event-transfer.js +38 -0
  98. package/dist/extension/event-transfer/set-event-transfer.js +36 -0
  99. package/dist/extension/highlight/index.js +20 -0
  100. package/dist/extension/highlight/normalize-tokens.js +94 -0
  101. package/dist/extension/highlight/prismjs.js +27 -0
  102. package/dist/extension/highlight/set-node-decorations.js +81 -0
  103. package/dist/extension/highlight/use-highlight.js +20 -0
  104. package/dist/extension/index.js +67 -0
  105. package/dist/extension/plugins/blockquote/helpers.js +68 -0
  106. package/dist/extension/plugins/blockquote/index.js +18 -0
  107. package/dist/extension/plugins/blockquote/menu/index.js +35 -0
  108. package/dist/extension/plugins/blockquote/plugin.js +154 -0
  109. package/dist/extension/plugins/blockquote/render-elem.js +29 -0
  110. package/dist/extension/plugins/check-list/helper.js +34 -0
  111. package/dist/extension/plugins/check-list/index.js +19 -0
  112. package/dist/extension/plugins/check-list/menu/index.js +39 -0
  113. package/dist/extension/plugins/check-list/plugin.js +92 -0
  114. package/dist/extension/plugins/check-list/render-elem.js +61 -0
  115. package/dist/extension/plugins/clear-format/helpers.js +51 -0
  116. package/dist/extension/plugins/clear-format/menu/index.js +35 -0
  117. package/dist/extension/plugins/code-block/helpers.js +140 -0
  118. package/dist/extension/plugins/code-block/index.js +20 -0
  119. package/dist/extension/plugins/code-block/menu/index.js +59 -0
  120. package/dist/extension/plugins/code-block/plugin.js +288 -0
  121. package/dist/extension/plugins/code-block/render-elem/constant.js +22 -0
  122. package/dist/extension/plugins/code-block/render-elem/index.js +89 -0
  123. package/dist/extension/plugins/code-block/render-elem/language-selector/index.css +18 -0
  124. package/dist/extension/plugins/code-block/render-elem/language-selector/index.js +38 -0
  125. package/dist/extension/plugins/formula/formula.css +22 -0
  126. package/dist/extension/plugins/formula/helper.js +80 -0
  127. package/dist/extension/plugins/formula/index.js +19 -0
  128. package/dist/extension/plugins/formula/menu/formula-modal.js +98 -0
  129. package/dist/extension/plugins/formula/menu/index.js +35 -0
  130. package/dist/extension/plugins/formula/plugin.js +22 -0
  131. package/dist/extension/plugins/formula/render-elem.js +64 -0
  132. package/dist/extension/plugins/header/helper.js +55 -0
  133. package/dist/extension/plugins/header/index.js +19 -0
  134. package/dist/extension/plugins/header/menu/index.js +72 -0
  135. package/dist/extension/plugins/header/plugin.js +155 -0
  136. package/dist/extension/plugins/header/render-elem.js +39 -0
  137. package/dist/extension/plugins/html/index.js +13 -0
  138. package/dist/extension/plugins/html/plugin.js +69 -0
  139. package/dist/extension/plugins/image/helper.js +131 -0
  140. package/dist/extension/plugins/image/index.js +19 -0
  141. package/dist/extension/plugins/image/menu/image-menu-dialog.js +92 -0
  142. package/dist/extension/plugins/image/menu/index.css +3 -0
  143. package/dist/extension/plugins/image/menu/index.js +103 -0
  144. package/dist/extension/plugins/image/plugin.js +56 -0
  145. package/dist/extension/plugins/image/render-element/image-previewer.js +89 -0
  146. package/dist/extension/plugins/image/render-element/index.js +141 -0
  147. package/dist/extension/plugins/image/render-element/style.css +68 -0
  148. package/dist/extension/plugins/index.js +116 -0
  149. package/dist/extension/plugins/link/helper.js +258 -0
  150. package/dist/extension/plugins/link/index.js +19 -0
  151. package/dist/extension/plugins/link/menu/index.js +92 -0
  152. package/dist/extension/plugins/link/menu/link-modal.js +169 -0
  153. package/dist/extension/plugins/link/plugin.js +172 -0
  154. package/dist/extension/plugins/link/render-elem/index.css +12 -0
  155. package/dist/extension/plugins/link/render-elem/index.js +103 -0
  156. package/dist/extension/plugins/link/render-elem/link-op-menu/index.css +33 -0
  157. package/dist/extension/plugins/link/render-elem/link-op-menu/index.js +89 -0
  158. package/dist/extension/plugins/list/constant.js +8 -0
  159. package/dist/extension/plugins/list/helpers.js +102 -0
  160. package/dist/extension/plugins/list/index.js +19 -0
  161. package/dist/extension/plugins/list/menu/index.js +41 -0
  162. package/dist/extension/plugins/list/plugin/index.js +80 -0
  163. package/dist/extension/plugins/list/plugin/insert-break-list.js +29 -0
  164. package/dist/extension/plugins/list/plugin/insert-fragment-list.js +179 -0
  165. package/dist/extension/plugins/list/plugin/normalize-list.js +79 -0
  166. package/dist/extension/plugins/list/plugin/on-tab-handle.js +63 -0
  167. package/dist/extension/plugins/list/plugin/shortcut.js +69 -0
  168. package/dist/extension/plugins/list/queries/index.js +52 -0
  169. package/dist/extension/plugins/list/render-elem/index.js +68 -0
  170. package/dist/extension/plugins/list/transforms/index.js +75 -0
  171. package/dist/extension/plugins/list/transforms/insert-list-item.js +98 -0
  172. package/dist/extension/plugins/list/transforms/move-list-item-down.js +50 -0
  173. package/dist/extension/plugins/list/transforms/move-list-item-up.js +124 -0
  174. package/dist/extension/plugins/list/transforms/move-list-items-to-list.js +63 -0
  175. package/dist/extension/plugins/list/transforms/move-list-items.js +73 -0
  176. package/dist/extension/plugins/list/transforms/normalize-list-item.js +110 -0
  177. package/dist/extension/plugins/list/transforms/normalize-nested-list.js +38 -0
  178. package/dist/extension/plugins/list/transforms/remove-first-list-item.js +24 -0
  179. package/dist/extension/plugins/list/transforms/transforms-to-list.js +131 -0
  180. package/dist/extension/plugins/list/transforms/unwrap-list.js +48 -0
  181. package/dist/extension/plugins/markdown/index.js +12 -0
  182. package/dist/extension/plugins/markdown/plugin.js +257 -0
  183. package/dist/extension/plugins/node-id/constants.js +24 -0
  184. package/dist/extension/plugins/node-id/helpers.js +78 -0
  185. package/dist/extension/plugins/node-id/index.js +12 -0
  186. package/dist/extension/plugins/node-id/with-node-id.js +37 -0
  187. package/dist/extension/plugins/p/helper.js +17 -0
  188. package/dist/extension/plugins/p/index.js +17 -0
  189. package/dist/extension/plugins/p/plugin.js +141 -0
  190. package/dist/extension/plugins/p/render-elem.js +29 -0
  191. package/dist/extension/plugins/paragraph/helper.js +17 -0
  192. package/dist/extension/plugins/paragraph/index.js +17 -0
  193. package/dist/extension/plugins/paragraph/plugin.js +141 -0
  194. package/dist/extension/plugins/paragraph/render-elem.js +29 -0
  195. package/dist/extension/plugins/table/constant.js +24 -0
  196. package/dist/extension/plugins/table/context-menu/horizontal-align-popover/index.css +3 -0
  197. package/dist/extension/plugins/table/context-menu/horizontal-align-popover/index.js +64 -0
  198. package/dist/extension/plugins/table/context-menu/index.css +13 -0
  199. package/dist/extension/plugins/table/context-menu/index.js +152 -0
  200. package/dist/extension/plugins/table/context-menu/insert-table-element/index.css +27 -0
  201. package/dist/extension/plugins/table/context-menu/insert-table-element/index.js +113 -0
  202. package/dist/extension/plugins/table/helper.js +333 -0
  203. package/dist/extension/plugins/table/index.js +21 -0
  204. package/dist/extension/plugins/table/menu/index.js +61 -0
  205. package/dist/extension/plugins/table/menu/table-operator.js +97 -0
  206. package/dist/extension/plugins/table/menu/table-size-selector/index.css +27 -0
  207. package/dist/extension/plugins/table/menu/table-size-selector/index.js +98 -0
  208. package/dist/extension/plugins/table/model.js +102 -0
  209. package/dist/extension/plugins/table/plugin.js +351 -0
  210. package/dist/extension/plugins/table/render-elem/index.css +64 -0
  211. package/dist/extension/plugins/table/render-elem/index.js +252 -0
  212. package/dist/extension/plugins/table/table-operations.js +323 -0
  213. package/dist/extension/plugins/text-style/helpers.js +57 -0
  214. package/dist/extension/plugins/text-style/index.js +17 -0
  215. package/dist/extension/plugins/text-style/menu/index.js +37 -0
  216. package/dist/extension/plugins/text-style/plugin.js +38 -0
  217. package/dist/extension/plugins/text-style/render-elem.js +63 -0
  218. package/dist/extension/render/render-element.js +115 -0
  219. package/dist/extension/render/render-leaf.js +22 -0
  220. package/dist/extension/toolbar/index.css +16 -0
  221. package/dist/extension/toolbar/index.js +89 -0
  222. package/dist/extension/toolbar/insert-toolbar.js +78 -0
  223. package/dist/hooks/use-attachments.js +38 -0
  224. package/dist/hooks/use-container-style.js +50 -0
  225. package/dist/hooks/use-mathjax.js +46 -0
  226. package/dist/hooks/use-scroll-context.js +20 -0
  227. package/dist/hooks/use-selection-update.js +20 -0
  228. package/dist/hooks/user-link-click.js +52 -0
  229. package/dist/index.js +9 -0
  230. package/dist/intl/ReactIntlUniversal.js +310 -0
  231. package/dist/intl/constants.js +21 -0
  232. package/dist/intl/index.js +33 -0
  233. package/dist/locale/index.js +11 -0
  234. package/dist/locale/lang/en.json +83 -0
  235. package/dist/slate-convert/html-to-slate/constants.js +146 -0
  236. package/dist/slate-convert/html-to-slate/helper.js +106 -0
  237. package/dist/slate-convert/html-to-slate/index.js +138 -0
  238. package/dist/slate-convert/html-to-slate/rules/blockquote.js +26 -0
  239. package/dist/slate-convert/html-to-slate/rules/br.js +29 -0
  240. package/dist/slate-convert/html-to-slate/rules/check-list.js +29 -0
  241. package/dist/slate-convert/html-to-slate/rules/code-block.js +95 -0
  242. package/dist/slate-convert/html-to-slate/rules/header.js +26 -0
  243. package/dist/slate-convert/html-to-slate/rules/image.js +31 -0
  244. package/dist/slate-convert/html-to-slate/rules/index.js +20 -0
  245. package/dist/slate-convert/html-to-slate/rules/link.js +31 -0
  246. package/dist/slate-convert/html-to-slate/rules/list.js +74 -0
  247. package/dist/slate-convert/html-to-slate/rules/p.js +37 -0
  248. package/dist/slate-convert/html-to-slate/rules/paragraph.js +37 -0
  249. package/dist/slate-convert/html-to-slate/rules/table.js +64 -0
  250. package/dist/slate-convert/html-to-slate/rules/text.js +71 -0
  251. package/dist/slate-convert/index.js +20 -0
  252. package/dist/slate-convert/slate-to-html/index.js +143 -0
  253. package/dist/utils/common.js +46 -0
  254. package/dist/utils/deserialize-html.js +219 -0
  255. package/dist/utils/dom-utils.js +57 -0
  256. package/dist/utils/dom.js +133 -0
  257. package/dist/utils/event-bus.js +40 -0
  258. package/dist/utils/event-handler.js +44 -0
  259. package/dist/utils/get-browser-Info.js +35 -0
  260. package/dist/utils/hotkey.js +45 -0
  261. package/dist/utils/is-punctuation-mark.js +50 -0
  262. package/dist/utils/object-utils.js +56 -0
  263. package/dist/utils/search.js +20 -0
  264. package/dist/utils/translate.js +18 -0
  265. package/dist/utils/type-detection.js +42 -0
  266. package/package.json +177 -0
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.addClass = addClass;
7
+ exports.getTarget = exports.getEventClassName = exports.getDataAttr = exports.canUseDOM = exports.addClassName = void 0;
8
+ exports.hasClass = hasClass;
9
+ exports.isNearBottom = exports.isInputOrEditorActive = void 0;
10
+ exports.removeClass = removeClass;
11
+ exports.removeClassName = void 0;
12
+ const canUseDOM = exports.canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
13
+ const getEventClassName = e => {
14
+ // svg mouseEvent event.target.className is an object
15
+ if (!e || !e.target) return '';
16
+ return e.target.getAttribute('class') || '';
17
+ };
18
+ exports.getEventClassName = getEventClassName;
19
+ const addClassName = (originClassName, targetClassName) => {
20
+ const originClassNames = originClassName.split(' ');
21
+ if (originClassNames.indexOf(targetClassName) > -1) return originClassName;
22
+ return originClassName + ' ' + targetClassName;
23
+ };
24
+ exports.addClassName = addClassName;
25
+ const removeClassName = (originClassName, targetClassName) => {
26
+ let originClassNames = originClassName.split(' ');
27
+ const targetClassNameIndex = originClassNames.indexOf(targetClassName);
28
+ if (targetClassNameIndex < 0) return originClassName;
29
+ originClassNames.splice(targetClassNameIndex, 1);
30
+ return originClassNames.join(' ');
31
+ };
32
+ exports.removeClassName = removeClassName;
33
+ function hasClass(node, className) {
34
+ if (node.classList) {
35
+ return node.classList.contains(className);
36
+ }
37
+ const originClass = node.className;
38
+ return ` ${originClass} `.indexOf(` ${className} `) > -1;
39
+ }
40
+ function addClass(node, className) {
41
+ if (node.classList) {
42
+ node.classList.add(className);
43
+ } else {
44
+ if (!hasClass(node, className)) {
45
+ node.className = `${node.className} ${className}`;
46
+ }
47
+ }
48
+ }
49
+ function removeClass(node, className) {
50
+ if (node.classList) {
51
+ node.classList.remove(className);
52
+ } else {
53
+ if (hasClass(node, className)) {
54
+ const originClass = node.className;
55
+ node.className = ` ${originClass} `.replace(` ${className} `, '');
56
+ }
57
+ }
58
+ }
59
+ const getDataAttr = props => {
60
+ return Object.keys(props).reduce((prev, key) => {
61
+ if (key.substr(0, 5) === 'aria-' || key.substr(0, 5) === 'data-' || key === 'role') {
62
+ prev[key] = props[key];
63
+ }
64
+ return prev;
65
+ }, {});
66
+ };
67
+ exports.getDataAttr = getDataAttr;
68
+ const isReactRefObj = target => {
69
+ if (target && typeof target === 'object') return 'current' in target;
70
+ return false;
71
+ };
72
+ const getTag = value => {
73
+ if (value == null) return value === undefined ? '[object Undefined]' : '[object Null]';
74
+ return Object.prototype.toString.call(value);
75
+ };
76
+ const isObject = value => {
77
+ const type = typeof value;
78
+ return value != null && (type === 'object' || type === 'function');
79
+ };
80
+ const isFunction = value => {
81
+ if (!isObject(value)) return false;
82
+ const tag = getTag(value);
83
+ return tag === '[object Function]' || tag === '[object AsyncFunction]' || tag === '[object GeneratorFunction]' || tag === '[object Proxy]';
84
+ };
85
+ const findDOMElements = target => {
86
+ if (isReactRefObj(target)) return target.current;
87
+ if (isFunction(target)) return target();
88
+ if (typeof target === 'string' && canUseDOM) {
89
+ let selection = document.querySelectorAll(target);
90
+ if (!selection.length) {
91
+ selection = document.querySelectorAll(`#${target}`);
92
+ }
93
+ if (!selection.length) {
94
+ throw new Error(`The target '${target}' could not be identified in the dom, tip: check spelling`);
95
+ }
96
+ return selection;
97
+ }
98
+ return target;
99
+ };
100
+ const isArrayOrNodeList = els => {
101
+ if (els === null) return false;
102
+ return Array.isArray(els) || canUseDOM && typeof els.length === 'number';
103
+ };
104
+ const getTarget = (target, allElements) => {
105
+ const els = findDOMElements(target);
106
+ if (!allElements) {
107
+ if (isArrayOrNodeList(els)) return els;
108
+ if (els === null) return null;
109
+ return els;
110
+ }
111
+ if (isArrayOrNodeList(els)) return els[0];
112
+ return els[0];
113
+ };
114
+ exports.getTarget = getTarget;
115
+ const isInputOrEditorActive = () => {
116
+ const activeEl = document.activeElement;
117
+ if (activeEl.tagName === 'INPUT' || activeEl.isContentEditable) return true;
118
+ return false;
119
+ };
120
+ exports.isInputOrEditorActive = isInputOrEditorActive;
121
+ const isNearBottom = function (element) {
122
+ let threshold = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 50;
123
+ const el = getTarget(element);
124
+ if (!el) return false;
125
+ const scrollTop = el.scrollTop;
126
+ const clientHeight = el.clientHeight;
127
+ const scrollHeight = el.scrollHeight;
128
+
129
+ // Triggered when the distance from the bottom is less than the threshold
130
+ const distanceToBottom = scrollHeight - (scrollTop + clientHeight);
131
+ return distanceToBottom <= threshold;
132
+ };
133
+ exports.isNearBottom = isNearBottom;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ class EventBus {
8
+ constructor() {
9
+ this.instance = null;
10
+ this.subscribers = {};
11
+ }
12
+ static getInstance() {
13
+ if (this.instance) return this.instance;
14
+ this.instance = new EventBus();
15
+ return this.instance;
16
+ }
17
+ subscribe(type, handler) {
18
+ if (!this.subscribers[type]) {
19
+ this.subscribers[type] = [];
20
+ }
21
+ const handlers = this.subscribers[type];
22
+ handlers.push(handler);
23
+ return () => {
24
+ const index = handlers.indexOf(handler);
25
+ if (index > -1) {
26
+ handlers.splice(index, 1);
27
+ }
28
+ };
29
+ }
30
+ dispatch(type) {
31
+ for (var _len = arguments.length, data = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
32
+ data[_key - 1] = arguments[_key];
33
+ }
34
+ const handlers = this.subscribers[type];
35
+ if (Array.isArray(handlers)) {
36
+ handlers.forEach(handler => handler(...data));
37
+ }
38
+ }
39
+ }
40
+ var _default = exports.default = EventBus;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _isHotkey = _interopRequireDefault(require("is-hotkey"));
9
+ class EventProxy {
10
+ constructor(_editor) {
11
+ this.onKeyDown = event => {
12
+ const editor = this.editor;
13
+ if (editor.onHotKeyDown) {
14
+ const isHandled = editor.onHotKeyDown(event);
15
+ if (isHandled) return;
16
+ }
17
+
18
+ // Disable the default 'save page'
19
+ if ((0, _isHotkey.default)('mod+s', event)) {
20
+ event.preventDefault();
21
+ const {
22
+ onSave
23
+ } = this.editor;
24
+ onSave && onSave();
25
+ }
26
+
27
+ // Disable default 'tab' behavior
28
+ if ((0, _isHotkey.default)('tab', event)) {
29
+ if (editor.hasMovedSelection) event.stopPropagation();
30
+ event.preventDefault();
31
+ }
32
+ };
33
+ this.onCopy = event => {
34
+ const editor = this.editor;
35
+ if (editor.onCopy) {
36
+ const isHandled = editor.onCopy(event);
37
+ if (isHandled) return true;
38
+ }
39
+ return false;
40
+ };
41
+ this.editor = _editor;
42
+ }
43
+ }
44
+ var _default = exports.default = EventProxy;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ const getBrowserInfo = isCheckBrowser => {
8
+ if (!isCheckBrowser) return {
9
+ isValidBrowser: true,
10
+ isWindowsWechat: false
11
+ };
12
+ let isValidBrowser = false;
13
+ let isWindowsWechat = false;
14
+ if (window.chrome) {
15
+ const appVersion = window.navigator.appVersion;
16
+ const appVersionList = appVersion.split(' ');
17
+ const index = appVersionList.findIndex(version => {
18
+ return version.indexOf('Chrome') >= 0;
19
+ });
20
+ let chromeVersion = appVersionList[index];
21
+ chromeVersion = chromeVersion.slice(chromeVersion.indexOf('/') + 1);
22
+ chromeVersion = parseInt(chromeVersion);
23
+ isValidBrowser = chromeVersion >= 76;
24
+ // Windows Wechat inner core is chrome 53, not support ECMA6, so use readonly mode
25
+ if (chromeVersion === 53 && navigator.appVersion && navigator.appVersion.includes('WindowsWechat')) {
26
+ isValidBrowser = false;
27
+ isWindowsWechat = true;
28
+ }
29
+ }
30
+ return {
31
+ isValidBrowser,
32
+ isWindowsWechat
33
+ };
34
+ };
35
+ var _default = exports.default = getBrowserInfo;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.isUpArrow = exports.isTab = exports.isT = exports.isSpace = exports.isShiftT = exports.isShiftSlash = exports.isShiftS = exports.isShiftModEnter = exports.isShiftEnter = exports.isS = exports.isP = exports.isOptPageUp = exports.isOptPageDown = exports.isModZ = exports.isModUp = exports.isModSlash = exports.isModShiftZ = exports.isModShiftG = exports.isModShiftDot = exports.isModShiftComma = exports.isModSemicolon = exports.isModS = exports.isModRight = exports.isModP = exports.isModLeft = exports.isModL = exports.isModG = exports.isModF = exports.isModEnter = exports.isModDown = exports.isModDot = exports.isModComma = exports.isModBackslash = exports.isEsc = exports.isEnter = exports.isDownArrow = exports.isA = void 0;
8
+ var _isHotkey = _interopRequireDefault(require("is-hotkey"));
9
+ const isModS = exports.isModS = (0, _isHotkey.default)('mod+s');
10
+ const isModZ = exports.isModZ = (0, _isHotkey.default)('mod+z');
11
+ const isModL = exports.isModL = (0, _isHotkey.default)('mod+l');
12
+ const isModF = exports.isModF = (0, _isHotkey.default)('mod+f');
13
+ const isModP = exports.isModP = (0, _isHotkey.default)('mod+p');
14
+ const isModG = exports.isModG = (0, _isHotkey.default)('mod+g');
15
+ const isModDot = exports.isModDot = (0, _isHotkey.default)('mod+.');
16
+ const isModComma = exports.isModComma = (0, _isHotkey.default)('mod+,');
17
+ const isModSlash = exports.isModSlash = (0, _isHotkey.default)('mod+/');
18
+ const isModBackslash = exports.isModBackslash = (0, _isHotkey.default)('mod+\'');
19
+ const isModSemicolon = exports.isModSemicolon = (0, _isHotkey.default)('mod+;');
20
+ const isModUp = exports.isModUp = (0, _isHotkey.default)('mod+up');
21
+ const isModDown = exports.isModDown = (0, _isHotkey.default)('mod+down');
22
+ const isModLeft = exports.isModLeft = (0, _isHotkey.default)('mod+left');
23
+ const isModRight = exports.isModRight = (0, _isHotkey.default)('mod+right');
24
+ const isModShiftZ = exports.isModShiftZ = (0, _isHotkey.default)('mod+shift+z');
25
+ const isModShiftG = exports.isModShiftG = (0, _isHotkey.default)('mod+shift+g');
26
+ const isModShiftDot = exports.isModShiftDot = (0, _isHotkey.default)('mod+shift+.');
27
+ const isModShiftComma = exports.isModShiftComma = (0, _isHotkey.default)('mod+shift+,');
28
+ const isShiftEnter = exports.isShiftEnter = (0, _isHotkey.default)('shift+enter');
29
+ const isModEnter = exports.isModEnter = (0, _isHotkey.default)('mod+enter');
30
+ const isSpace = exports.isSpace = (0, _isHotkey.default)('space');
31
+ const isShiftModEnter = exports.isShiftModEnter = (0, _isHotkey.default)('shift+mod+enter');
32
+ const isOptPageUp = exports.isOptPageUp = (0, _isHotkey.default)('opt+pageup');
33
+ const isOptPageDown = exports.isOptPageDown = (0, _isHotkey.default)('opt+pagedown');
34
+ const isEnter = exports.isEnter = (0, _isHotkey.default)('enter');
35
+ const isEsc = exports.isEsc = (0, _isHotkey.default)('esc');
36
+ const isTab = exports.isTab = (0, _isHotkey.default)('tab');
37
+ const isUpArrow = exports.isUpArrow = (0, _isHotkey.default)('arrowup');
38
+ const isDownArrow = exports.isDownArrow = (0, _isHotkey.default)('arrowdown');
39
+ const isP = exports.isP = (0, _isHotkey.default)('p'); // rate setting
40
+ const isA = exports.isA = (0, _isHotkey.default)('a'); // collaborators setting
41
+ const isT = exports.isT = (0, _isHotkey.default)('t'); // tags setting
42
+ const isS = exports.isS = (0, _isHotkey.default)('s'); // state setting
43
+ const isShiftS = exports.isShiftS = (0, _isHotkey.default)('shift+s'); // sub state setting
44
+ const isShiftT = exports.isShiftT = (0, _isHotkey.default)('shift+t'); // type setting
45
+ const isShiftSlash = exports.isShiftSlash = (0, _isHotkey.default)('shift+/');
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ const isChPunctuation = char => {
8
+ // \u2014|\u2018|\u2019|\u201c|\u201d|
9
+ // \u2026|
10
+ // \u2039|\u203a
11
+ // \u3001|\u3002|\u3008|\u3009|\u300a|\u300b|\u300c|\u300d|\u300e|\u300f
12
+ // \u3010|\u3011|\u3014|\u3015|\u301c|\u301d|\u301e
13
+ // \ufe43|\ufe44|\ufe4f
14
+ // \uffe5 (¥)
15
+ const reg = /[\u2014|\u2018|\u2019|\u201c|\u201d|\u2026|\u2039|\u203a|\u3001|\u3002|\u3008|\u3009|\u300a|\u300b|\u300c|\u300d|\u300e|\u300f|\u3010|\u3011|\u3014|\u3015|\u301c|\u301d|\u301e]/;
16
+ if (reg.test(char)) {
17
+ return true;
18
+ } else {
19
+ return false;
20
+ }
21
+ };
22
+ function isEnHalfWidthPunctuation(char) {
23
+ // Distribution of half-width punctuation points in unicode: 0x0021~0x007e
24
+ // https://en.wikibooks.org/wiki/Unicode/Character_reference/0000-0FFF
25
+ const reg = /[\x21-\x2f\x3a-\x40\x5b-\x60\x7B-\x7F]/;
26
+ if (reg.test(char)) {
27
+ return true;
28
+ } else {
29
+ return false;
30
+ }
31
+ }
32
+ function isEnFullWidthPunctuation(char) {
33
+ // 0xff01~0xff5e
34
+ // https://en.wikibooks.org/wiki/Unicode/Character_reference/F000-FFFF
35
+ const reg = /[\uff01-\uff0f\uff1a-\uff1f\uff20\uff3b-\uff3f\uff40\uff5b-\uff5f]/;
36
+ if (reg.test(char)) {
37
+ return true;
38
+ } else {
39
+ return false;
40
+ }
41
+ }
42
+ const isLastCharPunctuation = value => {
43
+ if (typeof value !== 'string' || !value) return false;
44
+ const lastChar = value.slice(-1);
45
+ if (isChPunctuation(lastChar)) return true;
46
+ if (isEnHalfWidthPunctuation(lastChar)) return true;
47
+ if (isEnFullWidthPunctuation(lastChar)) return true;
48
+ return false;
49
+ };
50
+ var _default = exports.default = isLastCharPunctuation;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _ObjectUtils;
8
+ class ObjectUtils {
9
+ static getDataType(data) {
10
+ let type = typeof data;
11
+ if (type !== 'object') {
12
+ return type;
13
+ }
14
+ return Object.prototype.toString.call(data).replace(/^\[object (\S+)\]$/, '$1');
15
+ }
16
+ static iterable(data) {
17
+ return ['Object', 'Array'].includes(this.getDataType(data));
18
+ }
19
+ static isObjectChanged(source, comparison, notIncludeKeys) {
20
+ if (!this.iterable(source)) {
21
+ throw new Error(`source should be a Object or Array , but got ${this.getDataType(source)}`);
22
+ }
23
+ if (this.getDataType(source) !== this.getDataType(comparison)) {
24
+ return true;
25
+ }
26
+ const sourceKeys = Object.keys(source);
27
+ const comparisonKeys = Object.keys({
28
+ ...source,
29
+ ...comparison
30
+ }).filter(key => !notIncludeKeys.includes(key));
31
+ if (sourceKeys.length !== comparisonKeys.length) {
32
+ return true;
33
+ }
34
+ return comparisonKeys.some(key => {
35
+ if (this.iterable(source[key])) {
36
+ return this.isObjectChanged(source[key], comparison[key], notIncludeKeys);
37
+ } else {
38
+ return source[key] !== comparison[key];
39
+ }
40
+ });
41
+ }
42
+ static isSameObject(source, comparison) {
43
+ let notIncludeKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
44
+ if (!source || !comparison) return false;
45
+ return !this.isObjectChanged(source, comparison, notIncludeKeys);
46
+ }
47
+ }
48
+ _ObjectUtils = ObjectUtils;
49
+ ObjectUtils.isObject = data => {
50
+ return _ObjectUtils.getDataType(data) === 'Object';
51
+ };
52
+ ObjectUtils.hasProperty = (obj, prop) => {
53
+ if (!obj) return false;
54
+ return Object.prototype.hasOwnProperty.call(obj, prop);
55
+ };
56
+ var _default = exports.default = ObjectUtils;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.searchOptions = void 0;
7
+ const searchOptions = (options, searchValue) => {
8
+ const validSearchValue = searchValue ? searchValue.trim().toLowerCase() : '';
9
+ const validOptions = Array.isArray(options) && options.length > 0 ? options : [];
10
+ if (!validSearchValue) return validOptions;
11
+ return options.filter(option => {
12
+ const {
13
+ name
14
+ } = option;
15
+ if (!name) return false;
16
+ if (name.toString().toLowerCase().indexOf(validSearchValue) > -1) return true;
17
+ return false;
18
+ });
19
+ };
20
+ exports.searchOptions = searchOptions;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.gettext = exports.getHTML = void 0;
8
+ var _intl = _interopRequireDefault(require("../intl"));
9
+ const gettext = (translate_Key, params) => {
10
+ if (!translate_Key) return '';
11
+ return _intl.default.get(translate_Key, params) || translate_Key;
12
+ };
13
+ exports.gettext = gettext;
14
+ const getHTML = (translate_Key, params) => {
15
+ if (!translate_Key) return '';
16
+ return _intl.default.getHTML(translate_Key, params) || translate_Key;
17
+ };
18
+ exports.getHTML = getHTML;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isString = exports.isObject = exports.isNumber = exports.isFunction = exports.getType = void 0;
7
+ const getType = value => {
8
+ return Object.prototype.toString.call(value).slice(8, -1);
9
+ };
10
+
11
+ /**
12
+ * Check whether is number
13
+ * @param {number} number
14
+ * @returns boolean
15
+ */
16
+ exports.getType = getType;
17
+ const isNumber = number => (number || number === 0) && getType(number) === 'Number';
18
+
19
+ /**
20
+ * Check whether is object
21
+ * @param {object} object
22
+ * @returns boolean
23
+ */
24
+ exports.isNumber = isNumber;
25
+ const isObject = object => object && getType(object) === 'Object';
26
+
27
+ /**
28
+ * Check whether is string
29
+ * @param {string} string
30
+ * @returns boolean
31
+ */
32
+ exports.isObject = isObject;
33
+ const isString = string => string && getType(string) === 'String';
34
+
35
+ /**
36
+ * Check whether is function
37
+ * @param {function} function
38
+ * @returns boolean
39
+ */
40
+ exports.isString = isString;
41
+ const isFunction = functionToCheck => functionToCheck && getType(functionToCheck) === 'Function';
42
+ exports.isFunction = isFunction;
package/package.json ADDED
@@ -0,0 +1,177 @@
1
+ {
2
+ "name": "@seafile/sea-email-editor",
3
+ "version": "0.0.1",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "dependencies": {
7
+ "@seafile/react-image-lightbox": "4.0.2",
8
+ "classnames": "2.3.2",
9
+ "copy-to-clipboard": "3.3.1",
10
+ "deep-copy": "1.4.2",
11
+ "deepmerge": "4.3.1",
12
+ "i18next": "^24.2.2",
13
+ "i18next-browser-languagedetector": "^8.0.4",
14
+ "i18next-xhr-backend": "^3.1.2",
15
+ "intl-messageformat": "^7.8.4",
16
+ "invariant": "^2.2.4",
17
+ "is-hotkey": "0.2.0",
18
+ "is-url": "^1.2.4",
19
+ "prismjs": "1.30.0",
20
+ "reactstrap": "9.2.3",
21
+ "rehype-format": "5.0.0",
22
+ "rehype-mathjax": "5.0.0",
23
+ "rehype-raw": "7.0.0",
24
+ "rehype-sanitize": "6.0.0",
25
+ "rehype-slug": "6.0.0",
26
+ "rehype-stringify": "9.0.4",
27
+ "remark-breaks": "4.0.0",
28
+ "remark-gfm": "4.0.0",
29
+ "remark-math": "6.0.0",
30
+ "remark-parse": "11.0.0",
31
+ "remark-rehype": "11.0.0",
32
+ "remark-stringify": "11.0.0",
33
+ "slate": "0.94.1",
34
+ "slate-history": "0.93.0",
35
+ "slate-hyperscript": "^0.81.3",
36
+ "slate-react": "0.98.3",
37
+ "slugid": "4.0.0",
38
+ "type-of": "2.0.1",
39
+ "unified": "11.0.3",
40
+ "xtend": "4.0.2"
41
+ },
42
+ "peerDependencies": {
43
+ "axios": "^1.8.0",
44
+ "lodash-es": "^4.17.21",
45
+ "prop-types": "15.8.1",
46
+ "react": "18.3.1",
47
+ "react-dom": "18.3.1"
48
+ },
49
+ "scripts": {
50
+ "clean": "rm -rf dist && mkdir dist",
51
+ "start.bak": "node scripts/start.js",
52
+ "build": "node scripts/build.js",
53
+ "pub:dist": "export BABEL_ENV=production && ./node_modules/.bin/babel src --out-dir dist --copy-files",
54
+ "eslint": "eslint --ext .jsx,.js src --max-warnings=0",
55
+ "lint": "lint-staged",
56
+ "pub:optimized": "rm dist/config.js",
57
+ "prepare": "husky install",
58
+ "prepublishOnly": "npm run clean && npm run pub:dist",
59
+ "release": "release-it",
60
+ "start": "export NODE_OPTIONS=--openssl-legacy-provider NODE_ENV=development LOG_ENV=rc && node dev-server.js"
61
+ },
62
+ "lint-staged": {
63
+ "src/**/*.js": [
64
+ "eslint --ext .tsx,.ts,.js ./src",
65
+ "git add"
66
+ ]
67
+ },
68
+ "files": [
69
+ "assets",
70
+ "dist",
71
+ "lib",
72
+ "es",
73
+ "index.js",
74
+ "package.json"
75
+ ],
76
+ "browserslist": {
77
+ "production": [
78
+ ">0.2%",
79
+ "not dead",
80
+ "not op_mini all"
81
+ ],
82
+ "development": [
83
+ "last 1 chrome version",
84
+ "last 1 firefox version",
85
+ "last 1 safari version"
86
+ ]
87
+ },
88
+ "devDependencies": {
89
+ "@babel/cli": "7.22.10",
90
+ "@babel/core": "7.22.11",
91
+ "@babel/eslint-parser": "7.16.3",
92
+ "@babel/plugin-proposal-private-property-in-object": "7.21.11",
93
+ "@babel/plugin-transform-class-properties": "7.23.3",
94
+ "@babel/plugin-transform-modules-commonjs": "7.24.8",
95
+ "@babel/plugin-transform-private-methods": "7.23.3",
96
+ "@babel/plugin-transform-runtime": "^7.23.9",
97
+ "@babel/preset-env": "7.22.14",
98
+ "@babel/runtime": "^7.10.2",
99
+ "@pmmmwh/react-refresh-webpack-plugin": "^0.5.3",
100
+ "@svgr/webpack": "8.1.0",
101
+ "@types/jest": "29.0.0",
102
+ "@typescript-eslint/eslint-plugin": "8.26.1",
103
+ "@typescript-eslint/parser": "8.26.1",
104
+ "babel-jest": "^29.7.0",
105
+ "babel-loader": "9.1.3",
106
+ "babel-plugin-import": "^1.13.8",
107
+ "babel-plugin-named-asset-import": "^0.3.4",
108
+ "babel-plugin-transform-goober": "1.2.0",
109
+ "babel-preset-react-app": "^10.0.1",
110
+ "bfj": "^7.0.2",
111
+ "browserslist": "^4.18.1",
112
+ "buffer": "^6.0.3",
113
+ "camelcase": "^6.2.1",
114
+ "case-sensitive-paths-webpack-plugin": "2.2.0",
115
+ "circular-dependency-plugin": "^5.2.2",
116
+ "clean-webpack-plugin": "4.0.0",
117
+ "core-js": "2.6.12",
118
+ "css-loader": "^6.5.1",
119
+ "css-minimizer-webpack-plugin": "5.0.1",
120
+ "dotenv": "^10.0.0",
121
+ "dotenv-expand": "^5.1.0",
122
+ "dtable-sdk": "5.0.10",
123
+ "dtable-store": "5.3.9",
124
+ "ejs": "3.1.10",
125
+ "eslint": "^8.3.0",
126
+ "eslint-config-react-app": "^7.0.1",
127
+ "eslint-plugin-react": "7.37.4",
128
+ "eslint-plugin-react-hooks": "5.2.0",
129
+ "eslint-webpack-plugin": "^3.1.1",
130
+ "file-loader": "^6.2.0",
131
+ "fs-extra": "^10.0.0",
132
+ "html-webpack-plugin": "^5.5.0",
133
+ "husky": "8.0.3",
134
+ "identity-obj-proxy": "3.0.0",
135
+ "is-wsl": "^1.1.0",
136
+ "jest": "29.7.0",
137
+ "jest-environment-jsdom": "29.7.0",
138
+ "koa": "2.16.0",
139
+ "koa-router": "7.3.0",
140
+ "koa-send": "5.0.1",
141
+ "koa2-cors": "2.0.6",
142
+ "lint-staged": "15.4.3",
143
+ "mini-css-extract-plugin": "^2.4.5",
144
+ "node-polyfill-webpack-plugin": "2.0.1",
145
+ "postcss": "^8.4.31",
146
+ "postcss-flexbugs-fixes": "^5.0.2",
147
+ "postcss-loader": "^6.2.1",
148
+ "postcss-normalize": "^10.0.1",
149
+ "postcss-preset-env": "^7.0.1",
150
+ "prettier": "3.1.0",
151
+ "raf": "3.4.0",
152
+ "react-app-polyfill": "^3.0.0",
153
+ "react-dev-utils": "^12.0.1",
154
+ "react-refresh": "^0.11.0",
155
+ "react-router": "7.1.3",
156
+ "react-router-dom": "7.1.3",
157
+ "release-it": "^18.1.2",
158
+ "resolve": "^1.12.0",
159
+ "resolve-url-loader": "5.0.0",
160
+ "sass-loader": "13.3.2",
161
+ "source-map-loader": "^3.0.0",
162
+ "style-loader": "^3.3.1",
163
+ "svgo-loader": "^3.0.0",
164
+ "tailwindcss": "^3.0.2",
165
+ "terser-webpack-plugin": "^5.2.5",
166
+ "url-loader": "4.1.1",
167
+ "web-vitals": "2.1.4",
168
+ "webpack": "5.98.0",
169
+ "webpack-dev-server": "5.2.0",
170
+ "webpack-manifest-plugin": "5.0.0",
171
+ "webpack-merge": "5.8.0",
172
+ "workbox-webpack-plugin": "7.0.0"
173
+ },
174
+ "publishConfig": {
175
+ "access": "public"
176
+ }
177
+ }