payload-richtext-tiptap 0.0.56 → 0.0.58
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/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.js +10 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/extension-kit.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/extension-kit.js +1 -2
- package/dist/src/fields/TiptapEditor/extensions/extension-kit.js.map +1 -1
- package/dist/src/fields/TiptapEditor/features/BlockEditor/BlockEditor.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/features/BlockEditor/BlockEditor.js +1 -17
- package/dist/src/fields/TiptapEditor/features/BlockEditor/BlockEditor.js.map +1 -1
- package/dist/src/fields/TiptapEditor/features/BlockEditor/components/EditorInfo.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/features/BlockEditor/components/EditorInfo.js.map +1 -1
- package/dist/src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.js +0 -1
- package/dist/src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.js.map +1 -1
- package/dist/src/fields/TiptapEditor/features/ui/Button/SpanButton.d.ts +16 -0
- package/dist/src/fields/TiptapEditor/features/ui/Button/SpanButton.d.ts.map +1 -0
- package/dist/src/fields/TiptapEditor/features/ui/Button/SpanButton.js +16 -0
- package/dist/src/fields/TiptapEditor/features/ui/Button/SpanButton.js.map +1 -0
- package/dist/src/fields/TiptapEditor/features/ui/Button/index.d.ts +1 -0
- package/dist/src/fields/TiptapEditor/features/ui/Button/index.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/features/ui/Button/index.js +1 -0
- package/dist/src/fields/TiptapEditor/features/ui/Button/index.js.map +1 -1
- package/dist/src/fields/TiptapEditor/features/ui/Dropdown/Dropdown.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/features/ui/Dropdown/Dropdown.js +3 -4
- package/dist/src/fields/TiptapEditor/features/ui/Dropdown/Dropdown.js.map +1 -1
- package/dist/src/fields/TiptapEditor/features/ui/Toolbar.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/features/ui/Toolbar.js +2 -3
- package/dist/src/fields/TiptapEditor/features/ui/Toolbar.js.map +1 -1
- package/dist/src/fields/TiptapEditor/hooks/useBlockEditor.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/hooks/useBlockEditor.js +1 -0
- package/dist/src/fields/TiptapEditor/hooks/useBlockEditor.js.map +1 -1
- package/dist/src/styles.css +5 -69
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +66 -66
package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VideoBlockView.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAmB,MAAM,eAAe,CAAC;AACxD,OAAO,KAAkD,MAAM,OAAO,CAAC;AAIvE,UAAU,mBAAmB;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,MAAM,CAAC;IACrB,IAAI,EAAE,IAAI,GAAG;QACX,KAAK,EAAE;YACL,GAAG,EAAE,MAAM,CAAC;YACZ,MAAM,EAAE,MAAM,CAAC;YACf,OAAO,EAAE,MAAM,CAAC;YAChB,WAAW,CAAC,EAAE,MAAM,CAAC;SACtB,CAAC;KACH,CAAC;IACF,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;CAC3D;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,IAAI,EAAE,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,cAAc,UAAW,mBAAmB,
|
|
1
|
+
{"version":3,"file":"VideoBlockView.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAmB,MAAM,eAAe,CAAC;AACxD,OAAO,KAAkD,MAAM,OAAO,CAAC;AAIvE,UAAU,mBAAmB;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,MAAM,CAAC;IACrB,IAAI,EAAE,IAAI,GAAG;QACX,KAAK,EAAE;YACL,GAAG,EAAE,MAAM,CAAC;YACZ,MAAM,EAAE,MAAM,CAAC;YACf,OAAO,EAAE,MAAM,CAAC;YAChB,WAAW,CAAC,EAAE,MAAM,CAAC;SACtB,CAAC;KACH,CAAC;IACF,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;CAC3D;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,IAAI,EAAE,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,cAAc,UAAW,mBAAmB,sBAmGxD,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -39,6 +39,16 @@ export const VideoBlockView = (props)=>{
|
|
|
39
39
|
]);
|
|
40
40
|
const videoJsOptions = useMemo(()=>{
|
|
41
41
|
if (playlistContent == undefined) return {};
|
|
42
|
+
if (playlistContent.items.some((item)=>item.type === "application/x-mpegURL" || item.type === "application/vnd.apple.mpegurl")) {
|
|
43
|
+
return {
|
|
44
|
+
sources: playlistContent.items.filter((item)=>item.type === "application/x-mpegURL" || item.type === "application/vnd.apple.mpegurl").map((item)=>({
|
|
45
|
+
src: item.src,
|
|
46
|
+
type: item.type,
|
|
47
|
+
label: item.label
|
|
48
|
+
})),
|
|
49
|
+
poster: playlistContent.poster
|
|
50
|
+
};
|
|
51
|
+
}
|
|
42
52
|
return {
|
|
43
53
|
sources: playlistContent.items.map((item)=>({
|
|
44
54
|
src: item.src,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.tsx"],"sourcesContent":["import { Node } from \"@tiptap/pm/model\";\nimport { Editor, NodeViewWrapper } from \"@tiptap/react\";\nimport React, { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { cn } from \"../../../lib/utils/index.js\";\nimport VideoPlayer from \"./videojs/VideoPlayer.js\";\n\ninterface VideoBlockViewProps {\n editor: Editor;\n getPos: () => number;\n node: Node & {\n attrs: {\n src: string;\n poster: string;\n assetId: string;\n playlistUrl?: string;\n };\n };\n updateAttributes: (attrs: Record<string, string>) => void;\n}\n\nexport type Playlist = {\n id: string;\n title: string;\n description: string;\n poster: string;\n items: Item[];\n};\n\nexport type Item = {\n src: string;\n type: string;\n label: string;\n width: number;\n height: number;\n};\n\nexport const VideoBlockView = (props: VideoBlockViewProps) => {\n const { editor, getPos, node } = props;\n const videoWrapperRef = useRef<HTMLDivElement>(null);\n const { src, poster, playlistUrl, caption } = node.attrs;\n const [playlistContent, setPlaylistContent] = React.useState<\n Playlist | undefined\n >();\n const [error, setError] = React.useState();\n\n useEffect(() => {\n async function getPlaylistContent() {\n const res = await fetch(playlistUrl, {\n cache: \"no-cache\",\n });\n return await res.json();\n }\n\n if (playlistUrl) {\n try {\n getPlaylistContent()\n .then((data) => {\n setPlaylistContent(data);\n })\n .catch((err) => {\n setError(err);\n });\n } catch (error) {\n setError(error);\n }\n }\n }, [playlistUrl]);\n\n const wrapperClassName = cn(\n node.attrs.align === \"left\" ? \"ml-0\" : \"ml-auto\",\n node.attrs.align === \"right\" ? \"mr-0\" : \"mr-auto\",\n node.attrs.align === \"center\" && \"mx-auto\"\n );\n\n const onClick = useCallback(() => {\n editor.commands.setNodeSelection(getPos());\n }, [getPos, editor.commands]);\n\n const videoJsOptions = useMemo(() => {\n if (playlistContent == undefined) return {};\n return {\n sources: playlistContent.items.map((item) => ({\n src: item.src,\n type: item.type,\n label: item.label,\n })),\n poster: playlistContent.poster,\n };\n }, [playlistContent]);\n return (\n <NodeViewWrapper>\n <div className={wrapperClassName} style={{ width: node.attrs.width }}>\n <div contentEditable={false} ref={videoWrapperRef}>\n {error && <div>{error}</div>}\n {/* <video\n controls\n className=\"block\"\n src={src}\n poster={poster}\n title=\"\"\n onClick={onClick}\n /> */}\n {playlistContent && <VideoPlayer options={videoJsOptions} />}\n {caption && playlistContent?.title && (\n <caption className=\"text-center block text-sm text-gray-500\">\n {playlistContent?.title}\n </caption>\n )}\n </div>\n </div>\n </NodeViewWrapper>\n );\n};\n\nexport default VideoBlockView;\n"],"names":["NodeViewWrapper","React","useCallback","useEffect","useMemo","useRef","cn","VideoPlayer","VideoBlockView","props","editor","getPos","node","videoWrapperRef","src","poster","playlistUrl","caption","attrs","playlistContent","setPlaylistContent","useState","error","setError","getPlaylistContent","res","fetch","cache","json","then","data","catch","err","wrapperClassName","align","onClick","commands","setNodeSelection","videoJsOptions","undefined","
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.tsx"],"sourcesContent":["import { Node } from \"@tiptap/pm/model\";\nimport { Editor, NodeViewWrapper } from \"@tiptap/react\";\nimport React, { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { cn } from \"../../../lib/utils/index.js\";\nimport VideoPlayer from \"./videojs/VideoPlayer.js\";\n\ninterface VideoBlockViewProps {\n editor: Editor;\n getPos: () => number;\n node: Node & {\n attrs: {\n src: string;\n poster: string;\n assetId: string;\n playlistUrl?: string;\n };\n };\n updateAttributes: (attrs: Record<string, string>) => void;\n}\n\nexport type Playlist = {\n id: string;\n title: string;\n description: string;\n poster: string;\n items: Item[];\n};\n\nexport type Item = {\n src: string;\n type: string;\n label: string;\n width: number;\n height: number;\n};\n\nexport const VideoBlockView = (props: VideoBlockViewProps) => {\n const { editor, getPos, node } = props;\n const videoWrapperRef = useRef<HTMLDivElement>(null);\n const { src, poster, playlistUrl, caption } = node.attrs;\n const [playlistContent, setPlaylistContent] = React.useState<\n Playlist | undefined\n >();\n const [error, setError] = React.useState();\n\n useEffect(() => {\n async function getPlaylistContent() {\n const res = await fetch(playlistUrl, {\n cache: \"no-cache\",\n });\n return await res.json();\n }\n\n if (playlistUrl) {\n try {\n getPlaylistContent()\n .then((data) => {\n setPlaylistContent(data);\n })\n .catch((err) => {\n setError(err);\n });\n } catch (error) {\n setError(error);\n }\n }\n }, [playlistUrl]);\n\n const wrapperClassName = cn(\n node.attrs.align === \"left\" ? \"ml-0\" : \"ml-auto\",\n node.attrs.align === \"right\" ? \"mr-0\" : \"mr-auto\",\n node.attrs.align === \"center\" && \"mx-auto\"\n );\n\n const onClick = useCallback(() => {\n editor.commands.setNodeSelection(getPos());\n }, [getPos, editor.commands]);\n\n const videoJsOptions = useMemo(() => {\n if (playlistContent == undefined) return {};\n\n if (\n playlistContent.items.some(\n (item) =>\n item.type === \"application/x-mpegURL\" ||\n item.type === \"application/vnd.apple.mpegurl\"\n )\n ) {\n return {\n sources: playlistContent.items\n .filter(\n (item) =>\n item.type === \"application/x-mpegURL\" ||\n item.type === \"application/vnd.apple.mpegurl\"\n )\n .map((item) => ({\n src: item.src,\n type: item.type,\n label: item.label,\n })),\n poster: playlistContent.poster,\n };\n }\n return {\n sources: playlistContent.items.map((item) => ({\n src: item.src,\n type: item.type,\n label: item.label,\n })),\n poster: playlistContent.poster,\n };\n }, [playlistContent]);\n return (\n <NodeViewWrapper>\n <div className={wrapperClassName} style={{ width: node.attrs.width }}>\n <div contentEditable={false} ref={videoWrapperRef}>\n {error && <div>{error}</div>}\n {/* <video\n controls\n className=\"block\"\n src={src}\n poster={poster}\n title=\"\"\n onClick={onClick}\n /> */}\n {playlistContent && <VideoPlayer options={videoJsOptions} />}\n {caption && playlistContent?.title && (\n <caption className=\"text-center block text-sm text-gray-500\">\n {playlistContent?.title}\n </caption>\n )}\n </div>\n </div>\n </NodeViewWrapper>\n );\n};\n\nexport default VideoBlockView;\n"],"names":["NodeViewWrapper","React","useCallback","useEffect","useMemo","useRef","cn","VideoPlayer","VideoBlockView","props","editor","getPos","node","videoWrapperRef","src","poster","playlistUrl","caption","attrs","playlistContent","setPlaylistContent","useState","error","setError","getPlaylistContent","res","fetch","cache","json","then","data","catch","err","wrapperClassName","align","onClick","commands","setNodeSelection","videoJsOptions","undefined","items","some","item","type","sources","filter","map","label","div","className","style","width","contentEditable","ref","options","title"],"mappings":";AACA,SAAiBA,eAAe,QAAQ,gBAAgB;AACxD,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,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,kCAElB;YACA,OAAO;gBACLC,SAASzB,gBAAgBqB,KAAK,CAC3BK,MAAM,CACL,CAACH,OACCA,KAAKC,IAAI,KAAK,2BACdD,KAAKC,IAAI,KAAK,iCAEjBG,GAAG,CAAC,CAACJ,OAAU,CAAA;wBACd5B,KAAK4B,KAAK5B,GAAG;wBACb6B,MAAMD,KAAKC,IAAI;wBACfI,OAAOL,KAAKK,KAAK;oBACnB,CAAA;gBACFhC,QAAQI,gBAAgBJ,MAAM;YAChC;QACF;QACA,OAAO;YACL6B,SAASzB,gBAAgBqB,KAAK,CAACM,GAAG,CAAC,CAACJ,OAAU,CAAA;oBAC5C5B,KAAK4B,KAAK5B,GAAG;oBACb6B,MAAMD,KAAKC,IAAI;oBACfI,OAAOL,KAAKK,KAAK;gBACnB,CAAA;YACAhC,QAAQI,gBAAgBJ,MAAM;QAChC;IACF,GAAG;QAACI;KAAgB;IACpB,qBACE,KAACnB;kBACC,cAAA,KAACgD;YAAIC,WAAWhB;YAAkBiB,OAAO;gBAAEC,OAAOvC,KAAKM,KAAK,CAACiC,KAAK;YAAC;sBACjE,cAAA,MAACH;gBAAII,iBAAiB;gBAAOC,KAAKxC;;oBAC/BS,uBAAS,KAAC0B;kCAAK1B;;oBASfH,iCAAmB,KAACZ;wBAAY+C,SAAShB;;oBACzCrB,WAAWE,iBAAiBoC,uBAC3B,KAACtC;wBAAQgC,WAAU;kCAChB9B,iBAAiBoC;;;;;;AAOhC,EAAE;AAEF,eAAe/C,eAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension-kit.d.ts","sourceRoot":"","sources":["../../../../../src/fields/TiptapEditor/extensions/extension-kit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"extension-kit.d.ts","sourceRoot":"","sources":["../../../../../src/fields/TiptapEditor/extensions/extension-kit.ts"],"names":[],"mappings":"AAyDA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAI9C,UAAU,iBAAiB;IACzB,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IACpB,kBAAkB,EAAE,eAAe,CAAC;CACrC;AAED,eAAO,MAAM,YAAY,iCAGtB,iBAAiB,+LAuHnB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AICommand, BlockquoteFigure, CharacterCount, Color, Column, // emojiSuggestion,
|
|
2
|
-
Columns, Document, Dropcursor, Facebook, Figcaption, FileHandler, Focus, FontFamily, FontSize, Heading, Highlight, HorizontalRule, VideoBlock, ImageBlock, AudioBlock, InsideLinks, Instagram, Link, Linkedin, Placeholder,
|
|
2
|
+
Columns, Document, Dropcursor, Facebook, Figcaption, FileHandler, Focus, FontFamily, FontSize, Heading, Highlight, HorizontalRule, VideoBlock, ImageBlock, AudioBlock, InsideLinks, Instagram, Link, Linkedin, Placeholder, Selection, SlashCommand, StarterKit, Subscript, Superscript, Table, TableCell, TableHeader, TableOfContents, TableRow, TaskItem, TaskList, TextAlign, TextStyle, Tiktok, TrailingNode, Twitter, Typography, Underline, Youtube } from "./index.js";
|
|
3
3
|
import { CodeBlockLowlight } from "@tiptap/extension-code-block-lowlight";
|
|
4
4
|
import lowlight from "lowlight";
|
|
5
5
|
import TextDirection from "tiptap-text-direction";
|
|
@@ -136,7 +136,6 @@ export const ExtensionKit = ({ dir, openAssetHQHandler })=>[
|
|
|
136
136
|
Facebook,
|
|
137
137
|
Linkedin,
|
|
138
138
|
Youtube,
|
|
139
|
-
Paragraph,
|
|
140
139
|
InsideLinks,
|
|
141
140
|
TextDirection.configure({
|
|
142
141
|
types: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/fields/TiptapEditor/extensions/extension-kit.ts"],"sourcesContent":["import {\n AICommand,\n BlockquoteFigure,\n CharacterCount,\n Color,\n Column,\n // emojiSuggestion,\n Columns,\n Document,\n Dropcursor,\n Facebook,\n Figcaption,\n FileHandler,\n Focus,\n FontFamily,\n FontSize,\n Heading,\n Highlight,\n HorizontalRule,\n VideoBlock,\n ImageBlock,\n AudioBlock,\n InsideLinks,\n Instagram,\n Link,\n Linkedin,\n Placeholder,\n
|
|
1
|
+
{"version":3,"sources":["../../../../../src/fields/TiptapEditor/extensions/extension-kit.ts"],"sourcesContent":["import {\n AICommand,\n BlockquoteFigure,\n CharacterCount,\n Color,\n Column,\n // emojiSuggestion,\n Columns,\n Document,\n Dropcursor,\n Facebook,\n Figcaption,\n FileHandler,\n Focus,\n FontFamily,\n FontSize,\n Heading,\n Highlight,\n HorizontalRule,\n VideoBlock,\n ImageBlock,\n AudioBlock,\n InsideLinks,\n Instagram,\n Link,\n Linkedin,\n Placeholder,\n Selection,\n SlashCommand,\n StarterKit,\n Subscript,\n Superscript,\n Table,\n TableCell,\n TableHeader,\n TableOfContents,\n TableRow,\n TaskItem,\n TaskList,\n TextAlign,\n TextStyle,\n Tiktok,\n TrailingNode,\n Twitter,\n Typography,\n Underline,\n Youtube,\n} from \"./index.js\";\n\nimport { CodeBlockLowlight } from \"@tiptap/extension-code-block-lowlight\";\nimport lowlight from \"lowlight\";\nimport TextDirection from \"tiptap-text-direction\";\nimport { ImageUpload } from \"./ImageUpload/ImageUpload.js\";\nimport { TableOfContentsNode } from \"./TableOfContentsNode/TableOfContentsNode.js\";\n\nimport History from \"@tiptap/extension-history\";\nimport API from \"../lib/api.js\";\nimport { openAssetHQType } from \"../types.js\";\nimport { Iframe } from \"./Iframe/iframe.js\";\nimport { Markdown } from \"tiptap-markdown\";\n\ninterface ExtensionKitProps {\n dir?: \"rtl\" | \"ltr\";\n openAssetHQHandler: openAssetHQType;\n}\n\nexport const ExtensionKit = ({\n dir,\n openAssetHQHandler,\n}: ExtensionKitProps) => [\n Markdown,\n Document,\n Columns,\n TaskList,\n TaskItem.configure({\n nested: true,\n }),\n Column,\n Selection,\n Heading.configure({\n levels: [1, 2, 3, 4, 5, 6],\n }),\n HorizontalRule,\n StarterKit.configure({\n document: false,\n dropcursor: false,\n heading: false,\n horizontalRule: false,\n blockquote: false,\n history: false,\n codeBlock: false,\n }),\n CodeBlockLowlight.configure({\n lowlight,\n defaultLanguage: null,\n }),\n TextStyle,\n FontSize,\n FontFamily,\n Color,\n TrailingNode,\n Link.configure({\n openOnClick: false,\n }),\n Highlight.configure({ multicolor: true }),\n Underline,\n CharacterCount.configure({ limit: 50000 }),\n TableOfContents,\n TableOfContentsNode,\n ImageUpload.configure({\n openAssetHQHandler,\n }),\n ImageBlock,\n VideoBlock,\n AudioBlock,\n FileHandler.configure({\n allowedMimeTypes: [\"image/png\", \"image/jpeg\", \"image/gif\", \"image/webp\"],\n onDrop: (currentEditor, files, pos) => {\n const file = files[0];\n (async () => {\n openAssetHQHandler((asset) => {\n currentEditor\n .chain()\n .setImageBlockAt({ pos, src: asset.fullUrl })\n .focus()\n .run();\n }, file);\n })();\n },\n onPaste: (currentEditor, files) => {\n files.forEach(async () => {\n const url = await API.uploadImage();\n\n return currentEditor\n .chain()\n .setImageBlockAt({\n pos: currentEditor.state.selection.anchor,\n src: url,\n })\n .focus()\n .run();\n });\n },\n }),\n // Emoji.configure({\n // enableEmoticons: true,\n // suggestion: emojiSuggestion,\n // }),\n TextAlign.extend({\n addKeyboardShortcuts() {\n return {};\n },\n }).configure({\n types: [\"heading\", \"paragraph\"],\n }),\n Subscript,\n Superscript,\n Table,\n TableCell,\n TableHeader,\n TableRow,\n Typography,\n Placeholder.configure({\n includeChildren: true,\n showOnlyCurrent: false,\n placeholder: () => \"\",\n }),\n SlashCommand,\n Focus,\n Figcaption,\n BlockquoteFigure,\n Dropcursor.configure({\n width: 2,\n class: \"ProseMirror-dropcursor border-black\",\n }),\n History,\n Iframe,\n Twitter,\n Tiktok,\n Instagram,\n Facebook,\n Linkedin,\n Youtube,\n InsideLinks,\n TextDirection.configure({\n types: [\"heading\", \"paragraph\"],\n }),\n AICommand,\n];\n\nexport default ExtensionKit;\n"],"names":["AICommand","BlockquoteFigure","CharacterCount","Color","Column","Columns","Document","Dropcursor","Facebook","Figcaption","FileHandler","Focus","FontFamily","FontSize","Heading","Highlight","HorizontalRule","VideoBlock","ImageBlock","AudioBlock","InsideLinks","Instagram","Link","Linkedin","Placeholder","Selection","SlashCommand","StarterKit","Subscript","Superscript","Table","TableCell","TableHeader","TableOfContents","TableRow","TaskItem","TaskList","TextAlign","TextStyle","Tiktok","TrailingNode","Twitter","Typography","Underline","Youtube","CodeBlockLowlight","lowlight","TextDirection","ImageUpload","TableOfContentsNode","History","API","Iframe","Markdown","ExtensionKit","dir","openAssetHQHandler","configure","nested","levels","document","dropcursor","heading","horizontalRule","blockquote","history","codeBlock","defaultLanguage","openOnClick","multicolor","limit","allowedMimeTypes","onDrop","currentEditor","files","pos","file","asset","chain","setImageBlockAt","src","fullUrl","focus","run","onPaste","forEach","url","uploadImage","state","selection","anchor","extend","addKeyboardShortcuts","types","includeChildren","showOnlyCurrent","placeholder","width","class"],"mappings":"AAAA,SACEA,SAAS,EACTC,gBAAgB,EAChBC,cAAc,EACdC,KAAK,EACLC,MAAM,EAENC,AADA,mBAAmB;AACnBA,OAAO,EACPC,QAAQ,EACRC,UAAU,EACVC,QAAQ,EACRC,UAAU,EACVC,WAAW,EACXC,KAAK,EACLC,UAAU,EACVC,QAAQ,EACRC,OAAO,EACPC,SAAS,EACTC,cAAc,EACdC,UAAU,EACVC,UAAU,EACVC,UAAU,EACVC,WAAW,EACXC,SAAS,EACTC,IAAI,EACJC,QAAQ,EACRC,WAAW,EACXC,SAAS,EACTC,YAAY,EACZC,UAAU,EACVC,SAAS,EACTC,WAAW,EACXC,KAAK,EACLC,SAAS,EACTC,WAAW,EACXC,eAAe,EACfC,QAAQ,EACRC,QAAQ,EACRC,QAAQ,EACRC,SAAS,EACTC,SAAS,EACTC,MAAM,EACNC,YAAY,EACZC,OAAO,EACPC,UAAU,EACVC,SAAS,EACTC,OAAO,QACF,aAAa;AAEpB,SAASC,iBAAiB,QAAQ,wCAAwC;AAC1E,OAAOC,cAAc,WA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,GAAGP;gBACL,CAAA;YACF;YACAQ,SAAS,CAACX,eAAeC;gBACvBA,MAAMW,OAAO,CAAC;oBACZ,MAAMC,MAAM,MAAMnC,IAAIoC,WAAW;oBAEjC,OAAOd,cACJK,KAAK,GACLC,eAAe,CAAC;wBACfJ,KAAKF,cAAce,KAAK,CAACC,SAAS,CAACC,MAAM;wBACzCV,KAAKM;oBACP,GACCJ,KAAK,GACLC,GAAG;gBACR;YACF;QACF;QACA,oBAAoB;QACpB,2BAA2B;QAC3B,iCAAiC;QACjC,MAAM;QACN9C,UAAUsD,MAAM,CAAC;YACfC;gBACE,OAAO,CAAC;YACV;QACF,GAAGnC,SAAS,CAAC;YACXoC,OAAO;gBAAC;gBAAW;aAAY;QACjC;QACAjE;QACAC;QACAC;QACAC;QACAC;QACAE;QACAQ;QACAlB,YAAYiC,SAAS,CAAC;YACpBqC,iBAAiB;YACjBC,iBAAiB;YACjBC,aAAa,IAAM;QACrB;QACAtE;QACAf;QACAF;QACAR;QACAM,WAAWkD,SAAS,CAAC;YACnBwC,OAAO;YACPC,OAAO;QACT;QACAhD;QACAE;QACAX;QACAF;QACAlB;QACAb;QACAe;QACAqB;QACAxB;QACA2B,cAAcU,SAAS,CAAC;YACtBoC,OAAO;gBAAC;gBAAW;aAAY;QACjC;QACA7F;KACD,CAAC;AAEF,eAAesD,aAAa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlockEditor.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/features/BlockEditor/BlockEditor.tsx"],"names":[],"mappings":"AAkBA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAKjD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,eAAO,MAAM,WAAW,sEAKrB,WAAW,GAAG;IACf,kBAAkB,EAAE,eAAe,CAAC;IACpC,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACzC,
|
|
1
|
+
{"version":3,"file":"BlockEditor.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/features/BlockEditor/BlockEditor.tsx"],"names":[],"mappings":"AAkBA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAKjD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,eAAO,MAAM,WAAW,sEAKrB,WAAW,GAAG;IACf,kBAAkB,EAAE,eAAe,CAAC;IACpC,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACzC,gCA2EA,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -39,24 +39,8 @@ export const BlockEditor = ({ handleChange, content, openAssetHQHandler, additio
|
|
|
39
39
|
}, [
|
|
40
40
|
code
|
|
41
41
|
]);
|
|
42
|
-
if (!editor) {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
42
|
const { i18n } = useTranslation();
|
|
46
|
-
|
|
47
|
-
const contentEn = "للكتابة..."; // Content for English or default language
|
|
48
|
-
const contentAr = "انقر هنا للكتابة..."; // Content for Arabic language
|
|
49
|
-
const contentFa = "اینجا کلیک کنید تا شروع به نوشتن کنید...";
|
|
50
|
-
/*switch (i18n.language) {
|
|
51
|
-
case 'ar':
|
|
52
|
-
editor.commands.setContent(contentAr)
|
|
53
|
-
break
|
|
54
|
-
case 'fa':
|
|
55
|
-
editor.commands.setContent(contentFa)
|
|
56
|
-
break
|
|
57
|
-
default:
|
|
58
|
-
editor.commands.setContent(contentEn)
|
|
59
|
-
}*/ return /*#__PURE__*/ _jsx(EditorContext.Provider, {
|
|
43
|
+
return editor && /*#__PURE__*/ _jsx(EditorContext.Provider, {
|
|
60
44
|
value: providerValue,
|
|
61
45
|
children: /*#__PURE__*/ _jsxs("div", {
|
|
62
46
|
lang: i18n.language,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/features/BlockEditor/BlockEditor.tsx"],"sourcesContent":["\"use client\";\nimport { EditorContent } from \"@tiptap/react\";\nimport { useEffect, useMemo, useRef } from \"react\";\n\nimport { useLocale } from \"@payloadcms/ui/providers/Locale\";\nimport { useTranslation } from \"@payloadcms/ui/providers/Translation\";\nimport { EditorContext } from \"../../context/EditorContext.js\";\nimport { IframeMenu } from \"../../extensions/Iframe/menus/index.js\";\nimport ImageBlockMenu from \"../../extensions/ImageBlock/components/ImageBlockMenu.js\";\nimport VideoBlockMenu from \"../../extensions/VideoBlock/components/VideoBlockMenu.js\";\nimport { InsideLinksMenu } from \"../../extensions/InsideLinks/menus/index.js\";\nimport { ColumnsMenu } from \"../../extensions/MultiColumn/menus/ColumnsMenu.js\";\nimport { SocialMediaMenu } from \"../../extensions/SocialMedia/menus/index.js\";\nimport {\n TableColumnMenu,\n TableRowMenu,\n} from \"../../extensions/Table/menus/index.js\";\nimport { useBlockEditor } from \"../../hooks/useBlockEditor.js\";\nimport { openAssetHQType } from \"../../types.js\";\nimport { Sidebar } from \"../Sidebar/Sidebar.js\";\nimport { ContentItemMenu } from \"../menus/ContentItemMenu/ContentItemMenu.js\";\nimport { TextMenu } from \"../menus/TextMenu/TextMenu.js\";\nimport { LinkMenu } from \"../menus/index.js\";\nimport { TiptapProps } from \"./types.js\";\nexport const BlockEditor = ({\n handleChange,\n content,\n openAssetHQHandler,\n additionalContext,\n}: TiptapProps & {\n openAssetHQHandler: openAssetHQType;\n additionalContext?: Record<string, any>;\n}) => {\n const menuContainerRef = useRef(null);\n const editorRef = useRef<HTMLDivElement>(null);\n\n const { editor, users, characterCount, leftSidebar } = useBlockEditor({\n content: content,\n handleChange: handleChange,\n openAssetHQHandler: openAssetHQHandler,\n additionalContext: additionalContext,\n });\n\n const { code } = useLocale();\n\n const displayedUsers = users.slice(0, 3);\n\n const providerValue = useMemo(() => {\n return {};\n }, []);\n\n useEffect(() => {\n if (code === \"ar\" || code === \"fa\") {\n editor?.commands?.setTextDirection(\"rtl\");\n editor?.commands?.setContent(\"dwa\");\n }\n }, [code]);\n\n
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/features/BlockEditor/BlockEditor.tsx"],"sourcesContent":["\"use client\";\nimport { EditorContent } from \"@tiptap/react\";\nimport { useEffect, useMemo, useRef } from \"react\";\n\nimport { useLocale } from \"@payloadcms/ui/providers/Locale\";\nimport { useTranslation } from \"@payloadcms/ui/providers/Translation\";\nimport { EditorContext } from \"../../context/EditorContext.js\";\nimport { IframeMenu } from \"../../extensions/Iframe/menus/index.js\";\nimport ImageBlockMenu from \"../../extensions/ImageBlock/components/ImageBlockMenu.js\";\nimport VideoBlockMenu from \"../../extensions/VideoBlock/components/VideoBlockMenu.js\";\nimport { InsideLinksMenu } from \"../../extensions/InsideLinks/menus/index.js\";\nimport { ColumnsMenu } from \"../../extensions/MultiColumn/menus/ColumnsMenu.js\";\nimport { SocialMediaMenu } from \"../../extensions/SocialMedia/menus/index.js\";\nimport {\n TableColumnMenu,\n TableRowMenu,\n} from \"../../extensions/Table/menus/index.js\";\nimport { useBlockEditor } from \"../../hooks/useBlockEditor.js\";\nimport { openAssetHQType } from \"../../types.js\";\nimport { Sidebar } from \"../Sidebar/Sidebar.js\";\nimport { ContentItemMenu } from \"../menus/ContentItemMenu/ContentItemMenu.js\";\nimport { TextMenu } from \"../menus/TextMenu/TextMenu.js\";\nimport { LinkMenu } from \"../menus/index.js\";\nimport { TiptapProps } from \"./types.js\";\nexport const BlockEditor = ({\n handleChange,\n content,\n openAssetHQHandler,\n additionalContext,\n}: TiptapProps & {\n openAssetHQHandler: openAssetHQType;\n additionalContext?: Record<string, any>;\n}) => {\n const menuContainerRef = useRef(null);\n const editorRef = useRef<HTMLDivElement>(null);\n\n const { editor, users, characterCount, leftSidebar } = useBlockEditor({\n content: content,\n handleChange: handleChange,\n openAssetHQHandler: openAssetHQHandler,\n additionalContext: additionalContext,\n });\n\n const { code } = useLocale();\n\n const displayedUsers = users.slice(0, 3);\n\n const providerValue = useMemo(() => {\n return {};\n }, []);\n\n useEffect(() => {\n if (code === \"ar\" || code === \"fa\") {\n editor?.commands?.setTextDirection(\"rtl\");\n editor?.commands?.setContent(\"dwa\");\n }\n }, [code]);\n\n const { i18n } = useTranslation();\n\n return (\n editor && (\n <EditorContext.Provider value={providerValue}>\n <div\n lang={i18n.language}\n className=\"flex h-full overflow-visible\"\n ref={menuContainerRef}\n >\n <Sidebar\n isOpen={leftSidebar.isOpen}\n onClose={leftSidebar.close}\n editor={editor}\n />\n <div className=\"relative flex flex-col flex-1 h-full justify-center items-center \">\n {/* <EditorHeader\n characters={characterCount.characters()}\n users={displayedUsers}\n words={characterCount.words()}\n isSidebarOpen={leftSidebar.isOpen}\n toggleSidebar={leftSidebar.toggle}\n /> */}\n <EditorContent\n editor={editor}\n ref={editorRef}\n lang={i18n.language}\n className=\"flex-1 overflow-y-visible w-full h-full outline-none outline-offset-0\"\n style={{\n outline: \"none\",\n }}\n />\n <ContentItemMenu editor={editor} />\n <LinkMenu editor={editor} appendTo={menuContainerRef} />\n\n <TextMenu editor={editor} />\n <IframeMenu editor={editor} appendTo={menuContainerRef} />\n <SocialMediaMenu editor={editor} appendTo={menuContainerRef} />\n <InsideLinksMenu editor={editor} appendTo={menuContainerRef} />\n <ColumnsMenu editor={editor} appendTo={menuContainerRef} />\n <TableRowMenu editor={editor} appendTo={menuContainerRef} />\n <TableColumnMenu editor={editor} appendTo={menuContainerRef} />\n <ImageBlockMenu editor={editor} appendTo={menuContainerRef} />\n <VideoBlockMenu editor={editor} appendTo={menuContainerRef} />\n </div>\n </div>\n </EditorContext.Provider>\n )\n );\n};\n\nexport default BlockEditor;\n"],"names":["EditorContent","useEffect","useMemo","useRef","useLocale","useTranslation","EditorContext","IframeMenu","ImageBlockMenu","VideoBlockMenu","InsideLinksMenu","ColumnsMenu","SocialMediaMenu","TableColumnMenu","TableRowMenu","useBlockEditor","Sidebar","ContentItemMenu","TextMenu","LinkMenu","BlockEditor","handleChange","content","openAssetHQHandler","additionalContext","menuContainerRef","editorRef","editor","users","characterCount","leftSidebar","code","displayedUsers","slice","providerValue","commands","setTextDirection","setContent","i18n","Provider","value","div","lang","language","className","ref","isOpen","onClose","close","style","outline","appendTo"],"mappings":"AAAA;;AACA,SAASA,aAAa,QAAQ,gBAAgB;AAC9C,SAASC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,QAAQ;AAEnD,SAASC,SAAS,QAAQ,kCAAkC;AAC5D,SAASC,cAAc,QAAQ,uCAAuC;AACtE,SAASC,aAAa,QAAQ,iCAAiC;AAC/D,SAASC,UAAU,QAAQ,yCAAyC;AACpE,OAAOC,oBAAoB,2DAA2D;AACtF,OAAOC,oBAAoB,2DAA2D;AACtF,SAASC,eAAe,QAAQ,8CAA8C;AAC9E,SAASC,WAAW,QAAQ,oDAAoD;AAChF,SAASC,eAAe,QAAQ,8CAA8C;AAC9E,SACEC,eAAe,EACfC,YAAY,QACP,wCAAwC;AAC/C,SAASC,cAAc,QAAQ,gCAAgC;AAE/D,SAASC,OAAO,QAAQ,wBAAwB;AAChD,SAASC,eAAe,QAAQ,8CAA8C;AAC9E,SAASC,QAAQ,QAAQ,gCAAgC;AACzD,SAASC,QAAQ,QAAQ,oBAAoB;AAE7C,OAAO,MAAMC,cAAc,CAAC,EAC1BC,YAAY,EACZC,OAAO,EACPC,kBAAkB,EAClBC,iBAAiB,EAIlB;IACC,MAAMC,mBAAmBtB,OAAO;IAChC,MAAMuB,YAAYvB,OAAuB;IAEzC,MAAM,EAAEwB,MAAM,EAAEC,KAAK,EAAEC,cAAc,EAAEC,WAAW,EAAE,GAAGf,eAAe;QACpEO,SAASA;QACTD,cAAcA;QACdE,oBAAoBA;QACpBC,mBAAmBA;IACrB;IAEA,MAAM,EAAEO,IAAI,EAAE,GAAG3B;IAEjB,MAAM4B,iBAAiBJ,MAAMK,KAAK,CAAC,GAAG;IAEtC,MAAMC,gBAAgBhC,QAAQ;QAC5B,OAAO,CAAC;IACV,GAAG,EAAE;IAELD,UAAU;QACR,IAAI8B,SAAS,QAAQA,SAAS,MAAM;YAClCJ,QAAQQ,UAAUC,iBAAiB;YACnCT,QAAQQ,UAAUE,WAAW;QAC/B;IACF,GAAG;QAACN;KAAK;IAET,MAAM,EAAEO,IAAI,EAAE,GAAGjC;IAEjB,OACEsB,wBACE,KAACrB,cAAciC,QAAQ;QAACC,OAAON;kBAC7B,cAAA,MAACO;YACCC,MAAMJ,KAAKK,QAAQ;YACnBC,WAAU;YACVC,KAAKpB;;8BAEL,KAACT;oBACC8B,QAAQhB,YAAYgB,MAAM;oBAC1BC,SAASjB,YAAYkB,KAAK;oBAC1BrB,QAAQA;;8BAEV,MAACc;oBAAIG,WAAU;;sCAQb,KAAC5C;4BACC2B,QAAQA;4BACRkB,KAAKnB;4BACLgB,MAAMJ,KAAKK,QAAQ;4BACnBC,WAAU;4BACVK,OAAO;gCACLC,SAAS;4BACX;;sCAEF,KAACjC;4BAAgBU,QAAQA;;sCACzB,KAACR;4BAASQ,QAAQA;4BAAQwB,UAAU1B;;sCAEpC,KAACP;4BAASS,QAAQA;;sCAClB,KAACpB;4BAAWoB,QAAQA;4BAAQwB,UAAU1B;;sCACtC,KAACb;4BAAgBe,QAAQA;4BAAQwB,UAAU1B;;sCAC3C,KAACf;4BAAgBiB,QAAQA;4BAAQwB,UAAU1B;;sCAC3C,KAACd;4BAAYgB,QAAQA;4BAAQwB,UAAU1B;;sCACvC,KAACX;4BAAaa,QAAQA;4BAAQwB,UAAU1B;;sCACxC,KAACZ;4BAAgBc,QAAQA;4BAAQwB,UAAU1B;;sCAC3C,KAACjB;4BAAemB,QAAQA;4BAAQwB,UAAU1B;;sCAC1C,KAAChB;4BAAekB,QAAQA;4BAAQwB,UAAU1B;;;;;;;AAMtD,EAAE;AAEF,eAAeL,YAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorInfo.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/features/BlockEditor/components/EditorInfo.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAe,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,UAAU,2DACU,eAAe,
|
|
1
|
+
{"version":3,"file":"EditorInfo.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/features/BlockEditor/components/EditorInfo.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAe,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,UAAU,2DACU,eAAe,uBAc/C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/BlockEditor/components/EditorInfo.tsx"],"sourcesContent":["import React, { memo } from \"react\";\nimport { EditorUser } from \"../types.js\";\n\nexport type EditorInfoProps = {\n characters: number;\n words: number;\n users: EditorUser[];\n};\n\nexport const EditorInfo = memo(\n ({ characters, users, words }: EditorInfoProps) => {\n return (\n <div className=\"flex items-center\">\n <div className=\"flex flex-col justify-center pr-4 mr-4 text-right border-r border-neutral-200 dark:border-neutral-800\">\n <div className=\"text-xs font-semibold text-neutral-500 dark:text-neutral-400\">\n {words} {words === 1 ? \"word\" : \"words\"}\n </div>\n <div className=\"text-xs font-semibold text-neutral-500 dark:text-neutral-400\">\n {characters} {characters === 1 ? \"character\" : \"characters\"}\n </div>\n </div>\n
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/BlockEditor/components/EditorInfo.tsx"],"sourcesContent":["import React, { memo } from \"react\";\nimport { EditorUser } from \"../types.js\";\n\nexport type EditorInfoProps = {\n characters: number;\n words: number;\n users: EditorUser[];\n};\n\nexport const EditorInfo = memo(\n ({ characters, users, words }: EditorInfoProps) => {\n return (\n <div className=\"flex items-center\">\n <div className=\"flex flex-col justify-center pr-4 mr-4 text-right border-r border-neutral-200 dark:border-neutral-800\">\n <div className=\"text-xs font-semibold text-neutral-500 dark:text-neutral-400\">\n {words} {words === 1 ? \"word\" : \"words\"}\n </div>\n <div className=\"text-xs font-semibold text-neutral-500 dark:text-neutral-400\">\n {characters} {characters === 1 ? \"character\" : \"characters\"}\n </div>\n </div>\n </div>\n );\n }\n);\n\nEditorInfo.displayName = \"EditorInfo\";\n"],"names":["React","memo","EditorInfo","characters","users","words","div","className","displayName"],"mappings":";AAAA,OAAOA,SAASC,IAAI,QAAQ,QAAQ;AASpC,OAAO,MAAMC,2BAAaD,KACxB,CAAC,EAAEE,UAAU,EAAEC,KAAK,EAAEC,KAAK,EAAmB;IAC5C,qBACE,KAACC;QAAIC,WAAU;kBACb,cAAA,MAACD;YAAIC,WAAU;;8BACb,MAACD;oBAAIC,WAAU;;wBACZF;wBAAM;wBAAEA,UAAU,IAAI,SAAS;;;8BAElC,MAACC;oBAAIC,WAAU;;wBACZJ;wBAAW;wBAAEA,eAAe,IAAI,cAAc;;;;;;AAKzD,GACA;AAEFD,WAAWM,WAAW,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AICommandPanel.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.tsx"],"names":[],"mappings":"AAIA,OAAO,KAON,MAAM,OAAO,CAAC;AAKf,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAEL,KAAK,EACN,MAAM,uDAAuD,CAAC;AAW/D,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,KAAK,EAAE,KAAK,EAAE,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"AICommandPanel.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.tsx"],"names":[],"mappings":"AAIA,OAAO,KAON,MAAM,OAAO,CAAC;AAKf,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAEL,KAAK,EACN,MAAM,uDAAuD,CAAC;AAW/D,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,KAAK,EAAE,KAAK,EAAE,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,cAAc,qFAkV1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.tsx"],"sourcesContent":["\"use client\";\n\nimport { useCompletion } from \"ai/react\";\nimport { ArrowUpCircle, Sparkles } from \"lucide-react\";\nimport React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from \"react\";\nimport Markdown from \"react-markdown\";\nimport TextareaAutosize from \"react-textarea-autosize\";\n\nimport { useLocale } from \"@payloadcms/ui/providers/Locale\";\nimport { Editor } from \"@tiptap/react\";\n\nimport {\n Command,\n Group,\n} from \"src/fields/TiptapEditor/extensions/AICommand/types.js\";\nimport { getPrevText } from \"../../../lib/utils/index.js\";\nimport { isRTL } from \"../../../lib/utils/isRtl.js\";\nimport CrazySpinner from \"../../ui/crazy-spinner.js\";\nimport { DropdownButton } from \"../../ui/Dropdown/Dropdown.js\";\nimport { Icon } from \"../../ui/Icon.js\";\nimport { ScrollArea } from \"../../ui/scroll-area.js\";\nimport { Surface } from \"../../ui/Surface.js\";\nimport { Toolbar } from \"../../ui/Toolbar.js\";\nimport AISelectorCommands from \"../../menus/TextMenu/components/ai-selector-commands.js\";\n\nexport type AICommandPanelProps = {\n editor: Editor;\n userPrompt?: string;\n onOpenChange: (value: boolean) => void;\n items: Group[];\n};\n\nexport const AICommandPanel = forwardRef(\n (\n {\n editor,\n onOpenChange,\n userPrompt,\n items,\n ...restProps\n }: AICommandPanelProps,\n ref\n ) => {\n const [inputValue, setInputValue] = useState(userPrompt ?? \"\");\n const { code } = useLocale();\n const { view } = editor;\n const scrollContainer = useRef<HTMLDivElement>(null);\n const activeItem = useRef<HTMLButtonElement>(null);\n const [selectedGroupIndex, setSelectedGroupIndex] = useState(0);\n const [selectedCommandIndex, setSelectedCommandIndex] = useState(0);\n\n const editorNode = view.dom as HTMLElement;\n const boundigClient = editorNode.getBoundingClientRect();\n const inputRef = useRef<HTMLTextAreaElement>(null);\n\n // const { status, messages, input, submitMessage, handleInputChange } = useAssistant({\n // // id: \"novel\",\n // api: \"/api/assistant\",\n // onResponse: (response) => {\n // if (response.status === 429) {\n // toast.error(\"You have reached your request limit for the day.\");\n // return;\n // }\n // },\n // onError: (e) => {\n // toast.error(e.message);\n // },\n // });\n\n const { completion, complete, isLoading } = useCompletion({\n // id: \"novel\",\n api: \"/api/generate\",\n onResponse: (response) => {\n if (response.status === 429) {\n console.log(\"You have reached your request limit for the day.\");\n\n return;\n }\n },\n\n onError: (e) => {\n console.log(\"ERROR\", e.message);\n },\n });\n\n const hasCompletion = completion.length > 0;\n const handleClick = useCallback(() => {\n if (completion) {\n return complete(completion, {\n body: { option: \"zap\", command: inputValue, language: code ?? \"en\" },\n }).then(() => setInputValue(\"\"));\n }\n const text = getPrevText(editor, { chars: 5000 });\n\n complete(text, {\n body: {\n option: \"zap\",\n command:\n (editor.storage.aiCommand.title\n ? \"Context Title:\" + editor.storage.aiCommand.title + \";\\n\"\n : \"\") +\n (editor.storage.aiCommand.language\n ? \"Context language:\" + editor.storage.aiCommand.language + \";\\n\"\n : \"\") +\n inputValue,\n language: editor.storage.aiCommand.language ?? code ?? \"en\",\n },\n }).then(() => setInputValue(\"\"));\n }, [code, inputValue]);\n\n useEffect(() => {\n if (userPrompt) setInputValue(userPrompt);\n }, [userPrompt]);\n useEffect(() => {\n editor.storage.aiCommand.completion = completion;\n // if (!isLoading && completion) {\n // const selection = editor.state.selection;\n // editor\n // .chain()\n // .focus()\n // .insertContentAt(selection.to - 1, completion)\n // .insertContentAt(selection.to, \" \")\n // .run();\n\n // }\n }, [completion, isLoading]);\n\n // Anytime the groups change, i.e. the user types to narrow it down, we want to\n // reset the current selection to the first menu item\n useEffect(() => {\n setSelectedGroupIndex(0);\n setSelectedCommandIndex(0);\n }, [items]);\n\n const selectItem = useCallback(\n (groupIndex: number, commandIndex: number) => {\n const command = items[groupIndex].commands[commandIndex];\n\n setInputValue(command.action(editor));\n // props.command(command);\n },\n [items, editor]\n );\n\n useImperativeHandle(ref, () => ({\n onKeyDown: ({ event }: { event: React.KeyboardEvent }) => {\n if (event.key === \"ArrowDown\") {\n if (!items.length) {\n return false;\n }\n\n const commands = items[selectedGroupIndex].commands;\n\n let newCommandIndex = selectedCommandIndex + 1;\n let newGroupIndex = selectedGroupIndex;\n\n if (commands.length - 1 < newCommandIndex) {\n newCommandIndex = 0;\n newGroupIndex = selectedGroupIndex + 1;\n }\n\n if (items.length - 1 < newGroupIndex) {\n newGroupIndex = 0;\n }\n\n setSelectedCommandIndex(newCommandIndex);\n setSelectedGroupIndex(newGroupIndex);\n\n return true;\n }\n\n if (event.key === \"ArrowUp\") {\n if (!items.length) {\n return false;\n }\n\n let newCommandIndex = selectedCommandIndex - 1;\n let newGroupIndex = selectedGroupIndex;\n\n if (newCommandIndex < 0) {\n newGroupIndex = selectedGroupIndex - 1;\n newCommandIndex = items[newGroupIndex]?.commands.length - 1 || 0;\n }\n\n if (newGroupIndex < 0) {\n newGroupIndex = items.length - 1;\n newCommandIndex = items[newGroupIndex].commands.length - 1;\n }\n\n setSelectedCommandIndex(newCommandIndex);\n setSelectedGroupIndex(newGroupIndex);\n\n return true;\n }\n\n if (event.key === \"Enter\") {\n if (\n !items.length ||\n selectedGroupIndex === -1 ||\n selectedCommandIndex === -1\n ) {\n return false;\n }\n\n selectItem(selectedGroupIndex, selectedCommandIndex);\n\n return true;\n }\n\n return false;\n },\n }));\n\n useEffect(() => {\n if (activeItem.current && scrollContainer.current) {\n const offsetTop = activeItem.current.offsetTop;\n const offsetHeight = activeItem.current.offsetHeight;\n\n scrollContainer.current.scrollTop = offsetTop - offsetHeight;\n }\n }, [selectedCommandIndex, selectedGroupIndex]);\n\n const createCommandClickHandler = useCallback(\n (groupIndex: number, commandIndex: number) => {\n return () => {\n selectItem(groupIndex, commandIndex);\n };\n },\n [selectItem]\n );\n\n return (\n <>\n <Surface\n className={`p-2 min-w-[20rem] flex flex-col gap-2 w-full ${\n hasCompletion ? \"-mt-72\" : \"\"\n }`}\n style={{\n width: boundigClient?.width,\n }}\n >\n <>\n {hasCompletion && (\n <div className=\"flex w-full\">\n <ScrollArea\n className=\"h-72 prose p-2 px-4 prose-sm w-full max-w-none\"\n dir={isRTL(completion) ? \"rtl\" : \"ltr\"}\n >\n <Markdown className=\"w-full\">{completion}</Markdown>\n </ScrollArea>\n </div>\n )}\n\n {isLoading && (\n <div\n className=\"flex h-12 w-full items-center px-4 text-sm font-medium text-muted-foreground text-blue-500\"\n style={{\n width: boundigClient?.width,\n }}\n >\n <Sparkles className=\"mr-2 h-4 w-4 shrink-0 \" />\n AI is thinking\n <div className=\"ml-2 mt-1\">\n <CrazySpinner />\n </div>\n </div>\n )}\n\n {!isLoading && (\n <>\n <div className=\"flex justify-between items-center \">\n {/* <CommandInput\n value={inputValue}\n onValueChange={setInputValue}\n autoFocus\n placeholder={\n hasCompletion ? 'Tell AI what to do next' : 'Ask AI to edit or generate...'\n }\n // onFocus={() => addAIHighlight(editor)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') handleClick()\n }}\n /> */}\n <Sparkles className=\"mr-2 h-4 w-4 shrink-0 text-blue-500 \" />\n <TextareaAutosize\n ref={inputRef}\n style={{ resize: \"none\" }}\n className=\"w-full p-2 text-black bg-white rounded dark:bg-black dark:text-white focus:outline-none outline-none border-0 \"\n value={inputValue}\n onChange={(e) => {\n editor.storage.aiCommand.userPrompt = e.target.value;\n\n setInputValue(e.target.value);\n }}\n placeholder={\n hasCompletion\n ? \"Tell AI what to do next\"\n : \"Ask AI to edit or generate...\"\n }\n autoFocus\n // onFocus={() => {\n // addAIHighlight(editor)}}\n\n onKeyDown={(e) => {\n if (e.key === \"Enter\") handleClick();\n }}\n />\n <Toolbar.Button\n // size=\"icon\"\n\n // className=\"absolute right-2 top-1/2 h-6 w-6 -translate-y-1/2 rounded-full bg-zinc-100 hover:bg-zinc-150\"\n onClick={handleClick}\n >\n <ArrowUpCircle />\n </Toolbar.Button>\n </div>\n </>\n )}\n </>\n </Surface>\n {!isLoading && (\n <Surface\n ref={scrollContainer}\n className=\"text-black max-h-[min(80vh,24rem)] overflow-auto flex-wrap mb-8 p-2\"\n >\n <div className=\"grid grid-cols-1 gap-0.5\">\n {hasCompletion ? (\n <AISelectorCommands\n editor={editor}\n messages={completion}\n onSelect={(value, options) => {\n console.log(\"VALUE\", value, options);\n complete(value, { body: options });\n }}\n />\n ) : (\n items.map((group, groupIndex: number) => (\n <React.Fragment key={`${group.title}-wrapper`}>\n <div\n className=\"text-neutral-500 text-[0.65rem] col-[1/-1] mx-2 mt-4 font-semibold tracking-wider select-none uppercase first:mt-0.5\"\n key={`${group.title}`}\n >\n {group.title}\n </div>\n {group.commands.map(\n (command: Command, commandIndex: number) => (\n <DropdownButton\n key={`${command.label}`}\n isActive={\n selectedGroupIndex === groupIndex &&\n selectedCommandIndex === commandIndex\n }\n onClick={createCommandClickHandler(\n groupIndex,\n commandIndex\n )}\n >\n <Icon icon={command.icon} className=\"mr-1\" />\n {command.label}\n </DropdownButton>\n )\n )}\n </React.Fragment>\n ))\n )}\n </div>\n </Surface>\n )}\n </>\n );\n }\n);\n"],"names":["useCompletion","ArrowUpCircle","Sparkles","React","forwardRef","useCallback","useEffect","useImperativeHandle","useRef","useState","Markdown","TextareaAutosize","useLocale","getPrevText","isRTL","CrazySpinner","DropdownButton","Icon","ScrollArea","Surface","Toolbar","AISelectorCommands","AICommandPanel","editor","onOpenChange","userPrompt","items","restProps","ref","inputValue","setInputValue","code","view","scrollContainer","activeItem","selectedGroupIndex","setSelectedGroupIndex","selectedCommandIndex","setSelectedCommandIndex","editorNode","dom","boundigClient","getBoundingClientRect","inputRef","completion","complete","isLoading","api","onResponse","response","status","console","log","onError","e","message","hasCompletion","length","handleClick","body","option","command","language","then","text","chars","storage","aiCommand","title","selectItem","groupIndex","commandIndex","commands","action","onKeyDown","event","key","newCommandIndex","newGroupIndex","current","offsetTop","offsetHeight","scrollTop","createCommandClickHandler","className","style","width","div","dir","resize","value","onChange","target","placeholder","autoFocus","Button","onClick","messages","onSelect","options","map","group","Fragment","isActive","icon","label"],"mappings":"AAAA;;AAEA,SAASA,aAAa,QAAQ,WAAW;AACzC,SAASC,aAAa,EAAEC,QAAQ,QAAQ,eAAe;AACvD,OAAOC,SACLC,UAAU,EACVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,MAAM,EACNC,QAAQ,QACH,QAAQ;AACf,OAAOC,cAAc,iBAAiB;AACtC,OAAOC,sBAAsB,0BAA0B;AAEvD,SAASC,SAAS,QAAQ,kCAAkC;AAO5D,SAASC,WAAW,QAAQ,8BAA8B;AAC1D,SAASC,KAAK,QAAQ,8BAA8B;AACpD,OAAOC,kBAAkB,4BAA4B;AACrD,SAASC,cAAc,QAAQ,gCAAgC;AAC/D,SAASC,IAAI,QAAQ,mBAAmB;AACx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AC9B;wCACAG,aACErC,gBACI,4BACA;wCAENsC,SAAS;wCACT,mBAAmB;wCACnB,6BAA6B;wCAE7BpB,WAAW,CAACpB;4CACV,IAAIA,EAAEsB,GAAG,KAAK,SAASlB;wCACzB;;kDAEF,KAACtC,QAAQ2E,MAAM;wCACb,cAAc;wCAEd,4GAA4G;wCAC5GC,SAAStC;kDAET,cAAA,KAACzD;;;;;;;;YAOZ,CAAC6C,2BACA,KAAC3B;gBACCS,KAAKK;gBACLmD,WAAU;0BAEV,cAAA,KAACG;oBAAIH,WAAU;8BACZ5B,8BACC,KAACnC;wBACCE,QAAQA;wBACR0E,UAAUrD;wBACVsD,UAAU,CAACR,OAAOS;4BAChBhD,QAAQC,GAAG,CAAC,SAASsC,OAAOS;4BAC5BtD,SAAS6C,OAAO;gCAAE/B,MAAMwC;4BAAQ;wBAClC;yBAGFzE,MAAM0E,GAAG,CAAC,CAACC,OAAO/B,2BAChB,MAACnE,MAAMmG,QAAQ;;8CACb,KAACf;oCACCH,WAAU;8CAGTiB,MAAMjC,KAAK;mCAFP,CAAC,EAAEiC,MAAMjC,KAAK,CAAC,CAAC;gCAItBiC,MAAM7B,QAAQ,CAAC4B,GAAG,CACjB,CAACvC,SAAkBU,6BACjB,MAACvD;wCAECuF,UACEpE,uBAAuBmC,cACvBjC,yBAAyBkC;wCAE3ByB,SAASb,0BACPb,YACAC;;0DAGF,KAACtD;gDAAKuF,MAAM3C,QAAQ2C,IAAI;gDAAEpB,WAAU;;4CACnCvB,QAAQ4C,KAAK;;uCAXT,CAAC,EAAE5C,QAAQ4C,KAAK,CAAC,CAAC;;2BAVV,CAAC,EAAEJ,MAAMjC,KAAK,CAAC,QAAQ,CAAC;;;;;AAiC7D,GACA"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.tsx"],"sourcesContent":["\"use client\";\n\nimport { useCompletion } from \"ai/react\";\nimport { ArrowUpCircle, Sparkles } from \"lucide-react\";\nimport React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from \"react\";\nimport Markdown from \"react-markdown\";\nimport TextareaAutosize from \"react-textarea-autosize\";\n\nimport { useLocale } from \"@payloadcms/ui/providers/Locale\";\nimport { Editor } from \"@tiptap/react\";\n\nimport {\n Command,\n Group,\n} from \"src/fields/TiptapEditor/extensions/AICommand/types.js\";\nimport { getPrevText } from \"../../../lib/utils/index.js\";\nimport { isRTL } from \"../../../lib/utils/isRtl.js\";\nimport CrazySpinner from \"../../ui/crazy-spinner.js\";\nimport { DropdownButton } from \"../../ui/Dropdown/Dropdown.js\";\nimport { Icon } from \"../../ui/Icon.js\";\nimport { ScrollArea } from \"../../ui/scroll-area.js\";\nimport { Surface } from \"../../ui/Surface.js\";\nimport { Toolbar } from \"../../ui/Toolbar.js\";\nimport AISelectorCommands from \"../../menus/TextMenu/components/ai-selector-commands.js\";\n\nexport type AICommandPanelProps = {\n editor: Editor;\n userPrompt?: string;\n onOpenChange: (value: boolean) => void;\n items: Group[];\n};\n\nexport const AICommandPanel = forwardRef(\n (\n {\n editor,\n onOpenChange,\n userPrompt,\n items,\n ...restProps\n }: AICommandPanelProps,\n ref\n ) => {\n const [inputValue, setInputValue] = useState(userPrompt ?? \"\");\n const { code } = useLocale();\n const { view } = editor;\n const scrollContainer = useRef<HTMLDivElement>(null);\n const activeItem = useRef<HTMLButtonElement>(null);\n const [selectedGroupIndex, setSelectedGroupIndex] = useState(0);\n const [selectedCommandIndex, setSelectedCommandIndex] = useState(0);\n\n const editorNode = view.dom as HTMLElement;\n const boundigClient = editorNode.getBoundingClientRect();\n const inputRef = useRef<HTMLTextAreaElement>(null);\n\n // const { status, messages, input, submitMessage, handleInputChange } = useAssistant({\n // // id: \"novel\",\n // api: \"/api/assistant\",\n // onResponse: (response) => {\n // if (response.status === 429) {\n // toast.error(\"You have reached your request limit for the day.\");\n // return;\n // }\n // },\n // onError: (e) => {\n // toast.error(e.message);\n // },\n // });\n\n const { completion, complete, isLoading } = useCompletion({\n // id: \"novel\",\n api: \"/api/generate\",\n onResponse: (response) => {\n if (response.status === 429) {\n console.log(\"You have reached your request limit for the day.\");\n\n return;\n }\n },\n\n onError: (e) => {\n console.log(\"ERROR\", e.message);\n },\n });\n\n const hasCompletion = completion.length > 0;\n const handleClick = useCallback(() => {\n if (completion) {\n return complete(completion, {\n body: { option: \"zap\", command: inputValue, language: code ?? \"en\" },\n }).then(() => setInputValue(\"\"));\n }\n const text = getPrevText(editor, { chars: 5000 });\n\n complete(text, {\n body: {\n option: \"zap\",\n command:\n (editor.storage.aiCommand.title\n ? \"Context Title:\" + editor.storage.aiCommand.title + \";\\n\"\n : \"\") +\n (editor.storage.aiCommand.language\n ? \"Context language:\" + editor.storage.aiCommand.language + \";\\n\"\n : \"\") +\n inputValue,\n language: editor.storage.aiCommand.language ?? code ?? \"en\",\n },\n }).then(() => setInputValue(\"\"));\n }, [code, inputValue]);\n\n useEffect(() => {\n if (userPrompt) setInputValue(userPrompt);\n }, [userPrompt]);\n useEffect(() => {\n editor.storage.aiCommand.completion = completion;\n // if (!isLoading && completion) {\n // const selection = editor.state.selection;\n // editor\n // .chain()\n // .focus()\n // .insertContentAt(selection.to - 1, completion)\n // .insertContentAt(selection.to, \" \")\n // .run();\n\n // }\n }, [completion, isLoading]);\n\n // Anytime the groups change, i.e. the user types to narrow it down, we want to\n // reset the current selection to the first menu item\n useEffect(() => {\n setSelectedGroupIndex(0);\n setSelectedCommandIndex(0);\n }, [items]);\n\n const selectItem = useCallback(\n (groupIndex: number, commandIndex: number) => {\n const command = items[groupIndex].commands[commandIndex];\n\n setInputValue(command.action(editor));\n // props.command(command);\n },\n [items, editor]\n );\n\n useImperativeHandle(ref, () => ({\n onKeyDown: ({ event }: { event: React.KeyboardEvent }) => {\n if (event.key === \"ArrowDown\") {\n if (!items.length) {\n return false;\n }\n\n const commands = items[selectedGroupIndex].commands;\n\n let newCommandIndex = selectedCommandIndex + 1;\n let newGroupIndex = selectedGroupIndex;\n\n if (commands.length - 1 < newCommandIndex) {\n newCommandIndex = 0;\n newGroupIndex = selectedGroupIndex + 1;\n }\n\n if (items.length - 1 < newGroupIndex) {\n newGroupIndex = 0;\n }\n\n setSelectedCommandIndex(newCommandIndex);\n setSelectedGroupIndex(newGroupIndex);\n\n return true;\n }\n\n if (event.key === \"ArrowUp\") {\n if (!items.length) {\n return false;\n }\n\n let newCommandIndex = selectedCommandIndex - 1;\n let newGroupIndex = selectedGroupIndex;\n\n if (newCommandIndex < 0) {\n newGroupIndex = selectedGroupIndex - 1;\n newCommandIndex = items[newGroupIndex]?.commands.length - 1 || 0;\n }\n\n if (newGroupIndex < 0) {\n newGroupIndex = items.length - 1;\n newCommandIndex = items[newGroupIndex].commands.length - 1;\n }\n\n setSelectedCommandIndex(newCommandIndex);\n setSelectedGroupIndex(newGroupIndex);\n\n return true;\n }\n\n if (event.key === \"Enter\") {\n if (\n !items.length ||\n selectedGroupIndex === -1 ||\n selectedCommandIndex === -1\n ) {\n return false;\n }\n\n selectItem(selectedGroupIndex, selectedCommandIndex);\n\n return true;\n }\n\n return false;\n },\n }));\n\n useEffect(() => {\n if (activeItem.current && scrollContainer.current) {\n const offsetTop = activeItem.current.offsetTop;\n const offsetHeight = activeItem.current.offsetHeight;\n\n scrollContainer.current.scrollTop = offsetTop - offsetHeight;\n }\n }, [selectedCommandIndex, selectedGroupIndex]);\n\n const createCommandClickHandler = useCallback(\n (groupIndex: number, commandIndex: number) => {\n return () => {\n selectItem(groupIndex, commandIndex);\n };\n },\n [selectItem]\n );\n\n return (\n <>\n <Surface\n className={`p-2 min-w-[20rem] flex flex-col gap-2 w-full ${\n hasCompletion ? \"-mt-72\" : \"\"\n }`}\n style={{\n width: boundigClient?.width,\n }}\n >\n <>\n {hasCompletion && (\n <div className=\"flex w-full\">\n <ScrollArea\n className=\"h-72 prose p-2 px-4 prose-sm w-full max-w-none\"\n dir={isRTL(completion) ? \"rtl\" : \"ltr\"}\n >\n <Markdown className=\"w-full\">{completion}</Markdown>\n </ScrollArea>\n </div>\n )}\n\n {isLoading && (\n <div\n className=\"flex h-12 w-full items-center px-4 text-sm font-medium text-muted-foreground text-blue-500\"\n style={{\n width: boundigClient?.width,\n }}\n >\n <Sparkles className=\"mr-2 h-4 w-4 shrink-0 \" />\n AI is thinking\n <div className=\"ml-2 mt-1\">\n <CrazySpinner />\n </div>\n </div>\n )}\n\n {!isLoading && (\n <>\n <div className=\"flex justify-between items-center \">\n {/* <CommandInput\n value={inputValue}\n onValueChange={setInputValue}\n autoFocus\n placeholder={\n hasCompletion ? 'Tell AI what to do next' : 'Ask AI to edit or generate...'\n }\n // onFocus={() => addAIHighlight(editor)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') handleClick()\n }}\n /> */}\n <Sparkles className=\"mr-2 h-4 w-4 shrink-0 text-blue-500 \" />\n <TextareaAutosize\n ref={inputRef}\n style={{ resize: \"none\" }}\n className=\"w-full p-2 text-black bg-white rounded dark:bg-black dark:text-white focus:outline-none outline-none border-0 \"\n value={inputValue}\n onChange={(e) => {\n editor.storage.aiCommand.userPrompt = e.target.value;\n\n setInputValue(e.target.value);\n }}\n placeholder={\n hasCompletion\n ? \"Tell AI what to do next\"\n : \"Ask AI to edit or generate...\"\n }\n autoFocus\n // onFocus={() => {\n // addAIHighlight(editor)}}\n\n onKeyDown={(e) => {\n if (e.key === \"Enter\") handleClick();\n }}\n />\n <Toolbar.Button\n // size=\"icon\"\n\n // className=\"absolute right-2 top-1/2 h-6 w-6 -translate-y-1/2 rounded-full bg-zinc-100 hover:bg-zinc-150\"\n onClick={handleClick}\n >\n <ArrowUpCircle />\n </Toolbar.Button>\n </div>\n </>\n )}\n </>\n </Surface>\n {!isLoading && (\n <Surface\n ref={scrollContainer}\n className=\"text-black max-h-[min(80vh,24rem)] overflow-auto flex-wrap mb-8 p-2\"\n >\n <div className=\"grid grid-cols-1 gap-0.5\">\n {hasCompletion ? (\n <AISelectorCommands\n editor={editor}\n messages={completion}\n onSelect={(value, options) => {\n complete(value, { body: options });\n }}\n />\n ) : (\n items.map((group, groupIndex: number) => (\n <React.Fragment key={`${group.title}-wrapper`}>\n <div\n className=\"text-neutral-500 text-[0.65rem] col-[1/-1] mx-2 mt-4 font-semibold tracking-wider select-none uppercase first:mt-0.5\"\n key={`${group.title}`}\n >\n {group.title}\n </div>\n {group.commands.map(\n (command: Command, commandIndex: number) => (\n <DropdownButton\n key={`${command.label}`}\n isActive={\n selectedGroupIndex === groupIndex &&\n selectedCommandIndex === commandIndex\n }\n onClick={createCommandClickHandler(\n groupIndex,\n commandIndex\n )}\n >\n <Icon icon={command.icon} className=\"mr-1\" />\n {command.label}\n </DropdownButton>\n )\n )}\n </React.Fragment>\n ))\n )}\n </div>\n </Surface>\n )}\n </>\n );\n }\n);\n"],"names":["useCompletion","ArrowUpCircle","Sparkles","React","forwardRef","useCallback","useEffect","useImperativeHandle","useRef","useState","Markdown","TextareaAutosize","useLocale","getPrevText","isRTL","CrazySpinner","DropdownButton","Icon","ScrollArea","Surface","Toolbar","AISelectorCommands","AICommandPanel","editor","onOpenChange","userPrompt","items","restProps","ref","inputValue","setInputValue","code","view","scrollContainer","activeItem","selectedGroupIndex","setSelectedGroupIndex","selectedCommandIndex","setSelectedCommandIndex","editorNode","dom","boundigClient","getBoundingClientRect","inputRef","completion","complete","isLoading","api","onResponse","response","status","console","log","onError","e","message","hasCompletion","length","handleClick","body","option","command","language","then","text","chars","storage","aiCommand","title","selectItem","groupIndex","commandIndex","commands","action","onKeyDown","event","key","newCommandIndex","newGroupIndex","current","offsetTop","offsetHeight","scrollTop","createCommandClickHandler","className","style","width","div","dir","resize","value","onChange","target","placeholder","autoFocus","Button","onClick","messages","onSelect","options","map","group","Fragment","isActive","icon","label"],"mappings":"AAAA;;AAEA,SAASA,aAAa,QAAQ,WAAW;AACzC,SAASC,aAAa,EAAEC,QAAQ,QAAQ,eAAe;AACvD,OAAOC,SACLC,UAAU,EACVC,WAAW,EACXC,SAAS,EAC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E5C,QAAQ4C,KAAK,CAAC,CAAC;;2BAVV,CAAC,EAAEJ,MAAMjC,KAAK,CAAC,QAAQ,CAAC;;;;;AAiC7D,GACA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type ButtonVariant = "primary" | "secondary" | "tertiary" | "quaternary" | "ghost";
|
|
3
|
+
export type ButtonSize = "medium" | "small" | "icon" | "iconSmall";
|
|
4
|
+
export type ButtonProps = {
|
|
5
|
+
variant?: ButtonVariant;
|
|
6
|
+
active?: boolean;
|
|
7
|
+
activeClassname?: string;
|
|
8
|
+
buttonSize?: ButtonSize;
|
|
9
|
+
} & React.ButtonHTMLAttributes<HTMLButtonElement>;
|
|
10
|
+
export declare const SpanButton: React.ForwardRefExoticComponent<{
|
|
11
|
+
variant?: ButtonVariant;
|
|
12
|
+
active?: boolean;
|
|
13
|
+
activeClassname?: string;
|
|
14
|
+
buttonSize?: ButtonSize;
|
|
15
|
+
} & React.ButtonHTMLAttributes<HTMLButtonElement> & React.RefAttributes<HTMLButtonElement>>;
|
|
16
|
+
//# sourceMappingURL=SpanButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SpanButton.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/features/ui/Button/SpanButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,MAAM,aAAa,GACrB,SAAS,GACT,WAAW,GACX,UAAU,GACV,YAAY,GACZ,OAAO,CAAC;AACZ,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,WAAW,CAAC;AAEnE,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,GAAG,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;AAElD,eAAO,MAAM,UAAU;cANX,aAAa;aACd,OAAO;sBACE,MAAM;iBACX,UAAU;2FA0ExB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { cn } from "../../../lib/utils/index.js";
|
|
4
|
+
export const SpanButton = /*#__PURE__*/ React.forwardRef(({ active, buttonSize = "medium", children, disabled, variant = "primary", className, activeClassname, ...rest }, ref)=>{
|
|
5
|
+
const buttonClassName = cn("flex group items-center justify-center border border-transparent gap-2 text-base font-semibold rounded-md disabled:opacity-50 whitespace-nowrap", variant === "primary" && cn("text-white bg-black border-black dark:text-black dark:bg-white dark:border-white", !disabled && !active && "hover:bg-neutral-800 active:bg-neutral-900 dark:hover:bg-neutral-200 dark:active:bg-neutral-300", active && cn("bg-neutral-900 dark:bg-neutral-300", activeClassname)), variant === "secondary" && cn("text-neutral-900 dark:text-white", !disabled && !active && "hover:bg-neutral-100 active:bg-neutral-200 dark:hover:bg-neutral-900 dark:active:bg-neutral-800", active && "bg-neutral-200 dark:bg-neutral-800"), variant === "tertiary" && cn("bg-neutral-50 text-neutral-900 dark:bg-neutral-900 dark:text-white dark:border-neutral-900", !disabled && !active && "hover:bg-neutral-100 active:bg-neutral-200 dark:hover:bg-neutral-800 dark:active:bg-neutral-700", active && cn("bg-neutral-200 dark:bg-neutral-800", activeClassname)), variant === "ghost" && cn("bg-transparent border-transparent text-neutral-500 dark:text-neutral-400", !disabled && !active && "hover:bg-black/5 hover:text-neutral-700 active:bg-black/10 active:text-neutral-800 dark:hover:bg-white/10 dark:hover:text-neutral-300 dark:active:text-neutral-200", active && cn("bg-black/10 text-neutral-800 dark:bg-white/20 dark:text-neutral-200", activeClassname)), buttonSize === "medium" && "py-2 px-3", buttonSize === "small" && "py-1 px-2", buttonSize === "icon" && "w-8 h-8", buttonSize === "iconSmall" && "w-6 h-6", className);
|
|
6
|
+
return /*#__PURE__*/ _jsx("span", {
|
|
7
|
+
type: "button",
|
|
8
|
+
ref: ref,
|
|
9
|
+
className: buttonClassName,
|
|
10
|
+
...rest,
|
|
11
|
+
children: children
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
SpanButton.displayName = "SpanButton";
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=SpanButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/ui/Button/SpanButton.tsx"],"sourcesContent":["import React from \"react\";\nimport { cn } from \"../../../lib/utils/index.js\";\n\nexport type ButtonVariant =\n | \"primary\"\n | \"secondary\"\n | \"tertiary\"\n | \"quaternary\"\n | \"ghost\";\nexport type ButtonSize = \"medium\" | \"small\" | \"icon\" | \"iconSmall\";\n\nexport type ButtonProps = {\n variant?: ButtonVariant;\n active?: boolean;\n activeClassname?: string;\n buttonSize?: ButtonSize;\n} & React.ButtonHTMLAttributes<HTMLButtonElement>;\n\nexport const SpanButton = React.forwardRef<HTMLButtonElement, ButtonProps>(\n (\n {\n active,\n buttonSize = \"medium\",\n children,\n disabled,\n variant = \"primary\",\n className,\n activeClassname,\n ...rest\n },\n ref\n ) => {\n const buttonClassName = cn(\n \"flex group items-center justify-center border border-transparent gap-2 text-base font-semibold rounded-md disabled:opacity-50 whitespace-nowrap\",\n\n variant === \"primary\" &&\n cn(\n \"text-white bg-black border-black dark:text-black dark:bg-white dark:border-white\",\n !disabled &&\n !active &&\n \"hover:bg-neutral-800 active:bg-neutral-900 dark:hover:bg-neutral-200 dark:active:bg-neutral-300\",\n active && cn(\"bg-neutral-900 dark:bg-neutral-300\", activeClassname)\n ),\n\n variant === \"secondary\" &&\n cn(\n \"text-neutral-900 dark:text-white\",\n !disabled &&\n !active &&\n \"hover:bg-neutral-100 active:bg-neutral-200 dark:hover:bg-neutral-900 dark:active:bg-neutral-800\",\n active && \"bg-neutral-200 dark:bg-neutral-800\"\n ),\n\n variant === \"tertiary\" &&\n cn(\n \"bg-neutral-50 text-neutral-900 dark:bg-neutral-900 dark:text-white dark:border-neutral-900\",\n !disabled &&\n !active &&\n \"hover:bg-neutral-100 active:bg-neutral-200 dark:hover:bg-neutral-800 dark:active:bg-neutral-700\",\n active && cn(\"bg-neutral-200 dark:bg-neutral-800\", activeClassname)\n ),\n\n variant === \"ghost\" &&\n cn(\n \"bg-transparent border-transparent text-neutral-500 dark:text-neutral-400\",\n !disabled &&\n !active &&\n \"hover:bg-black/5 hover:text-neutral-700 active:bg-black/10 active:text-neutral-800 dark:hover:bg-white/10 dark:hover:text-neutral-300 dark:active:text-neutral-200\",\n active &&\n cn(\n \"bg-black/10 text-neutral-800 dark:bg-white/20 dark:text-neutral-200\",\n activeClassname\n )\n ),\n\n buttonSize === \"medium\" && \"py-2 px-3\",\n buttonSize === \"small\" && \"py-1 px-2\",\n buttonSize === \"icon\" && \"w-8 h-8\",\n buttonSize === \"iconSmall\" && \"w-6 h-6\",\n\n className\n );\n\n return (\n <span type=\"button\" ref={ref} className={buttonClassName} {...rest}>\n {children}\n </span>\n );\n }\n);\n\nSpanButton.displayName = \"SpanButton\";\n"],"names":["React","cn","SpanButton","forwardRef","active","buttonSize","children","disabled","variant","className","activeClassname","rest","ref","buttonClassName","span","type","displayName"],"mappings":";AAAA,OAAOA,WAAW,QAAQ;AAC1B,SAASC,EAAE,QAAQ,8BAA8B;AAiBjD,OAAO,MAAMC,2BAAaF,MAAMG,UAAU,CACxC,CACE,EACEC,MAAM,EACNC,aAAa,QAAQ,EACrBC,QAAQ,EACRC,QAAQ,EACRC,UAAU,SAAS,EACnBC,SAAS,EACTC,eAAe,EACf,GAAGC,MACJ,EACDC;IAEA,MAAMC,kBAAkBZ,GACtB,mJAEAO,YAAY,aACVP,GACE,oFACA,CAACM,YACC,CAACH,UACD,mGACFA,UAAUH,GAAG,sCAAsCS,mBAGvDF,YAAY,eACVP,GACE,oCACA,CAACM,YACC,CAACH,UACD,mGACFA,UAAU,uCAGdI,YAAY,cACVP,GACE,8FACA,CAACM,YACC,CAACH,UACD,mGACFA,UAAUH,GAAG,sCAAsCS,mBAGvDF,YAAY,WACVP,GACE,4EACA,CAACM,YACC,CAACH,UACD,sKACFA,UACEH,GACE,uEACAS,mBAIRL,eAAe,YAAY,aAC3BA,eAAe,WAAW,aAC1BA,eAAe,UAAU,WACzBA,eAAe,eAAe,WAE9BI;IAGF,qBACE,KAACK;QAAKC,MAAK;QAASH,KAAKA;QAAKH,WAAWI;QAAkB,GAAGF,IAAI;kBAC/DL;;AAGP,GACA;AAEFJ,WAAWc,WAAW,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/features/ui/Button/index.tsx"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/features/ui/Button/index.tsx"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/ui/Button/index.tsx"],"sourcesContent":["export * from \"./Button.js\";\n"],"names":[],"mappings":"AAAA,cAAc,cAAc"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/ui/Button/index.tsx"],"sourcesContent":["export * from \"./Button.js\";\nexport { SpanButton } from \"./SpanButton.js\";\n"],"names":["SpanButton"],"mappings":"AAAA,cAAc,cAAc;AAC5B,SAASA,UAAU,QAAQ,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/features/ui/Dropdown/Dropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,eAAO,MAAM,qBAAqB,kBAE/B;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,sBAMA,CAAC;AAEF,eAAO,MAAM,cAAc,0DAMxB;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,
|
|
1
|
+
{"version":3,"file":"Dropdown.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/features/ui/Dropdown/Dropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,eAAO,MAAM,qBAAqB,kBAE/B;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,sBAMA,CAAC;AAEF,eAAO,MAAM,cAAc,0DAMxB;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,sBAyBA,CAAC"}
|
|
@@ -8,11 +8,10 @@ export const DropdownCategoryTitle = ({ children })=>{
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
export const DropdownButton = ({ children, isActive, onClick, disabled, className })=>{
|
|
11
|
-
const buttonClass = cn("flex items-center gap-2 p-1.5 text-sm font-medium text-neutral-500 dark:text-neutral-400 text-left bg-transparent w-full rounded outline-none", !isActive && !disabled, "hover:bg-neutral-100 hover:text-neutral-800 dark:hover:bg-neutral-900 dark:hover:text-neutral-200", isActive && !disabled && "bg-neutral-100 text-neutral-800 dark:bg-neutral-900 dark:text-neutral-200", disabled && "text-neutral-400 cursor-not-allowed dark:text-neutral-600", className);
|
|
12
|
-
return /*#__PURE__*/ _jsx("
|
|
13
|
-
type: "button",
|
|
11
|
+
const buttonClass = cn("flex items-center gap-2 p-1.5 text-sm font-medium text-neutral-500 dark:text-neutral-400 text-left bg-transparent w-full rounded outline-none cursor-pointer", !isActive && !disabled, "hover:bg-neutral-100 hover:text-neutral-800 dark:hover:bg-neutral-900 dark:hover:text-neutral-200", isActive && !disabled && "bg-neutral-100 text-neutral-800 dark:bg-neutral-900 dark:text-neutral-200", disabled && "text-neutral-400 cursor-not-allowed dark:text-neutral-600", className);
|
|
12
|
+
return /*#__PURE__*/ _jsx("span", {
|
|
14
13
|
className: buttonClass,
|
|
15
|
-
|
|
14
|
+
// disabled={disabled}
|
|
16
15
|
onClick: (e)=>{
|
|
17
16
|
e.preventDefault();
|
|
18
17
|
e.stopPropagation();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/ui/Dropdown/Dropdown.tsx"],"sourcesContent":["import React from \"react\";\nimport { cn } from \"../../../lib/utils/index.js\";\n\nexport const DropdownCategoryTitle = ({\n children,\n}: {\n children: React.ReactNode;\n}) => {\n return (\n <div className=\"text-[.65rem] font-semibold mb-1 uppercase text-neutral-500 dark:text-neutral-400 px-1.5\">\n {children}\n </div>\n );\n};\n\nexport const DropdownButton = ({\n children,\n isActive,\n onClick,\n disabled,\n className,\n}: {\n children: React.ReactNode;\n isActive?: boolean;\n onClick?: () => void;\n disabled?: boolean;\n className?: string;\n}) => {\n const buttonClass = cn(\n \"flex items-center gap-2 p-1.5 text-sm font-medium text-neutral-500 dark:text-neutral-400 text-left bg-transparent w-full rounded outline-none\",\n !isActive && !disabled,\n \"hover:bg-neutral-100 hover:text-neutral-800 dark:hover:bg-neutral-900 dark:hover:text-neutral-200\",\n isActive &&\n !disabled &&\n \"bg-neutral-100 text-neutral-800 dark:bg-neutral-900 dark:text-neutral-200\",\n disabled && \"text-neutral-400 cursor-not-allowed dark:text-neutral-600\",\n className\n );\n\n return (\n <
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/ui/Dropdown/Dropdown.tsx"],"sourcesContent":["import React from \"react\";\nimport { cn } from \"../../../lib/utils/index.js\";\n\nexport const DropdownCategoryTitle = ({\n children,\n}: {\n children: React.ReactNode;\n}) => {\n return (\n <div className=\"text-[.65rem] font-semibold mb-1 uppercase text-neutral-500 dark:text-neutral-400 px-1.5\">\n {children}\n </div>\n );\n};\n\nexport const DropdownButton = ({\n children,\n isActive,\n onClick,\n disabled,\n className,\n}: {\n children: React.ReactNode;\n isActive?: boolean;\n onClick?: () => void;\n disabled?: boolean;\n className?: string;\n}) => {\n const buttonClass = cn(\n \"flex items-center gap-2 p-1.5 text-sm font-medium text-neutral-500 dark:text-neutral-400 text-left bg-transparent w-full rounded outline-none cursor-pointer\",\n !isActive && !disabled,\n \"hover:bg-neutral-100 hover:text-neutral-800 dark:hover:bg-neutral-900 dark:hover:text-neutral-200\",\n isActive &&\n !disabled &&\n \"bg-neutral-100 text-neutral-800 dark:bg-neutral-900 dark:text-neutral-200\",\n disabled && \"text-neutral-400 cursor-not-allowed dark:text-neutral-600\",\n className\n );\n\n return (\n <span\n className={buttonClass}\n // disabled={disabled}\n onClick={(e) => {\n e.preventDefault();\n e.stopPropagation();\n onClick();\n }}\n >\n {children}\n </span>\n );\n};\n"],"names":["React","cn","DropdownCategoryTitle","children","div","className","DropdownButton","isActive","onClick","disabled","buttonClass","span","e","preventDefault","stopPropagation"],"mappings":";AAAA,OAAOA,WAAW,QAAQ;AAC1B,SAASC,EAAE,QAAQ,8BAA8B;AAEjD,OAAO,MAAMC,wBAAwB,CAAC,EACpCC,QAAQ,EAGT;IACC,qBACE,KAACC;QAAIC,WAAU;kBACZF;;AAGP,EAAE;AAEF,OAAO,MAAMG,iBAAiB,CAAC,EAC7BH,QAAQ,EACRI,QAAQ,EACRC,OAAO,EACPC,QAAQ,EACRJ,SAAS,EAOV;IACC,MAAMK,cAAcT,GAClB,gKACA,CAACM,YAAY,CAACE,UACd,qGACAF,YACE,CAACE,YACD,6EACFA,YAAY,6DACZJ;IAGF,qBACE,KAACM;QACCN,WAAWK;QACX,sBAAsB;QACtBF,SAAS,CAACI;YACRA,EAAEC,cAAc;YAChBD,EAAEE,eAAe;YACjBN;QACF;kBAECL;;AAGP,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/features/ui/Toolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAc,MAAM,OAAO,CAAC;AAEpE,OAAO,
|
|
1
|
+
{"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/features/ui/Toolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAc,MAAM,OAAO,CAAC;AAEpE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAKjD,MAAM,MAAM,mBAAmB,GAAG;IAChC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;AA+B9B,MAAM,MAAM,mBAAmB,GAAG;IAChC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;AAkB9B,MAAM,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,GAAG;IACzE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,UAAU,CAAC,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;IACvC,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;CAClC,CAAC;AA6CF,eAAO,MAAM,OAAO;;;;iBAnDT,OAAO;0BACE,MAAM;kBACd,MAAM;0BACE,MAAM,EAAE;qBACb,WAAW,CAAC,YAAY,CAAC;kBAC5B,WAAW,CAAC,SAAS,CAAC;;CAkDjC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import { cn } from "../../lib/utils/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { SpanButton } from "./Button/SpanButton.js";
|
|
5
5
|
import { Surface } from "./Surface.js";
|
|
6
6
|
import Tooltip from "./Tooltip/index.js";
|
|
7
7
|
const ToolbarWrapper = /*#__PURE__*/ forwardRef(({ shouldShowContent = true, children, isVertical = false, className, ...rest }, ref)=>{
|
|
@@ -25,8 +25,7 @@ const ToolbarDivider = /*#__PURE__*/ forwardRef(({ horizontal, className, ...res
|
|
|
25
25
|
ToolbarDivider.displayName = "Toolbar.Divider";
|
|
26
26
|
const ToolbarButton = /*#__PURE__*/ forwardRef(({ children, buttonSize = "icon", variant = "ghost", className, tooltip, tooltipShortcut, activeClassname, ...rest }, ref)=>{
|
|
27
27
|
const buttonClass = cn("gap-1 min-w-[2rem] px-2 w-auto", className);
|
|
28
|
-
const content = /*#__PURE__*/ _jsx(
|
|
29
|
-
type: "button",
|
|
28
|
+
const content = /*#__PURE__*/ _jsx(SpanButton, {
|
|
30
29
|
activeClassname: activeClassname,
|
|
31
30
|
className: buttonClass,
|
|
32
31
|
variant: variant,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/features/ui/Toolbar.tsx"],"sourcesContent":["import { ButtonHTMLAttributes, HTMLProps, forwardRef } from \"react\";\nimport { cn } from \"../../lib/utils/index.js\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/features/ui/Toolbar.tsx"],"sourcesContent":["import { ButtonHTMLAttributes, HTMLProps, forwardRef } from \"react\";\nimport { cn } from \"../../lib/utils/index.js\";\nimport { ButtonProps } from \"./Button/Button.js\";\nimport { SpanButton } from \"./Button/SpanButton.js\";\nimport { Surface } from \"./Surface.js\";\nimport Tooltip from \"./Tooltip/index.js\";\n\nexport type ToolbarWrapperProps = {\n shouldShowContent?: boolean;\n isVertical?: boolean;\n} & HTMLProps<HTMLDivElement>;\n\nconst ToolbarWrapper = forwardRef<HTMLDivElement, ToolbarWrapperProps>(\n (\n {\n shouldShowContent = true,\n children,\n isVertical = false,\n className,\n ...rest\n },\n ref\n ) => {\n const toolbarClassName = cn(\n \"text-black inline-flex h-full leading-none gap-0.5\",\n isVertical ? \"flex-col p-2\" : \"flex-row p-1 items-center\",\n className\n );\n\n return (\n shouldShowContent && (\n <Surface className={toolbarClassName} {...rest} ref={ref}>\n {children}\n </Surface>\n )\n );\n }\n);\n\nToolbarWrapper.displayName = \"Toolbar\";\n\nexport type ToolbarDividerProps = {\n horizontal?: boolean;\n} & HTMLProps<HTMLDivElement>;\n\nconst ToolbarDivider = forwardRef<HTMLDivElement, ToolbarDividerProps>(\n ({ horizontal, className, ...rest }, ref) => {\n const dividerClassName = cn(\n \"bg-neutral-200 dark:bg-neutral-800\",\n horizontal\n ? \"w-full min-w-[1.5rem] h-[1px] my-1 first:mt-0 last:mt-0\"\n : \"h-full min-h-[1.5rem] w-[1px] mx-1 first:ml-0 last:mr-0\",\n className\n );\n\n return <div className={dividerClassName} ref={ref} {...rest} />;\n }\n);\n\nToolbarDivider.displayName = \"Toolbar.Divider\";\n\nexport type ToolbarButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {\n active?: boolean;\n activeClassname?: string;\n tooltip?: string;\n tooltipShortcut?: string[];\n buttonSize?: ButtonProps[\"buttonSize\"];\n variant?: ButtonProps[\"variant\"];\n};\n\nconst ToolbarButton = forwardRef<HTMLButtonElement, ToolbarButtonProps>(\n (\n {\n children,\n buttonSize = \"icon\",\n variant = \"ghost\",\n className,\n tooltip,\n tooltipShortcut,\n activeClassname,\n ...rest\n },\n ref\n ) => {\n const buttonClass = cn(\"gap-1 min-w-[2rem] px-2 w-auto\", className);\n\n const content = (\n <SpanButton\n activeClassname={activeClassname}\n className={buttonClass}\n variant={variant}\n buttonSize={buttonSize}\n ref={ref}\n {...rest}\n >\n {children}\n </SpanButton>\n );\n\n if (tooltip) {\n return (\n <Tooltip title={tooltip} shortcut={tooltipShortcut}>\n {content}\n </Tooltip>\n );\n }\n\n return content;\n }\n);\n\nToolbarButton.displayName = \"ToolbarButton\";\n\nexport const Toolbar = {\n Wrapper: ToolbarWrapper,\n Divider: ToolbarDivider,\n Button: ToolbarButton,\n};\n"],"names":["forwardRef","cn","SpanButton","Surface","Tooltip","ToolbarWrapper","shouldShowContent","children","isVertical","className","rest","ref","toolbarClassName","displayName","ToolbarDivider","horizontal","dividerClassName","div","ToolbarButton","buttonSize","variant","tooltip","tooltipShortcut","activeClassname","buttonClass","content","title","shortcut","Toolbar","Wrapper","Divider","Button"],"mappings":";AAAA,SAA0CA,UAAU,QAAQ,QAAQ;AACpE,SAASC,EAAE,QAAQ,2BAA2B;AAE9C,SAASC,UAAU,QAAQ,yBAAyB;AACpD,SAASC,OAAO,QAAQ,eAAe;AACvC,OAAOC,aAAa,qBAAqB;AAOzC,MAAMC,+BAAiBL,WACrB,CACE,EACEM,oBAAoB,IAAI,EACxBC,QAAQ,EACRC,aAAa,KAAK,EAClBC,SAAS,EACT,GAAGC,MACJ,EACDC;IAEA,MAAMC,mBAAmBX,GACvB,sDACAO,aAAa,iBAAiB,6BAC9BC;IAGF,OACEH,mCACE,KAACH;QAAQM,WAAWG;QAAmB,GAAGF,IAAI;QAAEC,KAAKA;kBAClDJ;;AAIT;AAGFF,eAAeQ,WAAW,GAAG;AAM7B,MAAMC,+BAAiBd,WACrB,CAAC,EAAEe,UAAU,EAAEN,SAAS,EAAE,GAAGC,MAAM,EAAEC;IACnC,MAAMK,mBAAmBf,GACvB,sCACAc,aACI,4DACA,2DACJN;IAGF,qBAAO,KAACQ;QAAIR,WAAWO;QAAkBL,KAAKA;QAAM,GAAGD,IAAI;;AAC7D;AAGFI,eAAeD,WAAW,GAAG;AAW7B,MAAMK,8BAAgBlB,WACpB,CACE,EACEO,QAAQ,EACRY,aAAa,MAAM,EACnBC,UAAU,OAAO,EACjBX,SAAS,EACTY,OAAO,EACPC,eAAe,EACfC,eAAe,EACf,GAAGb,MACJ,EACDC;IAEA,MAAMa,cAAcvB,GAAG,kCAAkCQ;IAEzD,MAAMgB,wBACJ,KAACvB;QACCqB,iBAAiBA;QACjBd,WAAWe;QACXJ,SAASA;QACTD,YAAYA;QACZR,KAAKA;QACJ,GAAGD,IAAI;kBAEPH;;IAIL,IAAIc,SAAS;QACX,qBACE,KAACjB;YAAQsB,OAAOL;YAASM,UAAUL;sBAChCG;;IAGP;IAEA,OAAOA;AACT;AAGFP,cAAcL,WAAW,GAAG;AAE5B,OAAO,MAAMe,UAAU;IACrBC,SAASxB;IACTyB,SAAShB;IACTiB,QAAQb;AACV,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBlockEditor.d.ts","sourceRoot":"","sources":["../../../../../src/fields/TiptapEditor/hooks/useBlockEditor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAa,MAAM,eAAe,CAAC;AASlD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;KACvB;CACF;AAED,eAAO,MAAM,cAAc,sEAKxB;IACD,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,GAAG,CAAA;KAAE,CAAC;IACrC,YAAY,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IAClC,kBAAkB,EAAE,eAAe,CAAC;IACpC,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACzC;;;;;
|
|
1
|
+
{"version":3,"file":"useBlockEditor.d.ts","sourceRoot":"","sources":["../../../../../src/fields/TiptapEditor/hooks/useBlockEditor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAa,MAAM,eAAe,CAAC;AASlD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;KACvB;CACF;AAED,eAAO,MAAM,cAAc,sEAKxB;IACD,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,GAAG,CAAA;KAAE,CAAC;IACrC,YAAY,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IAClC,kBAAkB,EAAE,eAAe,CAAC;IACpC,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACzC;;;;;CAgGA,CAAC"}
|
|
@@ -20,6 +20,7 @@ export const useBlockEditor = ({ content, handleChange, openAssetHQHandler, addi
|
|
|
20
20
|
const { t, i18n } = useTranslation();
|
|
21
21
|
const editor = useEditor({
|
|
22
22
|
content: content?.json ?? content ?? {},
|
|
23
|
+
immediatelyRender: false,
|
|
23
24
|
autofocus: true,
|
|
24
25
|
onCreate: ({ editor })=>{
|
|
25
26
|
// provider?.on('synced', () => {
|