payload-richtext-tiptap 0.0.102 → 0.0.103
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/AudioBlock/AudioBlock.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/AudioBlock/components/AudioBlockMenu.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/FontSize/FontSize.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/Heading/Heading.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/ImageBlock/ImageBlock.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/ImageBlock/components/ImageBlockMenu.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/InsideLinks/InsideLink.client.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/MultiColumn/Columns.js +3 -3
- package/dist/src/fields/TiptapEditor/extensions/MultiColumn/Columns.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/MultiColumn/menus/ColumnsMenu.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/SlashCommand/MenuList.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/TableOfContentsNode/TableOfContentsNode.d.ts +10 -0
- package/dist/src/fields/TiptapEditor/extensions/TableOfContentsNode/TableOfContentsNode.d.ts.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/TableOfContentsNode/TableOfContentsNode.js +55 -0
- package/dist/src/fields/TiptapEditor/extensions/TableOfContentsNode/TableOfContentsNode.js.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/TableOfContentsNode/index.d.ts +2 -0
- package/dist/src/fields/TiptapEditor/extensions/TableOfContentsNode/index.d.ts.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/TableOfContentsNode/index.js +3 -0
- package/dist/src/fields/TiptapEditor/extensions/TableOfContentsNode/index.js.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/VideoBlock.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockMenu.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/quality-selector/events.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/serverside/ContentEmbedSupport.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/serverside/FacebookServerside.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/serverside/InstagramServerside.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/serverside/LinkedinServerside.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/serverside/TiktokServerside.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/serverside/TwitterBlockServerside.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/serverside/YouTubeServerside.js.map +1 -1
- package/dist/src/fields/TiptapEditor/features/Sidebar/Sidebar.d.ts +8 -0
- package/dist/src/fields/TiptapEditor/features/Sidebar/Sidebar.d.ts.map +1 -0
- package/dist/src/fields/TiptapEditor/features/Sidebar/Sidebar.js +32 -0
- package/dist/src/fields/TiptapEditor/features/Sidebar/Sidebar.js.map +1 -0
- package/dist/src/fields/TiptapEditor/features/Sidebar/index.d.ts +2 -0
- package/dist/src/fields/TiptapEditor/features/Sidebar/index.d.ts.map +1 -0
- package/dist/src/fields/TiptapEditor/features/Sidebar/index.js +3 -0
- package/dist/src/fields/TiptapEditor/features/Sidebar/index.js.map +1 -0
- package/dist/src/fields/TiptapEditor/features/TableOfContents/TableOfContents.d.ts +8 -0
- package/dist/src/fields/TiptapEditor/features/TableOfContents/TableOfContents.d.ts.map +1 -0
- package/dist/src/fields/TiptapEditor/features/TableOfContents/TableOfContents.js +57 -0
- package/dist/src/fields/TiptapEditor/features/TableOfContents/TableOfContents.js.map +1 -0
- package/dist/src/fields/TiptapEditor/features/TableOfContents/index.d.ts +2 -0
- package/dist/src/fields/TiptapEditor/features/TableOfContents/index.d.ts.map +1 -0
- package/dist/src/fields/TiptapEditor/features/TableOfContents/index.js +3 -0
- package/dist/src/fields/TiptapEditor/features/TableOfContents/index.js.map +1 -0
- package/dist/src/fields/TiptapEditor/features/menus/TextMenu/AITextMenu.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/features/menus/TextMenu/AITextMenu.js +5 -1
- package/dist/src/fields/TiptapEditor/features/menus/TextMenu/AITextMenu.js.map +1 -1
- package/dist/src/fields/TiptapEditor/features/menus/TextMenu/TextMenu.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/features/menus/TextMenu/TextMenu.js +5 -1
- package/dist/src/fields/TiptapEditor/features/menus/TextMenu/TextMenu.js.map +1 -1
- package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/FontFamilyPicker.js.map +1 -1
- package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/FontSizePicker.js.map +1 -1
- package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/ai-selector-commands.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/ai-selector-commands.js +14 -2
- package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/ai-selector-commands.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 +2 -2
- package/dist/src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.js.map +1 -1
- package/dist/src/fields/TiptapEditor/features/panels/AIEditorPanel/AIEditorPanel.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/features/panels/AIEditorPanel/AIEditorPanel.js +2 -2
- package/dist/src/fields/TiptapEditor/features/panels/AIEditorPanel/AIEditorPanel.js.map +1 -1
- package/dist/src/fields/TiptapEditor/features/panels/AIEditorPanel/utils.js.map +1 -1
- package/dist/src/fields/TiptapEditor/hooks/useBlockEditor.js.map +1 -1
- package/dist/src/fields/TiptapEditor/lib/utils/cssVar.js.map +1 -1
- package/dist/src/styles.css +53 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +28 -25
package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/ai-selector-commands.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../src/fields/TiptapEditor/features/menus/TextMenu/components/ai-selector-commands.tsx"],"sourcesContent":["import { useLocale } from \"@payloadcms/ui/providers/Locale\";\nimport * as Popover from \"@radix-ui/react-popover\";\nimport { Editor } from \"@tiptap/react\";\nimport i18next from \"i18next\";\nimport {\n ArrowDownWideNarrow,\n CheckCheck,\n ChevronDown,\n Languages,\n RefreshCcwDot,\n StepForward,\n WrapText,\n} from \"lucide-react\";\nimport { languages } from \"../../../../lib/constants.js\";\nimport { getPrevText } from \"../../../../lib/utils/index.js\";\nimport { DropdownCategoryTitle } from \"../../../ui/Dropdown/Dropdown.js\";\nimport { Icon } from \"../../../ui/Icon.js\";\nimport { Surface } from \"../../../ui/Surface.js\";\nimport { Toolbar } from \"../../../ui/Toolbar.js\";\nconst options = [\n // {\n // value: 'translate',\n // label: 'Translate text',\n // icon: WrapText,\n // },\n {\n value: \"summarize\",\n label: \"Summarize text\",\n icon: WrapText,\n },\n {\n value: \"rewrite\",\n label: \"Rewrite into Axios\",\n icon: WrapText,\n },\n {\n value: \"improve\",\n label: \"Improve writing\",\n icon: RefreshCcwDot,\n },\n\n {\n value: \"fix\",\n label: \"Fix grammar\",\n icon: CheckCheck,\n },\n {\n value: \"shorter\",\n label: \"Make shorter\",\n icon: ArrowDownWideNarrow,\n },\n {\n value: \"longer\",\n label: \"Make longer\",\n icon: WrapText,\n },\n];\n\ninterface AISelectorCommandsProps {\n editor: Editor;\n messages?: string;\n onSelect: (\n value: string,\n options: { option: string; language?: string, selection?: JSON }\n ) => void;\n}\n\nconst AISelectorCommands = ({\n messages,\n onSelect,\n editor,\n}: AISelectorCommandsProps) => {\n const { code } = useLocale();\n const editorSelection = editor?.state?.selection?.content?.()?.content?.toJSON()\n\n return (\n <>\n <DropdownCategoryTitle>Edit or review selection</DropdownCategoryTitle>\n {editorSelection && <Popover.Root>\n <Popover.Trigger asChild>\n <Toolbar.Button\n className=\"gap-2 px-4 w-full flex justify-start \"\n type=\"button\"\n // active={!!states.currentHighlight}\n tooltip={i18next.t(\"highlightText\") || \"Highlight text\"}\n >\n <Icon icon={Languages} className=\"h-4 w-4 text-blue-500\" />\n Translate text\n <Icon icon={ChevronDown} className=\"h-4 w-4 text-blue-500\" />\n </Toolbar.Button>\n </Popover.Trigger>\n <Popover.Content side=\"right\" align=\"start\" sideOffset={8} asChild>\n <Surface className=\"flex flex-col min-w-[15rem] p-2 max-h-[20rem] overflow-auto\">\n <DropdownCategoryTitle>Languages</DropdownCategoryTitle>\n\n {languages.map((lang) => (\n <Toolbar.Button\n onClick={() => {\n const editorSelection = editor.state.selection.content().content.toJSON()\n\n onSelect(\"\", {\n option: \"translate\",\n language: lang.value,\n selection: editorSelection\n });\n }}\n className=\"gap-2 px-4 w-full flex justify-start \"\n key={lang.value}\n >\n {lang.label}\n </Toolbar.Button>\n ))}\n </Surface>\n </Popover.Content>\n </Popover.Root>}\n\n {options.map((option) => (\n <Toolbar.Button\n // onSelect={(value) => {\n // const slice = editor.state.selection.content()\n // const text = editor?.storage?.markdown?.serializer.serialize(slice.content)\n // onSelect(text, option.value)\n // }}\n onClick={() => {\n const { from, to, empty } = editor.state.selection;\n const editorSelection = editor.state.selection.content().content.toJSON()\n\n const content = messages\n ? messages ?? \"\"\n : editor.state.doc.textBetween(from, to, \" \");\n onSelect(content, {\n option: option.value,\n language: editor?.storage?.aiCommand?.language ?? code ?? \"en\",\n });\n }}\n className=\" gap-2 px-4 w-full flex justify-start\"\n key={option.value}\n value={option.value}\n >\n <option.icon className=\"h-4 w-4 text-blue-500\" />\n {option.label}\n </Toolbar.Button>\n ))}\n <Toolbar.Divider horizontal />\n <DropdownCategoryTitle>Use AI to do more</DropdownCategoryTitle>\n <Toolbar.Button\n onClick={() => {\n const editorSelection = editor.state.selection.content().content.toJSON()\n\n const text = messages\n ? messages\n : getPrevText(editor, { chars: 5000 });\n onSelect(text, {\n option: \"continue\",\n language: editor?.storage?.aiCommand?.language ?? code ?? \"en\",\n });\n }}\n value=\"continue\"\n className=\"gap-2 px-4 w-full flex justify-start\"\n >\n <StepForward className=\"h-4 w-4 text-blue-500\" />\n Continue writing\n </Toolbar.Button>\n </>\n );\n};\n\nexport default AISelectorCommands;\n"],"names":["useLocale","Popover","i18next","ArrowDownWideNarrow","CheckCheck","ChevronDown","Languages","RefreshCcwDot","StepForward","WrapText","languages","getPrevText","DropdownCategoryTitle","Icon","Surface","Toolbar","options","value","label","icon","AISelectorCommands","messages","onSelect","editor","code","editorSelection","state","selection","content","toJSON","Root","Trigger","asChild","Button","className","type","tooltip","t","Content","side","align","sideOffset","map","lang","onClick","option","language","from","to","empty","doc","textBetween","storage","aiCommand","Divider","horizontal","text","chars"],"mappings":";AAAA,SAASA,SAAS,QAAQ,kCAAkC;AAC5D,YAAYC,aAAa,0BAA0B;AAEnD,OAAOC,aAAa,UAAU;AAC9B,SACEC,mBAAmB,EACnBC,UAAU,EACVC,WAAW,EACXC,SAAS,EACTC,aAAa,EACbC,WAAW,EACXC,QAAQ,QACH,eAAe;AACtB,SAASC,SAAS,QAAQ,+BAA+B;AACzD,SAASC,WAAW,QAAQ,iCAAiC;AAC7D,SAASC,qBAAqB,QAAQ,mCAAmC;AACzE,SAASC,IAAI,QAAQ,sBAAsB;AAC3C,SAASC,OAAO,QAAQ,yBAAyB;AACjD,SAASC,OAAO,QAAQ,yBAAyB;AACjD,MAAMC,UAAU;IACd,IAAI;IACJ,wBAAwB;IACxB,6BAA6B;IAC7B,oBAAoB;IACpB,KAAK;IACL;QACEC,OAAO;QACPC,OAAO;QACPC,MAAMV;IACR;IACA;QACEQ,OAAO;QACPC,OAAO;QACPC,MAAMV;IACR;IACA;QACEQ,OAAO;QACPC,OAAO;QACPC,MAAMZ;IACR;IAEA;QACEU,OAAO;QACPC,OAAO;QACPC,MAAMf;IACR;IACA;QACEa,OAAO;QACPC,OAAO;QACPC,MAAMhB;IACR;IACA;QACEc,OAAO;QACPC,OAAO;QACPC,MAAMV;IACR;CACD;AAWD,MAAMW,qBAAqB,CAAC,EAC1BC,QAAQ,EACRC,QAAQ,EACRC,MAAM,EACkB;IACxB,MAAM,EAAEC,IAAI,EAAE,GAAGxB;IACjB,MAAMyB,kBAAkBF,QAAQG,OAAOC,WAAWC,aAAaA,SAASC;IAExE,qBACE;;0BACE,KAACjB;0BAAsB;;YACtBa,iCAAmB,MAACxB,QAAQ6B,IAAI;;kCAC/B,KAAC7B,QAAQ8B,OAAO;wBAACC,OAAO;kCACtB,cAAA,MAACjB,QAAQkB,MAAM;4BACbC,WAAU;4BACVC,MAAK;4BACL,qCAAqC;4BACrCC,SAASlC,QAAQmC,CAAC,CAAC,oBAAoB;;8CAEvC,KAACxB;oCAAKM,MAAMb;oCAAW4B,WAAU;;gCAA0B;8CAE3D,KAACrB;oCAAKM,MAAMd;oCAAa6B,WAAU;;;;;kCAGvC,KAACjC,
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../src/fields/TiptapEditor/features/menus/TextMenu/components/ai-selector-commands.tsx"],"sourcesContent":["import { useLocale } from \"@payloadcms/ui/providers/Locale\";\nimport * as Popover from \"@radix-ui/react-popover\";\nimport { Editor } from \"@tiptap/react\";\nimport i18next from \"i18next\";\nimport {\n ArrowDownWideNarrow,\n CheckCheck,\n ChevronDown,\n Languages,\n RefreshCcwDot,\n StepForward,\n WrapText,\n} from \"lucide-react\";\nimport { languages } from \"../../../../lib/constants.js\";\nimport { getPrevText } from \"../../../../lib/utils/index.js\";\nimport { DropdownCategoryTitle } from \"../../../ui/Dropdown/Dropdown.js\";\nimport { Icon } from \"../../../ui/Icon.js\";\nimport { Surface } from \"../../../ui/Surface.js\";\nimport { Toolbar } from \"../../../ui/Toolbar.js\";\nconst options = [\n // {\n // value: 'translate',\n // label: 'Translate text',\n // icon: WrapText,\n // },\n {\n value: \"summarize\",\n label: \"Summarize text\",\n icon: WrapText,\n },\n {\n value: \"rewrite\",\n label: \"Rewrite into Axios\",\n icon: WrapText,\n },\n {\n value: \"improve\",\n label: \"Improve writing\",\n icon: RefreshCcwDot,\n },\n\n {\n value: \"fix\",\n label: \"Fix grammar\",\n icon: CheckCheck,\n },\n {\n value: \"shorter\",\n label: \"Make shorter\",\n icon: ArrowDownWideNarrow,\n },\n {\n value: \"longer\",\n label: \"Make longer\",\n icon: WrapText,\n },\n];\n\ninterface AISelectorCommandsProps {\n editor: Editor;\n messages?: string;\n onSelect: (\n value: string,\n options: { option: string; language?: string, selection?: JSON }\n ) => void;\n}\n\nconst AISelectorCommands = ({\n messages,\n onSelect,\n editor,\n}: AISelectorCommandsProps) => {\n const { code } = useLocale();\n const editorSelection = editor?.state?.selection?.content?.()?.content?.toJSON()\n\n return (\n <>\n <DropdownCategoryTitle>Edit or review selection</DropdownCategoryTitle>\n {editorSelection && <Popover.Root>\n <Popover.Trigger asChild>\n <Toolbar.Button\n className=\"gap-2 px-4 w-full flex justify-start \"\n type=\"button\"\n // active={!!states.currentHighlight}\n tooltip={i18next.t(\"highlightText\") || \"Highlight text\"}\n >\n <Icon icon={Languages} className=\"h-4 w-4 text-blue-500\" />\n Translate text\n <span className=\"text-xs ml-1 px-2 py-0.5 bg-blue-100 text-blue-700 rounded-full dark:bg-blue-700 dark:text-blue-100 align-baseline\">\n Beta\n </span>\n <Icon icon={ChevronDown} className=\"h-4 w-4 text-blue-500\" />\n </Toolbar.Button>\n </Popover.Trigger>\n <Popover.Content side=\"right\" align=\"start\" sideOffset={8} asChild>\n <Surface className=\"flex flex-col min-w-[15rem] p-2 max-h-[20rem] overflow-auto\">\n <DropdownCategoryTitle>Languages</DropdownCategoryTitle>\n\n {languages.map((lang) => (\n <Toolbar.Button\n onClick={() => {\n const editorSelection = editor.state.selection.content().content.toJSON()\n\n onSelect(\"\", {\n option: \"translate\",\n language: lang.value,\n selection: editorSelection\n });\n }}\n className=\"gap-2 px-4 w-full flex justify-start \"\n key={lang.value}\n >\n {lang.label}\n </Toolbar.Button>\n ))}\n </Surface>\n </Popover.Content>\n </Popover.Root>}\n\n {options.map((option) => (\n <Toolbar.Button\n // onSelect={(value) => {\n // const slice = editor.state.selection.content()\n // const text = editor?.storage?.markdown?.serializer.serialize(slice.content)\n // onSelect(text, option.value)\n // }}\n onClick={() => {\n const { from, to, empty } = editor.state.selection;\n const editorSelection = editor.state.selection.content().content.toJSON()\n\n const content = messages\n ? messages ?? \"\"\n : editor.state.doc.textBetween(from, to, \" \");\n onSelect(content, {\n option: option.value,\n language: editor?.storage?.aiCommand?.language ?? code ?? \"en\",\n });\n }}\n className=\" gap-2 px-4 w-full flex justify-start\"\n key={option.value}\n value={option.value}\n >\n <option.icon className=\"h-4 w-4 text-blue-500\" />\n {option.label}\n <span className=\"text-xs ml-1 px-2 py-0.5 bg-blue-100 text-blue-700 rounded-full dark:bg-blue-700 dark:text-blue-100 align-baseline\">\n Beta\n </span>\n </Toolbar.Button>\n ))}\n <Toolbar.Divider horizontal />\n <DropdownCategoryTitle>Use AI to do more</DropdownCategoryTitle>\n <Toolbar.Button\n onClick={() => {\n const editorSelection = editor.state.selection.content().content.toJSON()\n\n const text = messages\n ? messages\n : getPrevText(editor, { chars: 5000 });\n onSelect(text, {\n option: \"continue\",\n language: editor?.storage?.aiCommand?.language ?? code ?? \"en\",\n });\n }}\n value=\"continue\"\n className=\"gap-2 px-4 w-full flex justify-start\"\n >\n <StepForward className=\"h-4 w-4 text-blue-500\" />\n Continue writing\n <span className=\"text-xs ml-1 px-2 py-0.5 bg-blue-100 text-blue-700 rounded-full dark:bg-blue-700 dark:text-blue-100 align-baseline\">\n Beta\n </span>\n </Toolbar.Button>\n </>\n );\n};\n\nexport default AISelectorCommands;\n"],"names":["useLocale","Popover","i18next","ArrowDownWideNarrow","CheckCheck","ChevronDown","Languages","RefreshCcwDot","StepForward","WrapText","languages","getPrevText","DropdownCategoryTitle","Icon","Surface","Toolbar","options","value","label","icon","AISelectorCommands","messages","onSelect","editor","code","editorSelection","state","selection","content","toJSON","Root","Trigger","asChild","Button","className","type","tooltip","t","span","Content","side","align","sideOffset","map","lang","onClick","option","language","from","to","empty","doc","textBetween","storage","aiCommand","Divider","horizontal","text","chars"],"mappings":";AAAA,SAASA,SAAS,QAAQ,kCAAkC;AAC5D,YAAYC,aAAa,0BAA0B;AAEnD,OAAOC,aAAa,UAAU;AAC9B,SACEC,mBAAmB,EACnBC,UAAU,EACVC,WAAW,EACXC,SAAS,EACTC,aAAa,EACbC,WAAW,EACXC,QAAQ,QACH,eAAe;AACtB,SAASC,SAAS,QAAQ,+BAA+B;AACzD,SAASC,WAAW,QAAQ,iCAAiC;AAC7D,SAASC,qBAAqB,QAAQ,mCAAmC;AACzE,SAASC,IAAI,QAAQ,sBAAsB;AAC3C,SAASC,OAAO,QAAQ,yBAAyB;AACjD,SAASC,OAAO,QAAQ,yBAAyB;AACjD,MAAMC,UAAU;IACd,IAAI;IACJ,wBAAwB;IACxB,6BAA6B;IAC7B,oBAAoB;IACpB,KAAK;IACL;QACEC,OAAO;QACPC,OAAO;QACPC,MAAMV;IACR;IACA;QACEQ,OAAO;QACPC,OAAO;QACPC,MAAMV;IACR;IACA;QACEQ,OAAO;QACPC,OAAO;QACPC,MAAMZ;IACR;IAEA;QACEU,OAAO;QACPC,OAAO;QACPC,MAAMf;IACR;IACA;QACEa,OAAO;QACPC,OAAO;QACPC,MAAMhB;IACR;IACA;QACEc,OAAO;QACPC,OAAO;QACPC,MAAMV;IACR;CACD;AAWD,MAAMW,qBAAqB,CAAC,EAC1BC,QAAQ,EACRC,QAAQ,EACRC,MAAM,EACkB;IACxB,MAAM,EAAEC,IAAI,EAAE,GAAGxB;IACjB,MAAMyB,kBAAkBF,QAAQG,OAAOC,WAAWC,aAAaA,SAASC;IAExE,qBACE;;0BACE,KAACjB;0BAAsB;;YACtBa,iCAAmB,MAACxB,QAAQ6B,IAAI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SAASM,SAAS;4BAChBkB,QAAQA,OAAO7B,KAAK;4BACpB8B,UAAUxB,QAAQ8B,SAASC,WAAWP,YAAYvB,QAAQ;wBAC5D;oBACF;oBACAU,WAAU;oBAEVjB,OAAO6B,OAAO7B,KAAK;;sCAEnB,KAAC6B,OAAO3B,IAAI;4BAACe,WAAU;;wBACtBY,OAAO5B,KAAK;sCACb,KAACoB;4BAAKJ,WAAU;sCAAqH;;;mBALhIY,OAAO7B,KAAK;0BAUrB,KAACF,QAAQwC,OAAO;gBAACC,UAAU;;0BAC3B,KAAC5C;0BAAsB;;0BACvB,MAACG,QAAQkB,MAAM;gBACbY,SAAS;oBACP,MAAMpB,kBAAkBF,OAAOG,KAAK,CAACC,SAAS,CAACC,OAAO,GAAGA,OAAO,CAACC,MAAM;oBAEvE,MAAM4B,OAAOpC,WACTA,WACAV,YAAYY,QAAQ;wBAAEmC,OAAO;oBAAK;oBACtCpC,SAASmC,MAAM;wBACbX,QAAQ;wBACRC,UAAUxB,QAAQ8B,SAASC,WAAWP,YAAYvB,QAAQ;oBAC5D;gBACF;gBACAP,OAAM;gBACNiB,WAAU;;kCAEV,KAAC1B;wBAAY0B,WAAU;;oBAA0B;kCAEjD,KAACI;wBAAKJ,WAAU;kCAAqH;;;;;;AAM7I;AAEA,eAAed,mBAAmB"}
|
|
@@ -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;AAGvC,OAAO,EAEL,KAAK,EACN,MAAM,uDAAuD,CAAC;AAY/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;AAGvC,OAAO,EAEL,KAAK,EACN,MAAM,uDAAuD,CAAC;AAY/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,qFAoT1B,CAAC"}
|
|
@@ -194,7 +194,7 @@ export const AICommandPanel = /*#__PURE__*/ forwardRef(({ editor, onOpenChange,
|
|
|
194
194
|
/*#__PURE__*/ _jsx(Sparkles, {
|
|
195
195
|
className: "mr-2 h-4 w-4 shrink-0 "
|
|
196
196
|
}),
|
|
197
|
-
"AI is thinking",
|
|
197
|
+
"AI (Beta) is thinking",
|
|
198
198
|
/*#__PURE__*/ _jsx("div", {
|
|
199
199
|
className: "ml-2 mt-1",
|
|
200
200
|
children: /*#__PURE__*/ _jsx(CrazySpinner, {})
|
|
@@ -219,7 +219,7 @@ export const AICommandPanel = /*#__PURE__*/ forwardRef(({ editor, onOpenChange,
|
|
|
219
219
|
editor.storage.aiCommand.userPrompt = e.target.value;
|
|
220
220
|
setInputValue(e.target.value);
|
|
221
221
|
},
|
|
222
|
-
placeholder: hasCompletion ? i18next.t("tellAiPlaceholder") || "Tell AI what to do next" : i18next.t("askAiPlaceholder") || "Ask AI to edit or generate...",
|
|
222
|
+
placeholder: hasCompletion ? i18next.t("tellAiPlaceholder") || "Tell AI (Beta) what to do next" : i18next.t("askAiPlaceholder") || "Ask AI (Beta) to edit or generate...",
|
|
223
223
|
autoFocus: true,
|
|
224
224
|
// onFocus={() => {
|
|
225
225
|
// addAIHighlight(editor)}}
|
|
@@ -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 i18next from \"i18next\";\nimport {\n Command,\n Group,\n} from \"src/fields/TiptapEditor/extensions/AICommand/types.js\";\nimport { extractMarkdown } from \"../../../lib/extract.js\";\nimport { getPrevText } from \"../../../lib/utils/index.js\";\nimport AISelectorCommands from \"../../menus/TextMenu/components/ai-selector-commands.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 { checkJsonCompletion, formatCompletion } from \"../AIEditorPanel/utils.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\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 const editorSelection = editor.state.selection.content().content.toJSON()\n\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 selection: editorSelection\n },\n }).then(() => setInputValue(\"\"));\n }, [code, inputValue, completion]);\n\n useEffect(() => {\n if (userPrompt) setInputValue(userPrompt);\n }, [userPrompt]);\n useEffect(() => {\n if (!isLoading && hasCompletion) {\n editor.storage.aiCommand.completion = completion;\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 ${hasCompletion ? \"-mt-72\" : \"\"\n }`}\n style={{\n width: boundigClient?.width,\n }}\n >\n <>\n {(hasCompletion && completion?.length > 10 && (checkJsonCompletion(completion) ? !isLoading : true)) && (\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={i18next.dir()}\n >\n <Markdown>{checkJsonCompletion(completion) ? extractMarkdown({ type: 'doc', content: formatCompletion(completion) as any }) : completion}</Markdown>\n\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 ? i18next.t(\"tellAiPlaceholder\") || \"Tell AI what to do next\"\n : i18next.t(\"askAiPlaceholder\") || \"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","i18next","extractMarkdown","getPrevText","AISelectorCommands","CrazySpinner","DropdownButton","Icon","ScrollArea","Surface","Toolbar","checkJsonCompletion","formatCompletion","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","editorSelection","state","selection","content","toJSON","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","type","resize","value","onChange","target","placeholder","t","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;AAG5D,OAAOC,aAAa,UAAU;AAK9B,SAASC,eAAe,QAAQ,0BAA0B;AAC1D,SAASC,WAAW,QAAQ,8BAA8B;AAC1D,OAAOC,wBAAwB,0DAA0D;AACzF,OAAOC,kBAAkB,4BAA4B;AACrD,SAASC,cAAc,QAAQ,gCAAgC;AAC/D,SAASC,IAAI,QAAQ,mBAAmB;AACxC,SAASC,UAAU,QAAQ,0BAA0B;AACrD,SAASC,OAAO,QAAQ,sBAAsB;AAC9C,SAASC,OAAO,QAAQ,sBAAsB;AAC9C,SAASC,mBAAmB,EAAEC,gBAAgB,QAAQ,4BAA4B;AASlF,OAAO,MAAMC,+BAAiBrB,WAC5B,CACE,EACEsB,MAAM,EACNC,YAAY,EACZC,UAAU,EACVC,KAAK,EACL,GAAGC,WACiB,EACtBC;IAEA,MAAM,CAACC,YAAYC,cAAc,GAAGxB,SAASmB,cAAc;IAC3D,MAAM,EAAEM,IAAI,EAAE,GAAGtB;IACjB,MAAM,EAAEuB,IAAI,EAAE,GAAGT;IACjB,MAAMU,kBAAkB5B,OAAuB;IAC/C,MAAM6B,aAAa7B,OAA0B;IAC7C,MAAM,CAAC8B,oBAAoBC,sBAAsB,GAAG9B,SA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;4BAChB7D,SAASmD,OAAO;gCAAEhC,MAAM0C;4BAAQ;wBAClC;yBAGFhF,MAAMiF,GAAG,CAAC,CAACC,OAAOjC,2BAChB,MAAC3E,MAAM6G,QAAQ;;8CACb,KAACjB;oCACCH,WAAU;8CAGTmB,MAAMnC,KAAK;mCAFP,GAAGmC,MAAMnC,KAAK,EAAE;gCAItBmC,MAAM/B,QAAQ,CAAC8B,GAAG,CACjB,CAACzC,SAAkBU,6BACjB,MAAC7D;wCAEC+F,UACE3E,uBAAuBwC,cACvBtC,yBAAyBuC;wCAE3B2B,SAASf,0BACPb,YACAC;;0DAGF,KAAC5D;gDAAK+F,MAAM7C,QAAQ6C,IAAI;gDAAEtB,WAAU;;4CACnCvB,QAAQ8C,KAAK;;uCAXT,GAAG9C,QAAQ8C,KAAK,EAAE;;2BAVV,GAAGJ,MAAMnC,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 i18next from \"i18next\";\nimport {\n Command,\n Group,\n} from \"src/fields/TiptapEditor/extensions/AICommand/types.js\";\nimport { extractMarkdown } from \"../../../lib/extract.js\";\nimport { getPrevText } from \"../../../lib/utils/index.js\";\nimport AISelectorCommands from \"../../menus/TextMenu/components/ai-selector-commands.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 { checkJsonCompletion, formatCompletion } from \"../AIEditorPanel/utils.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\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 const editorSelection = editor.state.selection.content().content.toJSON()\n\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 selection: editorSelection\n },\n }).then(() => setInputValue(\"\"));\n }, [code, inputValue, completion]);\n\n useEffect(() => {\n if (userPrompt) setInputValue(userPrompt);\n }, [userPrompt]);\n useEffect(() => {\n if (!isLoading && hasCompletion) {\n editor.storage.aiCommand.completion = completion;\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 ${hasCompletion ? \"-mt-72\" : \"\"\n }`}\n style={{\n width: boundigClient?.width,\n }}\n >\n <>\n {(hasCompletion && completion?.length > 10 && (checkJsonCompletion(completion) ? !isLoading : true)) && (\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={i18next.dir()}\n >\n <Markdown>{checkJsonCompletion(completion) ? extractMarkdown({ type: 'doc', content: formatCompletion(completion) as any }) : completion}</Markdown>\n\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 (Beta) 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 <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 ? i18next.t(\"tellAiPlaceholder\") || \"Tell AI (Beta) what to do next\"\n : i18next.t(\"askAiPlaceholder\") || \"Ask AI (Beta) 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","i18next","extractMarkdown","getPrevText","AISelectorCommands","CrazySpinner","DropdownButton","Icon","ScrollArea","Surface","Toolbar","checkJsonCompletion","formatCompletion","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","editorSelection","state","selection","content","toJSON","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","type","resize","value","onChange","target","placeholder","t","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;AAG5D,OAAOC,aAAa,UAAU;AAK9B,SAASC,eAAe,QAAQ,0BAA0B;AAC1D,SAASC,WAAW,QAAQ,8BAA8B;AAC1D,OAAOC,wBAAwB,0DAA0D;AACzF,OAAOC,kBAAkB,4BAA4B;AACrD,SAASC,cAAc,QAAQ,gCAAgC;AAC/D,SAASC,IAAI,QAAQ,mBAAmB;AACxC,SAASC,UAAU,QAAQ,0BAA0B;AACrD,SAASC,OAAO,QAAQ,sBAAsB;AAC9C,SAASC,OAAO,QAAQ,sBAAsB;AAC9C,SAASC,mBAAmB,EAAEC,gBAAgB,QAAQ,4BAA4B;AASlF,OAAO,MAAMC,+BAAiBrB,WAC5B,CACE,EACEsB,MAAM,EACNC,YAAY,EACZC,UAAU,EACVC,KAAK,EACL,GAAGC,WACiB,EACtBC;IAEA,MAAM,CA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Ac;wCAEd,4GAA4G;wCAC5GC,SAAS7C;kDAET,cAAA,KAAC5D;;;;;;;;YAOZ,CAACgD,2BACA,KAAC5B;gBACCU,KAAKK;gBACLwD,WAAU;0BAEV,cAAA,KAACG;oBAAIH,WAAU;8BACZjC,8BACC,KAAC3C;wBACCU,QAAQA;wBACRiF,UAAU5D;wBACV6D,UAAU,CAACT,OAAOU;4BAChB7D,SAASmD,OAAO;gCAAEhC,MAAM0C;4BAAQ;wBAClC;yBAGFhF,MAAMiF,GAAG,CAAC,CAACC,OAAOjC,2BAChB,MAAC3E,MAAM6G,QAAQ;;8CACb,KAACjB;oCACCH,WAAU;8CAGTmB,MAAMnC,KAAK;mCAFP,CAAC,EAAEmC,MAAMnC,KAAK,CAAC,CAAC;gCAItBmC,MAAM/B,QAAQ,CAAC8B,GAAG,CACjB,CAACzC,SAAkBU,6BACjB,MAAC7D;wCAEC+F,UACE3E,uBAAuBwC,cACvBtC,yBAAyBuC;wCAE3B2B,SAASf,0BACPb,YACAC;;0DAGF,KAAC5D;gDAAK+F,MAAM7C,QAAQ6C,IAAI;gDAAEtB,WAAU;;4CACnCvB,QAAQ8C,KAAK;;uCAXT,CAAC,EAAE9C,QAAQ8C,KAAK,CAAC,CAAC;;2BAVV,CAAC,EAAEJ,MAAMnC,KAAK,CAAC,QAAQ,CAAC;;;;;AAiC7D,GACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AIEditorPanel.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AIEditorPanel/AIEditorPanel.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAiBvC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACxC,CAAC;AAEF,eAAO,MAAM,aAAa,6BAA8B,kBAAkB,
|
|
1
|
+
{"version":3,"file":"AIEditorPanel.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AIEditorPanel/AIEditorPanel.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAiBvC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACxC,CAAC;AAEF,eAAO,MAAM,aAAa,6BAA8B,kBAAkB,gCA+HzE,CAAC"}
|
|
@@ -90,7 +90,7 @@ export const AIEditorPanel = ({ editor, onOpenChange })=>{
|
|
|
90
90
|
/*#__PURE__*/ _jsx(Sparkles, {
|
|
91
91
|
className: "mr-2 h-4 w-4 shrink-0 "
|
|
92
92
|
}),
|
|
93
|
-
"AI is thinking",
|
|
93
|
+
"AI (Beta) is thinking",
|
|
94
94
|
/*#__PURE__*/ _jsx("div", {
|
|
95
95
|
className: "ml-2 mt-1",
|
|
96
96
|
children: /*#__PURE__*/ _jsx(CrazySpinner, {})
|
|
@@ -112,7 +112,7 @@ export const AIEditorPanel = ({ editor, onOpenChange })=>{
|
|
|
112
112
|
onChange: (e)=>{
|
|
113
113
|
setInputValue(e.target.value);
|
|
114
114
|
},
|
|
115
|
-
placeholder: hasCompletion ? i18next.t("tellAiPlaceholder") || "Tell AI what to do next" : i18next.t("askAiPlaceholder") || "Ask AI to edit or generate...",
|
|
115
|
+
placeholder: hasCompletion ? i18next.t("tellAiPlaceholder") || "Tell AI (Beta) what to do next" : i18next.t("askAiPlaceholder") || "Ask AI (Beta) to edit or generate...",
|
|
116
116
|
autoFocus: true,
|
|
117
117
|
// onFocus={() => {
|
|
118
118
|
// addAIHighlight(editor)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AIEditorPanel/AIEditorPanel.tsx"],"sourcesContent":["\"use client\";\n\nimport { useLocale } from \"@payloadcms/ui/providers/Locale\";\nimport { Editor } from \"@tiptap/react\";\nimport { useCompletion } from \"ai/react\";\nimport { ArrowRight, Sparkles } from \"lucide-react\";\nimport { useCallback, useRef, useState } from \"react\";\nimport TextareaAutosize from \"react-textarea-autosize\";\n\nimport i18next from \"i18next\";\nimport Markdown from \"react-markdown\";\nimport { extractMarkdown } from \"../../../lib/extract.js\";\nimport { getPrevText } from \"../../../lib/utils/index.js\";\nimport AICompletionCommands from \"../../menus/TextMenu/components/ai-completion-command.js\";\nimport AISelectorCommands from \"../../menus/TextMenu/components/ai-selector-commands.js\";\nimport { Surface } from \"../../ui/Surface.js\";\nimport { Toolbar } from \"../../ui/Toolbar.js\";\nimport CrazySpinner from \"../../ui/crazy-spinner.js\";\nimport { ScrollArea } from \"../../ui/scroll-area.js\";\nimport { checkJsonCompletion, formatCompletion } from \"./utils.js\";\nexport type AIEditorPanelProps = {\n editor: Editor;\n onOpenChange: (value: boolean) => void;\n};\n\nexport const AIEditorPanel = ({ editor, onOpenChange }: AIEditorPanelProps) => {\n const [inputValue, setInputValue] = useState(\"\");\n const { code } = useLocale();\n const { view } = editor;\n\n const editorNode = view.dom as HTMLElement;\n const boundigClient = editorNode.getBoundingClientRect();\n const inputRef = useRef<HTMLTextAreaElement>(null);\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 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: { option: \"zap\", command: inputValue, language: code ?? \"en\" },\n }).then(() => setInputValue(\"\"));\n }, [code, inputValue, completion]);\n\n return (\n <Surface\n className={`p-2 min-w-[20rem] `}\n style={{\n width: boundigClient?.width,\n }}\n >\n <>\n {(hasCompletion && completion?.length > 10 && (checkJsonCompletion(completion) ? !isLoading : true)) && (\n <div className=\"flex w-full\">\n <ScrollArea>\n <div\n className=\"prose p-2 px-4 prose-sm\"\n dir={i18next.dir()}\n >\n <Markdown>{checkJsonCompletion(completion) ? extractMarkdown({ type: 'doc', content: formatCompletion(completion) as any }) : completion}</Markdown>\n </div>\n </ScrollArea>\n </div>\n )}\n\n {isLoading && (\n <div className=\"flex h-12 w-full items-center px-4 text-sm font-medium text-muted-foreground text-blue-500\">\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
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AIEditorPanel/AIEditorPanel.tsx"],"sourcesContent":["\"use client\";\n\nimport { useLocale } from \"@payloadcms/ui/providers/Locale\";\nimport { Editor } from \"@tiptap/react\";\nimport { useCompletion } from \"ai/react\";\nimport { ArrowRight, Sparkles } from \"lucide-react\";\nimport { useCallback, useRef, useState } from \"react\";\nimport TextareaAutosize from \"react-textarea-autosize\";\n\nimport i18next from \"i18next\";\nimport Markdown from \"react-markdown\";\nimport { extractMarkdown } from \"../../../lib/extract.js\";\nimport { getPrevText } from \"../../../lib/utils/index.js\";\nimport AICompletionCommands from \"../../menus/TextMenu/components/ai-completion-command.js\";\nimport AISelectorCommands from \"../../menus/TextMenu/components/ai-selector-commands.js\";\nimport { Surface } from \"../../ui/Surface.js\";\nimport { Toolbar } from \"../../ui/Toolbar.js\";\nimport CrazySpinner from \"../../ui/crazy-spinner.js\";\nimport { ScrollArea } from \"../../ui/scroll-area.js\";\nimport { checkJsonCompletion, formatCompletion } from \"./utils.js\";\nexport type AIEditorPanelProps = {\n editor: Editor;\n onOpenChange: (value: boolean) => void;\n};\n\nexport const AIEditorPanel = ({ editor, onOpenChange }: AIEditorPanelProps) => {\n const [inputValue, setInputValue] = useState(\"\");\n const { code } = useLocale();\n const { view } = editor;\n\n const editorNode = view.dom as HTMLElement;\n const boundigClient = editorNode.getBoundingClientRect();\n const inputRef = useRef<HTMLTextAreaElement>(null);\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 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: { option: \"zap\", command: inputValue, language: code ?? \"en\" },\n }).then(() => setInputValue(\"\"));\n }, [code, inputValue, completion]);\n\n return (\n <Surface\n className={`p-2 min-w-[20rem] `}\n style={{\n width: boundigClient?.width,\n }}\n >\n <>\n {(hasCompletion && completion?.length > 10 && (checkJsonCompletion(completion) ? !isLoading : true)) && (\n <div className=\"flex w-full\">\n <ScrollArea>\n <div\n className=\"prose p-2 px-4 prose-sm\"\n dir={i18next.dir()}\n >\n <Markdown>{checkJsonCompletion(completion) ? extractMarkdown({ type: 'doc', content: formatCompletion(completion) as any }) : completion}</Markdown>\n </div>\n </ScrollArea>\n </div>\n )}\n\n {isLoading && (\n <div className=\"flex h-12 w-full items-center px-4 text-sm font-medium text-muted-foreground text-blue-500\">\n <Sparkles className=\"mr-2 h-4 w-4 shrink-0 \" />\n AI (Beta) 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 <Sparkles className=\"mr-2 h-4 w-4 shrink-0 text-blue-500 \" />\n <TextareaAutosize\n ref={inputRef}\n className=\"w-full p-2 text-black bg-white rounded dark:bg-black dark:text-white focus:outline-none\"\n value={inputValue}\n onChange={(e) => {\n setInputValue(e.target.value);\n }}\n placeholder={\n hasCompletion\n ? i18next.t(\"tellAiPlaceholder\") || \"Tell AI (Beta) what to do next\"\n : i18next.t(\"askAiPlaceholder\") || \"Ask AI (Beta) 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 <ArrowRight />\n </Toolbar.Button>\n </div>\n {hasCompletion ? (\n <AICompletionCommands\n editor={editor}\n onDiscard={() => {\n editor?.chain()?.unsetHighlight()?.focus()?.run();\n onOpenChange(false);\n }}\n completion={completion}\n />\n ) : (\n <AISelectorCommands\n messages={completion}\n editor={editor}\n onSelect={(value, options) => {\n complete(value, { body: options });\n }}\n />\n )}\n </>\n )}\n </>\n </Surface>\n );\n};\n\n"],"names":["useLocale","useCompletion","ArrowRight","Sparkles","useCallback","useRef","useState","TextareaAutosize","i18next","Markdown","extractMarkdown","getPrevText","AICompletionCommands","AISelectorCommands","Surface","Toolbar","CrazySpinner","ScrollArea","checkJsonCompletion","formatCompletion","AIEditorPanel","editor","onOpenChange","inputValue","setInputValue","code","view","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","className","style","width","div","dir","type","content","ref","value","onChange","target","placeholder","t","autoFocus","onKeyDown","key","Button","onClick","onDiscard","chain","unsetHighlight","focus","run","messages","onSelect","options"],"mappings":"AAAA;;AAEA,SAASA,SAAS,QAAQ,kCAAkC;AAE5D,SAASC,aAAa,QAAQ,WAA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B;oCAE7BC,WAAW,CAAC1B;wCACV,IAAIA,EAAE2B,GAAG,KAAK,SAASvB;oCACzB;;8CAEF,KAAC/B,QAAQuD,MAAM;oCACb,cAAc;oCAEd,4GAA4G;oCAC5GC,SAASzB;8CAET,cAAA,KAAC5C;;;;wBAGJ0C,8BACC,KAAChC;4BACCS,QAAQA;4BACRmD,WAAW;gCACTnD,QAAQoD,SAASC,kBAAkBC,SAASC;gCAC5CtD,aAAa;4BACf;4BACAU,YAAYA;2CAGd,KAACnB;4BACCgE,UAAU7C;4BACVX,QAAQA;4BACRyD,UAAU,CAAChB,OAAOiB;gCAChB9C,SAAS6B,OAAO;oCAAEf,MAAMgC;gCAAQ;4BAClC;;;;;;;AAQhB,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AIEditorPanel/utils.ts"],"sourcesContent":["\nimport json5 from 'json5';\n\nexport const convertBody = (body: string) => {\n try {\n let parsedBody = body.replace('```json', '').replace('```', '');\n parsedBody = json5.parse(parsedBody);\n return parsedBody as unknown as object[];\n } catch (error) {\n try {\n const fixedJson = jsonFixer(body);\n return json5.parse(fixedJson);\n } catch (error) {\n console.error('Error occured When parsing translated error: ', error);\n console.error('Error occured When parsing translated body ', body);\n throw new Error(\n `Openapi translate with assistant An error occurred while processing your request .error: ${error} body: ${body}`,\n );\n }\n }\n}\n\nexport const jsonFixer = (json: string, provider?: string) => {\n if (provider === 'bedrock') {\n json += '}';\n }\n let fixedText = json\n .replace('```json', '')\n .replace('```', '')\n .replace(/”/g, '\"')\n .replace(/“/g, '\"')\n .replace(/’/g, \"'\")\n .replace(/‘/g, \"'\");\n\n const regex = /\"text\":\\s*\"([^]*)\"/g;\n\n // Metinde her text alanını kontrol et\n fixedText = fixedText.replace(regex, (match, p1) => {\n let text = p1.trim();\n\n if (!text.startsWith('\"')) {\n text = '\"' + text;\n }\n\n if (!text.endsWith('\"')) {\n text = text + '\"';\n }\n\n return `\"text\": ${text}`;\n });\n\n return fixedText;\n};\n\nexport const formatCompletion = (completion: string) => {\n const translatedText = completion\n .trim()\n .replace(/<translated_text>/g, '')\n .replace('</translated_text>', '');\n const body = convertBody(translatedText)\n return body\n}\n\nexport const checkJsonCompletion = (completion: string) => {\n return completion.includes(\"```json\") || completion.includes(\"\\\"type\\\":\") || completion.includes(\"\\\"content\\\":\")\n}"],"names":["json5","convertBody","body","parsedBody","replace","parse","error","fixedJson","jsonFixer","console","Error","json","provider","fixedText","regex","match","p1","text","trim","startsWith","endsWith","formatCompletion","completion","translatedText","checkJsonCompletion","includes"],"mappings":"AACA,OAAOA,WAAW,QAAQ;AAE1B,OAAO,MAAMC,cAAc,CAACC;IACxB,IAAI;QACA,IAAIC,aAAaD,KAAKE,OAAO,CAAC,WAAW,IAAIA,OAAO,CAAC,OAAO;QAC5DD,aAAaH,MAAMK,KAAK,CAACF;QACzB,OAAOA;IACX,EAAE,OAAOG,OAAO;QACZ,IAAI;YACA,MAAMC,YAAYC,UAAUN;YAC5B,OAAOF,MAAMK,KAAK,CAACE;QACvB,EAAE,OAAOD,OAAO;YACZG,QAAQH,KAAK,CAAC,iDAAiDA;YAC/DG,QAAQH,KAAK,CAAC,+CAA+CJ;YAC7D,MAAM,IAAIQ,MACN,CAAC,yFAAyF,EAAEJ,MAAM,OAAO,EAAEJ,
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AIEditorPanel/utils.ts"],"sourcesContent":["\nimport json5 from 'json5';\n\nexport const convertBody = (body: string) => {\n try {\n let parsedBody = body.replace('```json', '').replace('```', '');\n parsedBody = json5.parse(parsedBody);\n return parsedBody as unknown as object[];\n } catch (error) {\n try {\n const fixedJson = jsonFixer(body);\n return json5.parse(fixedJson);\n } catch (error) {\n console.error('Error occured When parsing translated error: ', error);\n console.error('Error occured When parsing translated body ', body);\n throw new Error(\n `Openapi translate with assistant An error occurred while processing your request .error: ${error} body: ${body}`,\n );\n }\n }\n}\n\nexport const jsonFixer = (json: string, provider?: string) => {\n if (provider === 'bedrock') {\n json += '}';\n }\n let fixedText = json\n .replace('```json', '')\n .replace('```', '')\n .replace(/”/g, '\"')\n .replace(/“/g, '\"')\n .replace(/’/g, \"'\")\n .replace(/‘/g, \"'\");\n\n const regex = /\"text\":\\s*\"([^]*)\"/g;\n\n // Metinde her text alanını kontrol et\n fixedText = fixedText.replace(regex, (match, p1) => {\n let text = p1.trim();\n\n if (!text.startsWith('\"')) {\n text = '\"' + text;\n }\n\n if (!text.endsWith('\"')) {\n text = text + '\"';\n }\n\n return `\"text\": ${text}`;\n });\n\n return fixedText;\n};\n\nexport const formatCompletion = (completion: string) => {\n const translatedText = completion\n .trim()\n .replace(/<translated_text>/g, '')\n .replace('</translated_text>', '');\n const body = convertBody(translatedText)\n return body\n}\n\nexport const checkJsonCompletion = (completion: string) => {\n return completion.includes(\"```json\") || completion.includes(\"\\\"type\\\":\") || completion.includes(\"\\\"content\\\":\")\n}"],"names":["json5","convertBody","body","parsedBody","replace","parse","error","fixedJson","jsonFixer","console","Error","json","provider","fixedText","regex","match","p1","text","trim","startsWith","endsWith","formatCompletion","completion","translatedText","checkJsonCompletion","includes"],"mappings":"AACA,OAAOA,WAAW,QAAQ;AAE1B,OAAO,MAAMC,cAAc,CAACC;IACxB,IAAI;QACA,IAAIC,aAAaD,KAAKE,OAAO,CAAC,WAAW,IAAIA,OAAO,CAAC,OAAO;QAC5DD,aAAaH,MAAMK,KAAK,CAACF;QACzB,OAAOA;IACX,EAAE,OAAOG,OAAO;QACZ,IAAI;YACA,MAAMC,YAAYC,UAAUN;YAC5B,OAAOF,MAAMK,KAAK,CAACE;QACvB,EAAE,OAAOD,OAAO;YACZG,QAAQH,KAAK,CAAC,iDAAiDA;YAC/DG,QAAQH,KAAK,CAAC,+CAA+CJ;YAC7D,MAAM,IAAIQ,MACN,CAAC,yFAAyF,EAAEJ,MAAM,OAAO,EAAEJ,KAAK,CAAC;QAEzH;IACJ;AACJ,EAAC;AAED,OAAO,MAAMM,YAAY,CAACG,MAAcC;IACpC,IAAIA,aAAa,WAAW;QACxBD,QAAQ;IACZ;IACA,IAAIE,YAAYF,KACXP,OAAO,CAAC,WAAW,IACnBA,OAAO,CAAC,OAAO,IACfA,OAAO,CAAC,MAAM,KACdA,OAAO,CAAC,MAAM,KACdA,OAAO,CAAC,MAAM,KACdA,OAAO,CAAC,MAAM;IAEnB,MAAMU,QAAQ;IAEd,sCAAsC;IACtCD,YAAYA,UAAUT,OAAO,CAACU,OAAO,CAACC,OAAOC;QACzC,IAAIC,OAAOD,GAAGE,IAAI;QAElB,IAAI,CAACD,KAAKE,UAAU,CAAC,MAAM;YACvBF,OAAO,MAAMA;QACjB;QAEA,IAAI,CAACA,KAAKG,QAAQ,CAAC,MAAM;YACrBH,OAAOA,OAAO;QAClB;QAEA,OAAO,CAAC,QAAQ,EAAEA,KAAK,CAAC;IAC5B;IAEA,OAAOJ;AACX,EAAE;AAEF,OAAO,MAAMQ,mBAAmB,CAACC;IAC7B,MAAMC,iBAAiBD,WAClBJ,IAAI,GACJd,OAAO,CAAC,sBAAsB,IAC9BA,OAAO,CAAC,sBAAsB;IACnC,MAAMF,OAAOD,YAAYsB;IACzB,OAAOrB;AACX,EAAC;AAED,OAAO,MAAMsB,sBAAsB,CAACF;IAChC,OAAOA,WAAWG,QAAQ,CAAC,cAAcH,WAAWG,QAAQ,CAAC,gBAAgBH,WAAWG,QAAQ,CAAC;AACrG,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/fields/TiptapEditor/hooks/useBlockEditor.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useMemo } from \"react\";\n\nimport { Editor, useEditor } from \"@tiptap/react\";\n\nimport ExtensionKit from \"../extensions/extension-kit.js\";\nimport { EditorUser } from \"../features/BlockEditor/types.js\";\nimport { useSidebar } from \"./useSidebar.js\";\n\nimport TurndownService from \"turndown\";\nimport { gfm } from \"turndown-plugin-gfm\";\nimport { AssetReturnType, openAssetHQType } from \"../types.js\";\nimport i18next from \"i18next\";\n\ndeclare global {\n interface Window {\n editor: Editor | null;\n }\n}\n\nconst dummyAssetHqHandler = (\n listener: (asset: AssetReturnType) => void,\n file?: File\n) => {};\n\nexport const useBlockEditor = ({\n content,\n handleChange,\n openAssetHQHandler,\n additionalContext,\n autoFocus,\n isEditable,\n}: {\n content: { html: string; json: any };\n handleChange?: (data: any) => void;\n openAssetHQHandler?: openAssetHQType;\n additionalContext?: Record<string, any>;\n autoFocus: boolean;\n isEditable?: boolean;\n}) => {\n const leftSidebar = useSidebar();\n\n const turndownService = new TurndownService({});\n // Use the gfm plugin\n turndownService.use(gfm);\n turndownService.addRule(\"twitter\", {\n filter: \"div\",\n replacement: function (content) {\n return \"\\n\\n\" + content + \"\\n\\n\";\n },\n });\n\n const editor = useEditor(\n {\n content: content?.json ?? content ?? {},\n immediatelyRender: false,\n autofocus: autoFocus ?? true,\n editable: isEditable ?? true,\n onCreate: ({ editor }) => ({\n // provider?.on('synced', () => {\n // if (editor.isEmpty) {\n // editor.commands.setContent(initialContent)\n // }\n // })\n }),\n extensions: [\n ...ExtensionKit({\n openAssetHQHandler: openAssetHQHandler ?? dummyAssetHqHandler,\n // provider,\n }),\n // Collaboration.configure({\n // document: ydoc,\n // }),\n // CollaborationCursor.configure({\n // provider,\n // user: {\n // name: randomElement(userNames),\n // color: randomElement(userColors),\n // },\n // }),\n ],\n editorProps: {\n attributes: {\n languages: i18next.language,\n autocomplete: \"off\",\n autocorrect: \"off\",\n autocapitalize: \"off\",\n class: \"min-h-full\",\n },\n },\n onUpdate: ({ editor }) => {\n handleChange(editor?.getJSON() ?? {});\n },\n },\n []\n );\n\n useEffect(() => {\n if (editor?.storage?.aiCommand) {\n editor.storage.aiCommand.title = additionalContext?.title ?? \"\";\n editor.storage.aiCommand.language = additionalContext?.language ?? \"\";\n }\n }, [editor, additionalContext]);\n\n const users = useMemo(() => {\n if (!editor?.storage?.collaborationCursor?.users) {\n return [];\n }\n\n return editor?.storage?.collaborationCursor?.users.map(\n (user: EditorUser) => {\n const names = user.name?.split(\" \");\n const firstName = names?.[0];\n const lastName = names?.[names.length - 1];\n const initials = `${firstName?.[0] || \"?\"}${lastName?.[0] || \"?\"}`;\n\n return { ...user, initials: initials.length ? initials : \"?\" };\n }\n );\n }, [editor?.storage.collaborationCursor?.users]);\n\n const characterCount = editor?.storage.characterCount || {\n characters: () => 0,\n words: () => 0,\n };\n\n // useEffect(() => {\n // provider?.on('status', (event: { status: WebSocketStatus }) => {\n // setCollabState(event.status)\n // })\n // }, [provider])\n\n if (typeof window != \"undefined\") window.editor = editor;\n\n return { editor, users, characterCount, leftSidebar };\n};\n"],"names":["useEffect","useMemo","useEditor","ExtensionKit","useSidebar","TurndownService","gfm","i18next","dummyAssetHqHandler","listener","file","useBlockEditor","content","handleChange","openAssetHQHandler","additionalContext","autoFocus","isEditable","leftSidebar","turndownService","use","addRule","filter","replacement","editor","json","immediatelyRender","autofocus","editable","onCreate","extensions","editorProps","attributes","languages","language","autocomplete","autocorrect","autocapitalize","class","onUpdate","getJSON","storage","aiCommand","title","users","collaborationCursor","map","user","names","name","split","firstName","lastName","length","initials","characterCount","characters","words","window"],"mappings":"AAAA;AACA,SAASA,SAAS,EAAEC,OAAO,QAAQ,QAAQ;AAE3C,SAAiBC,SAAS,QAAQ,gBAAgB;AAElD,OAAOC,kBAAkB,iCAAiC;AAE1D,SAASC,UAAU,QAAQ,kBAAkB;AAE7C,OAAOC,qBAAqB,WAAW;AACvC,SAASC,GAAG,QAAQ,sBAAsB;AAE1C,OAAOC,aAAa,UAAU;AAQ9B,MAAMC,sBAAsB,CAC1BC,UACAC,QACI;AAEN,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,OAAO,EACPC,YAAY,EACZC,kBAAkB,EAClBC,iBAAiB,EACjBC,SAAS,EACTC,UAAU,EAQX;IACC,MAAMC,cAAcd;IAEpB,MAAMe,kBAAkB,IAAId,gBAAgB,CAAC;I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hooks/useBlockEditor.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useMemo } from \"react\";\n\nimport { Editor, useEditor } from \"@tiptap/react\";\n\nimport ExtensionKit from \"../extensions/extension-kit.js\";\nimport { EditorUser } from \"../features/BlockEditor/types.js\";\nimport { useSidebar } from \"./useSidebar.js\";\n\nimport TurndownService from \"turndown\";\nimport { gfm } from \"turndown-plugin-gfm\";\nimport { AssetReturnType, openAssetHQType } from \"../types.js\";\nimport i18next from \"i18next\";\n\ndeclare global {\n interface Window {\n editor: Editor | null;\n }\n}\n\nconst dummyAssetHqHandler = (\n listener: (asset: AssetReturnType) => void,\n file?: File\n) => {};\n\nexport const useBlockEditor = ({\n content,\n handleChange,\n openAssetHQHandler,\n additionalContext,\n autoFocus,\n isEditable,\n}: {\n content: { html: string; json: any };\n handleChange?: (data: any) => void;\n openAssetHQHandler?: openAssetHQType;\n additionalContext?: Record<string, any>;\n autoFocus: boolean;\n isEditable?: boolean;\n}) => {\n const leftSidebar = useSidebar();\n\n const turndownService = new TurndownService({});\n // Use the gfm plugin\n turndownService.use(gfm);\n turndownService.addRule(\"twitter\", {\n filter: \"div\",\n replacement: function (content) {\n return \"\\n\\n\" + content + \"\\n\\n\";\n },\n });\n\n const editor = useEditor(\n {\n content: content?.json ?? content ?? {},\n immediatelyRender: false,\n autofocus: autoFocus ?? true,\n editable: isEditable ?? true,\n onCreate: ({ editor }) => ({\n // provider?.on('synced', () => {\n // if (editor.isEmpty) {\n // editor.commands.setContent(initialContent)\n // }\n // })\n }),\n extensions: [\n ...ExtensionKit({\n openAssetHQHandler: openAssetHQHandler ?? dummyAssetHqHandler,\n // provider,\n }),\n // Collaboration.configure({\n // document: ydoc,\n // }),\n // CollaborationCursor.configure({\n // provider,\n // user: {\n // name: randomElement(userNames),\n // color: randomElement(userColors),\n // },\n // }),\n ],\n editorProps: {\n attributes: {\n languages: i18next.language,\n autocomplete: \"off\",\n autocorrect: \"off\",\n autocapitalize: \"off\",\n class: \"min-h-full\",\n },\n },\n onUpdate: ({ editor }) => {\n handleChange(editor?.getJSON() ?? {});\n },\n },\n []\n );\n\n useEffect(() => {\n if (editor?.storage?.aiCommand) {\n editor.storage.aiCommand.title = additionalContext?.title ?? \"\";\n editor.storage.aiCommand.language = additionalContext?.language ?? \"\";\n }\n }, [editor, additionalContext]);\n\n const users = useMemo(() => {\n if (!editor?.storage?.collaborationCursor?.users) {\n return [];\n }\n\n return editor?.storage?.collaborationCursor?.users.map(\n (user: EditorUser) => {\n const names = user.name?.split(\" \");\n const firstName = names?.[0];\n const lastName = names?.[names.length - 1];\n const initials = `${firstName?.[0] || \"?\"}${lastName?.[0] || \"?\"}`;\n\n return { ...user, initials: initials.length ? initials : \"?\" };\n }\n );\n }, [editor?.storage.collaborationCursor?.users]);\n\n const characterCount = editor?.storage.characterCount || {\n characters: () => 0,\n words: () => 0,\n };\n\n // useEffect(() => {\n // provider?.on('status', (event: { status: WebSocketStatus }) => {\n // setCollabState(event.status)\n // })\n // }, [provider])\n\n if (typeof window != \"undefined\") window.editor = editor;\n\n return { editor, users, characterCount, leftSidebar };\n};\n"],"names":["useEffect","useMemo","useEditor","ExtensionKit","useSidebar","TurndownService","gfm","i18next","dummyAssetHqHandler","listener","file","useBlockEditor","content","handleChange","openAssetHQHandler","additionalContext","autoFocus","isEditable","leftSidebar","turndownService","use","addRule","filter","replacement","editor","json","immediatelyRender","autofocus","editable","onCreate","extensions","editorProps","attributes","languages","language","autocomplete","autocorrect","autocapitalize","class","onUpdate","getJSON","storage","aiCommand","title","users","collaborationCursor","map","user","names","name","split","firstName","lastName","length","initials","characterCount","characters","words","window"],"mappings":"AAAA;AACA,SAASA,SAAS,EAAEC,OAAO,QAAQ,QAAQ;AAE3C,SAAiBC,SAAS,QAAQ,gBAAgB;AAElD,OAAOC,kBAAkB,iCAAiC;AAE1D,SAASC,UAAU,QAAQ,kBAAkB;AAE7C,OAAOC,qBAAqB,WAAW;AACvC,SAASC,GAAG,QAAQ,sBAAsB;AAE1C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,SAASI,qBAAqBD,MAAME,IACjD,CAACC;YACC,MAAMC,QAAQD,KAAKE,IAAI,EAAEC,MAAM;YAC/B,MAAMC,YAAYH,OAAO,CAAC,EAAE;YAC5B,MAAMI,WAAWJ,OAAO,CAACA,MAAMK,MAAM,GAAG,EAAE;YAC1C,MAAMC,WAAW,CAAC,EAAEH,WAAW,CAAC,EAAE,IAAI,IAAI,EAAEC,UAAU,CAAC,EAAE,IAAI,IAAI,CAAC;YAElE,OAAO;gBAAE,GAAGL,IAAI;gBAAEO,UAAUA,SAASD,MAAM,GAAGC,WAAW;YAAI;QAC/D;IAEJ,GAAG;QAAC9B,QAAQiB,QAAQI,qBAAqBD;KAAM;IAE/C,MAAMW,iBAAiB/B,QAAQiB,QAAQc,kBAAkB;QACvDC,YAAY,IAAM;QAClBC,OAAO,IAAM;IACf;IAEA,oBAAoB;IACpB,qEAAqE;IACrE,mCAAmC;IACnC,OAAO;IACP,iBAAiB;IAEjB,IAAI,OAAOC,UAAU,aAAaA,OAAOlC,MAAM,GAAGA;IAElD,OAAO;QAAEA;QAAQoB;QAAOW;QAAgBrC;IAAY;AACtD,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/lib/utils/cssVar.ts"],"sourcesContent":["export const cssVar = (name: string, value?: string) => {\n let currentName = name\n if (name.substring(0, 2) !== '--') {\n currentName = `--${currentName}`\n }\n\n if (value) {\n document.documentElement.style.setProperty(currentName, value)\n }\n\n return getComputedStyle(document.body).getPropertyValue(currentName)\n}\n\nexport default cssVar\n"],"names":["cssVar","name","value","currentName","substring","document","documentElement","style","setProperty","getComputedStyle","body","getPropertyValue"],"mappings":"AAAA,OAAO,MAAMA,SAAS,CAACC,MAAcC;IACnC,IAAIC,cAAcF;IAClB,IAAIA,KAAKG,SAAS,CAAC,GAAG,OAAO,MAAM;QACjCD,cAAc,CAAC,EAAE,EAAEA,
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/lib/utils/cssVar.ts"],"sourcesContent":["export const cssVar = (name: string, value?: string) => {\n let currentName = name\n if (name.substring(0, 2) !== '--') {\n currentName = `--${currentName}`\n }\n\n if (value) {\n document.documentElement.style.setProperty(currentName, value)\n }\n\n return getComputedStyle(document.body).getPropertyValue(currentName)\n}\n\nexport default cssVar\n"],"names":["cssVar","name","value","currentName","substring","document","documentElement","style","setProperty","getComputedStyle","body","getPropertyValue"],"mappings":"AAAA,OAAO,MAAMA,SAAS,CAACC,MAAcC;IACnC,IAAIC,cAAcF;IAClB,IAAIA,KAAKG,SAAS,CAAC,GAAG,OAAO,MAAM;QACjCD,cAAc,CAAC,EAAE,EAAEA,YAAY,CAAC;IAClC;IAEA,IAAID,OAAO;QACTG,SAASC,eAAe,CAACC,KAAK,CAACC,WAAW,CAACL,aAAaD;IAC1D;IAEA,OAAOO,iBAAiBJ,SAASK,IAAI,EAAEC,gBAAgB,CAACR;AAC1D,EAAC;AAED,eAAeH,OAAM"}
|
package/dist/src/styles.css
CHANGED
|
@@ -1661,6 +1661,10 @@ select {
|
|
|
1661
1661
|
margin-left: 0px;
|
|
1662
1662
|
}
|
|
1663
1663
|
|
|
1664
|
+
.ml-1 {
|
|
1665
|
+
margin-left: 0.25rem;
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1664
1668
|
.ml-1\.5 {
|
|
1665
1669
|
margin-left: 0.375rem;
|
|
1666
1670
|
}
|
|
@@ -2254,6 +2258,11 @@ select {
|
|
|
2254
2258
|
background-color: rgb(0 0 0 / 0.6);
|
|
2255
2259
|
}
|
|
2256
2260
|
|
|
2261
|
+
.bg-blue-100 {
|
|
2262
|
+
--tw-bg-opacity: 1;
|
|
2263
|
+
background-color: rgb(219 234 254 / var(--tw-bg-opacity, 1));
|
|
2264
|
+
}
|
|
2265
|
+
|
|
2257
2266
|
.bg-blue-400 {
|
|
2258
2267
|
--tw-bg-opacity: 1;
|
|
2259
2268
|
background-color: rgb(96 165 250 / var(--tw-bg-opacity, 1));
|
|
@@ -2289,6 +2298,11 @@ select {
|
|
|
2289
2298
|
background-color: rgb(23 23 23 / var(--tw-bg-opacity, 1));
|
|
2290
2299
|
}
|
|
2291
2300
|
|
|
2301
|
+
.bg-purple-100 {
|
|
2302
|
+
--tw-bg-opacity: 1;
|
|
2303
|
+
background-color: rgb(243 232 255 / var(--tw-bg-opacity, 1));
|
|
2304
|
+
}
|
|
2305
|
+
|
|
2292
2306
|
.bg-red-500 {
|
|
2293
2307
|
--tw-bg-opacity: 1;
|
|
2294
2308
|
background-color: rgb(239 68 68 / var(--tw-bg-opacity, 1));
|
|
@@ -2411,6 +2425,11 @@ select {
|
|
|
2411
2425
|
padding-right: 2rem;
|
|
2412
2426
|
}
|
|
2413
2427
|
|
|
2428
|
+
.py-0\.5 {
|
|
2429
|
+
padding-top: 0.125rem;
|
|
2430
|
+
padding-bottom: 0.125rem;
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2414
2433
|
.py-1 {
|
|
2415
2434
|
padding-top: 0.25rem;
|
|
2416
2435
|
padding-bottom: 0.25rem;
|
|
@@ -2470,6 +2489,10 @@ select {
|
|
|
2470
2489
|
text-align: right;
|
|
2471
2490
|
}
|
|
2472
2491
|
|
|
2492
|
+
.align-baseline {
|
|
2493
|
+
vertical-align: baseline;
|
|
2494
|
+
}
|
|
2495
|
+
|
|
2473
2496
|
.text-2xl {
|
|
2474
2497
|
font-size: 1.5rem;
|
|
2475
2498
|
line-height: 2rem;
|
|
@@ -2570,6 +2593,11 @@ select {
|
|
|
2570
2593
|
color: rgb(59 130 246 / var(--tw-text-opacity, 1));
|
|
2571
2594
|
}
|
|
2572
2595
|
|
|
2596
|
+
.text-blue-700 {
|
|
2597
|
+
--tw-text-opacity: 1;
|
|
2598
|
+
color: rgb(29 78 216 / var(--tw-text-opacity, 1));
|
|
2599
|
+
}
|
|
2600
|
+
|
|
2573
2601
|
.text-gray-400 {
|
|
2574
2602
|
--tw-text-opacity: 1;
|
|
2575
2603
|
color: rgb(156 163 175 / var(--tw-text-opacity, 1));
|
|
@@ -2615,6 +2643,11 @@ select {
|
|
|
2615
2643
|
color: rgb(147 51 234 / var(--tw-text-opacity, 1));
|
|
2616
2644
|
}
|
|
2617
2645
|
|
|
2646
|
+
.text-purple-700 {
|
|
2647
|
+
--tw-text-opacity: 1;
|
|
2648
|
+
color: rgb(126 34 206 / var(--tw-text-opacity, 1));
|
|
2649
|
+
}
|
|
2650
|
+
|
|
2618
2651
|
.text-red-500 {
|
|
2619
2652
|
--tw-text-opacity: 1;
|
|
2620
2653
|
color: rgb(239 68 68 / var(--tw-text-opacity, 1));
|
|
@@ -2973,6 +3006,11 @@ select {
|
|
|
2973
3006
|
background-color: rgb(0 0 0 / var(--tw-bg-opacity, 1));
|
|
2974
3007
|
}
|
|
2975
3008
|
|
|
3009
|
+
.dark\:bg-blue-700:is([data-theme="dark"] *) {
|
|
3010
|
+
--tw-bg-opacity: 1;
|
|
3011
|
+
background-color: rgb(29 78 216 / var(--tw-bg-opacity, 1));
|
|
3012
|
+
}
|
|
3013
|
+
|
|
2976
3014
|
.dark\:bg-neutral-300:is([data-theme="dark"] *) {
|
|
2977
3015
|
--tw-bg-opacity: 1;
|
|
2978
3016
|
background-color: rgb(212 212 212 / var(--tw-bg-opacity, 1));
|
|
@@ -2988,6 +3026,11 @@ select {
|
|
|
2988
3026
|
background-color: rgb(23 23 23 / var(--tw-bg-opacity, 1));
|
|
2989
3027
|
}
|
|
2990
3028
|
|
|
3029
|
+
.dark\:bg-purple-700:is([data-theme="dark"] *) {
|
|
3030
|
+
--tw-bg-opacity: 1;
|
|
3031
|
+
background-color: rgb(126 34 206 / var(--tw-bg-opacity, 1));
|
|
3032
|
+
}
|
|
3033
|
+
|
|
2991
3034
|
.dark\:bg-white:is([data-theme="dark"] *) {
|
|
2992
3035
|
--tw-bg-opacity: 1;
|
|
2993
3036
|
background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));
|
|
@@ -3006,6 +3049,11 @@ select {
|
|
|
3006
3049
|
color: rgb(0 0 0 / var(--tw-text-opacity, 1));
|
|
3007
3050
|
}
|
|
3008
3051
|
|
|
3052
|
+
.dark\:text-blue-100:is([data-theme="dark"] *) {
|
|
3053
|
+
--tw-text-opacity: 1;
|
|
3054
|
+
color: rgb(219 234 254 / var(--tw-text-opacity, 1));
|
|
3055
|
+
}
|
|
3056
|
+
|
|
3009
3057
|
.dark\:text-neutral-200:is([data-theme="dark"] *) {
|
|
3010
3058
|
--tw-text-opacity: 1;
|
|
3011
3059
|
color: rgb(229 229 229 / var(--tw-text-opacity, 1));
|
|
@@ -3026,6 +3074,11 @@ select {
|
|
|
3026
3074
|
color: rgb(82 82 82 / var(--tw-text-opacity, 1));
|
|
3027
3075
|
}
|
|
3028
3076
|
|
|
3077
|
+
.dark\:text-purple-100:is([data-theme="dark"] *) {
|
|
3078
|
+
--tw-text-opacity: 1;
|
|
3079
|
+
color: rgb(243 232 255 / var(--tw-text-opacity, 1));
|
|
3080
|
+
}
|
|
3081
|
+
|
|
3029
3082
|
.dark\:text-purple-400:is([data-theme="dark"] *) {
|
|
3030
3083
|
--tw-text-opacity: 1;
|
|
3031
3084
|
color: rgb(192 132 252 / var(--tw-text-opacity, 1));
|