notra-editor 0.5.0 → 0.6.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/code-block-view/code-block-shell.cjs +41 -0
- package/dist/components/code-block-view/code-block-shell.cjs.map +1 -0
- package/dist/components/code-block-view/code-block-shell.d.cts +11 -0
- package/dist/components/code-block-view/code-block-shell.d.ts +11 -0
- package/dist/components/code-block-view/code-block-shell.mjs +17 -0
- package/dist/components/code-block-view/code-block-shell.mjs.map +1 -0
- package/dist/components/{code-block-view.cjs → code-block-view/code-block-view.cjs} +16 -8
- package/dist/components/code-block-view/code-block-view.cjs.map +1 -0
- package/dist/components/code-block-view/code-block-view.d.cts +6 -0
- package/dist/components/code-block-view/code-block-view.d.ts +6 -0
- package/dist/components/code-block-view/code-block-view.mjs +26 -0
- package/dist/components/code-block-view/code-block-view.mjs.map +1 -0
- package/dist/components/code-block-view/language-select.cjs +91 -0
- package/dist/components/code-block-view/language-select.cjs.map +1 -0
- package/dist/components/code-block-view/language-select.d.cts +11 -0
- package/dist/components/code-block-view/language-select.d.ts +11 -0
- package/dist/components/code-block-view/language-select.mjs +74 -0
- package/dist/components/code-block-view/language-select.mjs.map +1 -0
- package/dist/components/ui/command.cjs +144 -0
- package/dist/components/ui/command.cjs.map +1 -0
- package/dist/components/ui/command.d.cts +12 -0
- package/dist/components/ui/command.d.ts +12 -0
- package/dist/components/ui/command.mjs +115 -0
- package/dist/components/ui/command.mjs.map +1 -0
- package/dist/extensions/code-block.cjs +76 -19
- package/dist/extensions/code-block.cjs.map +1 -1
- package/dist/extensions/code-block.d.cts +7 -3
- package/dist/extensions/code-block.d.ts +7 -3
- package/dist/extensions/code-block.mjs +73 -8
- package/dist/extensions/code-block.mjs.map +1 -1
- package/dist/extensions/editor.d.cts +3 -3
- package/dist/extensions/editor.d.ts +3 -3
- package/dist/extensions/index.d.cts +1 -1
- package/dist/extensions/index.d.ts +1 -1
- package/dist/extensions/shared.cjs +5 -1
- package/dist/extensions/shared.cjs.map +1 -1
- package/dist/extensions/shared.d.cts +2 -1
- package/dist/extensions/shared.d.ts +2 -1
- package/dist/extensions/shared.mjs +5 -1
- package/dist/extensions/shared.mjs.map +1 -1
- package/dist/index.cjs +20 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.mjs +16 -1
- package/dist/index.mjs.map +1 -1
- package/dist/lib/highlight-code-to-html.cjs +38 -0
- package/dist/lib/highlight-code-to-html.cjs.map +1 -0
- package/dist/lib/highlight-code-to-html.d.cts +6 -0
- package/dist/lib/highlight-code-to-html.d.ts +6 -0
- package/dist/lib/highlight-code-to-html.mjs +14 -0
- package/dist/lib/highlight-code-to-html.mjs.map +1 -0
- package/dist/lib/languages.cjs +181 -0
- package/dist/lib/languages.cjs.map +1 -0
- package/dist/lib/languages.d.cts +24 -0
- package/dist/lib/languages.d.ts +24 -0
- package/dist/lib/languages.mjs +155 -0
- package/dist/lib/languages.mjs.map +1 -0
- package/dist/notra-reader.cjs +32 -3
- package/dist/notra-reader.cjs.map +1 -1
- package/dist/notra-reader.d.cts +11 -1
- package/dist/notra-reader.d.ts +11 -1
- package/dist/notra-reader.mjs +32 -3
- package/dist/notra-reader.mjs.map +1 -1
- package/dist/styles/globals.css +109 -0
- package/dist/themes/default/shared.css +132 -5
- package/package.json +5 -1
- package/dist/components/code-block-view.cjs.map +0 -1
- package/dist/components/code-block-view.d.cts +0 -12
- package/dist/components/code-block-view.d.ts +0 -12
- package/dist/components/code-block-view.mjs +0 -17
- package/dist/components/code-block-view.mjs.map +0 -1
package/dist/notra-reader.cjs
CHANGED
|
@@ -23,17 +23,46 @@ __export(notra_reader_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(notra_reader_exports);
|
|
24
24
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
25
|
var import_react = require("@tiptap/static-renderer/pm/react");
|
|
26
|
-
var
|
|
26
|
+
var import_code_block_shell = require("./components/code-block-view/code-block-shell");
|
|
27
27
|
var import_extensions = require("./extensions");
|
|
28
|
+
var import_code_block = require("./extensions/code-block");
|
|
29
|
+
var import_highlight_code_to_html = require("./lib/highlight-code-to-html");
|
|
30
|
+
var import_languages = require("./lib/languages");
|
|
28
31
|
var import_markdown_to_json = require("./utils/markdown-to-json");
|
|
29
|
-
function NotraReader({
|
|
32
|
+
function NotraReader({
|
|
33
|
+
content,
|
|
34
|
+
className,
|
|
35
|
+
lowlight = import_code_block.defaultLowlight
|
|
36
|
+
}) {
|
|
30
37
|
const json = (0, import_markdown_to_json.markdownToJSON)(content);
|
|
31
38
|
const rendered = (0, import_react.renderToReactElement)({
|
|
32
39
|
extensions: import_extensions.sharedExtensions,
|
|
33
40
|
content: json,
|
|
34
41
|
options: {
|
|
35
42
|
nodeMapping: {
|
|
36
|
-
codeBlock: ({ node
|
|
43
|
+
codeBlock: ({ node }) => {
|
|
44
|
+
const language = node.attrs.language ?? "";
|
|
45
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
46
|
+
import_code_block_shell.CodeBlockShell,
|
|
47
|
+
{
|
|
48
|
+
languageSlot: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: (0, import_languages.getLanguageLabel)(language) }),
|
|
49
|
+
value: node.textContent,
|
|
50
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
51
|
+
"code",
|
|
52
|
+
{
|
|
53
|
+
dangerouslySetInnerHTML: {
|
|
54
|
+
__html: (0, import_highlight_code_to_html.highlightCodeToHtml)(
|
|
55
|
+
node.textContent,
|
|
56
|
+
language,
|
|
57
|
+
lowlight
|
|
58
|
+
)
|
|
59
|
+
},
|
|
60
|
+
className: "hljs"
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}
|
|
37
66
|
}
|
|
38
67
|
}
|
|
39
68
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/notra-reader.tsx"],"sourcesContent":["import { renderToReactElement } from '@tiptap/static-renderer/pm/react';\n\nimport { CodeBlockShell } from './components/code-block-view';\nimport { sharedExtensions } from './extensions';\nimport { markdownToJSON } from './utils/markdown-to-json';\n\nexport interface NotraReaderProps {\n\t/** Markdown content to render */\n\tcontent: string;\n\t/** Additional CSS class on the wrapper element */\n\tclassName?: string;\n}\n\nexport function NotraReader({
|
|
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/** Additional CSS class on the wrapper element */\n\tclassName?: 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\tclassName,\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\tconst classNames = ['notra', 'notra-reader', className]\n\t\t.filter(Boolean)\n\t\t.join(' ');\n\n\treturn <div className={classNames}>{rendered}</div>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4CqB;AA5CrB,mBAAqC;AAGrC,8BAA+B;AAC/B,wBAAiC;AACjC,wBAAgC;AAChC,oCAAoC;AACpC,uBAAiC;AACjC,8BAA+B;AAmBxB,SAAS,YAAY;AAAA,EAC3B;AAAA,EACA;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,QAAM,aAAa,CAAC,SAAS,gBAAgB,SAAS,EACpD,OAAO,OAAO,EACd,KAAK,GAAG;AAEV,SAAO,4CAAC,SAAI,WAAW,YAAa,oBAAS;AAC9C;","names":[]}
|
package/dist/notra-reader.d.cts
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { createLowlight } from 'lowlight';
|
|
2
3
|
|
|
4
|
+
type Lowlight = ReturnType<typeof createLowlight>;
|
|
3
5
|
interface NotraReaderProps {
|
|
4
6
|
/** Markdown content to render */
|
|
5
7
|
content: string;
|
|
6
8
|
/** Additional CSS class on the wrapper element */
|
|
7
9
|
className?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Optional lowlight instance for syntax highlighting. Defaults to the same
|
|
12
|
+
* `defaultLowlight` (createLowlight(common)) used by `CodeBlockExtension`.
|
|
13
|
+
* Pass a custom instance if you configured the editor with
|
|
14
|
+
* `createCodeBlockExtension(myLowlight)` and want the reader to highlight
|
|
15
|
+
* the same superset of languages.
|
|
16
|
+
*/
|
|
17
|
+
lowlight?: Lowlight;
|
|
8
18
|
}
|
|
9
|
-
declare function NotraReader({ content, className }: NotraReaderProps): react_jsx_runtime.JSX.Element;
|
|
19
|
+
declare function NotraReader({ content, className, lowlight }: NotraReaderProps): react_jsx_runtime.JSX.Element;
|
|
10
20
|
|
|
11
21
|
export { NotraReader, type NotraReaderProps };
|
package/dist/notra-reader.d.ts
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { createLowlight } from 'lowlight';
|
|
2
3
|
|
|
4
|
+
type Lowlight = ReturnType<typeof createLowlight>;
|
|
3
5
|
interface NotraReaderProps {
|
|
4
6
|
/** Markdown content to render */
|
|
5
7
|
content: string;
|
|
6
8
|
/** Additional CSS class on the wrapper element */
|
|
7
9
|
className?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Optional lowlight instance for syntax highlighting. Defaults to the same
|
|
12
|
+
* `defaultLowlight` (createLowlight(common)) used by `CodeBlockExtension`.
|
|
13
|
+
* Pass a custom instance if you configured the editor with
|
|
14
|
+
* `createCodeBlockExtension(myLowlight)` and want the reader to highlight
|
|
15
|
+
* the same superset of languages.
|
|
16
|
+
*/
|
|
17
|
+
lowlight?: Lowlight;
|
|
8
18
|
}
|
|
9
|
-
declare function NotraReader({ content, className }: NotraReaderProps): react_jsx_runtime.JSX.Element;
|
|
19
|
+
declare function NotraReader({ content, className, lowlight }: NotraReaderProps): react_jsx_runtime.JSX.Element;
|
|
10
20
|
|
|
11
21
|
export { NotraReader, type NotraReaderProps };
|
package/dist/notra-reader.mjs
CHANGED
|
@@ -1,16 +1,45 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { renderToReactElement } from "@tiptap/static-renderer/pm/react";
|
|
3
|
-
import { CodeBlockShell } from "./components/code-block-view";
|
|
3
|
+
import { CodeBlockShell } from "./components/code-block-view/code-block-shell";
|
|
4
4
|
import { sharedExtensions } from "./extensions";
|
|
5
|
+
import { defaultLowlight } from "./extensions/code-block";
|
|
6
|
+
import { highlightCodeToHtml } from "./lib/highlight-code-to-html";
|
|
7
|
+
import { getLanguageLabel } from "./lib/languages";
|
|
5
8
|
import { markdownToJSON } from "./utils/markdown-to-json";
|
|
6
|
-
function NotraReader({
|
|
9
|
+
function NotraReader({
|
|
10
|
+
content,
|
|
11
|
+
className,
|
|
12
|
+
lowlight = defaultLowlight
|
|
13
|
+
}) {
|
|
7
14
|
const json = markdownToJSON(content);
|
|
8
15
|
const rendered = renderToReactElement({
|
|
9
16
|
extensions: sharedExtensions,
|
|
10
17
|
content: json,
|
|
11
18
|
options: {
|
|
12
19
|
nodeMapping: {
|
|
13
|
-
codeBlock: ({ node
|
|
20
|
+
codeBlock: ({ node }) => {
|
|
21
|
+
const language = node.attrs.language ?? "";
|
|
22
|
+
return /* @__PURE__ */ jsx(
|
|
23
|
+
CodeBlockShell,
|
|
24
|
+
{
|
|
25
|
+
languageSlot: /* @__PURE__ */ jsx("span", { children: getLanguageLabel(language) }),
|
|
26
|
+
value: node.textContent,
|
|
27
|
+
children: /* @__PURE__ */ jsx(
|
|
28
|
+
"code",
|
|
29
|
+
{
|
|
30
|
+
dangerouslySetInnerHTML: {
|
|
31
|
+
__html: highlightCodeToHtml(
|
|
32
|
+
node.textContent,
|
|
33
|
+
language,
|
|
34
|
+
lowlight
|
|
35
|
+
)
|
|
36
|
+
},
|
|
37
|
+
className: "hljs"
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
}
|
|
14
43
|
}
|
|
15
44
|
}
|
|
16
45
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/notra-reader.tsx"],"sourcesContent":["import { renderToReactElement } from '@tiptap/static-renderer/pm/react';\n\nimport { CodeBlockShell } from './components/code-block-view';\nimport { sharedExtensions } from './extensions';\nimport { markdownToJSON } from './utils/markdown-to-json';\n\nexport interface NotraReaderProps {\n\t/** Markdown content to render */\n\tcontent: string;\n\t/** Additional CSS class on the wrapper element */\n\tclassName?: string;\n}\n\nexport function NotraReader({
|
|
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/** Additional CSS class on the wrapper element */\n\tclassName?: 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\tclassName,\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\tconst classNames = ['notra', 'notra-reader', className]\n\t\t.filter(Boolean)\n\t\t.join(' ');\n\n\treturn <div className={classNames}>{rendered}</div>;\n}\n"],"mappings":"AA4CqB;AA5CrB,SAAS,4BAA4B;AAGrC,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,2BAA2B;AACpC,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAmBxB,SAAS,YAAY;AAAA,EAC3B;AAAA,EACA;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,QAAM,aAAa,CAAC,SAAS,gBAAgB,SAAS,EACpD,OAAO,OAAO,EACd,KAAK,GAAG;AAEV,SAAO,oBAAC,SAAI,WAAW,YAAa,oBAAS;AAC9C;","names":[]}
|
package/dist/styles/globals.css
CHANGED
|
@@ -223,6 +223,10 @@
|
|
|
223
223
|
width: calc(var(--nt-spacing) * 3);
|
|
224
224
|
height: calc(var(--nt-spacing) * 3);
|
|
225
225
|
}
|
|
226
|
+
.nt\:size-4 {
|
|
227
|
+
width: calc(var(--nt-spacing) * 4);
|
|
228
|
+
height: calc(var(--nt-spacing) * 4);
|
|
229
|
+
}
|
|
226
230
|
.nt\:size-6 {
|
|
227
231
|
width: calc(var(--nt-spacing) * 6);
|
|
228
232
|
height: calc(var(--nt-spacing) * 6);
|
|
@@ -254,18 +258,27 @@
|
|
|
254
258
|
.nt\:h-9 {
|
|
255
259
|
height: calc(var(--nt-spacing) * 9);
|
|
256
260
|
}
|
|
261
|
+
.nt\:h-full {
|
|
262
|
+
height: 100%;
|
|
263
|
+
}
|
|
257
264
|
.nt\:h-px {
|
|
258
265
|
height: 1px;
|
|
259
266
|
}
|
|
260
267
|
.nt\:max-h-\(--radix-dropdown-menu-content-available-height\) {
|
|
261
268
|
max-height: var(--radix-dropdown-menu-content-available-height);
|
|
262
269
|
}
|
|
270
|
+
.nt\:max-h-\[300px\] {
|
|
271
|
+
max-height: 300px;
|
|
272
|
+
}
|
|
263
273
|
.nt\:w-\(--radix-dropdown-menu-trigger-width\) {
|
|
264
274
|
width: var(--radix-dropdown-menu-trigger-width);
|
|
265
275
|
}
|
|
266
276
|
.nt\:w-72 {
|
|
267
277
|
width: calc(var(--nt-spacing) * 72);
|
|
268
278
|
}
|
|
279
|
+
.nt\:w-\[200px\] {
|
|
280
|
+
width: 200px;
|
|
281
|
+
}
|
|
269
282
|
.nt\:w-auto {
|
|
270
283
|
width: auto;
|
|
271
284
|
}
|
|
@@ -284,6 +297,9 @@
|
|
|
284
297
|
.nt\:min-w-\[96px\] {
|
|
285
298
|
min-width: 96px;
|
|
286
299
|
}
|
|
300
|
+
.nt\:flex-1 {
|
|
301
|
+
flex: 1;
|
|
302
|
+
}
|
|
287
303
|
.nt\:shrink-0 {
|
|
288
304
|
flex-shrink: 0;
|
|
289
305
|
}
|
|
@@ -296,12 +312,18 @@
|
|
|
296
312
|
.nt\:cursor-default {
|
|
297
313
|
cursor: default;
|
|
298
314
|
}
|
|
315
|
+
.nt\:scroll-py-1 {
|
|
316
|
+
scroll-padding-block: calc(var(--nt-spacing) * 1);
|
|
317
|
+
}
|
|
299
318
|
.nt\:flex-col {
|
|
300
319
|
flex-direction: column;
|
|
301
320
|
}
|
|
302
321
|
.nt\:items-center {
|
|
303
322
|
align-items: center;
|
|
304
323
|
}
|
|
324
|
+
.nt\:justify-between {
|
|
325
|
+
justify-content: space-between;
|
|
326
|
+
}
|
|
305
327
|
.nt\:justify-center {
|
|
306
328
|
justify-content: center;
|
|
307
329
|
}
|
|
@@ -314,6 +336,9 @@
|
|
|
314
336
|
.nt\:gap-1\.5 {
|
|
315
337
|
gap: calc(var(--nt-spacing) * 1.5);
|
|
316
338
|
}
|
|
339
|
+
.nt\:gap-2 {
|
|
340
|
+
gap: calc(var(--nt-spacing) * 2);
|
|
341
|
+
}
|
|
317
342
|
.nt\:overflow-hidden {
|
|
318
343
|
overflow: hidden;
|
|
319
344
|
}
|
|
@@ -339,6 +364,10 @@
|
|
|
339
364
|
border-style: var(--tw-border-style);
|
|
340
365
|
border-width: 1px;
|
|
341
366
|
}
|
|
367
|
+
.nt\:border-b {
|
|
368
|
+
border-bottom-style: var(--tw-border-style);
|
|
369
|
+
border-bottom-width: 1px;
|
|
370
|
+
}
|
|
342
371
|
.nt\:border-none {
|
|
343
372
|
--tw-border-style: none;
|
|
344
373
|
border-style: none;
|
|
@@ -346,6 +375,12 @@
|
|
|
346
375
|
.nt\:border-border {
|
|
347
376
|
border-color: var(--border);
|
|
348
377
|
}
|
|
378
|
+
.nt\:border-foreground\/10 {
|
|
379
|
+
border-color: var(--foreground);
|
|
380
|
+
@supports (color: color-mix(in lab, red, red)) {
|
|
381
|
+
border-color: color-mix(in oklab, var(--foreground) 10%, transparent);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
349
384
|
.nt\:border-input {
|
|
350
385
|
border-color: var(--input);
|
|
351
386
|
}
|
|
@@ -379,6 +414,9 @@
|
|
|
379
414
|
.nt\:bg-clip-padding {
|
|
380
415
|
background-clip: padding-box;
|
|
381
416
|
}
|
|
417
|
+
.nt\:p-0 {
|
|
418
|
+
padding: calc(var(--nt-spacing) * 0);
|
|
419
|
+
}
|
|
382
420
|
.nt\:p-1 {
|
|
383
421
|
padding: calc(var(--nt-spacing) * 1);
|
|
384
422
|
}
|
|
@@ -400,6 +438,15 @@
|
|
|
400
438
|
.nt\:py-1 {
|
|
401
439
|
padding-block: calc(var(--nt-spacing) * 1);
|
|
402
440
|
}
|
|
441
|
+
.nt\:py-1\.5 {
|
|
442
|
+
padding-block: calc(var(--nt-spacing) * 1.5);
|
|
443
|
+
}
|
|
444
|
+
.nt\:py-3 {
|
|
445
|
+
padding-block: calc(var(--nt-spacing) * 3);
|
|
446
|
+
}
|
|
447
|
+
.nt\:py-6 {
|
|
448
|
+
padding-block: calc(var(--nt-spacing) * 6);
|
|
449
|
+
}
|
|
403
450
|
.nt\:\!pt-9 {
|
|
404
451
|
padding-top: calc(var(--nt-spacing) * 9) !important;
|
|
405
452
|
}
|
|
@@ -409,6 +456,9 @@
|
|
|
409
456
|
.nt\:pl-1\.5 {
|
|
410
457
|
padding-left: calc(var(--nt-spacing) * 1.5);
|
|
411
458
|
}
|
|
459
|
+
.nt\:text-center {
|
|
460
|
+
text-align: center;
|
|
461
|
+
}
|
|
412
462
|
.nt\:text-base {
|
|
413
463
|
font-size: var(--nt-text-base);
|
|
414
464
|
line-height: var(--tw-leading, var(--nt-text-base--line-height));
|
|
@@ -441,6 +491,9 @@
|
|
|
441
491
|
.nt\:text-destructive {
|
|
442
492
|
color: var(--destructive);
|
|
443
493
|
}
|
|
494
|
+
.nt\:text-foreground {
|
|
495
|
+
color: var(--foreground);
|
|
496
|
+
}
|
|
444
497
|
.nt\:text-muted-foreground {
|
|
445
498
|
color: var(--muted-foreground);
|
|
446
499
|
}
|
|
@@ -459,6 +512,15 @@
|
|
|
459
512
|
.nt\:underline-offset-4 {
|
|
460
513
|
text-underline-offset: 4px;
|
|
461
514
|
}
|
|
515
|
+
.nt\:opacity-0 {
|
|
516
|
+
opacity: 0%;
|
|
517
|
+
}
|
|
518
|
+
.nt\:opacity-50 {
|
|
519
|
+
opacity: 50%;
|
|
520
|
+
}
|
|
521
|
+
.nt\:opacity-100 {
|
|
522
|
+
opacity: 100%;
|
|
523
|
+
}
|
|
462
524
|
.nt\:shadow-lg {
|
|
463
525
|
--tw-shadow: 0 10px 15px -3px var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 4px 6px -4px var(--tw-shadow-color, rgb(0 0 0 / 0.1));
|
|
464
526
|
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
|
@@ -816,6 +878,16 @@
|
|
|
816
878
|
color: var(--tt-brand-color-500);
|
|
817
879
|
}
|
|
818
880
|
}
|
|
881
|
+
.nt\:data-\[disabled\=true\]\:pointer-events-none {
|
|
882
|
+
&[data-disabled="true"] {
|
|
883
|
+
pointer-events: none;
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
.nt\:data-\[disabled\=true\]\:opacity-50 {
|
|
887
|
+
&[data-disabled="true"] {
|
|
888
|
+
opacity: 50%;
|
|
889
|
+
}
|
|
890
|
+
}
|
|
819
891
|
.nt\:data-\[orientation\=horizontal\]\:h-px {
|
|
820
892
|
&[data-orientation="horizontal"] {
|
|
821
893
|
height: 1px;
|
|
@@ -836,6 +908,16 @@
|
|
|
836
908
|
width: 1px;
|
|
837
909
|
}
|
|
838
910
|
}
|
|
911
|
+
.nt\:data-\[selected\=true\]\:bg-accent {
|
|
912
|
+
&[data-selected="true"] {
|
|
913
|
+
background-color: var(--accent);
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
.nt\:data-\[selected\=true\]\:text-accent-foreground {
|
|
917
|
+
&[data-selected="true"] {
|
|
918
|
+
color: var(--accent-foreground);
|
|
919
|
+
}
|
|
920
|
+
}
|
|
839
921
|
.nt\:data-\[state\=closed\]\:overflow-hidden {
|
|
840
922
|
&[data-state="closed"] {
|
|
841
923
|
overflow: hidden;
|
|
@@ -968,6 +1050,33 @@
|
|
|
968
1050
|
}
|
|
969
1051
|
}
|
|
970
1052
|
}
|
|
1053
|
+
.nt\:\[\&_\[cmdk-group-heading\]\]\:px-2 {
|
|
1054
|
+
& [cmdk-group-heading] {
|
|
1055
|
+
padding-inline: calc(var(--nt-spacing) * 2);
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
.nt\:\[\&_\[cmdk-group-heading\]\]\:py-1\.5 {
|
|
1059
|
+
& [cmdk-group-heading] {
|
|
1060
|
+
padding-block: calc(var(--nt-spacing) * 1.5);
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
.nt\:\[\&_\[cmdk-group-heading\]\]\:text-xs {
|
|
1064
|
+
& [cmdk-group-heading] {
|
|
1065
|
+
font-size: var(--nt-text-xs);
|
|
1066
|
+
line-height: var(--tw-leading, var(--nt-text-xs--line-height));
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
.nt\:\[\&_\[cmdk-group-heading\]\]\:font-medium {
|
|
1070
|
+
& [cmdk-group-heading] {
|
|
1071
|
+
--tw-font-weight: var(--nt-font-weight-medium);
|
|
1072
|
+
font-weight: var(--nt-font-weight-medium);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
.nt\:\[\&_\[cmdk-group-heading\]\]\:text-muted-foreground {
|
|
1076
|
+
& [cmdk-group-heading] {
|
|
1077
|
+
color: var(--muted-foreground);
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
971
1080
|
.nt\:\[\&_svg\]\:pointer-events-none {
|
|
972
1081
|
& svg {
|
|
973
1082
|
pointer-events: none;
|
|
@@ -341,14 +341,13 @@
|
|
|
341
341
|
===================== */
|
|
342
342
|
.notra .tiptap pre,
|
|
343
343
|
.notra-reader pre {
|
|
344
|
-
background-color: var(--notra-codeblock-bg);
|
|
345
|
-
color: var(--notra-codeblock-text);
|
|
346
344
|
border: 1px solid var(--notra-codeblock-border);
|
|
347
345
|
margin-top: 1.5em;
|
|
348
346
|
margin-bottom: 1.5em;
|
|
349
|
-
padding: 1em;
|
|
350
347
|
font-size: 1rem;
|
|
351
348
|
border-radius: var(--notra-radius);
|
|
349
|
+
overflow: hidden;
|
|
350
|
+
font-family: var(--notra-font-mono);
|
|
352
351
|
}
|
|
353
352
|
|
|
354
353
|
.notra .tiptap pre code,
|
|
@@ -356,8 +355,136 @@
|
|
|
356
355
|
background-color: transparent;
|
|
357
356
|
border: none;
|
|
358
357
|
border-radius: 0;
|
|
359
|
-
|
|
360
|
-
|
|
358
|
+
padding: 1em;
|
|
359
|
+
display: block;
|
|
360
|
+
overflow-x: auto;
|
|
361
|
+
font-size: 0.875em;
|
|
362
|
+
line-height: 1.5;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/* =====================
|
|
366
|
+
Code — Highlight (Atom One Light, default)
|
|
367
|
+
===================== */
|
|
368
|
+
.notra .hljs {
|
|
369
|
+
color: #383a42;
|
|
370
|
+
background: #fafafa;
|
|
371
|
+
}
|
|
372
|
+
.notra .hljs-comment,
|
|
373
|
+
.notra .hljs-quote {
|
|
374
|
+
color: #a0a1a7;
|
|
375
|
+
font-style: italic;
|
|
376
|
+
}
|
|
377
|
+
.notra .hljs-doctag,
|
|
378
|
+
.notra .hljs-formula,
|
|
379
|
+
.notra .hljs-keyword {
|
|
380
|
+
color: #a626a4;
|
|
381
|
+
}
|
|
382
|
+
.notra .hljs-deletion,
|
|
383
|
+
.notra .hljs-name,
|
|
384
|
+
.notra .hljs-section,
|
|
385
|
+
.notra .hljs-selector-tag,
|
|
386
|
+
.notra .hljs-subst {
|
|
387
|
+
color: #e45649;
|
|
388
|
+
}
|
|
389
|
+
.notra .hljs-literal {
|
|
390
|
+
color: #0184bb;
|
|
391
|
+
}
|
|
392
|
+
.notra .hljs-addition,
|
|
393
|
+
.notra .hljs-attribute,
|
|
394
|
+
.notra .hljs-meta .hljs-string,
|
|
395
|
+
.notra .hljs-regexp,
|
|
396
|
+
.notra .hljs-string {
|
|
397
|
+
color: #50a14f;
|
|
398
|
+
}
|
|
399
|
+
.notra .hljs-built_in,
|
|
400
|
+
.notra .hljs-class .hljs-title,
|
|
401
|
+
.notra .hljs-title.class_ {
|
|
402
|
+
color: #c18401;
|
|
403
|
+
}
|
|
404
|
+
.notra .hljs-attr,
|
|
405
|
+
.notra .hljs-number,
|
|
406
|
+
.notra .hljs-selector-attr,
|
|
407
|
+
.notra .hljs-selector-class,
|
|
408
|
+
.notra .hljs-selector-pseudo,
|
|
409
|
+
.notra .hljs-template-variable,
|
|
410
|
+
.notra .hljs-type,
|
|
411
|
+
.notra .hljs-variable {
|
|
412
|
+
color: #986801;
|
|
413
|
+
}
|
|
414
|
+
.notra .hljs-bullet,
|
|
415
|
+
.notra .hljs-link,
|
|
416
|
+
.notra .hljs-meta,
|
|
417
|
+
.notra .hljs-selector-id,
|
|
418
|
+
.notra .hljs-symbol,
|
|
419
|
+
.notra .hljs-title {
|
|
420
|
+
color: #4078f2;
|
|
421
|
+
}
|
|
422
|
+
.notra .hljs-emphasis {
|
|
423
|
+
font-style: italic;
|
|
424
|
+
}
|
|
425
|
+
.notra .hljs-strong {
|
|
426
|
+
font-weight: bold;
|
|
427
|
+
}
|
|
428
|
+
.notra .hljs-link {
|
|
429
|
+
text-decoration: underline;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/* =====================
|
|
433
|
+
Code — Highlight (Atom One Dark, .dark override)
|
|
434
|
+
===================== */
|
|
435
|
+
.dark .notra .hljs {
|
|
436
|
+
color: #abb2bf;
|
|
437
|
+
background: #282c34;
|
|
438
|
+
}
|
|
439
|
+
.dark .notra .hljs-comment,
|
|
440
|
+
.dark .notra .hljs-quote {
|
|
441
|
+
color: #5c6370;
|
|
442
|
+
font-style: italic;
|
|
443
|
+
}
|
|
444
|
+
.dark .notra .hljs-doctag,
|
|
445
|
+
.dark .notra .hljs-formula,
|
|
446
|
+
.dark .notra .hljs-keyword {
|
|
447
|
+
color: #c678dd;
|
|
448
|
+
}
|
|
449
|
+
.dark .notra .hljs-deletion,
|
|
450
|
+
.dark .notra .hljs-name,
|
|
451
|
+
.dark .notra .hljs-section,
|
|
452
|
+
.dark .notra .hljs-selector-tag,
|
|
453
|
+
.dark .notra .hljs-subst {
|
|
454
|
+
color: #e06c75;
|
|
455
|
+
}
|
|
456
|
+
.dark .notra .hljs-literal {
|
|
457
|
+
color: #56b6c2;
|
|
458
|
+
}
|
|
459
|
+
.dark .notra .hljs-addition,
|
|
460
|
+
.dark .notra .hljs-attribute,
|
|
461
|
+
.dark .notra .hljs-meta .hljs-string,
|
|
462
|
+
.dark .notra .hljs-regexp,
|
|
463
|
+
.dark .notra .hljs-string {
|
|
464
|
+
color: #98c379;
|
|
465
|
+
}
|
|
466
|
+
.dark .notra .hljs-built_in,
|
|
467
|
+
.dark .notra .hljs-class .hljs-title,
|
|
468
|
+
.dark .notra .hljs-title.class_ {
|
|
469
|
+
color: #e6c07b;
|
|
470
|
+
}
|
|
471
|
+
.dark .notra .hljs-attr,
|
|
472
|
+
.dark .notra .hljs-number,
|
|
473
|
+
.dark .notra .hljs-selector-attr,
|
|
474
|
+
.dark .notra .hljs-selector-class,
|
|
475
|
+
.dark .notra .hljs-selector-pseudo,
|
|
476
|
+
.dark .notra .hljs-template-variable,
|
|
477
|
+
.dark .notra .hljs-type,
|
|
478
|
+
.dark .notra .hljs-variable {
|
|
479
|
+
color: #d19a66;
|
|
480
|
+
}
|
|
481
|
+
.dark .notra .hljs-bullet,
|
|
482
|
+
.dark .notra .hljs-link,
|
|
483
|
+
.dark .notra .hljs-meta,
|
|
484
|
+
.dark .notra .hljs-selector-id,
|
|
485
|
+
.dark .notra .hljs-symbol,
|
|
486
|
+
.dark .notra .hljs-title {
|
|
487
|
+
color: #61aeee;
|
|
361
488
|
}
|
|
362
489
|
|
|
363
490
|
/* =====================
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "notra-editor",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.0",
|
|
5
5
|
"description": "A Markdown-first rich text editor for React",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"@radix-ui/react-slot": "^1.2.4",
|
|
43
43
|
"@tiptap/core": "^3.22.4",
|
|
44
44
|
"@tiptap/extension-code-block": "^3.22.4",
|
|
45
|
+
"@tiptap/extension-code-block-lowlight": "^3.22.4",
|
|
45
46
|
"@tiptap/extension-image": "^3.22.4",
|
|
46
47
|
"@tiptap/extension-link": "^3.22.4",
|
|
47
48
|
"@tiptap/extension-list": "^3.22.4",
|
|
@@ -51,6 +52,9 @@
|
|
|
51
52
|
"@tiptap/static-renderer": "^3.22.4",
|
|
52
53
|
"class-variance-authority": "^0.7.1",
|
|
53
54
|
"clsx": "^2.1.1",
|
|
55
|
+
"cmdk": "^1.1.1",
|
|
56
|
+
"hast-util-to-html": "^9.0.5",
|
|
57
|
+
"lowlight": "^3.3.0",
|
|
54
58
|
"lucide-react": "^1.9.0",
|
|
55
59
|
"radix-ui": "^1.4.3",
|
|
56
60
|
"tailwind-merge": "^3.5.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/code-block-view.tsx"],"sourcesContent":["'use client';\n\nimport {\n\tNodeViewContent,\n\tNodeViewWrapper,\n\ttype NodeViewProps\n} from '@tiptap/react';\n\nimport { CopyButton } from './copy-button';\n\nimport type { ReactNode } from 'react';\n\ninterface CodeBlockShellProps {\n\tvalue: string;\n\tchildren: ReactNode;\n}\n\n// Visual structure shared by editor (NodeView) and reader (nodeMapping).\n// Children is the <code> element (or <NodeViewContent as=\"code\"/>); the\n// shell does not wrap it because each consumer mounts <code> differently.\nexport const CodeBlockShell = ({ value, children }: CodeBlockShellProps) => (\n\t<div className=\"nt:relative\">\n\t\t<div className=\"nt:absolute nt:inset-x-0 nt:top-0 nt:flex nt:h-9 nt:items-center nt:justify-end nt:px-2\">\n\t\t\t<CopyButton value={value} />\n\t\t</div>\n\t\t<pre className=\"nt:!pt-9\">{children}</pre>\n\t</div>\n);\n\n// Editor-side React NodeView. Tiptap mounts content-editable DOM directly\n// onto the <code> rendered by NodeViewContent.\nexport const CodeBlockView = ({ node }: NodeViewProps) => (\n\t<NodeViewWrapper>\n\t\t<CodeBlockShell value={node.textContent}>\n\t\t\t<NodeViewContent<'code'> as=\"code\" />\n\t\t</CodeBlockShell>\n\t</NodeViewWrapper>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBC;AAnBD,mBAIO;AAEP,yBAA2B;AAYpB,MAAM,iBAAiB,CAAC,EAAE,OAAO,SAAS,MAChD,6CAAC,SAAI,WAAU,eACd;AAAA,8CAAC,SAAI,WAAU,2FACd,sDAAC,iCAAW,OAAc,GAC3B;AAAA,EACA,4CAAC,SAAI,WAAU,YAAY,UAAS;AAAA,GACrC;AAKM,MAAM,gBAAgB,CAAC,EAAE,KAAK,MACpC,4CAAC,gCACA,sDAAC,kBAAe,OAAO,KAAK,aAC3B,sDAAC,gCAAwB,IAAG,QAAO,GACpC,GACD;","names":[]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { NodeViewProps } from '@tiptap/react';
|
|
3
|
-
import { ReactNode } from 'react';
|
|
4
|
-
|
|
5
|
-
interface CodeBlockShellProps {
|
|
6
|
-
value: string;
|
|
7
|
-
children: ReactNode;
|
|
8
|
-
}
|
|
9
|
-
declare const CodeBlockShell: ({ value, children }: CodeBlockShellProps) => react_jsx_runtime.JSX.Element;
|
|
10
|
-
declare const CodeBlockView: ({ node }: NodeViewProps) => react_jsx_runtime.JSX.Element;
|
|
11
|
-
|
|
12
|
-
export { CodeBlockShell, CodeBlockView };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { NodeViewProps } from '@tiptap/react';
|
|
3
|
-
import { ReactNode } from 'react';
|
|
4
|
-
|
|
5
|
-
interface CodeBlockShellProps {
|
|
6
|
-
value: string;
|
|
7
|
-
children: ReactNode;
|
|
8
|
-
}
|
|
9
|
-
declare const CodeBlockShell: ({ value, children }: CodeBlockShellProps) => react_jsx_runtime.JSX.Element;
|
|
10
|
-
declare const CodeBlockView: ({ node }: NodeViewProps) => react_jsx_runtime.JSX.Element;
|
|
11
|
-
|
|
12
|
-
export { CodeBlockShell, CodeBlockView };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
NodeViewContent,
|
|
5
|
-
NodeViewWrapper
|
|
6
|
-
} from "@tiptap/react";
|
|
7
|
-
import { CopyButton } from "./copy-button";
|
|
8
|
-
const CodeBlockShell = ({ value, children }) => /* @__PURE__ */ jsxs("div", { className: "nt:relative", children: [
|
|
9
|
-
/* @__PURE__ */ jsx("div", { className: "nt:absolute nt:inset-x-0 nt:top-0 nt:flex nt:h-9 nt:items-center nt:justify-end nt:px-2", children: /* @__PURE__ */ jsx(CopyButton, { value }) }),
|
|
10
|
-
/* @__PURE__ */ jsx("pre", { className: "nt:!pt-9", children })
|
|
11
|
-
] });
|
|
12
|
-
const CodeBlockView = ({ node }) => /* @__PURE__ */ jsx(NodeViewWrapper, { children: /* @__PURE__ */ jsx(CodeBlockShell, { value: node.textContent, children: /* @__PURE__ */ jsx(NodeViewContent, { as: "code" }) }) });
|
|
13
|
-
export {
|
|
14
|
-
CodeBlockShell,
|
|
15
|
-
CodeBlockView
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=code-block-view.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/code-block-view.tsx"],"sourcesContent":["'use client';\n\nimport {\n\tNodeViewContent,\n\tNodeViewWrapper,\n\ttype NodeViewProps\n} from '@tiptap/react';\n\nimport { CopyButton } from './copy-button';\n\nimport type { ReactNode } from 'react';\n\ninterface CodeBlockShellProps {\n\tvalue: string;\n\tchildren: ReactNode;\n}\n\n// Visual structure shared by editor (NodeView) and reader (nodeMapping).\n// Children is the <code> element (or <NodeViewContent as=\"code\"/>); the\n// shell does not wrap it because each consumer mounts <code> differently.\nexport const CodeBlockShell = ({ value, children }: CodeBlockShellProps) => (\n\t<div className=\"nt:relative\">\n\t\t<div className=\"nt:absolute nt:inset-x-0 nt:top-0 nt:flex nt:h-9 nt:items-center nt:justify-end nt:px-2\">\n\t\t\t<CopyButton value={value} />\n\t\t</div>\n\t\t<pre className=\"nt:!pt-9\">{children}</pre>\n\t</div>\n);\n\n// Editor-side React NodeView. Tiptap mounts content-editable DOM directly\n// onto the <code> rendered by NodeViewContent.\nexport const CodeBlockView = ({ node }: NodeViewProps) => (\n\t<NodeViewWrapper>\n\t\t<CodeBlockShell value={node.textContent}>\n\t\t\t<NodeViewContent<'code'> as=\"code\" />\n\t\t</CodeBlockShell>\n\t</NodeViewWrapper>\n);\n"],"mappings":";AAqBC,SAEE,KAFF;AAnBD;AAAA,EACC;AAAA,EACA;AAAA,OAEM;AAEP,SAAS,kBAAkB;AAYpB,MAAM,iBAAiB,CAAC,EAAE,OAAO,SAAS,MAChD,qBAAC,SAAI,WAAU,eACd;AAAA,sBAAC,SAAI,WAAU,2FACd,8BAAC,cAAW,OAAc,GAC3B;AAAA,EACA,oBAAC,SAAI,WAAU,YAAY,UAAS;AAAA,GACrC;AAKM,MAAM,gBAAgB,CAAC,EAAE,KAAK,MACpC,oBAAC,mBACA,8BAAC,kBAAe,OAAO,KAAK,aAC3B,8BAAC,mBAAwB,IAAG,QAAO,GACpC,GACD;","names":[]}
|