notra-editor 0.6.0 → 0.8.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.
- package/dist/components/blockquote-button/blockquote-button.d.cts +2 -2
- package/dist/components/blockquote-button/blockquote-button.d.ts +2 -2
- package/dist/components/code-block-button/code-block-button.d.cts +2 -2
- package/dist/components/code-block-button/code-block-button.d.ts +2 -2
- package/dist/components/heading-dropdown-menu/heading-dropdown-menu.d.cts +2 -2
- package/dist/components/heading-dropdown-menu/heading-dropdown-menu.d.ts +2 -2
- package/dist/components/heading-dropdown-menu/heading-menu-item.d.cts +2 -2
- package/dist/components/heading-dropdown-menu/heading-menu-item.d.ts +2 -2
- package/dist/components/image-popover/image-popover.d.cts +2 -2
- package/dist/components/image-popover/image-popover.d.ts +2 -2
- package/dist/components/image-popover/use-image-popover.d.cts +3 -3
- package/dist/components/image-popover/use-image-popover.d.ts +3 -3
- package/dist/components/link-popover/link-popover.d.cts +2 -2
- package/dist/components/link-popover/link-popover.d.ts +2 -2
- package/dist/components/link-popover/use-link-popover.d.cts +2 -2
- package/dist/components/link-popover/use-link-popover.d.ts +2 -2
- package/dist/components/list-dropdown-menu/list-dropdown-menu.d.cts +2 -2
- package/dist/components/list-dropdown-menu/list-dropdown-menu.d.ts +2 -2
- package/dist/components/list-dropdown-menu/list-menu-item.d.cts +2 -2
- package/dist/components/list-dropdown-menu/list-menu-item.d.ts +2 -2
- package/dist/components/mark-button/mark-button.d.cts +2 -2
- package/dist/components/mark-button/mark-button.d.ts +2 -2
- package/dist/components/toolbar/toolbar.d.cts +2 -2
- package/dist/components/toolbar/toolbar.d.ts +2 -2
- package/dist/components/ui/button.d.cts +2 -2
- package/dist/components/ui/button.d.ts +2 -2
- package/dist/components/ui/command.cjs +92 -29
- package/dist/components/ui/command.cjs.map +1 -1
- package/dist/components/ui/command.d.cts +18 -8
- package/dist/components/ui/command.d.ts +18 -8
- package/dist/components/ui/command.mjs +95 -29
- package/dist/components/ui/command.mjs.map +1 -1
- package/dist/components/ui/dialog.cjs +188 -0
- package/dist/components/ui/dialog.cjs.map +1 -0
- package/dist/components/ui/dialog.d.cts +20 -0
- package/dist/components/ui/dialog.d.ts +20 -0
- package/dist/components/ui/dialog.mjs +155 -0
- package/dist/components/ui/dialog.mjs.map +1 -0
- package/dist/components/ui/dropdown-menu.cjs +3 -2
- package/dist/components/ui/dropdown-menu.cjs.map +1 -1
- package/dist/components/ui/dropdown-menu.d.cts +16 -16
- package/dist/components/ui/dropdown-menu.d.ts +16 -16
- package/dist/components/ui/dropdown-menu.mjs +3 -2
- package/dist/components/ui/dropdown-menu.mjs.map +1 -1
- package/dist/components/ui/input-group.cjs +175 -0
- package/dist/components/ui/input-group.cjs.map +1 -0
- package/dist/components/ui/input-group.d.cts +20 -0
- package/dist/components/ui/input-group.d.ts +20 -0
- package/dist/components/ui/input-group.mjs +146 -0
- package/dist/components/ui/input-group.mjs.map +1 -0
- package/dist/components/ui/input.cjs +1 -1
- package/dist/components/ui/input.cjs.map +1 -1
- package/dist/components/ui/input.d.cts +2 -2
- package/dist/components/ui/input.d.ts +2 -2
- package/dist/components/ui/input.mjs +1 -1
- package/dist/components/ui/input.mjs.map +1 -1
- package/dist/components/ui/popover.cjs +46 -6
- package/dist/components/ui/popover.cjs.map +1 -1
- package/dist/components/ui/popover.d.cts +9 -6
- package/dist/components/ui/popover.d.ts +9 -6
- package/dist/components/ui/popover.mjs +43 -6
- package/dist/components/ui/popover.mjs.map +1 -1
- package/dist/components/ui/separator.cjs +2 -1
- package/dist/components/ui/separator.cjs.map +1 -1
- package/dist/components/ui/separator.d.cts +2 -2
- package/dist/components/ui/separator.d.ts +2 -2
- package/dist/components/ui/separator.mjs +2 -1
- package/dist/components/ui/separator.mjs.map +1 -1
- package/dist/components/ui/textarea.cjs +43 -0
- package/dist/components/ui/textarea.cjs.map +1 -0
- package/dist/components/ui/textarea.d.cts +6 -0
- package/dist/components/ui/textarea.d.ts +6 -0
- package/dist/components/ui/textarea.mjs +19 -0
- package/dist/components/ui/textarea.mjs.map +1 -0
- package/dist/components/undo-redo-button/undo-redo-button.d.cts +2 -2
- package/dist/components/undo-redo-button/undo-redo-button.d.ts +2 -2
- package/dist/components/undo-redo-button/use-undo-redo.d.cts +2 -2
- package/dist/components/undo-redo-button/use-undo-redo.d.ts +2 -2
- package/dist/extensions/code-block.cjs.map +1 -1
- package/dist/extensions/code-block.mjs.map +1 -1
- package/dist/hooks/use-markdown-editor.cjs +9 -0
- package/dist/hooks/use-markdown-editor.cjs.map +1 -1
- package/dist/hooks/use-markdown-editor.d.cts +0 -1
- package/dist/hooks/use-markdown-editor.d.ts +0 -1
- package/dist/hooks/use-markdown-editor.mjs +9 -0
- package/dist/hooks/use-markdown-editor.mjs.map +1 -1
- package/dist/notra-editor.cjs +3 -12
- package/dist/notra-editor.cjs.map +1 -1
- package/dist/notra-editor.d.cts +1 -7
- package/dist/notra-editor.d.ts +1 -7
- package/dist/notra-editor.mjs +3 -12
- package/dist/notra-editor.mjs.map +1 -1
- package/dist/notra-reader.cjs +1 -3
- package/dist/notra-reader.cjs.map +1 -1
- package/dist/notra-reader.d.cts +1 -3
- package/dist/notra-reader.d.ts +1 -3
- package/dist/notra-reader.mjs +1 -3
- package/dist/notra-reader.mjs.map +1 -1
- package/dist/styles/globals.css +952 -205
- package/dist/themes/default/editor.css +3035 -245
- package/dist/themes/default/reader.css +965 -10
- package/package.json +5 -3
- package/dist/icons/redo-icon.cjs +0 -54
- package/dist/icons/redo-icon.cjs.map +0 -1
- package/dist/icons/redo-icon.d.cts +0 -7
- package/dist/icons/redo-icon.d.ts +0 -7
- package/dist/icons/redo-icon.mjs +0 -30
- package/dist/icons/redo-icon.mjs.map +0 -1
- package/dist/icons/undo-icon.cjs +0 -54
- package/dist/icons/undo-icon.cjs.map +0 -1
- package/dist/icons/undo-icon.d.cts +0 -7
- package/dist/icons/undo-icon.d.ts +0 -7
- package/dist/icons/undo-icon.mjs +0 -30
- package/dist/icons/undo-icon.mjs.map +0 -1
- package/dist/themes/default/shared.css +0 -576
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/ui/separator.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/components/ui/separator.tsx"],"sourcesContent":["'use client';\n\nimport { Separator as SeparatorPrimitive } from 'radix-ui';\nimport * as React from 'react';\n\nimport { cn } from '../../lib/utils';\n\nfunction Separator({\n\tclassName,\n\torientation = 'horizontal',\n\tdecorative = true,\n\t...props\n}: React.ComponentProps<typeof SeparatorPrimitive.Root>) {\n\treturn (\n\t\t<SeparatorPrimitive.Root\n\t\t\tclassName={cn(\n\t\t\t\t'nt:shrink-0 nt:bg-border nt:data-horizontal:h-px nt:data-horizontal:w-full nt:data-vertical:w-px nt:data-vertical:self-stretch',\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\tdata-slot=\"separator\"\n\t\t\tdecorative={decorative}\n\t\t\torientation={orientation}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nexport { Separator };\n"],"mappings":";AAcE;AAZF,SAAS,aAAa,0BAA0B;AAGhD,SAAS,UAAU;AAEnB,SAAS,UAAU;AAAA,EAClB;AAAA,EACA,cAAc;AAAA,EACd,aAAa;AAAA,EACb,GAAG;AACJ,GAAyD;AACxD,SACC;AAAA,IAAC,mBAAmB;AAAA,IAAnB;AAAA,MACA,WAAW;AAAA,QACV;AAAA,QACA;AAAA,MACD;AAAA,MACA,aAAU;AAAA,MACV;AAAA,MACA;AAAA,MACC,GAAG;AAAA;AAAA,EACL;AAEF;","names":[]}
|
|
@@ -0,0 +1,43 @@
|
|
|
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 textarea_exports = {};
|
|
20
|
+
__export(textarea_exports, {
|
|
21
|
+
Textarea: () => Textarea
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(textarea_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_utils = require("../../lib/utils");
|
|
26
|
+
function Textarea({ className, ...props }) {
|
|
27
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
28
|
+
"textarea",
|
|
29
|
+
{
|
|
30
|
+
className: (0, import_utils.cn)(
|
|
31
|
+
"nt:flex nt:field-sizing-content nt:min-h-16 nt:w-full nt:rounded-lg nt:border nt:border-input nt:bg-transparent nt:px-2.5 nt:py-2 nt:text-base nt:transition-colors nt:outline-none nt:placeholder:text-muted-foreground nt:focus-visible:border-ring nt:focus-visible:ring-3 nt:focus-visible:ring-ring/50 nt:disabled:cursor-not-allowed nt:disabled:bg-input/50 nt:disabled:opacity-50 nt:aria-invalid:border-destructive nt:aria-invalid:ring-3 nt:aria-invalid:ring-destructive/20 nt:md:text-sm nt:dark:bg-input/30 nt:dark:disabled:bg-input/80 nt:dark:aria-invalid:border-destructive/50 nt:dark:aria-invalid:ring-destructive/40",
|
|
32
|
+
className
|
|
33
|
+
),
|
|
34
|
+
"data-slot": "textarea",
|
|
35
|
+
...props
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
Textarea
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=textarea.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/ui/textarea.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { cn } from '../../lib/utils';\n\nfunction Textarea({ className, ...props }: React.ComponentProps<'textarea'>) {\n\treturn (\n\t\t<textarea\n\t\t\tclassName={cn(\n\t\t\t\t'nt:flex nt:field-sizing-content nt:min-h-16 nt:w-full nt:rounded-lg nt:border nt:border-input nt:bg-transparent nt:px-2.5 nt:py-2 nt:text-base nt:transition-colors nt:outline-none nt:placeholder:text-muted-foreground nt:focus-visible:border-ring nt:focus-visible:ring-3 nt:focus-visible:ring-ring/50 nt:disabled:cursor-not-allowed nt:disabled:bg-input/50 nt:disabled:opacity-50 nt:aria-invalid:border-destructive nt:aria-invalid:ring-3 nt:aria-invalid:ring-destructive/20 nt:md:text-sm nt:dark:bg-input/30 nt:dark:disabled:bg-input/80 nt:dark:aria-invalid:border-destructive/50 nt:dark:aria-invalid:ring-destructive/40',\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\tdata-slot=\"textarea\"\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nexport { Textarea };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAME;AAJF,mBAAmB;AAEnB,SAAS,SAAS,EAAE,WAAW,GAAG,MAAM,GAAqC;AAC5E,SACC;AAAA,IAAC;AAAA;AAAA,MACA,eAAW;AAAA,QACV;AAAA,QACA;AAAA,MACD;AAAA,MACA,aAAU;AAAA,MACT,GAAG;AAAA;AAAA,EACL;AAEF;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../lib/utils";
|
|
3
|
+
function Textarea({ className, ...props }) {
|
|
4
|
+
return /* @__PURE__ */ jsx(
|
|
5
|
+
"textarea",
|
|
6
|
+
{
|
|
7
|
+
className: cn(
|
|
8
|
+
"nt:flex nt:field-sizing-content nt:min-h-16 nt:w-full nt:rounded-lg nt:border nt:border-input nt:bg-transparent nt:px-2.5 nt:py-2 nt:text-base nt:transition-colors nt:outline-none nt:placeholder:text-muted-foreground nt:focus-visible:border-ring nt:focus-visible:ring-3 nt:focus-visible:ring-ring/50 nt:disabled:cursor-not-allowed nt:disabled:bg-input/50 nt:disabled:opacity-50 nt:aria-invalid:border-destructive nt:aria-invalid:ring-3 nt:aria-invalid:ring-destructive/20 nt:md:text-sm nt:dark:bg-input/30 nt:dark:disabled:bg-input/80 nt:dark:aria-invalid:border-destructive/50 nt:dark:aria-invalid:ring-destructive/40",
|
|
9
|
+
className
|
|
10
|
+
),
|
|
11
|
+
"data-slot": "textarea",
|
|
12
|
+
...props
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
Textarea
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=textarea.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/ui/textarea.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { cn } from '../../lib/utils';\n\nfunction Textarea({ className, ...props }: React.ComponentProps<'textarea'>) {\n\treturn (\n\t\t<textarea\n\t\t\tclassName={cn(\n\t\t\t\t'nt:flex nt:field-sizing-content nt:min-h-16 nt:w-full nt:rounded-lg nt:border nt:border-input nt:bg-transparent nt:px-2.5 nt:py-2 nt:text-base nt:transition-colors nt:outline-none nt:placeholder:text-muted-foreground nt:focus-visible:border-ring nt:focus-visible:ring-3 nt:focus-visible:ring-ring/50 nt:disabled:cursor-not-allowed nt:disabled:bg-input/50 nt:disabled:opacity-50 nt:aria-invalid:border-destructive nt:aria-invalid:ring-3 nt:aria-invalid:ring-destructive/20 nt:md:text-sm nt:dark:bg-input/30 nt:dark:disabled:bg-input/80 nt:dark:aria-invalid:border-destructive/50 nt:dark:aria-invalid:ring-destructive/40',\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\tdata-slot=\"textarea\"\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n\nexport { Textarea };\n"],"mappings":"AAME;AAJF,SAAS,UAAU;AAEnB,SAAS,SAAS,EAAE,WAAW,GAAG,MAAM,GAAqC;AAC5E,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAW;AAAA,QACV;AAAA,QACA;AAAA,MACD;AAAA,MACA,aAAU;AAAA,MACT,GAAG;AAAA;AAAA,EACL;AAEF;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
2
|
import { UndoRedoAction } from './use-undo-redo.cjs';
|
|
3
3
|
import { Editor } from '@tiptap/core';
|
|
4
4
|
import 'lucide-react';
|
|
@@ -7,6 +7,6 @@ interface UndoRedoButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButton
|
|
|
7
7
|
editor: Editor | null;
|
|
8
8
|
action: UndoRedoAction;
|
|
9
9
|
}
|
|
10
|
-
declare const UndoRedoButton:
|
|
10
|
+
declare const UndoRedoButton: React$1.ForwardRefExoticComponent<UndoRedoButtonProps & React$1.RefAttributes<HTMLButtonElement>>;
|
|
11
11
|
|
|
12
12
|
export { UndoRedoButton, type UndoRedoButtonProps };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
2
|
import { UndoRedoAction } from './use-undo-redo.js';
|
|
3
3
|
import { Editor } from '@tiptap/core';
|
|
4
4
|
import 'lucide-react';
|
|
@@ -7,6 +7,6 @@ interface UndoRedoButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButton
|
|
|
7
7
|
editor: Editor | null;
|
|
8
8
|
action: UndoRedoAction;
|
|
9
9
|
}
|
|
10
|
-
declare const UndoRedoButton:
|
|
10
|
+
declare const UndoRedoButton: React$1.ForwardRefExoticComponent<UndoRedoButtonProps & React$1.RefAttributes<HTMLButtonElement>>;
|
|
11
11
|
|
|
12
12
|
export { UndoRedoButton, type UndoRedoButtonProps };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
import * as lucide_react from 'lucide-react';
|
|
3
3
|
import { Editor } from '@tiptap/core';
|
|
4
4
|
|
|
@@ -11,7 +11,7 @@ declare function useUndoRedo({ editor, action }: UseUndoRedoConfig): {
|
|
|
11
11
|
canExecute: boolean;
|
|
12
12
|
handleAction: () => boolean;
|
|
13
13
|
label: string;
|
|
14
|
-
Icon:
|
|
14
|
+
Icon: React.ForwardRefExoticComponent<Omit<lucide_react.LucideProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
export { type UndoRedoAction, type UseUndoRedoConfig, useUndoRedo };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
import * as lucide_react from 'lucide-react';
|
|
3
3
|
import { Editor } from '@tiptap/core';
|
|
4
4
|
|
|
@@ -11,7 +11,7 @@ declare function useUndoRedo({ editor, action }: UseUndoRedoConfig): {
|
|
|
11
11
|
canExecute: boolean;
|
|
12
12
|
handleAction: () => boolean;
|
|
13
13
|
label: string;
|
|
14
|
-
Icon:
|
|
14
|
+
Icon: React.ForwardRefExoticComponent<Omit<lucide_react.LucideProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
export { type UndoRedoAction, type UseUndoRedoConfig, useUndoRedo };
|
|
@@ -1 +1 @@
|
|
|
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\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAuC;AACvC,2CAAkC;AAClC,mBAAsC;AACtC,sBAAuC;AAEvC,6BAA8B;AAC9B,uBAAkC;AAQ3B,MAAM,sBAA4B,gCAAe,sBAAM;AAK9D,MAAM,qBAAqB;AAC3B,MAAM,kBAAkB;AAEjB,SAAS,yBAAyB,UAAoB;AAC5D,SAAO,uDAAkB,UAAU;AAAA,IAClC;AAAA;AAAA,IAEA,sBAAsB;AAAA,IACtB,SAAS;AAAA,EACV,CAAC,EAAE,OAAO;AAAA,IACT,cAAc;AACb,iBAAO,oCAAsB,oCAAa;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;
|
|
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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAuC;AACvC,2CAAkC;AAClC,mBAAsC;AACtC,sBAAuC;AAEvC,6BAA8B;AAC9B,uBAAkC;AAQ3B,MAAM,sBAA4B,gCAAe,sBAAM;AAK9D,MAAM,qBAAqB;AAC3B,MAAM,kBAAkB;AAEjB,SAAS,yBAAyB,UAAoB;AAC5D,SAAO,uDAAkB,UAAU;AAAA,IAClC;AAAA;AAAA,IAEA,sBAAsB;AAAA,IACtB,SAAS;AAAA,EACV,CAAC,EAAE,OAAO;AAAA,IACT,cAAc;AACb,iBAAO,oCAAsB,oCAAa;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,YACN,oCAAuB;AAAA,UACtB,MAAM;AAAA,UACN,MAAM,KAAK;AAAA,UACX,eAAe,CAAC,WAAW;AAAA,YAC1B,cAAU,oCAAkB,MAAM,CAAC,CAAC;AAAA,UACrC;AAAA,QACD,CAAC;AAAA,YACD,oCAAuB;AAAA,UACtB,MAAM;AAAA,UACN,MAAM,KAAK;AAAA,UACX,eAAe,CAAC,WAAW;AAAA,YAC1B,cAAU,oCAAkB,MAAM,CAAC,CAAC;AAAA,UACrC;AAAA,QACD,CAAC;AAAA,MACF;AAAA,IACD;AAAA,EACD,CAAC;AACF;AAEO,MAAM,qBAAqB,yBAAyB,eAAe;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
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\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;
|
|
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":[]}
|
|
@@ -40,6 +40,15 @@ function useMarkdownEditor({
|
|
|
40
40
|
extensions: import_extensions.editorExtensions,
|
|
41
41
|
editable,
|
|
42
42
|
content: value,
|
|
43
|
+
editorProps: {
|
|
44
|
+
attributes: {
|
|
45
|
+
autocomplete: "off",
|
|
46
|
+
autocorrect: "off",
|
|
47
|
+
autocapitalize: "off",
|
|
48
|
+
"aria-label": "Main content area, start typing to enter text.",
|
|
49
|
+
class: "notra-prose"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
43
52
|
onUpdate({ editor: editor2 }) {
|
|
44
53
|
const md = getMarkdown(
|
|
45
54
|
editor2.storage
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/use-markdown-editor.ts"],"sourcesContent":["import { EditorState } from '@tiptap/pm/state';\nimport { useEditor } from '@tiptap/react';\nimport { useEffect, useRef } from 'react';\n\nimport { editorExtensions } from '../extensions';\n\nimport type { MarkdownStorage } from 'tiptap-markdown';\n\nexport interface UseMarkdownEditorOptions {\n\tvalue: string;\n\tonChange: (value: string) => void;\n\
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/use-markdown-editor.ts"],"sourcesContent":["import { EditorState } from '@tiptap/pm/state';\nimport { useEditor } from '@tiptap/react';\nimport { useEffect, useRef } from 'react';\n\nimport { editorExtensions } from '../extensions';\n\nimport type { MarkdownStorage } from 'tiptap-markdown';\n\nexport interface UseMarkdownEditorOptions {\n\tvalue: string;\n\tonChange: (value: string) => void;\n\teditable?: boolean;\n}\n\nfunction getMarkdown(storage: Record<string, unknown>): string {\n\treturn (storage.markdown as MarkdownStorage).getMarkdown();\n}\n\nexport function useMarkdownEditor({\n\tvalue,\n\tonChange,\n\teditable = true\n}: UseMarkdownEditorOptions) {\n\tconst externalValue = useRef(value);\n\tconst onChangeRef = useRef(onChange);\n\n\tonChangeRef.current = onChange;\n\n\tconst editor = useEditor({\n\t\textensions: editorExtensions,\n\t\teditable,\n\t\tcontent: value,\n\t\teditorProps: {\n\t\t\tattributes: {\n\t\t\t\tautocomplete: 'off',\n\t\t\t\tautocorrect: 'off',\n\t\t\t\tautocapitalize: 'off',\n\t\t\t\t'aria-label': 'Main content area, start typing to enter text.',\n\t\t\t\tclass: 'notra-prose'\n\t\t\t}\n\t\t},\n\t\tonUpdate({ editor }) {\n\t\t\tconst md = getMarkdown(\n\t\t\t\teditor.storage as unknown as Record<string, unknown>\n\t\t\t);\n\n\t\t\texternalValue.current = md;\n\t\t\tonChangeRef.current(md);\n\t\t},\n\t\tonCreate({ editor }) {\n\t\t\t// Browser-specific behaviors (MutationObserver, DOM reconciliation)\n\t\t\t// may create unwanted transactions during mount, polluting the history\n\t\t\t// and making undo available before the user has made any changes.\n\t\t\t// Reset the editor state after initialization to ensure a clean history.\n\t\t\tsetTimeout(() => {\n\t\t\t\tif (editor.isDestroyed) return;\n\n\t\t\t\tconst { state } = editor;\n\t\t\t\tconst freshState = EditorState.create({\n\t\t\t\t\tdoc: state.doc,\n\t\t\t\t\tselection: state.selection,\n\t\t\t\t\tplugins: state.plugins\n\t\t\t\t});\n\n\t\t\t\teditor.view.updateState(freshState);\n\t\t\t\t// Dispatch empty transaction to notify state listeners (undo/redo buttons)\n\t\t\t\teditor.view.dispatch(editor.view.state.tr);\n\t\t\t}, 0);\n\t\t}\n\t});\n\n\tuseEffect(() => {\n\t\tif (!editor) return;\n\n\t\tif (value === externalValue.current) return;\n\n\t\texternalValue.current = value;\n\t\teditor.commands.setContent(value);\n\t}, [value, editor]);\n\n\tuseEffect(() => {\n\t\tif (!editor) return;\n\n\t\teditor.setEditable(editable);\n\t}, [editable, editor]);\n\n\treturn { editor };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA4B;AAC5B,mBAA0B;AAC1B,IAAAA,gBAAkC;AAElC,wBAAiC;AAUjC,SAAS,YAAY,SAA0C;AAC9D,SAAQ,QAAQ,SAA6B,YAAY;AAC1D;AAEO,SAAS,kBAAkB;AAAA,EACjC;AAAA,EACA;AAAA,EACA,WAAW;AACZ,GAA6B;AAC5B,QAAM,oBAAgB,sBAAO,KAAK;AAClC,QAAM,kBAAc,sBAAO,QAAQ;AAEnC,cAAY,UAAU;AAEtB,QAAM,aAAS,wBAAU;AAAA,IACxB,YAAY;AAAA,IACZ;AAAA,IACA,SAAS;AAAA,IACT,aAAa;AAAA,MACZ,YAAY;AAAA,QACX,cAAc;AAAA,QACd,aAAa;AAAA,QACb,gBAAgB;AAAA,QAChB,cAAc;AAAA,QACd,OAAO;AAAA,MACR;AAAA,IACD;AAAA,IACA,SAAS,EAAE,QAAAC,QAAO,GAAG;AACpB,YAAM,KAAK;AAAA,QACVA,QAAO;AAAA,MACR;AAEA,oBAAc,UAAU;AACxB,kBAAY,QAAQ,EAAE;AAAA,IACvB;AAAA,IACA,SAAS,EAAE,QAAAA,QAAO,GAAG;AAKpB,iBAAW,MAAM;AAChB,YAAIA,QAAO,YAAa;AAExB,cAAM,EAAE,MAAM,IAAIA;AAClB,cAAM,aAAa,yBAAY,OAAO;AAAA,UACrC,KAAK,MAAM;AAAA,UACX,WAAW,MAAM;AAAA,UACjB,SAAS,MAAM;AAAA,QAChB,CAAC;AAED,QAAAA,QAAO,KAAK,YAAY,UAAU;AAElC,QAAAA,QAAO,KAAK,SAASA,QAAO,KAAK,MAAM,EAAE;AAAA,MAC1C,GAAG,CAAC;AAAA,IACL;AAAA,EACD,CAAC;AAED,+BAAU,MAAM;AACf,QAAI,CAAC,OAAQ;AAEb,QAAI,UAAU,cAAc,QAAS;AAErC,kBAAc,UAAU;AACxB,WAAO,SAAS,WAAW,KAAK;AAAA,EACjC,GAAG,CAAC,OAAO,MAAM,CAAC;AAElB,+BAAU,MAAM;AACf,QAAI,CAAC,OAAQ;AAEb,WAAO,YAAY,QAAQ;AAAA,EAC5B,GAAG,CAAC,UAAU,MAAM,CAAC;AAErB,SAAO,EAAE,OAAO;AACjB;","names":["import_react","editor"]}
|
|
@@ -3,7 +3,6 @@ import * as _tiptap_core from '@tiptap/core';
|
|
|
3
3
|
interface UseMarkdownEditorOptions {
|
|
4
4
|
value: string;
|
|
5
5
|
onChange: (value: string) => void;
|
|
6
|
-
placeholder?: string;
|
|
7
6
|
editable?: boolean;
|
|
8
7
|
}
|
|
9
8
|
declare function useMarkdownEditor({ value, onChange, editable }: UseMarkdownEditorOptions): {
|
|
@@ -3,7 +3,6 @@ import * as _tiptap_core from '@tiptap/core';
|
|
|
3
3
|
interface UseMarkdownEditorOptions {
|
|
4
4
|
value: string;
|
|
5
5
|
onChange: (value: string) => void;
|
|
6
|
-
placeholder?: string;
|
|
7
6
|
editable?: boolean;
|
|
8
7
|
}
|
|
9
8
|
declare function useMarkdownEditor({ value, onChange, editable }: UseMarkdownEditorOptions): {
|
|
@@ -17,6 +17,15 @@ function useMarkdownEditor({
|
|
|
17
17
|
extensions: editorExtensions,
|
|
18
18
|
editable,
|
|
19
19
|
content: value,
|
|
20
|
+
editorProps: {
|
|
21
|
+
attributes: {
|
|
22
|
+
autocomplete: "off",
|
|
23
|
+
autocorrect: "off",
|
|
24
|
+
autocapitalize: "off",
|
|
25
|
+
"aria-label": "Main content area, start typing to enter text.",
|
|
26
|
+
class: "notra-prose"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
20
29
|
onUpdate({ editor: editor2 }) {
|
|
21
30
|
const md = getMarkdown(
|
|
22
31
|
editor2.storage
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/use-markdown-editor.ts"],"sourcesContent":["import { EditorState } from '@tiptap/pm/state';\nimport { useEditor } from '@tiptap/react';\nimport { useEffect, useRef } from 'react';\n\nimport { editorExtensions } from '../extensions';\n\nimport type { MarkdownStorage } from 'tiptap-markdown';\n\nexport interface UseMarkdownEditorOptions {\n\tvalue: string;\n\tonChange: (value: string) => void;\n\
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/use-markdown-editor.ts"],"sourcesContent":["import { EditorState } from '@tiptap/pm/state';\nimport { useEditor } from '@tiptap/react';\nimport { useEffect, useRef } from 'react';\n\nimport { editorExtensions } from '../extensions';\n\nimport type { MarkdownStorage } from 'tiptap-markdown';\n\nexport interface UseMarkdownEditorOptions {\n\tvalue: string;\n\tonChange: (value: string) => void;\n\teditable?: boolean;\n}\n\nfunction getMarkdown(storage: Record<string, unknown>): string {\n\treturn (storage.markdown as MarkdownStorage).getMarkdown();\n}\n\nexport function useMarkdownEditor({\n\tvalue,\n\tonChange,\n\teditable = true\n}: UseMarkdownEditorOptions) {\n\tconst externalValue = useRef(value);\n\tconst onChangeRef = useRef(onChange);\n\n\tonChangeRef.current = onChange;\n\n\tconst editor = useEditor({\n\t\textensions: editorExtensions,\n\t\teditable,\n\t\tcontent: value,\n\t\teditorProps: {\n\t\t\tattributes: {\n\t\t\t\tautocomplete: 'off',\n\t\t\t\tautocorrect: 'off',\n\t\t\t\tautocapitalize: 'off',\n\t\t\t\t'aria-label': 'Main content area, start typing to enter text.',\n\t\t\t\tclass: 'notra-prose'\n\t\t\t}\n\t\t},\n\t\tonUpdate({ editor }) {\n\t\t\tconst md = getMarkdown(\n\t\t\t\teditor.storage as unknown as Record<string, unknown>\n\t\t\t);\n\n\t\t\texternalValue.current = md;\n\t\t\tonChangeRef.current(md);\n\t\t},\n\t\tonCreate({ editor }) {\n\t\t\t// Browser-specific behaviors (MutationObserver, DOM reconciliation)\n\t\t\t// may create unwanted transactions during mount, polluting the history\n\t\t\t// and making undo available before the user has made any changes.\n\t\t\t// Reset the editor state after initialization to ensure a clean history.\n\t\t\tsetTimeout(() => {\n\t\t\t\tif (editor.isDestroyed) return;\n\n\t\t\t\tconst { state } = editor;\n\t\t\t\tconst freshState = EditorState.create({\n\t\t\t\t\tdoc: state.doc,\n\t\t\t\t\tselection: state.selection,\n\t\t\t\t\tplugins: state.plugins\n\t\t\t\t});\n\n\t\t\t\teditor.view.updateState(freshState);\n\t\t\t\t// Dispatch empty transaction to notify state listeners (undo/redo buttons)\n\t\t\t\teditor.view.dispatch(editor.view.state.tr);\n\t\t\t}, 0);\n\t\t}\n\t});\n\n\tuseEffect(() => {\n\t\tif (!editor) return;\n\n\t\tif (value === externalValue.current) return;\n\n\t\texternalValue.current = value;\n\t\teditor.commands.setContent(value);\n\t}, [value, editor]);\n\n\tuseEffect(() => {\n\t\tif (!editor) return;\n\n\t\teditor.setEditable(editable);\n\t}, [editable, editor]);\n\n\treturn { editor };\n}\n"],"mappings":"AAAA,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAC1B,SAAS,WAAW,cAAc;AAElC,SAAS,wBAAwB;AAUjC,SAAS,YAAY,SAA0C;AAC9D,SAAQ,QAAQ,SAA6B,YAAY;AAC1D;AAEO,SAAS,kBAAkB;AAAA,EACjC;AAAA,EACA;AAAA,EACA,WAAW;AACZ,GAA6B;AAC5B,QAAM,gBAAgB,OAAO,KAAK;AAClC,QAAM,cAAc,OAAO,QAAQ;AAEnC,cAAY,UAAU;AAEtB,QAAM,SAAS,UAAU;AAAA,IACxB,YAAY;AAAA,IACZ;AAAA,IACA,SAAS;AAAA,IACT,aAAa;AAAA,MACZ,YAAY;AAAA,QACX,cAAc;AAAA,QACd,aAAa;AAAA,QACb,gBAAgB;AAAA,QAChB,cAAc;AAAA,QACd,OAAO;AAAA,MACR;AAAA,IACD;AAAA,IACA,SAAS,EAAE,QAAAA,QAAO,GAAG;AACpB,YAAM,KAAK;AAAA,QACVA,QAAO;AAAA,MACR;AAEA,oBAAc,UAAU;AACxB,kBAAY,QAAQ,EAAE;AAAA,IACvB;AAAA,IACA,SAAS,EAAE,QAAAA,QAAO,GAAG;AAKpB,iBAAW,MAAM;AAChB,YAAIA,QAAO,YAAa;AAExB,cAAM,EAAE,MAAM,IAAIA;AAClB,cAAM,aAAa,YAAY,OAAO;AAAA,UACrC,KAAK,MAAM;AAAA,UACX,WAAW,MAAM;AAAA,UACjB,SAAS,MAAM;AAAA,QAChB,CAAC;AAED,QAAAA,QAAO,KAAK,YAAY,UAAU;AAElC,QAAAA,QAAO,KAAK,SAASA,QAAO,KAAK,MAAM,EAAE;AAAA,MAC1C,GAAG,CAAC;AAAA,IACL;AAAA,EACD,CAAC;AAED,YAAU,MAAM;AACf,QAAI,CAAC,OAAQ;AAEb,QAAI,UAAU,cAAc,QAAS;AAErC,kBAAc,UAAU;AACxB,WAAO,SAAS,WAAW,KAAK;AAAA,EACjC,GAAG,CAAC,OAAO,MAAM,CAAC;AAElB,YAAU,MAAM;AACf,QAAI,CAAC,OAAQ;AAEb,WAAO,YAAY,QAAQ;AAAA,EAC5B,GAAG,CAAC,UAAU,MAAM,CAAC;AAErB,SAAO,EAAE,OAAO;AACjB;","names":["editor"]}
|
package/dist/notra-editor.cjs
CHANGED
|
@@ -35,21 +35,12 @@ var import_toolbar = require("./components/toolbar/toolbar");
|
|
|
35
35
|
var import_spacer = require("./components/ui/spacer");
|
|
36
36
|
var import_undo_redo_button = require("./components/undo-redo-button/undo-redo-button");
|
|
37
37
|
var import_use_markdown_editor = require("./hooks/use-markdown-editor");
|
|
38
|
-
function NotraEditor({
|
|
39
|
-
value,
|
|
40
|
-
onChange,
|
|
41
|
-
placeholder,
|
|
42
|
-
readOnly = false,
|
|
43
|
-
className
|
|
44
|
-
}) {
|
|
38
|
+
function NotraEditor({ value, onChange }) {
|
|
45
39
|
const { editor } = (0, import_use_markdown_editor.useMarkdownEditor)({
|
|
46
40
|
value,
|
|
47
|
-
onChange
|
|
48
|
-
placeholder,
|
|
49
|
-
editable: !readOnly
|
|
41
|
+
onChange
|
|
50
42
|
});
|
|
51
|
-
|
|
52
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: classNames, children: [
|
|
43
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "notra notra-editor-wrapper", children: [
|
|
53
44
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_toolbar.Toolbar, { variant: "fixed", children: [
|
|
54
45
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_spacer.Spacer, {}),
|
|
55
46
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_toolbar.ToolbarGroup, { children: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/notra-editor.tsx"],"sourcesContent":["'use client';\n\nimport { EditorContent } from '@tiptap/react';\n\nimport { BlockquoteButton } from './components/blockquote-button/blockquote-button';\nimport { CodeBlockButton } from './components/code-block-button/code-block-button';\nimport { HeadingDropdownMenu } from './components/heading-dropdown-menu/heading-dropdown-menu';\nimport { ImagePopover } from './components/image-popover/image-popover';\nimport { LinkPopover } from './components/link-popover/link-popover';\nimport { ListDropdownMenu } from './components/list-dropdown-menu/list-dropdown-menu';\nimport { MarkButton } from './components/mark-button/mark-button';\nimport {\n\tToolbar,\n\tToolbarGroup,\n\tToolbarSeparator\n} from './components/toolbar/toolbar';\nimport { Spacer } from './components/ui/spacer';\nimport { UndoRedoButton } from './components/undo-redo-button/undo-redo-button';\nimport { useMarkdownEditor } from './hooks/use-markdown-editor';\n\nexport interface NotraEditorProps {\n\t/** Markdown content (source of truth) */\n\tvalue: string;\n\t/** Called when content changes, receives updated Markdown */\n\tonChange: (value: string) => void;\n
|
|
1
|
+
{"version":3,"sources":["../src/notra-editor.tsx"],"sourcesContent":["'use client';\n\nimport { EditorContent } from '@tiptap/react';\n\nimport { BlockquoteButton } from './components/blockquote-button/blockquote-button';\nimport { CodeBlockButton } from './components/code-block-button/code-block-button';\nimport { HeadingDropdownMenu } from './components/heading-dropdown-menu/heading-dropdown-menu';\nimport { ImagePopover } from './components/image-popover/image-popover';\nimport { LinkPopover } from './components/link-popover/link-popover';\nimport { ListDropdownMenu } from './components/list-dropdown-menu/list-dropdown-menu';\nimport { MarkButton } from './components/mark-button/mark-button';\nimport {\n\tToolbar,\n\tToolbarGroup,\n\tToolbarSeparator\n} from './components/toolbar/toolbar';\nimport { Spacer } from './components/ui/spacer';\nimport { UndoRedoButton } from './components/undo-redo-button/undo-redo-button';\nimport { useMarkdownEditor } from './hooks/use-markdown-editor';\n\nexport interface NotraEditorProps {\n\t/** Markdown content (source of truth) */\n\tvalue: string;\n\t/** Called when content changes, receives updated Markdown */\n\tonChange: (value: string) => void;\n}\n\nexport function NotraEditor({ value, onChange }: NotraEditorProps) {\n\tconst { editor } = useMarkdownEditor({\n\t\tvalue,\n\t\tonChange\n\t});\n\n\treturn (\n\t\t<div className=\"notra notra-editor-wrapper\">\n\t\t\t<Toolbar variant=\"fixed\">\n\t\t\t\t<Spacer />\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<UndoRedoButton action=\"undo\" editor={editor} />\n\t\t\t\t\t<UndoRedoButton action=\"redo\" editor={editor} />\n\t\t\t\t</ToolbarGroup>\n\t\t\t\t<ToolbarSeparator />\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<HeadingDropdownMenu editor={editor} levels={[1, 2, 3, 4]} />\n\t\t\t\t\t<ListDropdownMenu\n\t\t\t\t\t\teditor={editor}\n\t\t\t\t\t\ttypes={['bulletList', 'orderedList', 'taskList']}\n\t\t\t\t\t/>\n\t\t\t\t\t<BlockquoteButton editor={editor} />\n\t\t\t\t\t<CodeBlockButton editor={editor} />\n\t\t\t\t</ToolbarGroup>\n\t\t\t\t<ToolbarSeparator />\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<MarkButton editor={editor} type=\"bold\" />\n\t\t\t\t\t<MarkButton editor={editor} type=\"italic\" />\n\t\t\t\t\t<MarkButton editor={editor} type=\"strike\" />\n\t\t\t\t\t<MarkButton editor={editor} type=\"code\" />\n\t\t\t\t\t<LinkPopover editor={editor} />\n\t\t\t\t\t<ImagePopover editor={editor} />\n\t\t\t\t</ToolbarGroup>\n\t\t\t\t<Spacer />\n\t\t\t</Toolbar>\n\t\t\t<EditorContent className=\"notra-editor-content\" editor={editor} />\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoCI;AAlCJ,mBAA8B;AAE9B,+BAAiC;AACjC,+BAAgC;AAChC,mCAAoC;AACpC,2BAA6B;AAC7B,0BAA4B;AAC5B,gCAAiC;AACjC,yBAA2B;AAC3B,qBAIO;AACP,oBAAuB;AACvB,8BAA+B;AAC/B,iCAAkC;AAS3B,SAAS,YAAY,EAAE,OAAO,SAAS,GAAqB;AAClE,QAAM,EAAE,OAAO,QAAI,8CAAkB;AAAA,IACpC;AAAA,IACA;AAAA,EACD,CAAC;AAED,SACC,6CAAC,SAAI,WAAU,8BACd;AAAA,iDAAC,0BAAQ,SAAQ,SAChB;AAAA,kDAAC,wBAAO;AAAA,MACR,6CAAC,+BACA;AAAA,oDAAC,0CAAe,QAAO,QAAO,QAAgB;AAAA,QAC9C,4CAAC,0CAAe,QAAO,QAAO,QAAgB;AAAA,SAC/C;AAAA,MACA,4CAAC,mCAAiB;AAAA,MAClB,6CAAC,+BACA;AAAA,oDAAC,oDAAoB,QAAgB,QAAQ,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG;AAAA,QAC3D;AAAA,UAAC;AAAA;AAAA,YACA;AAAA,YACA,OAAO,CAAC,cAAc,eAAe,UAAU;AAAA;AAAA,QAChD;AAAA,QACA,4CAAC,6CAAiB,QAAgB;AAAA,QAClC,4CAAC,4CAAgB,QAAgB;AAAA,SAClC;AAAA,MACA,4CAAC,mCAAiB;AAAA,MAClB,6CAAC,+BACA;AAAA,oDAAC,iCAAW,QAAgB,MAAK,QAAO;AAAA,QACxC,4CAAC,iCAAW,QAAgB,MAAK,UAAS;AAAA,QAC1C,4CAAC,iCAAW,QAAgB,MAAK,UAAS;AAAA,QAC1C,4CAAC,iCAAW,QAAgB,MAAK,QAAO;AAAA,QACxC,4CAAC,mCAAY,QAAgB;AAAA,QAC7B,4CAAC,qCAAa,QAAgB;AAAA,SAC/B;AAAA,MACA,4CAAC,wBAAO;AAAA,OACT;AAAA,IACA,4CAAC,8BAAc,WAAU,wBAAuB,QAAgB;AAAA,KACjE;AAEF;","names":[]}
|
package/dist/notra-editor.d.cts
CHANGED
|
@@ -5,13 +5,7 @@ interface NotraEditorProps {
|
|
|
5
5
|
value: string;
|
|
6
6
|
/** Called when content changes, receives updated Markdown */
|
|
7
7
|
onChange: (value: string) => void;
|
|
8
|
-
/** Placeholder text shown when editor is empty */
|
|
9
|
-
placeholder?: string;
|
|
10
|
-
/** Disable editing */
|
|
11
|
-
readOnly?: boolean;
|
|
12
|
-
/** Additional CSS class on the wrapper element */
|
|
13
|
-
className?: string;
|
|
14
8
|
}
|
|
15
|
-
declare function NotraEditor({ value, onChange
|
|
9
|
+
declare function NotraEditor({ value, onChange }: NotraEditorProps): react_jsx_runtime.JSX.Element;
|
|
16
10
|
|
|
17
11
|
export { NotraEditor, type NotraEditorProps };
|
package/dist/notra-editor.d.ts
CHANGED
|
@@ -5,13 +5,7 @@ interface NotraEditorProps {
|
|
|
5
5
|
value: string;
|
|
6
6
|
/** Called when content changes, receives updated Markdown */
|
|
7
7
|
onChange: (value: string) => void;
|
|
8
|
-
/** Placeholder text shown when editor is empty */
|
|
9
|
-
placeholder?: string;
|
|
10
|
-
/** Disable editing */
|
|
11
|
-
readOnly?: boolean;
|
|
12
|
-
/** Additional CSS class on the wrapper element */
|
|
13
|
-
className?: string;
|
|
14
8
|
}
|
|
15
|
-
declare function NotraEditor({ value, onChange
|
|
9
|
+
declare function NotraEditor({ value, onChange }: NotraEditorProps): react_jsx_runtime.JSX.Element;
|
|
16
10
|
|
|
17
11
|
export { NotraEditor, type NotraEditorProps };
|
package/dist/notra-editor.mjs
CHANGED
|
@@ -16,21 +16,12 @@ import {
|
|
|
16
16
|
import { Spacer } from "./components/ui/spacer";
|
|
17
17
|
import { UndoRedoButton } from "./components/undo-redo-button/undo-redo-button";
|
|
18
18
|
import { useMarkdownEditor } from "./hooks/use-markdown-editor";
|
|
19
|
-
function NotraEditor({
|
|
20
|
-
value,
|
|
21
|
-
onChange,
|
|
22
|
-
placeholder,
|
|
23
|
-
readOnly = false,
|
|
24
|
-
className
|
|
25
|
-
}) {
|
|
19
|
+
function NotraEditor({ value, onChange }) {
|
|
26
20
|
const { editor } = useMarkdownEditor({
|
|
27
21
|
value,
|
|
28
|
-
onChange
|
|
29
|
-
placeholder,
|
|
30
|
-
editable: !readOnly
|
|
22
|
+
onChange
|
|
31
23
|
});
|
|
32
|
-
|
|
33
|
-
return /* @__PURE__ */ jsxs("div", { className: classNames, children: [
|
|
24
|
+
return /* @__PURE__ */ jsxs("div", { className: "notra notra-editor-wrapper", children: [
|
|
34
25
|
/* @__PURE__ */ jsxs(Toolbar, { variant: "fixed", children: [
|
|
35
26
|
/* @__PURE__ */ jsx(Spacer, {}),
|
|
36
27
|
/* @__PURE__ */ jsxs(ToolbarGroup, { children: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/notra-editor.tsx"],"sourcesContent":["'use client';\n\nimport { EditorContent } from '@tiptap/react';\n\nimport { BlockquoteButton } from './components/blockquote-button/blockquote-button';\nimport { CodeBlockButton } from './components/code-block-button/code-block-button';\nimport { HeadingDropdownMenu } from './components/heading-dropdown-menu/heading-dropdown-menu';\nimport { ImagePopover } from './components/image-popover/image-popover';\nimport { LinkPopover } from './components/link-popover/link-popover';\nimport { ListDropdownMenu } from './components/list-dropdown-menu/list-dropdown-menu';\nimport { MarkButton } from './components/mark-button/mark-button';\nimport {\n\tToolbar,\n\tToolbarGroup,\n\tToolbarSeparator\n} from './components/toolbar/toolbar';\nimport { Spacer } from './components/ui/spacer';\nimport { UndoRedoButton } from './components/undo-redo-button/undo-redo-button';\nimport { useMarkdownEditor } from './hooks/use-markdown-editor';\n\nexport interface NotraEditorProps {\n\t/** Markdown content (source of truth) */\n\tvalue: string;\n\t/** Called when content changes, receives updated Markdown */\n\tonChange: (value: string) => void;\n
|
|
1
|
+
{"version":3,"sources":["../src/notra-editor.tsx"],"sourcesContent":["'use client';\n\nimport { EditorContent } from '@tiptap/react';\n\nimport { BlockquoteButton } from './components/blockquote-button/blockquote-button';\nimport { CodeBlockButton } from './components/code-block-button/code-block-button';\nimport { HeadingDropdownMenu } from './components/heading-dropdown-menu/heading-dropdown-menu';\nimport { ImagePopover } from './components/image-popover/image-popover';\nimport { LinkPopover } from './components/link-popover/link-popover';\nimport { ListDropdownMenu } from './components/list-dropdown-menu/list-dropdown-menu';\nimport { MarkButton } from './components/mark-button/mark-button';\nimport {\n\tToolbar,\n\tToolbarGroup,\n\tToolbarSeparator\n} from './components/toolbar/toolbar';\nimport { Spacer } from './components/ui/spacer';\nimport { UndoRedoButton } from './components/undo-redo-button/undo-redo-button';\nimport { useMarkdownEditor } from './hooks/use-markdown-editor';\n\nexport interface NotraEditorProps {\n\t/** Markdown content (source of truth) */\n\tvalue: string;\n\t/** Called when content changes, receives updated Markdown */\n\tonChange: (value: string) => void;\n}\n\nexport function NotraEditor({ value, onChange }: NotraEditorProps) {\n\tconst { editor } = useMarkdownEditor({\n\t\tvalue,\n\t\tonChange\n\t});\n\n\treturn (\n\t\t<div className=\"notra notra-editor-wrapper\">\n\t\t\t<Toolbar variant=\"fixed\">\n\t\t\t\t<Spacer />\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<UndoRedoButton action=\"undo\" editor={editor} />\n\t\t\t\t\t<UndoRedoButton action=\"redo\" editor={editor} />\n\t\t\t\t</ToolbarGroup>\n\t\t\t\t<ToolbarSeparator />\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<HeadingDropdownMenu editor={editor} levels={[1, 2, 3, 4]} />\n\t\t\t\t\t<ListDropdownMenu\n\t\t\t\t\t\teditor={editor}\n\t\t\t\t\t\ttypes={['bulletList', 'orderedList', 'taskList']}\n\t\t\t\t\t/>\n\t\t\t\t\t<BlockquoteButton editor={editor} />\n\t\t\t\t\t<CodeBlockButton editor={editor} />\n\t\t\t\t</ToolbarGroup>\n\t\t\t\t<ToolbarSeparator />\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<MarkButton editor={editor} type=\"bold\" />\n\t\t\t\t\t<MarkButton editor={editor} type=\"italic\" />\n\t\t\t\t\t<MarkButton editor={editor} type=\"strike\" />\n\t\t\t\t\t<MarkButton editor={editor} type=\"code\" />\n\t\t\t\t\t<LinkPopover editor={editor} />\n\t\t\t\t\t<ImagePopover editor={editor} />\n\t\t\t\t</ToolbarGroup>\n\t\t\t\t<Spacer />\n\t\t\t</Toolbar>\n\t\t\t<EditorContent className=\"notra-editor-content\" editor={editor} />\n\t\t</div>\n\t);\n}\n"],"mappings":";AAoCI,cACA,YADA;AAlCJ,SAAS,qBAAqB;AAE9B,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AACjC,SAAS,kBAAkB;AAC3B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,cAAc;AACvB,SAAS,sBAAsB;AAC/B,SAAS,yBAAyB;AAS3B,SAAS,YAAY,EAAE,OAAO,SAAS,GAAqB;AAClE,QAAM,EAAE,OAAO,IAAI,kBAAkB;AAAA,IACpC;AAAA,IACA;AAAA,EACD,CAAC;AAED,SACC,qBAAC,SAAI,WAAU,8BACd;AAAA,yBAAC,WAAQ,SAAQ,SAChB;AAAA,0BAAC,UAAO;AAAA,MACR,qBAAC,gBACA;AAAA,4BAAC,kBAAe,QAAO,QAAO,QAAgB;AAAA,QAC9C,oBAAC,kBAAe,QAAO,QAAO,QAAgB;AAAA,SAC/C;AAAA,MACA,oBAAC,oBAAiB;AAAA,MAClB,qBAAC,gBACA;AAAA,4BAAC,uBAAoB,QAAgB,QAAQ,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG;AAAA,QAC3D;AAAA,UAAC;AAAA;AAAA,YACA;AAAA,YACA,OAAO,CAAC,cAAc,eAAe,UAAU;AAAA;AAAA,QAChD;AAAA,QACA,oBAAC,oBAAiB,QAAgB;AAAA,QAClC,oBAAC,mBAAgB,QAAgB;AAAA,SAClC;AAAA,MACA,oBAAC,oBAAiB;AAAA,MAClB,qBAAC,gBACA;AAAA,4BAAC,cAAW,QAAgB,MAAK,QAAO;AAAA,QACxC,oBAAC,cAAW,QAAgB,MAAK,UAAS;AAAA,QAC1C,oBAAC,cAAW,QAAgB,MAAK,UAAS;AAAA,QAC1C,oBAAC,cAAW,QAAgB,MAAK,QAAO;AAAA,QACxC,oBAAC,eAAY,QAAgB;AAAA,QAC7B,oBAAC,gBAAa,QAAgB;AAAA,SAC/B;AAAA,MACA,oBAAC,UAAO;AAAA,OACT;AAAA,IACA,oBAAC,iBAAc,WAAU,wBAAuB,QAAgB;AAAA,KACjE;AAEF;","names":[]}
|
package/dist/notra-reader.cjs
CHANGED
|
@@ -31,7 +31,6 @@ var import_languages = require("./lib/languages");
|
|
|
31
31
|
var import_markdown_to_json = require("./utils/markdown-to-json");
|
|
32
32
|
function NotraReader({
|
|
33
33
|
content,
|
|
34
|
-
className,
|
|
35
34
|
lowlight = import_code_block.defaultLowlight
|
|
36
35
|
}) {
|
|
37
36
|
const json = (0, import_markdown_to_json.markdownToJSON)(content);
|
|
@@ -66,8 +65,7 @@ function NotraReader({
|
|
|
66
65
|
}
|
|
67
66
|
}
|
|
68
67
|
});
|
|
69
|
-
|
|
70
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: classNames, children: rendered });
|
|
68
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("article", { className: "notra notra-prose", children: rendered });
|
|
71
69
|
}
|
|
72
70
|
// Annotate the CommonJS export names for ESM import in node:
|
|
73
71
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/notra-reader.tsx"],"sourcesContent":["import { renderToReactElement } from '@tiptap/static-renderer/pm/react';\nimport { type createLowlight } from 'lowlight';\n\nimport { CodeBlockShell } from './components/code-block-view/code-block-shell';\nimport { sharedExtensions } from './extensions';\nimport { defaultLowlight } from './extensions/code-block';\nimport { highlightCodeToHtml } from './lib/highlight-code-to-html';\nimport { getLanguageLabel } from './lib/languages';\nimport { markdownToJSON } from './utils/markdown-to-json';\n\ntype Lowlight = ReturnType<typeof createLowlight>;\n\nexport interface NotraReaderProps {\n\t/** Markdown content to render */\n\tcontent: string;\n\t
|
|
1
|
+
{"version":3,"sources":["../src/notra-reader.tsx"],"sourcesContent":["import { renderToReactElement } from '@tiptap/static-renderer/pm/react';\nimport { type createLowlight } from 'lowlight';\n\nimport { CodeBlockShell } from './components/code-block-view/code-block-shell';\nimport { sharedExtensions } from './extensions';\nimport { defaultLowlight } from './extensions/code-block';\nimport { highlightCodeToHtml } from './lib/highlight-code-to-html';\nimport { getLanguageLabel } from './lib/languages';\nimport { markdownToJSON } from './utils/markdown-to-json';\n\ntype Lowlight = ReturnType<typeof createLowlight>;\n\nexport interface NotraReaderProps {\n\t/** Markdown content to render */\n\tcontent: string;\n\t/**\n\t * Optional lowlight instance for syntax highlighting. Defaults to the same\n\t * `defaultLowlight` (createLowlight(common)) used by `CodeBlockExtension`.\n\t * Pass a custom instance if you configured the editor with\n\t * `createCodeBlockExtension(myLowlight)` and want the reader to highlight\n\t * the same superset of languages.\n\t */\n\tlowlight?: Lowlight;\n}\n\nexport function NotraReader({\n\tcontent,\n\tlowlight = defaultLowlight\n}: NotraReaderProps) {\n\tconst json = markdownToJSON(content);\n\n\tconst rendered = renderToReactElement({\n\t\textensions: sharedExtensions,\n\t\tcontent: json,\n\t\toptions: {\n\t\t\tnodeMapping: {\n\t\t\t\tcodeBlock: ({ node }) => {\n\t\t\t\t\tconst language = (node.attrs.language as string) ?? '';\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<CodeBlockShell\n\t\t\t\t\t\t\tlanguageSlot={<span>{getLanguageLabel(language)}</span>}\n\t\t\t\t\t\t\tvalue={node.textContent}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<code\n\t\t\t\t\t\t\t\tdangerouslySetInnerHTML={{\n\t\t\t\t\t\t\t\t\t__html: highlightCodeToHtml(\n\t\t\t\t\t\t\t\t\t\tnode.textContent,\n\t\t\t\t\t\t\t\t\t\tlanguage,\n\t\t\t\t\t\t\t\t\t\tlowlight\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\tclassName=\"hljs\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</CodeBlockShell>\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\treturn <article className=\"notra notra-prose\">{rendered}</article>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAyCqB;AAzCrB,mBAAqC;AAGrC,8BAA+B;AAC/B,wBAAiC;AACjC,wBAAgC;AAChC,oCAAoC;AACpC,uBAAiC;AACjC,8BAA+B;AAiBxB,SAAS,YAAY;AAAA,EAC3B;AAAA,EACA,WAAW;AACZ,GAAqB;AACpB,QAAM,WAAO,wCAAe,OAAO;AAEnC,QAAM,eAAW,mCAAqB;AAAA,IACrC,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,SAAS;AAAA,MACR,aAAa;AAAA,QACZ,WAAW,CAAC,EAAE,KAAK,MAAM;AACxB,gBAAM,WAAY,KAAK,MAAM,YAAuB;AAEpD,iBACC;AAAA,YAAC;AAAA;AAAA,cACA,cAAc,4CAAC,UAAM,iDAAiB,QAAQ,GAAE;AAAA,cAChD,OAAO,KAAK;AAAA,cAEZ;AAAA,gBAAC;AAAA;AAAA,kBACA,yBAAyB;AAAA,oBACxB,YAAQ;AAAA,sBACP,KAAK;AAAA,sBACL;AAAA,sBACA;AAAA,oBACD;AAAA,kBACD;AAAA,kBACA,WAAU;AAAA;AAAA,cACX;AAAA;AAAA,UACD;AAAA,QAEF;AAAA,MACD;AAAA,IACD;AAAA,EACD,CAAC;AAED,SAAO,4CAAC,aAAQ,WAAU,qBAAqB,oBAAS;AACzD;","names":[]}
|
package/dist/notra-reader.d.cts
CHANGED
|
@@ -5,8 +5,6 @@ type Lowlight = ReturnType<typeof createLowlight>;
|
|
|
5
5
|
interface NotraReaderProps {
|
|
6
6
|
/** Markdown content to render */
|
|
7
7
|
content: string;
|
|
8
|
-
/** Additional CSS class on the wrapper element */
|
|
9
|
-
className?: string;
|
|
10
8
|
/**
|
|
11
9
|
* Optional lowlight instance for syntax highlighting. Defaults to the same
|
|
12
10
|
* `defaultLowlight` (createLowlight(common)) used by `CodeBlockExtension`.
|
|
@@ -16,6 +14,6 @@ interface NotraReaderProps {
|
|
|
16
14
|
*/
|
|
17
15
|
lowlight?: Lowlight;
|
|
18
16
|
}
|
|
19
|
-
declare function NotraReader({ content,
|
|
17
|
+
declare function NotraReader({ content, lowlight }: NotraReaderProps): react_jsx_runtime.JSX.Element;
|
|
20
18
|
|
|
21
19
|
export { NotraReader, type NotraReaderProps };
|
package/dist/notra-reader.d.ts
CHANGED
|
@@ -5,8 +5,6 @@ type Lowlight = ReturnType<typeof createLowlight>;
|
|
|
5
5
|
interface NotraReaderProps {
|
|
6
6
|
/** Markdown content to render */
|
|
7
7
|
content: string;
|
|
8
|
-
/** Additional CSS class on the wrapper element */
|
|
9
|
-
className?: string;
|
|
10
8
|
/**
|
|
11
9
|
* Optional lowlight instance for syntax highlighting. Defaults to the same
|
|
12
10
|
* `defaultLowlight` (createLowlight(common)) used by `CodeBlockExtension`.
|
|
@@ -16,6 +14,6 @@ interface NotraReaderProps {
|
|
|
16
14
|
*/
|
|
17
15
|
lowlight?: Lowlight;
|
|
18
16
|
}
|
|
19
|
-
declare function NotraReader({ content,
|
|
17
|
+
declare function NotraReader({ content, lowlight }: NotraReaderProps): react_jsx_runtime.JSX.Element;
|
|
20
18
|
|
|
21
19
|
export { NotraReader, type NotraReaderProps };
|
package/dist/notra-reader.mjs
CHANGED
|
@@ -8,7 +8,6 @@ import { getLanguageLabel } from "./lib/languages";
|
|
|
8
8
|
import { markdownToJSON } from "./utils/markdown-to-json";
|
|
9
9
|
function NotraReader({
|
|
10
10
|
content,
|
|
11
|
-
className,
|
|
12
11
|
lowlight = defaultLowlight
|
|
13
12
|
}) {
|
|
14
13
|
const json = markdownToJSON(content);
|
|
@@ -43,8 +42,7 @@ function NotraReader({
|
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
44
|
});
|
|
46
|
-
|
|
47
|
-
return /* @__PURE__ */ jsx("div", { className: classNames, children: rendered });
|
|
45
|
+
return /* @__PURE__ */ jsx("article", { className: "notra notra-prose", children: rendered });
|
|
48
46
|
}
|
|
49
47
|
export {
|
|
50
48
|
NotraReader
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/notra-reader.tsx"],"sourcesContent":["import { renderToReactElement } from '@tiptap/static-renderer/pm/react';\nimport { type createLowlight } from 'lowlight';\n\nimport { CodeBlockShell } from './components/code-block-view/code-block-shell';\nimport { sharedExtensions } from './extensions';\nimport { defaultLowlight } from './extensions/code-block';\nimport { highlightCodeToHtml } from './lib/highlight-code-to-html';\nimport { getLanguageLabel } from './lib/languages';\nimport { markdownToJSON } from './utils/markdown-to-json';\n\ntype Lowlight = ReturnType<typeof createLowlight>;\n\nexport interface NotraReaderProps {\n\t/** Markdown content to render */\n\tcontent: string;\n\t
|
|
1
|
+
{"version":3,"sources":["../src/notra-reader.tsx"],"sourcesContent":["import { renderToReactElement } from '@tiptap/static-renderer/pm/react';\nimport { type createLowlight } from 'lowlight';\n\nimport { CodeBlockShell } from './components/code-block-view/code-block-shell';\nimport { sharedExtensions } from './extensions';\nimport { defaultLowlight } from './extensions/code-block';\nimport { highlightCodeToHtml } from './lib/highlight-code-to-html';\nimport { getLanguageLabel } from './lib/languages';\nimport { markdownToJSON } from './utils/markdown-to-json';\n\ntype Lowlight = ReturnType<typeof createLowlight>;\n\nexport interface NotraReaderProps {\n\t/** Markdown content to render */\n\tcontent: string;\n\t/**\n\t * Optional lowlight instance for syntax highlighting. Defaults to the same\n\t * `defaultLowlight` (createLowlight(common)) used by `CodeBlockExtension`.\n\t * Pass a custom instance if you configured the editor with\n\t * `createCodeBlockExtension(myLowlight)` and want the reader to highlight\n\t * the same superset of languages.\n\t */\n\tlowlight?: Lowlight;\n}\n\nexport function NotraReader({\n\tcontent,\n\tlowlight = defaultLowlight\n}: NotraReaderProps) {\n\tconst json = markdownToJSON(content);\n\n\tconst rendered = renderToReactElement({\n\t\textensions: sharedExtensions,\n\t\tcontent: json,\n\t\toptions: {\n\t\t\tnodeMapping: {\n\t\t\t\tcodeBlock: ({ node }) => {\n\t\t\t\t\tconst language = (node.attrs.language as string) ?? '';\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<CodeBlockShell\n\t\t\t\t\t\t\tlanguageSlot={<span>{getLanguageLabel(language)}</span>}\n\t\t\t\t\t\t\tvalue={node.textContent}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<code\n\t\t\t\t\t\t\t\tdangerouslySetInnerHTML={{\n\t\t\t\t\t\t\t\t\t__html: highlightCodeToHtml(\n\t\t\t\t\t\t\t\t\t\tnode.textContent,\n\t\t\t\t\t\t\t\t\t\tlanguage,\n\t\t\t\t\t\t\t\t\t\tlowlight\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\tclassName=\"hljs\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</CodeBlockShell>\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\treturn <article className=\"notra notra-prose\">{rendered}</article>;\n}\n"],"mappings":"AAyCqB;AAzCrB,SAAS,4BAA4B;AAGrC,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,2BAA2B;AACpC,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAiBxB,SAAS,YAAY;AAAA,EAC3B;AAAA,EACA,WAAW;AACZ,GAAqB;AACpB,QAAM,OAAO,eAAe,OAAO;AAEnC,QAAM,WAAW,qBAAqB;AAAA,IACrC,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,SAAS;AAAA,MACR,aAAa;AAAA,QACZ,WAAW,CAAC,EAAE,KAAK,MAAM;AACxB,gBAAM,WAAY,KAAK,MAAM,YAAuB;AAEpD,iBACC;AAAA,YAAC;AAAA;AAAA,cACA,cAAc,oBAAC,UAAM,2BAAiB,QAAQ,GAAE;AAAA,cAChD,OAAO,KAAK;AAAA,cAEZ;AAAA,gBAAC;AAAA;AAAA,kBACA,yBAAyB;AAAA,oBACxB,QAAQ;AAAA,sBACP,KAAK;AAAA,sBACL;AAAA,sBACA;AAAA,oBACD;AAAA,kBACD;AAAA,kBACA,WAAU;AAAA;AAAA,cACX;AAAA;AAAA,UACD;AAAA,QAEF;AAAA,MACD;AAAA,IACD;AAAA,EACD,CAAC;AAED,SAAO,oBAAC,aAAQ,WAAU,qBAAqB,oBAAS;AACzD;","names":[]}
|