@cratis/components 4.22.1 → 4.23.0

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 +6 -1
@@ -0,0 +1,33 @@
1
+ import type { HTMLAttributes, TextareaHTMLAttributes } from 'react';
2
+ /** Attributes passed through to one part of a {@link MarkdownEditor}, including `data-*` attributes. */
3
+ export type MarkdownEditorPartAttributes<TElement> = HTMLAttributes<TElement> & {
4
+ [attribute: `data-${string}`]: string | number | boolean | undefined;
5
+ };
6
+ /**
7
+ * Stable Cratis-owned parts for styling a {@link MarkdownEditor}. Each is marked with a matching
8
+ * `data-cratis-part` attribute, and what is passed here is spread onto that element - the editor's own
9
+ * value, selection and event wiring always win.
10
+ */
11
+ export interface MarkdownEditorParts {
12
+ /** The editor's single bordered box. Carries `data-disabled`, `data-invalid`, `data-readonly` and `data-busy`. */
13
+ root?: MarkdownEditorPartAttributes<HTMLDivElement>;
14
+ /** The formatting toolbar. */
15
+ toolbar?: MarkdownEditorPartAttributes<HTMLDivElement>;
16
+ /** Every formatting button in the toolbar. Carries `data-disabled`. */
17
+ format?: MarkdownEditorPartAttributes<HTMLButtonElement>;
18
+ /** The round button that swaps between the markdown and the preview. Carries `data-pressed`. */
19
+ toggle?: MarkdownEditorPartAttributes<HTMLButtonElement>;
20
+ /** The writing area. Carries `data-disabled`, `data-invalid` and `data-readonly`. */
21
+ textarea?: Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'value' | 'defaultValue' | 'onChange'> & {
22
+ [attribute: `data-${string}`]: string | number | boolean | undefined;
23
+ };
24
+ /** The rendered preview pane. */
25
+ preview?: MarkdownEditorPartAttributes<HTMLDivElement>;
26
+ /** The status line announcing uploads in progress. */
27
+ status?: MarkdownEditorPartAttributes<HTMLDivElement>;
28
+ /** The suggestion list that opens at the caret while a completion is typed. */
29
+ suggestions?: MarkdownEditorPartAttributes<HTMLDivElement>;
30
+ /** Every entry in the suggestion list. Carries `data-selected` on the highlighted one. */
31
+ suggestion?: MarkdownEditorPartAttributes<HTMLDivElement>;
32
+ }
33
+ //# sourceMappingURL=MarkdownEditorParts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownEditorParts.d.ts","sourceRoot":"","sources":["../../../MarkdownEditor/MarkdownEditorParts.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,OAAO,CAAC;AAEpE,wGAAwG;AACxG,MAAM,MAAM,4BAA4B,CAAC,QAAQ,IAAI,cAAc,CAAC,QAAQ,CAAC,GAAG;IAC5E,CAAC,SAAS,EAAE,QAAQ,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;CACxE,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAChC,kHAAkH;IAClH,IAAI,CAAC,EAAE,4BAA4B,CAAC,cAAc,CAAC,CAAC;IAEpD,8BAA8B;IAC9B,OAAO,CAAC,EAAE,4BAA4B,CAAC,cAAc,CAAC,CAAC;IAEvD,uEAAuE;IACvE,MAAM,CAAC,EAAE,4BAA4B,CAAC,iBAAiB,CAAC,CAAC;IAEzD,gGAAgG;IAChG,MAAM,CAAC,EAAE,4BAA4B,CAAC,iBAAiB,CAAC,CAAC;IAEzD,qFAAqF;IACrF,QAAQ,CAAC,EAAE,IAAI,CAAC,sBAAsB,CAAC,mBAAmB,CAAC,EAAE,OAAO,GAAG,cAAc,GAAG,UAAU,CAAC,GAAG;QAClG,CAAC,SAAS,EAAE,QAAQ,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;KACxE,CAAC;IAEF,iCAAiC;IACjC,OAAO,CAAC,EAAE,4BAA4B,CAAC,cAAc,CAAC,CAAC;IAEvD,sDAAsD;IACtD,MAAM,CAAC,EAAE,4BAA4B,CAAC,cAAc,CAAC,CAAC;IAEtD,+EAA+E;IAC/E,WAAW,CAAC,EAAE,4BAA4B,CAAC,cAAc,CAAC,CAAC;IAE3D,0FAA0F;IAC1F,UAAU,CAAC,EAAE,4BAA4B,CAAC,cAAc,CAAC,CAAC;CAC7D"}
@@ -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=MarkdownEditorParts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownEditorParts.js","sourceRoot":"","sources":["../../../MarkdownEditor/MarkdownEditorParts.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 { HTMLAttributes, TextareaHTMLAttributes } from 'react';\n\n/** Attributes passed through to one part of a {@link MarkdownEditor}, including `data-*` attributes. */\nexport type MarkdownEditorPartAttributes<TElement> = HTMLAttributes<TElement> & {\n [attribute: `data-${string}`]: string | number | boolean | undefined;\n};\n\n/**\n * Stable Cratis-owned parts for styling a {@link MarkdownEditor}. Each is marked with a matching\n * `data-cratis-part` attribute, and what is passed here is spread onto that element - the editor's own\n * value, selection and event wiring always win.\n */\nexport interface MarkdownEditorParts {\n /** The editor's single bordered box. Carries `data-disabled`, `data-invalid`, `data-readonly` and `data-busy`. */\n root?: MarkdownEditorPartAttributes<HTMLDivElement>;\n\n /** The formatting toolbar. */\n toolbar?: MarkdownEditorPartAttributes<HTMLDivElement>;\n\n /** Every formatting button in the toolbar. Carries `data-disabled`. */\n format?: MarkdownEditorPartAttributes<HTMLButtonElement>;\n\n /** The round button that swaps between the markdown and the preview. Carries `data-pressed`. */\n toggle?: MarkdownEditorPartAttributes<HTMLButtonElement>;\n\n /** The writing area. Carries `data-disabled`, `data-invalid` and `data-readonly`. */\n textarea?: Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'value' | 'defaultValue' | 'onChange'> & {\n [attribute: `data-${string}`]: string | number | boolean | undefined;\n };\n\n /** The rendered preview pane. */\n preview?: MarkdownEditorPartAttributes<HTMLDivElement>;\n\n /** The status line announcing uploads in progress. */\n status?: MarkdownEditorPartAttributes<HTMLDivElement>;\n\n /** The suggestion list that opens at the caret while a completion is typed. */\n suggestions?: MarkdownEditorPartAttributes<HTMLDivElement>;\n\n /** Every entry in the suggestion list. Carries `data-selected` on the highlighted one. */\n suggestion?: MarkdownEditorPartAttributes<HTMLDivElement>;\n}\n"]}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * A formatting action offered by the {@link MarkdownEditor}'s toolbar. Each one edits the markdown
3
+ * around the current selection, and applying it to text that already carries it takes it off again.
4
+ */
5
+ export declare enum MarkdownFormat {
6
+ /** Wraps the selection in `**`. */
7
+ Bold = "bold",
8
+ /** Wraps the selection in `_`. */
9
+ Italic = "italic",
10
+ /** Wraps the selection in `~~`. */
11
+ Strikethrough = "strikethrough",
12
+ /** Prefixes the selected lines with `## `. */
13
+ Heading = "heading",
14
+ /** Prefixes the selected lines with `> `. */
15
+ Quote = "quote",
16
+ /** Wraps the selection in backticks. */
17
+ Code = "code",
18
+ /** Fences the selected lines in a code block. */
19
+ CodeBlock = "codeBlock",
20
+ /** Turns the selection into a link and selects the address to type over. */
21
+ Link = "link",
22
+ /** Prefixes the selected lines with `- `. */
23
+ BulletList = "bulletList",
24
+ /** Numbers the selected lines `1. `, `2. `, … */
25
+ NumberedList = "numberedList",
26
+ /** Prefixes the selected lines with `- [ ] `. */
27
+ TaskList = "taskList"
28
+ }
29
+ //# sourceMappingURL=MarkdownFormat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownFormat.d.ts","sourceRoot":"","sources":["../../../MarkdownEditor/MarkdownFormat.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,oBAAY,cAAc;IACtB,mCAAmC;IACnC,IAAI,SAAS;IAEb,kCAAkC;IAClC,MAAM,WAAW;IAEjB,mCAAmC;IACnC,aAAa,kBAAkB;IAE/B,8CAA8C;IAC9C,OAAO,YAAY;IAEnB,6CAA6C;IAC7C,KAAK,UAAU;IAEf,wCAAwC;IACxC,IAAI,SAAS;IAEb,iDAAiD;IACjD,SAAS,cAAc;IAEvB,4EAA4E;IAC5E,IAAI,SAAS;IAEb,6CAA6C;IAC7C,UAAU,eAAe;IAEzB,iDAAiD;IACjD,YAAY,iBAAiB;IAE7B,iDAAiD;IACjD,QAAQ,aAAa;CACxB"}
@@ -0,0 +1,17 @@
1
+ var MarkdownFormat;
2
+ (function (MarkdownFormat) {
3
+ MarkdownFormat["Bold"] = "bold";
4
+ MarkdownFormat["Italic"] = "italic";
5
+ MarkdownFormat["Strikethrough"] = "strikethrough";
6
+ MarkdownFormat["Heading"] = "heading";
7
+ MarkdownFormat["Quote"] = "quote";
8
+ MarkdownFormat["Code"] = "code";
9
+ MarkdownFormat["CodeBlock"] = "codeBlock";
10
+ MarkdownFormat["Link"] = "link";
11
+ MarkdownFormat["BulletList"] = "bulletList";
12
+ MarkdownFormat["NumberedList"] = "numberedList";
13
+ MarkdownFormat["TaskList"] = "taskList";
14
+ })(MarkdownFormat || (MarkdownFormat = {}));
15
+
16
+ export { MarkdownFormat };
17
+ //# sourceMappingURL=MarkdownFormat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownFormat.js","sources":["../../../MarkdownEditor/MarkdownFormat.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 * A formatting action offered by the {@link MarkdownEditor}'s toolbar. Each one edits the markdown\n * around the current selection, and applying it to text that already carries it takes it off again.\n */\nexport enum MarkdownFormat {\n /** Wraps the selection in `**`. */\n Bold = 'bold',\n\n /** Wraps the selection in `_`. */\n Italic = 'italic',\n\n /** Wraps the selection in `~~`. */\n Strikethrough = 'strikethrough',\n\n /** Prefixes the selected lines with `## `. */\n Heading = 'heading',\n\n /** Prefixes the selected lines with `> `. */\n Quote = 'quote',\n\n /** Wraps the selection in backticks. */\n Code = 'code',\n\n /** Fences the selected lines in a code block. */\n CodeBlock = 'codeBlock',\n\n /** Turns the selection into a link and selects the address to type over. */\n Link = 'link',\n\n /** Prefixes the selected lines with `- `. */\n BulletList = 'bulletList',\n\n /** Numbers the selected lines `1. `, `2. `, … */\n NumberedList = 'numberedList',\n\n /** Prefixes the selected lines with `- [ ] `. */\n TaskList = 'taskList',\n}\n"],"names":[],"mappings":"IAOY;AAAZ,CAAA,UAAY,cAAc,EAAA;AAEtB,IAAA,cAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AAGb,IAAA,cAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AAGjB,IAAA,cAAA,CAAA,eAAA,CAAA,GAAA,eAA+B;AAG/B,IAAA,cAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AAGnB,IAAA,cAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AAGf,IAAA,cAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AAGb,IAAA,cAAA,CAAA,WAAA,CAAA,GAAA,WAAuB;AAGvB,IAAA,cAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AAGb,IAAA,cAAA,CAAA,YAAA,CAAA,GAAA,YAAyB;AAGzB,IAAA,cAAA,CAAA,cAAA,CAAA,GAAA,cAA6B;AAG7B,IAAA,cAAA,CAAA,UAAA,CAAA,GAAA,UAAqB;AACzB,CAAC,EAjCW,cAAc,KAAd,cAAc,GAAA,EAAA,CAAA,CAAA;;"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The whole lines a selection touches - the unit that line formats such as lists and quotes apply to.
3
+ */
4
+ export interface MarkdownLineBlock {
5
+ /** Where the first touched line starts. */
6
+ start: number;
7
+ /** Where the last touched line ends, before its line break. */
8
+ end: number;
9
+ /** The touched lines, without their line breaks. */
10
+ lines: string[];
11
+ }
12
+ //# sourceMappingURL=MarkdownLineBlock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownLineBlock.d.ts","sourceRoot":"","sources":["../../../MarkdownEditor/MarkdownLineBlock.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IAEd,+DAA+D;IAC/D,GAAG,EAAE,MAAM,CAAC;IAEZ,oDAAoD;IACpD,KAAK,EAAE,MAAM,EAAE,CAAC;CACnB"}
@@ -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=MarkdownLineBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownLineBlock.js","sourceRoot":"","sources":["../../../MarkdownEditor/MarkdownLineBlock.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 * The whole lines a selection touches - the unit that line formats such as lists and quotes apply to.\n */\nexport interface MarkdownLineBlock {\n /** Where the first touched line starts. */\n start: number;\n\n /** Where the last touched line ends, before its line break. */\n end: number;\n\n /** The touched lines, without their line breaks. */\n lines: string[];\n}\n"]}
@@ -0,0 +1,22 @@
1
+ import { MarkdownEditorMode } from './MarkdownEditorMode.js';
2
+ import type { MarkdownEditorPartAttributes } from './MarkdownEditorParts.js';
3
+ /** Props for {@link MarkdownModeToggle}. */
4
+ export interface MarkdownModeToggleProps {
5
+ /** The mode being shown. */
6
+ mode: MarkdownEditorMode;
7
+ /** Called with the mode to show next. */
8
+ onModeChange: (mode: MarkdownEditorMode) => void;
9
+ /** What the button says while the markdown is showing. */
10
+ showPreviewLabel: string;
11
+ /** What the button says while the preview is showing. */
12
+ showMarkdownLabel: string;
13
+ /** Pass-through attributes for the button. */
14
+ parts?: MarkdownEditorPartAttributes<HTMLButtonElement>;
15
+ }
16
+ /**
17
+ * The round button in the editor's top-right corner that swaps between the markdown and its preview.
18
+ * A toggle rather than two buttons: `aria-pressed` says whether the preview is showing and the label
19
+ * names what pressing it does, so assistive technology announces both the state and the action.
20
+ */
21
+ export declare const MarkdownModeToggle: ({ mode, onModeChange, showPreviewLabel, showMarkdownLabel, parts, }: MarkdownModeToggleProps) => import("react").JSX.Element;
22
+ //# sourceMappingURL=MarkdownModeToggle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownModeToggle.d.ts","sourceRoot":"","sources":["../../../MarkdownEditor/MarkdownModeToggle.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,0BAAuB,CAAC;AAG1E,4CAA4C;AAC5C,MAAM,WAAW,uBAAuB;IACpC,4BAA4B;IAC5B,IAAI,EAAE,kBAAkB,CAAC;IAEzB,yCAAyC;IACzC,YAAY,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAEjD,0DAA0D;IAC1D,gBAAgB,EAAE,MAAM,CAAC;IAEzB,yDAAyD;IACzD,iBAAiB,EAAE,MAAM,CAAC;IAE1B,8CAA8C;IAC9C,KAAK,CAAC,EAAE,4BAA4B,CAAC,iBAAiB,CAAC,CAAC;CAC3D;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,wEAM5B,uBAAuB,gCAqBzB,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { FaPen, FaEye } from 'react-icons/fa6';
3
+ import { classNames } from '../ClassNames/classNames.js';
4
+ import { MarkdownEditorMode } from './MarkdownEditorMode.js';
5
+ import { nextMarkdownEditorMode } from './nextMarkdownEditorMode.js';
6
+
7
+ const MarkdownModeToggle = ({ mode, onModeChange, showPreviewLabel, showMarkdownLabel, parts, }) => {
8
+ const previewing = mode === MarkdownEditorMode.Preview;
9
+ const label = previewing ? showMarkdownLabel : showPreviewLabel;
10
+ return (jsx("button", { ...parts, type: 'button', className: classNames('cratis-markdown-editor__toggle', parts?.className), "data-cratis-part": 'toggle', "data-pressed": previewing || undefined, "aria-pressed": previewing, "aria-label": label, title: label, onClick: () => onModeChange(nextMarkdownEditorMode(mode)), children: jsx("span", { className: 'cratis-markdown-editor__toggle-icon', "aria-hidden": 'true', children: previewing ? jsx(FaPen, {}) : jsx(FaEye, {}) }) }));
11
+ };
12
+
13
+ export { MarkdownModeToggle };
14
+ //# sourceMappingURL=MarkdownModeToggle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownModeToggle.js","sources":["../../../MarkdownEditor/MarkdownModeToggle.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 { FaEye, FaPen } from 'react-icons/fa6';\nimport { classNames } from '../ClassNames/classNames';\nimport { MarkdownEditorMode } from './MarkdownEditorMode';\nimport type { MarkdownEditorPartAttributes } from './MarkdownEditorParts';\nimport { nextMarkdownEditorMode } from './nextMarkdownEditorMode';\n\n/** Props for {@link MarkdownModeToggle}. */\nexport interface MarkdownModeToggleProps {\n /** The mode being shown. */\n mode: MarkdownEditorMode;\n\n /** Called with the mode to show next. */\n onModeChange: (mode: MarkdownEditorMode) => void;\n\n /** What the button says while the markdown is showing. */\n showPreviewLabel: string;\n\n /** What the button says while the preview is showing. */\n showMarkdownLabel: string;\n\n /** Pass-through attributes for the button. */\n parts?: MarkdownEditorPartAttributes<HTMLButtonElement>;\n}\n\n/**\n * The round button in the editor's top-right corner that swaps between the markdown and its preview.\n * A toggle rather than two buttons: `aria-pressed` says whether the preview is showing and the label\n * names what pressing it does, so assistive technology announces both the state and the action.\n */\nexport const MarkdownModeToggle = ({\n mode,\n onModeChange,\n showPreviewLabel,\n showMarkdownLabel,\n parts,\n}: MarkdownModeToggleProps) => {\n const previewing = mode === MarkdownEditorMode.Preview;\n const label = previewing ? showMarkdownLabel : showPreviewLabel;\n\n return (\n <button\n {...parts}\n type='button'\n className={classNames('cratis-markdown-editor__toggle', parts?.className)}\n data-cratis-part='toggle'\n data-pressed={previewing || undefined}\n aria-pressed={previewing}\n aria-label={label}\n title={label}\n onClick={() => onModeChange(nextMarkdownEditorMode(mode))}\n >\n <span className='cratis-markdown-editor__toggle-icon' aria-hidden='true'>\n {previewing ? <FaPen /> : <FaEye />}\n </span>\n </button>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;AAgCO,MAAM,kBAAkB,GAAG,CAAC,EAC/B,IAAI,EACJ,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,GACiB,KAAI;AAC1B,IAAA,MAAM,UAAU,GAAG,IAAI,KAAK,kBAAkB,CAAC,OAAO;IACtD,MAAM,KAAK,GAAG,UAAU,GAAG,iBAAiB,GAAG,gBAAgB;AAE/D,IAAA,QACIA,GAAA,CAAA,QAAA,EAAA,EAAA,GACQ,KAAK,EACT,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,UAAU,CAAC,gCAAgC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAA,kBAAA,EACxD,QAAQ,EAAA,cAAA,EACX,UAAU,IAAI,SAAS,EAAA,cAAA,EACvB,UAAU,EAAA,YAAA,EACZ,KAAK,EACjB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,MAAM,YAAY,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC,EAAA,QAAA,EAEzDA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,qCAAqC,EAAA,aAAA,EAAa,MAAM,EAAA,QAAA,EACnE,UAAU,GAAGA,GAAA,CAAC,KAAK,EAAA,EAAA,CAAG,GAAGA,IAAC,KAAK,EAAA,EAAA,CAAG,EAAA,CAChC,EAAA,CACF;AAEjB;;"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * One entry in the list a {@link MarkdownCompletion} offers while its trigger is being typed. The host
3
+ * maps whatever it looks up - an issue, a person, a document - into this shape; the editor renders it
4
+ * and writes {@link insertText} into the markdown when it is picked.
5
+ */
6
+ export interface MarkdownSuggestion {
7
+ /** Identifies the suggestion within one list. Used as its key and in its element id. */
8
+ id: string;
9
+ /** The text that replaces the trigger and everything typed after it when the suggestion is picked. */
10
+ insertText: string;
11
+ /** The main text of the entry, such as a title or a name. */
12
+ label: string;
13
+ /** Secondary text shown ahead of the label in a monospace face, such as `owner/repository#12`. */
14
+ detail?: string;
15
+ /** A short annotation shown after the label, such as the kind of thing suggested. */
16
+ annotation?: string;
17
+ }
18
+ //# sourceMappingURL=MarkdownSuggestion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownSuggestion.d.ts","sourceRoot":"","sources":["../../../MarkdownEditor/MarkdownSuggestion.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAC/B,wFAAwF;IACxF,EAAE,EAAE,MAAM,CAAC;IAEX,sGAAsG;IACtG,UAAU,EAAE,MAAM,CAAC;IAEnB,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IAEd,kGAAkG;IAClG,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,qFAAqF;IACrF,UAAU,CAAC,EAAE,MAAM,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=MarkdownSuggestion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownSuggestion.js","sourceRoot":"","sources":["../../../MarkdownEditor/MarkdownSuggestion.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 * One entry in the list a {@link MarkdownCompletion} offers while its trigger is being typed. The host\n * maps whatever it looks up - an issue, a person, a document - into this shape; the editor renders it\n * and writes {@link insertText} into the markdown when it is picked.\n */\nexport interface MarkdownSuggestion {\n /** Identifies the suggestion within one list. Used as its key and in its element id. */\n id: string;\n\n /** The text that replaces the trigger and everything typed after it when the suggestion is picked. */\n insertText: string;\n\n /** The main text of the entry, such as a title or a name. */\n label: string;\n\n /** Secondary text shown ahead of the label in a monospace face, such as `owner/repository#12`. */\n detail?: string;\n\n /** A short annotation shown after the label, such as the kind of thing suggested. */\n annotation?: string;\n}\n"]}
@@ -0,0 +1,41 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { CaretPosition } from './CaretPosition.js';
3
+ import type { MarkdownEditorParts } from './MarkdownEditorParts.js';
4
+ import type { MarkdownSuggestion } from './MarkdownSuggestion.js';
5
+ /** Props for {@link MarkdownSuggestionList}. */
6
+ export interface MarkdownSuggestionListProps {
7
+ /** The list's element id, which the writing area points at. */
8
+ id: string;
9
+ /** Builds the element id of the suggestion at an index, which the writing area points at when it is highlighted. */
10
+ optionId: (index: number) => string;
11
+ /** The list's accessible name. */
12
+ label: string;
13
+ /** The suggestions to show. */
14
+ suggestions: readonly MarkdownSuggestion[];
15
+ /** The index of the highlighted suggestion. */
16
+ activeIndex: number;
17
+ /** Where the caret is. */
18
+ caret: CaretPosition;
19
+ /** The stacking order to open at - above any dialog the editor sits in. */
20
+ zIndex: string;
21
+ /** Where to portal the list to. */
22
+ container: HTMLElement;
23
+ /** Highlights a suggestion as the pointer moves onto it. */
24
+ onHighlight: (index: number) => void;
25
+ /** Picks a suggestion. */
26
+ onChoose: (suggestion: MarkdownSuggestion) => void;
27
+ /** Renders the content of a suggestion in place of the default. */
28
+ renderSuggestion?: (suggestion: MarkdownSuggestion) => ReactNode;
29
+ /** Pass-through attributes for the list and its entries. */
30
+ parts?: Pick<MarkdownEditorParts, 'suggestions' | 'suggestion'>;
31
+ }
32
+ /**
33
+ * The list of suggestions that opens at the caret while a completion is typed.
34
+ *
35
+ * Portaled out of the editor so no scrolling or clipping ancestor cuts it off, and marked as a top
36
+ * layer so a modal dialog around the editor neither hides it from assistive technology nor closes when
37
+ * it is clicked. Focus never leaves the writing area: the list is driven through
38
+ * `aria-activedescendant`, and pressing an entry does not take focus.
39
+ */
40
+ export declare const MarkdownSuggestionList: ({ id, optionId, label, suggestions, activeIndex, caret, zIndex, container, onHighlight, onChoose, renderSuggestion, parts, }: MarkdownSuggestionListProps) => import("react").ReactPortal;
41
+ //# sourceMappingURL=MarkdownSuggestionList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownSuggestionList.d.ts","sourceRoot":"","sources":["../../../Markd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
3
+ import { classNames } from '../ClassNames/classNames.js';
4
+
5
+ const roomBelow = 240;
6
+ const DefaultSuggestion = ({ suggestion }) => (jsxs(Fragment, { children: [suggestion.detail && jsx("span", { className: 'cratis-markdown-editor__suggestion-detail', children: suggestion.detail }), jsx("span", { className: 'cratis-markdown-editor__suggestion-label', children: suggestion.label }), suggestion.annotation && (jsx("span", { className: 'cratis-markdown-editor__suggestion-annotation', children: suggestion.annotation }))] }));
7
+ const MarkdownSuggestionList = ({ id, optionId, label, suggestions, activeIndex, caret, zIndex, container, onHighlight, onChoose, renderSuggestion, parts, }) => {
8
+ const opensAbove = caret.bottom + roomBelow > window.innerHeight && caret.top > window.innerHeight - caret.bottom;
9
+ const style = {
10
+ ...parts?.suggestions?.style,
11
+ zIndex,
12
+ left: Math.max(0, Math.min(caret.left, window.innerWidth - 16)),
13
+ ...(opensAbove ? { bottom: window.innerHeight - caret.top + 4 } : { top: caret.bottom + 4 }),
14
+ };
15
+ return createPortal(jsx("div", { ...parts?.suggestions, id: id, role: 'listbox', "aria-label": label, className: classNames('cratis-markdown-editor__suggestions', parts?.suggestions?.className), "data-cratis-part": 'suggestions', "data-react-aria-top-layer": 'true', style: style, children: suggestions.map((suggestion, index) => (jsx("div", { ...parts?.suggestion, id: optionId(index), role: 'option', "aria-selected": index === activeIndex, className: classNames('cratis-markdown-editor__suggestion', parts?.suggestion?.className), "data-cratis-part": 'suggestion', "data-selected": index === activeIndex || undefined, onMouseDown: event => event.preventDefault(), onMouseEnter: () => onHighlight(index), onClick: () => onChoose(suggestion), children: renderSuggestion ? renderSuggestion(suggestion) : jsx(DefaultSuggestion, { suggestion: suggestion }) }, suggestion.id))) }), container);
16
+ };
17
+
18
+ export { MarkdownSuggestionList };
19
+ //# sourceMappingURL=MarkdownSuggestionList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownSuggestionList.js","sources":["../../../MarkdownEditor/MarkdownSuggestionList.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 type { CSSProperties, ReactNode } from 'react';\nimport { createPortal } from 'react-dom';\nimport { classNames } from '../ClassNames/classNames';\nimport type { CaretPosition } from './CaretPosition';\nimport type { MarkdownEditorParts } from './MarkdownEditorParts';\nimport type { MarkdownSuggestion } from './MarkdownSuggestion';\n\n/** Room kept below the caret before the list opens above it instead. */\nconst roomBelow = 240;\n\n/** Props for {@link MarkdownSuggestionList}. */\nexport interface MarkdownSuggestionListProps {\n /** The list's element id, which the writing area points at. */\n id: string;\n\n /** Builds the element id of the suggestion at an index, which the writing area points at when it is highlighted. */\n optionId: (index: number) => string;\n\n /** The list's accessible name. */\n label: string;\n\n /** The suggestions to show. */\n suggestions: readonly MarkdownSuggestion[];\n\n /** The index of the highlighted suggestion. */\n activeIndex: number;\n\n /** Where the caret is. */\n caret: CaretPosition;\n\n /** The stacking order to open at - above any dialog the editor sits in. */\n zIndex: string;\n\n /** Where to portal the list to. */\n container: HTMLElement;\n\n /** Highlights a suggestion as the pointer moves onto it. */\n onHighlight: (index: number) => void;\n\n /** Picks a suggestion. */\n onChoose: (suggestion: MarkdownSuggestion) => void;\n\n /** Renders the content of a suggestion in place of the default. */\n renderSuggestion?: (suggestion: MarkdownSuggestion) => ReactNode;\n\n /** Pass-through attributes for the list and its entries. */\n parts?: Pick<MarkdownEditorParts, 'suggestions' | 'suggestion'>;\n}\n\nconst DefaultSuggestion = ({ suggestion }: { suggestion: MarkdownSuggestion }) => (\n <>\n {suggestion.detail && <span className='cratis-markdown-editor__suggestion-detail'>{suggestion.detail}</span>}\n <span className='cratis-markdown-editor__suggestion-label'>{suggestion.label}</span>\n {suggestion.annotation && (\n <span className='cratis-markdown-editor__suggestion-annotation'>{suggestion.annotation}</span>\n )}\n </>\n);\n\n/**\n * The list of suggestions that opens at the caret while a completion is typed.\n *\n * Portaled out of the editor so no scrolling or clipping ancestor cuts it off, and marked as a top\n * layer so a modal dialog around the editor neither hides it from assistive technology nor closes when\n * it is clicked. Focus never leaves the writing area: the list is driven through\n * `aria-activedescendant`, and pressing an entry does not take focus.\n */\nexport const MarkdownSuggestionList = ({\n id,\n optionId,\n label,\n suggestions,\n activeIndex,\n caret,\n zIndex,\n container,\n onHighlight,\n onChoose,\n renderSuggestion,\n parts,\n}: MarkdownSuggestionListProps) => {\n const opensAbove = caret.bottom + roomBelow > window.innerHeight && caret.top > window.innerHeight - caret.bottom;\n const style: CSSProperties = {\n ...parts?.suggestions?.style,\n zIndex,\n left: Math.max(0, Math.min(caret.left, window.innerWidth - 16)),\n ...(opensAbove ? { bottom: window.innerHeight - caret.top + 4 } : { top: caret.bottom + 4 }),\n };\n\n return createPortal(\n <div\n {...parts?.suggestions}\n id={id}\n role='listbox'\n aria-label={label}\n className={classNames('cratis-markdown-editor__suggestions', parts?.suggestions?.className)}\n data-cratis-part='suggestions'\n data-react-aria-top-layer='true'\n style={style}\n >\n {suggestions.map((suggestion, index) => (\n <div\n key={suggestion.id}\n {...parts?.suggestion}\n id={optionId(index)}\n role='option'\n aria-selected={index === activeIndex}\n className={classNames('cratis-markdown-editor__suggestion', parts?.suggestion?.className)}\n data-cratis-part='suggestion'\n data-selected={index === activeIndex || undefined}\n onMouseDown={event => event.preventDefault()}\n onMouseEnter={() => onHighlight(index)}\n onClick={() => onChoose(suggestion)}\n >\n {renderSuggestion ? renderSuggestion(suggestion) : <DefaultSuggestion suggestion={suggestion} />}\n </div>\n ))}\n </div>,\n container,\n );\n};\n"],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;;;AAWA,MAAM,SAAS,GAAG,GAAG;AAyCrB,MAAM,iBAAiB,GAAG,CAAC,EAAE,UAAU,EAAsC,MACzEA,IAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAA,CACK,UAAU,CAAC,MAAM,IAAIC,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,2CAA2C,YAAE,UAAU,CAAC,MAAM,EAAA,CAAQ,EAC5GA,GAAA,CAA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,EACJ,MAAM,EAChC,KAAK,EAAE,KAAK,EAAA,QAAA,EAEX,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,KAAK,MAC/BA,GAAA,CAAA,KAAA,EAAA,EAAA,GAEQ,KAAK,EAAE,UAAU,EACrB,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,EACnB,IAAI,EAAC,QAAQ,EAAA,eAAA,EACE,KAAK,KAAK,WAAW,EACpC,SAAS,EAAE,UAAU,CAAC,oCAAoC,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,CAAC,EAAA,kBAAA,EACxE,YAAY,EAAA,eAAA,EACd,KAAK,KAAK,WAAW,IAAI,SAAS,EACjD,WAAW,EAAE,KAAK,IAAI,KAAK,CAAC,cAAc,EAAE,EAC5C,YAAY,EAAE,MAAM,WAAW,CAAC,KAAK,CAAC,EACtC,OAAO,EAAE,MAAM,QAAQ,CAAC,UAAU,CAAC,EAAA,QAAA,EAElC,gBAAgB,GAAG,gBAAgB,CAAC,UAAU,CAAC,GAAGA,GAAA,CAAC,iBAAiB,IAAC,UAAU,EAAE,UAAU,EAAA,CAAI,IAZ3F,UAAU,CAAC,EAAE,CAahB,CACT,CAAC,EAAA,CACA,EACN,SAAS,CACZ;AACL;;"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Markdown after an edit, together with the selection the writing area should show afterwards.
3
+ */
4
+ export interface MarkdownTextEdit {
5
+ /** The markdown after the edit. */
6
+ value: string;
7
+ /** Where the selection starts after the edit. */
8
+ selectionStart: number;
9
+ /** Where the selection ends after the edit. Equal to {@link selectionStart} for a plain caret. */
10
+ selectionEnd: number;
11
+ }
12
+ //# sourceMappingURL=MarkdownTextEdit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownTextEdit.d.ts","sourceRoot":"","sources":["../../../MarkdownEditor/MarkdownTextEdit.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IAEd,iDAAiD;IACjD,cAAc,EAAE,MAAM,CAAC;IAEvB,kGAAkG;IAClG,YAAY,EAAE,MAAM,CAAC;CACxB"}
@@ -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=MarkdownTextEdit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownTextEdit.js","sourceRoot":"","sources":["../../../MarkdownEditor/MarkdownTextEdit.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 * Markdown after an edit, together with the selection the writing area should show afterwards.\n */\nexport interface MarkdownTextEdit {\n /** The markdown after the edit. */\n value: string;\n\n /** Where the selection starts after the edit. */\n selectionStart: number;\n\n /** Where the selection ends after the edit. Equal to {@link selectionStart} for a plain caret. */\n selectionEnd: number;\n}\n"]}
@@ -0,0 +1,23 @@
1
+ import type { MarkdownFormat } from './MarkdownFormat.js';
2
+ import type { MarkdownEditorLabels } from './MarkdownEditorLabels.js';
3
+ import type { MarkdownEditorParts } from './MarkdownEditorParts.js';
4
+ /** Props for {@link MarkdownToolbar}. */
5
+ export interface MarkdownToolbarProps {
6
+ /** The formats to offer, in groups separated from each other. */
7
+ formats: readonly (readonly MarkdownFormat[])[];
8
+ /** The resolved labels. */
9
+ labels: Required<MarkdownEditorLabels>;
10
+ /** Whether the formats can be applied. */
11
+ disabled: boolean;
12
+ /** Applies a format to the writing area's selection. */
13
+ onFormat: (format: MarkdownFormat) => void;
14
+ /** Pass-through attributes for the toolbar and its buttons. */
15
+ parts?: Pick<MarkdownEditorParts, 'toolbar' | 'format'>;
16
+ }
17
+ /**
18
+ * The formatting toolbar above the writing area. One Tab stop: the arrow keys, Home and End move
19
+ * between the buttons, as the ARIA toolbar pattern describes. A button press never takes focus from
20
+ * the writing area, so the selection it formats stays where it was.
21
+ */
22
+ export declare const MarkdownToolbar: ({ formats, labels, disabled, onFormat, parts }: MarkdownToolbarProps) => import("react").JSX.Element;
23
+ //# sourceMappingURL=MarkdownToolbar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownToolbar.d.ts","sourceRoot":"","sources":["../../../MarkdownEditor/MarkdownToolbar.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAAwB,CAAC;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAAuB,CAAC;AAIjE,yCAAyC;AACzC,MAAM,WAAW,oBAAoB;IACjC,iEAAiE;IACjE,OAAO,EAAE,SAAS,CAAC,SAAS,cAAc,EAAE,CAAC,EAAE,CAAC;IAEhD,2BAA2B;IAC3B,MAAM,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAC;IAEvC,0CAA0C;IAC1C,QAAQ,EAAE,OAAO,CAAC;IAElB,wDAAwD;IACxD,QAAQ,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;IAE3C,+DAA+D;IAC/D,KAAK,CAAC,EAAE,IAAI,CAAC,mBAAmB,EAAE,SAAS,GAAG,QAAQ,CAAC,CAAC;CAC3D;AAWD;;;;GAIG;AACH,eAAO,MAAM,eAAe,mDAAoD,oBAAoB,gCAoEnG,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { useState, useRef, Fragment } from 'react';
3
+ import { classNames } from '../ClassNames/classNames.js';
4
+ import { formatIcons } from './formatIcons.js';
5
+ import { formatShortcuts } from './formatShortcuts.js';
6
+
7
+ const shortcutFor = (format) => {
8
+ for (const [letter, shortcut] of formatShortcuts) {
9
+ if (shortcut === format)
10
+ return `Control+${letter.toUpperCase()} Meta+${letter.toUpperCase()}`;
11
+ }
12
+ return undefined;
13
+ };
14
+ const navigationKeys = new Set(['ArrowLeft', 'ArrowRight', 'Home', 'End']);
15
+ const MarkdownToolbar = ({ formats, labels, disabled, onFormat, parts }) => {
16
+ const flat = formats.flat();
17
+ const [focusIndex, setFocusIndex] = useState(0);
18
+ const buttons = useRef([]);
19
+ const current = Math.min(focusIndex, Math.max(flat.length - 1, 0));
20
+ const onKeyDown = (event) => {
21
+ parts?.toolbar?.onKeyDown?.(event);
22
+ if (!navigationKeys.has(event.key) || flat.length === 0)
23
+ return;
24
+ event.preventDefault();
25
+ const next = event.key === 'Home'
26
+ ? 0
27
+ : event.key === 'End'
28
+ ? flat.length - 1
29
+ : (current + (event.key === 'ArrowRight' ? 1 : -1) + flat.length) % flat.length;
30
+ setFocusIndex(next);
31
+ buttons.current[next]?.focus();
32
+ };
33
+ const offsets = formats.map((_, groupIndex) => formats.slice(0, groupIndex).reduce((total, group) => total + group.length, 0));
34
+ return (jsx("div", { ...parts?.toolbar, role: 'toolbar', "aria-label": labels.toolbar, className: classNames('cratis-markdown-editor__toolbar', parts?.toolbar?.className), "data-cratis-part": 'toolbar', onKeyDown: onKeyDown, children: formats.map((group, groupIndex) => (jsxs(Fragment, { children: [groupIndex > 0 && jsx("span", { className: 'cratis-markdown-editor__separator', "aria-hidden": 'true' }), group.map((format, formatIndex) => {
35
+ const index = offsets[groupIndex] + formatIndex;
36
+ return (jsx("button", { ...parts?.format, ref: element => {
37
+ buttons.current[index] = element;
38
+ }, type: 'button', className: classNames('cratis-markdown-editor__format', parts?.format?.className), "data-cratis-part": 'format', "data-disabled": disabled || undefined, disabled: disabled, tabIndex: index === current ? 0 : -1, "aria-label": labels[format], "aria-keyshortcuts": shortcutFor(format), title: labels[format], onMouseDown: event => event.preventDefault(), onFocus: () => setFocusIndex(index), onClick: () => onFormat(format), children: jsx("span", { className: 'cratis-markdown-editor__format-icon', "aria-hidden": 'true', children: formatIcons[format] }) }, format));
39
+ })] }, group.join('-')))) }));
40
+ };
41
+
42
+ export { MarkdownToolbar };
43
+ //# sourceMappingURL=MarkdownToolbar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownToolbar.js","sources":["../../../MarkdownEditor/MarkdownToolbar.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 { Fragment, useRef, useState, type KeyboardEvent } from 'react';\nimport { classNames } from '../ClassNames/classNames';\nimport type { MarkdownFormat } from './MarkdownFormat';\nimport type { MarkdownEditorLabels } from './MarkdownEditorLabels';\nimport type { MarkdownEditorParts } from './MarkdownEditorParts';\nimport { formatIcons } from './formatIcons';\nimport { formatShortcuts } from './formatShortcuts';\n\n/** Props for {@link MarkdownToolbar}. */\nexport interface MarkdownToolbarProps {\n /** The formats to offer, in groups separated from each other. */\n formats: readonly (readonly MarkdownFormat[])[];\n\n /** The resolved labels. */\n labels: Required<MarkdownEditorLabels>;\n\n /** Whether the formats can be applied. */\n disabled: boolean;\n\n /** Applies a format to the writing area's selection. */\n onFormat: (format: MarkdownFormat) => void;\n\n /** Pass-through attributes for the toolbar and its buttons. */\n parts?: Pick<MarkdownEditorParts, 'toolbar' | 'format'>;\n}\n\nconst shortcutFor = (format: MarkdownFormat) => {\n for (const [letter, shortcut] of formatShortcuts) {\n if (shortcut === format) return `Control+${letter.toUpperCase()} Meta+${letter.toUpperCase()}`;\n }\n return undefined;\n};\n\nconst navigationKeys = new Set(['ArrowLeft', 'ArrowRight', 'Home', 'End']);\n\n/**\n * The formatting toolbar above the writing area. One Tab stop: the arrow keys, Home and End move\n * between the buttons, as the ARIA toolbar pattern describes. A button press never takes focus from\n * the writing area, so the selection it formats stays where it was.\n */\nexport const MarkdownToolbar = ({ formats, labels, disabled, onFormat, parts }: MarkdownToolbarProps) => {\n const flat = formats.flat();\n const [focusIndex, setFocusIndex] = useState(0);\n const buttons = useRef<(HTMLButtonElement | null)[]>([]);\n const current = Math.min(focusIndex, Math.max(flat.length - 1, 0));\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n parts?.toolbar?.onKeyDown?.(event);\n if (!navigationKeys.has(event.key) || flat.length === 0) return;\n event.preventDefault();\n const next =\n event.key === 'Home'\n ? 0\n : event.key === 'End'\n ? flat.length - 1\n : (current + (event.key === 'ArrowRight' ? 1 : -1) + flat.length) % flat.length;\n setFocusIndex(next);\n buttons.current[next]?.focus();\n };\n\n const offsets = formats.map((_, groupIndex) =>\n formats.slice(0, groupIndex).reduce((total, group) => total + group.length, 0),\n );\n\n return (\n <div\n {...parts?.toolbar}\n role='toolbar'\n aria-label={labels.toolbar}\n className={classNames('cratis-markdown-editor__toolbar', parts?.toolbar?.className)}\n data-cratis-part='toolbar'\n onKeyDown={onKeyDown}\n >\n {formats.map((group, groupIndex) => (\n <Fragment key={group.join('-')}>\n {groupIndex > 0 && <span className='cratis-markdown-editor__separator' aria-hidden='true' />}\n {group.map((format, formatIndex) => {\n const index = offsets[groupIndex] + formatIndex;\n return (\n <button\n key={format}\n {...parts?.format}\n ref={element => {\n buttons.current[index] = element;\n }}\n type='button'\n className={classNames('cratis-markdown-editor__format', parts?.format?.className)}\n data-cratis-part='format'\n data-disabled={disabled || undefined}\n disabled={disabled}\n tabIndex={index === current ? 0 : -1}\n aria-label={labels[format]}\n aria-keyshortcuts={shortcutFor(format)}\n title={labels[format]}\n onMouseDown={event => event.preventDefault()}\n onFocus={() => setFocusIndex(index)}\n onClick={() => onFormat(format)}\n >\n <span className='cratis-markdown-editor__format-icon' aria-hidden='true'>\n {formatIcons[format]}\n </span>\n </button>\n );\n })}\n </Fragment>\n ))}\n </div>\n );\n};\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;AA6BA,MAAM,WAAW,GAAG,CAAC,MAAsB,KAAI;IAC3C,KAAK,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,eAAe,EAAE;QAC9C,IAAI,QAAQ,KAAK,MAAM;YAAE,OAAO,C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ACV,QAAQ,IAAI,SAAS,EACpC,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,KAAK,KAAK,OAAO,GAAG,CAAC,GAAG,EAAE,EAAA,YAAA,EACxB,MAAM,CAAC,MAAM,CAAC,EAAA,mBAAA,EACP,WAAW,CAAC,MAAM,CAAC,EACtC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,EACrB,WAAW,EAAE,KAAK,IAAI,KAAK,CAAC,cAAc,EAAE,EAC5C,OAAO,EAAE,MAAM,aAAa,CAAC,KAAK,CAAC,EACnC,OAAO,EAAE,MAAM,QAAQ,CAAC,MAAM,CAAC,EAAA,QAAA,EAE/BA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,qCAAqC,iBAAa,MAAM,EAAA,QAAA,EACnE,WAAW,CAAC,MAAM,CAAC,GACjB,EAAA,EApBF,MAAM,CAqBN;AAEjB,gBAAA,CAAC,CAAC,CAAA,EAAA,EA7BS,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CA8BnB,CACd,CAAC,EAAA,CACA;AAEd;;"}
@@ -0,0 +1,37 @@
1
+ import type { RefObject } from 'react';
2
+ import type { MarkdownEditorLabels } from './MarkdownEditorLabels.js';
3
+ import type { MarkdownEditorParts } from './MarkdownEditorParts.js';
4
+ import type { MarkdownEditorProps } from './MarkdownEditor.js';
5
+ import type { MarkdownFormat } from './MarkdownFormat.js';
6
+ import type { MarkdownTextEdit } from './MarkdownTextEdit.js';
7
+ import type { MarkdownCompletionState } from './useMarkdownCompletion.js';
8
+ import type { MarkdownUploadsState } from './useMarkdownUploads.js';
9
+ /** Props for {@link MarkdownWritingArea}. */
10
+ export interface MarkdownWritingAreaProps extends Pick<MarkdownEditorProps, 'value' | 'onChange' | 'onBlur' | 'placeholder' | 'autoFocus' | 'disabled' | 'readOnly' | 'invalid' | 'id' | 'aria-label' | 'aria-labelledby' | 'aria-describedby'> {
11
+ /** Pass-through attributes for the textarea. */
12
+ parts?: MarkdownEditorParts['textarea'];
13
+ /** The writing area's element, which the editor formats and measures. */
14
+ textareaRef: RefObject<HTMLTextAreaElement | null>;
15
+ /** The resolved labels. */
16
+ labels: Required<MarkdownEditorLabels>;
17
+ /** The completion being typed at the caret. */
18
+ completion: MarkdownCompletionState;
19
+ /** The uploads started from this editor. */
20
+ uploads: MarkdownUploadsState;
21
+ /** The element id of the suggestion list. */
22
+ suggestionsId: string;
23
+ /** The element id of the highlighted suggestion, while the list is open. */
24
+ activeOptionId?: string;
25
+ /** Called when the selection moves. */
26
+ onSelectionChange: (start: number, end: number) => void;
27
+ /** Applies an edit that also places the selection. */
28
+ onEdit: (edit: MarkdownTextEdit) => void;
29
+ /** Applies a format to the selection, as a keyboard shortcut asks. */
30
+ onFormat: (format: MarkdownFormat) => void;
31
+ }
32
+ /**
33
+ * The textarea of a {@link MarkdownEditor}, with its completion keys, formatting shortcuts, and file
34
+ * paste and drop.
35
+ */
36
+ export declare const MarkdownWritingArea: (props: MarkdownWritingAreaProps) => import("react").JSX.Element;
37
+ //# sourceMappingURL=MarkdownWritingArea.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownWritingArea.d.ts","sourceRoot":"","sources":["../../../MarkdownEditor/MarkdownWritingArea.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAA4C,SAAS,EAAkB,MAAM,OAAO,CAAC;AAEjG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAAwB,CAAC;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAoB,CAAC;AAG3D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAAyB,CAAC;AACvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAsB,CAAC;AAEjE,6CAA6C;AAC7C,MAAM,WAAW,wBACb,SAAQ,IAAI,CACR,mBAAmB,EACjB,OAAO,GACP,UAAU,GACV,QAAQ,GACR,aAAa,GACb,WAAW,GACX,UAAU,GACV,UAAU,GACV,SAAS,GACT,IAAI,GACJ,YAAY,GACZ,iBAAiB,GACjB,kBAAkB,CACvB;IACD,gDAAgD;IAChD,KAAK,CAAC,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAExC,yEAAyE;IACzE,WAAW,EAAE,SAAS,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;IAEnD,2BAA2B;IAC3B,MAAM,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAC;IAEvC,+CAA+C;IAC/C,UAAU,EAAE,uBAAuB,CAAC;IAEpC,4CAA4C;IAC5C,OAAO,EAAE,oBAAoB,CAAC;IAE9B,6CAA6C;IAC7C,aAAa,EAAE,MAAM,CAAC;IAEtB,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,uCAAuC;IACvC,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAExD,sDAAsD;IACtD,MAAM,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAEzC,sEAAsE;IACtE,QAAQ,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;CAC9C;AAID;;;GAGG;AACH,eAAO,MAAM,mBAAmB,UAAW,wBAAwB,gCAsFlE,CAAC"}
@@ -0,0 +1,65 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { classNames } from '../ClassNames/classNames.js';
3
+ import { filesIn } from './filesIn.js';
4
+ import { formatShortcuts } from './formatShortcuts.js';
5
+
6
+ const hasFiles = (event) => Array.from(event.dataTransfer.types).includes('Files');
7
+ const MarkdownWritingArea = (props) => {
8
+ const { completion, uploads, textareaRef, parts } = props;
9
+ const disabled = props.disabled ?? false;
10
+ const readOnly = props.readOnly ?? false;
11
+ const invalid = props.invalid ?? false;
12
+ const reportSelection = (event) => props.onSelectionChange(event.currentTarget.selectionStart, event.currentTarget.selectionEnd);
13
+ const onKeyDown = (event) => {
14
+ parts?.onKeyDown?.(event);
15
+ const edit = completion.handleKeyDown(event);
16
+ if (edit) {
17
+ props.onEdit(edit);
18
+ return;
19
+ }
20
+ if (event.defaultPrevented || event.altKey || event.shiftKey || !(event.ctrlKey || event.metaKey))
21
+ return;
22
+ const format = formatShortcuts.get(event.key.toLowerCase());
23
+ if (!format || disabled || readOnly)
24
+ return;
25
+ event.preventDefault();
26
+ props.onFormat(format);
27
+ };
28
+ const onPaste = (event) => {
29
+ parts?.onPaste?.(event);
30
+ if (!uploads.isEnabled)
31
+ return;
32
+ const files = filesIn(event.clipboardData.items);
33
+ if (files.length === 0)
34
+ return;
35
+ event.preventDefault();
36
+ uploads.upload(files);
37
+ };
38
+ const onDrop = (event) => {
39
+ parts?.onDrop?.(event);
40
+ if (!uploads.isEnabled)
41
+ return;
42
+ const files = Array.from(event.dataTransfer.files);
43
+ if (files.length === 0)
44
+ return;
45
+ event.preventDefault();
46
+ uploads.upload(files);
47
+ };
48
+ return (jsx("textarea", { ...parts, ref: textareaRef, id: props.id, className: classNames('cratis-markdown-editor__textarea', parts?.className), "data-cratis-part": 'textarea', "data-disabled": disabled || undefined, "data-invalid": invalid || undefined, "data-readonly": readOnly || undefined, value: props.value, placeholder: props.placeholder, disabled: disabled, readOnly: readOnly, autoFocus: props.autoFocus, spellCheck: true, "aria-label": props['aria-labelledby'] ? props['aria-label'] : (props['aria-label'] ?? props.labels.editor), "aria-labelledby": props['aria-labelledby'], "aria-describedby": props['aria-describedby'], "aria-invalid": invalid || undefined, "aria-multiline": 'true', "aria-autocomplete": completion.isOpen ? 'list' : undefined, "aria-controls": completion.isOpen ? props.suggestionsId : undefined, "aria-activedescendant": props.activeOptionId, onChange: event => {
49
+ props.onSelectionChange(event.target.selectionStart, event.target.selectionEnd);
50
+ props.onChange(event.target.value);
51
+ }, onSelect: event => {
52
+ parts?.onSelect?.(event);
53
+ reportSelection(event);
54
+ }, onKeyDown: onKeyDown, onBlur: event => {
55
+ parts?.onBlur?.(event);
56
+ props.onBlur?.();
57
+ }, onPaste: onPaste, onDrop: onDrop, onDragOver: event => {
58
+ parts?.onDragOver?.(event);
59
+ if (uploads.isEnabled && hasFiles(event))
60
+ event.preventDefault();
61
+ } }));
62
+ };
63
+
64
+ export { MarkdownWritingArea };
65
+ //# sourceMappingURL=MarkdownWritingArea.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownWritingArea.js","sources":["../../../MarkdownEditor/MarkdownWritingArea.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 type { ClipboardEvent, DragEvent, KeyboardEvent, RefObject, SyntheticEvent } from 'react';\nimport { classNames } from '../ClassNames/classNames';\nimport type { MarkdownEditorLabels } from './MarkdownEditorLabels';\nimport type { MarkdownEditorParts } from './MarkdownEditorParts';\nimport type { MarkdownEditorProps } from './MarkdownEditor';\nimport type { MarkdownFormat } from './MarkdownFormat';\nimport type { MarkdownTextEdit } from './MarkdownTextEdit';\nimport { filesIn } from './filesIn';\nimport { formatShortcuts } from './formatShortcuts';\nimport type { MarkdownCompletionState } from './useMarkdownCompletion';\nimport type { MarkdownUploadsState } from './useMarkdownUploads';\n\n/** Props for {@link MarkdownWritingArea}. */\nexport interface MarkdownWritingAreaProps\n extends Pick<\n MarkdownEditorProps,\n | 'value'\n | 'onChange'\n | 'onBlur'\n | 'placeholder'\n | 'autoFocus'\n | 'disabled'\n | 'readOnly'\n | 'invalid'\n | 'id'\n | 'aria-label'\n | 'aria-labelledby'\n | 'aria-describedby'\n > {\n /** Pass-through attributes for the textarea. */\n parts?: MarkdownEditorParts['textarea'];\n\n /** The writing area's element, which the editor formats and measures. */\n textareaRef: RefObject<HTMLTextAreaElement | null>;\n\n /** The resolved labels. */\n labels: Required<MarkdownEditorLabels>;\n\n /** The completion being typed at the caret. */\n completion: MarkdownCompletionState;\n\n /** The uploads started from this editor. */\n uploads: MarkdownUploadsState;\n\n /** The element id of the suggestion list. */\n suggestionsId: string;\n\n /** The element id of the highlighted suggestion, while the list is open. */\n activeOptionId?: string;\n\n /** Called when the selection moves. */\n onSelectionChange: (start: number, end: number) => void;\n\n /** Applies an edit that also places the selection. */\n onEdit: (edit: MarkdownTextEdit) => void;\n\n /** Applies a format to the selection, as a keyboard shortcut asks. */\n onFormat: (format: MarkdownFormat) => void;\n}\n\nconst hasFiles = (event: DragEvent<HTMLTextAreaElement>) => Array.from(event.dataTransfer.types).includes('Files');\n\n/**\n * The textarea of a {@link MarkdownEditor}, with its completion keys, formatting shortcuts, and file\n * paste and drop.\n */\nexport const MarkdownWritingArea = (props: MarkdownWritingAreaProps) => {\n const { completion, uploads, textareaRef, parts } = props;\n const disabled = props.disabled ?? false;\n const readOnly = props.readOnly ?? false;\n const invalid = props.invalid ?? false;\n\n const reportSelection = (event: SyntheticEvent<HTMLTextAreaElement>) =>\n props.onSelectionChange(event.currentTarget.selectionStart, event.currentTarget.selectionEnd);\n\n const onKeyDown = (event: KeyboardEvent<HTMLTextAreaElement>) => {\n parts?.onKeyDown?.(event);\n const edit = completion.handleKeyDown(event);\n if (edit) {\n props.onEdit(edit);\n return;\n }\n if (event.defaultPrevented || event.altKey || event.shiftKey || !(event.ctrlKey || event.metaKey)) return;\n const format = formatShortcuts.get(event.key.toLowerCase());\n if (!format || disabled || readOnly) return;\n event.preventDefault();\n props.onFormat(format);\n };\n\n const onPaste = (event: ClipboardEvent<HTMLTextAreaElement>) => {\n parts?.onPaste?.(event);\n if (!uploads.isEnabled) return;\n const files = filesIn(event.clipboardData.items);\n if (files.length === 0) return;\n event.preventDefault();\n uploads.upload(files);\n };\n\n const onDrop = (event: DragEvent<HTMLTextAreaElement>) => {\n parts?.onDrop?.(event);\n if (!uploads.isEnabled) return;\n const files = Array.from(event.dataTransfer.files);\n if (files.length === 0) return;\n event.preventDefault();\n uploads.upload(files);\n };\n\n return (\n <textarea\n {...parts}\n ref={textareaRef}\n id={props.id}\n className={classNames('cratis-markdown-editor__textarea', parts?.className)}\n data-cratis-part='textarea'\n data-disabled={disabled || undefined}\n data-invalid={invalid || undefined}\n data-readonly={readOnly || undefined}\n value={props.value}\n placeholder={props.placeholder}\n disabled={disabled}\n readOnly={readOnly}\n autoFocus={props.autoFocus}\n spellCheck\n aria-label={props['aria-labelledby'] ? props['aria-label'] : (props['aria-label'] ?? props.labels.editor)}\n aria-labelledby={props['aria-labelledby']}\n aria-describedby={props['aria-describedby']}\n aria-invalid={invalid || undefined}\n aria-multiline='true'\n aria-autocomplete={completion.isOpen ? 'list' : undefined}\n aria-controls={completion.isOpen ? props.suggestionsId : undefined}\n aria-activedescendant={props.activeOptionId}\n onChange={event => {\n props.onSelectionChange(event.target.selectionStart, event.target.selectionEnd);\n props.onChange(event.target.value);\n }}\n onSelect={event => {\n parts?.onSelect?.(event);\n reportSelection(event);\n }}\n onKeyDown={onKeyDown}\n onBlur={event => {\n parts?.onBlur?.(event);\n props.onBlur?.();\n }}\n onPaste={onPaste}\n onDrop={onDrop}\n onDragOver={event => {\n parts?.onDragOver?.(event);\n if (uploads.isEnabled && hasFiles(event)) event.preventDefault();\n }}\n />\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;AA+DA,MAAM,QAAQ,GAAG,CAAC,KAAqC,KAAK,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC;AAM3G,MAAM,mBAAmB,GAAG,CAAC,KAA+B,KAAI;IACnE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,KAAK;AACzD,IAAA,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,KAAK;AACxC,IAAA,MAAM,QA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F,UAAU,CAAC,MAAM,GAAG,MAAM,GAAG,SAAS,EAAA,eAAA,EAC1C,UAAU,CAAC,MAAM,GAAG,KAAK,CAAC,aAAa,GAAG,SAAS,EAAA,uBAAA,EAC3C,KAAK,CAAC,cAAc,EAC3C,QAAQ,EAAE,KAAK,IAAG;AACd,YAAA,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,MAAM,CAAC,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC;YAC/E,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;AACtC,QAAA,CAAC,EACD,QAAQ,EAAE,KAAK,IAAG;AACd,YAAA,KAAK,EAAE,QAAQ,GAAG,KAAK,CAAC;YACxB,eAAe,CAAC,KAAK,CAAC;QAC1B,CAAC,EACD,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,KAAK,IAAG;AACZ,YAAA,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC;AACtB,YAAA,KAAK,CAAC,MAAM,IAAI;AACpB,QAAA,CAAC,EACD,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,KAAK,IAAG;AAChB,YAAA,KAAK,EAAE,UAAU,GAAG,KAAK,CAAC;AAC1B,YAAA,IAAI,OAAO,CAAC,SAAS,IAAI,QAAQ,CAAC,KAAK,CAAC;gBAAE,KAAK,CAAC,cAAc,EAAE;QACpE,CAAC,EAAA,CACH;AAEV;;"}
@@ -0,0 +1,13 @@
1
+ import { MarkdownFormat } from './MarkdownFormat.js';
2
+ import type { MarkdownTextEdit } from './MarkdownTextEdit.js';
3
+ /**
4
+ * Applies a toolbar format to the selection in a piece of markdown. Every format is a toggle: applying
5
+ * it where it is already applied takes it off.
6
+ * @param value The markdown being edited.
7
+ * @param selectionStart Where the selection starts.
8
+ * @param selectionEnd Where the selection ends.
9
+ * @param format The {@link MarkdownFormat} to apply.
10
+ * @returns The edited markdown and the selection the writing area should show afterwards.
11
+ */
12
+ export declare const applyMarkdownFormat: (value: string, selectionStart: number, selectionEnd: number, format: MarkdownFormat) => MarkdownTextEdit;
13
+ //# sourceMappingURL=applyMarkdownFormat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyMarkdownFormat.d.ts","sourceRoot":"","sources":["../../../MarkdownEditor/applyMarkdownFormat.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAoB,CAAC;AAY3D;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,UACrB,MAAM,kBACG,MAAM,gBACR,MAAM,UACZ,cAAc,KACvB,gBA4BF,CAAC"}