@block-kit/plugin 1.0.0 → 1.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 (169) hide show
  1. package/dist/es/align/{index.js → align/index.js} +1 -1
  2. package/dist/es/background/{index.js → background/index.js} +1 -1
  3. package/dist/es/bold/{index.js → bold/index.js} +1 -1
  4. package/dist/es/bullet-list/{index.js → bullet-list/index.js} +8 -12
  5. package/dist/es/{is-2b264ec8.js → bullet-list/utils/bullet-list/utils/is.js} +2 -2
  6. package/dist/es/bullet-list/view/bullet-list/view/list.js +9 -0
  7. package/dist/es/divider/{index.js → divider/index.js} +5 -5
  8. package/dist/es/emoji/{index.js → emoji/index.js} +2 -2
  9. package/dist/es/font-color/{index.js → font-color/index.js} +1 -1
  10. package/dist/es/font-size/{index.js → font-size/index.js} +1 -1
  11. package/dist/es/heading/{index.js → heading/index.js} +1 -1
  12. package/dist/es/image/image/index.js +135 -0
  13. package/dist/es/image/view/image/view/image.js +39 -0
  14. package/dist/es/image/view/image/view/wrapper.js +90 -0
  15. package/dist/es/indent/{index.js → indent/index.js} +3 -3
  16. package/dist/es/index.css +1 -1
  17. package/dist/es/index.js +50 -64
  18. package/dist/es/inline-code/{index.js → inline-code/index.js} +2 -2
  19. package/dist/es/italic/{index.js → italic/index.js} +1 -1
  20. package/dist/es/line-height/{index.js → line-height/index.js} +1 -1
  21. package/dist/es/link/{index.js → link/index.js} +5 -17
  22. package/dist/es/link/view/link/view/a.js +18 -0
  23. package/dist/es/mention/mention/index.js +28 -0
  24. package/dist/es/mention/modules/mention/modules/suggest.js +98 -0
  25. package/dist/es/mention/utils/mention/utils/constant.js +24 -0
  26. package/dist/es/mention/view/mention/view/suggest.js +72 -0
  27. package/dist/es/{tslib.es6-83956cc1.js → node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs.js} +1 -1
  28. package/dist/es/order-list/{index.js → order-list/index.js} +11 -150
  29. package/dist/es/order-list/utils/order-list/utils/format.js +75 -0
  30. package/dist/es/order-list/utils/order-list/utils/is.js +12 -0
  31. package/dist/es/order-list/utils/order-list/utils/serial.js +68 -0
  32. package/dist/es/order-list/view/order-list/view/list.js +10 -0
  33. package/dist/es/quote/{index.js → quote/index.js} +4 -4
  34. package/dist/es/{selection-badfb0bc.js → shared/components/shared/components/selection.js} +3 -31
  35. package/dist/es/shared/icons/shared/icons/divider.js +5 -0
  36. package/dist/es/shared/icons/shared/icons/emoji.js +5 -0
  37. package/dist/es/shared/icons/shared/icons/font-color.js +5 -0
  38. package/dist/es/shared/icons/shared/icons/font-size.js +5 -0
  39. package/dist/es/shared/icons/shared/icons/justify.js +5 -0
  40. package/dist/es/shared/icons/shared/icons/line-height.js +5 -0
  41. package/dist/es/shared/icons/shared/icons/text.js +5 -0
  42. package/dist/es/shared/modules/shared/modules/selection.js +32 -0
  43. package/dist/es/{dom-71a99400.js → shared/utils/shared/utils/dom.js} +1 -1
  44. package/dist/es/shared/utils/shared/utils/event.js +5 -0
  45. package/dist/es/{is-3de778e2.js → shared/utils/shared/utils/is.js} +1 -1
  46. package/dist/es/shortcut/modules/shortcut/modules/preset.js +23 -0
  47. package/dist/es/shortcut/{index.js → shortcut/index.js} +6 -25
  48. package/dist/es/strike/{index.js → strike/index.js} +1 -1
  49. package/dist/es/toolbar/context/toolbar/context/basic.js +69 -0
  50. package/dist/es/toolbar/context/toolbar/context/float.js +67 -0
  51. package/dist/es/toolbar/context/toolbar/context/provider.js +12 -0
  52. package/dist/es/toolbar/modules/toolbar/modules/align.js +20 -0
  53. package/dist/es/toolbar/modules/toolbar/modules/bold.js +16 -0
  54. package/dist/es/toolbar/modules/toolbar/modules/bullet-list.js +17 -0
  55. package/dist/es/toolbar/modules/toolbar/modules/cut.js +7 -0
  56. package/dist/es/toolbar/modules/toolbar/modules/divider.js +15 -0
  57. package/dist/es/toolbar/modules/toolbar/modules/emoji.js +25 -0
  58. package/dist/es/toolbar/modules/toolbar/modules/font-color.js +49 -0
  59. package/dist/es/toolbar/modules/toolbar/modules/font-size.js +19 -0
  60. package/dist/es/toolbar/modules/toolbar/modules/heading.js +19 -0
  61. package/dist/es/toolbar/modules/toolbar/modules/history.js +34 -0
  62. package/dist/es/toolbar/modules/toolbar/modules/image.js +15 -0
  63. package/dist/es/toolbar/modules/toolbar/modules/inline-code.js +15 -0
  64. package/dist/es/toolbar/modules/toolbar/modules/italic.js +16 -0
  65. package/dist/es/toolbar/modules/toolbar/modules/line-height.js +15 -0
  66. package/dist/es/toolbar/modules/toolbar/modules/link.js +89 -0
  67. package/dist/es/toolbar/modules/toolbar/modules/order-list.js +17 -0
  68. package/dist/es/toolbar/modules/toolbar/modules/quote.js +15 -0
  69. package/dist/es/toolbar/modules/toolbar/modules/strike.js +15 -0
  70. package/dist/es/toolbar/modules/toolbar/modules/underline.js +15 -0
  71. package/dist/es/toolbar/toolbar/index.js +45 -0
  72. package/dist/es/toolbar/types/toolbar/types/index.js +7 -0
  73. package/dist/es/{marks-ac0ec630.js → toolbar/utils/toolbar/utils/marks.js} +1 -5
  74. package/dist/es/underline/{index.js → underline/index.js} +1 -1
  75. package/dist/lib/bullet-list/index.js +21 -25
  76. package/dist/lib/{is-fa1755d0.js → bullet-list/utils/is.js} +3 -1
  77. package/dist/lib/bullet-list/view/list.js +13 -0
  78. package/dist/lib/divider/index.js +7 -7
  79. package/dist/lib/emoji/index.js +1 -1
  80. package/dist/lib/image/index.js +9 -119
  81. package/dist/lib/image/view/image.js +43 -0
  82. package/dist/lib/image/view/wrapper.js +94 -0
  83. package/dist/lib/indent/index.js +3 -3
  84. package/dist/lib/index.css +1 -1
  85. package/dist/lib/index.js +23 -37
  86. package/dist/lib/inline-code/index.js +1 -1
  87. package/dist/lib/link/index.js +3 -15
  88. package/dist/lib/link/view/a.js +22 -0
  89. package/dist/lib/mention/index.js +26 -15
  90. package/dist/lib/mention/modules/suggest.js +106 -0
  91. package/dist/lib/mention/utils/constant.js +29 -0
  92. package/dist/lib/mention/view/suggest.js +76 -0
  93. package/dist/lib/order-list/index.js +34 -173
  94. package/dist/lib/order-list/utils/format.js +79 -0
  95. package/dist/lib/{is-18806678.js → order-list/utils/is.js} +4 -2
  96. package/dist/lib/order-list/utils/serial.js +72 -0
  97. package/dist/lib/order-list/view/list.js +14 -0
  98. package/dist/lib/quote/index.js +12 -12
  99. package/dist/lib/{selection-868f15c1.js → shared/components/selection.js} +2 -29
  100. package/dist/lib/shared/icons/divider.js +9 -0
  101. package/dist/lib/shared/icons/emoji.js +9 -0
  102. package/dist/lib/shared/icons/font-color.js +9 -0
  103. package/dist/lib/shared/icons/font-size.js +9 -0
  104. package/dist/lib/shared/icons/justify.js +9 -0
  105. package/dist/lib/shared/icons/line-height.js +9 -0
  106. package/dist/lib/shared/icons/text.js +9 -0
  107. package/dist/lib/shared/modules/selection.js +36 -0
  108. package/dist/lib/{dom-cb8b8e40.js → shared/utils/dom.js} +2 -0
  109. package/dist/lib/shared/utils/event.js +9 -0
  110. package/dist/lib/{is-473d664a.js → shared/utils/is.js} +2 -0
  111. package/dist/lib/shortcut/index.js +8 -27
  112. package/dist/lib/shortcut/modules/preset.js +27 -0
  113. package/dist/lib/toolbar/context/basic.js +73 -0
  114. package/dist/lib/toolbar/context/float.js +75 -0
  115. package/dist/lib/toolbar/context/provider.js +21 -0
  116. package/dist/lib/toolbar/index.js +45 -38
  117. package/dist/lib/toolbar/modules/align.js +24 -0
  118. package/dist/lib/toolbar/modules/bold.js +20 -0
  119. package/dist/lib/toolbar/modules/bullet-list.js +21 -0
  120. package/dist/lib/toolbar/modules/cut.js +11 -0
  121. package/dist/lib/toolbar/modules/divider.js +19 -0
  122. package/dist/lib/toolbar/modules/emoji.js +33 -0
  123. package/dist/lib/toolbar/modules/font-color.js +53 -0
  124. package/dist/lib/toolbar/modules/font-size.js +23 -0
  125. package/dist/lib/toolbar/modules/heading.js +23 -0
  126. package/dist/lib/toolbar/modules/history.js +38 -0
  127. package/dist/lib/toolbar/modules/image.js +19 -0
  128. package/dist/lib/toolbar/modules/inline-code.js +19 -0
  129. package/dist/lib/toolbar/modules/italic.js +20 -0
  130. package/dist/lib/toolbar/modules/line-height.js +19 -0
  131. package/dist/lib/toolbar/modules/link.js +97 -0
  132. package/dist/lib/toolbar/modules/order-list.js +21 -0
  133. package/dist/lib/toolbar/modules/quote.js +19 -0
  134. package/dist/lib/toolbar/modules/strike.js +19 -0
  135. package/dist/lib/toolbar/modules/underline.js +19 -0
  136. package/dist/lib/{marks-a30b8a0f.js → toolbar/utils/marks.js} +1 -4
  137. package/dist/styles/index.css +1 -0
  138. package/package.json +6 -6
  139. package/dist/es/image/index.js +0 -245
  140. package/dist/es/index-1e46887d.js +0 -205
  141. package/dist/es/index-ddc2e5ac.js +0 -493
  142. package/dist/es/is-7f3ae820.js +0 -12
  143. package/dist/es/mention/index.js +0 -13
  144. package/dist/es/toolbar/index.js +0 -34
  145. package/dist/es/toolbar/types/index.js +0 -7
  146. package/dist/lib/index-f50053bf.js +0 -506
  147. package/dist/lib/index-ffc4bb34.js +0 -212
  148. /package/dist/es/align/types/{index.js → align/types/index.js} +0 -0
  149. /package/dist/es/background/types/{index.js → background/types/index.js} +0 -0
  150. /package/dist/es/bold/types/{index.js → bold/types/index.js} +0 -0
  151. /package/dist/es/bullet-list/types/{index.js → bullet-list/types/index.js} +0 -0
  152. /package/dist/es/divider/types/{index.js → divider/types/index.js} +0 -0
  153. /package/dist/es/emoji/types/{index.js → emoji/types/index.js} +0 -0
  154. /package/dist/es/font-color/types/{index.js → font-color/types/index.js} +0 -0
  155. /package/dist/es/font-size/types/{index.js → font-size/types/index.js} +0 -0
  156. /package/dist/es/heading/types/{index.js → heading/types/index.js} +0 -0
  157. /package/dist/es/image/types/{index.js → image/types/index.js} +0 -0
  158. /package/dist/es/indent/types/{index.js → indent/types/index.js} +0 -0
  159. /package/dist/es/inline-code/types/{index.js → inline-code/types/index.js} +0 -0
  160. /package/dist/es/italic/types/{index.js → italic/types/index.js} +0 -0
  161. /package/dist/es/line-height/types/{index.js → line-height/types/index.js} +0 -0
  162. /package/dist/es/link/types/{index.js → link/types/index.js} +0 -0
  163. /package/dist/es/mention/types/{index.js → mention/types/index.js} +0 -0
  164. /package/dist/es/order-list/types/{index.js → order-list/types/index.js} +0 -0
  165. /package/dist/es/quote/types/{index.js → quote/types/index.js} +0 -0
  166. /package/dist/es/shortcut/types/{index.js → shortcut/types/index.js} +0 -0
  167. /package/dist/es/strike/types/{index.js → strike/types/index.js} +0 -0
  168. /package/dist/es/underline/types/{index.js → underline/types/index.js} +0 -0
  169. /package/dist/lib/{tslib.es6-d44c9a95.js → tslib.es6-82029525.js} +0 -0
@@ -1,9 +1,8 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import { Range, EDITOR_EVENT } from '@block-kit/core';
2
+ import { Range } from '@block-kit/core';
3
3
  import { ReadonlyContext } from '@block-kit/react';
4
- import { getId, cs, Bind } from '@block-kit/utils';
4
+ import { getId, cs } from '@block-kit/utils';
5
5
  import React from 'react';
6
- import { _ as __decorate } from './tslib.es6-83956cc1.js';
7
6
 
8
7
  class SelectionHOC extends React.PureComponent {
9
8
  constructor(props) {
@@ -51,31 +50,4 @@ class SelectionHOC extends React.PureComponent {
51
50
  }
52
51
  SelectionHOC.contextType = ReadonlyContext;
53
52
 
54
- class SelectionPlugin {
55
- constructor(editor) {
56
- this.editor = editor;
57
- this.idToView = new Map();
58
- editor.event.on(EDITOR_EVENT.SELECTION_CHANGE, this.onSelectionChange);
59
- }
60
- destroy() {
61
- this.idToView.clear();
62
- this.editor.event.off(EDITOR_EVENT.SELECTION_CHANGE, this.onSelectionChange);
63
- }
64
- mountView(id, view) {
65
- this.idToView.set(id, view);
66
- }
67
- unmountView(id) {
68
- this.idToView.delete(id);
69
- }
70
- onSelectionChange(e) {
71
- const current = e.current;
72
- this.idToView.forEach(view => {
73
- view.onSelectionChange(current);
74
- });
75
- }
76
- }
77
- __decorate([
78
- Bind
79
- ], SelectionPlugin.prototype, "onSelectionChange", null);
80
-
81
- export { SelectionHOC as S, SelectionPlugin as a };
53
+ export { SelectionHOC };
@@ -0,0 +1,5 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+
3
+ const DividerIcon = () => (jsx("svg", { className: "arco-icon", viewBox: "0 0 1024 1024", xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "currentColor", children: jsx("path", { d: "M64.128 810.666667h128a21.333333 21.333333 0 0 1 21.333333 21.333333v42.666667a21.333333 21.333333 0 0 1-21.333333 21.333333h-128a21.333333 21.333333 0 0 1-21.333333-21.333333v-42.666667a21.333333 21.333333 0 0 1 21.333333-21.333333z m384 0h128a21.333333 21.333333 0 0 1 21.333333 21.333333v42.666667a21.333333 21.333333 0 0 1-21.333333 21.333333h-128a21.333333 21.333333 0 0 1-21.333333-21.333333v-42.666667a21.333333 21.333333 0 0 1 21.333333-21.333333z m384 0h128a21.333333 21.333333 0 0 1 21.333333 21.333333v42.666667a21.333333 21.333333 0 0 1-21.333333 21.333333h-128a21.333333 21.333333 0 0 1-21.333333-21.333333v-42.666667a21.333333 21.333333 0 0 1 21.333333-21.333333z m-768-682.666667h128a21.333333 21.333333 0 0 1 21.333333 21.333333v42.666667a21.333333 21.333333 0 0 1-21.333333 21.333333h-128a21.333333 21.333333 0 0 1-21.333333-21.333333V149.333333a21.333333 21.333333 0 0 1 21.333333-21.333333z m384 0h128a21.333333 21.333333 0 0 1 21.333333 21.333333v42.666667a21.333333 21.333333 0 0 1-21.333333 21.333333h-128a21.333333 21.333333 0 0 1-21.333333-21.333333V149.333333a21.333333 21.333333 0 0 1 21.333333-21.333333z m384 0h128a21.333333 21.333333 0 0 1 21.333333 21.333333v42.666667a21.333333 21.333333 0 0 1-21.333333 21.333333h-128a21.333333 21.333333 0 0 1-21.333333-21.333333V149.333333a21.333333 21.333333 0 0 1 21.333333-21.333333zM64 469.333333h896a21.333333 21.333333 0 0 1 21.333333 21.333334v42.666666a21.333333 21.333333 0 0 1-21.333333 21.333334H64a21.333333 21.333333 0 0 1-21.333333-21.333334v-42.666666a21.333333 21.333333 0 0 1 21.333333-21.333334z" }) }));
4
+
5
+ export { DividerIcon };
@@ -0,0 +1,5 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+
3
+ const EmojiIcon = () => (jsxs("svg", { className: "arco-icon", viewBox: "0 0 1024 1024", version: "1.1", xmlns: "http://www.w3.org/2000/svg", "p-id": "5996", width: "1em", height: "1em", fill: "currentColor", children: [jsx("path", { d: "M512 128a384 384 0 1 0 0 768 384 384 0 0 0 0-768zM42.666667 512C42.666667 252.8 252.8 42.666667 512 42.666667s469.333333 210.133333 469.333333 469.333333-210.133333 469.333333-469.333333 469.333333S42.666667 771.2 42.666667 512z m533.333333-64a42.666667 42.666667 0 0 1 42.666667-42.666667h85.333333a42.666667 42.666667 0 1 1 0 85.333334h-85.333333a42.666667 42.666667 0 0 1-42.666667-42.666667z m-254.165333 193.834667a42.666667 42.666667 0 0 1 60.330666 0 183.594667 183.594667 0 0 0 259.669334 0 42.666667 42.666667 0 0 1 60.330666 60.330666 268.928 268.928 0 0 1-380.330666 0 42.666667 42.666667 0 0 1 0-60.330666z" }), jsx("path", { d: "M362.666667 362.666667a42.666667 42.666667 0 0 1 42.666666 42.666666v80a42.666667 42.666667 0 0 1-85.333333 0V405.333333a42.666667 42.666667 0 0 1 42.666667-42.666666z" })] }));
4
+
5
+ export { EmojiIcon };
@@ -0,0 +1,5 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+
3
+ const FontColorIcon = () => (jsx("svg", { className: "arco-icon", viewBox: "0 0 1024 1024", version: "1.1", xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "currentColor", children: jsx("path", { d: "M594.9 842.3h-94.3l-67.4-180.9H158L94.4 842.3H0.1l251.7-660.9h91.3l251.8 660.9zM406.7 586.7l-99.8-274.8c-3.1-8.8-6.5-24.2-10.2-46.1h-2.1c-3.1 19.9-6.7 35.3-10.7 46.1l-99 274.8h221.8z m284.2-183.4c46.9-29.3 101.1-43.9 162.6-43.9 113.8 0 170.7 59.7 170.7 179.2v303.8h-82.8v-73h-2.1c-32.7 56-80.9 84.1-144.6 84.1-45.8 0-82.2-12.4-109.2-37.1-27-24.7-40.5-58.2-40.5-100.3 0-88.2 52.2-139.5 156.6-154l139.9-19.6c0-77.1-31.9-115.6-95.6-115.6-56.6 0-108.2 19.1-154.9 57.2v-80.8z m139.9 217.1c-38.7 5.1-65.4 14.8-80 29-14.7 14.2-22 34.1-22 59.7 0 22.5 8 40.8 23.9 55 15.9 14.2 37 21.3 63.1 21.3 36.4 0 66.4-12.8 90-38.4 23.6-25.6 35.4-57.7 35.4-96.4v-45.2l-110.4 15z" }) }));
4
+
5
+ export { FontColorIcon };
@@ -0,0 +1,5 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+
3
+ const FontSizeIcon = () => (jsxs("svg", { className: "arco-icon", viewBox: "0 0 1024 1024", version: "1.1", xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "currentColor", children: [jsx("path", { d: "M597.333333 853.333333h85.333334L426.666667 170.666667H341.333333L85.333333 853.333333h85.333334l80-213.333333h266.666666z m-314.666666-298.666666L384 284.458667 485.333333 554.666667z" }), jsx("path", { d: "M918.784 331.178667V257.450667L832 170.666667l-86.784 86.784v73.728L810.666667 265.685333v492.629334l-65.450667-65.493334v73.728L832 853.333333l86.784-86.784v-73.728L853.333333 758.314667V265.685333l65.450667 65.493334z" })] }));
4
+
5
+ export { FontSizeIcon };
@@ -0,0 +1,5 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+
3
+ const JustifyIcon = () => (jsx("svg", { className: "arco-icon", viewBox: "0 0 1024 1024", version: "1.1", xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "currentColor", children: jsx("path", { d: "M875.975111 823.978667a36.010667 36.010667 0 1 1 0 72.021333H148.024889a36.010667 36.010667 0 1 1 0-72.021333h727.950222z m0-231.992889a36.010667 36.010667 0 1 1 0 72.021333H148.024889a36.010667 36.010667 0 1 1 0-72.021333h727.950222z m0-231.992889a36.010667 36.010667 0 1 1 0 72.021333H148.024889a36.010667 36.010667 0 0 1 0-72.021333h727.950222z m0-231.992889a36.010667 36.010667 0 1 1 0 72.021333H148.024889a36.010667 36.010667 0 0 1 0-72.021333h727.950222z", fill: "currentColor" }) }));
4
+
5
+ export { JustifyIcon };
@@ -0,0 +1,5 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+
3
+ const LineHeightIcon = () => (jsx("svg", { className: "arco-icon", viewBox: "0 0 1024 1024", version: "1.1", xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "currentColor", children: jsx("path", { d: "M469.333333 170.666667h426.666667v85.333333H469.333333V170.666667zM256 298.666667v170.666666H170.666667V298.666667H42.666667l170.666666-170.666667 170.666667 170.666667H256z m0 426.666666h128l-170.666667 170.666667-170.666666-170.666667h128v-170.666666h85.333333v170.666666z m213.333333 42.666667h426.666667v85.333333H469.333333v-85.333333z m-85.333333-298.666667h512v85.333334H384v-85.333334z" }) }));
4
+
5
+ export { LineHeightIcon };
@@ -0,0 +1,5 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+
3
+ const TextIcon = () => (jsx("svg", { className: "arco-icon", viewBox: "0 0 1024 1024", version: "1.1", xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "currentColor", children: jsx("path", { d: "M853.333333 138.666667H170.666667c-17.066667 0-32 14.933333-32 32v128c0 17.066667 14.933333 32 32 32s32-14.933333 32-32V202.666667h277.333333v618.666666H384c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h256c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32h-96v-618.666666h277.333333V298.666667c0 17.066667 14.933333 32 32 32s32-14.933333 32-32V170.666667c0-17.066667-14.933333-32-32-32z" }) }));
4
+
5
+ export { TextIcon };
@@ -0,0 +1,32 @@
1
+ import { __decorate } from '../../../../node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs.js';
2
+ import { EDITOR_EVENT } from '@block-kit/core';
3
+ import { Bind } from '@block-kit/utils';
4
+
5
+ class SelectionPlugin {
6
+ constructor(editor) {
7
+ this.editor = editor;
8
+ this.idToView = new Map();
9
+ editor.event.on(EDITOR_EVENT.SELECTION_CHANGE, this.onSelectionChange);
10
+ }
11
+ destroy() {
12
+ this.idToView.clear();
13
+ this.editor.event.off(EDITOR_EVENT.SELECTION_CHANGE, this.onSelectionChange);
14
+ }
15
+ mountView(id, view) {
16
+ this.idToView.set(id, view);
17
+ }
18
+ unmountView(id) {
19
+ this.idToView.delete(id);
20
+ }
21
+ onSelectionChange(e) {
22
+ const current = e.current;
23
+ this.idToView.forEach(view => {
24
+ view.onSelectionChange(current);
25
+ });
26
+ }
27
+ }
28
+ __decorate([
29
+ Bind
30
+ ], SelectionPlugin.prototype, "onSelectionChange", null);
31
+
32
+ export { SelectionPlugin };
@@ -42,4 +42,4 @@ const scrollIfNeeded = (container, child, buffer = 0) => {
42
42
  }
43
43
  };
44
44
 
45
- export { setMountDOM as a, getMountDOM as g, preventContextEvent as p, scrollIfNeeded as s };
45
+ export { getMountDOM, preventContextEvent, scrollIfNeeded, setMountDOM };
@@ -0,0 +1,5 @@
1
+ const PLUGIN_EVENTS = {
2
+ SHORTCUT_MARKS_CHANGE: "SHORTCUT_MARKS_CHANGE",
3
+ };
4
+
5
+ export { PLUGIN_EVENTS };
@@ -12,4 +12,4 @@ const isKeyCode = (event, code) => {
12
12
  return event.keyCode === code;
13
13
  };
14
14
 
15
- export { isKeyCode as a, isEmptyLine as i };
15
+ export { isEmptyLine, isKeyCode };
@@ -0,0 +1,23 @@
1
+ import { CTRL_KEY, KEY_CODE, NIL, TRULY } from '@block-kit/utils';
2
+ import { BOLD_KEY } from '../../../../bold/types/bold/types/index.js';
3
+ import { ITALIC_KEY } from '../../../../italic/types/italic/types/index.js';
4
+ import { isKeyCode } from '../../../../shared/utils/shared/utils/is.js';
5
+
6
+ const PRESET_SHORTCUT = {
7
+ [BOLD_KEY]: (event, payload) => {
8
+ if (event[CTRL_KEY] && isKeyCode(event, KEY_CODE.B) && payload.sel) {
9
+ const { editor, keys, sel } = payload;
10
+ editor.perform.applyMarks(sel, { [BOLD_KEY]: keys[BOLD_KEY] ? NIL : TRULY });
11
+ return true;
12
+ }
13
+ },
14
+ [ITALIC_KEY]: (event, payload) => {
15
+ if (event[CTRL_KEY] && isKeyCode(event, KEY_CODE.I) && payload.sel) {
16
+ const { editor, keys, sel } = payload;
17
+ editor.perform.applyMarks(sel, { [ITALIC_KEY]: keys[ITALIC_KEY] ? NIL : TRULY });
18
+ return true;
19
+ }
20
+ },
21
+ };
22
+
23
+ export { PRESET_SHORTCUT };
@@ -1,29 +1,10 @@
1
- import { _ as __decorate } from '../tslib.es6-83956cc1.js';
1
+ import { __decorate } from '../../node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs.js';
2
2
  import { CorePlugin, EDITOR_EVENT } from '@block-kit/core';
3
- import { CTRL_KEY, KEY_CODE, NIL, TRULY, Bind } from '@block-kit/utils';
4
- import { f as filterLineMarkMap, a as filterMarkMap, P as PLUGIN_EVENTS } from '../marks-ac0ec630.js';
5
- import { BOLD_KEY } from '../bold/types/index.js';
6
- import { ITALIC_KEY } from '../italic/types/index.js';
7
- import { a as isKeyCode } from '../is-3de778e2.js';
8
- import { SHORTCUT_KEY } from './types/index.js';
9
- import '@block-kit/delta';
10
-
11
- const PRESET_SHORTCUT = {
12
- [BOLD_KEY]: (event, payload) => {
13
- if (event[CTRL_KEY] && isKeyCode(event, KEY_CODE.B) && payload.sel) {
14
- const { editor, keys, sel } = payload;
15
- editor.perform.applyMarks(sel, { [BOLD_KEY]: keys[BOLD_KEY] ? NIL : TRULY });
16
- return true;
17
- }
18
- },
19
- [ITALIC_KEY]: (event, payload) => {
20
- if (event[CTRL_KEY] && isKeyCode(event, KEY_CODE.I) && payload.sel) {
21
- const { editor, keys, sel } = payload;
22
- editor.perform.applyMarks(sel, { [ITALIC_KEY]: keys[ITALIC_KEY] ? NIL : TRULY });
23
- return true;
24
- }
25
- },
26
- };
3
+ import { Bind } from '@block-kit/utils';
4
+ import { PLUGIN_EVENTS } from '../../shared/utils/shared/utils/event.js';
5
+ import { filterLineMarkMap, filterMarkMap } from '../../toolbar/utils/toolbar/utils/marks.js';
6
+ import { PRESET_SHORTCUT } from '../modules/shortcut/modules/preset.js';
7
+ import { SHORTCUT_KEY } from '../types/shortcut/types/index.js';
27
8
 
28
9
  class Shortcut extends CorePlugin {
29
10
  constructor(editor, config) {
@@ -1,7 +1,7 @@
1
1
  import { isMatchHTMLTag, applyMarker } from '@block-kit/core';
2
2
  import { EditorPlugin } from '@block-kit/react';
3
3
  import { isHTMLElement, TRULY } from '@block-kit/utils';
4
- import { STRIKE_KEY } from './types/index.js';
4
+ import { STRIKE_KEY } from '../types/strike/types/index.js';
5
5
 
6
6
  class StrikePlugin extends EditorPlugin {
7
7
  destroy() { }
@@ -0,0 +1,69 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { EDITOR_EVENT } from '@block-kit/core';
3
+ import { useEditorStatic } from '@block-kit/react';
4
+ import { cs } from '@block-kit/utils';
5
+ import { useMemoFn } from '@block-kit/utils/dist/es/hooks';
6
+ import { forwardRef, useState, useEffect } from 'react';
7
+ import { PLUGIN_EVENTS } from '../../../../shared/utils/shared/utils/event.js';
8
+ import { filterLineMarkMap, filterMarkMap } from '../../../utils/toolbar/utils/marks.js';
9
+ import { ToolbarContext } from './provider.js';
10
+
11
+ const Toolbar = forwardRef((props, ref) => {
12
+ const { editor } = useEditorStatic();
13
+ const [keys, setKeys] = useState({});
14
+ const refreshMarks = useMemoFn(() => {
15
+ const current = editor.selection.get();
16
+ if (!current) {
17
+ setKeys({});
18
+ return void 0;
19
+ }
20
+ const lines = editor.state.block.getLines();
21
+ const { start, end } = current;
22
+ const lineMarkMap = filterLineMarkMap(lines.slice(start.line, end.line + 1).map(line => line.attributes));
23
+ if (current.isCollapsed) {
24
+ setKeys(Object.assign(Object.assign({}, editor.collect.marks), lineMarkMap));
25
+ return void 0;
26
+ }
27
+ const ops = [];
28
+ if (current.isCollapsed) {
29
+ const op = editor.collect.getOpAtPoint(current.start);
30
+ op && ops.push(op);
31
+ }
32
+ else {
33
+ const fragment = editor.collect.getFragment();
34
+ fragment && ops.push(...fragment);
35
+ }
36
+ const markMap = filterMarkMap(ops);
37
+ setKeys(Object.assign(Object.assign({}, markMap), lineMarkMap));
38
+ });
39
+ useEffect(() => {
40
+ editor.event.on(EDITOR_EVENT.SELECTION_CHANGE, refreshMarks);
41
+ editor.event.on(PLUGIN_EVENTS.SHORTCUT_MARKS_CHANGE, refreshMarks);
42
+ return () => {
43
+ editor.event.off(EDITOR_EVENT.SELECTION_CHANGE, refreshMarks);
44
+ editor.event.off(PLUGIN_EVENTS.SHORTCUT_MARKS_CHANGE, refreshMarks);
45
+ };
46
+ }, [editor.event, refreshMarks]);
47
+ // 浮动工具栏的情况下, 挂载时需要刷新 marks
48
+ useEffect(() => {
49
+ refreshMarks();
50
+ }, [refreshMarks]);
51
+ return (jsx("div", { ref: ref, style: props.styles, className: cs("block-kit-menu-toolbar", props.className), onMouseDown: e => {
52
+ const target = e.target;
53
+ // 避免 float 的情况下触发按下事件
54
+ e.stopPropagation();
55
+ // 存在需要抢夺焦点的情况, 例如超链接输入的弹出层
56
+ if (target instanceof HTMLElement && target.hasAttribute("data-no-prevent")) {
57
+ return void 0;
58
+ }
59
+ e.preventDefault();
60
+ }, children: jsx(ToolbarContext.Provider, { value: {
61
+ keys,
62
+ editor,
63
+ setKeys,
64
+ refreshMarks,
65
+ selection: editor.selection.get(),
66
+ }, children: props.children }) }));
67
+ });
68
+
69
+ export { Toolbar };
@@ -0,0 +1,67 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { EDITOR_EVENT } from '@block-kit/core';
3
+ import { useEditorStatic, useReadonly } from '@block-kit/react';
4
+ import { cs } from '@block-kit/utils';
5
+ import { useMemoFn } from '@block-kit/utils/dist/es/hooks';
6
+ import { useRef, useState, useEffect, useMemo } from 'react';
7
+ import ReactDOM from 'react-dom';
8
+ import { getMountDOM } from '../../../../shared/utils/shared/utils/dom.js';
9
+ import { Toolbar } from './basic.js';
10
+
11
+ const FloatToolbar = props => {
12
+ const { editor } = useEditorStatic();
13
+ const { readonly } = useReadonly();
14
+ const ref = useRef(null);
15
+ const [visible, setVisible] = useState(false);
16
+ const [isMouseDown, setIsMouseDown] = useState(false);
17
+ const onWeakUp = useMemoFn((wakeUp) => {
18
+ if (editor.state.isFocused() && wakeUp) {
19
+ setVisible(true);
20
+ }
21
+ else {
22
+ setVisible(false);
23
+ }
24
+ });
25
+ useEffect(() => {
26
+ if (readonly)
27
+ return void 0;
28
+ const onMouseUp = () => {
29
+ setIsMouseDown(false);
30
+ };
31
+ const onMouseDown = () => {
32
+ setIsMouseDown(true);
33
+ };
34
+ const onSelectionChange = (e) => {
35
+ const { current } = e;
36
+ const isWakeUp = current ? !current.isCollapsed : false;
37
+ onWeakUp(isWakeUp);
38
+ };
39
+ document.addEventListener(EDITOR_EVENT.MOUSE_UP, onMouseUp);
40
+ document.addEventListener(EDITOR_EVENT.MOUSE_DOWN, onMouseDown);
41
+ editor.event.on(EDITOR_EVENT.SELECTION_CHANGE, onSelectionChange);
42
+ return () => {
43
+ document.removeEventListener(EDITOR_EVENT.MOUSE_UP, onMouseUp);
44
+ document.removeEventListener(EDITOR_EVENT.MOUSE_DOWN, onMouseDown);
45
+ editor.event.off(EDITOR_EVENT.SELECTION_CHANGE, onSelectionChange);
46
+ };
47
+ }, [editor, onWeakUp, readonly]);
48
+ const { left, top } = useMemo(() => {
49
+ if (!readonly && visible && !isMouseDown) {
50
+ const rect = editor.rect.getSelectionRect();
51
+ if (rect) {
52
+ const topOffset = props.offsetTop || 0;
53
+ const leftOffset = props.offsetLeft || 0;
54
+ const t = rect.top + topOffset;
55
+ const l = rect.left + rect.width / 2 + leftOffset;
56
+ return { top: t, left: l };
57
+ }
58
+ }
59
+ return { top: -999999, left: -999999 };
60
+ }, [editor.rect, readonly, visible, isMouseDown, props.offsetLeft, props.offsetTop]);
61
+ // 只读状态 / 不可见 / 鼠标按下 时隐藏
62
+ return readonly || !visible || isMouseDown
63
+ ? null
64
+ : ReactDOM.createPortal(jsx(Toolbar, { ref: ref, className: cs("block-kit-float-toolbar", props.className), styles: { top: top, left: left }, children: props.children }), getMountDOM(editor));
65
+ };
66
+
67
+ export { FloatToolbar };
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+
3
+ const ToolbarContext = React.createContext({
4
+ keys: {},
5
+ setKeys: () => null,
6
+ refreshMarks: () => null,
7
+ editor: null,
8
+ selection: null,
9
+ });
10
+ const useToolbarContext = () => React.useContext(ToolbarContext);
11
+
12
+ export { ToolbarContext, useToolbarContext };
@@ -0,0 +1,20 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { Trigger } from '@arco-design/web-react';
3
+ import { IconAlignLeft, IconAlignCenter, IconAlignRight, IconDown } from '@arco-design/web-react/icon';
4
+ import { NIL } from '@block-kit/utils';
5
+ import { ALIGN_KEY } from '../../../../align/types/align/types/index.js';
6
+ import { JustifyIcon } from '../../../../shared/icons/shared/icons/justify.js';
7
+ import { useToolbarContext } from '../../../context/toolbar/context/provider.js';
8
+
9
+ const MAP = {
10
+ left: jsx(IconAlignLeft, {}),
11
+ center: jsx(IconAlignCenter, {}),
12
+ right: jsx(IconAlignRight, {}),
13
+ justify: jsx(JustifyIcon, {}),
14
+ };
15
+ const Align = () => {
16
+ const { keys, refreshMarks, editor } = useToolbarContext();
17
+ return (jsx(Trigger, { trigger: "click", popupAlign: { bottom: 10 }, getPopupContainer: e => e.parentElement || document.body, popup: () => (jsxs("div", { className: "block-kit-toolbar-dropdown", onClick: refreshMarks, children: [jsx("div", { className: "kit-toolbar-node", onClick: () => editor.command.exec(ALIGN_KEY, { value: NIL }), children: jsx(IconAlignLeft, {}) }), jsx("div", { className: "kit-toolbar-node", onClick: () => editor.command.exec(ALIGN_KEY, { value: "center" }), children: jsx(IconAlignCenter, {}) }), jsx("div", { className: "kit-toolbar-node", onClick: () => editor.command.exec(ALIGN_KEY, { value: "right" }), children: jsx(IconAlignRight, {}) }), jsx("div", { className: "kit-toolbar-node", onClick: () => editor.command.exec(ALIGN_KEY, { value: "justify" }), children: jsx(JustifyIcon, {}) })] })), children: jsxs("div", { className: "menu-toolbar-item", children: [MAP[keys[ALIGN_KEY]] || jsx(IconAlignLeft, {}), jsx(IconDown, { className: "menu-toolbar-icon-down" })] }) }));
18
+ };
19
+
20
+ export { Align };
@@ -0,0 +1,16 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { IconBold } from '@arco-design/web-react/icon';
3
+ import { cs, NIL, TRULY } from '@block-kit/utils';
4
+ import { BOLD_KEY } from '../../../../bold/types/bold/types/index.js';
5
+ import { useToolbarContext } from '../../../context/toolbar/context/provider.js';
6
+
7
+ const Bold = () => {
8
+ const { keys, refreshMarks, editor } = useToolbarContext();
9
+ const onExec = () => {
10
+ editor.command.exec(BOLD_KEY, { value: keys[BOLD_KEY] ? NIL : TRULY });
11
+ refreshMarks();
12
+ };
13
+ return (jsx("div", { className: cs("menu-toolbar-item", keys[BOLD_KEY] && "active"), onClick: onExec, children: jsx(IconBold, {}) }));
14
+ };
15
+
16
+ export { Bold };
@@ -0,0 +1,17 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { IconUnorderedList } from '@arco-design/web-react/icon';
3
+ import { cs, TRULY } from '@block-kit/utils';
4
+ import { BULLET_LIST_KEY } from '../../../../bullet-list/types/bullet-list/types/index.js';
5
+ import { isBulletList } from '../../../../bullet-list/utils/bullet-list/utils/is.js';
6
+ import { useToolbarContext } from '../../../context/toolbar/context/provider.js';
7
+
8
+ const BulletList = () => {
9
+ const { keys, refreshMarks, editor } = useToolbarContext();
10
+ const isBullet = isBulletList(keys);
11
+ return (jsx("div", { className: cs("menu-toolbar-item", isBullet && "active"), onClick: () => {
12
+ editor.command.exec(BULLET_LIST_KEY, { value: TRULY });
13
+ refreshMarks();
14
+ }, children: jsx(IconUnorderedList, {}) }));
15
+ };
16
+
17
+ export { BulletList };
@@ -0,0 +1,7 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+
3
+ const Cut = () => {
4
+ return jsx("div", { className: "menu-toolbar-cut" });
5
+ };
6
+
7
+ export { Cut };
@@ -0,0 +1,15 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { cs, TRULY } from '@block-kit/utils';
3
+ import { DIVIDER_KEY } from '../../../../divider/types/divider/types/index.js';
4
+ import { DividerIcon } from '../../../../shared/icons/shared/icons/divider.js';
5
+ import { useToolbarContext } from '../../../context/toolbar/context/provider.js';
6
+
7
+ const Divider = () => {
8
+ const { refreshMarks, editor } = useToolbarContext();
9
+ return (jsx("div", { className: cs("menu-toolbar-item"), onClick: () => {
10
+ editor.command.exec(DIVIDER_KEY, { value: TRULY });
11
+ refreshMarks();
12
+ }, children: jsx(DividerIcon, {}) }));
13
+ };
14
+
15
+ export { Divider };
@@ -0,0 +1,25 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { Trigger } from '@arco-design/web-react';
3
+ import Picker from '@emoji-mart/react';
4
+ import { cs } from '@block-kit/utils';
5
+ import { EMOJI_KEY } from '../../../../emoji/types/emoji/types/index.js';
6
+ import { EmojiIcon } from '../../../../shared/icons/shared/icons/emoji.js';
7
+ import { useToolbarContext } from '../../../context/toolbar/context/provider.js';
8
+
9
+ const Emoji = () => {
10
+ const { editor } = useToolbarContext();
11
+ return (jsx(Trigger, { className: "menu-toolbar-emoji-trigger", popupAlign: { bottom: 10 }, getPopupContainer: e => e.parentElement || document.body, popup: () => (jsx(Picker, { theme: document.body.getAttribute("arco-theme") === "dark" ? "dark" : "light", searchPosition: "none", previewPosition: "none", categories: [
12
+ "frequent",
13
+ "people",
14
+ "nature",
15
+ "foods",
16
+ "activity",
17
+ "places",
18
+ "objects",
19
+ "symbols",
20
+ ], onEmojiSelect: (emoji) => {
21
+ editor.command.exec(EMOJI_KEY, { value: emoji.id });
22
+ }, maxFrequentRows: 2 })), trigger: "click", children: jsx("div", { className: cs("menu-toolbar-item"), children: jsx(EmojiIcon, {}) }) }));
23
+ };
24
+
25
+ export { Emoji };
@@ -0,0 +1,49 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { Trigger } from '@arco-design/web-react';
3
+ import { IconDown } from '@arco-design/web-react/icon';
4
+ import { cs } from '@block-kit/utils';
5
+ import { BACKGROUND_KEY } from '../../../../background/types/background/types/index.js';
6
+ import { FONT_COLOR_KEY } from '../../../../font-color/types/font-color/types/index.js';
7
+ import { FontColorIcon } from '../../../../shared/icons/shared/icons/font-color.js';
8
+ import { useToolbarContext } from '../../../context/toolbar/context/provider.js';
9
+
10
+ const COLOR = [
11
+ "",
12
+ "rgb(143, 149, 158)",
13
+ "rgb(216, 57, 49)",
14
+ "rgb(222, 120, 2)",
15
+ "rgb(220, 155, 4)",
16
+ "rgb(46, 161, 33)",
17
+ "rgb(36, 91, 219)",
18
+ "rgb(100, 37, 208)",
19
+ ];
20
+ const BACKGROUND = [
21
+ "",
22
+ "rgb(242, 243, 245)",
23
+ "rgb(251, 191, 188)",
24
+ "rgba(254, 212, 164, 0.8)",
25
+ "rgba(255, 246, 122, 0.8)",
26
+ "rgba(183, 237, 177, 0.8)",
27
+ "rgba(186, 206, 253, 0.7)",
28
+ "rgba(205, 178, 250, 0.7)",
29
+ "rgba(222, 224, 227, 0.8)",
30
+ "rgb(187, 191, 196)",
31
+ "rgb(247, 105, 100)",
32
+ "rgb(255, 165, 61)",
33
+ "rgb(255, 233, 40)",
34
+ "rgb(98, 210, 86)",
35
+ "rgba(78, 131, 253, 0.55)",
36
+ "rgba(147, 90, 246, 0.55)",
37
+ ];
38
+ const FontColor = () => {
39
+ const { keys, refreshMarks, editor } = useToolbarContext();
40
+ return (jsx(Trigger, { trigger: "click", popupAlign: { bottom: 10 }, getPopupContainer: e => e.parentElement || document.body, popup: () => (jsxs("div", { className: "block-kit-toolbar-dropdown block-kit-color-picker", onClick: refreshMarks, children: [jsx("div", { className: "kit-color-picker-label", children: "\u5B57\u4F53\u989C\u8272" }), jsx("div", { className: "kit-picker-group", children: COLOR.map(it => (jsx("div", { className: cs("kit-picker-item-wrapper", keys[FONT_COLOR_KEY] === it && "active", !keys[FONT_COLOR_KEY] && !it && "active"), style: { color: it ? it : void 0 }, onClick: () => {
41
+ editor.command.exec(FONT_COLOR_KEY, { value: it });
42
+ refreshMarks();
43
+ }, children: jsx("div", { className: "kit-picker-item", children: jsx(FontColorIcon, {}) }) }, it))) }), jsx("div", { className: "kit-color-picker-label", children: "\u80CC\u666F\u989C\u8272" }), jsx("div", { className: "kit-picker-group kit-picker-background-case", children: BACKGROUND.map(it => (jsx("div", { className: cs("kit-picker-item-wrapper", keys[BACKGROUND_KEY] === it && "active", !keys[BACKGROUND_KEY] && !it && "active"), onClick: () => {
44
+ editor.command.exec(BACKGROUND_KEY, { value: it });
45
+ refreshMarks();
46
+ }, children: jsx("div", { style: { background: it ? it : void 0 }, className: cs("kit-picker-item", !it && "kit-picker-item-empty-background") }) }, it))) })] })), children: jsxs("div", { className: "menu-toolbar-item kit-color-case", children: [jsx("div", { className: "kit-color-block", style: { color: keys[FONT_COLOR_KEY], background: keys[BACKGROUND_KEY] }, children: jsx(FontColorIcon, {}) }), jsx(IconDown, { className: "menu-toolbar-icon-down" })] }) }));
47
+ };
48
+
49
+ export { FontColor };
@@ -0,0 +1,19 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { Trigger } from '@arco-design/web-react';
3
+ import { IconCheck, IconDown } from '@arco-design/web-react/icon';
4
+ import { NIL } from '@block-kit/utils';
5
+ import { useRef } from 'react';
6
+ import { FONT_SIZE_KEY } from '../../../../font-size/types/font-size/types/index.js';
7
+ import { FontSizeIcon } from '../../../../shared/icons/shared/icons/font-size.js';
8
+ import { useToolbarContext } from '../../../context/toolbar/context/provider.js';
9
+
10
+ const STEP = Array(10)
11
+ .fill(null)
12
+ .map((_, i) => String(i + 12));
13
+ const FontSize = () => {
14
+ const triggerRef = useRef(null);
15
+ const { keys, refreshMarks, editor } = useToolbarContext();
16
+ return (jsx(Trigger, { ref: triggerRef, popupAlign: { bottom: 10 }, trigger: "click", getPopupContainer: e => e.parentElement || document.body, popup: () => (jsxs("div", { className: "block-kit-toolbar-dropdown", onClick: refreshMarks, children: [jsxs("div", { className: "block-kit-toolbar-height-item kit-toolbar-node", onClick: () => editor.command.exec(FONT_SIZE_KEY, { value: NIL }), children: [!keys[FONT_SIZE_KEY] && jsx(IconCheck, {}), "\u9ED8\u8BA4"] }), STEP.map(item => (jsxs("div", { className: "block-kit-toolbar-height-item kit-toolbar-node", onClick: () => editor.command.exec(FONT_SIZE_KEY, { value: item }), children: [keys[FONT_SIZE_KEY] === item && jsx(IconCheck, {}), item, "px"] }, item)))] })), children: jsxs("div", { className: "menu-toolbar-item", children: [jsx(FontSizeIcon, {}), jsx(IconDown, { className: "menu-toolbar-icon-down" })] }) }));
17
+ };
18
+
19
+ export { FontSize };
@@ -0,0 +1,19 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { Trigger } from '@arco-design/web-react';
3
+ import { IconH1, IconH2, IconH3, IconDown } from '@arco-design/web-react/icon';
4
+ import { NIL } from '@block-kit/utils';
5
+ import { HEADING_KEY } from '../../../../heading/types/heading/types/index.js';
6
+ import { TextIcon } from '../../../../shared/icons/shared/icons/text.js';
7
+ import { useToolbarContext } from '../../../context/toolbar/context/provider.js';
8
+
9
+ const MAP = {
10
+ h1: jsx(IconH1, {}),
11
+ h2: jsx(IconH2, {}),
12
+ h3: jsx(IconH3, {}),
13
+ };
14
+ const Heading = () => {
15
+ const { keys, refreshMarks, editor: { command }, } = useToolbarContext();
16
+ return (jsx(Trigger, { trigger: "click", popupAlign: { bottom: 10 }, getPopupContainer: e => e.parentElement || document.body, popup: () => (jsxs("div", { className: "block-kit-toolbar-dropdown", onClick: refreshMarks, children: [jsx("div", { className: "kit-toolbar-node", onClick: () => command.exec(HEADING_KEY, { value: NIL }), children: jsx(TextIcon, {}) }), jsx("div", { className: "kit-toolbar-node", onClick: () => command.exec(HEADING_KEY, { value: "h1" }), children: jsx(IconH1, {}) }), jsx("div", { className: "kit-toolbar-node", onClick: () => command.exec(HEADING_KEY, { value: "h2" }), children: jsx(IconH2, {}) }), jsx("div", { className: "kit-toolbar-node", onClick: () => command.exec(HEADING_KEY, { value: "h3" }), children: jsx(IconH3, {}) })] })), children: jsxs("div", { className: "menu-toolbar-item", children: [MAP[keys[HEADING_KEY]] || jsx(TextIcon, {}), jsx(IconDown, { className: "menu-toolbar-icon-down" })] }) }));
17
+ };
18
+
19
+ export { Heading };
@@ -0,0 +1,34 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { IconUndo, IconRedo } from '@arco-design/web-react/icon';
3
+ import { EDITOR_EVENT } from '@block-kit/core';
4
+ import { cs } from '@block-kit/utils';
5
+ import { useMemoFn } from '@block-kit/utils/dist/es/hooks';
6
+ import { useState, useEffect, Fragment } from 'react';
7
+ import { useToolbarContext } from '../../../context/toolbar/context/provider.js';
8
+
9
+ const History = () => {
10
+ const { editor, refreshMarks } = useToolbarContext();
11
+ const [undoable, setUndoable] = useState(false);
12
+ const [redoable, setRedoable] = useState(false);
13
+ const refresh = useMemoFn(() => {
14
+ setUndoable(editor.history.isUndoAble());
15
+ setRedoable(editor.history.isRedoAble());
16
+ });
17
+ useEffect(() => {
18
+ editor.event.on(EDITOR_EVENT.CONTENT_CHANGE, refresh, 1000);
19
+ return () => {
20
+ editor.event.off(EDITOR_EVENT.CONTENT_CHANGE, refresh);
21
+ };
22
+ }, [editor, refresh]);
23
+ const undo = () => {
24
+ editor.history.undo();
25
+ refreshMarks();
26
+ };
27
+ const redo = () => {
28
+ editor.history.redo();
29
+ refreshMarks();
30
+ };
31
+ return (jsxs(Fragment, { children: [jsx("div", { className: cs("menu-toolbar-item", !undoable && "disable"), onClick: undo, children: jsx(IconUndo, {}) }), jsx("div", { className: cs("menu-toolbar-item", !redoable && "disable"), onClick: redo, children: jsx(IconRedo, {}) })] }));
32
+ };
33
+
34
+ export { History };
@@ -0,0 +1,15 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { IconImage } from '@arco-design/web-react/icon';
3
+ import { cs, TRULY } from '@block-kit/utils';
4
+ import { IMAGE_KEY } from '../../../../image/types/image/types/index.js';
5
+ import { useToolbarContext } from '../../../context/toolbar/context/provider.js';
6
+
7
+ const Image = () => {
8
+ const { refreshMarks, editor } = useToolbarContext();
9
+ return (jsx("div", { className: cs("menu-toolbar-item"), onClick: () => {
10
+ editor.command.exec(IMAGE_KEY, { value: TRULY });
11
+ refreshMarks();
12
+ }, children: jsx(IconImage, {}) }));
13
+ };
14
+
15
+ export { Image };