notra-editor 0.5.0 → 0.7.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 (157) hide show
  1. package/dist/components/blockquote-button/blockquote-button.d.cts +2 -2
  2. package/dist/components/blockquote-button/blockquote-button.d.ts +2 -2
  3. package/dist/components/code-block-button/code-block-button.d.cts +2 -2
  4. package/dist/components/code-block-button/code-block-button.d.ts +2 -2
  5. package/dist/components/code-block-view/code-block-shell.cjs +41 -0
  6. package/dist/components/code-block-view/code-block-shell.cjs.map +1 -0
  7. package/dist/components/code-block-view/code-block-shell.d.cts +11 -0
  8. package/dist/components/code-block-view/code-block-shell.d.ts +11 -0
  9. package/dist/components/code-block-view/code-block-shell.mjs +17 -0
  10. package/dist/components/code-block-view/code-block-shell.mjs.map +1 -0
  11. package/dist/components/{code-block-view.cjs → code-block-view/code-block-view.cjs} +16 -8
  12. package/dist/components/code-block-view/code-block-view.cjs.map +1 -0
  13. package/dist/components/code-block-view/code-block-view.d.cts +6 -0
  14. package/dist/components/code-block-view/code-block-view.d.ts +6 -0
  15. package/dist/components/code-block-view/code-block-view.mjs +26 -0
  16. package/dist/components/code-block-view/code-block-view.mjs.map +1 -0
  17. package/dist/components/code-block-view/language-select.cjs +91 -0
  18. package/dist/components/code-block-view/language-select.cjs.map +1 -0
  19. package/dist/components/code-block-view/language-select.d.cts +11 -0
  20. package/dist/components/code-block-view/language-select.d.ts +11 -0
  21. package/dist/components/code-block-view/language-select.mjs +74 -0
  22. package/dist/components/code-block-view/language-select.mjs.map +1 -0
  23. package/dist/components/heading-dropdown-menu/heading-dropdown-menu.d.cts +2 -2
  24. package/dist/components/heading-dropdown-menu/heading-dropdown-menu.d.ts +2 -2
  25. package/dist/components/heading-dropdown-menu/heading-menu-item.d.cts +2 -2
  26. package/dist/components/heading-dropdown-menu/heading-menu-item.d.ts +2 -2
  27. package/dist/components/image-popover/image-popover.d.cts +2 -2
  28. package/dist/components/image-popover/image-popover.d.ts +2 -2
  29. package/dist/components/image-popover/use-image-popover.d.cts +3 -3
  30. package/dist/components/image-popover/use-image-popover.d.ts +3 -3
  31. package/dist/components/link-popover/link-popover.d.cts +2 -2
  32. package/dist/components/link-popover/link-popover.d.ts +2 -2
  33. package/dist/components/link-popover/use-link-popover.d.cts +2 -2
  34. package/dist/components/link-popover/use-link-popover.d.ts +2 -2
  35. package/dist/components/list-dropdown-menu/list-dropdown-menu.d.cts +2 -2
  36. package/dist/components/list-dropdown-menu/list-dropdown-menu.d.ts +2 -2
  37. package/dist/components/list-dropdown-menu/list-menu-item.d.cts +2 -2
  38. package/dist/components/list-dropdown-menu/list-menu-item.d.ts +2 -2
  39. package/dist/components/mark-button/mark-button.d.cts +2 -2
  40. package/dist/components/mark-button/mark-button.d.ts +2 -2
  41. package/dist/components/toolbar/toolbar.d.cts +2 -2
  42. package/dist/components/toolbar/toolbar.d.ts +2 -2
  43. package/dist/components/ui/button.d.cts +2 -2
  44. package/dist/components/ui/button.d.ts +2 -2
  45. package/dist/components/ui/command.cjs +207 -0
  46. package/dist/components/ui/command.cjs.map +1 -0
  47. package/dist/components/ui/command.d.cts +22 -0
  48. package/dist/components/ui/command.d.ts +22 -0
  49. package/dist/components/ui/command.mjs +181 -0
  50. package/dist/components/ui/command.mjs.map +1 -0
  51. package/dist/components/ui/dialog.cjs +188 -0
  52. package/dist/components/ui/dialog.cjs.map +1 -0
  53. package/dist/components/ui/dialog.d.cts +20 -0
  54. package/dist/components/ui/dialog.d.ts +20 -0
  55. package/dist/components/ui/dialog.mjs +155 -0
  56. package/dist/components/ui/dialog.mjs.map +1 -0
  57. package/dist/components/ui/dropdown-menu.cjs +3 -2
  58. package/dist/components/ui/dropdown-menu.cjs.map +1 -1
  59. package/dist/components/ui/dropdown-menu.d.cts +16 -16
  60. package/dist/components/ui/dropdown-menu.d.ts +16 -16
  61. package/dist/components/ui/dropdown-menu.mjs +3 -2
  62. package/dist/components/ui/dropdown-menu.mjs.map +1 -1
  63. package/dist/components/ui/input-group.cjs +175 -0
  64. package/dist/components/ui/input-group.cjs.map +1 -0
  65. package/dist/components/ui/input-group.d.cts +20 -0
  66. package/dist/components/ui/input-group.d.ts +20 -0
  67. package/dist/components/ui/input-group.mjs +146 -0
  68. package/dist/components/ui/input-group.mjs.map +1 -0
  69. package/dist/components/ui/input.cjs +1 -1
  70. package/dist/components/ui/input.cjs.map +1 -1
  71. package/dist/components/ui/input.d.cts +2 -2
  72. package/dist/components/ui/input.d.ts +2 -2
  73. package/dist/components/ui/input.mjs +1 -1
  74. package/dist/components/ui/input.mjs.map +1 -1
  75. package/dist/components/ui/popover.cjs +46 -6
  76. package/dist/components/ui/popover.cjs.map +1 -1
  77. package/dist/components/ui/popover.d.cts +9 -6
  78. package/dist/components/ui/popover.d.ts +9 -6
  79. package/dist/components/ui/popover.mjs +43 -6
  80. package/dist/components/ui/popover.mjs.map +1 -1
  81. package/dist/components/ui/separator.cjs +2 -1
  82. package/dist/components/ui/separator.cjs.map +1 -1
  83. package/dist/components/ui/separator.d.cts +2 -2
  84. package/dist/components/ui/separator.d.ts +2 -2
  85. package/dist/components/ui/separator.mjs +2 -1
  86. package/dist/components/ui/separator.mjs.map +1 -1
  87. package/dist/components/ui/textarea.cjs +43 -0
  88. package/dist/components/ui/textarea.cjs.map +1 -0
  89. package/dist/components/ui/textarea.d.cts +6 -0
  90. package/dist/components/ui/textarea.d.ts +6 -0
  91. package/dist/components/ui/textarea.mjs +19 -0
  92. package/dist/components/ui/textarea.mjs.map +1 -0
  93. package/dist/components/undo-redo-button/undo-redo-button.d.cts +2 -2
  94. package/dist/components/undo-redo-button/undo-redo-button.d.ts +2 -2
  95. package/dist/components/undo-redo-button/use-undo-redo.d.cts +2 -2
  96. package/dist/components/undo-redo-button/use-undo-redo.d.ts +2 -2
  97. package/dist/extensions/code-block.cjs +76 -19
  98. package/dist/extensions/code-block.cjs.map +1 -1
  99. package/dist/extensions/code-block.d.cts +7 -3
  100. package/dist/extensions/code-block.d.ts +7 -3
  101. package/dist/extensions/code-block.mjs +73 -8
  102. package/dist/extensions/code-block.mjs.map +1 -1
  103. package/dist/extensions/editor.d.cts +3 -3
  104. package/dist/extensions/editor.d.ts +3 -3
  105. package/dist/extensions/index.d.cts +1 -1
  106. package/dist/extensions/index.d.ts +1 -1
  107. package/dist/extensions/shared.cjs +5 -1
  108. package/dist/extensions/shared.cjs.map +1 -1
  109. package/dist/extensions/shared.d.cts +2 -1
  110. package/dist/extensions/shared.d.ts +2 -1
  111. package/dist/extensions/shared.mjs +5 -1
  112. package/dist/extensions/shared.mjs.map +1 -1
  113. package/dist/index.cjs +20 -2
  114. package/dist/index.cjs.map +1 -1
  115. package/dist/index.d.cts +6 -0
  116. package/dist/index.d.ts +6 -0
  117. package/dist/index.mjs +16 -1
  118. package/dist/index.mjs.map +1 -1
  119. package/dist/lib/highlight-code-to-html.cjs +38 -0
  120. package/dist/lib/highlight-code-to-html.cjs.map +1 -0
  121. package/dist/lib/highlight-code-to-html.d.cts +6 -0
  122. package/dist/lib/highlight-code-to-html.d.ts +6 -0
  123. package/dist/lib/highlight-code-to-html.mjs +14 -0
  124. package/dist/lib/highlight-code-to-html.mjs.map +1 -0
  125. package/dist/lib/languages.cjs +181 -0
  126. package/dist/lib/languages.cjs.map +1 -0
  127. package/dist/lib/languages.d.cts +24 -0
  128. package/dist/lib/languages.d.ts +24 -0
  129. package/dist/lib/languages.mjs +155 -0
  130. package/dist/lib/languages.mjs.map +1 -0
  131. package/dist/notra-reader.cjs +32 -3
  132. package/dist/notra-reader.cjs.map +1 -1
  133. package/dist/notra-reader.d.cts +11 -1
  134. package/dist/notra-reader.d.ts +11 -1
  135. package/dist/notra-reader.mjs +32 -3
  136. package/dist/notra-reader.mjs.map +1 -1
  137. package/dist/styles/globals.css +1022 -165
  138. package/dist/themes/default/editor.css +69 -0
  139. package/dist/themes/default/shared.css +165 -5
  140. package/package.json +7 -1
  141. package/dist/components/code-block-view.cjs.map +0 -1
  142. package/dist/components/code-block-view.d.cts +0 -12
  143. package/dist/components/code-block-view.d.ts +0 -12
  144. package/dist/components/code-block-view.mjs +0 -17
  145. package/dist/components/code-block-view.mjs.map +0 -1
  146. package/dist/icons/redo-icon.cjs +0 -54
  147. package/dist/icons/redo-icon.cjs.map +0 -1
  148. package/dist/icons/redo-icon.d.cts +0 -7
  149. package/dist/icons/redo-icon.d.ts +0 -7
  150. package/dist/icons/redo-icon.mjs +0 -30
  151. package/dist/icons/redo-icon.mjs.map +0 -1
  152. package/dist/icons/undo-icon.cjs +0 -54
  153. package/dist/icons/undo-icon.cjs.map +0 -1
  154. package/dist/icons/undo-icon.d.cts +0 -7
  155. package/dist/icons/undo-icon.d.ts +0 -7
  156. package/dist/icons/undo-icon.mjs +0 -30
  157. package/dist/icons/undo-icon.mjs.map +0 -1
@@ -1,6 +1,10 @@
1
1
  import * as _tiptap_core from '@tiptap/core';
2
- import * as _tiptap_extension_code_block from '@tiptap/extension-code-block';
2
+ import * as _tiptap_extension_code_block_lowlight from '@tiptap/extension-code-block-lowlight';
3
+ import { createLowlight } from 'lowlight';
3
4
 
4
- declare const CodeBlockExtension: _tiptap_core.Node<_tiptap_extension_code_block.CodeBlockOptions, any>;
5
+ type Lowlight = ReturnType<typeof createLowlight>;
6
+ declare const defaultLowlight: Lowlight;
7
+ declare function createCodeBlockExtension(lowlight: Lowlight): _tiptap_core.Node<_tiptap_extension_code_block_lowlight.CodeBlockLowlightOptions, any>;
8
+ declare const CodeBlockExtension: _tiptap_core.Node<_tiptap_extension_code_block_lowlight.CodeBlockLowlightOptions, any>;
5
9
 
6
- export { CodeBlockExtension };
10
+ export { CodeBlockExtension, createCodeBlockExtension, defaultLowlight };
@@ -1,12 +1,77 @@
1
- import CodeBlock from "@tiptap/extension-code-block";
1
+ import { textblockTypeInputRule } from "@tiptap/core";
2
+ import { CodeBlockLowlight } from "@tiptap/extension-code-block-lowlight";
2
3
  import { ReactNodeViewRenderer } from "@tiptap/react";
3
- import { CodeBlockView } from "../components/code-block-view";
4
- const CodeBlockExtension = CodeBlock.extend({
5
- addNodeView() {
6
- return ReactNodeViewRenderer(CodeBlockView);
7
- }
8
- });
4
+ import { common, createLowlight } from "lowlight";
5
+ import { CodeBlockView } from "../components/code-block-view/code-block-view";
6
+ import { normalizeLanguage } from "../lib/languages";
7
+ const defaultLowlight = createLowlight(common);
8
+ const backtickInputRegex = /^```([a-z]+)?[\s\n]$/;
9
+ const tildeInputRegex = /^~~~([a-z]+)?[\s\n]$/;
10
+ function createCodeBlockExtension(lowlight) {
11
+ return CodeBlockLowlight.configure({
12
+ lowlight,
13
+ // Tab inserts spaces instead of leaving the editor; Shift-Tab dedents.
14
+ enableTabIndentation: true,
15
+ tabSize: 2
16
+ }).extend({
17
+ addNodeView() {
18
+ return ReactNodeViewRenderer(CodeBlockView);
19
+ },
20
+ addKeyboardShortcuts() {
21
+ const parent = this.parent?.() ?? {};
22
+ return {
23
+ ...parent,
24
+ Tab: ({ editor }) => {
25
+ if (!this.options.enableTabIndentation) {
26
+ return false;
27
+ }
28
+ const tabSize = this.options.tabSize ?? 2;
29
+ const { selection } = editor.state;
30
+ const { $from, empty } = selection;
31
+ if ($from.parent.type !== this.type) {
32
+ return false;
33
+ }
34
+ const indent = " ".repeat(tabSize);
35
+ if (empty) {
36
+ return editor.commands.command(({ tr }) => {
37
+ tr.insertText(indent);
38
+ return true;
39
+ });
40
+ }
41
+ return editor.commands.command(({ tr, state }) => {
42
+ const { from, to } = selection;
43
+ const text = state.doc.textBetween(from, to, "\n", "\n");
44
+ const indented = text.split("\n").map((line) => indent + line).join("\n");
45
+ tr.replaceWith(from, to, state.schema.text(indented));
46
+ return true;
47
+ });
48
+ }
49
+ };
50
+ },
51
+ addInputRules() {
52
+ return [
53
+ textblockTypeInputRule({
54
+ find: backtickInputRegex,
55
+ type: this.type,
56
+ getAttributes: (match) => ({
57
+ language: normalizeLanguage(match[1])
58
+ })
59
+ }),
60
+ textblockTypeInputRule({
61
+ find: tildeInputRegex,
62
+ type: this.type,
63
+ getAttributes: (match) => ({
64
+ language: normalizeLanguage(match[1])
65
+ })
66
+ })
67
+ ];
68
+ }
69
+ });
70
+ }
71
+ const CodeBlockExtension = createCodeBlockExtension(defaultLowlight);
9
72
  export {
10
- CodeBlockExtension
73
+ CodeBlockExtension,
74
+ createCodeBlockExtension,
75
+ defaultLowlight
11
76
  };
12
77
  //# sourceMappingURL=code-block.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/extensions/code-block.ts"],"sourcesContent":["import CodeBlock from '@tiptap/extension-code-block';\nimport { ReactNodeViewRenderer } from '@tiptap/react';\n\nimport { CodeBlockView } from '../components/code-block-view';\n\nexport const CodeBlockExtension = CodeBlock.extend({\n\taddNodeView() {\n\t\treturn ReactNodeViewRenderer(CodeBlockView);\n\t}\n});\n"],"mappings":"AAAA,OAAO,eAAe;AACtB,SAAS,6BAA6B;AAEtC,SAAS,qBAAqB;AAEvB,MAAM,qBAAqB,UAAU,OAAO;AAAA,EAClD,cAAc;AACb,WAAO,sBAAsB,aAAa;AAAA,EAC3C;AACD,CAAC;","names":[]}
1
+ {"version":3,"sources":["../../src/extensions/code-block.ts"],"sourcesContent":["import { textblockTypeInputRule } from '@tiptap/core';\nimport { CodeBlockLowlight } from '@tiptap/extension-code-block-lowlight';\nimport { ReactNodeViewRenderer } from '@tiptap/react';\nimport { common, createLowlight } from 'lowlight';\n\nimport { CodeBlockView } from '../components/code-block-view/code-block-view';\nimport { normalizeLanguage } from '../lib/languages';\n\ntype Lowlight = ReturnType<typeof createLowlight>;\n\n// Module-level instance, shared by the default CodeBlockExtension and the\n// reader. Loads the lowlight `common` set (~37 mainstream languages, ~150 KB).\n// Consumers needing more or fewer languages should call createCodeBlockExtension\n// with their own instance and pass the same instance to <NotraReader lowlight={…} />.\nexport const defaultLowlight: Lowlight = createLowlight(common);\n\n// Mirrors the regexes in @tiptap/extension-code-block. Override the rules so\n// the captured language is collapsed to its canonical LANGUAGES value before\n// being written to the node attribute (e.g. ```js → language: \"javascript\").\nconst backtickInputRegex = /^```([a-z]+)?[\\s\\n]$/;\nconst tildeInputRegex = /^~~~([a-z]+)?[\\s\\n]$/;\n\nexport function createCodeBlockExtension(lowlight: Lowlight) {\n\treturn CodeBlockLowlight.configure({\n\t\tlowlight,\n\t\t// Tab inserts spaces instead of leaving the editor; Shift-Tab dedents.\n\t\tenableTabIndentation: true,\n\t\ttabSize: 2\n\t}).extend({\n\t\taddNodeView() {\n\t\t\treturn ReactNodeViewRenderer(CodeBlockView);\n\t\t},\n\t\taddKeyboardShortcuts() {\n\t\t\tconst parent = this.parent?.() ?? {};\n\n\t\t\t// Upstream's empty-selection Tab branch goes through\n\t\t\t// `editor.commands.insertContent(' '.repeat(tabSize))`, which\n\t\t\t// `tiptap-markdown` reroutes via its overridden `insertContentAt`\n\t\t\t// → `markdown.parser.parse(...)`. Whitespace-only input parses to\n\t\t\t// an empty document, so the spaces vanish while the keymap still\n\t\t\t// reports the event as handled. Use a raw transaction instead.\n\t\t\treturn {\n\t\t\t\t...parent,\n\t\t\t\tTab: ({ editor }) => {\n\t\t\t\t\tif (!this.options.enableTabIndentation) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst tabSize = this.options.tabSize ?? 2;\n\t\t\t\t\tconst { selection } = editor.state;\n\t\t\t\t\tconst { $from, empty } = selection;\n\n\t\t\t\t\tif ($from.parent.type !== this.type) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst indent = ' '.repeat(tabSize);\n\n\t\t\t\t\tif (empty) {\n\t\t\t\t\t\treturn editor.commands.command(({ tr }) => {\n\t\t\t\t\t\t\ttr.insertText(indent);\n\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\treturn editor.commands.command(({ tr, state }) => {\n\t\t\t\t\t\tconst { from, to } = selection;\n\t\t\t\t\t\tconst text = state.doc.textBetween(from, to, '\\n', '\\n');\n\t\t\t\t\t\tconst indented = text\n\t\t\t\t\t\t\t.split('\\n')\n\t\t\t\t\t\t\t.map((line) => indent + line)\n\t\t\t\t\t\t\t.join('\\n');\n\n\t\t\t\t\t\ttr.replaceWith(from, to, state.schema.text(indented));\n\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t};\n\t\t},\n\t\taddInputRules() {\n\t\t\treturn [\n\t\t\t\ttextblockTypeInputRule({\n\t\t\t\t\tfind: backtickInputRegex,\n\t\t\t\t\ttype: this.type,\n\t\t\t\t\tgetAttributes: (match) => ({\n\t\t\t\t\t\tlanguage: normalizeLanguage(match[1])\n\t\t\t\t\t})\n\t\t\t\t}),\n\t\t\t\ttextblockTypeInputRule({\n\t\t\t\t\tfind: tildeInputRegex,\n\t\t\t\t\ttype: this.type,\n\t\t\t\t\tgetAttributes: (match) => ({\n\t\t\t\t\t\tlanguage: normalizeLanguage(match[1])\n\t\t\t\t\t})\n\t\t\t\t})\n\t\t\t];\n\t\t}\n\t});\n}\n\nexport const CodeBlockExtension = createCodeBlockExtension(defaultLowlight);\n"],"mappings":"AAAA,SAAS,8BAA8B;AACvC,SAAS,yBAAyB;AAClC,SAAS,6BAA6B;AACtC,SAAS,QAAQ,sBAAsB;AAEvC,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAQ3B,MAAM,kBAA4B,eAAe,MAAM;AAK9D,MAAM,qBAAqB;AAC3B,MAAM,kBAAkB;AAEjB,SAAS,yBAAyB,UAAoB;AAC5D,SAAO,kBAAkB,UAAU;AAAA,IAClC;AAAA;AAAA,IAEA,sBAAsB;AAAA,IACtB,SAAS;AAAA,EACV,CAAC,EAAE,OAAO;AAAA,IACT,cAAc;AACb,aAAO,sBAAsB,aAAa;AAAA,IAC3C;AAAA,IACA,uBAAuB;AACtB,YAAM,SAAS,KAAK,SAAS,KAAK,CAAC;AAQnC,aAAO;AAAA,QACN,GAAG;AAAA,QACH,KAAK,CAAC,EAAE,OAAO,MAAM;AACpB,cAAI,CAAC,KAAK,QAAQ,sBAAsB;AACvC,mBAAO;AAAA,UACR;AAEA,gBAAM,UAAU,KAAK,QAAQ,WAAW;AACxC,gBAAM,EAAE,UAAU,IAAI,OAAO;AAC7B,gBAAM,EAAE,OAAO,MAAM,IAAI;AAEzB,cAAI,MAAM,OAAO,SAAS,KAAK,MAAM;AACpC,mBAAO;AAAA,UACR;AAEA,gBAAM,SAAS,IAAI,OAAO,OAAO;AAEjC,cAAI,OAAO;AACV,mBAAO,OAAO,SAAS,QAAQ,CAAC,EAAE,GAAG,MAAM;AAC1C,iBAAG,WAAW,MAAM;AAEpB,qBAAO;AAAA,YACR,CAAC;AAAA,UACF;AAEA,iBAAO,OAAO,SAAS,QAAQ,CAAC,EAAE,IAAI,MAAM,MAAM;AACjD,kBAAM,EAAE,MAAM,GAAG,IAAI;AACrB,kBAAM,OAAO,MAAM,IAAI,YAAY,MAAM,IAAI,MAAM,IAAI;AACvD,kBAAM,WAAW,KACf,MAAM,IAAI,EACV,IAAI,CAAC,SAAS,SAAS,IAAI,EAC3B,KAAK,IAAI;AAEX,eAAG,YAAY,MAAM,IAAI,MAAM,OAAO,KAAK,QAAQ,CAAC;AAEpD,mBAAO;AAAA,UACR,CAAC;AAAA,QACF;AAAA,MACD;AAAA,IACD;AAAA,IACA,gBAAgB;AACf,aAAO;AAAA,QACN,uBAAuB;AAAA,UACtB,MAAM;AAAA,UACN,MAAM,KAAK;AAAA,UACX,eAAe,CAAC,WAAW;AAAA,YAC1B,UAAU,kBAAkB,MAAM,CAAC,CAAC;AAAA,UACrC;AAAA,QACD,CAAC;AAAA,QACD,uBAAuB;AAAA,UACtB,MAAM;AAAA,UACN,MAAM,KAAK;AAAA,UACX,eAAe,CAAC,WAAW;AAAA,YAC1B,UAAU,kBAAkB,MAAM,CAAC,CAAC;AAAA,UACrC;AAAA,QACD,CAAC;AAAA,MACF;AAAA,IACD;AAAA,EACD,CAAC;AACF;AAEO,MAAM,qBAAqB,yBAAyB,eAAe;","names":[]}
@@ -1,10 +1,10 @@
1
1
  import * as tiptap_markdown from 'tiptap-markdown';
2
- import * as _tiptap_extension_code_block from '@tiptap/extension-code-block';
3
2
  import * as _tiptap_extension_image from '@tiptap/extension-image';
4
3
  import * as _tiptap_extension_list from '@tiptap/extension-list';
5
- import * as _tiptap_core from '@tiptap/core';
6
4
  import * as _tiptap_starter_kit from '@tiptap/starter-kit';
5
+ import * as _tiptap_core from '@tiptap/core';
6
+ import * as _tiptap_extension_code_block_lowlight from '@tiptap/extension-code-block-lowlight';
7
7
 
8
- declare const editorExtensions: (_tiptap_core.Extension<_tiptap_starter_kit.StarterKitOptions, any> | _tiptap_core.Extension<_tiptap_extension_list.ListKitOptions, any> | _tiptap_core.Node<_tiptap_extension_image.ImageOptions, any> | _tiptap_core.Node<_tiptap_extension_code_block.CodeBlockOptions, any> | _tiptap_core.Extension<tiptap_markdown.MarkdownOptions, tiptap_markdown.MarkdownStorage>)[];
8
+ declare const editorExtensions: (_tiptap_core.Node<_tiptap_extension_code_block_lowlight.CodeBlockLowlightOptions, any> | _tiptap_core.Extension<_tiptap_starter_kit.StarterKitOptions, any> | _tiptap_core.Extension<_tiptap_extension_list.ListKitOptions, any> | _tiptap_core.Node<_tiptap_extension_image.ImageOptions, any> | _tiptap_core.Extension<tiptap_markdown.MarkdownOptions, tiptap_markdown.MarkdownStorage>)[];
9
9
 
10
10
  export { editorExtensions };
@@ -1,10 +1,10 @@
1
1
  import * as tiptap_markdown from 'tiptap-markdown';
2
- import * as _tiptap_extension_code_block from '@tiptap/extension-code-block';
3
2
  import * as _tiptap_extension_image from '@tiptap/extension-image';
4
3
  import * as _tiptap_extension_list from '@tiptap/extension-list';
5
- import * as _tiptap_core from '@tiptap/core';
6
4
  import * as _tiptap_starter_kit from '@tiptap/starter-kit';
5
+ import * as _tiptap_core from '@tiptap/core';
6
+ import * as _tiptap_extension_code_block_lowlight from '@tiptap/extension-code-block-lowlight';
7
7
 
8
- declare const editorExtensions: (_tiptap_core.Extension<_tiptap_starter_kit.StarterKitOptions, any> | _tiptap_core.Extension<_tiptap_extension_list.ListKitOptions, any> | _tiptap_core.Node<_tiptap_extension_image.ImageOptions, any> | _tiptap_core.Node<_tiptap_extension_code_block.CodeBlockOptions, any> | _tiptap_core.Extension<tiptap_markdown.MarkdownOptions, tiptap_markdown.MarkdownStorage>)[];
8
+ declare const editorExtensions: (_tiptap_core.Node<_tiptap_extension_code_block_lowlight.CodeBlockLowlightOptions, any> | _tiptap_core.Extension<_tiptap_starter_kit.StarterKitOptions, any> | _tiptap_core.Extension<_tiptap_extension_list.ListKitOptions, any> | _tiptap_core.Node<_tiptap_extension_image.ImageOptions, any> | _tiptap_core.Extension<tiptap_markdown.MarkdownOptions, tiptap_markdown.MarkdownStorage>)[];
9
9
 
10
10
  export { editorExtensions };
@@ -3,6 +3,6 @@ export { editorExtensions } from './editor.cjs';
3
3
  import '@tiptap/extension-image';
4
4
  import '@tiptap/extension-list';
5
5
  import '@tiptap/core';
6
+ import '@tiptap/extension-code-block-lowlight';
6
7
  import '@tiptap/starter-kit';
7
8
  import 'tiptap-markdown';
8
- import '@tiptap/extension-code-block';
@@ -3,6 +3,6 @@ export { editorExtensions } from './editor.js';
3
3
  import '@tiptap/extension-image';
4
4
  import '@tiptap/extension-list';
5
5
  import '@tiptap/core';
6
+ import '@tiptap/extension-code-block-lowlight';
6
7
  import '@tiptap/starter-kit';
7
8
  import 'tiptap-markdown';
8
- import '@tiptap/extension-code-block';
@@ -35,6 +35,7 @@ module.exports = __toCommonJS(shared_exports);
35
35
  var import_extension_image = __toESM(require("@tiptap/extension-image"), 1);
36
36
  var import_extension_list = require("@tiptap/extension-list");
37
37
  var import_starter_kit = __toESM(require("@tiptap/starter-kit"), 1);
38
+ var import_code_block = require("./code-block");
38
39
  const starterKitBaseConfig = {
39
40
  heading: { levels: [1, 2, 3, 4, 5, 6] },
40
41
  link: {
@@ -45,7 +46,9 @@ const starterKitBaseConfig = {
45
46
  bulletList: false,
46
47
  orderedList: false,
47
48
  listItem: false,
48
- listKeymap: false
49
+ listKeymap: false,
50
+ // Disable StarterKit's vanilla code-block; use the lowlight one instead
51
+ codeBlock: false
49
52
  };
50
53
  const sharedExtensions = [
51
54
  import_starter_kit.default.configure({
@@ -56,6 +59,7 @@ const sharedExtensions = [
56
59
  trailingNode: false
57
60
  }),
58
61
  import_extension_list.ListKit,
62
+ import_code_block.CodeBlockExtension,
59
63
  import_extension_image.default
60
64
  ];
61
65
  // Annotate the CommonJS export names for ESM import in node:
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/extensions/shared.ts"],"sourcesContent":["import Image from '@tiptap/extension-image';\nimport { ListKit } from '@tiptap/extension-list';\nimport StarterKit, { type StarterKitOptions } from '@tiptap/starter-kit';\n\n// Shared StarterKit config: content nodes/marks, no lists (use ListKit instead)\nexport const starterKitBaseConfig: Partial<StarterKitOptions> = {\n\theading: { levels: [1, 2, 3, 4, 5, 6] },\n\tlink: {\n\t\topenOnClick: false,\n\t\tautolink: true\n\t},\n\t// Disable StarterKit's built-in list handling; use @tiptap/extension-list instead\n\tbulletList: false,\n\torderedList: false,\n\tlistItem: false,\n\tlistKeymap: false\n};\n\n// Content model extensions — shared by editor and reader\n// No interactive features (dropcursor, gapcursor, undoRedo, trailingNode)\nexport const sharedExtensions = [\n\tStarterKit.configure({\n\t\t...starterKitBaseConfig,\n\t\tdropcursor: false,\n\t\tgapcursor: false,\n\t\tundoRedo: false,\n\t\ttrailingNode: false\n\t}),\n\tListKit,\n\tImage\n];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAAkB;AAClB,4BAAwB;AACxB,yBAAmD;AAG5C,MAAM,uBAAmD;AAAA,EAC/D,SAAS,EAAE,QAAQ,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,EAAE;AAAA,EACtC,MAAM;AAAA,IACL,aAAa;AAAA,IACb,UAAU;AAAA,EACX;AAAA;AAAA,EAEA,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,UAAU;AAAA,EACV,YAAY;AACb;AAIO,MAAM,mBAAmB;AAAA,EAC/B,mBAAAA,QAAW,UAAU;AAAA,IACpB,GAAG;AAAA,IACH,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,UAAU;AAAA,IACV,cAAc;AAAA,EACf,CAAC;AAAA,EACD;AAAA,EACA,uBAAAC;AACD;","names":["StarterKit","Image"]}
1
+ {"version":3,"sources":["../../src/extensions/shared.ts"],"sourcesContent":["import Image from '@tiptap/extension-image';\nimport { ListKit } from '@tiptap/extension-list';\nimport StarterKit, { type StarterKitOptions } from '@tiptap/starter-kit';\n\nimport { CodeBlockExtension } from './code-block';\n\n// Shared StarterKit config: content nodes/marks, no lists (use ListKit instead),\n// no codeBlock (use the lowlight-extended CodeBlockExtension instead).\nexport const starterKitBaseConfig: Partial<StarterKitOptions> = {\n\theading: { levels: [1, 2, 3, 4, 5, 6] },\n\tlink: {\n\t\topenOnClick: false,\n\t\tautolink: true\n\t},\n\t// Disable StarterKit's built-in list handling; use @tiptap/extension-list instead\n\tbulletList: false,\n\torderedList: false,\n\tlistItem: false,\n\tlistKeymap: false,\n\t// Disable StarterKit's vanilla code-block; use the lowlight one instead\n\tcodeBlock: false\n};\n\n// Content model extensions — shared by editor and reader\n// No interactive features (dropcursor, gapcursor, undoRedo, trailingNode)\nexport const sharedExtensions = [\n\tStarterKit.configure({\n\t\t...starterKitBaseConfig,\n\t\tdropcursor: false,\n\t\tgapcursor: false,\n\t\tundoRedo: false,\n\t\ttrailingNode: false\n\t}),\n\tListKit,\n\tCodeBlockExtension,\n\tImage\n];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAAkB;AAClB,4BAAwB;AACxB,yBAAmD;AAEnD,wBAAmC;AAI5B,MAAM,uBAAmD;AAAA,EAC/D,SAAS,EAAE,QAAQ,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,EAAE;AAAA,EACtC,MAAM;AAAA,IACL,aAAa;AAAA,IACb,UAAU;AAAA,EACX;AAAA;AAAA,EAEA,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,UAAU;AAAA,EACV,YAAY;AAAA;AAAA,EAEZ,WAAW;AACZ;AAIO,MAAM,mBAAmB;AAAA,EAC/B,mBAAAA,QAAW,UAAU;AAAA,IACpB,GAAG;AAAA,IACH,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,UAAU;AAAA,IACV,cAAc;AAAA,EACf,CAAC;AAAA,EACD;AAAA,EACA;AAAA,EACA,uBAAAC;AACD;","names":["StarterKit","Image"]}
@@ -1,9 +1,10 @@
1
1
  import * as _tiptap_extension_image from '@tiptap/extension-image';
2
2
  import * as _tiptap_extension_list from '@tiptap/extension-list';
3
3
  import * as _tiptap_core from '@tiptap/core';
4
+ import * as _tiptap_extension_code_block_lowlight from '@tiptap/extension-code-block-lowlight';
4
5
  import { StarterKitOptions } from '@tiptap/starter-kit';
5
6
 
6
7
  declare const starterKitBaseConfig: Partial<StarterKitOptions>;
7
- declare const sharedExtensions: (_tiptap_core.Extension<StarterKitOptions, any> | _tiptap_core.Extension<_tiptap_extension_list.ListKitOptions, any> | _tiptap_core.Node<_tiptap_extension_image.ImageOptions, any>)[];
8
+ declare const sharedExtensions: (_tiptap_core.Node<_tiptap_extension_code_block_lowlight.CodeBlockLowlightOptions, any> | _tiptap_core.Extension<StarterKitOptions, any> | _tiptap_core.Extension<_tiptap_extension_list.ListKitOptions, any> | _tiptap_core.Node<_tiptap_extension_image.ImageOptions, any>)[];
8
9
 
9
10
  export { sharedExtensions, starterKitBaseConfig };
@@ -1,9 +1,10 @@
1
1
  import * as _tiptap_extension_image from '@tiptap/extension-image';
2
2
  import * as _tiptap_extension_list from '@tiptap/extension-list';
3
3
  import * as _tiptap_core from '@tiptap/core';
4
+ import * as _tiptap_extension_code_block_lowlight from '@tiptap/extension-code-block-lowlight';
4
5
  import { StarterKitOptions } from '@tiptap/starter-kit';
5
6
 
6
7
  declare const starterKitBaseConfig: Partial<StarterKitOptions>;
7
- declare const sharedExtensions: (_tiptap_core.Extension<StarterKitOptions, any> | _tiptap_core.Extension<_tiptap_extension_list.ListKitOptions, any> | _tiptap_core.Node<_tiptap_extension_image.ImageOptions, any>)[];
8
+ declare const sharedExtensions: (_tiptap_core.Node<_tiptap_extension_code_block_lowlight.CodeBlockLowlightOptions, any> | _tiptap_core.Extension<StarterKitOptions, any> | _tiptap_core.Extension<_tiptap_extension_list.ListKitOptions, any> | _tiptap_core.Node<_tiptap_extension_image.ImageOptions, any>)[];
8
9
 
9
10
  export { sharedExtensions, starterKitBaseConfig };
@@ -1,6 +1,7 @@
1
1
  import Image from "@tiptap/extension-image";
2
2
  import { ListKit } from "@tiptap/extension-list";
3
3
  import StarterKit from "@tiptap/starter-kit";
4
+ import { CodeBlockExtension } from "./code-block";
4
5
  const starterKitBaseConfig = {
5
6
  heading: { levels: [1, 2, 3, 4, 5, 6] },
6
7
  link: {
@@ -11,7 +12,9 @@ const starterKitBaseConfig = {
11
12
  bulletList: false,
12
13
  orderedList: false,
13
14
  listItem: false,
14
- listKeymap: false
15
+ listKeymap: false,
16
+ // Disable StarterKit's vanilla code-block; use the lowlight one instead
17
+ codeBlock: false
15
18
  };
16
19
  const sharedExtensions = [
17
20
  StarterKit.configure({
@@ -22,6 +25,7 @@ const sharedExtensions = [
22
25
  trailingNode: false
23
26
  }),
24
27
  ListKit,
28
+ CodeBlockExtension,
25
29
  Image
26
30
  ];
27
31
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/extensions/shared.ts"],"sourcesContent":["import Image from '@tiptap/extension-image';\nimport { ListKit } from '@tiptap/extension-list';\nimport StarterKit, { type StarterKitOptions } from '@tiptap/starter-kit';\n\n// Shared StarterKit config: content nodes/marks, no lists (use ListKit instead)\nexport const starterKitBaseConfig: Partial<StarterKitOptions> = {\n\theading: { levels: [1, 2, 3, 4, 5, 6] },\n\tlink: {\n\t\topenOnClick: false,\n\t\tautolink: true\n\t},\n\t// Disable StarterKit's built-in list handling; use @tiptap/extension-list instead\n\tbulletList: false,\n\torderedList: false,\n\tlistItem: false,\n\tlistKeymap: false\n};\n\n// Content model extensions — shared by editor and reader\n// No interactive features (dropcursor, gapcursor, undoRedo, trailingNode)\nexport const sharedExtensions = [\n\tStarterKit.configure({\n\t\t...starterKitBaseConfig,\n\t\tdropcursor: false,\n\t\tgapcursor: false,\n\t\tundoRedo: false,\n\t\ttrailingNode: false\n\t}),\n\tListKit,\n\tImage\n];\n"],"mappings":"AAAA,OAAO,WAAW;AAClB,SAAS,eAAe;AACxB,OAAO,gBAA4C;AAG5C,MAAM,uBAAmD;AAAA,EAC/D,SAAS,EAAE,QAAQ,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,EAAE;AAAA,EACtC,MAAM;AAAA,IACL,aAAa;AAAA,IACb,UAAU;AAAA,EACX;AAAA;AAAA,EAEA,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,UAAU;AAAA,EACV,YAAY;AACb;AAIO,MAAM,mBAAmB;AAAA,EAC/B,WAAW,UAAU;AAAA,IACpB,GAAG;AAAA,IACH,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,UAAU;AAAA,IACV,cAAc;AAAA,EACf,CAAC;AAAA,EACD;AAAA,EACA;AACD;","names":[]}
1
+ {"version":3,"sources":["../../src/extensions/shared.ts"],"sourcesContent":["import Image from '@tiptap/extension-image';\nimport { ListKit } from '@tiptap/extension-list';\nimport StarterKit, { type StarterKitOptions } from '@tiptap/starter-kit';\n\nimport { CodeBlockExtension } from './code-block';\n\n// Shared StarterKit config: content nodes/marks, no lists (use ListKit instead),\n// no codeBlock (use the lowlight-extended CodeBlockExtension instead).\nexport const starterKitBaseConfig: Partial<StarterKitOptions> = {\n\theading: { levels: [1, 2, 3, 4, 5, 6] },\n\tlink: {\n\t\topenOnClick: false,\n\t\tautolink: true\n\t},\n\t// Disable StarterKit's built-in list handling; use @tiptap/extension-list instead\n\tbulletList: false,\n\torderedList: false,\n\tlistItem: false,\n\tlistKeymap: false,\n\t// Disable StarterKit's vanilla code-block; use the lowlight one instead\n\tcodeBlock: false\n};\n\n// Content model extensions — shared by editor and reader\n// No interactive features (dropcursor, gapcursor, undoRedo, trailingNode)\nexport const sharedExtensions = [\n\tStarterKit.configure({\n\t\t...starterKitBaseConfig,\n\t\tdropcursor: false,\n\t\tgapcursor: false,\n\t\tundoRedo: false,\n\t\ttrailingNode: false\n\t}),\n\tListKit,\n\tCodeBlockExtension,\n\tImage\n];\n"],"mappings":"AAAA,OAAO,WAAW;AAClB,SAAS,eAAe;AACxB,OAAO,gBAA4C;AAEnD,SAAS,0BAA0B;AAI5B,MAAM,uBAAmD;AAAA,EAC/D,SAAS,EAAE,QAAQ,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,EAAE;AAAA,EACtC,MAAM;AAAA,IACL,aAAa;AAAA,IACb,UAAU;AAAA,EACX;AAAA;AAAA,EAEA,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,UAAU;AAAA,EACV,YAAY;AAAA;AAAA,EAEZ,WAAW;AACZ;AAIO,MAAM,mBAAmB;AAAA,EAC/B,WAAW,UAAU;AAAA,IACpB,GAAG;AAAA,IACH,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,UAAU;AAAA,IACV,cAAc;AAAA,EACf,CAAC;AAAA,EACD;AAAA,EACA;AAAA,EACA;AACD;","names":[]}
package/dist/index.cjs CHANGED
@@ -20,8 +20,11 @@ var index_exports = {};
20
20
  __export(index_exports, {
21
21
  BlockquoteButton: () => import_blockquote_button.BlockquoteButton,
22
22
  CodeBlockButton: () => import_code_block_button.CodeBlockButton,
23
+ CodeBlockExtension: () => import_code_block.CodeBlockExtension,
23
24
  HeadingDropdownMenu: () => import_heading_dropdown_menu.HeadingDropdownMenu,
24
25
  ImagePopover: () => import_image_popover.ImagePopover,
26
+ LANGUAGES: () => import_languages.LANGUAGES,
27
+ LanguageSelect: () => import_language_select.LanguageSelect,
25
28
  LinkPopover: () => import_link_popover.LinkPopover,
26
29
  ListDropdownMenu: () => import_list_dropdown_menu.ListDropdownMenu,
27
30
  MarkButton: () => import_mark_button.MarkButton,
@@ -31,7 +34,11 @@ __export(index_exports, {
31
34
  Toolbar: () => import_toolbar.Toolbar,
32
35
  ToolbarGroup: () => import_toolbar.ToolbarGroup,
33
36
  ToolbarSeparator: () => import_toolbar.ToolbarSeparator,
34
- UndoRedoButton: () => import_undo_redo_button.UndoRedoButton
37
+ UndoRedoButton: () => import_undo_redo_button.UndoRedoButton,
38
+ createCodeBlockExtension: () => import_code_block.createCodeBlockExtension,
39
+ defaultLowlight: () => import_code_block.defaultLowlight,
40
+ getLanguageLabel: () => import_languages.getLanguageLabel,
41
+ highlightCodeToHtml: () => import_highlight_code_to_html.highlightCodeToHtml
35
42
  });
36
43
  module.exports = __toCommonJS(index_exports);
37
44
  var import_globals = require("./styles/globals.css");
@@ -47,12 +54,19 @@ var import_blockquote_button = require("./components/blockquote-button/blockquot
47
54
  var import_code_block_button = require("./components/code-block-button/code-block-button");
48
55
  var import_link_popover = require("./components/link-popover/link-popover");
49
56
  var import_image_popover = require("./components/image-popover/image-popover");
57
+ var import_code_block = require("./extensions/code-block");
58
+ var import_language_select = require("./components/code-block-view/language-select");
59
+ var import_languages = require("./lib/languages");
60
+ var import_highlight_code_to_html = require("./lib/highlight-code-to-html");
50
61
  // Annotate the CommonJS export names for ESM import in node:
51
62
  0 && (module.exports = {
52
63
  BlockquoteButton,
53
64
  CodeBlockButton,
65
+ CodeBlockExtension,
54
66
  HeadingDropdownMenu,
55
67
  ImagePopover,
68
+ LANGUAGES,
69
+ LanguageSelect,
56
70
  LinkPopover,
57
71
  ListDropdownMenu,
58
72
  MarkButton,
@@ -62,6 +76,10 @@ var import_image_popover = require("./components/image-popover/image-popover");
62
76
  Toolbar,
63
77
  ToolbarGroup,
64
78
  ToolbarSeparator,
65
- UndoRedoButton
79
+ UndoRedoButton,
80
+ createCodeBlockExtension,
81
+ defaultLowlight,
82
+ getLanguageLabel,
83
+ highlightCodeToHtml
66
84
  });
67
85
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import './styles/globals.css';\n\nexport { NotraEditor } from './notra-editor';\nexport type { NotraEditorProps } from './notra-editor';\n\nexport { NotraReader } from './notra-reader';\nexport type { NotraReaderProps } from './notra-reader';\n\nexport {\n\tToolbar,\n\tToolbarGroup,\n\tToolbarSeparator\n} from './components/toolbar/toolbar';\nexport type {\n\tToolbarProps,\n\tToolbarSeparatorProps\n} from './components/toolbar/toolbar';\n\nexport { UndoRedoButton } from './components/undo-redo-button/undo-redo-button';\nexport type { UndoRedoButtonProps } from './components/undo-redo-button/undo-redo-button';\n\nexport { Spacer } from './components/ui/spacer';\n\nexport { MarkButton } from './components/mark-button/mark-button';\nexport type { MarkButtonProps } from './components/mark-button/mark-button';\nexport type { MarkType } from './components/mark-button/use-mark';\n\nexport { HeadingDropdownMenu } from './components/heading-dropdown-menu/heading-dropdown-menu';\nexport type { HeadingDropdownMenuProps } from './components/heading-dropdown-menu/heading-dropdown-menu';\n\nexport { ListDropdownMenu } from './components/list-dropdown-menu/list-dropdown-menu';\nexport type { ListDropdownMenuProps } from './components/list-dropdown-menu/list-dropdown-menu';\n\nexport { BlockquoteButton } from './components/blockquote-button/blockquote-button';\nexport type { BlockquoteButtonProps } from './components/blockquote-button/blockquote-button';\n\nexport { CodeBlockButton } from './components/code-block-button/code-block-button';\nexport type { CodeBlockButtonProps } from './components/code-block-button/code-block-button';\n\nexport { LinkPopover } from './components/link-popover/link-popover';\nexport type { LinkPopoverProps } from './components/link-popover/link-popover';\n\nexport { ImagePopover } from './components/image-popover/image-popover';\nexport type { ImagePopoverProps } from './components/image-popover/image-popover';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAO;AAEP,0BAA4B;AAG5B,0BAA4B;AAG5B,qBAIO;AAMP,8BAA+B;AAG/B,oBAAuB;AAEvB,yBAA2B;AAI3B,mCAAoC;AAGpC,gCAAiC;AAGjC,+BAAiC;AAGjC,+BAAgC;AAGhC,0BAA4B;AAG5B,2BAA6B;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import './styles/globals.css';\n\nexport { NotraEditor } from './notra-editor';\nexport type { NotraEditorProps } from './notra-editor';\n\nexport { NotraReader } from './notra-reader';\nexport type { NotraReaderProps } from './notra-reader';\n\nexport {\n\tToolbar,\n\tToolbarGroup,\n\tToolbarSeparator\n} from './components/toolbar/toolbar';\nexport type {\n\tToolbarProps,\n\tToolbarSeparatorProps\n} from './components/toolbar/toolbar';\n\nexport { UndoRedoButton } from './components/undo-redo-button/undo-redo-button';\nexport type { UndoRedoButtonProps } from './components/undo-redo-button/undo-redo-button';\n\nexport { Spacer } from './components/ui/spacer';\n\nexport { MarkButton } from './components/mark-button/mark-button';\nexport type { MarkButtonProps } from './components/mark-button/mark-button';\nexport type { MarkType } from './components/mark-button/use-mark';\n\nexport { HeadingDropdownMenu } from './components/heading-dropdown-menu/heading-dropdown-menu';\nexport type { HeadingDropdownMenuProps } from './components/heading-dropdown-menu/heading-dropdown-menu';\n\nexport { ListDropdownMenu } from './components/list-dropdown-menu/list-dropdown-menu';\nexport type { ListDropdownMenuProps } from './components/list-dropdown-menu/list-dropdown-menu';\n\nexport { BlockquoteButton } from './components/blockquote-button/blockquote-button';\nexport type { BlockquoteButtonProps } from './components/blockquote-button/blockquote-button';\n\nexport { CodeBlockButton } from './components/code-block-button/code-block-button';\nexport type { CodeBlockButtonProps } from './components/code-block-button/code-block-button';\n\nexport { LinkPopover } from './components/link-popover/link-popover';\nexport type { LinkPopoverProps } from './components/link-popover/link-popover';\n\nexport { ImagePopover } from './components/image-popover/image-popover';\nexport type { ImagePopoverProps } from './components/image-popover/image-popover';\n\nexport {\n\tCodeBlockExtension,\n\tcreateCodeBlockExtension,\n\tdefaultLowlight\n} from './extensions/code-block';\n\nexport { LanguageSelect } from './components/code-block-view/language-select';\nexport type { LanguageSelectProps } from './components/code-block-view/language-select';\n\nexport { LANGUAGES, getLanguageLabel } from './lib/languages';\nexport type { Language } from './lib/languages';\n\nexport { highlightCodeToHtml } from './lib/highlight-code-to-html';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAO;AAEP,0BAA4B;AAG5B,0BAA4B;AAG5B,qBAIO;AAMP,8BAA+B;AAG/B,oBAAuB;AAEvB,yBAA2B;AAI3B,mCAAoC;AAGpC,gCAAiC;AAGjC,+BAAiC;AAGjC,+BAAgC;AAGhC,0BAA4B;AAG5B,2BAA6B;AAG7B,wBAIO;AAEP,6BAA+B;AAG/B,uBAA4C;AAG5C,oCAAoC;","names":[]}
package/dist/index.d.cts CHANGED
@@ -11,7 +11,12 @@ export { BlockquoteButton, BlockquoteButtonProps } from './components/blockquote
11
11
  export { CodeBlockButton, CodeBlockButtonProps } from './components/code-block-button/code-block-button.cjs';
12
12
  export { LinkPopover, LinkPopoverProps } from './components/link-popover/link-popover.cjs';
13
13
  export { ImagePopover, ImagePopoverProps } from './components/image-popover/image-popover.cjs';
14
+ export { CodeBlockExtension, createCodeBlockExtension, defaultLowlight } from './extensions/code-block.cjs';
15
+ export { LanguageSelect, LanguageSelectProps } from './components/code-block-view/language-select.cjs';
16
+ export { LANGUAGES, Language, getLanguageLabel } from './lib/languages.cjs';
17
+ export { highlightCodeToHtml } from './lib/highlight-code-to-html.cjs';
14
18
  import 'react/jsx-runtime';
19
+ import 'lowlight';
15
20
  import 'react';
16
21
  import './components/undo-redo-button/use-undo-redo.cjs';
17
22
  import 'lucide-react';
@@ -21,3 +26,4 @@ import './components/ui/button.cjs';
21
26
  import 'class-variance-authority/types';
22
27
  import 'class-variance-authority';
23
28
  import './components/list-dropdown-menu/use-list.cjs';
29
+ import '@tiptap/extension-code-block-lowlight';
package/dist/index.d.ts CHANGED
@@ -11,7 +11,12 @@ export { BlockquoteButton, BlockquoteButtonProps } from './components/blockquote
11
11
  export { CodeBlockButton, CodeBlockButtonProps } from './components/code-block-button/code-block-button.js';
12
12
  export { LinkPopover, LinkPopoverProps } from './components/link-popover/link-popover.js';
13
13
  export { ImagePopover, ImagePopoverProps } from './components/image-popover/image-popover.js';
14
+ export { CodeBlockExtension, createCodeBlockExtension, defaultLowlight } from './extensions/code-block.js';
15
+ export { LanguageSelect, LanguageSelectProps } from './components/code-block-view/language-select.js';
16
+ export { LANGUAGES, Language, getLanguageLabel } from './lib/languages.js';
17
+ export { highlightCodeToHtml } from './lib/highlight-code-to-html.js';
14
18
  import 'react/jsx-runtime';
19
+ import 'lowlight';
15
20
  import 'react';
16
21
  import './components/undo-redo-button/use-undo-redo.js';
17
22
  import 'lucide-react';
@@ -21,3 +26,4 @@ import './components/ui/button.js';
21
26
  import 'class-variance-authority/types';
22
27
  import 'class-variance-authority';
23
28
  import './components/list-dropdown-menu/use-list.js';
29
+ import '@tiptap/extension-code-block-lowlight';
package/dist/index.mjs CHANGED
@@ -15,11 +15,22 @@ import { BlockquoteButton } from "./components/blockquote-button/blockquote-butt
15
15
  import { CodeBlockButton } from "./components/code-block-button/code-block-button";
16
16
  import { LinkPopover } from "./components/link-popover/link-popover";
17
17
  import { ImagePopover } from "./components/image-popover/image-popover";
18
+ import {
19
+ CodeBlockExtension,
20
+ createCodeBlockExtension,
21
+ defaultLowlight
22
+ } from "./extensions/code-block";
23
+ import { LanguageSelect } from "./components/code-block-view/language-select";
24
+ import { LANGUAGES, getLanguageLabel } from "./lib/languages";
25
+ import { highlightCodeToHtml } from "./lib/highlight-code-to-html";
18
26
  export {
19
27
  BlockquoteButton,
20
28
  CodeBlockButton,
29
+ CodeBlockExtension,
21
30
  HeadingDropdownMenu,
22
31
  ImagePopover,
32
+ LANGUAGES,
33
+ LanguageSelect,
23
34
  LinkPopover,
24
35
  ListDropdownMenu,
25
36
  MarkButton,
@@ -29,6 +40,10 @@ export {
29
40
  Toolbar,
30
41
  ToolbarGroup,
31
42
  ToolbarSeparator,
32
- UndoRedoButton
43
+ UndoRedoButton,
44
+ createCodeBlockExtension,
45
+ defaultLowlight,
46
+ getLanguageLabel,
47
+ highlightCodeToHtml
33
48
  };
34
49
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import './styles/globals.css';\n\nexport { NotraEditor } from './notra-editor';\nexport type { NotraEditorProps } from './notra-editor';\n\nexport { NotraReader } from './notra-reader';\nexport type { NotraReaderProps } from './notra-reader';\n\nexport {\n\tToolbar,\n\tToolbarGroup,\n\tToolbarSeparator\n} from './components/toolbar/toolbar';\nexport type {\n\tToolbarProps,\n\tToolbarSeparatorProps\n} from './components/toolbar/toolbar';\n\nexport { UndoRedoButton } from './components/undo-redo-button/undo-redo-button';\nexport type { UndoRedoButtonProps } from './components/undo-redo-button/undo-redo-button';\n\nexport { Spacer } from './components/ui/spacer';\n\nexport { MarkButton } from './components/mark-button/mark-button';\nexport type { MarkButtonProps } from './components/mark-button/mark-button';\nexport type { MarkType } from './components/mark-button/use-mark';\n\nexport { HeadingDropdownMenu } from './components/heading-dropdown-menu/heading-dropdown-menu';\nexport type { HeadingDropdownMenuProps } from './components/heading-dropdown-menu/heading-dropdown-menu';\n\nexport { ListDropdownMenu } from './components/list-dropdown-menu/list-dropdown-menu';\nexport type { ListDropdownMenuProps } from './components/list-dropdown-menu/list-dropdown-menu';\n\nexport { BlockquoteButton } from './components/blockquote-button/blockquote-button';\nexport type { BlockquoteButtonProps } from './components/blockquote-button/blockquote-button';\n\nexport { CodeBlockButton } from './components/code-block-button/code-block-button';\nexport type { CodeBlockButtonProps } from './components/code-block-button/code-block-button';\n\nexport { LinkPopover } from './components/link-popover/link-popover';\nexport type { LinkPopoverProps } from './components/link-popover/link-popover';\n\nexport { ImagePopover } from './components/image-popover/image-popover';\nexport type { ImagePopoverProps } from './components/image-popover/image-popover';\n"],"mappings":"AAAA,OAAO;AAEP,SAAS,mBAAmB;AAG5B,SAAS,mBAAmB;AAG5B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAMP,SAAS,sBAAsB;AAG/B,SAAS,cAAc;AAEvB,SAAS,kBAAkB;AAI3B,SAAS,2BAA2B;AAGpC,SAAS,wBAAwB;AAGjC,SAAS,wBAAwB;AAGjC,SAAS,uBAAuB;AAGhC,SAAS,mBAAmB;AAG5B,SAAS,oBAAoB;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import './styles/globals.css';\n\nexport { NotraEditor } from './notra-editor';\nexport type { NotraEditorProps } from './notra-editor';\n\nexport { NotraReader } from './notra-reader';\nexport type { NotraReaderProps } from './notra-reader';\n\nexport {\n\tToolbar,\n\tToolbarGroup,\n\tToolbarSeparator\n} from './components/toolbar/toolbar';\nexport type {\n\tToolbarProps,\n\tToolbarSeparatorProps\n} from './components/toolbar/toolbar';\n\nexport { UndoRedoButton } from './components/undo-redo-button/undo-redo-button';\nexport type { UndoRedoButtonProps } from './components/undo-redo-button/undo-redo-button';\n\nexport { Spacer } from './components/ui/spacer';\n\nexport { MarkButton } from './components/mark-button/mark-button';\nexport type { MarkButtonProps } from './components/mark-button/mark-button';\nexport type { MarkType } from './components/mark-button/use-mark';\n\nexport { HeadingDropdownMenu } from './components/heading-dropdown-menu/heading-dropdown-menu';\nexport type { HeadingDropdownMenuProps } from './components/heading-dropdown-menu/heading-dropdown-menu';\n\nexport { ListDropdownMenu } from './components/list-dropdown-menu/list-dropdown-menu';\nexport type { ListDropdownMenuProps } from './components/list-dropdown-menu/list-dropdown-menu';\n\nexport { BlockquoteButton } from './components/blockquote-button/blockquote-button';\nexport type { BlockquoteButtonProps } from './components/blockquote-button/blockquote-button';\n\nexport { CodeBlockButton } from './components/code-block-button/code-block-button';\nexport type { CodeBlockButtonProps } from './components/code-block-button/code-block-button';\n\nexport { LinkPopover } from './components/link-popover/link-popover';\nexport type { LinkPopoverProps } from './components/link-popover/link-popover';\n\nexport { ImagePopover } from './components/image-popover/image-popover';\nexport type { ImagePopoverProps } from './components/image-popover/image-popover';\n\nexport {\n\tCodeBlockExtension,\n\tcreateCodeBlockExtension,\n\tdefaultLowlight\n} from './extensions/code-block';\n\nexport { LanguageSelect } from './components/code-block-view/language-select';\nexport type { LanguageSelectProps } from './components/code-block-view/language-select';\n\nexport { LANGUAGES, getLanguageLabel } from './lib/languages';\nexport type { Language } from './lib/languages';\n\nexport { highlightCodeToHtml } from './lib/highlight-code-to-html';\n"],"mappings":"AAAA,OAAO;AAEP,SAAS,mBAAmB;AAG5B,SAAS,mBAAmB;AAG5B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAMP,SAAS,sBAAsB;AAG/B,SAAS,cAAc;AAEvB,SAAS,kBAAkB;AAI3B,SAAS,2BAA2B;AAGpC,SAAS,wBAAwB;AAGjC,SAAS,wBAAwB;AAGjC,SAAS,uBAAuB;AAGhC,SAAS,mBAAmB;AAG5B,SAAS,oBAAoB;AAG7B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEP,SAAS,sBAAsB;AAG/B,SAAS,WAAW,wBAAwB;AAG5C,SAAS,2BAA2B;","names":[]}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var highlight_code_to_html_exports = {};
20
+ __export(highlight_code_to_html_exports, {
21
+ highlightCodeToHtml: () => highlightCodeToHtml
22
+ });
23
+ module.exports = __toCommonJS(highlight_code_to_html_exports);
24
+ var import_hast_util_to_html = require("hast-util-to-html");
25
+ function highlightCodeToHtml(code, language, lowlight) {
26
+ if (!code) return "";
27
+ const lang = language ?? "auto";
28
+ if (lang === "plaintext") {
29
+ return (0, import_hast_util_to_html.toHtml)({ type: "text", value: code });
30
+ }
31
+ const tree = lang === "auto" || !lowlight.registered(lang) ? lowlight.highlightAuto(code) : lowlight.highlight(lang, code);
32
+ return (0, import_hast_util_to_html.toHtml)(tree);
33
+ }
34
+ // Annotate the CommonJS export names for ESM import in node:
35
+ 0 && (module.exports = {
36
+ highlightCodeToHtml
37
+ });
38
+ //# sourceMappingURL=highlight-code-to-html.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/highlight-code-to-html.ts"],"sourcesContent":["import { toHtml } from 'hast-util-to-html';\n\nimport type { createLowlight } from 'lowlight';\n\ntype Lowlight = ReturnType<typeof createLowlight>;\n\n// Server-safe: lowlight + hast-util-to-html are pure JS and run in Node.\n// Used by NotraReader's nodeMapping.codeBlock; the editor uses the\n// extension's built-in ProseMirror decorations instead.\nexport function highlightCodeToHtml(\n\tcode: string,\n\tlanguage: string | null | undefined,\n\tlowlight: Lowlight\n): string {\n\tif (!code) return '';\n\n\tconst lang = language ?? 'auto';\n\n\t// \"plaintext\" deliberately skips highlighting — emit only escaped text.\n\tif (lang === 'plaintext') {\n\t\treturn toHtml({ type: 'text', value: code });\n\t}\n\n\tconst tree =\n\t\tlang === 'auto' || !lowlight.registered(lang)\n\t\t\t? lowlight.highlightAuto(code)\n\t\t\t: lowlight.highlight(lang, code);\n\n\treturn toHtml(tree);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAuB;AAShB,SAAS,oBACf,MACA,UACA,UACS;AACT,MAAI,CAAC,KAAM,QAAO;AAElB,QAAM,OAAO,YAAY;AAGzB,MAAI,SAAS,aAAa;AACzB,eAAO,iCAAO,EAAE,MAAM,QAAQ,OAAO,KAAK,CAAC;AAAA,EAC5C;AAEA,QAAM,OACL,SAAS,UAAU,CAAC,SAAS,WAAW,IAAI,IACzC,SAAS,cAAc,IAAI,IAC3B,SAAS,UAAU,MAAM,IAAI;AAEjC,aAAO,iCAAO,IAAI;AACnB;","names":[]}
@@ -0,0 +1,6 @@
1
+ import { createLowlight } from 'lowlight';
2
+
3
+ type Lowlight = ReturnType<typeof createLowlight>;
4
+ declare function highlightCodeToHtml(code: string, language: string | null | undefined, lowlight: Lowlight): string;
5
+
6
+ export { highlightCodeToHtml };
@@ -0,0 +1,6 @@
1
+ import { createLowlight } from 'lowlight';
2
+
3
+ type Lowlight = ReturnType<typeof createLowlight>;
4
+ declare function highlightCodeToHtml(code: string, language: string | null | undefined, lowlight: Lowlight): string;
5
+
6
+ export { highlightCodeToHtml };
@@ -0,0 +1,14 @@
1
+ import { toHtml } from "hast-util-to-html";
2
+ function highlightCodeToHtml(code, language, lowlight) {
3
+ if (!code) return "";
4
+ const lang = language ?? "auto";
5
+ if (lang === "plaintext") {
6
+ return toHtml({ type: "text", value: code });
7
+ }
8
+ const tree = lang === "auto" || !lowlight.registered(lang) ? lowlight.highlightAuto(code) : lowlight.highlight(lang, code);
9
+ return toHtml(tree);
10
+ }
11
+ export {
12
+ highlightCodeToHtml
13
+ };
14
+ //# sourceMappingURL=highlight-code-to-html.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/highlight-code-to-html.ts"],"sourcesContent":["import { toHtml } from 'hast-util-to-html';\n\nimport type { createLowlight } from 'lowlight';\n\ntype Lowlight = ReturnType<typeof createLowlight>;\n\n// Server-safe: lowlight + hast-util-to-html are pure JS and run in Node.\n// Used by NotraReader's nodeMapping.codeBlock; the editor uses the\n// extension's built-in ProseMirror decorations instead.\nexport function highlightCodeToHtml(\n\tcode: string,\n\tlanguage: string | null | undefined,\n\tlowlight: Lowlight\n): string {\n\tif (!code) return '';\n\n\tconst lang = language ?? 'auto';\n\n\t// \"plaintext\" deliberately skips highlighting — emit only escaped text.\n\tif (lang === 'plaintext') {\n\t\treturn toHtml({ type: 'text', value: code });\n\t}\n\n\tconst tree =\n\t\tlang === 'auto' || !lowlight.registered(lang)\n\t\t\t? lowlight.highlightAuto(code)\n\t\t\t: lowlight.highlight(lang, code);\n\n\treturn toHtml(tree);\n}\n"],"mappings":"AAAA,SAAS,cAAc;AAShB,SAAS,oBACf,MACA,UACA,UACS;AACT,MAAI,CAAC,KAAM,QAAO;AAElB,QAAM,OAAO,YAAY;AAGzB,MAAI,SAAS,aAAa;AACzB,WAAO,OAAO,EAAE,MAAM,QAAQ,OAAO,KAAK,CAAC;AAAA,EAC5C;AAEA,QAAM,OACL,SAAS,UAAU,CAAC,SAAS,WAAW,IAAI,IACzC,SAAS,cAAc,IAAI,IAC3B,SAAS,UAAU,MAAM,IAAI;AAEjC,SAAO,OAAO,IAAI;AACnB;","names":[]}