@antscorp/antsomi-ui 2.0.82 → 2.0.83-text-editor-beta.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 (213) hide show
  1. package/es/assets/css/main.scss +4 -2
  2. package/es/components/index.scss +1 -0
  3. package/es/components/molecules/AccountSelection/AccountListing.js +14 -3
  4. package/es/components/molecules/EmojiPopover/EmojiPopover.js +5 -1
  5. package/es/components/molecules/FontSizeInput/FontSizeInput.d.ts +3 -0
  6. package/es/components/molecules/FontSizeInput/FontSizeInput.js +77 -0
  7. package/es/components/molecules/FontSizeInput/constants.d.ts +2 -0
  8. package/es/components/molecules/FontSizeInput/constants.js +5 -0
  9. package/es/components/molecules/FontSizeInput/index.d.ts +2 -0
  10. package/es/components/molecules/FontSizeInput/index.js +1 -0
  11. package/es/components/molecules/FontSizeInput/types.d.ts +21 -0
  12. package/es/components/molecules/FontSizeInput/types.js +1 -0
  13. package/es/components/molecules/VirtualizedMenu/VirtualizedMenu.d.ts +1 -2
  14. package/es/components/molecules/VirtualizedMenu/__mocks__/index.js +2550 -938
  15. package/es/components/molecules/VirtualizedMenu/components/Item/Item.d.ts +4 -3
  16. package/es/components/molecules/VirtualizedMenu/components/Item/Item.js +24 -22
  17. package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.d.ts +1 -2
  18. package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.js +59 -31
  19. package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.optimized.d.ts +19 -0
  20. package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.optimized.js +233 -0
  21. package/es/components/molecules/VirtualizedMenu/components/MenuInline/index.d.ts +1 -1
  22. package/es/components/molecules/VirtualizedMenu/components/MenuInline/index.js +2 -1
  23. package/es/components/molecules/VirtualizedMenu/styled.d.ts +1 -1
  24. package/es/components/molecules/VirtualizedMenu/styled.js +11 -3
  25. package/es/components/molecules/VirtualizedMenu/types.d.ts +1 -8
  26. package/es/components/molecules/VirtualizedMenu/utils.d.ts +7 -5
  27. package/es/components/molecules/VirtualizedMenu/utils.js +12 -18
  28. package/es/components/molecules/index.d.ts +1 -0
  29. package/es/components/molecules/index.js +1 -0
  30. package/es/components/organism/ActivityTimeline/__mocks__/event_tracking.json +1290 -0
  31. package/es/components/organism/ActivityTimeline/__mocks__/timeline.json +3059 -0
  32. package/es/components/organism/TextEditor/TextEditor.d.ts +3 -0
  33. package/es/components/organism/TextEditor/TextEditor.js +239 -0
  34. package/es/components/organism/TextEditor/__mocks__/text-block.settings.json +320 -0
  35. package/es/components/organism/TextEditor/__mocks__/text-contennt.d.ts +1 -0
  36. package/es/components/organism/TextEditor/__mocks__/text-contennt.js +38 -0
  37. package/es/components/organism/TextEditor/constants.d.ts +135 -0
  38. package/es/components/organism/TextEditor/constants.js +280 -0
  39. package/es/components/organism/TextEditor/extensions/BackgroundColor.d.ts +25 -0
  40. package/es/components/organism/TextEditor/extensions/BackgroundColor.js +41 -0
  41. package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.d.ts +130 -0
  42. package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.js +247 -0
  43. package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.d.ts +15 -0
  44. package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.js +31 -0
  45. package/es/components/organism/TextEditor/extensions/BubbleMenu/index.d.ts +2 -0
  46. package/es/components/organism/TextEditor/extensions/BubbleMenu/index.js +2 -0
  47. package/es/components/organism/TextEditor/extensions/Color.d.ts +6 -0
  48. package/es/components/organism/TextEditor/extensions/Color.js +19 -0
  49. package/es/components/organism/TextEditor/extensions/Emoji.d.ts +57 -0
  50. package/es/components/organism/TextEditor/extensions/Emoji.js +184 -0
  51. package/es/components/organism/TextEditor/extensions/FontFamily.d.ts +6 -0
  52. package/es/components/organism/TextEditor/extensions/FontFamily.js +43 -0
  53. package/es/components/organism/TextEditor/extensions/FontSize.d.ts +32 -0
  54. package/es/components/organism/TextEditor/extensions/FontSize.js +47 -0
  55. package/es/components/organism/TextEditor/extensions/FontWeight.d.ts +23 -0
  56. package/es/components/organism/TextEditor/extensions/FontWeight.js +41 -0
  57. package/es/components/organism/TextEditor/extensions/Highlight.d.ts +1 -0
  58. package/es/components/organism/TextEditor/extensions/Highlight.js +14 -0
  59. package/es/components/organism/TextEditor/extensions/Indent.d.ts +28 -0
  60. package/es/components/organism/TextEditor/extensions/Indent.js +66 -0
  61. package/es/components/organism/TextEditor/extensions/LineHeight.d.ts +20 -0
  62. package/es/components/organism/TextEditor/extensions/LineHeight.js +36 -0
  63. package/es/components/organism/TextEditor/extensions/Link.d.ts +3 -0
  64. package/es/components/organism/TextEditor/extensions/Link.js +47 -0
  65. package/es/components/organism/TextEditor/extensions/ListItemMarker.d.ts +13 -0
  66. package/es/components/organism/TextEditor/extensions/ListItemMarker.js +174 -0
  67. package/es/components/organism/TextEditor/extensions/Selection.d.ts +6 -0
  68. package/es/components/organism/TextEditor/extensions/Selection.js +40 -0
  69. package/es/components/organism/TextEditor/extensions/SmartTag.d.ts +33 -0
  70. package/es/components/organism/TextEditor/extensions/SmartTag.js +162 -0
  71. package/es/components/organism/TextEditor/extensions/StyleMemory.d.ts +36 -0
  72. package/es/components/organism/TextEditor/extensions/StyleMemory.js +163 -0
  73. package/es/components/organism/TextEditor/extensions/TextTransform.d.ts +31 -0
  74. package/es/components/organism/TextEditor/extensions/TextTransform.js +35 -0
  75. package/es/components/organism/TextEditor/hooks/index.d.ts +6 -0
  76. package/es/components/organism/TextEditor/hooks/index.js +6 -0
  77. package/es/components/organism/TextEditor/hooks/useDocumentState.d.ts +18 -0
  78. package/es/components/organism/TextEditor/hooks/useDocumentState.js +42 -0
  79. package/es/components/organism/TextEditor/hooks/useLinkHandler.d.ts +27 -0
  80. package/es/components/organism/TextEditor/hooks/useLinkHandler.js +279 -0
  81. package/es/components/organism/TextEditor/hooks/useMarkTracking.d.ts +26 -0
  82. package/es/components/organism/TextEditor/hooks/useMarkTracking.js +68 -0
  83. package/es/components/organism/TextEditor/hooks/usePersistence.d.ts +31 -0
  84. package/es/components/organism/TextEditor/hooks/usePersistence.js +169 -0
  85. package/es/components/organism/TextEditor/hooks/useStyleMemory.d.ts +6 -0
  86. package/es/components/organism/TextEditor/hooks/useStyleMemory.js +42 -0
  87. package/es/components/organism/TextEditor/hooks/useStylePresets.d.ts +34 -0
  88. package/es/components/organism/TextEditor/hooks/useStylePresets.js +83 -0
  89. package/es/components/organism/TextEditor/index.d.ts +5 -0
  90. package/es/components/organism/TextEditor/index.js +2 -0
  91. package/es/components/organism/TextEditor/index.scss +26 -0
  92. package/es/components/organism/TextEditor/provider.d.ts +10 -0
  93. package/es/components/organism/TextEditor/provider.js +20 -0
  94. package/es/components/organism/TextEditor/store.d.ts +11 -0
  95. package/es/components/organism/TextEditor/store.js +12 -0
  96. package/es/components/organism/TextEditor/styled.d.ts +5 -0
  97. package/es/components/organism/TextEditor/styled.js +69 -0
  98. package/es/components/organism/TextEditor/types.d.ts +95 -0
  99. package/es/components/organism/TextEditor/types.js +1 -0
  100. package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.d.ts +6 -0
  101. package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.js +78 -0
  102. package/es/components/organism/TextEditor/ui/BubbleMenu/index.d.ts +1 -0
  103. package/es/components/organism/TextEditor/ui/BubbleMenu/index.js +1 -0
  104. package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.d.ts +43 -0
  105. package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.js +120 -0
  106. package/es/components/organism/TextEditor/ui/ColorPicker/index.d.ts +1 -0
  107. package/es/components/organism/TextEditor/ui/ColorPicker/index.js +1 -0
  108. package/es/components/organism/TextEditor/ui/Emoji/EmojiList.d.ts +11 -0
  109. package/es/components/organism/TextEditor/ui/Emoji/EmojiList.js +66 -0
  110. package/es/components/organism/TextEditor/ui/Emoji/index.d.ts +2 -0
  111. package/es/components/organism/TextEditor/ui/Emoji/index.js +2 -0
  112. package/es/components/organism/TextEditor/ui/Emoji/suggestion.d.ts +4 -0
  113. package/es/components/organism/TextEditor/ui/Emoji/suggestion.js +71 -0
  114. package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.d.ts +11 -0
  115. package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.js +72 -0
  116. package/es/components/organism/TextEditor/ui/FontPopover/styled.d.ts +1 -0
  117. package/es/components/organism/TextEditor/ui/FontPopover/styled.js +51 -0
  118. package/es/components/organism/TextEditor/ui/Popover/Popover.d.ts +6 -0
  119. package/es/components/organism/TextEditor/ui/Popover/Popover.js +7 -0
  120. package/es/components/organism/TextEditor/ui/Popover/index.d.ts +1 -0
  121. package/es/components/organism/TextEditor/ui/Popover/index.js +1 -0
  122. package/es/components/organism/TextEditor/ui/Select/Select.d.ts +4 -0
  123. package/es/components/organism/TextEditor/ui/Select/Select.js +7 -0
  124. package/es/components/organism/TextEditor/ui/Select/index.d.ts +1 -0
  125. package/es/components/organism/TextEditor/ui/Select/index.js +1 -0
  126. package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.d.ts +30 -0
  127. package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.js +49 -0
  128. package/es/components/organism/TextEditor/ui/TextAlignSelect/index.d.ts +1 -0
  129. package/es/components/organism/TextEditor/ui/TextAlignSelect/index.js +1 -0
  130. package/es/components/organism/TextEditor/ui/Toolbar/Toolbar.d.ts +14 -0
  131. package/es/components/organism/TextEditor/ui/Toolbar/Toolbar.js +42 -0
  132. package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.d.ts +5 -0
  133. package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.js +7 -0
  134. package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.d.ts +5 -0
  135. package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.js +7 -0
  136. package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.d.ts +5 -0
  137. package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.js +18 -0
  138. package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.d.ts +4 -0
  139. package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.js +13 -0
  140. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.d.ts +7 -0
  141. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.js +18 -0
  142. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.d.ts +6 -0
  143. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.js +42 -0
  144. package/es/components/organism/TextEditor/ui/Toolbar/actions/HighlightAction.d.ts +5 -0
  145. package/es/components/organism/TextEditor/ui/Toolbar/actions/HighlightAction.js +7 -0
  146. package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.d.ts +5 -0
  147. package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.js +7 -0
  148. package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.d.ts +5 -0
  149. package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.js +7 -0
  150. package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.d.ts +6 -0
  151. package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.js +4 -0
  152. package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.d.ts +5 -0
  153. package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.js +7 -0
  154. package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.d.ts +5 -0
  155. package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.js +7 -0
  156. package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.d.ts +7 -0
  157. package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.js +9 -0
  158. package/es/components/organism/TextEditor/ui/Toolbar/actions/SpacingAction.d.ts +9 -0
  159. package/es/components/organism/TextEditor/ui/Toolbar/actions/SpacingAction.js +22 -0
  160. package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.d.ts +5 -0
  161. package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.js +7 -0
  162. package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.d.ts +5 -0
  163. package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.js +13 -0
  164. package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.d.ts +5 -0
  165. package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.js +13 -0
  166. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.d.ts +5 -0
  167. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.js +3 -0
  168. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.d.ts +7 -0
  169. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.js +19 -0
  170. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.d.ts +15 -0
  171. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.js +14 -0
  172. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.d.ts +5 -0
  173. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.js +28 -0
  174. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.d.ts +5 -0
  175. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.js +5 -0
  176. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.d.ts +6 -0
  177. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.js +10 -0
  178. package/es/components/organism/TextEditor/ui/Toolbar/actions/index.d.ts +20 -0
  179. package/es/components/organism/TextEditor/ui/Toolbar/actions/index.js +20 -0
  180. package/es/components/organism/TextEditor/ui/Toolbar/index.d.ts +1 -0
  181. package/es/components/organism/TextEditor/ui/Toolbar/index.js +1 -0
  182. package/es/components/organism/TextEditor/utils/documentState.d.ts +57 -0
  183. package/es/components/organism/TextEditor/utils/documentState.js +100 -0
  184. package/es/components/organism/TextEditor/utils/font.d.ts +84 -0
  185. package/es/components/organism/TextEditor/utils/font.js +175 -0
  186. package/es/components/organism/TextEditor/utils/htmlProcessing.d.ts +62 -0
  187. package/es/components/organism/TextEditor/utils/htmlProcessing.js +304 -0
  188. package/es/components/organism/TextEditor/utils/index.d.ts +8 -0
  189. package/es/components/organism/TextEditor/utils/index.js +16 -0
  190. package/es/components/organism/TextEditor/utils/link.d.ts +100 -0
  191. package/es/components/organism/TextEditor/utils/link.js +149 -0
  192. package/es/components/organism/TextEditor/utils/menu.d.ts +134 -0
  193. package/es/components/organism/TextEditor/utils/menu.js +317 -0
  194. package/es/components/organism/TextEditor/utils/selection.d.ts +25 -0
  195. package/es/components/organism/TextEditor/utils/selection.js +57 -0
  196. package/es/components/organism/TextEditor/utils/smartTag.d.ts +49 -0
  197. package/es/components/organism/TextEditor/utils/smartTag.js +89 -0
  198. package/es/components/organism/TextEditor/utils/style.d.ts +78 -0
  199. package/es/components/organism/TextEditor/utils/style.js +193 -0
  200. package/es/components/organism/index.d.ts +1 -0
  201. package/es/components/organism/index.js +1 -0
  202. package/es/components/organism/index.scss +1 -0
  203. package/es/hooks/useBroadcastedLocalStorage.d.ts +5 -0
  204. package/es/hooks/useBroadcastedLocalStorage.js +71 -0
  205. package/es/utils/common.d.ts +6 -9
  206. package/es/utils/common.js +44 -23
  207. package/es/utils/index.d.ts +1 -0
  208. package/es/utils/index.js +1 -0
  209. package/es/utils/tree.d.ts +225 -0
  210. package/es/utils/tree.js +469 -0
  211. package/es/utils/web.d.ts +4 -0
  212. package/es/utils/web.js +25 -0
  213. package/package.json +29 -3
@@ -0,0 +1,47 @@
1
+ import '@tiptap/extension-text-style';
2
+ import { Extension } from '@tiptap/core';
3
+ import { DEFAULT_TEXT_STYLE } from '../constants';
4
+ /**
5
+ * This extension allows you to set a font size for text.
6
+ */
7
+ export const FontSize = Extension.create({
8
+ name: 'fontSize',
9
+ addOptions() {
10
+ return {
11
+ types: ['textStyle'],
12
+ defaultFontSize: DEFAULT_TEXT_STYLE.fontSize,
13
+ };
14
+ },
15
+ addGlobalAttributes() {
16
+ return [
17
+ {
18
+ types: this.options.types,
19
+ attributes: {
20
+ fontSize: {
21
+ default: this.options.defaultFontSize,
22
+ parseHTML: element => element.style.fontSize || this.options.defaultFontSize,
23
+ renderHTML: attributes => {
24
+ if (!attributes.fontSize) {
25
+ return {};
26
+ }
27
+ return {
28
+ style: `font-size: ${attributes.fontSize}`,
29
+ };
30
+ },
31
+ },
32
+ },
33
+ },
34
+ ];
35
+ },
36
+ addCommands() {
37
+ return {
38
+ setFontSize: fontSize => ({ chain }) => chain().setMark('textStyle', { fontSize }).run(),
39
+ unsetFontSize: () => ({ chain }) => chain()
40
+ .setMark('textStyle', {
41
+ fontSize: this.options.defaultFontSize || null,
42
+ })
43
+ .removeEmptyTextStyle()
44
+ .run(),
45
+ };
46
+ },
47
+ });
@@ -0,0 +1,23 @@
1
+ import { Extension } from '@tiptap/core';
2
+ export interface FontWeightOptions {
3
+ types: string[];
4
+ defaultWeight: string | number;
5
+ }
6
+ declare module '@tiptap/core' {
7
+ interface Commands<ReturnType> {
8
+ fontWeight: {
9
+ /**
10
+ * Set the font weight
11
+ * @param fontWeight The font weight
12
+ * @example editor.commands.setFontWeight('bold')
13
+ */
14
+ setFontWeight: (fontWeight: string | number) => ReturnType;
15
+ /**
16
+ * Unset the font weight
17
+ * @example editor.commands.unsetFontWeight()
18
+ */
19
+ unsetFontWeight: () => ReturnType;
20
+ };
21
+ }
22
+ }
23
+ export declare const FontWeight: Extension<any, any>;
@@ -0,0 +1,41 @@
1
+ import { Extension } from '@tiptap/core';
2
+ import { DEFAULT_TEXT_STYLE } from '../constants';
3
+ export const FontWeight = Extension.create({
4
+ name: 'fontWeight',
5
+ addOptions() {
6
+ return {
7
+ types: ['textStyle'],
8
+ defaultWeight: DEFAULT_TEXT_STYLE.fontWeight,
9
+ };
10
+ },
11
+ addGlobalAttributes() {
12
+ return [
13
+ {
14
+ types: this.options.types,
15
+ attributes: {
16
+ fontWeight: {
17
+ default: this.options.defaultWeight,
18
+ renderHTML: attributes => {
19
+ if (!attributes.fontWeight) {
20
+ return {};
21
+ }
22
+ return {
23
+ style: `font-weight: ${attributes.fontWeight}`,
24
+ };
25
+ },
26
+ parseHTML: element => element.style.fontWeight,
27
+ },
28
+ },
29
+ },
30
+ ];
31
+ },
32
+ addCommands() {
33
+ return {
34
+ setFontWeight: fontWeight => ({ chain }) => chain().setMark('textStyle', { fontWeight }).run(),
35
+ unsetFontWeight: () => ({ chain }) => chain()
36
+ .setMark('textStyle', { fontWeight: this.options.defaultWeight })
37
+ .removeEmptyTextStyle()
38
+ .run(),
39
+ };
40
+ },
41
+ });
@@ -0,0 +1 @@
1
+ export declare const Highlight: import("@tiptap/core").Mark<import("@tiptap/extension-highlight").HighlightOptions, any>;
@@ -0,0 +1,14 @@
1
+ import { Highlight as TiptapHighlightExtension } from '@tiptap/extension-highlight';
2
+ export const Highlight = TiptapHighlightExtension.extend({
3
+ parseHTML() {
4
+ return [
5
+ {
6
+ tag: 'mark',
7
+ },
8
+ {
9
+ tag: 'span',
10
+ getAttrs: node => node.style.backgroundColor !== undefined && null,
11
+ },
12
+ ];
13
+ },
14
+ });
@@ -0,0 +1,28 @@
1
+ import { Extension } from '@tiptap/core';
2
+ export interface IndentOptions {
3
+ /**
4
+ * Maximum indentation level
5
+ * @default 8
6
+ */
7
+ maxIndent: number;
8
+ /**
9
+ * Types of nodes that can be indented
10
+ * @default ['paragraph', 'heading']
11
+ */
12
+ types: string[];
13
+ }
14
+ declare module '@tiptap/core' {
15
+ interface Commands<ReturnType> {
16
+ indent: {
17
+ /**
18
+ * Increase indent
19
+ */
20
+ indent: () => ReturnType;
21
+ /**
22
+ * Decrease indent
23
+ */
24
+ outdent: () => ReturnType;
25
+ };
26
+ }
27
+ }
28
+ export declare const Indent: Extension<IndentOptions, any>;
@@ -0,0 +1,66 @@
1
+ import { Extension } from '@tiptap/core';
2
+ export const Indent = Extension.create({
3
+ name: 'indent',
4
+ addOptions() {
5
+ return {
6
+ maxIndent: 8,
7
+ types: ['paragraph', 'heading'],
8
+ };
9
+ },
10
+ addGlobalAttributes() {
11
+ return [
12
+ {
13
+ types: this.options.types,
14
+ attributes: {
15
+ indent: {
16
+ default: 0,
17
+ renderHTML: attributes => ({
18
+ style: `margin-left: ${attributes.indent}em;`,
19
+ }),
20
+ parseHTML: element => {
21
+ const indent = element.style.marginLeft;
22
+ if (indent) {
23
+ return parseInt(indent) || 0;
24
+ }
25
+ return 0;
26
+ },
27
+ },
28
+ },
29
+ },
30
+ ];
31
+ },
32
+ addCommands() {
33
+ return {
34
+ indent: () => ({ commands }) => {
35
+ // Lấy giá trị indent hiện tại
36
+ const currentIndent = this.editor.getAttributes('paragraph').indent || 0;
37
+ // Giới hạn mức indent tối đa từ options
38
+ if (currentIndent >= this.options.maxIndent)
39
+ return false;
40
+ return this.options.types
41
+ .map(type => commands.updateAttributes(type, {
42
+ indent: currentIndent + 1,
43
+ }))
44
+ .every(reponse => reponse);
45
+ },
46
+ outdent: () => ({ commands }) => {
47
+ // Lấy giá trị indent hiện tại
48
+ const currentIndent = this.editor.getAttributes('paragraph').indent || 0;
49
+ // Không thể outdent khi indent = 0
50
+ if (currentIndent <= 0)
51
+ return false;
52
+ return this.options.types
53
+ .map(type => commands.updateAttributes(type, {
54
+ indent: currentIndent - 1,
55
+ }))
56
+ .every(reponse => reponse);
57
+ },
58
+ };
59
+ },
60
+ addKeyboardShortcuts() {
61
+ return {
62
+ Tab: () => this.editor.commands.indent(),
63
+ 'Shift-Tab': () => this.editor.commands.outdent(),
64
+ };
65
+ },
66
+ });
@@ -0,0 +1,20 @@
1
+ import { Extension } from '@tiptap/core';
2
+ export interface LineHeightOptions {
3
+ types: string[];
4
+ defaultHeight: string;
5
+ }
6
+ declare module '@tiptap/core' {
7
+ interface Commands<ReturnType> {
8
+ lineHeight: {
9
+ /**
10
+ * Set the line height attribute
11
+ */
12
+ setLineHeight: (height: string) => ReturnType;
13
+ /**
14
+ * Unset the text align attribute
15
+ */
16
+ unsetLineHeight: () => ReturnType;
17
+ };
18
+ }
19
+ }
20
+ export declare const LineHeight: Extension<LineHeightOptions, any>;
@@ -0,0 +1,36 @@
1
+ import { Extension } from '@tiptap/core';
2
+ import { DEFAULT_TEXT_STYLE } from '../constants';
3
+ export const LineHeight = Extension.create({
4
+ name: 'lineHeight',
5
+ addOptions() {
6
+ return {
7
+ defaultHeight: DEFAULT_TEXT_STYLE.lineHeight,
8
+ types: ['heading', 'paragraph'],
9
+ };
10
+ },
11
+ addGlobalAttributes() {
12
+ return [
13
+ {
14
+ types: this.options.types,
15
+ attributes: {
16
+ lineHeight: {
17
+ default: this.options.defaultHeight,
18
+ parseHTML: element => element.style.lineHeight || this.options.defaultHeight,
19
+ renderHTML: attributes => {
20
+ if (!attributes.lineHeight) {
21
+ return {};
22
+ }
23
+ return { style: `line-height: ${attributes.lineHeight}` };
24
+ },
25
+ },
26
+ },
27
+ },
28
+ ];
29
+ },
30
+ addCommands() {
31
+ return {
32
+ setLineHeight: (height) => ({ commands }) => this.options.types.every(type => commands.updateAttributes(type, { lineHeight: height })),
33
+ unsetLineHeight: () => ({ commands }) => this.options.types.every(type => commands.resetAttributes(type, 'lineHeight')),
34
+ };
35
+ },
36
+ });
@@ -0,0 +1,3 @@
1
+ import { LinkOptions as TiptapLinkOptions } from '@tiptap/extension-link';
2
+ export type LinkOptions = TiptapLinkOptions & {};
3
+ export declare const Link: import("@tiptap/core").Mark<TiptapLinkOptions, any>;
@@ -0,0 +1,47 @@
1
+ import TiptapLinkExtension from '@tiptap/extension-link';
2
+ import { LINK_TEXT_COLOR } from '../constants';
3
+ export const Link = TiptapLinkExtension.extend({
4
+ addOptions() {
5
+ return {
6
+ ...this.parent?.(),
7
+ openOnClick: false,
8
+ autolink: false,
9
+ };
10
+ },
11
+ addAttributes() {
12
+ return {
13
+ ...this.parent?.(),
14
+ id: {
15
+ default: null,
16
+ parseHTML: el => el.getAttribute('data-link-id'),
17
+ renderHTML: attrs => ({
18
+ 'data-link-id': attrs.id,
19
+ }),
20
+ },
21
+ title: {
22
+ default: '',
23
+ parseHTML: el => el.title,
24
+ },
25
+ dynamic: {
26
+ default: null,
27
+ parseHTML: el => el.getAttribute('data-dynamic'),
28
+ renderHTML: attrs => ({
29
+ 'data-dynamic': attrs.dynamic,
30
+ }),
31
+ },
32
+ };
33
+ },
34
+ addKeyboardShortcuts() {
35
+ return {
36
+ ...this.parent?.(),
37
+ Enter: ({ editor }) => {
38
+ editor.chain().unsetUnderline().run();
39
+ const currentColor = editor.getAttributes('textStyle').color;
40
+ if (currentColor === LINK_TEXT_COLOR) {
41
+ editor.chain().unsetColor().run();
42
+ }
43
+ return false;
44
+ },
45
+ };
46
+ },
47
+ });
@@ -0,0 +1,13 @@
1
+ import { Extension } from '@tiptap/core';
2
+ export interface ListItemMarkerOptions {
3
+ paddingRight: number;
4
+ defaultFontSize: string;
5
+ defaultFontFamily: string;
6
+ }
7
+ /**
8
+ * Extension tạo marker tùy chỉnh cho danh sách trong p
9
+ *
10
+ * Extension này thay thế marker mặc định của danh sách bằng các marker
11
+ * có thể kế thừa style (font, size, color...) từ text node đầu tiên.
12
+ */
13
+ export declare const ListItemMarker: Extension<ListItemMarkerOptions, any>;
@@ -0,0 +1,174 @@
1
+ import { Extension } from '@tiptap/core';
2
+ import { Plugin, PluginKey } from '@tiptap/pm/state';
3
+ import { Decoration, DecorationSet } from '@tiptap/pm/view';
4
+ import { kebabCase } from 'lodash';
5
+ function getMaxMarkerWidth(markers, font = '16px Arial') {
6
+ let max = 0;
7
+ const canvas = document.createElement('canvas');
8
+ const ctx = canvas.getContext('2d');
9
+ if (!ctx)
10
+ return max;
11
+ ctx.font = font;
12
+ for (const m of markers) {
13
+ const w = ctx.measureText(m).width;
14
+ if (w > max)
15
+ max = w;
16
+ }
17
+ return max;
18
+ }
19
+ /**
20
+ * Tạo các marker tùy chỉnh cho danh sách (bullet và ordered) với style kế thừa từ text node
21
+ *
22
+ * @param doc - ProseMirror document node
23
+ * @returns DecorationSet chứa tất cả các widget decoration cho marker
24
+ */
25
+ const styleMarker = (doc, options) => {
26
+ const decorations = [];
27
+ doc.descendants((listNode, listNodePos) => {
28
+ const isBulletList = listNode.type.name === 'bulletList';
29
+ const isOrderedList = listNode.type.name === 'orderedList';
30
+ if (!isBulletList && !isOrderedList) {
31
+ return;
32
+ }
33
+ // Khởi tạo marker dựa trên loại danh sách
34
+ const getMarker = (isOrderedList, index) => isOrderedList ? `${index + 1}.` : '•';
35
+ const markers = [];
36
+ const listItems = [];
37
+ listNode.descendants((listItem, listItemPos) => {
38
+ if (listItem.type.name !== 'listItem') {
39
+ return;
40
+ }
41
+ const itemInfo = {
42
+ node: listItem,
43
+ pos: listItemPos,
44
+ isEmpty: true,
45
+ };
46
+ listItems.push(itemInfo);
47
+ // Tìm paragraph đầu tiên và text node đầu tiên
48
+ let foundText = false;
49
+ let foundParagraph = false;
50
+ listItem.descendants((node, nodePos) => {
51
+ if (!foundParagraph && node.type.name === 'paragraph') {
52
+ foundParagraph = true;
53
+ itemInfo.paragraphPos = nodePos;
54
+ itemInfo.paragraphNode = node;
55
+ }
56
+ if (!foundText && node.type.name === 'text') {
57
+ foundText = true;
58
+ itemInfo.isEmpty = false;
59
+ itemInfo.textNode = node;
60
+ itemInfo.textNodePos = nodePos;
61
+ const textStyleMark = node.marks.find(nodeMark => nodeMark.type.name === 'textStyle');
62
+ if (textStyleMark) {
63
+ itemInfo.textStyleMark = textStyleMark;
64
+ }
65
+ }
66
+ });
67
+ const index = listItems.length;
68
+ const marker = getMarker(isOrderedList, index - 1);
69
+ markers.push(marker);
70
+ });
71
+ for (let i = 0; i < listItems.length; i++) {
72
+ const item = listItems[i];
73
+ if (!item.textStyleMark) {
74
+ for (let j = i - 1; j >= 0; j--) {
75
+ if (listItems[j].textStyleMark) {
76
+ item.textStyleMark = listItems[j].textStyleMark;
77
+ break;
78
+ }
79
+ }
80
+ }
81
+ }
82
+ let font = `${options.defaultFontSize} ${options.defaultFontFamily}`;
83
+ for (const item of listItems) {
84
+ if (item.textStyleMark) {
85
+ const { fontSize, fontFamily } = item.textStyleMark.attrs;
86
+ if (fontSize && fontFamily) {
87
+ font = `${fontSize} ${fontFamily}`;
88
+ break;
89
+ }
90
+ }
91
+ }
92
+ const maxWidth = getMaxMarkerWidth(markers, font);
93
+ const { paddingRight } = options;
94
+ const totalWidth = maxWidth + paddingRight;
95
+ listItems.forEach((item, index) => {
96
+ if (item.paragraphPos === undefined) {
97
+ return;
98
+ }
99
+ const marker = getMarker(isOrderedList, index);
100
+ const widget = document.createElement('span');
101
+ widget.innerHTML = marker;
102
+ // Đặt các thuộc tính style cơ bản
103
+ widget.style.setProperty('user-select', 'none');
104
+ widget.style.setProperty('text-decoration', 'none');
105
+ widget.style.setProperty('display', 'inline-block');
106
+ widget.style.setProperty('width', `${totalWidth}px`);
107
+ widget.style.setProperty('text-align', 'left');
108
+ // Sao chép tất cả các thuộc tính style từ mark textStyle
109
+ if (item.textStyleMark) {
110
+ for (const styleProp in item.textStyleMark.attrs) {
111
+ widget.style.setProperty(kebabCase(styleProp), String(item.textStyleMark.attrs[styleProp]));
112
+ }
113
+ }
114
+ // Tính toán vị trí chính xác cho marker
115
+ const absoluteListItemPos = listNodePos + item.pos + 1;
116
+ const absoluteParagraphPos = absoluteListItemPos + item.paragraphPos;
117
+ const markerPos = absoluteParagraphPos + 1;
118
+ // Đặt marker widget tại vị trí đã tính toán (bên trong paragraph)
119
+ // Decoration.widget sẽ tạo một widget tại vị trí markerPos
120
+ decorations.push(Decoration.widget(markerPos, widget, {
121
+ ignoreSelection: true,
122
+ }));
123
+ if (item.paragraphNode) {
124
+ // Tính toán vị trí bắt đầu và kết thúc của paragraph
125
+ const paragraphStart = absoluteParagraphPos;
126
+ const paragraphEnd = paragraphStart + item.paragraphNode.nodeSize;
127
+ // Thêm decoration cho paragraph với style inline-block
128
+ decorations.push(Decoration.node(paragraphStart + 1, paragraphEnd + 1, {
129
+ style: 'display: inline;',
130
+ }));
131
+ }
132
+ });
133
+ });
134
+ return DecorationSet.create(doc, decorations);
135
+ };
136
+ /**
137
+ * Extension tạo marker tùy chỉnh cho danh sách trong p
138
+ *
139
+ * Extension này thay thế marker mặc định của danh sách bằng các marker
140
+ * có thể kế thừa style (font, size, color...) từ text node đầu tiên.
141
+ */
142
+ export const ListItemMarker = Extension.create({
143
+ name: 'list-item-marker',
144
+ addOptions() {
145
+ return {
146
+ ...this.parent?.(),
147
+ paddingRight: 10,
148
+ defaultFontSize: '16px',
149
+ defaultFontFamily: 'Arial',
150
+ };
151
+ },
152
+ addProseMirrorPlugins() {
153
+ const { options } = this;
154
+ return [
155
+ new Plugin({
156
+ key: new PluginKey('custom-list-item-marker'),
157
+ state: {
158
+ init(_, { doc }) {
159
+ return styleMarker(doc, options);
160
+ },
161
+ // Chỉ tính toán lại nếu document thay đổi
162
+ apply(tr, oldState) {
163
+ return tr.docChanged ? styleMarker(tr.doc, options) : oldState;
164
+ },
165
+ },
166
+ props: {
167
+ decorations(state) {
168
+ return this.getState(state);
169
+ },
170
+ },
171
+ }),
172
+ ];
173
+ },
174
+ });
@@ -0,0 +1,6 @@
1
+ import { Extension } from '@tiptap/core';
2
+ interface SelectionDecorationOptions {
3
+ className: string;
4
+ }
5
+ export declare const SelectionDecoration: Extension<SelectionDecorationOptions, any>;
6
+ export {};
@@ -0,0 +1,40 @@
1
+ import { Extension, isNodeSelection } from '@tiptap/core';
2
+ import { Plugin, PluginKey } from '@tiptap/pm/state';
3
+ import { Decoration, DecorationSet } from '@tiptap/pm/view';
4
+ const EXTENSION_NAME = 'selectionDecoration';
5
+ export const SelectionDecoration = Extension.create({
6
+ name: EXTENSION_NAME,
7
+ addOptions() {
8
+ return {
9
+ className: 'selection',
10
+ };
11
+ },
12
+ addProseMirrorPlugins() {
13
+ return [
14
+ new Plugin({
15
+ key: new PluginKey(EXTENSION_NAME),
16
+ props: {
17
+ decorations: () => {
18
+ const { state, isFocused, isEditable } = this.editor;
19
+ const { selection } = state;
20
+ const { from, to } = selection;
21
+ if (state.selection.empty) {
22
+ return null;
23
+ }
24
+ if (isFocused === true || !isEditable) {
25
+ return null;
26
+ }
27
+ if (isNodeSelection(state.selection)) {
28
+ return null;
29
+ }
30
+ return DecorationSet.create(state.doc, [
31
+ Decoration.inline(from, to, {
32
+ class: this.options.className,
33
+ }),
34
+ ]);
35
+ },
36
+ },
37
+ }),
38
+ ];
39
+ },
40
+ });
@@ -0,0 +1,33 @@
1
+ import { Node } from '@tiptap/core';
2
+ import { Attrs } from '@tiptap/pm/model';
3
+ /**
4
+ * Represents the options for the SmartTag node.
5
+ */
6
+ export interface SmartTagOptions {
7
+ HTMLAttributes: Record<string, unknown>;
8
+ highlight: boolean;
9
+ }
10
+ export interface SmartTagStorage {
11
+ highlight: boolean;
12
+ }
13
+ /**
14
+ * Represents the options for the SmartTag node.
15
+ */
16
+ declare module '@tiptap/core' {
17
+ interface Commands<ReturnType> {
18
+ smartTag: {
19
+ setSmartTag: (attrs: {
20
+ id: string;
21
+ content?: string;
22
+ }) => ReturnType;
23
+ deleteSmartTagGlobally: (predicate: (attrs: Attrs) => boolean) => ReturnType;
24
+ updateSmartTagAttrsGlobally: (updateFn: (attrs: Attrs) => Attrs | undefined) => ReturnType;
25
+ updateSmartTagHighlight: (enabled: boolean) => ReturnType;
26
+ };
27
+ }
28
+ }
29
+ export declare const EXTENSION_NAME = "smartTag";
30
+ /**
31
+ * Represents a dynamic tag node in the editor.
32
+ */
33
+ export declare const SmartTag: Node<SmartTagOptions, SmartTagStorage>;