@cratis/components 4.22.1 → 4.23.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 (153) hide show
  1. package/compat-manifest.json +11 -11
  2. package/dist/esm/MarkdownEditor/CaretPosition.d.ts +12 -0
  3. package/dist/esm/MarkdownEditor/CaretPosition.d.ts.map +1 -0
  4. package/dist/esm/MarkdownEditor/CaretPosition.js +4 -0
  5. package/dist/esm/MarkdownEditor/CaretPosition.js.map +1 -0
  6. package/dist/esm/MarkdownEditor/MarkdownCompletion.d.ts +63 -0
  7. package/dist/esm/MarkdownEditor/MarkdownCompletion.d.ts.map +1 -0
  8. package/dist/esm/MarkdownEditor/MarkdownCompletion.js +4 -0
  9. package/dist/esm/MarkdownEditor/MarkdownCompletion.js.map +1 -0
  10. package/dist/esm/MarkdownEditor/MarkdownCompletionContext.d.ts +11 -0
  11. package/dist/esm/MarkdownEditor/MarkdownCompletionContext.d.ts.map +1 -0
  12. package/dist/esm/MarkdownEditor/MarkdownCompletionContext.js +4 -0
  13. package/dist/esm/MarkdownEditor/MarkdownCompletionContext.js.map +1 -0
  14. package/dist/esm/MarkdownEditor/MarkdownCompletionMatch.d.ts +17 -0
  15. package/dist/esm/MarkdownEditor/MarkdownCompletionMatch.d.ts.map +1 -0
  16. package/dist/esm/MarkdownEditor/MarkdownCompletionMatch.js +4 -0
  17. package/dist/esm/MarkdownEditor/MarkdownCompletionMatch.js.map +1 -0
  18. package/dist/esm/MarkdownEditor/MarkdownEditor.d.ts +86 -0
  19. package/dist/esm/MarkdownEditor/MarkdownEditor.d.ts.map +1 -0
  20. package/dist/esm/MarkdownEditor/MarkdownEditor.js +100 -0
  21. package/dist/esm/MarkdownEditor/MarkdownEditor.js.map +1 -0
  22. package/dist/esm/MarkdownEditor/MarkdownEditorLabels.d.ts +47 -0
  23. package/dist/esm/MarkdownEditor/MarkdownEditorLabels.d.ts.map +1 -0
  24. package/dist/esm/MarkdownEditor/MarkdownEditorLabels.js +4 -0
  25. package/dist/esm/MarkdownEditor/MarkdownEditorLabels.js.map +1 -0
  26. package/dist/esm/MarkdownEditor/MarkdownEditorMode.d.ts +11 -0
  27. package/dist/esm/MarkdownEditor/MarkdownEditorMode.d.ts.map +1 -0
  28. package/dist/esm/MarkdownEditor/MarkdownEditorMode.js +8 -0
  29. package/dist/esm/MarkdownEditor/MarkdownEditorMode.js.map +1 -0
  30. package/dist/esm/MarkdownEditor/MarkdownEditorParts.d.ts +33 -0
  31. package/dist/esm/MarkdownEditor/MarkdownEditorParts.d.ts.map +1 -0
  32. package/dist/esm/MarkdownEditor/MarkdownEditorParts.js +4 -0
  33. package/dist/esm/MarkdownEditor/MarkdownEditorParts.js.map +1 -0
  34. package/dist/esm/MarkdownEditor/MarkdownFormat.d.ts +29 -0
  35. package/dist/esm/MarkdownEditor/MarkdownFormat.d.ts.map +1 -0
  36. package/dist/esm/MarkdownEditor/MarkdownFormat.js +17 -0
  37. package/dist/esm/MarkdownEditor/MarkdownFormat.js.map +1 -0
  38. package/dist/esm/MarkdownEditor/MarkdownLineBlock.d.ts +12 -0
  39. package/dist/esm/MarkdownEditor/MarkdownLineBlock.d.ts.map +1 -0
  40. package/dist/esm/MarkdownEditor/MarkdownLineBlock.js +4 -0
  41. package/dist/esm/MarkdownEditor/MarkdownLineBlock.js.map +1 -0
  42. package/dist/esm/MarkdownEditor/MarkdownModeToggle.d.ts +22 -0
  43. package/dist/esm/MarkdownEditor/MarkdownModeToggle.d.ts.map +1 -0
  44. package/dist/esm/MarkdownEditor/MarkdownModeToggle.js +14 -0
  45. package/dist/esm/MarkdownEditor/MarkdownModeToggle.js.map +1 -0
  46. package/dist/esm/MarkdownEditor/MarkdownSuggestion.d.ts +18 -0
  47. package/dist/esm/MarkdownEditor/MarkdownSuggestion.d.ts.map +1 -0
  48. package/dist/esm/MarkdownEditor/MarkdownSuggestion.js +4 -0
  49. package/dist/esm/MarkdownEditor/MarkdownSuggestion.js.map +1 -0
  50. package/dist/esm/MarkdownEditor/MarkdownSuggestionList.d.ts +41 -0
  51. package/dist/esm/MarkdownEditor/MarkdownSuggestionList.d.ts.map +1 -0
  52. package/dist/esm/MarkdownEditor/MarkdownSuggestionList.js +19 -0
  53. package/dist/esm/MarkdownEditor/MarkdownSuggestionList.js.map +1 -0
  54. package/dist/esm/MarkdownEditor/MarkdownTextEdit.d.ts +12 -0
  55. package/dist/esm/MarkdownEditor/MarkdownTextEdit.d.ts.map +1 -0
  56. package/dist/esm/MarkdownEditor/MarkdownTextEdit.js +4 -0
  57. package/dist/esm/MarkdownEditor/MarkdownTextEdit.js.map +1 -0
  58. package/dist/esm/MarkdownEditor/MarkdownToolbar.d.ts +23 -0
  59. package/dist/esm/MarkdownEditor/MarkdownToolbar.d.ts.map +1 -0
  60. package/dist/esm/MarkdownEditor/MarkdownToolbar.js +43 -0
  61. package/dist/esm/MarkdownEditor/MarkdownToolbar.js.map +1 -0
  62. package/dist/esm/MarkdownEditor/MarkdownWritingArea.d.ts +37 -0
  63. package/dist/esm/MarkdownEditor/MarkdownWritingArea.d.ts.map +1 -0
  64. package/dist/esm/MarkdownEditor/MarkdownWritingArea.js +65 -0
  65. package/dist/esm/MarkdownEditor/MarkdownWritingArea.js.map +1 -0
  66. package/dist/esm/MarkdownEditor/applyMarkdownFormat.d.ts +13 -0
  67. package/dist/esm/MarkdownEditor/applyMarkdownFormat.d.ts.map +1 -0
  68. package/dist/esm/MarkdownEditor/applyMarkdownFormat.js +42 -0
  69. package/dist/esm/MarkdownEditor/applyMarkdownFormat.js.map +1 -0
  70. package/dist/esm/MarkdownEditor/caretPositionIn.d.ts +13 -0
  71. package/dist/esm/MarkdownEditor/caretPositionIn.d.ts.map +1 -0
  72. package/dist/esm/MarkdownEditor/caretPositionIn.js +54 -0
  73. package/dist/esm/MarkdownEditor/caretPositionIn.js.map +1 -0
  74. package/dist/esm/MarkdownEditor/defaultMarkdownEditorLabels.d.ts +4 -0
  75. package/dist/esm/MarkdownEditor/defaultMarkdownEditorLabels.d.ts.map +1 -0
  76. package/dist/esm/MarkdownEditor/defaultMarkdownEditorLabels.js +23 -0
  77. package/dist/esm/MarkdownEditor/defaultMarkdownEditorLabels.js.map +1 -0
  78. package/dist/esm/MarkdownEditor/defaultMarkdownFormats.d.ts +7 -0
  79. package/dist/esm/MarkdownEditor/defaultMarkdownFormats.d.ts.map +1 -0
  80. package/dist/esm/MarkdownEditor/defaultMarkdownFormats.js +10 -0
  81. package/dist/esm/MarkdownEditor/defaultMarkdownFormats.js.map +1 -0
  82. package/dist/esm/MarkdownEditor/filesIn.d.ts +7 -0
  83. package/dist/esm/MarkdownEditor/filesIn.d.ts.map +1 -0
  84. package/dist/esm/MarkdownEditor/filesIn.js +7 -0
  85. package/dist/esm/MarkdownEditor/filesIn.js.map +1 -0
  86. package/dist/esm/MarkdownEditor/findCompletionMatch.d.ts +12 -0
  87. package/dist/esm/MarkdownEditor/findCompletionMatch.d.ts.map +1 -0
  88. package/dist/esm/MarkdownEditor/findCompletionMatch.js +42 -0
  89. package/dist/esm/MarkdownEditor/findCompletionMatch.js.map +1 -0
  90. package/dist/esm/MarkdownEditor/formatIcons.d.ts +5 -0
  91. package/dist/esm/MarkdownEditor/formatIcons.d.ts.map +1 -0
  92. package/dist/esm/MarkdownEditor/formatIcons.js +20 -0
  93. package/dist/esm/MarkdownEditor/formatIcons.js.map +1 -0
  94. package/dist/esm/MarkdownEditor/formatShortcuts.d.ts +4 -0
  95. package/dist/esm/MarkdownEditor/formatShortcuts.d.ts.map +1 -0
  96. package/dist/esm/MarkdownEditor/formatShortcuts.js +10 -0
  97. package/dist/esm/MarkdownEditor/formatShortcuts.js.map +1 -0
  98. package/dist/esm/MarkdownEditor/index.d.ts +14 -0
  99. package/dist/esm/MarkdownEditor/index.d.ts.map +1 -0
  100. package/dist/esm/MarkdownEditor/index.js +7 -0
  101. package/dist/esm/MarkdownEditor/index.js.map +1 -0
  102. package/dist/esm/MarkdownEditor/insertLink.d.ts +12 -0
  103. package/dist/esm/MarkdownEditor/insertLink.d.ts.map +1 -0
  104. package/dist/esm/MarkdownEditor/insertLink.js +26 -0
  105. package/dist/esm/MarkdownEditor/insertLink.js.map +1 -0
  106. package/dist/esm/MarkdownEditor/lineBlockAround.d.ts +11 -0
  107. package/dist/esm/MarkdownEditor/lineBlockAround.d.ts.map +1 -0
  108. package/dist/esm/MarkdownEditor/lineBlockAround.js +14 -0
  109. package/dist/esm/MarkdownEditor/lineBlockAround.js.map +1 -0
  110. package/dist/esm/MarkdownEditor/nextMarkdownEditorMode.d.ts +8 -0
  111. package/dist/esm/MarkdownEditor/nextMarkdownEditorMode.d.ts.map +1 -0
  112. package/dist/esm/MarkdownEditor/nextMarkdownEditorMode.js +6 -0
  113. package/dist/esm/MarkdownEditor/nextMarkdownEditorMode.js.map +1 -0
  114. package/dist/esm/MarkdownEditor/replacePlaceholder.d.ts +14 -0
  115. package/dist/esm/MarkdownEditor/replacePlaceholder.d.ts.map +1 -0
  116. package/dist/esm/MarkdownEditor/replacePlaceholder.js +4 -0
  117. package/dist/esm/MarkdownEditor/replacePlaceholder.js.map +1 -0
  118. package/dist/esm/MarkdownEditor/replaceRange.d.ts +12 -0
  119. package/dist/esm/MarkdownEditor/replaceRange.d.ts.map +1 -0
  120. package/dist/esm/MarkdownEditor/replaceRange.js +11 -0
  121. package/dist/esm/MarkdownEditor/replaceRange.js.map +1 -0
  122. package/dist/esm/MarkdownEditor/toggleCodeBlock.d.ts +11 -0
  123. package/dist/esm/MarkdownEditor/toggleCodeBlock.d.ts.map +1 -0
  124. package/dist/esm/MarkdownEditor/toggleCodeBlock.js +30 -0
  125. package/dist/esm/MarkdownEditor/toggleCodeBlock.js.map +1 -0
  126. package/dist/esm/MarkdownEditor/toggleInlineMarker.d.ts +13 -0
  127. package/dist/esm/MarkdownEditor/toggleInlineMarker.d.ts.map +1 -0
  128. package/dist/esm/MarkdownEditor/toggleInlineMarker.js +29 -0
  129. package/dist/esm/MarkdownEditor/toggleInlineMarker.js.map +1 -0
  130. package/dist/esm/MarkdownEditor/toggleLinePrefix.d.ts +14 -0
  131. package/dist/esm/MarkdownEditor/toggleLinePrefix.d.ts.map +1 -0
  132. package/dist/esm/MarkdownEditor/toggleLinePrefix.js +24 -0
  133. package/dist/esm/MarkdownEditor/toggleLinePrefix.js.map +1 -0
  134. package/dist/esm/MarkdownEditor/uploadPlaceholderFor.d.ts +11 -0
  135. package/dist/esm/MarkdownEditor/uploadPlaceholderFor.d.ts.map +1 -0
  136. package/dist/esm/MarkdownEditor/uploadPlaceholderFor.js +4 -0
  137. package/dist/esm/MarkdownEditor/uploadPlaceholderFor.js.map +1 -0
  138. package/dist/esm/MarkdownEditor/useMarkdownCompletion.d.ts +44 -0
  139. package/dist/esm/MarkdownEditor/useMarkdownCompletion.d.ts.map +1 -0
  140. package/dist/esm/MarkdownEditor/useMarkdownCompletion.js +92 -0
  141. package/dist/esm/MarkdownEditor/useMarkdownCompletion.js.map +1 -0
  142. package/dist/esm/MarkdownEditor/useMarkdownUploads.d.ts +38 -0
  143. package/dist/esm/MarkdownEditor/useMarkdownUploads.d.ts.map +1 -0
  144. package/dist/esm/MarkdownEditor/useMarkdownUploads.js +55 -0
  145. package/dist/esm/MarkdownEditor/useMarkdownUploads.js.map +1 -0
  146. package/dist/esm/styles.MarkdownEditor.css +229 -0
  147. package/dist/esm/styles.base.css +2 -0
  148. package/dist/esm/styles.css +228 -0
  149. package/dist/esm/types/parts.d.ts +12 -0
  150. package/dist/esm/types/parts.d.ts.map +1 -1
  151. package/dist/esm/types/parts.js +12 -0
  152. package/dist/esm/types/parts.js.map +1 -1
  153. package/package.json +7 -2
@@ -68,7 +68,7 @@
68
68
  {
69
69
  "name": "@cratis/components",
70
70
  "role": "core",
71
- "version": "4.22.1",
71
+ "version": "4.23.1",
72
72
  "releaseMajorRange": ">=4 <5",
73
73
  "independentRelease": false,
74
74
  "private": false,
@@ -92,7 +92,7 @@
92
92
  {
93
93
  "name": "@cratis/eslint-plugin-components",
94
94
  "role": "eslint",
95
- "version": "4.22.1",
95
+ "version": "4.23.1",
96
96
  "releaseMajorRange": ">=4 <5",
97
97
  "independentRelease": false,
98
98
  "private": false,
@@ -105,7 +105,7 @@
105
105
  {
106
106
  "name": "@cratis/components.migrator",
107
107
  "role": "migrator",
108
- "version": "4.22.1",
108
+ "version": "4.23.1",
109
109
  "releaseMajorRange": ">=4 <5",
110
110
  "independentRelease": false,
111
111
  "private": false,
@@ -116,13 +116,13 @@
116
116
  {
117
117
  "name": "@cratis/components.conformance",
118
118
  "role": "conformance",
119
- "version": "4.22.1",
119
+ "version": "4.23.1",
120
120
  "releaseMajorRange": ">=4 <5",
121
121
  "independentRelease": false,
122
122
  "private": false,
123
123
  "packageAccess": "public",
124
124
  "peerDependencies": {
125
- "@cratis/components": "4.22.1",
125
+ "@cratis/components": "4.23.1",
126
126
  "react": "^19.0.0",
127
127
  "react-dom": "^19.0.0"
128
128
  },
@@ -132,13 +132,13 @@
132
132
  {
133
133
  "name": "@cratis/components.mui",
134
134
  "role": "renderer-adapter",
135
- "version": "4.22.1",
135
+ "version": "4.23.1",
136
136
  "releaseMajorRange": ">=4 <5",
137
137
  "independentRelease": false,
138
138
  "private": false,
139
139
  "packageAccess": "public",
140
140
  "peerDependencies": {
141
- "@cratis/components": "4.22.1",
141
+ "@cratis/components": "4.23.1",
142
142
  "@emotion/react": ">=11.5 <12",
143
143
  "@emotion/styled": ">=11.11 <12",
144
144
  "@mui/material": ">=9 <10",
@@ -188,13 +188,13 @@
188
188
  {
189
189
  "name": "@cratis/components.primereact",
190
190
  "role": "renderer-adapter",
191
- "version": "4.22.1",
191
+ "version": "4.23.1",
192
192
  "releaseMajorRange": ">=4 <5",
193
193
  "independentRelease": false,
194
194
  "private": false,
195
195
  "packageAccess": "public",
196
196
  "peerDependencies": {
197
- "@cratis/components": "4.22.1",
197
+ "@cratis/components": "4.23.1",
198
198
  "@primereact/core": ">=11 <12",
199
199
  "@primereact/ui": ">=11 <12",
200
200
  "@primeuix/themes": ">=3 <4",
@@ -256,13 +256,13 @@
256
256
  {
257
257
  "name": "@cratis/components.primereact10",
258
258
  "role": "renderer-adapter",
259
- "version": "4.22.1",
259
+ "version": "4.23.1",
260
260
  "releaseMajorRange": ">=4 <5",
261
261
  "independentRelease": false,
262
262
  "private": false,
263
263
  "packageAccess": "public",
264
264
  "peerDependencies": {
265
- "@cratis/components": "4.22.1",
265
+ "@cratis/components": "4.23.1",
266
266
  "primereact": ">=10.9.9 <11",
267
267
  "react": "^19.0.0",
268
268
  "react-dom": "^19.0.0"
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Where the caret of a writing area is on screen, in viewport coordinates.
3
+ */
4
+ export interface CaretPosition {
5
+ /** The left edge of the caret. */
6
+ left: number;
7
+ /** The top of the line the caret is on. */
8
+ top: number;
9
+ /** The bottom of the line the caret is on. */
10
+ bottom: number;
11
+ }
12
+ //# sourceMappingURL=CaretPosition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CaretPosition.d.ts","sourceRoot":"","sources":["../../../MarkdownEditor/CaretPosition.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IAEb,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAC;IAEZ,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAC;CAClB"}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+ export {};
4
+ //# sourceMappingURL=CaretPosition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CaretPosition.js","sourceRoot":"","sources":["../../../MarkdownEditor/CaretPosition.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * Where the caret of a writing area is on screen, in viewport coordinates.\n */\nexport interface CaretPosition {\n /** The left edge of the caret. */\n left: number;\n\n /** The top of the line the caret is on. */\n top: number;\n\n /** The bottom of the line the caret is on. */\n bottom: number;\n}\n"]}
@@ -0,0 +1,63 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { MarkdownCompletionContext } from './MarkdownCompletionContext.js';
3
+ import type { MarkdownSuggestion } from './MarkdownSuggestion.js';
4
+ /**
5
+ * Configures autocompletion for a {@link MarkdownEditor}: what starts it, and where the suggestions
6
+ * come from. The editor recognizes the trigger at the caret, asks {@link suggest} for suggestions,
7
+ * renders the list, and writes the picked suggestion's text over the trigger and what followed it.
8
+ *
9
+ * ```ts
10
+ * const issues: MarkdownCompletion = {
11
+ * trigger: '#',
12
+ * allowSpaces: true,
13
+ * label: 'Issues',
14
+ * suggest: async (query, { signal }) => (await searchIssues(query, signal)).map(issue => ({
15
+ * id: issue.id,
16
+ * insertText: `#${issue.number}`,
17
+ * label: issue.title,
18
+ * detail: `#${issue.number}`,
19
+ * })),
20
+ * };
21
+ * ```
22
+ */
23
+ export interface MarkdownCompletion {
24
+ /**
25
+ * What starts a completion.
26
+ *
27
+ * A string, such as `'#'` or `'@'`, starts one when it is typed at the start of a line or after
28
+ * whitespace; what follows it up to the caret, on the same line, is the query.
29
+ *
30
+ * A regular expression is matched against the current line up to the caret and starts a completion
31
+ * when its match ends at the caret. The whole match is what a picked suggestion replaces, and the
32
+ * query is the named group `query` when there is one, otherwise the first group, otherwise the
33
+ * whole match. Anchor it with `$` and use a lookbehind such as `(?<=^|\s)` for word boundaries.
34
+ */
35
+ trigger: string | RegExp;
36
+ /**
37
+ * Whether the query of a string trigger may contain spaces - searching by title rather than by a
38
+ * single word. Leading spaces are dropped from the query. Defaults to `false`.
39
+ */
40
+ allowSpaces?: boolean;
41
+ /** How many characters must follow the trigger before suggestions are asked for. Defaults to `0`. */
42
+ minimumQueryLength?: number;
43
+ /** How long typing must pause, in milliseconds, before suggestions are asked for. Defaults to `150`. */
44
+ debounce?: number;
45
+ /**
46
+ * Returns the suggestions for what has been typed after the trigger. May answer synchronously or
47
+ * with a promise; an answer for a query the person has already typed past is dropped, and so is a
48
+ * rejected one. An empty answer closes the list.
49
+ * @param query What has been typed after the trigger.
50
+ * @param context The {@link MarkdownCompletionContext} of the request.
51
+ * @returns The suggestions to offer, in the order to offer them.
52
+ */
53
+ suggest: (query: string, context: MarkdownCompletionContext) => readonly MarkdownSuggestion[] | Promise<readonly MarkdownSuggestion[]>;
54
+ /** Accessible name of the suggestion list. Defaults to the editor's `suggestions` label. */
55
+ label?: string;
56
+ /**
57
+ * Renders the content of one suggestion in place of the default detail, label and annotation.
58
+ * @param suggestion The suggestion to render.
59
+ * @returns What to show for it.
60
+ */
61
+ renderSuggestion?: (suggestion: MarkdownSuggestion) => ReactNode;
62
+ }
63
+ //# sourceMappingURL=MarkdownCompletion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownCompletion.d.ts","sourceRoot":"","sources":["../../../MarkdownEditor/MarkdownCompletion.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAA6B,CAAC;AAC7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAsB,CAAC;AAE/D;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,kBAAkB;IAC/B;;;;;;;;;;OAUG;IACH,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IAEzB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,qGAAqG;IACrG,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B,wGAAwG;IACxG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;;OAOG;IACH,OAAO,EAAE,CACL,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,yBAAyB,KACjC,SAAS,kBAAkB,EAAE,GAAG,OAAO,CAAC,SAAS,kBAAkB,EAAE,CAAC,CAAC;IAE5E,4FAA4F;IAC5F,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,kBAAkB,KAAK,SAAS,CAAC;CACpE"}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+ export {};
4
+ //# sourceMappingURL=MarkdownCompletion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownCompletion.js","sourceRoot":"","sources":["../../../MarkdownEditor/MarkdownCompletion.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { ReactNode } from 'react';\nimport type { MarkdownCompletionContext } from './MarkdownCompletionContext';\nimport type { MarkdownSuggestion } from './MarkdownSuggestion';\n\n/**\n * Configures autocompletion for a {@link MarkdownEditor}: what starts it, and where the suggestions\n * come from. The editor recognizes the trigger at the caret, asks {@link suggest} for suggestions,\n * renders the list, and writes the picked suggestion's text over the trigger and what followed it.\n *\n * ```ts\n * const issues: MarkdownCompletion = {\n * trigger: '#',\n * allowSpaces: true,\n * label: 'Issues',\n * suggest: async (query, { signal }) => (await searchIssues(query, signal)).map(issue => ({\n * id: issue.id,\n * insertText: `#${issue.number}`,\n * label: issue.title,\n * detail: `#${issue.number}`,\n * })),\n * };\n * ```\n */\nexport interface MarkdownCompletion {\n /**\n * What starts a completion.\n *\n * A string, such as `'#'` or `'@'`, starts one when it is typed at the start of a line or after\n * whitespace; what follows it up to the caret, on the same line, is the query.\n *\n * A regular expression is matched against the current line up to the caret and starts a completion\n * when its match ends at the caret. The whole match is what a picked suggestion replaces, and the\n * query is the named group `query` when there is one, otherwise the first group, otherwise the\n * whole match. Anchor it with `$` and use a lookbehind such as `(?<=^|\\s)` for word boundaries.\n */\n trigger: string | RegExp;\n\n /**\n * Whether the query of a string trigger may contain spaces - searching by title rather than by a\n * single word. Leading spaces are dropped from the query. Defaults to `false`.\n */\n allowSpaces?: boolean;\n\n /** How many characters must follow the trigger before suggestions are asked for. Defaults to `0`. */\n minimumQueryLength?: number;\n\n /** How long typing must pause, in milliseconds, before suggestions are asked for. Defaults to `150`. */\n debounce?: number;\n\n /**\n * Returns the suggestions for what has been typed after the trigger. May answer synchronously or\n * with a promise; an answer for a query the person has already typed past is dropped, and so is a\n * rejected one. An empty answer closes the list.\n * @param query What has been typed after the trigger.\n * @param context The {@link MarkdownCompletionContext} of the request.\n * @returns The suggestions to offer, in the order to offer them.\n */\n suggest: (\n query: string,\n context: MarkdownCompletionContext,\n ) => readonly MarkdownSuggestion[] | Promise<readonly MarkdownSuggestion[]>;\n\n /** Accessible name of the suggestion list. Defaults to the editor's `suggestions` label. */\n label?: string;\n\n /**\n * Renders the content of one suggestion in place of the default detail, label and annotation.\n * @param suggestion The suggestion to render.\n * @returns What to show for it.\n */\n renderSuggestion?: (suggestion: MarkdownSuggestion) => ReactNode;\n}\n"]}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * What a {@link MarkdownCompletion} is told alongside the query when it is asked for suggestions.
3
+ */
4
+ export interface MarkdownCompletionContext {
5
+ /**
6
+ * Aborted as soon as the answer is no longer wanted - the person typed on, moved the caret away or
7
+ * picked something. Pass it to `fetch` or check it before doing more work.
8
+ */
9
+ signal: AbortSignal;
10
+ }
11
+ //# sourceMappingURL=MarkdownCompletionContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownCompletionContext.d.ts","sourceRoot":"","sources":["../../../MarkdownEditor/MarkdownCompletionContext.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACtC;;;OAGG;IACH,MAAM,EAAE,WAAW,CAAC;CACvB"}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+ export {};
4
+ //# sourceMappingURL=MarkdownCompletionContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownCompletionContext.js","sourceRoot":"","sources":["../../../MarkdownEditor/MarkdownCompletionContext.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * What a {@link MarkdownCompletion} is told alongside the query when it is asked for suggestions.\n */\nexport interface MarkdownCompletionContext {\n /**\n * Aborted as soon as the answer is no longer wanted - the person typed on, moved the caret away or\n * picked something. Pass it to `fetch` or check it before doing more work.\n */\n signal: AbortSignal;\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import type { MarkdownCompletion } from './MarkdownCompletion.js';
2
+ /**
3
+ * A completion trigger found at the caret, and the query typed after it.
4
+ */
5
+ export interface MarkdownCompletionMatch {
6
+ /** The completion whose trigger was found. */
7
+ completion: MarkdownCompletion;
8
+ /** The position of the matched completion in the list it was configured in. */
9
+ completionIndex: number;
10
+ /** Where the trigger starts - the start of what a picked suggestion replaces. */
11
+ start: number;
12
+ /** The caret - the end of what a picked suggestion replaces. */
13
+ end: number;
14
+ /** What has been typed after the trigger. */
15
+ query: string;
16
+ }
17
+ //# sourceMappingURL=MarkdownCompletionMatch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownCompletionMatch.d.ts","sourceRoot":"","sources":["../../../MarkdownEditor/MarkdownCompletionMatch.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAsB,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACpC,8CAA8C;IAC9C,UAAU,EAAE,kBAAkB,CAAC;IAE/B,+EAA+E;IAC/E,eAAe,EAAE,MAAM,CAAC;IAExB,iFAAiF;IACjF,KAAK,EAAE,MAAM,CAAC;IAEd,gEAAgE;IAChE,GAAG,EAAE,MAAM,CAAC;IAEZ,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;CACjB"}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+ export {};
4
+ //# sourceMappingURL=MarkdownCompletionMatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownCompletionMatch.js","sourceRoot":"","sources":["../../../MarkdownEditor/MarkdownCompletionMatch.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { MarkdownCompletion } from './MarkdownCompletion';\n\n/**\n * A completion trigger found at the caret, and the query typed after it.\n */\nexport interface MarkdownCompletionMatch {\n /** The completion whose trigger was found. */\n completion: MarkdownCompletion;\n\n /** The position of the matched completion in the list it was configured in. */\n completionIndex: number;\n\n /** Where the trigger starts - the start of what a picked suggestion replaces. */\n start: number;\n\n /** The caret - the end of what a picked suggestion replaces. */\n end: number;\n\n /** What has been typed after the trigger. */\n query: string;\n}\n"]}
@@ -0,0 +1,86 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { MarkdownCompletion } from './MarkdownCompletion.js';
3
+ import type { MarkdownEditorLabels } from './MarkdownEditorLabels.js';
4
+ import { MarkdownEditorMode } from './MarkdownEditorMode.js';
5
+ import type { MarkdownEditorParts } from './MarkdownEditorParts.js';
6
+ import type { MarkdownFormat } from './MarkdownFormat.js';
7
+ /** Props for {@link MarkdownEditor}. */
8
+ export interface MarkdownEditorProps {
9
+ /** The markdown being edited. */
10
+ value: string;
11
+ /** Called with the markdown as it is written, formatted, completed or uploaded into. */
12
+ onChange: (value: string) => void;
13
+ /** Called when focus leaves the writing area. */
14
+ onBlur?: () => void;
15
+ /** Placeholder shown while the markdown is empty. */
16
+ placeholder?: string;
17
+ /**
18
+ * The height the editor takes when its container leaves its height to its content - a number of
19
+ * pixels or any CSS length. Inside a container with a height of its own the editor fills that
20
+ * instead. Defaults to 320 pixels.
21
+ */
22
+ height?: number | string;
23
+ /** The mode the editor opens in. Defaults to {@link MarkdownEditorMode.Write}. */
24
+ initialMode?: MarkdownEditorMode;
25
+ /** Focuses the writing area as the editor mounts. */
26
+ autoFocus?: boolean;
27
+ /** Disables writing, formatting and uploading. */
28
+ disabled?: boolean;
29
+ /** Shows the markdown without letting it be changed. */
30
+ readOnly?: boolean;
31
+ /** Marks the markdown as invalid, as a failed validation does. */
32
+ invalid?: boolean;
33
+ /**
34
+ * The formatting toolbar, as groups of formats separated from each other. Pass `false` for no
35
+ * toolbar. Defaults to text styles, blocks and links, and lists.
36
+ */
37
+ formats?: readonly (readonly MarkdownFormat[])[] | false;
38
+ /**
39
+ * Renders the preview of the markdown. The editor ships no markdown renderer - rendering, and what
40
+ * HTML is allowed through, belongs to the host - so the preview toggle only shows when this is given.
41
+ * @param markdown The markdown to render. Never empty: the editor shows its own empty text instead.
42
+ * @returns The rendered markdown.
43
+ */
44
+ renderPreview?: (markdown: string) => ReactNode;
45
+ /** Autocompletions offered while their trigger is typed, such as `#` for issues or `@` for people. */
46
+ completions?: readonly MarkdownCompletion[];
47
+ /**
48
+ * Uploads a file pasted or dropped into the writing area and returns the markdown that stands for
49
+ * it, such as an image or a link. Omit to leave pasting and dropping files to the browser.
50
+ * @param file The file to upload.
51
+ * @returns The markdown that replaces the file's placeholder.
52
+ */
53
+ uploadFile?: (file: File) => Promise<string>;
54
+ /**
55
+ * Told about a file whose upload failed. Its placeholder has already been taken out again.
56
+ * @param file The file that failed to upload.
57
+ * @param error What {@link uploadFile} rejected with.
58
+ */
59
+ onUploadFailed?: (file: File, error: unknown) => void;
60
+ /** Overrides for the editor's labels. Unset fields fall back to English. */
61
+ labels?: MarkdownEditorLabels;
62
+ /** The writing area's element id, for a `<label htmlFor>`. */
63
+ id?: string;
64
+ /** The writing area's accessible name. Defaults to the `editor` label unless `aria-labelledby` is given. */
65
+ 'aria-label'?: string;
66
+ /** The id of the element naming the writing area. */
67
+ 'aria-labelledby'?: string;
68
+ /** The id of the element describing the writing area, such as a validation message. */
69
+ 'aria-describedby'?: string;
70
+ /** Extra class name on the editor's root. */
71
+ className?: string;
72
+ /** Pass-through attributes for the editor's stable parts. */
73
+ pt?: MarkdownEditorParts;
74
+ }
75
+ /**
76
+ * A markdown editor: one bordered box holding a formatting toolbar and the writing area, with a round
77
+ * toggle in its corner that swaps the whole box to the rendered preview. It fills the container it is
78
+ * given, recognizes configured completion triggers at the caret, and uploads pasted or dropped files
79
+ * through the host.
80
+ *
81
+ * Only one pane shows at a time: a markdown surface usually lives in a dialog or panel that is already
82
+ * narrow, and a side-by-side preview would halve the writing width for something wanted only now and
83
+ * then.
84
+ */
85
+ export declare const MarkdownEditor: (props: MarkdownEditorProps) => import("react").JSX.Element;
86
+ //# sourceMappingURL=MarkdownEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownEditor.d.ts","sourceRoot":"","sources":["../../../MarkdownEditor/MarkdownEditor.tsx"],"names":[],"mappings":"AAGA,OAAO,EAA4C,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAQjF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAAwB,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAkB,CAAC;AAmBvD,wCAAwC;AACxC,MAAM,WAAW,mBAAmB;IAChC,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;IAEd,wFAAwF;IACxF,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAElC,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E,CAAC,EAAE,mBAAmB,CAAC;CAC5B;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,UAAW,mBAAmB,gCAkMxD,CAAC"}
@@ -0,0 +1,100 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { useState, useRef, useId, useLayoutEffect } from 'react';
3
+ import { classNames } from '../ClassNames/classNames.js';
4
+ import { unstable_useOverlayEnvironment } from '../renderer/RendererContext.js';
5
+ import { zIndexAboveDialog, OVERLAY_OFFSET } from '../renderer/dialogStack.js';
6
+ import { useNearestDialogZIndex } from '../renderer/DialogStackContext.js';
7
+ import { MarkdownEditorMode } from './MarkdownEditorMode.js';
8
+ import { MarkdownModeToggle } from './MarkdownModeToggle.js';
9
+ import { MarkdownSuggestionList } from './MarkdownSuggestionList.js';
10
+ import { MarkdownToolbar } from './MarkdownToolbar.js';
11
+ import { MarkdownWritingArea } from './MarkdownWritingArea.js';
12
+ import { applyMarkdownFormat } from './applyMarkdownFormat.js';
13
+ import { caretPositionIn } from './caretPositionIn.js';
14
+ import { defaultMarkdownEditorLabels } from './defaultMarkdownEditorLabels.js';
15
+ import { defaultMarkdownFormats } from './defaultMarkdownFormats.js';
16
+ import { useMarkdownCompletion } from './useMarkdownCompletion.js';
17
+ import { useMarkdownUploads } from './useMarkdownUploads.js';
18
+
19
+ const defaultHeight = 320;
20
+ const MarkdownEditor = (props) => {
21
+ const { value, onChange, height = defaultHeight, disabled = false, readOnly = false, invalid = false } = props;
22
+ const labels = { ...defaultMarkdownEditorLabels, ...props.labels };
23
+ const [mode, setMode] = useState(props.renderPreview ? (props.initialMode ?? MarkdownEditorMode.Write) : MarkdownEditorMode.Write);
24
+ const [selection, setSelection] = useState({ start: value.length, end: value.length });
25
+ const [caret, setCaret] = useState();
26
+ const textareaRef = useRef(null);
27
+ const pendingSelection = useRef(undefined);
28
+ const latest = useRef({ value, caret: value.length });
29
+ latest.current.value = value;
30
+ const baseId = useId();
31
+ const overlayEnvironment = unstable_useOverlayEnvironment();
32
+ const nearestDialogZIndex = useNearestDialogZIndex();
33
+ const editable = !disabled && !readOnly;
34
+ const completion = useMarkdownCompletion(value, selection.start, selection.end, editable && mode === MarkdownEditorMode.Write ? (props.completions ?? []) : []);
35
+ const applyEdit = (edit) => {
36
+ latest.current = { value: edit.value, caret: edit.selectionEnd };
37
+ pendingSelection.current = edit;
38
+ setSelection({ start: edit.selectionStart, end: edit.selectionEnd });
39
+ onChange(edit.value);
40
+ };
41
+ const uploads = useMarkdownUploads({
42
+ uploadFile: editable ? props.uploadFile : undefined,
43
+ onUploadFailed: props.onUploadFailed,
44
+ currentValue: () => latest.current.value,
45
+ insertAtCaret: text => {
46
+ const { value: current, caret: at } = latest.current;
47
+ const position = Math.min(at, current.length);
48
+ const caretAfter = position + text.length;
49
+ applyEdit({
50
+ value: `${current.slice(0, position)}${text}${current.slice(position)}`,
51
+ selectionStart: caretAfter,
52
+ selectionEnd: caretAfter,
53
+ });
54
+ },
55
+ replaceValue: next => {
56
+ latest.current = { ...latest.current, value: next };
57
+ onChange(next);
58
+ },
59
+ });
60
+ useLayoutEffect(() => {
61
+ const pending = pendingSelection.current;
62
+ const textarea = textareaRef.current;
63
+ if (!pending || !textarea || textarea.value !== pending.value)
64
+ return;
65
+ pendingSelection.current = undefined;
66
+ textarea.focus();
67
+ textarea.setSelectionRange(pending.selectionStart, pending.selectionEnd);
68
+ });
69
+ useLayoutEffect(() => {
70
+ const textarea = textareaRef.current;
71
+ setCaret(completion.isOpen && textarea ? caretPositionIn(textarea, selection.end) : undefined);
72
+ }, [completion.isOpen, value, selection.end]);
73
+ const applyFormat = (format) => {
74
+ const textarea = textareaRef.current;
75
+ if (!textarea || !editable)
76
+ return;
77
+ applyEdit(applyMarkdownFormat(value, textarea.selectionStart, textarea.selectionEnd, format));
78
+ };
79
+ const formats = props.formats === false ? [] : (props.formats ?? defaultMarkdownFormats);
80
+ const hasToolbar = formats.some(group => group.length > 0);
81
+ const canPreview = props.renderPreview !== undefined;
82
+ const suggestionsId = `${baseId}-suggestions`;
83
+ const optionId = (index) => `${baseId}-suggestion-${index}`;
84
+ const container = overlayEnvironment.getContainer();
85
+ const busy = uploads.uploading.length > 0;
86
+ const minHeight = typeof height === 'number' ? `${height}px` : height;
87
+ return (jsxs("div", { ...props.pt?.root, className: classNames('cratis-markdown-editor', canPreview && 'cratis-markdown-editor--toggleable', props.className, props.pt?.root?.className), style: { minHeight, ...props.pt?.root?.style }, "data-cratis-part": 'root', "data-disabled": disabled || undefined, "data-invalid": invalid || undefined, "data-readonly": readOnly || undefined, "data-busy": busy || undefined, children: [canPreview && (jsx(MarkdownModeToggle, { mode: mode, onModeChange: setMode, showPreviewLabel: labels.showPreview, showMarkdownLabel: labels.showMarkdown, parts: props.pt?.toggle })), mode === MarkdownEditorMode.Write && hasToolbar && (jsx(MarkdownToolbar, { formats: formats, labels: labels, disabled: !editable, onFormat: applyFormat, parts: props.pt })), jsx("div", { className: 'cratis-markdown-editor__body', children: mode === MarkdownEditorMode.Preview && props.renderPreview ? (jsx("div", { ...props.pt?.preview, className: classNames('cratis-markdown-editor__preview', props.pt?.preview?.className), "data-cratis-part": 'preview', children: value.trim().length > 0 ? (props.renderPreview(value)) : (jsx("p", { className: 'cratis-markdown-editor__empty', children: labels.emptyPreview })) })) : (jsx(MarkdownWritingArea, { value: value, onChange: onChange, onBlur: props.onBlur, placeholder: props.placeholder, autoFocus: props.autoFocus, disabled: disabled, readOnly: readOnly, invalid: invalid, id: props.id, "aria-label": props['aria-label'], "aria-labelledby": props['aria-labelledby'], "aria-describedby": props['aria-describedby'], parts: props.pt?.textarea, textareaRef: textareaRef, labels: labels, completion: completion, uploads: uploads, suggestionsId: suggestionsId, activeOptionId: completion.isOpen ? optionId(completion.activeIndex) : undefined, onSelectionChange: (start, end) => {
88
+ latest.current = { ...latest.current, caret: end };
89
+ setSelection({ start, end });
90
+ }, onEdit: applyEdit, onFormat: applyFormat })) }), busy && (jsx("div", { ...props.pt?.status, role: 'status', className: classNames('cratis-markdown-editor__status', props.pt?.status?.className), "data-cratis-part": 'status', children: labels.uploading(uploads.uploading) })), completion.isOpen && caret && container && (jsx(MarkdownSuggestionList, { id: suggestionsId, optionId: optionId, label: completion.match?.completion.label ?? labels.suggestions, suggestions: completion.suggestions, activeIndex: completion.activeIndex, caret: caret, zIndex: nearestDialogZIndex === null
91
+ ? 'var(--cratis-z-index-overlay)'
92
+ : zIndexAboveDialog(nearestDialogZIndex, OVERLAY_OFFSET), container: container, onHighlight: completion.highlight, onChoose: suggestion => {
93
+ const edit = completion.choose(suggestion);
94
+ if (edit)
95
+ applyEdit(edit);
96
+ }, renderSuggestion: completion.match?.completion.renderSuggestion, parts: props.pt }))] }));
97
+ };
98
+
99
+ export { MarkdownEditor };
100
+ //# sourceMappingURL=MarkdownEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownEditor.js","sources":["../../../MarkdownEditor/MarkdownEditor.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useId, useLayoutEffect, useRef, useState, type ReactNode } from 'react';\nimport { classNames } from '../ClassNames/classNames';\nimport { unstable_useOverlayEnvironment } from '../renderer/RendererContext';\nimport { OVERLAY_OFFSET, zIndexAboveDialog } from '../renderer/dialogStack';\nimport { useNearestDialogZIndex } from '../renderer/DialogStackContext';\nimport type { ExactPartKeys } from '../types/ExactPartKeys';\nimport type { PartsOf } from '../types/parts';\nimport type { CaretPosition } from './CaretPosition';\nimport type { MarkdownCompletion } from './MarkdownCompletion';\nimport type { MarkdownEditorLabels } from './MarkdownEditorLabels';\nimport { MarkdownEditorMode } from './MarkdownEditorMode';\nimport type { MarkdownEditorParts } from './MarkdownEditorParts';\nimport type { MarkdownFormat } from './MarkdownFormat';\nimport type { MarkdownTextEdit } from './MarkdownTextEdit';\nimport { MarkdownModeToggle } from './MarkdownModeToggle';\nimport { MarkdownSuggestionList } from './MarkdownSuggestionList';\nimport { MarkdownToolbar } from './MarkdownToolbar';\nimport { MarkdownWritingArea } from './MarkdownWritingArea';\nimport { applyMarkdownFormat } from './applyMarkdownFormat';\nimport { caretPositionIn } from './caretPositionIn';\nimport { defaultMarkdownEditorLabels } from './defaultMarkdownEditorLabels';\nimport { defaultMarkdownFormats } from './defaultMarkdownFormats';\nimport { useMarkdownCompletion } from './useMarkdownCompletion';\nimport { useMarkdownUploads } from './useMarkdownUploads';\n\nconst markdownEditorPartsMatchManifest: ExactPartKeys<MarkdownEditorParts, PartsOf<'MarkdownEditor'>> = true;\nvoid markdownEditorPartsMatchManifest;\n\n/** The height the editor falls back to when its container leaves its height to its content. */\nconst defaultHeight = 320;\n\n/** Props for {@link MarkdownEditor}. */\nexport interface MarkdownEditorProps {\n /** The markdown being edited. */\n value: string;\n\n /** Called with the markdown as it is written, formatted, completed or uploaded into. */\n onChange: (value: string) => void;\n\n /** Called when focus leaves the writing area. */\n onBlur?: () => void;\n\n /** Placeholder shown while the markdown is empty. */\n placeholder?: string;\n\n /**\n * The height the editor takes when its container leaves its height to its content - a number of\n * pixels or any CSS length. Inside a container with a height of its own the editor fills that\n * instead. Defaults to 320 pixels.\n */\n height?: number | string;\n\n /** The mode the editor opens in. Defaults to {@link MarkdownEditorMode.Write}. */\n initialMode?: MarkdownEditorMode;\n\n /** Focuses the writing area as the editor mounts. */\n autoFocus?: boolean;\n\n /** Disables writing, formatting and uploading. */\n disabled?: boolean;\n\n /** Shows the markdown without letting it be changed. */\n readOnly?: boolean;\n\n /** Marks the markdown as invalid, as a failed validation does. */\n invalid?: boolean;\n\n /**\n * The formatting toolbar, as groups of formats separated from each other. Pass `false` for no\n * toolbar. Defaults to text styles, blocks and links, and lists.\n */\n formats?: readonly (readonly MarkdownFormat[])[] | false;\n\n /**\n * Renders the preview of the markdown. The editor ships no markdown renderer - rendering, and what\n * HTML is allowed through, belongs to the host - so the preview toggle only shows when this is given.\n * @param markdown The markdown to render. Never empty: the editor shows its own empty text instead.\n * @returns The rendered markdown.\n */\n renderPreview?: (markdown: string) => ReactNode;\n\n /** Autocompletions offered while their trigger is typed, such as `#` for issues or `@` for people. */\n completions?: readonly MarkdownCompletion[];\n\n /**\n * Uploads a file pasted or dropped into the writing area and returns the markdown that stands for\n * it, such as an image or a link. Omit to leave pasting and dropping files to the browser.\n * @param file The file to upload.\n * @returns The markdown that replaces the file's placeholder.\n */\n uploadFile?: (file: File) => Promise<string>;\n\n /**\n * Told about a file whose upload failed. Its placeholder has already been taken out again.\n * @param file The file that failed to upload.\n * @param error What {@link uploadFile} rejected with.\n */\n onUploadFailed?: (file: File, error: unknown) => void;\n\n /** Overrides for the editor's labels. Unset fields fall back to English. */\n labels?: MarkdownEditorLabels;\n\n /** The writing area's element id, for a `<label htmlFor>`. */\n id?: string;\n\n /** The writing area's accessible name. Defaults to the `editor` label unless `aria-labelledby` is given. */\n 'aria-label'?: string;\n\n /** The id of the element naming the writing area. */\n 'aria-labelledby'?: string;\n\n /** The id of the element describing the writing area, such as a validation message. */\n 'aria-describedby'?: string;\n\n /** Extra class name on the editor's root. */\n className?: string;\n\n /** Pass-through attributes for the editor's stable parts. */\n pt?: MarkdownEditorParts;\n}\n\n/**\n * A markdown editor: one bordered box holding a formatting toolbar and the writing area, with a round\n * toggle in its corner that swaps the whole box to the rendered preview. It fills the container it is\n * given, recognizes configured completion triggers at the caret, and uploads pasted or dropped files\n * through the host.\n *\n * Only one pane shows at a time: a markdown surface usually lives in a dialog or panel that is already\n * narrow, and a side-by-side preview would halve the writing width for something wanted only now and\n * then.\n */\nexport const MarkdownEditor = (props: MarkdownEditorProps) => {\n const { value, onChange, height = defaultHeight, disabled = false, readOnly = false, invalid = false } = props;\n const labels = { ...defaultMarkdownEditorLabels, ...props.labels };\n const [mode, setMode] = useState(\n props.renderPreview ? (props.initialMode ?? MarkdownEditorMode.Write) : MarkdownEditorMode.Write,\n );\n const [selection, setSelection] = useState({ start: value.length, end: value.length });\n const [caret, setCaret] = useState<CaretPosition>();\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const pendingSelection = useRef<MarkdownTextEdit>(undefined);\n const latest = useRef({ value, caret: value.length });\n latest.current.value = value;\n const baseId = useId();\n const overlayEnvironment = unstable_useOverlayEnvironment();\n const nearestDialogZIndex = useNearestDialogZIndex();\n\n const editable = !disabled && !readOnly;\n const completion = useMarkdownCompletion(\n value,\n selection.start,\n selection.end,\n editable && mode === MarkdownEditorMode.Write ? (props.completions ?? []) : [],\n );\n\n const applyEdit = (edit: MarkdownTextEdit) => {\n latest.current = { value: edit.value, caret: edit.selectionEnd };\n pendingSelection.current = edit;\n setSelection({ start: edit.selectionStart, end: edit.selectionEnd });\n onChange(edit.value);\n };\n\n const uploads = useMarkdownUploads({\n uploadFile: editable ? props.uploadFile : undefined,\n onUploadFailed: props.onUploadFailed,\n currentValue: () => latest.current.value,\n insertAtCaret: text => {\n const { value: current, caret: at } = latest.current;\n const position = Math.min(at, current.length);\n const caretAfter = position + text.length;\n applyEdit({\n value: `${current.slice(0, position)}${text}${current.slice(position)}`,\n selectionStart: caretAfter,\n selectionEnd: caretAfter,\n });\n },\n replaceValue: next => {\n latest.current = { ...latest.current, value: next };\n onChange(next);\n },\n });\n\n // Restores the selection an edit asked for once the edited markdown is in the writing area.\n useLayoutEffect(() => {\n const pending = pendingSelection.current;\n const textarea = textareaRef.current;\n if (!pending || !textarea || textarea.value !== pending.value) return;\n pendingSelection.current = undefined;\n textarea.focus();\n textarea.setSelectionRange(pending.selectionStart, pending.selectionEnd);\n });\n\n // Measured before paint, so the list never flashes at the caret's previous place while typing.\n useLayoutEffect(() => {\n const textarea = textareaRef.current;\n setCaret(completion.isOpen && textarea ? caretPositionIn(textarea, selection.end) : undefined);\n }, [completion.isOpen, value, selection.end]);\n\n const applyFormat = (format: MarkdownFormat) => {\n const textarea = textareaRef.current;\n if (!textarea || !editable) return;\n applyEdit(applyMarkdownFormat(value, textarea.selectionStart, textarea.selectionEnd, format));\n };\n\n const formats = props.formats === false ? [] : (props.formats ?? defaultMarkdownFormats);\n const hasToolbar = formats.some(group => group.length > 0);\n const canPreview = props.renderPreview !== undefined;\n const suggestionsId = `${baseId}-suggestions`;\n const optionId = (index: number) => `${baseId}-suggestion-${index}`;\n const container = overlayEnvironment.getContainer();\n const busy = uploads.uploading.length > 0;\n const minHeight = typeof height === 'number' ? `${height}px` : height;\n\n return (\n <div\n {...props.pt?.root}\n className={classNames(\n 'cratis-markdown-editor',\n canPreview && 'cratis-markdown-editor--toggleable',\n props.className,\n props.pt?.root?.className,\n )}\n style={{ minHeight, ...props.pt?.root?.style }}\n data-cratis-part='root'\n data-disabled={disabled || undefined}\n data-invalid={invalid || undefined}\n data-readonly={readOnly || undefined}\n data-busy={busy || undefined}\n >\n {canPreview && (\n <MarkdownModeToggle\n mode={mode}\n onModeChange={setMode}\n showPreviewLabel={labels.showPreview}\n showMarkdownLabel={labels.showMarkdown}\n parts={props.pt?.toggle}\n />\n )}\n {mode === MarkdownEditorMode.Write && hasToolbar && (\n <MarkdownToolbar\n formats={formats}\n labels={labels}\n disabled={!editable}\n onFormat={applyFormat}\n parts={props.pt}\n />\n )}\n <div className='cratis-markdown-editor__body'>\n {mode === MarkdownEditorMode.Preview && props.renderPreview ? (\n <div\n {...props.pt?.preview}\n className={classNames('cratis-markdown-editor__preview', props.pt?.preview?.className)}\n data-cratis-part='preview'\n >\n {value.trim().length > 0 ? (\n props.renderPreview(value)\n ) : (\n <p className='cratis-markdown-editor__empty'>{labels.emptyPreview}</p>\n )}\n </div>\n ) : (\n <MarkdownWritingArea\n value={value}\n onChange={onChange}\n onBlur={props.onBlur}\n placeholder={props.placeholder}\n autoFocus={props.autoFocus}\n disabled={disabled}\n readOnly={readOnly}\n invalid={invalid}\n id={props.id}\n aria-label={props['aria-label']}\n aria-labelledby={props['aria-labelledby']}\n aria-describedby={props['aria-describedby']}\n parts={props.pt?.textarea}\n textareaRef={textareaRef}\n labels={labels}\n completion={completion}\n uploads={uploads}\n suggestionsId={suggestionsId}\n activeOptionId={completion.isOpen ? optionId(completion.activeIndex) : undefined}\n onSelectionChange={(start, end) => {\n latest.current = { ...latest.current, caret: end };\n setSelection({ start, end });\n }}\n onEdit={applyEdit}\n onFormat={applyFormat}\n />\n )}\n </div>\n {busy && (\n <div\n {...props.pt?.status}\n role='status'\n className={classNames('cratis-markdown-editor__status', props.pt?.status?.className)}\n data-cratis-part='status'\n >\n {labels.uploading(uploads.uploading)}\n </div>\n )}\n {completion.isOpen && caret && container && (\n <MarkdownSuggestionList\n id={suggestionsId}\n optionId={optionId}\n label={completion.match?.completion.label ?? labels.suggestions}\n suggestions={completion.suggestions}\n activeIndex={completion.activeIndex}\n caret={caret}\n zIndex={\n nearestDialogZIndex === null\n ? 'var(--cratis-z-index-overlay)'\n : zIndexAboveDialog(nearestDialogZIndex, OVERLAY_OFFSET)\n }\n container={container}\n onHighlight={completion.highlight}\n onChoose={suggestion => {\n const edit = completion.choose(suggestion);\n if (edit) applyEdit(edit);\n }}\n renderSuggestion={completion.match?.completion.renderSuggestion}\n parts={props.pt}\n />\n )}\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;AAgCA,MAAM,aAAa,GAAG,GAAG;AAsGlB,MAAM,cAAc,GAAG,CAAC,KAA0B,KAAI;IACzD,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAG,aAAa,EAAE,QAAQ,GAAG,KAAK,EAAE,QAAQ,GAAG,KAAK,EAAE,OAAO,GAAG,KAAK,EAAE,GAAG,KAAK;IAC9G,MAAM,MAAM,GAAG,EAAE,GAAG,2BAA2B,EAAE,GAAG,KAAK,CAAC,MAAM,EAAE;AAClE,IAAA,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAC5B,KAAK,CAAC,aAAa,IAAI,KAAK,CAAC,WAAW,IAAI,kBAAkB,CAAC,KAAK,IAAI,kBAAkB,CAAC,KAAK,CACnG;IACD,MAAM,CAAC,SAAS,EAAE,YAAY,C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label a {@link MarkdownEditor} renders or announces. Any field left unset falls
3
+ * back to a literal English default, so a host with its own translations passes them here.
4
+ */
5
+ export interface MarkdownEditorLabels {
6
+ /** Accessible name of the writing area when the host gives it none. Defaults to `'Markdown'`. */
7
+ editor?: string;
8
+ /** Accessible name of the formatting toolbar. Defaults to `'Formatting'`. */
9
+ toolbar?: string;
10
+ /** The bold format. Defaults to `'Bold'`. */
11
+ bold?: string;
12
+ /** The italic format. Defaults to `'Italic'`. */
13
+ italic?: string;
14
+ /** The strikethrough format. Defaults to `'Strikethrough'`. */
15
+ strikethrough?: string;
16
+ /** The heading format. Defaults to `'Heading'`. */
17
+ heading?: string;
18
+ /** The quote format. Defaults to `'Quote'`. */
19
+ quote?: string;
20
+ /** The inline code format. Defaults to `'Code'`. */
21
+ code?: string;
22
+ /** The code block format. Defaults to `'Code block'`. */
23
+ codeBlock?: string;
24
+ /** The link format. Defaults to `'Link'`. */
25
+ link?: string;
26
+ /** The bulleted list format. Defaults to `'Bulleted list'`. */
27
+ bulletList?: string;
28
+ /** The numbered list format. Defaults to `'Numbered list'`. */
29
+ numberedList?: string;
30
+ /** The task list format. Defaults to `'Task list'`. */
31
+ taskList?: string;
32
+ /** What the mode toggle says while the markdown is showing. Defaults to `'Show preview'`. */
33
+ showPreview?: string;
34
+ /** What the mode toggle says while the preview is showing. Defaults to `'Show markdown'`. */
35
+ showMarkdown?: string;
36
+ /** Shown in the preview when there is no markdown. Defaults to `'Nothing to preview'`. */
37
+ emptyPreview?: string;
38
+ /** Accessible name of a suggestion list whose completion names none. Defaults to `'Suggestions'`. */
39
+ suggestions?: string;
40
+ /**
41
+ * Announces the files uploading. Defaults to `Uploading <names>…`.
42
+ * @param fileNames The names of the files uploading, in the order they were added.
43
+ * @returns The text to show.
44
+ */
45
+ uploading?: (fileNames: readonly string[]) => string;
46
+ }
47
+ //# sourceMappingURL=MarkdownEditorLabels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownEditorLabels.d.ts","sourceRoot":"","sources":["../../../MarkdownEditor/MarkdownEditorLabels.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACjC,iGAAiG;IACjG,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,+DAA+D;IAC/D,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,yDAAyD;IACzD,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,+DAA+D;IAC/D,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,uDAAuD;IACvD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,6FAA6F;IAC7F,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,6FAA6F;IAC7F,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,0FAA0F;IAC1F,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,qGAAqG;IACrG,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,KAAK,MAAM,CAAC;CACxD"}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+ export {};
4
+ //# sourceMappingURL=MarkdownEditorLabels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownEditorLabels.js","sourceRoot":"","sources":["../../../MarkdownEditor/MarkdownEditorLabels.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * Overrides for every label a {@link MarkdownEditor} renders or announces. Any field left unset falls\n * back to a literal English default, so a host with its own translations passes them here.\n */\nexport interface MarkdownEditorLabels {\n /** Accessible name of the writing area when the host gives it none. Defaults to `'Markdown'`. */\n editor?: string;\n\n /** Accessible name of the formatting toolbar. Defaults to `'Formatting'`. */\n toolbar?: string;\n\n /** The bold format. Defaults to `'Bold'`. */\n bold?: string;\n\n /** The italic format. Defaults to `'Italic'`. */\n italic?: string;\n\n /** The strikethrough format. Defaults to `'Strikethrough'`. */\n strikethrough?: string;\n\n /** The heading format. Defaults to `'Heading'`. */\n heading?: string;\n\n /** The quote format. Defaults to `'Quote'`. */\n quote?: string;\n\n /** The inline code format. Defaults to `'Code'`. */\n code?: string;\n\n /** The code block format. Defaults to `'Code block'`. */\n codeBlock?: string;\n\n /** The link format. Defaults to `'Link'`. */\n link?: string;\n\n /** The bulleted list format. Defaults to `'Bulleted list'`. */\n bulletList?: string;\n\n /** The numbered list format. Defaults to `'Numbered list'`. */\n numberedList?: string;\n\n /** The task list format. Defaults to `'Task list'`. */\n taskList?: string;\n\n /** What the mode toggle says while the markdown is showing. Defaults to `'Show preview'`. */\n showPreview?: string;\n\n /** What the mode toggle says while the preview is showing. Defaults to `'Show markdown'`. */\n showMarkdown?: string;\n\n /** Shown in the preview when there is no markdown. Defaults to `'Nothing to preview'`. */\n emptyPreview?: string;\n\n /** Accessible name of a suggestion list whose completion names none. Defaults to `'Suggestions'`. */\n suggestions?: string;\n\n /**\n * Announces the files uploading. Defaults to `Uploading <names>…`.\n * @param fileNames The names of the files uploading, in the order they were added.\n * @returns The text to show.\n */\n uploading?: (fileNames: readonly string[]) => string;\n}\n"]}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * What a {@link MarkdownEditor} is showing. Only one pane is on screen at a time: the markdown being
3
+ * written, or the rendered preview of it.
4
+ */
5
+ export declare enum MarkdownEditorMode {
6
+ /** The raw markdown, with the formatting toolbar. */
7
+ Write = "write",
8
+ /** The markdown rendered by the host's preview renderer. */
9
+ Preview = "preview"
10
+ }
11
+ //# sourceMappingURL=MarkdownEditorMode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownEditorMode.d.ts","sourceRoot":"","sources":["../../../MarkdownEditor/MarkdownEditorMode.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,oBAAY,kBAAkB;IAC1B,qDAAqD;IACrD,KAAK,UAAU;IAEf,4DAA4D;IAC5D,OAAO,YAAY;CACtB"}
@@ -0,0 +1,8 @@
1
+ var MarkdownEditorMode;
2
+ (function (MarkdownEditorMode) {
3
+ MarkdownEditorMode["Write"] = "write";
4
+ MarkdownEditorMode["Preview"] = "preview";
5
+ })(MarkdownEditorMode || (MarkdownEditorMode = {}));
6
+
7
+ export { MarkdownEditorMode };
8
+ //# sourceMappingURL=MarkdownEditorMode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownEditorMode.js","sources":["../../../MarkdownEditor/MarkdownEditorMode.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * What a {@link MarkdownEditor} is showing. Only one pane is on screen at a time: the markdown being\n * written, or the rendered preview of it.\n */\nexport enum MarkdownEditorMode {\n /** The raw markdown, with the formatting toolbar. */\n Write = 'write',\n\n /** The markdown rendered by the host's preview renderer. */\n Preview = 'preview',\n}\n"],"names":[],"mappings":"IAOY;AAAZ,CAAA,UAAY,kBAAkB,EAAA;AAE1B,IAAA,kBAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AAGf,IAAA,kBAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACvB,CAAC,EANW,kBAAkB,KAAlB,kBAAkB,GAAA,EAAA,CAAA,CAAA;;"}