notra-editor 0.4.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/image-popover/image-popover.cjs +161 -0
- package/dist/components/image-popover/image-popover.cjs.map +1 -0
- package/dist/components/image-popover/image-popover.d.cts +9 -0
- package/dist/components/image-popover/image-popover.d.ts +9 -0
- package/dist/components/image-popover/image-popover.mjs +137 -0
- package/dist/components/image-popover/image-popover.mjs.map +1 -0
- package/dist/components/image-popover/use-image-popover.cjs +88 -0
- package/dist/components/image-popover/use-image-popover.cjs.map +1 -0
- package/dist/components/image-popover/use-image-popover.d.cts +19 -0
- package/dist/components/image-popover/use-image-popover.d.ts +19 -0
- package/dist/components/image-popover/use-image-popover.mjs +64 -0
- package/dist/components/image-popover/use-image-popover.mjs.map +1 -0
- package/dist/components/link-popover/link-popover.cjs +12 -3
- package/dist/components/link-popover/link-popover.cjs.map +1 -1
- package/dist/components/link-popover/link-popover.mjs +12 -3
- package/dist/components/link-popover/link-popover.mjs.map +1 -1
- package/dist/components/link-popover/use-link-popover.cjs +17 -2
- package/dist/components/link-popover/use-link-popover.cjs.map +1 -1
- package/dist/components/link-popover/use-link-popover.d.cts +1 -0
- package/dist/components/link-popover/use-link-popover.d.ts +1 -0
- package/dist/components/link-popover/use-link-popover.mjs +17 -2
- package/dist/components/link-popover/use-link-popover.mjs.map +1 -1
- 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.cjs +2 -0
- package/dist/extensions/editor.cjs.map +1 -1
- package/dist/extensions/editor.d.cts +4 -3
- package/dist/extensions/editor.d.ts +4 -3
- package/dist/extensions/editor.mjs +2 -0
- package/dist/extensions/editor.mjs.map +1 -1
- package/dist/extensions/index.d.cts +2 -1
- package/dist/extensions/index.d.ts +2 -1
- package/dist/extensions/shared.cjs +8 -2
- package/dist/extensions/shared.cjs.map +1 -1
- package/dist/extensions/shared.d.cts +3 -1
- package/dist/extensions/shared.d.ts +3 -1
- package/dist/extensions/shared.mjs +8 -2
- package/dist/extensions/shared.mjs.map +1 -1
- package/dist/index.cjs +23 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.mjs +18 -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-editor.cjs +3 -1
- package/dist/notra-editor.cjs.map +1 -1
- package/dist/notra-editor.mjs +3 -1
- package/dist/notra-editor.mjs.map +1 -1
- 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 +112 -0
- package/dist/themes/default/shared.css +150 -5
- package/package.json +6 -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
|
@@ -0,0 +1,41 @@
|
|
|
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 code_block_shell_exports = {};
|
|
20
|
+
__export(code_block_shell_exports, {
|
|
21
|
+
CodeBlockShell: () => CodeBlockShell
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(code_block_shell_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_copy_button = require("../copy-button");
|
|
26
|
+
const CodeBlockShell = ({
|
|
27
|
+
value,
|
|
28
|
+
languageSlot,
|
|
29
|
+
children
|
|
30
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "nt:relative", children: [
|
|
31
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "nt:absolute nt:inset-x-0 nt:top-0 nt:flex nt:h-9 nt:items-center nt:justify-between nt:px-2", children: [
|
|
32
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "nt:min-w-0 nt:flex-1", children: languageSlot }),
|
|
33
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_copy_button.CopyButton, { value })
|
|
34
|
+
] }),
|
|
35
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "nt:!pt-9 hljs", children })
|
|
36
|
+
] });
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
CodeBlockShell
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=code-block-shell.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/code-block-view/code-block-shell.tsx"],"sourcesContent":["import { CopyButton } from '../copy-button';\n\nimport type { ReactNode } from 'react';\n\ninterface CodeBlockShellProps {\n\tvalue: string;\n\tlanguageSlot: ReactNode;\n\tchildren: ReactNode;\n}\n\n// Visual frame shared by the editor (NodeView) and reader (nodeMapping).\n// `languageSlot` lets each consumer plug its own widget into the top bar:\n// the editor passes <LanguageSelect>, the reader passes a static label.\n// `children` is the <code> element (NodeViewContent in the editor, a\n// dangerouslySetInnerHTML <code> in the reader).\nexport const CodeBlockShell = ({\n\tvalue,\n\tlanguageSlot,\n\tchildren\n}: 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-between nt:px-2\">\n\t\t\t<div className=\"nt:min-w-0 nt:flex-1\">{languageSlot}</div>\n\t\t\t<CopyButton value={value} />\n\t\t</div>\n\t\t<pre className=\"nt:!pt-9 hljs\">{children}</pre>\n\t</div>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBE;AArBF,yBAA2B;AAepB,MAAM,iBAAiB,CAAC;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AACD,MACC,6CAAC,SAAI,WAAU,eACd;AAAA,+CAAC,SAAI,WAAU,+FACd;AAAA,gDAAC,SAAI,WAAU,wBAAwB,wBAAa;AAAA,IACpD,4CAAC,iCAAW,OAAc;AAAA,KAC3B;AAAA,EACA,4CAAC,SAAI,WAAU,iBAAiB,UAAS;AAAA,GAC1C;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
interface CodeBlockShellProps {
|
|
5
|
+
value: string;
|
|
6
|
+
languageSlot: ReactNode;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
declare const CodeBlockShell: ({ value, languageSlot, children }: CodeBlockShellProps) => react_jsx_runtime.JSX.Element;
|
|
10
|
+
|
|
11
|
+
export { CodeBlockShell };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
interface CodeBlockShellProps {
|
|
5
|
+
value: string;
|
|
6
|
+
languageSlot: ReactNode;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
declare const CodeBlockShell: ({ value, languageSlot, children }: CodeBlockShellProps) => react_jsx_runtime.JSX.Element;
|
|
10
|
+
|
|
11
|
+
export { CodeBlockShell };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CopyButton } from "../copy-button";
|
|
3
|
+
const CodeBlockShell = ({
|
|
4
|
+
value,
|
|
5
|
+
languageSlot,
|
|
6
|
+
children
|
|
7
|
+
}) => /* @__PURE__ */ jsxs("div", { className: "nt:relative", children: [
|
|
8
|
+
/* @__PURE__ */ jsxs("div", { className: "nt:absolute nt:inset-x-0 nt:top-0 nt:flex nt:h-9 nt:items-center nt:justify-between nt:px-2", children: [
|
|
9
|
+
/* @__PURE__ */ jsx("div", { className: "nt:min-w-0 nt:flex-1", children: languageSlot }),
|
|
10
|
+
/* @__PURE__ */ jsx(CopyButton, { value })
|
|
11
|
+
] }),
|
|
12
|
+
/* @__PURE__ */ jsx("pre", { className: "nt:!pt-9 hljs", children })
|
|
13
|
+
] });
|
|
14
|
+
export {
|
|
15
|
+
CodeBlockShell
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=code-block-shell.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/code-block-view/code-block-shell.tsx"],"sourcesContent":["import { CopyButton } from '../copy-button';\n\nimport type { ReactNode } from 'react';\n\ninterface CodeBlockShellProps {\n\tvalue: string;\n\tlanguageSlot: ReactNode;\n\tchildren: ReactNode;\n}\n\n// Visual frame shared by the editor (NodeView) and reader (nodeMapping).\n// `languageSlot` lets each consumer plug its own widget into the top bar:\n// the editor passes <LanguageSelect>, the reader passes a static label.\n// `children` is the <code> element (NodeViewContent in the editor, a\n// dangerouslySetInnerHTML <code> in the reader).\nexport const CodeBlockShell = ({\n\tvalue,\n\tlanguageSlot,\n\tchildren\n}: 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-between nt:px-2\">\n\t\t\t<div className=\"nt:min-w-0 nt:flex-1\">{languageSlot}</div>\n\t\t\t<CopyButton value={value} />\n\t\t</div>\n\t\t<pre className=\"nt:!pt-9 hljs\">{children}</pre>\n\t</div>\n);\n"],"mappings":"AAqBE,SACC,KADD;AArBF,SAAS,kBAAkB;AAepB,MAAM,iBAAiB,CAAC;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AACD,MACC,qBAAC,SAAI,WAAU,eACd;AAAA,uBAAC,SAAI,WAAU,+FACd;AAAA,wBAAC,SAAI,WAAU,wBAAwB,wBAAa;AAAA,IACpD,oBAAC,cAAW,OAAc;AAAA,KAC3B;AAAA,EACA,oBAAC,SAAI,WAAU,iBAAiB,UAAS;AAAA,GAC1C;","names":[]}
|
|
@@ -19,21 +19,29 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
20
|
var code_block_view_exports = {};
|
|
21
21
|
__export(code_block_view_exports, {
|
|
22
|
-
CodeBlockShell: () => CodeBlockShell,
|
|
23
22
|
CodeBlockView: () => CodeBlockView
|
|
24
23
|
});
|
|
25
24
|
module.exports = __toCommonJS(code_block_view_exports);
|
|
26
25
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
27
26
|
var import_react = require("@tiptap/react");
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
var import_code_block_shell = require("./code-block-shell");
|
|
28
|
+
var import_language_select = require("./language-select");
|
|
29
|
+
const CodeBlockView = ({ node, updateAttributes }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.NodeViewWrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
30
|
+
import_code_block_shell.CodeBlockShell,
|
|
31
|
+
{
|
|
32
|
+
languageSlot: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
33
|
+
import_language_select.LanguageSelect,
|
|
34
|
+
{
|
|
35
|
+
language: node.attrs.language ?? "",
|
|
36
|
+
onLanguageChange: (language) => updateAttributes({ language })
|
|
37
|
+
}
|
|
38
|
+
),
|
|
39
|
+
value: node.textContent,
|
|
40
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.NodeViewContent, { as: "code", className: "hljs" })
|
|
41
|
+
}
|
|
42
|
+
) });
|
|
34
43
|
// Annotate the CommonJS export names for ESM import in node:
|
|
35
44
|
0 && (module.exports = {
|
|
36
|
-
CodeBlockShell,
|
|
37
45
|
CodeBlockView
|
|
38
46
|
});
|
|
39
47
|
//# sourceMappingURL=code-block-view.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/code-block-view/code-block-view.tsx"],"sourcesContent":["'use client';\n\nimport {\n\tNodeViewContent,\n\tNodeViewWrapper,\n\ttype NodeViewProps\n} from '@tiptap/react';\n\nimport { CodeBlockShell } from './code-block-shell';\nimport { LanguageSelect } from './language-select';\n\n// Editor-side React NodeView. Tiptap mounts content-editable DOM directly\n// onto the <code> rendered by NodeViewContent. lowlight decorates that\n// content with <span class=\"hljs-*\"> spans on every transaction.\nexport const CodeBlockView = ({ node, updateAttributes }: NodeViewProps) => (\n\t<NodeViewWrapper>\n\t\t<CodeBlockShell\n\t\t\tlanguageSlot={\n\t\t\t\t<LanguageSelect\n\t\t\t\t\tlanguage={(node.attrs.language as string) ?? ''}\n\t\t\t\t\tonLanguageChange={(language) => updateAttributes({ language })}\n\t\t\t\t/>\n\t\t\t}\n\t\t\tvalue={node.textContent}\n\t\t>\n\t\t\t<NodeViewContent<'code'> as=\"code\" className=\"hljs\" />\n\t\t</CodeBlockShell>\n\t</NodeViewWrapper>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBI;AAhBJ,mBAIO;AAEP,8BAA+B;AAC/B,6BAA+B;AAKxB,MAAM,gBAAgB,CAAC,EAAE,MAAM,iBAAiB,MACtD,4CAAC,gCACA;AAAA,EAAC;AAAA;AAAA,IACA,cACC;AAAA,MAAC;AAAA;AAAA,QACA,UAAW,KAAK,MAAM,YAAuB;AAAA,QAC7C,kBAAkB,CAAC,aAAa,iBAAiB,EAAE,SAAS,CAAC;AAAA;AAAA,IAC9D;AAAA,IAED,OAAO,KAAK;AAAA,IAEZ,sDAAC,gCAAwB,IAAG,QAAO,WAAU,QAAO;AAAA;AACrD,GACD;","names":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
NodeViewContent,
|
|
5
|
+
NodeViewWrapper
|
|
6
|
+
} from "@tiptap/react";
|
|
7
|
+
import { CodeBlockShell } from "./code-block-shell";
|
|
8
|
+
import { LanguageSelect } from "./language-select";
|
|
9
|
+
const CodeBlockView = ({ node, updateAttributes }) => /* @__PURE__ */ jsx(NodeViewWrapper, { children: /* @__PURE__ */ jsx(
|
|
10
|
+
CodeBlockShell,
|
|
11
|
+
{
|
|
12
|
+
languageSlot: /* @__PURE__ */ jsx(
|
|
13
|
+
LanguageSelect,
|
|
14
|
+
{
|
|
15
|
+
language: node.attrs.language ?? "",
|
|
16
|
+
onLanguageChange: (language) => updateAttributes({ language })
|
|
17
|
+
}
|
|
18
|
+
),
|
|
19
|
+
value: node.textContent,
|
|
20
|
+
children: /* @__PURE__ */ jsx(NodeViewContent, { as: "code", className: "hljs" })
|
|
21
|
+
}
|
|
22
|
+
) });
|
|
23
|
+
export {
|
|
24
|
+
CodeBlockView
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=code-block-view.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/code-block-view/code-block-view.tsx"],"sourcesContent":["'use client';\n\nimport {\n\tNodeViewContent,\n\tNodeViewWrapper,\n\ttype NodeViewProps\n} from '@tiptap/react';\n\nimport { CodeBlockShell } from './code-block-shell';\nimport { LanguageSelect } from './language-select';\n\n// Editor-side React NodeView. Tiptap mounts content-editable DOM directly\n// onto the <code> rendered by NodeViewContent. lowlight decorates that\n// content with <span class=\"hljs-*\"> spans on every transaction.\nexport const CodeBlockView = ({ node, updateAttributes }: NodeViewProps) => (\n\t<NodeViewWrapper>\n\t\t<CodeBlockShell\n\t\t\tlanguageSlot={\n\t\t\t\t<LanguageSelect\n\t\t\t\t\tlanguage={(node.attrs.language as string) ?? ''}\n\t\t\t\t\tonLanguageChange={(language) => updateAttributes({ language })}\n\t\t\t\t/>\n\t\t\t}\n\t\t\tvalue={node.textContent}\n\t\t>\n\t\t\t<NodeViewContent<'code'> as=\"code\" className=\"hljs\" />\n\t\t</CodeBlockShell>\n\t</NodeViewWrapper>\n);\n"],"mappings":";AAkBI;AAhBJ;AAAA,EACC;AAAA,EACA;AAAA,OAEM;AAEP,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAKxB,MAAM,gBAAgB,CAAC,EAAE,MAAM,iBAAiB,MACtD,oBAAC,mBACA;AAAA,EAAC;AAAA;AAAA,IACA,cACC;AAAA,MAAC;AAAA;AAAA,QACA,UAAW,KAAK,MAAM,YAAuB;AAAA,QAC7C,kBAAkB,CAAC,aAAa,iBAAiB,EAAE,SAAS,CAAC;AAAA;AAAA,IAC9D;AAAA,IAED,OAAO,KAAK;AAAA,IAEZ,8BAAC,mBAAwB,IAAG,QAAO,WAAU,QAAO;AAAA;AACrD,GACD;","names":[]}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var language_select_exports = {};
|
|
21
|
+
__export(language_select_exports, {
|
|
22
|
+
LanguageSelect: () => LanguageSelect
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(language_select_exports);
|
|
25
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
var import_lucide_react = require("lucide-react");
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
var import_languages = require("../../lib/languages");
|
|
29
|
+
var import_utils = require("../../lib/utils");
|
|
30
|
+
var import_button = require("../ui/button");
|
|
31
|
+
var import_command = require("../ui/command");
|
|
32
|
+
var import_popover = require("../ui/popover");
|
|
33
|
+
const LanguageSelect = ({
|
|
34
|
+
language,
|
|
35
|
+
onLanguageChange
|
|
36
|
+
}) => {
|
|
37
|
+
const [open, setOpen] = (0, import_react.useState)(false);
|
|
38
|
+
const current = language || "auto";
|
|
39
|
+
const label = (0, import_languages.getLanguageLabel)(current);
|
|
40
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_popover.Popover, { open, onOpenChange: setOpen, children: [
|
|
41
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popover.PopoverTrigger, { asChild: true, onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
42
|
+
import_button.Button,
|
|
43
|
+
{
|
|
44
|
+
"aria-expanded": open,
|
|
45
|
+
className: "nt:h-7 nt:gap-1 nt:px-2 nt:text-xs",
|
|
46
|
+
size: "sm",
|
|
47
|
+
tabIndex: -1,
|
|
48
|
+
type: "button",
|
|
49
|
+
variant: "ghost",
|
|
50
|
+
children: [
|
|
51
|
+
label,
|
|
52
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.ChevronDownIcon, { className: "nt:size-3 nt:opacity-50" })
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
) }),
|
|
56
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popover.PopoverContent, { align: "start", className: "nt:w-[200px] nt:p-0", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_command.Command, { children: [
|
|
57
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_command.CommandInput, { placeholder: "Search language..." }),
|
|
58
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_command.CommandList, { children: [
|
|
59
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_command.CommandEmpty, { children: "No language found." }),
|
|
60
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_command.CommandGroup, { children: import_languages.LANGUAGES.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
61
|
+
import_command.CommandItem,
|
|
62
|
+
{
|
|
63
|
+
value: item.value,
|
|
64
|
+
onSelect: (value) => {
|
|
65
|
+
onLanguageChange(value);
|
|
66
|
+
setOpen(false);
|
|
67
|
+
},
|
|
68
|
+
children: [
|
|
69
|
+
item.label,
|
|
70
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
71
|
+
import_lucide_react.CheckIcon,
|
|
72
|
+
{
|
|
73
|
+
className: (0, import_utils.cn)(
|
|
74
|
+
"nt:ml-auto nt:size-4",
|
|
75
|
+
current === item.value ? "nt:opacity-100" : "nt:opacity-0"
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
item.value
|
|
82
|
+
)) })
|
|
83
|
+
] })
|
|
84
|
+
] }) })
|
|
85
|
+
] });
|
|
86
|
+
};
|
|
87
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
88
|
+
0 && (module.exports = {
|
|
89
|
+
LanguageSelect
|
|
90
|
+
});
|
|
91
|
+
//# sourceMappingURL=language-select.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/code-block-view/language-select.tsx"],"sourcesContent":["'use client';\n\nimport { CheckIcon, ChevronDownIcon } from 'lucide-react';\nimport { useState } from 'react';\n\nimport { LANGUAGES, getLanguageLabel } from '../../lib/languages';\nimport { cn } from '../../lib/utils';\nimport { Button } from '../ui/button';\nimport {\n\tCommand,\n\tCommandEmpty,\n\tCommandGroup,\n\tCommandInput,\n\tCommandItem,\n\tCommandList\n} from '../ui/command';\nimport { Popover, PopoverContent, PopoverTrigger } from '../ui/popover';\n\nexport interface LanguageSelectProps {\n\t/** Current language value (e.g. \"typescript\"); empty / \"auto\" → \"Auto\" label */\n\tlanguage: string;\n\t/** Called with the new value when the user picks a language */\n\tonLanguageChange: (language: string) => void;\n}\n\nexport const LanguageSelect = ({\n\tlanguage,\n\tonLanguageChange\n}: LanguageSelectProps) => {\n\tconst [open, setOpen] = useState(false);\n\tconst current = language || 'auto';\n\tconst label = getLanguageLabel(current);\n\n\treturn (\n\t\t<Popover open={open} onOpenChange={setOpen}>\n\t\t\t<PopoverTrigger asChild onClick={(e) => e.stopPropagation()}>\n\t\t\t\t<Button\n\t\t\t\t\taria-expanded={open}\n\t\t\t\t\tclassName=\"nt:h-7 nt:gap-1 nt:px-2 nt:text-xs\"\n\t\t\t\t\tsize=\"sm\"\n\t\t\t\t\ttabIndex={-1}\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tvariant=\"ghost\"\n\t\t\t\t>\n\t\t\t\t\t{label}\n\t\t\t\t\t<ChevronDownIcon className=\"nt:size-3 nt:opacity-50\" />\n\t\t\t\t</Button>\n\t\t\t</PopoverTrigger>\n\t\t\t<PopoverContent align=\"start\" className=\"nt:w-[200px] nt:p-0\">\n\t\t\t\t<Command>\n\t\t\t\t\t<CommandInput placeholder=\"Search language...\" />\n\t\t\t\t\t<CommandList>\n\t\t\t\t\t\t<CommandEmpty>No language found.</CommandEmpty>\n\t\t\t\t\t\t<CommandGroup>\n\t\t\t\t\t\t\t{LANGUAGES.map((item) => (\n\t\t\t\t\t\t\t\t<CommandItem\n\t\t\t\t\t\t\t\t\tkey={item.value}\n\t\t\t\t\t\t\t\t\tvalue={item.value}\n\t\t\t\t\t\t\t\t\tonSelect={(value) => {\n\t\t\t\t\t\t\t\t\t\tonLanguageChange(value);\n\t\t\t\t\t\t\t\t\t\tsetOpen(false);\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\t\t{item.label}\n\t\t\t\t\t\t\t\t\t<CheckIcon\n\t\t\t\t\t\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\t\t\t\t\t'nt:ml-auto nt:size-4',\n\t\t\t\t\t\t\t\t\t\t\tcurrent === item.value ? 'nt:opacity-100' : 'nt:opacity-0'\n\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</CommandItem>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</CommandGroup>\n\t\t\t\t\t</Command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AAAA,UAbK,KAAK;AAAA,QAcX,CACA,GACF;AAAA,SACD;AAAA,OACD,GACD;AAAA,KACD;AAEF;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
interface LanguageSelectProps {
|
|
4
|
+
/** Current language value (e.g. "typescript"); empty / "auto" → "Auto" label */
|
|
5
|
+
language: string;
|
|
6
|
+
/** Called with the new value when the user picks a language */
|
|
7
|
+
onLanguageChange: (language: string) => void;
|
|
8
|
+
}
|
|
9
|
+
declare const LanguageSelect: ({ language, onLanguageChange }: LanguageSelectProps) => react_jsx_runtime.JSX.Element;
|
|
10
|
+
|
|
11
|
+
export { LanguageSelect, type LanguageSelectProps };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
interface LanguageSelectProps {
|
|
4
|
+
/** Current language value (e.g. "typescript"); empty / "auto" → "Auto" label */
|
|
5
|
+
language: string;
|
|
6
|
+
/** Called with the new value when the user picks a language */
|
|
7
|
+
onLanguageChange: (language: string) => void;
|
|
8
|
+
}
|
|
9
|
+
declare const LanguageSelect: ({ language, onLanguageChange }: LanguageSelectProps) => react_jsx_runtime.JSX.Element;
|
|
10
|
+
|
|
11
|
+
export { LanguageSelect, type LanguageSelectProps };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { CheckIcon, ChevronDownIcon } from "lucide-react";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { LANGUAGES, getLanguageLabel } from "../../lib/languages";
|
|
6
|
+
import { cn } from "../../lib/utils";
|
|
7
|
+
import { Button } from "../ui/button";
|
|
8
|
+
import {
|
|
9
|
+
Command,
|
|
10
|
+
CommandEmpty,
|
|
11
|
+
CommandGroup,
|
|
12
|
+
CommandInput,
|
|
13
|
+
CommandItem,
|
|
14
|
+
CommandList
|
|
15
|
+
} from "../ui/command";
|
|
16
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover";
|
|
17
|
+
const LanguageSelect = ({
|
|
18
|
+
language,
|
|
19
|
+
onLanguageChange
|
|
20
|
+
}) => {
|
|
21
|
+
const [open, setOpen] = useState(false);
|
|
22
|
+
const current = language || "auto";
|
|
23
|
+
const label = getLanguageLabel(current);
|
|
24
|
+
return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
|
|
25
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsxs(
|
|
26
|
+
Button,
|
|
27
|
+
{
|
|
28
|
+
"aria-expanded": open,
|
|
29
|
+
className: "nt:h-7 nt:gap-1 nt:px-2 nt:text-xs",
|
|
30
|
+
size: "sm",
|
|
31
|
+
tabIndex: -1,
|
|
32
|
+
type: "button",
|
|
33
|
+
variant: "ghost",
|
|
34
|
+
children: [
|
|
35
|
+
label,
|
|
36
|
+
/* @__PURE__ */ jsx(ChevronDownIcon, { className: "nt:size-3 nt:opacity-50" })
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
) }),
|
|
40
|
+
/* @__PURE__ */ jsx(PopoverContent, { align: "start", className: "nt:w-[200px] nt:p-0", children: /* @__PURE__ */ jsxs(Command, { children: [
|
|
41
|
+
/* @__PURE__ */ jsx(CommandInput, { placeholder: "Search language..." }),
|
|
42
|
+
/* @__PURE__ */ jsxs(CommandList, { children: [
|
|
43
|
+
/* @__PURE__ */ jsx(CommandEmpty, { children: "No language found." }),
|
|
44
|
+
/* @__PURE__ */ jsx(CommandGroup, { children: LANGUAGES.map((item) => /* @__PURE__ */ jsxs(
|
|
45
|
+
CommandItem,
|
|
46
|
+
{
|
|
47
|
+
value: item.value,
|
|
48
|
+
onSelect: (value) => {
|
|
49
|
+
onLanguageChange(value);
|
|
50
|
+
setOpen(false);
|
|
51
|
+
},
|
|
52
|
+
children: [
|
|
53
|
+
item.label,
|
|
54
|
+
/* @__PURE__ */ jsx(
|
|
55
|
+
CheckIcon,
|
|
56
|
+
{
|
|
57
|
+
className: cn(
|
|
58
|
+
"nt:ml-auto nt:size-4",
|
|
59
|
+
current === item.value ? "nt:opacity-100" : "nt:opacity-0"
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
item.value
|
|
66
|
+
)) })
|
|
67
|
+
] })
|
|
68
|
+
] }) })
|
|
69
|
+
] });
|
|
70
|
+
};
|
|
71
|
+
export {
|
|
72
|
+
LanguageSelect
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=language-select.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/code-block-view/language-select.tsx"],"sourcesContent":["'use client';\n\nimport { CheckIcon, ChevronDownIcon } from 'lucide-react';\nimport { useState } from 'react';\n\nimport { LANGUAGES, getLanguageLabel } from '../../lib/languages';\nimport { cn } from '../../lib/utils';\nimport { Button } from '../ui/button';\nimport {\n\tCommand,\n\tCommandEmpty,\n\tCommandGroup,\n\tCommandInput,\n\tCommandItem,\n\tCommandList\n} from '../ui/command';\nimport { Popover, PopoverContent, PopoverTrigger } from '../ui/popover';\n\nexport interface LanguageSelectProps {\n\t/** Current language value (e.g. \"typescript\"); empty / \"auto\" → \"Auto\" label */\n\tlanguage: string;\n\t/** Called with the new value when the user picks a language */\n\tonLanguageChange: (language: string) => void;\n}\n\nexport const LanguageSelect = ({\n\tlanguage,\n\tonLanguageChange\n}: LanguageSelectProps) => {\n\tconst [open, setOpen] = useState(false);\n\tconst current = language || 'auto';\n\tconst label = getLanguageLabel(current);\n\n\treturn (\n\t\t<Popover open={open} onOpenChange={setOpen}>\n\t\t\t<PopoverTrigger asChild onClick={(e) => e.stopPropagation()}>\n\t\t\t\t<Button\n\t\t\t\t\taria-expanded={open}\n\t\t\t\t\tclassName=\"nt:h-7 nt:gap-1 nt:px-2 nt:text-xs\"\n\t\t\t\t\tsize=\"sm\"\n\t\t\t\t\ttabIndex={-1}\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tvariant=\"ghost\"\n\t\t\t\t>\n\t\t\t\t\t{label}\n\t\t\t\t\t<ChevronDownIcon className=\"nt:size-3 nt:opacity-50\" />\n\t\t\t\t</Button>\n\t\t\t</PopoverTrigger>\n\t\t\t<PopoverContent align=\"start\" className=\"nt:w-[200px] nt:p-0\">\n\t\t\t\t<Command>\n\t\t\t\t\t<CommandInput placeholder=\"Search language...\" />\n\t\t\t\t\t<CommandList>\n\t\t\t\t\t\t<CommandEmpty>No language found.</CommandEmpty>\n\t\t\t\t\t\t<CommandGroup>\n\t\t\t\t\t\t\t{LANGUAGES.map((item) => (\n\t\t\t\t\t\t\t\t<CommandItem\n\t\t\t\t\t\t\t\t\tkey={item.value}\n\t\t\t\t\t\t\t\t\tvalue={item.value}\n\t\t\t\t\t\t\t\t\tonSelect={(value) => {\n\t\t\t\t\t\t\t\t\t\tonLanguageChange(value);\n\t\t\t\t\t\t\t\t\t\tsetOpen(false);\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\t\t{item.label}\n\t\t\t\t\t\t\t\t\t<CheckIcon\n\t\t\t\t\t\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\t\t\t\t\t'nt:ml-auto nt:size-4',\n\t\t\t\t\t\t\t\t\t\t\tcurrent === item.value ? 'nt:opacity-100' : 'nt:opacity-0'\n\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</CommandItem>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</CommandGroup>\n\t\t\t\t\t</CommandList>\n\t\t\t\t</Command>\n\t\t\t</PopoverContent>\n\t\t</Popover>\n\t);\n};\n"],"mappings":";AAoCI,SASC,KATD;AAlCJ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AAAA,QAcX,CACA,GACF;AAAA,SACD;AAAA,OACD,GACD;AAAA,KACD;AAEF;","names":[]}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var image_popover_exports = {};
|
|
21
|
+
__export(image_popover_exports, {
|
|
22
|
+
ImagePopover: () => ImagePopover
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(image_popover_exports);
|
|
25
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
var import_lucide_react = require("lucide-react");
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
var import_use_image_popover = require("./use-image-popover");
|
|
29
|
+
var import_button = require("../ui/button");
|
|
30
|
+
var import_input = require("../ui/input");
|
|
31
|
+
var import_popover = require("../ui/popover");
|
|
32
|
+
var import_separator = require("../ui/separator");
|
|
33
|
+
const ImagePopover = (0, import_react.forwardRef)(
|
|
34
|
+
({ editor, ...buttonProps }, ref) => {
|
|
35
|
+
const [isOpen, setIsOpen] = (0, import_react.useState)(false);
|
|
36
|
+
const {
|
|
37
|
+
url,
|
|
38
|
+
setUrl,
|
|
39
|
+
alt,
|
|
40
|
+
setAlt,
|
|
41
|
+
isActive,
|
|
42
|
+
canSet,
|
|
43
|
+
setImage,
|
|
44
|
+
removeImage,
|
|
45
|
+
wasSelectionMove
|
|
46
|
+
} = (0, import_use_image_popover.useImagePopover)({ editor });
|
|
47
|
+
(0, import_react.useEffect)(() => {
|
|
48
|
+
if (isActive && wasSelectionMove) {
|
|
49
|
+
setIsOpen(true);
|
|
50
|
+
}
|
|
51
|
+
}, [isActive, wasSelectionMove]);
|
|
52
|
+
const handleSetImage = (0, import_react.useCallback)(() => {
|
|
53
|
+
setImage();
|
|
54
|
+
setIsOpen(false);
|
|
55
|
+
}, [setImage]);
|
|
56
|
+
const handleRemoveImage = (0, import_react.useCallback)(() => {
|
|
57
|
+
removeImage();
|
|
58
|
+
setIsOpen(false);
|
|
59
|
+
}, [removeImage]);
|
|
60
|
+
const handleKeyDown = (0, import_react.useCallback)(
|
|
61
|
+
(event) => {
|
|
62
|
+
if (event.key === "Enter") {
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
handleSetImage();
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
[handleSetImage]
|
|
68
|
+
);
|
|
69
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_popover.Popover, { open: isOpen, onOpenChange: setIsOpen, children: [
|
|
70
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popover.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
71
|
+
import_button.Button,
|
|
72
|
+
{
|
|
73
|
+
ref,
|
|
74
|
+
"aria-label": "Image",
|
|
75
|
+
"aria-pressed": isActive,
|
|
76
|
+
"data-active-state": isActive ? "on" : "off",
|
|
77
|
+
disabled: !canSet,
|
|
78
|
+
size: "icon",
|
|
79
|
+
tabIndex: -1,
|
|
80
|
+
type: "button",
|
|
81
|
+
variant: "ghost",
|
|
82
|
+
...buttonProps,
|
|
83
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
84
|
+
import_lucide_react.ImageIcon,
|
|
85
|
+
{
|
|
86
|
+
className: isActive ? "nt:text-[var(--tt-brand-color-500)]" : void 0
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
) }),
|
|
91
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
92
|
+
import_popover.PopoverContent,
|
|
93
|
+
{
|
|
94
|
+
align: "start",
|
|
95
|
+
className: "nt:flex nt:w-72 nt:flex-col nt:gap-1 nt:p-1",
|
|
96
|
+
children: [
|
|
97
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
98
|
+
import_input.Input,
|
|
99
|
+
{
|
|
100
|
+
autoFocus: true,
|
|
101
|
+
className: "nt:h-7 nt:border-none nt:shadow-none nt:focus-visible:ring-0",
|
|
102
|
+
placeholder: "Paste image URL...",
|
|
103
|
+
type: "url",
|
|
104
|
+
value: url,
|
|
105
|
+
onChange: (e) => setUrl(e.target.value),
|
|
106
|
+
onKeyDown: handleKeyDown
|
|
107
|
+
}
|
|
108
|
+
),
|
|
109
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
110
|
+
import_input.Input,
|
|
111
|
+
{
|
|
112
|
+
className: "nt:h-7 nt:border-none nt:shadow-none nt:focus-visible:ring-0",
|
|
113
|
+
placeholder: "Alt text (optional)",
|
|
114
|
+
type: "text",
|
|
115
|
+
value: alt,
|
|
116
|
+
onChange: (e) => setAlt(e.target.value),
|
|
117
|
+
onKeyDown: handleKeyDown
|
|
118
|
+
}
|
|
119
|
+
),
|
|
120
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "nt:flex nt:items-center nt:justify-end nt:gap-1", children: [
|
|
121
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
122
|
+
import_button.Button,
|
|
123
|
+
{
|
|
124
|
+
"aria-label": "Apply image",
|
|
125
|
+
disabled: !url && !isActive,
|
|
126
|
+
size: "icon-sm",
|
|
127
|
+
tabIndex: -1,
|
|
128
|
+
type: "button",
|
|
129
|
+
variant: "ghost",
|
|
130
|
+
onClick: handleSetImage,
|
|
131
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.CornerDownLeft, {})
|
|
132
|
+
}
|
|
133
|
+
),
|
|
134
|
+
isActive && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
135
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_separator.Separator, { className: "nt:h-5", orientation: "vertical" }),
|
|
136
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
137
|
+
import_button.Button,
|
|
138
|
+
{
|
|
139
|
+
"aria-label": "Remove image",
|
|
140
|
+
size: "icon-sm",
|
|
141
|
+
tabIndex: -1,
|
|
142
|
+
type: "button",
|
|
143
|
+
variant: "ghost",
|
|
144
|
+
onClick: handleRemoveImage,
|
|
145
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Trash2, {})
|
|
146
|
+
}
|
|
147
|
+
)
|
|
148
|
+
] })
|
|
149
|
+
] })
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
)
|
|
153
|
+
] });
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
ImagePopover.displayName = "ImagePopover";
|
|
157
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
158
|
+
0 && (module.exports = {
|
|
159
|
+
ImagePopover
|
|
160
|
+
});
|
|
161
|
+
//# sourceMappingURL=image-popover.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/image-popover/image-popover.tsx"],"sourcesContent":["'use client';\n\nimport { CornerDownLeft, ImageIcon, Trash2 } from 'lucide-react';\nimport { forwardRef, useCallback, useEffect, useState } from 'react';\n\nimport { useImagePopover } from './use-image-popover';\nimport { Button } from '../ui/button';\nimport { Input } from '../ui/input';\nimport { Popover, PopoverContent, PopoverTrigger } from '../ui/popover';\nimport { Separator } from '../ui/separator';\n\nimport type { Editor } from '@tiptap/core';\n\nexport interface ImagePopoverProps extends Omit<\n\tReact.ButtonHTMLAttributes<HTMLButtonElement>,\n\t'type'\n> {\n\teditor: Editor | null;\n}\n\nexport const ImagePopover = forwardRef<HTMLButtonElement, ImagePopoverProps>(\n\t({ editor, ...buttonProps }, ref) => {\n\t\tconst [isOpen, setIsOpen] = useState(false);\n\n\t\tconst {\n\t\t\turl,\n\t\t\tsetUrl,\n\t\t\talt,\n\t\t\tsetAlt,\n\t\t\tisActive,\n\t\t\tcanSet,\n\t\t\tsetImage,\n\t\t\tremoveImage,\n\t\t\twasSelectionMove\n\t\t} = useImagePopover({ editor });\n\n\t\t// Auto-open popover when cursor moves onto an existing image (selection-only transaction)\n\t\tuseEffect(() => {\n\t\t\tif (isActive && wasSelectionMove) {\n\t\t\t\tsetIsOpen(true);\n\t\t\t}\n\t\t}, [isActive, wasSelectionMove]);\n\n\t\tconst handleSetImage = useCallback(() => {\n\t\t\tsetImage();\n\t\t\tsetIsOpen(false);\n\t\t}, [setImage]);\n\n\t\tconst handleRemoveImage = useCallback(() => {\n\t\t\tremoveImage();\n\t\t\tsetIsOpen(false);\n\t\t}, [removeImage]);\n\n\t\tconst handleKeyDown = useCallback(\n\t\t\t(event: React.KeyboardEvent<HTMLInputElement>) => {\n\t\t\t\tif (event.key === 'Enter') {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\thandleSetImage();\n\t\t\t\t}\n\t\t\t},\n\t\t\t[handleSetImage]\n\t\t);\n\n\t\treturn (\n\t\t\t<Popover open={isOpen} onOpenChange={setIsOpen}>\n\t\t\t\t<PopoverTrigger asChild>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tref={ref}\n\t\t\t\t\t\taria-label=\"Image\"\n\t\t\t\t\t\taria-pressed={isActive}\n\t\t\t\t\t\tdata-active-state={isActive ? 'on' : 'off'}\n\t\t\t\t\t\tdisabled={!canSet}\n\t\t\t\t\t\tsize=\"icon\"\n\t\t\t\t\t\ttabIndex={-1}\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tvariant=\"ghost\"\n\t\t\t\t\t\t{...buttonProps}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ImageIcon\n\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\tisActive ? 'nt:text-[var(--tt-brand-color-500)]' : undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Button>\n\t\t\t\t</PopoverTrigger>\n\t\t\t\t<PopoverContent\n\t\t\t\t\talign=\"start\"\n\t\t\t\t\tclassName=\"nt:flex nt:w-72 nt:flex-col nt:gap-1 nt:p-1\"\n\t\t\t\t>\n\t\t\t\t\t<Input\n\t\t\t\t\t\tautoFocus\n\t\t\t\t\t\tclassName=\"nt:h-7 nt:border-none nt:shadow-none nt:focus-visible:ring-0\"\n\t\t\t\t\t\tplaceholder=\"Paste image URL...\"\n\t\t\t\t\t\ttype=\"url\"\n\t\t\t\t\t\tvalue={url}\n\t\t\t\t\t\tonChange={(e) => setUrl(e.target.value)}\n\t\t\t\t\t\tonKeyDown={handleKeyDown}\n\t\t\t\t\t/>\n\t\t\t\t\t<Input\n\t\t\t\t\t\tclassName=\"nt:h-7 nt:border-none nt:shadow-none nt:focus-visible:ring-0\"\n\t\t\t\t\t\tplaceholder=\"Alt text (optional)\"\n\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\tvalue={alt}\n\t\t\t\t\t\tonChange={(e) => setAlt(e.target.value)}\n\t\t\t\t\t\tonKeyDown={handleKeyDown}\n\t\t\t\t\t/>\n\t\t\t\t\t<div className=\"nt:flex nt:items-center nt:justify-end nt:gap-1\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\taria-label=\"Apply image\"\n\t\t\t\t\t\t\tdisabled={!url && !isActive}\n\t\t\t\t\t\t\tsize=\"icon-sm\"\n\t\t\t\t\t\t\ttabIndex={-1}\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\tvariant=\"ghost\"\n\t\t\t\t\t\t\tonClick={handleSetImage}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<CornerDownLeft />\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t{isActive && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<Separator className=\"nt:h-5\" orientation=\"vertical\" />\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\taria-label=\"Remove image\"\n\t\t\t\t\t\t\t\t\tsize=\"icon-sm\"\n\t\t\t\t\t\t\t\t\ttabIndex={-1}\n\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\tvariant=\"ghost\"\n\t\t\t\t\t\t\t\t\tonClick={handleRemoveImage}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<Trash2 />\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</div>\n\t\t\t\t</PopoverContent>\n\t\t\t</Popover>\n\t\t);\n\t}\n);\n\nImagePopover.displayName = 'ImagePopover';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA8EM;AA5EN,0BAAkD;AAClD,mBAA6D;AAE7D,+BAAgC;AAChC,oBAAuB;AACvB,mBAAsB;AACtB,qBAAwD;AACxD,uBAA0B;AAWnB,MAAM,mBAAe;AAAA,EAC3B,CAAC,EAAE,QAAQ,GAAG,YAAY,GAAG,QAAQ;AACpC,UAAM,CAAC,QAAQ,SAAS,QAAI,uBAAS,KAAK;AAE1C,UAAM;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA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ACZ;AAAA,YACA;AAAA,cAAC;AAAA;AAAA,gBACA,WAAU;AAAA,gBACV,aAAY;AAAA,gBACZ,MAAK;AAAA,gBACL,OAAO;AAAA,gBACP,UAAU,CAAC,MAAM,OAAO,EAAE,OAAO,KAAK;AAAA,gBACtC,WAAW;AAAA;AAAA,YACZ;AAAA,YACA,6CAAC,SAAI,WAAU,mDACd;AAAA;AAAA,gBAAC;AAAA;AAAA,kBACA,cAAW;AAAA,kBACX,UAAU,CAAC,OAAO,CAAC;AAAA,kBACnB,MAAK;AAAA,kBACL,UAAU;AAAA,kBACV,MAAK;AAAA,kBACL,SAAQ;AAAA,kBACR,SAAS;AAAA,kBAET,sDAAC,sCAAe;AAAA;AAAA,cACjB;AAAA,cACC,YACA,4EACC;AAAA,4DAAC,8BAAU,WAAU,UAAS,aAAY,YAAW;AAAA,gBACrD;AAAA,kBAAC;AAAA;AAAA,oBACA,cAAW;AAAA,oBACX,MAAK;AAAA,oBACL,UAAU;AAAA,oBACV,MAAK;AAAA,oBACL,SAAQ;AAAA,oBACR,SAAS;AAAA,oBAET,sDAAC,8BAAO;AAAA;AAAA,gBACT;AAAA,iBACD;AAAA,eAEF;AAAA;AAAA;AAAA,MACD;AAAA,OACD;AAAA,EAEF;AACD;AAEA,aAAa,cAAc;","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { Editor } from '@tiptap/core';
|
|
3
|
+
|
|
4
|
+
interface ImagePopoverProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {
|
|
5
|
+
editor: Editor | null;
|
|
6
|
+
}
|
|
7
|
+
declare const ImagePopover: react.ForwardRefExoticComponent<ImagePopoverProps & react.RefAttributes<HTMLButtonElement>>;
|
|
8
|
+
|
|
9
|
+
export { ImagePopover, type ImagePopoverProps };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { Editor } from '@tiptap/core';
|
|
3
|
+
|
|
4
|
+
interface ImagePopoverProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {
|
|
5
|
+
editor: Editor | null;
|
|
6
|
+
}
|
|
7
|
+
declare const ImagePopover: react.ForwardRefExoticComponent<ImagePopoverProps & react.RefAttributes<HTMLButtonElement>>;
|
|
8
|
+
|
|
9
|
+
export { ImagePopover, type ImagePopoverProps };
|