@doist/typist 9.0.3 → 10.0.0-next.2

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 (236) hide show
  1. package/dist/components/typist-editor.d.ts +126 -123
  2. package/dist/components/typist-editor.d.ts.map +1 -1
  3. package/dist/components/typist-editor.helper.d.ts +8 -11
  4. package/dist/components/typist-editor.helper.d.ts.map +1 -1
  5. package/dist/components/typist-editor.helper.js +21 -19
  6. package/dist/components/typist-editor.helper.js.map +1 -0
  7. package/dist/components/typist-editor.js +133 -135
  8. package/dist/components/typist-editor.js.map +1 -0
  9. package/dist/constants/common.js +9 -5
  10. package/dist/constants/common.js.map +1 -0
  11. package/dist/constants/extension-priorities.d.ts +3 -1
  12. package/dist/constants/extension-priorities.d.ts.map +1 -1
  13. package/dist/constants/extension-priorities.js +34 -30
  14. package/dist/constants/extension-priorities.js.map +1 -0
  15. package/dist/constants/regular-expressions.js +14 -10
  16. package/dist/constants/regular-expressions.js.map +1 -0
  17. package/dist/extensions/core/extra-editor-commands/commands/create-paragraph-end.d.ts +12 -9
  18. package/dist/extensions/core/extra-editor-commands/commands/create-paragraph-end.d.ts.map +1 -1
  19. package/dist/extensions/core/extra-editor-commands/commands/create-paragraph-end.js +16 -19
  20. package/dist/extensions/core/extra-editor-commands/commands/create-paragraph-end.js.map +1 -0
  21. package/dist/extensions/core/extra-editor-commands/commands/extend-word-range.d.ts +12 -9
  22. package/dist/extensions/core/extra-editor-commands/commands/extend-word-range.d.ts.map +1 -1
  23. package/dist/extensions/core/extra-editor-commands/commands/extend-word-range.js +25 -28
  24. package/dist/extensions/core/extra-editor-commands/commands/extend-word-range.js.map +1 -0
  25. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content-at.d.ts +24 -22
  26. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content-at.d.ts.map +1 -1
  27. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content-at.js +34 -36
  28. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content-at.js.map +1 -0
  29. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content.d.ts +23 -20
  30. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content.d.ts.map +1 -1
  31. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content.js +15 -8
  32. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content.js.map +1 -0
  33. package/dist/extensions/core/extra-editor-commands/extra-editor-commands.js +22 -18
  34. package/dist/extensions/core/extra-editor-commands/extra-editor-commands.js.map +1 -0
  35. package/dist/extensions/core/view-event-handlers.d.ts +14 -13
  36. package/dist/extensions/core/view-event-handlers.d.ts.map +1 -1
  37. package/dist/extensions/core/view-event-handlers.js +33 -31
  38. package/dist/extensions/core/view-event-handlers.js.map +1 -0
  39. package/dist/extensions/plain-text/paste-multiline-text.js +45 -59
  40. package/dist/extensions/plain-text/paste-multiline-text.js.map +1 -0
  41. package/dist/extensions/plain-text/plain-text-document.d.ts +7 -7
  42. package/dist/extensions/plain-text/plain-text-document.d.ts.map +1 -1
  43. package/dist/extensions/plain-text/plain-text-document.js +14 -13
  44. package/dist/extensions/plain-text/plain-text-document.js.map +1 -0
  45. package/dist/extensions/plain-text/plain-text-kit.d.ts +35 -33
  46. package/dist/extensions/plain-text/plain-text-kit.d.ts.map +1 -1
  47. package/dist/extensions/plain-text/plain-text-kit.js +33 -48
  48. package/dist/extensions/plain-text/plain-text-kit.js.map +1 -0
  49. package/dist/extensions/plain-text/plain-text-paragraph.d.ts +2 -9
  50. package/dist/extensions/plain-text/plain-text-paragraph.js +11 -11
  51. package/dist/extensions/plain-text/plain-text-paragraph.js.map +1 -0
  52. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-lists.js +37 -81
  53. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-lists.js.map +1 -0
  54. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-select-wrap.js +32 -42
  55. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-select-wrap.js.map +1 -0
  56. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-url-pasting.js +24 -37
  57. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-url-pasting.js.map +1 -0
  58. package/dist/extensions/plain-text/smart-markdown-typing/smart-markdown-typing.js +21 -13
  59. package/dist/extensions/plain-text/smart-markdown-typing/smart-markdown-typing.js.map +1 -0
  60. package/dist/extensions/rich-text/bold-and-italics.js +42 -40
  61. package/dist/extensions/rich-text/bold-and-italics.js.map +1 -0
  62. package/dist/extensions/rich-text/curvenote-codemark.js +16 -14
  63. package/dist/extensions/rich-text/curvenote-codemark.js.map +1 -0
  64. package/dist/extensions/rich-text/paste-emojis.js +20 -22
  65. package/dist/extensions/rich-text/paste-emojis.js.map +1 -0
  66. package/dist/extensions/rich-text/paste-markdown.js +46 -86
  67. package/dist/extensions/rich-text/paste-markdown.js.map +1 -0
  68. package/dist/extensions/rich-text/rich-text-bullet-list.d.ts +10 -9
  69. package/dist/extensions/rich-text/rich-text-bullet-list.d.ts.map +1 -1
  70. package/dist/extensions/rich-text/rich-text-bullet-list.js +42 -56
  71. package/dist/extensions/rich-text/rich-text-bullet-list.js.map +1 -0
  72. package/dist/extensions/rich-text/rich-text-code.js +34 -34
  73. package/dist/extensions/rich-text/rich-text-code.js.map +1 -0
  74. package/dist/extensions/rich-text/rich-text-document.d.ts +7 -7
  75. package/dist/extensions/rich-text/rich-text-document.d.ts.map +1 -1
  76. package/dist/extensions/rich-text/rich-text-document.js +14 -13
  77. package/dist/extensions/rich-text/rich-text-document.js.map +1 -0
  78. package/dist/extensions/rich-text/rich-text-heading.d.ts +5 -4
  79. package/dist/extensions/rich-text/rich-text-heading.d.ts.map +1 -1
  80. package/dist/extensions/rich-text/rich-text-heading.js +25 -25
  81. package/dist/extensions/rich-text/rich-text-heading.js.map +1 -0
  82. package/dist/extensions/rich-text/rich-text-image.d.ts +53 -52
  83. package/dist/extensions/rich-text/rich-text-image.d.ts.map +1 -1
  84. package/dist/extensions/rich-text/rich-text-image.js +88 -105
  85. package/dist/extensions/rich-text/rich-text-image.js.map +1 -0
  86. package/dist/extensions/rich-text/rich-text-kit.d.ts +127 -125
  87. package/dist/extensions/rich-text/rich-text-kit.d.ts.map +1 -1
  88. package/dist/extensions/rich-text/rich-text-kit.js +73 -135
  89. package/dist/extensions/rich-text/rich-text-kit.js.map +1 -0
  90. package/dist/extensions/rich-text/rich-text-link.d.ts +5 -4
  91. package/dist/extensions/rich-text/rich-text-link.d.ts.map +1 -1
  92. package/dist/extensions/rich-text/rich-text-link.js +82 -90
  93. package/dist/extensions/rich-text/rich-text-link.js.map +1 -0
  94. package/dist/extensions/rich-text/rich-text-ordered-list.d.ts +10 -9
  95. package/dist/extensions/rich-text/rich-text-ordered-list.d.ts.map +1 -1
  96. package/dist/extensions/rich-text/rich-text-ordered-list.js +42 -56
  97. package/dist/extensions/rich-text/rich-text-ordered-list.js.map +1 -0
  98. package/dist/extensions/rich-text/rich-text-strikethrough.d.ts +5 -4
  99. package/dist/extensions/rich-text/rich-text-strikethrough.d.ts.map +1 -1
  100. package/dist/extensions/rich-text/rich-text-strikethrough.js +10 -10
  101. package/dist/extensions/rich-text/rich-text-strikethrough.js.map +1 -0
  102. package/dist/extensions/shared/copy-markdown-source.js +22 -31
  103. package/dist/extensions/shared/copy-markdown-source.js.map +1 -0
  104. package/dist/extensions/shared/paste-html-table-as-string.js +47 -60
  105. package/dist/extensions/shared/paste-html-table-as-string.js.map +1 -0
  106. package/dist/extensions/shared/paste-singleline-text.js +31 -39
  107. package/dist/extensions/shared/paste-singleline-text.js.map +1 -0
  108. package/dist/factories/create-suggestion-extension.d.ts +74 -74
  109. package/dist/factories/create-suggestion-extension.d.ts.map +1 -1
  110. package/dist/factories/create-suggestion-extension.js +139 -161
  111. package/dist/factories/create-suggestion-extension.js.map +1 -0
  112. package/dist/helpers/dom.js +9 -5
  113. package/dist/helpers/dom.js.map +1 -0
  114. package/dist/helpers/schema.d.ts +5 -3
  115. package/dist/helpers/schema.d.ts.map +1 -1
  116. package/dist/helpers/schema.js +25 -21
  117. package/dist/helpers/schema.js.map +1 -0
  118. package/dist/helpers/serializer.js +24 -28
  119. package/dist/helpers/serializer.js.map +1 -0
  120. package/dist/helpers/unified.js +24 -17
  121. package/dist/helpers/unified.js.map +1 -0
  122. package/dist/hooks/use-editor.js +50 -53
  123. package/dist/hooks/use-editor.js.map +1 -0
  124. package/dist/index.d.ts +25 -31
  125. package/dist/index.js +24 -24
  126. package/dist/serializers/html/html.d.ts +12 -10
  127. package/dist/serializers/html/html.d.ts.map +1 -1
  128. package/dist/serializers/html/html.js +67 -127
  129. package/dist/serializers/html/html.js.map +1 -0
  130. package/dist/serializers/html/plugins/rehype-code-block.js +17 -17
  131. package/dist/serializers/html/plugins/rehype-code-block.js.map +1 -0
  132. package/dist/serializers/html/plugins/rehype-image.js +20 -30
  133. package/dist/serializers/html/plugins/rehype-image.js.map +1 -0
  134. package/dist/serializers/html/plugins/rehype-suggestions.js +31 -32
  135. package/dist/serializers/html/plugins/rehype-suggestions.js.map +1 -0
  136. package/dist/serializers/html/plugins/rehype-task-list.js +31 -32
  137. package/dist/serializers/html/plugins/rehype-task-list.js.map +1 -0
  138. package/dist/serializers/html/plugins/remark-autolink-literal.d.ts +4 -1
  139. package/dist/serializers/html/plugins/remark-autolink-literal.d.ts.map +1 -1
  140. package/dist/serializers/html/plugins/remark-autolink-literal.js +25 -21
  141. package/dist/serializers/html/plugins/remark-autolink-literal.js.map +1 -0
  142. package/dist/serializers/html/plugins/remark-disable-constructs.js +21 -41
  143. package/dist/serializers/html/plugins/remark-disable-constructs.js.map +1 -0
  144. package/dist/serializers/html/plugins/remark-strikethrough.d.ts +5 -2
  145. package/dist/serializers/html/plugins/remark-strikethrough.d.ts.map +1 -1
  146. package/dist/serializers/html/plugins/remark-strikethrough.js +25 -21
  147. package/dist/serializers/html/plugins/remark-strikethrough.js.map +1 -0
  148. package/dist/serializers/markdown/markdown.d.ts +13 -12
  149. package/dist/serializers/markdown/markdown.d.ts.map +1 -1
  150. package/dist/serializers/markdown/markdown.js +78 -154
  151. package/dist/serializers/markdown/markdown.js.map +1 -0
  152. package/dist/serializers/markdown/plugins/image.js +27 -24
  153. package/dist/serializers/markdown/plugins/image.js.map +1 -0
  154. package/dist/serializers/markdown/plugins/list-item.js +32 -37
  155. package/dist/serializers/markdown/plugins/list-item.js.map +1 -0
  156. package/dist/serializers/markdown/plugins/paragraph.js +19 -19
  157. package/dist/serializers/markdown/plugins/paragraph.js.map +1 -0
  158. package/dist/serializers/markdown/plugins/strikethrough.js +23 -19
  159. package/dist/serializers/markdown/plugins/strikethrough.js.map +1 -0
  160. package/dist/serializers/markdown/plugins/suggestion.js +21 -19
  161. package/dist/serializers/markdown/plugins/suggestion.js.map +1 -0
  162. package/dist/serializers/markdown/plugins/task-item.js +31 -35
  163. package/dist/serializers/markdown/plugins/task-item.js.map +1 -0
  164. package/dist/utilities/can-insert-node-at.d.ts +12 -5
  165. package/dist/utilities/can-insert-node-at.d.ts.map +1 -1
  166. package/dist/utilities/can-insert-node-at.js +10 -8
  167. package/dist/utilities/can-insert-node-at.js.map +1 -0
  168. package/dist/utilities/can-insert-suggestion.d.ts +11 -5
  169. package/dist/utilities/can-insert-suggestion.d.ts.map +1 -1
  170. package/dist/utilities/can-insert-suggestion.js +15 -12
  171. package/dist/utilities/can-insert-suggestion.js.map +1 -0
  172. package/package.json +26 -13
  173. package/dist/constants/common.d.ts +0 -10
  174. package/dist/constants/common.d.ts.map +0 -1
  175. package/dist/constants/regular-expressions.d.ts +0 -18
  176. package/dist/constants/regular-expressions.d.ts.map +0 -1
  177. package/dist/extensions/core/extra-editor-commands/extra-editor-commands.d.ts +0 -9
  178. package/dist/extensions/core/extra-editor-commands/extra-editor-commands.d.ts.map +0 -1
  179. package/dist/extensions/plain-text/paste-multiline-text.d.ts +0 -10
  180. package/dist/extensions/plain-text/paste-multiline-text.d.ts.map +0 -1
  181. package/dist/extensions/plain-text/plain-text-paragraph.d.ts.map +0 -1
  182. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-lists.d.ts +0 -9
  183. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-lists.d.ts.map +0 -1
  184. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-select-wrap.d.ts +0 -9
  185. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-select-wrap.d.ts.map +0 -1
  186. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-url-pasting.d.ts +0 -9
  187. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-url-pasting.d.ts.map +0 -1
  188. package/dist/extensions/plain-text/smart-markdown-typing/smart-markdown-typing.d.ts +0 -8
  189. package/dist/extensions/plain-text/smart-markdown-typing/smart-markdown-typing.d.ts.map +0 -1
  190. package/dist/extensions/rich-text/bold-and-italics.d.ts +0 -8
  191. package/dist/extensions/rich-text/bold-and-italics.d.ts.map +0 -1
  192. package/dist/extensions/rich-text/curvenote-codemark.d.ts +0 -11
  193. package/dist/extensions/rich-text/curvenote-codemark.d.ts.map +0 -1
  194. package/dist/extensions/rich-text/paste-emojis.d.ts +0 -9
  195. package/dist/extensions/rich-text/paste-emojis.d.ts.map +0 -1
  196. package/dist/extensions/rich-text/paste-markdown.d.ts +0 -11
  197. package/dist/extensions/rich-text/paste-markdown.d.ts.map +0 -1
  198. package/dist/extensions/rich-text/rich-text-code.d.ts +0 -17
  199. package/dist/extensions/rich-text/rich-text-code.d.ts.map +0 -1
  200. package/dist/extensions/shared/copy-markdown-source.d.ts +0 -20
  201. package/dist/extensions/shared/copy-markdown-source.d.ts.map +0 -1
  202. package/dist/extensions/shared/paste-html-table-as-string.d.ts +0 -20
  203. package/dist/extensions/shared/paste-html-table-as-string.d.ts.map +0 -1
  204. package/dist/extensions/shared/paste-singleline-text.d.ts +0 -10
  205. package/dist/extensions/shared/paste-singleline-text.d.ts.map +0 -1
  206. package/dist/helpers/dom.d.ts +0 -8
  207. package/dist/helpers/dom.d.ts.map +0 -1
  208. package/dist/helpers/serializer.d.ts +0 -21
  209. package/dist/helpers/serializer.d.ts.map +0 -1
  210. package/dist/helpers/unified.d.ts +0 -21
  211. package/dist/helpers/unified.d.ts.map +0 -1
  212. package/dist/hooks/use-editor.d.ts +0 -19
  213. package/dist/hooks/use-editor.d.ts.map +0 -1
  214. package/dist/index.d.ts.map +0 -1
  215. package/dist/serializers/html/plugins/rehype-code-block.d.ts +0 -10
  216. package/dist/serializers/html/plugins/rehype-code-block.d.ts.map +0 -1
  217. package/dist/serializers/html/plugins/rehype-image.d.ts +0 -11
  218. package/dist/serializers/html/plugins/rehype-image.d.ts.map +0 -1
  219. package/dist/serializers/html/plugins/rehype-suggestions.d.ts +0 -10
  220. package/dist/serializers/html/plugins/rehype-suggestions.d.ts.map +0 -1
  221. package/dist/serializers/html/plugins/rehype-task-list.d.ts +0 -7
  222. package/dist/serializers/html/plugins/rehype-task-list.d.ts.map +0 -1
  223. package/dist/serializers/html/plugins/remark-disable-constructs.d.ts +0 -11
  224. package/dist/serializers/html/plugins/remark-disable-constructs.d.ts.map +0 -1
  225. package/dist/serializers/markdown/plugins/image.d.ts +0 -12
  226. package/dist/serializers/markdown/plugins/image.d.ts.map +0 -1
  227. package/dist/serializers/markdown/plugins/list-item.d.ts +0 -14
  228. package/dist/serializers/markdown/plugins/list-item.d.ts.map +0 -1
  229. package/dist/serializers/markdown/plugins/paragraph.d.ts +0 -13
  230. package/dist/serializers/markdown/plugins/paragraph.d.ts.map +0 -1
  231. package/dist/serializers/markdown/plugins/strikethrough.d.ts +0 -13
  232. package/dist/serializers/markdown/plugins/strikethrough.d.ts.map +0 -1
  233. package/dist/serializers/markdown/plugins/suggestion.d.ts +0 -11
  234. package/dist/serializers/markdown/plugins/suggestion.d.ts.map +0 -1
  235. package/dist/serializers/markdown/plugins/task-item.d.ts +0 -14
  236. package/dist/serializers/markdown/plugins/task-item.d.ts.map +0 -1
@@ -1,24 +1,27 @@
1
- import { ViewEventHandlersOptions } from '../extensions/core/view-event-handlers';
2
- import { getAllNodesAttributesByType } from './typist-editor.helper';
3
- import type { Editor as CoreEditor, EditorEvents, Extensions } from '@tiptap/core';
4
- import type { Selection } from '@tiptap/pm/state';
1
+ import { ViewEventHandlersOptions } from "../extensions/core/view-event-handlers.js";
2
+ import { getAllNodesAttributesByType } from "./typist-editor.helper.js";
3
+ import * as react from "react";
4
+ import { Editor, EditorEvents, Extensions } from "@tiptap/core";
5
+ import { Selection } from "@tiptap/pm/state";
6
+
7
+ //#region src/components/typist-editor.d.ts
5
8
  /**
6
9
  * The forwarded ref that describes the helper methods that the `TypistEditor` parent component
7
10
  * will have access to.
8
11
  */
9
12
  type TypistEditorRef = {
10
- /**
11
- * Returns the `Editor` instance associated to the `TypistEditor` component.
12
- */
13
- getEditor: () => CoreEditor;
14
- /**
15
- * Returns the current editor document output as Markdown.
16
- */
17
- getMarkdown: () => string;
18
- /**
19
- * Returns the attributes of a given node type for all the nodes in the editor document.
20
- */
21
- getAllNodesAttributesByType: (nodeType: string) => ReturnType<typeof getAllNodesAttributesByType>;
13
+ /**
14
+ * Returns the `Editor` instance associated to the `TypistEditor` component.
15
+ */
16
+ getEditor: () => Editor;
17
+ /**
18
+ * Returns the current editor document output as Markdown.
19
+ */
20
+ getMarkdown: () => string;
21
+ /**
22
+ * Returns the attributes of a given node type for all the nodes in the editor document.
23
+ */
24
+ getAllNodesAttributesByType: (nodeType: string) => ReturnType<typeof getAllNodesAttributesByType>;
22
25
  };
23
26
  /**
24
27
  * The properties that describe the `beforeCreate` editor event.
@@ -57,116 +60,116 @@ type DestroyProps = EditorEvents['destroy'];
57
60
  * the supported WAI-ARIA 1.1 attributes.
58
61
  */
59
62
  type TypistEditorProps = {
60
- /**
61
- * Auto focus the editor to the end of the document on initialization.
62
- */
63
- autoFocus?: boolean;
64
- /**
65
- * The CSS class for the container surrounding the editor DOM element.
66
- */
67
- className?: string;
68
- /**
69
- * The initial Markdown content for the editor.
70
- */
71
- content?: string;
72
- /**
73
- * The initial content selection (only applied if `autoFocus` is `true`).
74
- */
75
- contentSelection?: Selection;
76
- /**
77
- * Determines if users can write into the editor.
78
- */
79
- editable?: boolean;
80
- /**
81
- * The list of required extensions to initialize the editor.
82
- *
83
- * You may consider wrapping this prop with `useMemo` to prevent unnecessary re-renders.
84
- */
85
- extensions: Extensions;
86
- /**
87
- * A short hint that gives users an idea what can be entered in the editor.
88
- */
89
- placeholder?: string;
90
- /**
91
- * The event handler that is fired before the editor view is created.
92
- *
93
- * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders.
94
- */
95
- onBeforeCreate?: (props: BeforeCreateProps) => void;
96
- /**
97
- * The event handler that is fired when the editor view is ready.
98
- *
99
- * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders.
100
- */
101
- onCreate?: (props: CreateProps) => void;
102
- /**
103
- * The event handler that is fired when the editor content has changed.
104
- *
105
- * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders.
106
- */
107
- onUpdate?: (props: UpdateProps) => void;
108
- /**
109
- * The event handler that is fired when the editor selection has changed.
110
- *
111
- * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders.
112
- */
113
- onSelectionUpdate?: (props: SelectionUpdateProps) => void;
114
- /**
115
- * The event handler that is fired when the editor state has changed.
116
- *
117
- * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders.
118
- */
119
- onTransaction?: (props: TransacationProps) => void;
120
- /**
121
- * The event handler that is fired when the editor view gains focus.
122
- *
123
- * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders.
124
- */
125
- onFocus?: (props: FocusProps) => void;
126
- /**
127
- * The event handler that is fired when the editor view loses focus.
128
- *
129
- * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders.
130
- */
131
- onBlur?: (props: BlurProps) => void;
132
- /**
133
- * The event handler that is fired when the editor view is being destroyed.
134
- *
135
- * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders.
136
- */
137
- onDestroy?: (props: DestroyProps) => void;
138
- /**
139
- * Identifies the element (or elements) that describes the object.
140
- *
141
- * @see aria-labelledby
142
- */
143
- 'aria-describedby'?: React.AriaAttributes['aria-describedby'];
144
- /**
145
- * Defines a string value that labels the current element.
146
- *
147
- * @see aria-labelledby.
148
- */
149
- 'aria-label'?: React.AriaAttributes['aria-label'];
150
- /**
151
- * Identifies the element (or elements) that labels the current element.
152
- *
153
- * @see aria-describedby.
154
- */
155
- 'aria-labelledby'?: React.AriaAttributes['aria-labelledby'];
156
- /**
157
- * The event handler that processes `click` events in the editor.
158
- */
159
- onClick?: ViewEventHandlersOptions['onClick'];
160
- /**
161
- * The event handler that processes `keydown` events in the editor.
162
- */
163
- onKeyDown?: ViewEventHandlersOptions['onKeyDown'];
63
+ /**
64
+ * Auto focus the editor to the end of the document on initialization.
65
+ */
66
+ autoFocus?: boolean;
67
+ /**
68
+ * The CSS class for the container surrounding the editor DOM element.
69
+ */
70
+ className?: string;
71
+ /**
72
+ * The initial Markdown content for the editor.
73
+ */
74
+ content?: string;
75
+ /**
76
+ * The initial content selection (only applied if `autoFocus` is `true`).
77
+ */
78
+ contentSelection?: Selection;
79
+ /**
80
+ * Determines if users can write into the editor.
81
+ */
82
+ editable?: boolean;
83
+ /**
84
+ * The list of required extensions to initialize the editor.
85
+ *
86
+ * You may consider wrapping this prop with `useMemo` to prevent unnecessary re-renders.
87
+ */
88
+ extensions: Extensions;
89
+ /**
90
+ * A short hint that gives users an idea what can be entered in the editor.
91
+ */
92
+ placeholder?: string;
93
+ /**
94
+ * The event handler that is fired before the editor view is created.
95
+ *
96
+ * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders.
97
+ */
98
+ onBeforeCreate?: (props: BeforeCreateProps) => void;
99
+ /**
100
+ * The event handler that is fired when the editor view is ready.
101
+ *
102
+ * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders.
103
+ */
104
+ onCreate?: (props: CreateProps) => void;
105
+ /**
106
+ * The event handler that is fired when the editor content has changed.
107
+ *
108
+ * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders.
109
+ */
110
+ onUpdate?: (props: UpdateProps) => void;
111
+ /**
112
+ * The event handler that is fired when the editor selection has changed.
113
+ *
114
+ * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders.
115
+ */
116
+ onSelectionUpdate?: (props: SelectionUpdateProps) => void;
117
+ /**
118
+ * The event handler that is fired when the editor state has changed.
119
+ *
120
+ * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders.
121
+ */
122
+ onTransaction?: (props: TransacationProps) => void;
123
+ /**
124
+ * The event handler that is fired when the editor view gains focus.
125
+ *
126
+ * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders.
127
+ */
128
+ onFocus?: (props: FocusProps) => void;
129
+ /**
130
+ * The event handler that is fired when the editor view loses focus.
131
+ *
132
+ * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders.
133
+ */
134
+ onBlur?: (props: BlurProps) => void;
135
+ /**
136
+ * The event handler that is fired when the editor view is being destroyed.
137
+ *
138
+ * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders.
139
+ */
140
+ onDestroy?: (props: DestroyProps) => void;
141
+ /**
142
+ * Identifies the element (or elements) that describes the object.
143
+ *
144
+ * @see aria-labelledby
145
+ */
146
+ 'aria-describedby'?: React.AriaAttributes['aria-describedby'];
147
+ /**
148
+ * Defines a string value that labels the current element.
149
+ *
150
+ * @see aria-labelledby.
151
+ */
152
+ 'aria-label'?: React.AriaAttributes['aria-label'];
153
+ /**
154
+ * Identifies the element (or elements) that labels the current element.
155
+ *
156
+ * @see aria-describedby.
157
+ */
158
+ 'aria-labelledby'?: React.AriaAttributes['aria-labelledby'];
159
+ /**
160
+ * The event handler that processes `click` events in the editor.
161
+ */
162
+ onClick?: ViewEventHandlersOptions['onClick'];
163
+ /**
164
+ * The event handler that processes `keydown` events in the editor.
165
+ */
166
+ onKeyDown?: ViewEventHandlersOptions['onKeyDown'];
164
167
  };
165
168
  /**
166
169
  * The `TypistEditor` component represents a plain-text or a rich-text editing control, built on
167
170
  * top of the amazing [Tiptap](https://tiptap.dev/) library.
168
171
  */
169
- declare const TypistEditor: import("react").ForwardRefExoticComponent<TypistEditorProps & import("react").RefAttributes<TypistEditorRef>>;
170
- export { TypistEditor };
171
- export type { BeforeCreateProps, BlurProps, CreateProps, DestroyProps, FocusProps, SelectionUpdateProps, TransacationProps, TypistEditorProps, TypistEditorRef, UpdateProps, };
172
+ declare const TypistEditor: react.ForwardRefExoticComponent<TypistEditorProps & react.RefAttributes<TypistEditorRef>>;
173
+ //#endregion
174
+ export { type BeforeCreateProps, type BlurProps, type CreateProps, type DestroyProps, type FocusProps, type SelectionUpdateProps, type TransacationProps, TypistEditor, type TypistEditorProps, type TypistEditorRef, type UpdateProps };
172
175
  //# sourceMappingURL=typist-editor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"typist-editor.d.ts","sourceRoot":"","sources":["../../src/components/typist-editor.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAqB,wBAAwB,EAAE,MAAM,wCAAwC,CAAA;AAMpG,OAAO,EAAE,2BAA2B,EAA2B,MAAM,wBAAwB,CAAA;AAE7F,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAClF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAEjD;;;GAGG;AACH,KAAK,eAAe,GAAG;IACnB;;OAEG;IACH,SAAS,EAAE,MAAM,UAAU,CAAA;IAE3B;;OAEG;IACH,WAAW,EAAE,MAAM,MAAM,CAAA;IAEzB;;OAEG;IACH,2BAA2B,EAAE,CACzB,QAAQ,EAAE,MAAM,KACf,UAAU,CAAC,OAAO,2BAA2B,CAAC,CAAA;CACtD,CAAA;AAED;;GAEG;AACH,KAAK,iBAAiB,GAAG,YAAY,CAAC,cAAc,CAAC,CAAA;AAErD;;GAEG;AACH,KAAK,WAA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@tiptap/pm/model';
3
- /**
4
- * Given a ProseMirror document, and a selection, resolves that selection within the bounds of the
5
- * document size. This works similarly to the official `autoFocus` implementation.
6
- */
7
- declare function resolveContentSelection(doc: ProseMirrorNode, selection: Selection): Selection;
1
+ import { Selection } from "@tiptap/pm/state";
2
+ import { Node } from "@tiptap/pm/model";
3
+
4
+ //#region src/components/typist-editor.helper.d.ts
8
5
  /**
9
6
  * The return type for the node attributes, an object mapping attribute names to values.
10
7
  */
11
8
  type NodeAttributes = {
12
- [key: string]: unknown;
9
+ [key: string]: unknown;
13
10
  };
14
11
  /**
15
12
  * Given a ProseMirror document and a node type, returns the attributes of the given node type for
16
13
  * all the nodes in the document. This is based on the official implementation for the
17
14
  * `findChildren` helper function.
18
15
  */
19
- declare function getAllNodesAttributesByType(doc: ProseMirrorNode, nodeType: string): Array<NodeAttributes>;
20
- export { getAllNodesAttributesByType, resolveContentSelection };
21
- export type { NodeAttributes };
16
+ declare function getAllNodesAttributesByType(doc: Node, nodeType: string): Array<NodeAttributes>;
17
+ //#endregion
18
+ export { getAllNodesAttributesByType };
22
19
  //# sourceMappingURL=typist-editor.helper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"typist-editor.helper.d.ts","sourceRoot":"","sources":["../../src/components/typist-editor.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAiB,MAAM,kBAAkB,CAAA;AAG3D,OAAO,KAAK,EAAE,IAAI,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAE/D;;;GAGG;AACH,iBAAS,uBAAuB,CAAC,GAAG,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,GAAG,SAAS,CAStF;AAED;;GAEG;AACH,KAAK,cAAc,GAAG;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACzB,CAAA;AAED;;;;GAIG;AACH,iBAAS,2BAA2B,CAChC,GAAG,EAAE,eAAe,EACpB,QAAQ,EAAE,MAAM,GACjB,KAAK,CAAC,cAAc,CAAC,CAUvB;AAED,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,CAAA;AAE/D,YAAY,EAAE,cAAc,EAAE,CAAA"}
1
+ {"version":3,"file":"typist-editor.helper.d.ts","names":[],"sources":["../../src/components/typist-editor.helper.ts"],"mappings":";;;;;;AAwBgB;KADX,cAAA;EAAA,CACA,GAAA;AAAA;;;;;;iBAQI,2BAAA,CACL,GAAA,EAAK,IAAA,EACL,QAAA,WACD,KAAA,CAAM,cAAA"}
@@ -1,26 +1,28 @@
1
- import { Selection, TextSelection } from '@tiptap/pm/state';
2
- import { clamp } from 'lodash-es';
1
+ import { Selection, TextSelection } from "@tiptap/pm/state";
2
+ import { clamp } from "lodash-es";
3
+ //#region src/components/typist-editor.helper.ts
3
4
  /**
4
- * Given a ProseMirror document, and a selection, resolves that selection within the bounds of the
5
- * document size. This works similarly to the official `autoFocus` implementation.
6
- */
5
+ * Given a ProseMirror document, and a selection, resolves that selection within the bounds of the
6
+ * document size. This works similarly to the official `autoFocus` implementation.
7
+ */
7
8
  function resolveContentSelection(doc, selection) {
8
- const minPos = Selection.atStart(doc).from;
9
- const maxPos = Selection.atEnd(doc).to;
10
- return TextSelection.create(doc, clamp(selection.anchor, minPos, maxPos), clamp(selection.head, minPos, maxPos));
9
+ const minPos = Selection.atStart(doc).from;
10
+ const maxPos = Selection.atEnd(doc).to;
11
+ return TextSelection.create(doc, clamp(selection.anchor, minPos, maxPos), clamp(selection.head, minPos, maxPos));
11
12
  }
12
13
  /**
13
- * Given a ProseMirror document and a node type, returns the attributes of the given node type for
14
- * all the nodes in the document. This is based on the official implementation for the
15
- * `findChildren` helper function.
16
- */
14
+ * Given a ProseMirror document and a node type, returns the attributes of the given node type for
15
+ * all the nodes in the document. This is based on the official implementation for the
16
+ * `findChildren` helper function.
17
+ */
17
18
  function getAllNodesAttributesByType(doc, nodeType) {
18
- const result = [];
19
- doc.descendants((node) => {
20
- if (node.type.name === nodeType) {
21
- result.push(node.attrs);
22
- }
23
- });
24
- return result;
19
+ const result = [];
20
+ doc.descendants((node) => {
21
+ if (node.type.name === nodeType) result.push(node.attrs);
22
+ });
23
+ return result;
25
24
  }
25
+ //#endregion
26
26
  export { getAllNodesAttributesByType, resolveContentSelection };
27
+
28
+ //# sourceMappingURL=typist-editor.helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typist-editor.helper.js","names":[],"sources":["../../src/components/typist-editor.helper.ts"],"sourcesContent":["import { Selection, TextSelection } from '@tiptap/pm/state'\nimport { clamp } from 'lodash-es'\n\nimport type { Node as ProseMirrorNode } from '@tiptap/pm/model'\n\n/**\n * Given a ProseMirror document, and a selection, resolves that selection within the bounds of the\n * document size. This works similarly to the official `autoFocus` implementation.\n */\nfunction resolveContentSelection(doc: ProseMirrorNode, selection: Selection): Selection {\n const minPos = Selection.atStart(doc).from\n const maxPos = Selection.atEnd(doc).to\n\n return TextSelection.create(\n doc,\n clamp(selection.anchor, minPos, maxPos),\n clamp(selection.head, minPos, maxPos),\n )\n}\n\n/**\n * The return type for the node attributes, an object mapping attribute names to values.\n */\ntype NodeAttributes = {\n [key: string]: unknown\n}\n\n/**\n * Given a ProseMirror document and a node type, returns the attributes of the given node type for\n * all the nodes in the document. This is based on the official implementation for the\n * `findChildren` helper function.\n */\nfunction getAllNodesAttributesByType(\n doc: ProseMirrorNode,\n nodeType: string,\n): Array<NodeAttributes> {\n const result: Array<NodeAttributes> = []\n\n doc.descendants((node) => {\n if (node.type.name === nodeType) {\n result.push(node.attrs)\n }\n })\n\n return result\n}\n\nexport { getAllNodesAttributesByType, resolveContentSelection }\n\nexport type { NodeAttributes }\n"],"mappings":";;;;;;;AASA,SAAS,wBAAwB,KAAsB,WAAiC;CACpF,MAAM,SAAS,UAAU,QAAQ,IAAI,CAAC;CACtC,MAAM,SAAS,UAAU,MAAM,IAAI,CAAC;AAEpC,QAAO,cAAc,OACjB,KACA,MAAM,UAAU,QAAQ,QAAQ,OAAO,EACvC,MAAM,UAAU,MAAM,QAAQ,OAAO,CACxC;;;;;;;AAeL,SAAS,4BACL,KACA,UACqB;CACrB,MAAM,SAAgC,EAAE;AAExC,KAAI,aAAa,SAAS;AACtB,MAAI,KAAK,KAAK,SAAS,SACnB,QAAO,KAAK,KAAK,MAAM;GAE7B;AAEF,QAAO"}