@antscorp/antsomi-ui 2.0.83-text-editor-beta.10 → 2.0.84

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 (226) hide show
  1. package/es/assets/css/main.scss +2 -4
  2. package/es/components/molecules/DisplayFormat/constants.js +2 -2
  3. package/es/components/molecules/DisplayFormat/utils.js +2 -2
  4. package/es/components/molecules/EmojiPopover/EmojiPopover.js +1 -5
  5. package/es/components/molecules/VirtualizedMenu/VirtualizedMenu.d.ts +3 -6
  6. package/es/components/molecules/VirtualizedMenu/__mocks__/index.js +982 -2594
  7. package/es/components/molecules/VirtualizedMenu/components/Item/Item.d.ts +3 -13
  8. package/es/components/molecules/VirtualizedMenu/components/Item/Item.js +25 -53
  9. package/es/components/molecules/VirtualizedMenu/components/Item/index.d.ts +1 -1
  10. package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.d.ts +5 -8
  11. package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.js +46 -289
  12. package/es/components/molecules/VirtualizedMenu/components/MenuInline/index.js +0 -1
  13. package/es/components/molecules/VirtualizedMenu/styled.d.ts +1 -1
  14. package/es/components/molecules/VirtualizedMenu/styled.js +4 -23
  15. package/es/components/molecules/VirtualizedMenu/types.d.ts +9 -6
  16. package/es/components/molecules/VirtualizedMenu/utils.d.ts +5 -8
  17. package/es/components/molecules/VirtualizedMenu/utils.js +18 -13
  18. package/es/components/molecules/index.d.ts +0 -1
  19. package/es/components/molecules/index.js +0 -1
  20. package/es/components/organism/index.d.ts +0 -1
  21. package/es/components/organism/index.js +0 -1
  22. package/es/hooks/index.d.ts +0 -1
  23. package/es/hooks/index.js +0 -1
  24. package/es/utils/common.d.ts +9 -6
  25. package/es/utils/common.js +23 -44
  26. package/es/utils/index.d.ts +0 -1
  27. package/es/utils/index.js +0 -1
  28. package/es/utils/web.d.ts +0 -4
  29. package/es/utils/web.js +0 -25
  30. package/package.json +3 -29
  31. package/es/components/index.scss +0 -2
  32. package/es/components/molecules/FontSizeInput/FontSizeInput.d.ts +0 -3
  33. package/es/components/molecules/FontSizeInput/FontSizeInput.js +0 -128
  34. package/es/components/molecules/FontSizeInput/components/FontSizeControl.d.ts +0 -8
  35. package/es/components/molecules/FontSizeInput/components/FontSizeControl.js +0 -14
  36. package/es/components/molecules/FontSizeInput/components/FontSizeDropdown.d.ts +0 -20
  37. package/es/components/molecules/FontSizeInput/components/FontSizeDropdown.js +0 -17
  38. package/es/components/molecules/FontSizeInput/constants.d.ts +0 -2
  39. package/es/components/molecules/FontSizeInput/constants.js +0 -5
  40. package/es/components/molecules/FontSizeInput/index.d.ts +0 -2
  41. package/es/components/molecules/FontSizeInput/index.js +0 -1
  42. package/es/components/molecules/FontSizeInput/styled.d.ts +0 -3
  43. package/es/components/molecules/FontSizeInput/styled.js +0 -22
  44. package/es/components/molecules/FontSizeInput/styles.scss +0 -15
  45. package/es/components/molecules/FontSizeInput/types.d.ts +0 -24
  46. package/es/components/molecules/FontSizeInput/types.js +0 -1
  47. package/es/components/molecules/FontSizeInput/utils.d.ts +0 -7
  48. package/es/components/molecules/FontSizeInput/utils.js +0 -9
  49. package/es/components/molecules/index.scss +0 -1
  50. package/es/components/organism/ActivityTimeline/__mocks__/event_tracking.json +0 -1290
  51. package/es/components/organism/ActivityTimeline/__mocks__/timeline.json +0 -3059
  52. package/es/components/organism/TextEditor/TextEditor.d.ts +0 -3
  53. package/es/components/organism/TextEditor/TextEditor.js +0 -251
  54. package/es/components/organism/TextEditor/__mocks__/text-block.settings.json +0 -320
  55. package/es/components/organism/TextEditor/__mocks__/text-contennt.d.ts +0 -1
  56. package/es/components/organism/TextEditor/__mocks__/text-contennt.js +0 -38
  57. package/es/components/organism/TextEditor/constants.d.ts +0 -135
  58. package/es/components/organism/TextEditor/constants.js +0 -280
  59. package/es/components/organism/TextEditor/extensions/BackgroundColor.d.ts +0 -25
  60. package/es/components/organism/TextEditor/extensions/BackgroundColor.js +0 -46
  61. package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.d.ts +0 -130
  62. package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.js +0 -247
  63. package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.d.ts +0 -15
  64. package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.js +0 -31
  65. package/es/components/organism/TextEditor/extensions/BubbleMenu/index.d.ts +0 -2
  66. package/es/components/organism/TextEditor/extensions/BubbleMenu/index.js +0 -2
  67. package/es/components/organism/TextEditor/extensions/Color.d.ts +0 -6
  68. package/es/components/organism/TextEditor/extensions/Color.js +0 -41
  69. package/es/components/organism/TextEditor/extensions/Emoji.d.ts +0 -57
  70. package/es/components/organism/TextEditor/extensions/Emoji.js +0 -184
  71. package/es/components/organism/TextEditor/extensions/FontFamily.d.ts +0 -6
  72. package/es/components/organism/TextEditor/extensions/FontFamily.js +0 -43
  73. package/es/components/organism/TextEditor/extensions/FontSize.d.ts +0 -32
  74. package/es/components/organism/TextEditor/extensions/FontSize.js +0 -47
  75. package/es/components/organism/TextEditor/extensions/FontWeight.d.ts +0 -23
  76. package/es/components/organism/TextEditor/extensions/FontWeight.js +0 -41
  77. package/es/components/organism/TextEditor/extensions/Highlight.d.ts +0 -1
  78. package/es/components/organism/TextEditor/extensions/Highlight.js +0 -14
  79. package/es/components/organism/TextEditor/extensions/Indent.d.ts +0 -28
  80. package/es/components/organism/TextEditor/extensions/Indent.js +0 -68
  81. package/es/components/organism/TextEditor/extensions/LineHeight.d.ts +0 -20
  82. package/es/components/organism/TextEditor/extensions/LineHeight.js +0 -36
  83. package/es/components/organism/TextEditor/extensions/Link.d.ts +0 -15
  84. package/es/components/organism/TextEditor/extensions/Link.js +0 -50
  85. package/es/components/organism/TextEditor/extensions/ListItemMarker.d.ts +0 -13
  86. package/es/components/organism/TextEditor/extensions/ListItemMarker.js +0 -174
  87. package/es/components/organism/TextEditor/extensions/Selection.d.ts +0 -6
  88. package/es/components/organism/TextEditor/extensions/Selection.js +0 -40
  89. package/es/components/organism/TextEditor/extensions/SmartTag.d.ts +0 -39
  90. package/es/components/organism/TextEditor/extensions/SmartTag.js +0 -167
  91. package/es/components/organism/TextEditor/extensions/StyleMemory.d.ts +0 -36
  92. package/es/components/organism/TextEditor/extensions/StyleMemory.js +0 -163
  93. package/es/components/organism/TextEditor/extensions/TextTransform.d.ts +0 -31
  94. package/es/components/organism/TextEditor/extensions/TextTransform.js +0 -37
  95. package/es/components/organism/TextEditor/hooks/index.d.ts +0 -6
  96. package/es/components/organism/TextEditor/hooks/index.js +0 -6
  97. package/es/components/organism/TextEditor/hooks/useDocumentState.d.ts +0 -18
  98. package/es/components/organism/TextEditor/hooks/useDocumentState.js +0 -42
  99. package/es/components/organism/TextEditor/hooks/useLinkHandler.d.ts +0 -10
  100. package/es/components/organism/TextEditor/hooks/useLinkHandler.js +0 -223
  101. package/es/components/organism/TextEditor/hooks/useMarkTracking.d.ts +0 -26
  102. package/es/components/organism/TextEditor/hooks/useMarkTracking.js +0 -68
  103. package/es/components/organism/TextEditor/hooks/usePersistence.d.ts +0 -31
  104. package/es/components/organism/TextEditor/hooks/usePersistence.js +0 -169
  105. package/es/components/organism/TextEditor/hooks/useStyleMemory.d.ts +0 -6
  106. package/es/components/organism/TextEditor/hooks/useStyleMemory.js +0 -42
  107. package/es/components/organism/TextEditor/hooks/useStylePresets.d.ts +0 -34
  108. package/es/components/organism/TextEditor/hooks/useStylePresets.js +0 -83
  109. package/es/components/organism/TextEditor/index.d.ts +0 -14
  110. package/es/components/organism/TextEditor/index.js +0 -6
  111. package/es/components/organism/TextEditor/index.scss +0 -61
  112. package/es/components/organism/TextEditor/provider.d.ts +0 -10
  113. package/es/components/organism/TextEditor/provider.js +0 -20
  114. package/es/components/organism/TextEditor/store.d.ts +0 -11
  115. package/es/components/organism/TextEditor/store.js +0 -12
  116. package/es/components/organism/TextEditor/styled.d.ts +0 -8
  117. package/es/components/organism/TextEditor/styled.js +0 -90
  118. package/es/components/organism/TextEditor/types.d.ts +0 -92
  119. package/es/components/organism/TextEditor/types.js +0 -1
  120. package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.d.ts +0 -6
  121. package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.js +0 -78
  122. package/es/components/organism/TextEditor/ui/BubbleMenu/index.d.ts +0 -1
  123. package/es/components/organism/TextEditor/ui/BubbleMenu/index.js +0 -1
  124. package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.d.ts +0 -43
  125. package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.js +0 -120
  126. package/es/components/organism/TextEditor/ui/ColorPicker/index.d.ts +0 -1
  127. package/es/components/organism/TextEditor/ui/ColorPicker/index.js +0 -1
  128. package/es/components/organism/TextEditor/ui/Emoji/EmojiList.d.ts +0 -11
  129. package/es/components/organism/TextEditor/ui/Emoji/EmojiList.js +0 -66
  130. package/es/components/organism/TextEditor/ui/Emoji/index.d.ts +0 -2
  131. package/es/components/organism/TextEditor/ui/Emoji/index.js +0 -2
  132. package/es/components/organism/TextEditor/ui/Emoji/suggestion.d.ts +0 -4
  133. package/es/components/organism/TextEditor/ui/Emoji/suggestion.js +0 -71
  134. package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.d.ts +0 -12
  135. package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.js +0 -69
  136. package/es/components/organism/TextEditor/ui/FontPopover/styled.d.ts +0 -1
  137. package/es/components/organism/TextEditor/ui/FontPopover/styled.js +0 -20
  138. package/es/components/organism/TextEditor/ui/Popover/Popover.d.ts +0 -6
  139. package/es/components/organism/TextEditor/ui/Popover/Popover.js +0 -7
  140. package/es/components/organism/TextEditor/ui/Popover/index.d.ts +0 -1
  141. package/es/components/organism/TextEditor/ui/Popover/index.js +0 -1
  142. package/es/components/organism/TextEditor/ui/Select/Select.d.ts +0 -4
  143. package/es/components/organism/TextEditor/ui/Select/Select.js +0 -7
  144. package/es/components/organism/TextEditor/ui/Select/index.d.ts +0 -1
  145. package/es/components/organism/TextEditor/ui/Select/index.js +0 -1
  146. package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.d.ts +0 -30
  147. package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.js +0 -49
  148. package/es/components/organism/TextEditor/ui/TextAlignSelect/index.d.ts +0 -1
  149. package/es/components/organism/TextEditor/ui/TextAlignSelect/index.js +0 -1
  150. package/es/components/organism/TextEditor/ui/Toolbar/Toolbar.d.ts +0 -14
  151. package/es/components/organism/TextEditor/ui/Toolbar/Toolbar.js +0 -42
  152. package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.d.ts +0 -5
  153. package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.js +0 -7
  154. package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.d.ts +0 -5
  155. package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.js +0 -7
  156. package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.d.ts +0 -5
  157. package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.js +0 -18
  158. package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.d.ts +0 -4
  159. package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.js +0 -13
  160. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.d.ts +0 -7
  161. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.js +0 -18
  162. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.d.ts +0 -7
  163. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.js +0 -37
  164. package/es/components/organism/TextEditor/ui/Toolbar/actions/HighlightAction.d.ts +0 -5
  165. package/es/components/organism/TextEditor/ui/Toolbar/actions/HighlightAction.js +0 -7
  166. package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.d.ts +0 -5
  167. package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.js +0 -7
  168. package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.d.ts +0 -5
  169. package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.js +0 -7
  170. package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.d.ts +0 -6
  171. package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.js +0 -4
  172. package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.d.ts +0 -5
  173. package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.js +0 -7
  174. package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.d.ts +0 -5
  175. package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.js +0 -7
  176. package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.d.ts +0 -7
  177. package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.js +0 -9
  178. package/es/components/organism/TextEditor/ui/Toolbar/actions/SpacingAction.d.ts +0 -9
  179. package/es/components/organism/TextEditor/ui/Toolbar/actions/SpacingAction.js +0 -22
  180. package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.d.ts +0 -5
  181. package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.js +0 -7
  182. package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.d.ts +0 -5
  183. package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.js +0 -13
  184. package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.d.ts +0 -5
  185. package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.js +0 -13
  186. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.d.ts +0 -5
  187. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.js +0 -3
  188. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.d.ts +0 -7
  189. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.js +0 -19
  190. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.d.ts +0 -15
  191. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.js +0 -14
  192. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.d.ts +0 -5
  193. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.js +0 -30
  194. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.d.ts +0 -5
  195. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.js +0 -5
  196. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.d.ts +0 -6
  197. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.js +0 -10
  198. package/es/components/organism/TextEditor/ui/Toolbar/actions/index.d.ts +0 -20
  199. package/es/components/organism/TextEditor/ui/Toolbar/actions/index.js +0 -20
  200. package/es/components/organism/TextEditor/ui/Toolbar/index.d.ts +0 -1
  201. package/es/components/organism/TextEditor/ui/Toolbar/index.js +0 -1
  202. package/es/components/organism/TextEditor/utils/documentState.d.ts +0 -57
  203. package/es/components/organism/TextEditor/utils/documentState.js +0 -100
  204. package/es/components/organism/TextEditor/utils/font.d.ts +0 -84
  205. package/es/components/organism/TextEditor/utils/font.js +0 -175
  206. package/es/components/organism/TextEditor/utils/htmlProcessing.d.ts +0 -63
  207. package/es/components/organism/TextEditor/utils/htmlProcessing.js +0 -321
  208. package/es/components/organism/TextEditor/utils/index.d.ts +0 -8
  209. package/es/components/organism/TextEditor/utils/index.js +0 -16
  210. package/es/components/organism/TextEditor/utils/link.d.ts +0 -100
  211. package/es/components/organism/TextEditor/utils/link.js +0 -149
  212. package/es/components/organism/TextEditor/utils/menu.d.ts +0 -134
  213. package/es/components/organism/TextEditor/utils/menu.js +0 -317
  214. package/es/components/organism/TextEditor/utils/selection.d.ts +0 -25
  215. package/es/components/organism/TextEditor/utils/selection.js +0 -57
  216. package/es/components/organism/TextEditor/utils/smartTag.d.ts +0 -49
  217. package/es/components/organism/TextEditor/utils/smartTag.js +0 -89
  218. package/es/components/organism/TextEditor/utils/style.d.ts +0 -78
  219. package/es/components/organism/TextEditor/utils/style.js +0 -193
  220. package/es/components/organism/index.scss +0 -1
  221. package/es/hooks/useBroadcastedLocalStorage.d.ts +0 -5
  222. package/es/hooks/useBroadcastedLocalStorage.js +0 -71
  223. package/es/hooks/useElementSize.d.ts +0 -7
  224. package/es/hooks/useElementSize.js +0 -56
  225. package/es/utils/tree.d.ts +0 -225
  226. package/es/utils/tree.js +0 -469
@@ -1,167 +0,0 @@
1
- import { Node, mergeAttributes } from '@tiptap/core';
2
- import { Plugin, PluginKey } from '@tiptap/pm/state';
3
- import { Decoration, DecorationSet } from '@tiptap/pm/view';
4
- export const EXTENSION_NAME = 'smartTag';
5
- /**
6
- * Creates decorations for all SmartTag nodes in the document
7
- * @param doc - The ProseMirror document
8
- * @param highlight - Whether to highlight the SmartTags
9
- * @returns A DecorationSet containing decorations for all SmartTag nodes
10
- */
11
- function createSmartTagDecorations(doc, highlight) {
12
- const decorations = [];
13
- if (!highlight) {
14
- return DecorationSet.create(doc, decorations);
15
- }
16
- // Find all SmartTag nodes and create decorations for them
17
- doc.descendants((node, pos) => {
18
- if (node.type.name === EXTENSION_NAME) {
19
- // Create a node decoration that adds the highlight class
20
- decorations.push(Decoration.node(pos, pos + node.nodeSize, {
21
- class: 'highlight',
22
- }));
23
- }
24
- });
25
- return DecorationSet.create(doc, decorations);
26
- }
27
- /**
28
- * Represents a dynamic tag node in the editor.
29
- */
30
- export const SmartTag = Node.create({
31
- name: EXTENSION_NAME,
32
- group: 'inline',
33
- atom: true,
34
- inline: true,
35
- selectable: true,
36
- addStorage() {
37
- return {
38
- highlight: this.options.highlight,
39
- };
40
- },
41
- addOptions() {
42
- return {
43
- HTMLAttributes: {},
44
- highlight: true,
45
- };
46
- },
47
- addAttributes() {
48
- return {
49
- id: {
50
- default: '',
51
- parseHTML: el => el.getAttribute('data-dynamic-id'),
52
- },
53
- content: {
54
- default: '',
55
- parseHTML: el => el.innerText,
56
- },
57
- tag: {
58
- default: null,
59
- parseHTML: el => el.getAttribute('tag'),
60
- renderHTML: attrs => (attrs.tag ? { tag: attrs.tag } : null),
61
- },
62
- };
63
- },
64
- parseHTML() {
65
- return [
66
- {
67
- tag: 'span[data-dynamic="true"]',
68
- priority: 1000,
69
- getAttrs: node => node.getAttribute('data-dynamic') === 'true' && null,
70
- },
71
- ];
72
- },
73
- renderHTML({ node }) {
74
- return [
75
- 'span',
76
- mergeAttributes(this.options.HTMLAttributes, {
77
- 'data-dynamic': 'true',
78
- 'data-dynamic-id': node.attrs.id,
79
- class: 'smart-tag',
80
- }),
81
- node.attrs.content,
82
- ];
83
- },
84
- renderText({ node }) {
85
- return node.attrs.content;
86
- },
87
- addCommands() {
88
- return {
89
- setSmartTag: attrs => ({ chain, state }) => {
90
- const { selection, storedMarks } = state;
91
- const { $from } = selection;
92
- const marks = storedMarks || $from.marks();
93
- const smartTagNode = this.type.create(attrs);
94
- const nodeWithMarks = marks.length > 0 ? smartTagNode.mark(marks) : smartTagNode;
95
- return chain()
96
- .command(({ tr }) => {
97
- tr.replaceSelectionWith(nodeWithMarks, false);
98
- return true;
99
- })
100
- .run();
101
- },
102
- deleteSmartTagGlobally: predicate => ({ tr, state }) => {
103
- let hasDeleted = false;
104
- const { doc } = state;
105
- doc.descendants((node, pos) => {
106
- if (node.type.name === this.name && predicate(node.attrs)) {
107
- tr.delete(pos, pos + node.nodeSize);
108
- hasDeleted = true;
109
- }
110
- });
111
- return hasDeleted;
112
- },
113
- updateSmartTagAttrsGlobally: updateFn => ({ tr, state }) => {
114
- let hasUpdated = false;
115
- const { doc } = state;
116
- doc.descendants((node, pos) => {
117
- if (node.type.name === this.name) {
118
- const updatedAttrs = updateFn(node.attrs);
119
- if (updatedAttrs) {
120
- tr.setNodeMarkup(pos, undefined, {
121
- ...node.attrs,
122
- ...updatedAttrs,
123
- });
124
- hasUpdated = true;
125
- }
126
- }
127
- });
128
- return hasUpdated;
129
- },
130
- updateSmartTagHighlight: (enabled) => ({ tr }) => {
131
- // Update the storage value
132
- this.storage.highlight = enabled;
133
- // Set metadata on the transaction to trigger the plugin to update decorations
134
- tr.setMeta('updateSmartTagHighlight', { highlight: enabled });
135
- return true;
136
- },
137
- };
138
- },
139
- addProseMirrorPlugins() {
140
- return [
141
- new Plugin({
142
- key: new PluginKey(`${EXTENSION_NAME}_highlight`),
143
- // Initialize the plugin state with decorations based on the initial highlight value
144
- state: {
145
- init: (_, { doc }) => createSmartTagDecorations(doc, this.storage.highlight),
146
- // Update the decorations when the document changes or when the highlight value changes
147
- apply: (tr, oldDecorations) => {
148
- // Check if the highlight value has changed
149
- const highlightMeta = tr.getMeta('updateSmartTagHighlight');
150
- // If the document has changed or the highlight value has changed, update the decorations
151
- if (tr.docChanged || highlightMeta !== undefined) {
152
- return createSmartTagDecorations(tr.doc, this.storage.highlight);
153
- }
154
- // Otherwise, map the old decorations through the transaction
155
- return oldDecorations.map(tr.mapping, tr.doc);
156
- },
157
- },
158
- // Provide the decorations to the editor view
159
- props: {
160
- decorations(state) {
161
- return this.getState(state);
162
- },
163
- },
164
- }),
165
- ];
166
- },
167
- });
@@ -1,36 +0,0 @@
1
- import { Extension } from '@tiptap/core';
2
- import { Mark } from '@tiptap/pm/model';
3
- import { DocumentStateConfig } from '../utils/documentState';
4
- export interface StyleMemoryOptions {
5
- /**
6
- * Marks to exclude from being stored
7
- * @default ['link', 'smartTag']
8
- */
9
- excludeMarks: string[];
10
- /**
11
- * Configuration for document emptiness detection
12
- */
13
- documentStateConfig?: DocumentStateConfig;
14
- }
15
- export interface StyleMemoryStorage {
16
- storedMarks: Mark[];
17
- }
18
- declare module '@tiptap/core' {
19
- interface Commands<ReturnType> {
20
- styleMemory: {
21
- /**
22
- * Manually store current marks
23
- */
24
- storeCurrentMarks: () => ReturnType;
25
- /**
26
- * Clear stored marks
27
- */
28
- clearStoredMarks: () => ReturnType;
29
- /**
30
- * Apply stored marks to current selection
31
- */
32
- applyStoredMarks: () => ReturnType;
33
- };
34
- }
35
- }
36
- export declare const StyleMemory: Extension<StyleMemoryOptions, StyleMemoryStorage>;
@@ -1,163 +0,0 @@
1
- import { Extension } from '@tiptap/core';
2
- import { Plugin, PluginKey } from '@tiptap/pm/state';
3
- import { isDocumentEmpty, DocumentStateTracker } from '../utils/documentState';
4
- export const StyleMemory = Extension.create({
5
- name: 'styleMemory',
6
- addOptions() {
7
- return {
8
- excludeMarks: ['link', 'smartTag'],
9
- documentStateConfig: {
10
- ignoreWhitespace: true,
11
- },
12
- };
13
- },
14
- addStorage() {
15
- return {
16
- storedMarks: [],
17
- };
18
- },
19
- addCommands() {
20
- return {
21
- storeCurrentMarks: () => ({ state }) => {
22
- const { selection, storedMarks } = state;
23
- const { $from } = selection;
24
- // Get marks from current position or stored marks
25
- const currentMarks = storedMarks || $from.marks();
26
- // Filter out excluded marks
27
- const filteredMarks = currentMarks.filter(mark => !this.options.excludeMarks.includes(mark.type.name));
28
- this.storage.storedMarks = filteredMarks;
29
- return true;
30
- },
31
- clearStoredMarks: () => () => {
32
- this.storage.storedMarks = [];
33
- return true;
34
- },
35
- applyStoredMarks: () => ({ commands }) => {
36
- if (this.storage.storedMarks.length === 0) {
37
- return true;
38
- }
39
- // Apply each stored mark
40
- this.storage.storedMarks.forEach(mark => {
41
- commands.setMark(mark.type.name, mark.attrs);
42
- });
43
- return true;
44
- },
45
- };
46
- },
47
- addProseMirrorPlugins() {
48
- const stateTracker = new DocumentStateTracker();
49
- return [
50
- new Plugin({
51
- key: new PluginKey('styleMemory'),
52
- state: {
53
- init: (_, initialState) => {
54
- const isEmpty = isDocumentEmpty(initialState, this.options.documentStateConfig);
55
- return {
56
- lastContentSize: initialState.doc.content.size,
57
- wasEmpty: isEmpty,
58
- };
59
- },
60
- apply: (tr, _oldState, _oldEditorState, newEditorState) => {
61
- const changes = stateTracker.update(newEditorState);
62
- const isEmpty = isDocumentEmpty(newEditorState, this.options.documentStateConfig);
63
- const hasContent = !isEmpty;
64
- // Store marks when content exists and user has selection with marks
65
- if (hasContent && tr.selection && !tr.selection.empty) {
66
- const { $from } = tr.selection;
67
- const marks = tr.storedMarks || $from.marks();
68
- if (marks.length > 0) {
69
- const filteredMarks = marks.filter(mark => !this.options.excludeMarks.includes(mark.type.name));
70
- if (filteredMarks.length > 0) {
71
- this.storage.storedMarks = filteredMarks;
72
- }
73
- }
74
- }
75
- // Also store marks when selection changes and we have marks
76
- if (hasContent && tr.selectionSet) {
77
- const { $from } = tr.selection;
78
- const marks = tr.storedMarks || $from.marks();
79
- if (marks.length > 0) {
80
- const filteredMarks = marks.filter(mark => !this.options.excludeMarks.includes(mark.type.name));
81
- if (filteredMarks.length > 0) {
82
- this.storage.storedMarks = filteredMarks;
83
- }
84
- }
85
- }
86
- // Apply stored marks when transitioning from empty to non-empty
87
- if (changes.becameNonEmpty && this.storage.storedMarks.length > 0) {
88
- // Set stored marks for the next input
89
- tr.setStoredMarks(this.storage.storedMarks);
90
- }
91
- return {
92
- lastContentSize: newEditorState.doc.content.size,
93
- wasEmpty: isEmpty,
94
- };
95
- },
96
- },
97
- appendTransaction: (transactions, oldState, newState) => {
98
- const wasEmpty = isDocumentEmpty(oldState, this.options.documentStateConfig);
99
- const hasContent = !isDocumentEmpty(newState, this.options.documentStateConfig);
100
- // Check if we need to restore marks after content was added to empty editor
101
- if (wasEmpty && hasContent && this.storage.storedMarks.length > 0) {
102
- const { tr } = newState;
103
- let hasChanges = false;
104
- // Find the newly added content
105
- let newContentStart = -1;
106
- let newContentEnd = -1;
107
- for (const transaction of transactions) {
108
- if (transaction.docChanged) {
109
- transaction.steps.forEach(step => {
110
- if ('from' in step &&
111
- 'to' in step &&
112
- typeof step.from === 'number' &&
113
- typeof step.to === 'number') {
114
- if (newContentStart === -1 || step.from < newContentStart) {
115
- newContentStart = step.from;
116
- }
117
- if (newContentEnd === -1 || step.to > newContentEnd) {
118
- newContentEnd = step.to;
119
- }
120
- }
121
- });
122
- }
123
- }
124
- // Apply stored marks to the new content if we found the range
125
- if (newContentStart !== -1 && newContentEnd !== -1) {
126
- this.storage.storedMarks.forEach(mark => {
127
- tr.addMark(newContentStart, newContentEnd, mark);
128
- hasChanges = true;
129
- });
130
- }
131
- // Also set stored marks for future typing
132
- if (this.storage.storedMarks.length > 0) {
133
- tr.setStoredMarks(this.storage.storedMarks);
134
- hasChanges = true;
135
- }
136
- if (hasChanges) {
137
- return tr;
138
- }
139
- }
140
- return null;
141
- },
142
- // Handle view updates for better mark application
143
- view: () => ({
144
- update: (view, prevState) => {
145
- const prevEmpty = isDocumentEmpty(prevState, this.options.documentStateConfig);
146
- const currentEmpty = isDocumentEmpty(view.state, this.options.documentStateConfig);
147
- // When transitioning from empty to non-empty, ensure stored marks are applied
148
- if (prevEmpty && !currentEmpty && this.storage.storedMarks.length > 0) {
149
- // Use setTimeout to ensure this runs after the current transaction
150
- setTimeout(() => {
151
- const { state, dispatch } = view;
152
- const { tr } = state;
153
- // Set stored marks for the current position
154
- tr.setStoredMarks(this.storage.storedMarks);
155
- dispatch(tr);
156
- }, 0);
157
- }
158
- },
159
- }),
160
- }),
161
- ];
162
- },
163
- });
@@ -1,31 +0,0 @@
1
- import '@tiptap/extension-text-style';
2
- import { Extension } from '@tiptap/core';
3
- export type TextTransformOptions = {
4
- /**
5
- * A list of node names where the text transform can be applied.
6
- * @default ['textStyle']
7
- * @example ['heading', 'paragraph']
8
- */
9
- types: string[];
10
- };
11
- declare module '@tiptap/core' {
12
- interface Commands<ReturnType> {
13
- textTransform: {
14
- /**
15
- * Set the text transform
16
- * @param textTransform The text transform
17
- * @example editor.commands.setTextTransform('uppercase')
18
- */
19
- setTextTransform: (textTransform: string) => ReturnType;
20
- /**
21
- * Unset the text transform
22
- * @example editor.commands.unsetTextTransform()
23
- */
24
- unsetTextTransform: () => ReturnType;
25
- };
26
- }
27
- }
28
- /**
29
- * This extension allows you to set a text transform for text.
30
- */
31
- export declare const TextTransform: Extension<TextTransformOptions, any>;
@@ -1,37 +0,0 @@
1
- import '@tiptap/extension-text-style';
2
- import { Extension } from '@tiptap/core';
3
- /**
4
- * This extension allows you to set a text transform for text.
5
- */
6
- export const TextTransform = Extension.create({
7
- name: 'textTransform',
8
- addOptions() {
9
- return {
10
- types: ['textStyle'],
11
- };
12
- },
13
- addGlobalAttributes() {
14
- return [
15
- {
16
- types: this.options.types,
17
- attributes: {
18
- textTransform: {
19
- default: null,
20
- renderHTML: attrs => attrs.textTransform && attrs.textTransform !== 'none'
21
- ? {
22
- style: `text-transform: ${attrs.textTransform}`,
23
- }
24
- : {},
25
- parseHTML: element => element.style.textTransform,
26
- },
27
- },
28
- },
29
- ];
30
- },
31
- addCommands() {
32
- return {
33
- setTextTransform: textTransform => ({ chain }) => chain().setMark('textStyle', { textTransform }).run(),
34
- unsetTextTransform: () => ({ chain }) => chain().setMark('textStyle', { textTransform: 'none' }).removeEmptyTextStyle().run(),
35
- };
36
- },
37
- });
@@ -1,6 +0,0 @@
1
- export * from './usePersistence';
2
- export * from './useLinkHandler';
3
- export * from './useMarkTracking';
4
- export * from './useStyleMemory';
5
- export * from './useStylePresets';
6
- export * from './useDocumentState';
@@ -1,6 +0,0 @@
1
- export * from './usePersistence';
2
- export * from './useLinkHandler';
3
- export * from './useMarkTracking';
4
- export * from './useStyleMemory';
5
- export * from './useStylePresets';
6
- export * from './useDocumentState';
@@ -1,18 +0,0 @@
1
- import { Editor } from '@tiptap/react';
2
- import { DocumentStateConfig, getDocumentStats } from '../utils/documentState';
3
- export interface UseDocumentStateOptions extends DocumentStateConfig {
4
- /** Callback when document becomes empty */
5
- onBecomeEmpty?: () => void;
6
- /** Callback when document becomes non-empty */
7
- onBecomeNonEmpty?: () => void;
8
- /** Callback when document state changes */
9
- onStateChange?: (stats: ReturnType<typeof getDocumentStats>) => void;
10
- }
11
- export declare function useDocumentState(editor: Editor | null, options?: UseDocumentStateOptions): {
12
- nodeSize: number;
13
- textLength: number;
14
- trimmedTextLength: number;
15
- nodeCount: void;
16
- isEmpty: boolean;
17
- emptyDocumentSize: number;
18
- } | null;
@@ -1,42 +0,0 @@
1
- import { useCallback, useEffect, useRef, useState } from 'react';
2
- import { DocumentStateTracker, getDocumentStats, } from '../utils/documentState';
3
- export function useDocumentState(editor, options = {}) {
4
- const { onBecomeEmpty, onBecomeNonEmpty, onStateChange } = options;
5
- const [documentStats, setDocumentStats] = useState(() => editor ? getDocumentStats(editor.state) : null);
6
- const trackerRef = useRef(new DocumentStateTracker());
7
- const updateDocumentState = useCallback(() => {
8
- if (!editor)
9
- return;
10
- const stats = getDocumentStats(editor.state);
11
- const changes = trackerRef.current.update(editor.state);
12
- setDocumentStats(stats);
13
- // Trigger callbacks
14
- if (changes.becameEmpty) {
15
- onBecomeEmpty?.();
16
- }
17
- if (changes.becameNonEmpty) {
18
- onBecomeNonEmpty?.();
19
- }
20
- if (changes.sizeChanged || changes.textLengthChanged) {
21
- onStateChange?.(stats);
22
- }
23
- }, [editor, onBecomeEmpty, onBecomeNonEmpty, onStateChange]);
24
- useEffect(() => {
25
- if (!editor)
26
- return;
27
- // Initial state
28
- updateDocumentState();
29
- // Listen to changes
30
- editor.on('update', updateDocumentState);
31
- editor.on('transaction', updateDocumentState);
32
- return () => {
33
- editor.off('update', updateDocumentState);
34
- editor.off('transaction', updateDocumentState);
35
- };
36
- }, [editor, updateDocumentState]);
37
- // Reset tracker when editor changes
38
- useEffect(() => {
39
- trackerRef.current.reset();
40
- }, [editor]);
41
- return documentStats;
42
- }
@@ -1,10 +0,0 @@
1
- import { Editor } from '@tiptap/react';
2
- import { Attrs } from '@tiptap/pm/model';
3
- export declare function useLinkHandler(params: {
4
- editor?: Editor | null;
5
- }): {
6
- setLink: (attrs: import("../extensions/Link").LinkAttrs) => void;
7
- deleteLink: (id: string) => void;
8
- unsetLink: () => void;
9
- updateLinkAttrsGlobally: (updateFn: (attrs: Attrs) => Attrs | undefined) => void;
10
- };