payload-richtext-tiptap 0.0.142 → 0.0.144
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/README.md +27 -1
- package/dist/src/fields/TiptapEditor/extensions/AICommand/AICommand.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/AICommand/AICommand.js +48 -38
- package/dist/src/fields/TiptapEditor/extensions/AICommand/AICommand.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/LinkPreview/LinkPreview.d.ts +3 -3
- package/dist/src/fields/TiptapEditor/extensions/LinkPreview/LinkPreview.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/LinkPreview/LinkPreview.js +47 -41
- package/dist/src/fields/TiptapEditor/extensions/LinkPreview/LinkPreview.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/extension-kit.d.ts +1 -1
- package/dist/src/fields/TiptapEditor/extensions/extension-kit.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/serverside/ServersideTiptapBody.d.ts +4 -2
- package/dist/src/fields/TiptapEditor/extensions/serverside/ServersideTiptapBody.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/serverside/ServersideTiptapBody.js +53 -14
- package/dist/src/fields/TiptapEditor/extensions/serverside/ServersideTiptapBody.js.map +1 -1
- package/dist/src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.js +4 -4
- 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 +4 -6
- package/dist/src/fields/TiptapEditor/features/panels/AIEditorPanel/AIEditorPanel.js.map +1 -1
- package/dist/src/fields/TiptapEditor/lib/tiptapSchema.d.ts +62 -62
- package/dist/src/mobile.css +1 -1
- package/dist/src/styles.css +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -3
|
@@ -66,11 +66,11 @@ export const AICommandPanel = /*#__PURE__*/ forwardRef(({ editor, onOpenChange,
|
|
|
66
66
|
userPrompt
|
|
67
67
|
]);
|
|
68
68
|
useEffect(()=>{
|
|
69
|
-
if (hasCompletion) {
|
|
70
|
-
editor.storage.aiCommand.completion = object;
|
|
69
|
+
if (!!hasCompletion) {
|
|
70
|
+
editor.storage.aiCommand.completion = object?.content ?? [];
|
|
71
71
|
}
|
|
72
72
|
}, [
|
|
73
|
-
|
|
73
|
+
markdown,
|
|
74
74
|
isLoading
|
|
75
75
|
]);
|
|
76
76
|
useEffect(()=>{
|
|
@@ -163,7 +163,7 @@ export const AICommandPanel = /*#__PURE__*/ forwardRef(({ editor, onOpenChange,
|
|
|
163
163
|
markdown && /*#__PURE__*/ _jsx("div", {
|
|
164
164
|
className: "flex w-full",
|
|
165
165
|
children: /*#__PURE__*/ _jsx(ScrollArea, {
|
|
166
|
-
className: "prose p-2 px-4 prose-sm",
|
|
166
|
+
className: "prose p-2 px-4 prose-sm max-h-96",
|
|
167
167
|
dir: i18next.dir(),
|
|
168
168
|
children: /*#__PURE__*/ _jsx(Markdown, {
|
|
169
169
|
children: markdown
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.tsx"],"sourcesContent":["'use client'\r\nimport { ArrowUpCircle, Sparkles } from 'lucide-react'\r\nimport React, {\r\n forwardRef,\r\n useCallback,\r\n useEffect,\r\n useImperativeHandle,\r\n useRef,\r\n useState,\r\n} from 'react'\r\nimport Markdown from 'react-markdown'\r\nimport TextareaAutosize from 'react-textarea-autosize'\r\n\r\nimport { Editor } from '@tiptap/react'\r\n\r\nimport { experimental_useObject as useObject } from '@ai-sdk/react'\r\nimport i18next from 'i18next'\r\nimport { Command, Group } from '../../../extensions/AICommand/types.js'\r\nimport { TiptapSchema } from '../../../lib/tiptapSchema.js'\r\nimport { getPrevText } from '../../../lib/utils/index.js'\r\nimport AISelectorCommands from '../../menus/TextMenu/components/ai-selector-commands.js'\r\nimport CrazySpinner from '../../ui/crazy-spinner.js'\r\nimport { DropdownButton } from '../../ui/Dropdown/Dropdown.js'\r\nimport { Icon } from '../../ui/Icon.js'\r\nimport { ScrollArea } from '../../ui/scroll-area.js'\r\nimport { Surface } from '../../ui/Surface.js'\r\nimport { Toolbar } from '../../ui/Toolbar.js'\r\nimport { useExtractMarkdown } from '../AIEditorPanel/markdown.hook.js'\r\n\r\nexport type AICommandPanelProps = {\r\n editor: Editor\r\n userPrompt?: string\r\n onOpenChange: (value: boolean) => void\r\n items: Group[]\r\n}\r\n\r\nexport const AICommandPanel = forwardRef(\r\n ({ editor, onOpenChange, userPrompt, items, ...restProps }: AICommandPanelProps, ref) => {\r\n const [inputValue, setInputValue] = useState(userPrompt ?? '')\r\n const { view } = editor\r\n const scrollContainer = useRef<HTMLDivElement>(null)\r\n const activeItem = useRef<HTMLButtonElement>(null)\r\n const [selectedGroupIndex, setSelectedGroupIndex] = useState(0)\r\n const [selectedCommandIndex, setSelectedCommandIndex] = useState(0)\r\n\r\n const editorNode = view.dom as HTMLElement\r\n const boundigClient = editorNode.getBoundingClientRect()\r\n const inputRef = useRef<HTMLTextAreaElement>(null)\r\n\r\n const { object, submit, isLoading } = useObject({\r\n api: '/api/generate',\r\n schema: TiptapSchema,\r\n })\r\n\r\n const { markdown } = useExtractMarkdown(object)\r\n\r\n const hasCompletion = Boolean(object)\r\n\r\n const handleClick = useCallback(() => {\r\n if (object) {\r\n submit({\r\n prompt: '',\r\n body: {\r\n option: 'zap',\r\n command: inputValue,\r\n language: editor?.storage?.aiCommand?.language,\r\n selection: object,\r\n },\r\n })\r\n setInputValue('')\r\n return\r\n }\r\n\r\n submit({\r\n prompt: '',\r\n body: {\r\n option: 'zap',\r\n command: inputValue,\r\n language: editor?.storage?.aiCommand?.language,\r\n },\r\n })\r\n setInputValue('')\r\n }, [editor?.storage?.aiCommand?.language, inputValue, object, submit])\r\n\r\n useEffect(() => {\r\n if (userPrompt) setInputValue(userPrompt)\r\n }, [userPrompt])\r\n useEffect(() => {\r\n if (hasCompletion) {\r\n editor.storage.aiCommand.completion = object\r\n }\r\n }, [object, isLoading])\r\n\r\n useEffect(() => {\r\n setSelectedGroupIndex(0)\r\n setSelectedCommandIndex(0)\r\n }, [items])\r\n\r\n const selectItem = useCallback(\r\n (groupIndex: number, commandIndex: number) => {\r\n const command = items[groupIndex].commands[commandIndex]\r\n setInputValue(command.action(editor))\r\n },\r\n [items, editor],\r\n )\r\n\r\n useImperativeHandle(ref, () => ({\r\n onKeyDown: ({ event }: { event: React.KeyboardEvent }) => {\r\n if (event.key === 'ArrowDown') {\r\n if (!items.length) {\r\n return false\r\n }\r\n\r\n const commands = items[selectedGroupIndex].commands\r\n\r\n let newCommandIndex = selectedCommandIndex + 1\r\n let newGroupIndex = selectedGroupIndex\r\n\r\n if (commands.length - 1 < newCommandIndex) {\r\n newCommandIndex = 0\r\n newGroupIndex = selectedGroupIndex + 1\r\n }\r\n\r\n if (items.length - 1 < newGroupIndex) {\r\n newGroupIndex = 0\r\n }\r\n\r\n setSelectedCommandIndex(newCommandIndex)\r\n setSelectedGroupIndex(newGroupIndex)\r\n\r\n return true\r\n }\r\n\r\n if (event.key === 'ArrowUp') {\r\n if (!items.length) {\r\n return false\r\n }\r\n\r\n let newCommandIndex = selectedCommandIndex - 1\r\n let newGroupIndex = selectedGroupIndex\r\n\r\n if (newCommandIndex < 0) {\r\n newGroupIndex = selectedGroupIndex - 1\r\n newCommandIndex = items[newGroupIndex]?.commands.length - 1 || 0\r\n }\r\n\r\n if (newGroupIndex < 0) {\r\n newGroupIndex = items.length - 1\r\n newCommandIndex = items[newGroupIndex].commands.length - 1\r\n }\r\n\r\n setSelectedCommandIndex(newCommandIndex)\r\n setSelectedGroupIndex(newGroupIndex)\r\n\r\n return true\r\n }\r\n\r\n if (event.key === 'Enter') {\r\n if (!items.length || selectedGroupIndex === -1 || selectedCommandIndex === -1) {\r\n return false\r\n }\r\n\r\n selectItem(selectedGroupIndex, selectedCommandIndex)\r\n\r\n return true\r\n }\r\n\r\n return false\r\n },\r\n }))\r\n\r\n useEffect(() => {\r\n if (activeItem.current && scrollContainer.current) {\r\n const offsetTop = activeItem.current.offsetTop\r\n const offsetHeight = activeItem.current.offsetHeight\r\n\r\n scrollContainer.current.scrollTop = offsetTop - offsetHeight\r\n }\r\n }, [selectedCommandIndex, selectedGroupIndex])\r\n\r\n const createCommandClickHandler = useCallback(\r\n (groupIndex: number, commandIndex: number) => {\r\n return () => {\r\n selectItem(groupIndex, commandIndex)\r\n }\r\n },\r\n [selectItem],\r\n )\r\n\r\n return (\r\n <>\r\n <Surface\r\n className={`p-2 min-w-[20rem] flex flex-col gap-2 w-full ${\r\n hasCompletion ? '-mt-72' : ''\r\n }`}\r\n style={{\r\n width: boundigClient?.width,\r\n }}\r\n >\r\n <>\r\n {markdown && (\r\n <div className='flex w-full'>\r\n <ScrollArea className='prose p-2 px-4 prose-sm' dir={i18next.dir()}>\r\n <Markdown>{markdown}</Markdown>\r\n </ScrollArea>\r\n </div>\r\n )}\r\n\r\n {isLoading && (\r\n <div\r\n className='flex h-12 w-full items-center px-4 text-sm font-medium text-muted-foreground text-blue-500'\r\n style={{\r\n width: boundigClient?.width,\r\n }}\r\n >\r\n <Sparkles className='mr-2 h-4 w-4 shrink-0 ' />\r\n AI (Beta) is thinking\r\n <div className='ml-2 mt-1'>\r\n <CrazySpinner />\r\n </div>\r\n </div>\r\n )}\r\n\r\n {!isLoading && (\r\n <>\r\n <div className='flex justify-between items-center '>\r\n <Sparkles className='mr-2 h-4 w-4 shrink-0 text-blue-500 ' />\r\n <TextareaAutosize\r\n ref={inputRef}\r\n style={{ resize: 'none' }}\r\n className='w-full p-2 text-black bg-white rounded dark:bg-black dark:text-white focus:outline-none outline-none border-0 '\r\n value={inputValue}\r\n onChange={(e) => {\r\n editor.storage.aiCommand.userPrompt = e.target.value\r\n setInputValue(e.target.value)\r\n }}\r\n placeholder={\r\n hasCompletion\r\n ? i18next.t('tellAiPlaceholder') || 'Tell AI (Beta) what to do next'\r\n : i18next.t('askAiPlaceholder') || 'Ask AI (Beta) to edit or generate...'\r\n }\r\n autoFocus\r\n onKeyDown={(e) => {\r\n if (e.key === 'Enter') handleClick()\r\n }}\r\n />\r\n <Toolbar.Button onClick={handleClick}>\r\n <ArrowUpCircle />\r\n </Toolbar.Button>\r\n </div>\r\n </>\r\n )}\r\n </>\r\n </Surface>\r\n {!isLoading && (\r\n <Surface\r\n ref={scrollContainer}\r\n className='text-black max-h-[min(80vh,24rem)] overflow-auto flex-wrap mb-8 p-2'\r\n >\r\n <div className='grid grid-cols-1 gap-0.5'>\r\n {hasCompletion ? (\r\n <AISelectorCommands\r\n editor={editor}\r\n messages={object}\r\n onSelect={(value, options) => {\r\n if (options?.option === 'translate') {\r\n submit({ prompt: value, body: options })\r\n } else {\r\n submit({\r\n prompt: value,\r\n body: { ...options, source: editor?.storage?.aiCommand?.language },\r\n })\r\n }\r\n }}\r\n />\r\n ) : (\r\n items.map((group, groupIndex: number) => (\r\n <React.Fragment key={`${group.title}-wrapper`}>\r\n <div\r\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'\r\n key={`${group.title}`}\r\n >\r\n {group.title}\r\n </div>\r\n {group.commands.map((command: Command, commandIndex: number) => (\r\n <DropdownButton\r\n key={`${command.label}`}\r\n isActive={\r\n selectedGroupIndex === groupIndex && selectedCommandIndex === commandIndex\r\n }\r\n onClick={createCommandClickHandler(groupIndex, commandIndex)}\r\n >\r\n <Icon icon={command.icon} className='mr-1' />\r\n {command.label}\r\n </DropdownButton>\r\n ))}\r\n </React.Fragment>\r\n ))\r\n )}\r\n </div>\r\n </Surface>\r\n )}\r\n </>\r\n )\r\n },\r\n)\r\n"],"names":["ArrowUpCircle","Sparkles","React","forwardRef","useCallback","useEffect","useImperativeHandle","useRef","useState","Markdown","TextareaAutosize","experimental_useObject","useObject","i18next","TiptapSchema","AISelectorCommands","CrazySpinner","DropdownButton","Icon","ScrollArea","Surface","Toolbar","useExtractMarkdown","AICommandPanel","editor","onOpenChange","userPrompt","items","restProps","ref","inputValue","setInputValue","view","scrollContainer","activeItem","selectedGroupIndex","setSelectedGroupIndex","selectedCommandIndex","setSelectedCommandIndex","editorNode","dom","boundigClient","getBoundingClientRect","inputRef","object","submit","isLoading","api","schema","markdown","hasCompletion","Boolean","handleClick","prompt","body","option","command","language","storage","aiCommand","selection","completion","selectItem","groupIndex","commandIndex","commands","action","onKeyDown","event","key","length","newCommandIndex","newGroupIndex","current","offsetTop","offsetHeight","scrollTop","createCommandClickHandler","className","style","width","div","dir","resize","value","onChange","e","target","placeholder","t","autoFocus","Button","onClick","messages","onSelect","options","source","map","group","Fragment","title","isActive","icon","label"],"mappings":"AAAA;;AACA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,eAAc;AACtD,OAAOC,SACLC,UAAU,EACVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,MAAM,EACNC,QAAQ,QACH,QAAO;AACd,OAAOC,cAAc,iBAAgB;AACrC,OAAOC,sBAAsB,0BAAyB;AAItD,SAASC,0BAA0BC,SAAS,QAAQ,gBAAe;AACnE,OAAOC,aAAa,UAAS;AAE7B,SAASC,YAAY,QAAQ,+BAA8B;AAE3D,OAAOC,wBAAwB,0DAAyD;AACxF,OAAOC,kBAAkB,4BAA2B;AACpD,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,IAAI,QAAQ,mBAAkB;AACvC,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,OAAO,QAAQ,sBAAqB;AAC7C,SAASC,OAAO,QAAQ,sBAAqB;AAC7C,SAASC,kBAAkB,QAAQ,oCAAmC;AAStE,OAAO,MAAMC,+BAAiBpB,WAC5B,CAAC,EAAEqB,MAAM,EAAEC,YAAY,EAAEC,UAA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MAAM9C,QAAQ8C,IAAI;gDAAExB,WAAU;;4CACnCtB,QAAQ+C,KAAK;;uCAPT,CAAC,EAAE/C,QAAQ+C,KAAK,CAAC,CAAC;;2BATR,CAAC,EAAEL,MAAME,KAAK,CAAC,QAAQ,CAAC;;;;;AA2B7D,GACD"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.tsx"],"sourcesContent":["'use client'\r\nimport { ArrowUpCircle, Sparkles } from 'lucide-react'\r\nimport React, {\r\n forwardRef,\r\n useCallback,\r\n useEffect,\r\n useImperativeHandle,\r\n useRef,\r\n useState,\r\n} from 'react'\r\nimport Markdown from 'react-markdown'\r\nimport TextareaAutosize from 'react-textarea-autosize'\r\n\r\nimport { Editor } from '@tiptap/react'\r\n\r\nimport { experimental_useObject as useObject } from '@ai-sdk/react'\r\nimport i18next from 'i18next'\r\nimport { Command, Group } from '../../../extensions/AICommand/types.js'\r\nimport { TiptapSchema } from '../../../lib/tiptapSchema.js'\r\nimport { getPrevText } from '../../../lib/utils/index.js'\r\nimport AISelectorCommands from '../../menus/TextMenu/components/ai-selector-commands.js'\r\nimport CrazySpinner from '../../ui/crazy-spinner.js'\r\nimport { DropdownButton } from '../../ui/Dropdown/Dropdown.js'\r\nimport { Icon } from '../../ui/Icon.js'\r\nimport { ScrollArea } from '../../ui/scroll-area.js'\r\nimport { Surface } from '../../ui/Surface.js'\r\nimport { Toolbar } from '../../ui/Toolbar.js'\r\nimport { useExtractMarkdown } from '../AIEditorPanel/markdown.hook.js'\r\n\r\nexport type AICommandPanelProps = {\r\n editor: Editor\r\n userPrompt?: string\r\n onOpenChange: (value: boolean) => void\r\n items: Group[]\r\n}\r\n\r\nexport const AICommandPanel = forwardRef(\r\n ({ editor, onOpenChange, userPrompt, items, ...restProps }: AICommandPanelProps, ref) => {\r\n const [inputValue, setInputValue] = useState(userPrompt ?? '')\r\n const { view } = editor\r\n const scrollContainer = useRef<HTMLDivElement>(null)\r\n const activeItem = useRef<HTMLButtonElement>(null)\r\n const [selectedGroupIndex, setSelectedGroupIndex] = useState(0)\r\n const [selectedCommandIndex, setSelectedCommandIndex] = useState(0)\r\n\r\n const editorNode = view.dom as HTMLElement\r\n const boundigClient = editorNode.getBoundingClientRect()\r\n const inputRef = useRef<HTMLTextAreaElement>(null)\r\n\r\n const { object, submit, isLoading } = useObject({\r\n api: '/api/generate',\r\n schema: TiptapSchema,\r\n })\r\n\r\n const { markdown } = useExtractMarkdown(object)\r\n\r\n const hasCompletion = Boolean(object)\r\n\r\n const handleClick = useCallback(() => {\r\n if (object) {\r\n submit({\r\n prompt: '',\r\n body: {\r\n option: 'zap',\r\n command: inputValue,\r\n language: editor?.storage?.aiCommand?.language,\r\n selection: object,\r\n },\r\n })\r\n setInputValue('')\r\n return\r\n }\r\n\r\n submit({\r\n prompt: '',\r\n body: {\r\n option: 'zap',\r\n command: inputValue,\r\n language: editor?.storage?.aiCommand?.language,\r\n },\r\n })\r\n setInputValue('')\r\n }, [editor?.storage?.aiCommand?.language, inputValue, object, submit])\r\n\r\n useEffect(() => {\r\n if (userPrompt) setInputValue(userPrompt)\r\n }, [userPrompt])\r\n useEffect(() => {\r\n if (!!hasCompletion) {\r\n editor.storage.aiCommand.completion = object?.content ?? []\r\n }\r\n }, [markdown, isLoading])\r\n\r\n useEffect(() => {\r\n setSelectedGroupIndex(0)\r\n setSelectedCommandIndex(0)\r\n }, [items])\r\n\r\n const selectItem = useCallback(\r\n (groupIndex: number, commandIndex: number) => {\r\n const command = items[groupIndex].commands[commandIndex]\r\n setInputValue(command.action(editor))\r\n },\r\n [items, editor],\r\n )\r\n\r\n useImperativeHandle(ref, () => ({\r\n onKeyDown: ({ event }: { event: React.KeyboardEvent }) => {\r\n if (event.key === 'ArrowDown') {\r\n if (!items.length) {\r\n return false\r\n }\r\n\r\n const commands = items[selectedGroupIndex].commands\r\n\r\n let newCommandIndex = selectedCommandIndex + 1\r\n let newGroupIndex = selectedGroupIndex\r\n\r\n if (commands.length - 1 < newCommandIndex) {\r\n newCommandIndex = 0\r\n newGroupIndex = selectedGroupIndex + 1\r\n }\r\n\r\n if (items.length - 1 < newGroupIndex) {\r\n newGroupIndex = 0\r\n }\r\n\r\n setSelectedCommandIndex(newCommandIndex)\r\n setSelectedGroupIndex(newGroupIndex)\r\n\r\n return true\r\n }\r\n\r\n if (event.key === 'ArrowUp') {\r\n if (!items.length) {\r\n return false\r\n }\r\n\r\n let newCommandIndex = selectedCommandIndex - 1\r\n let newGroupIndex = selectedGroupIndex\r\n\r\n if (newCommandIndex < 0) {\r\n newGroupIndex = selectedGroupIndex - 1\r\n newCommandIndex = items[newGroupIndex]?.commands.length - 1 || 0\r\n }\r\n\r\n if (newGroupIndex < 0) {\r\n newGroupIndex = items.length - 1\r\n newCommandIndex = items[newGroupIndex].commands.length - 1\r\n }\r\n\r\n setSelectedCommandIndex(newCommandIndex)\r\n setSelectedGroupIndex(newGroupIndex)\r\n\r\n return true\r\n }\r\n\r\n if (event.key === 'Enter') {\r\n if (!items.length || selectedGroupIndex === -1 || selectedCommandIndex === -1) {\r\n return false\r\n }\r\n\r\n selectItem(selectedGroupIndex, selectedCommandIndex)\r\n\r\n return true\r\n }\r\n\r\n return false\r\n },\r\n }))\r\n\r\n useEffect(() => {\r\n if (activeItem.current && scrollContainer.current) {\r\n const offsetTop = activeItem.current.offsetTop\r\n const offsetHeight = activeItem.current.offsetHeight\r\n\r\n scrollContainer.current.scrollTop = offsetTop - offsetHeight\r\n }\r\n }, [selectedCommandIndex, selectedGroupIndex])\r\n\r\n const createCommandClickHandler = useCallback(\r\n (groupIndex: number, commandIndex: number) => {\r\n return () => {\r\n selectItem(groupIndex, commandIndex)\r\n }\r\n },\r\n [selectItem],\r\n )\r\n\r\n return (\r\n <>\r\n <Surface\r\n className={`p-2 min-w-[20rem] flex flex-col gap-2 w-full ${\r\n hasCompletion ? '-mt-72' : ''\r\n }`}\r\n style={{\r\n width: boundigClient?.width,\r\n }}\r\n >\r\n <>\r\n {markdown && (\r\n <div className='flex w-full'>\r\n <ScrollArea className='prose p-2 px-4 prose-sm max-h-96' dir={i18next.dir()}>\r\n <Markdown>{markdown}</Markdown>\r\n </ScrollArea>\r\n </div>\r\n )}\r\n\r\n {isLoading && (\r\n <div\r\n className='flex h-12 w-full items-center px-4 text-sm font-medium text-muted-foreground text-blue-500'\r\n style={{\r\n width: boundigClient?.width,\r\n }}\r\n >\r\n <Sparkles className='mr-2 h-4 w-4 shrink-0 ' />\r\n AI (Beta) is thinking\r\n <div className='ml-2 mt-1'>\r\n <CrazySpinner />\r\n </div>\r\n </div>\r\n )}\r\n\r\n {!isLoading && (\r\n <>\r\n <div className='flex justify-between items-center '>\r\n <Sparkles className='mr-2 h-4 w-4 shrink-0 text-blue-500 ' />\r\n <TextareaAutosize\r\n ref={inputRef}\r\n style={{ resize: 'none' }}\r\n className='w-full p-2 text-black bg-white rounded dark:bg-black dark:text-white focus:outline-none outline-none border-0 '\r\n value={inputValue}\r\n onChange={(e) => {\r\n editor.storage.aiCommand.userPrompt = e.target.value\r\n setInputValue(e.target.value)\r\n }}\r\n placeholder={\r\n hasCompletion\r\n ? i18next.t('tellAiPlaceholder') || 'Tell AI (Beta) what to do next'\r\n : i18next.t('askAiPlaceholder') || 'Ask AI (Beta) to edit or generate...'\r\n }\r\n autoFocus\r\n onKeyDown={(e) => {\r\n if (e.key === 'Enter') handleClick()\r\n }}\r\n />\r\n <Toolbar.Button onClick={handleClick}>\r\n <ArrowUpCircle />\r\n </Toolbar.Button>\r\n </div>\r\n </>\r\n )}\r\n </>\r\n </Surface>\r\n {!isLoading && (\r\n <Surface\r\n ref={scrollContainer}\r\n className='text-black max-h-[min(80vh,24rem)] overflow-auto flex-wrap mb-8 p-2'\r\n >\r\n <div className='grid grid-cols-1 gap-0.5'>\r\n {hasCompletion ? (\r\n <AISelectorCommands\r\n editor={editor}\r\n messages={object}\r\n onSelect={(value, options) => {\r\n if (options?.option === 'translate') {\r\n submit({ prompt: value, body: options })\r\n } else {\r\n submit({\r\n prompt: value,\r\n body: { ...options, source: editor?.storage?.aiCommand?.language },\r\n })\r\n }\r\n }}\r\n />\r\n ) : (\r\n items.map((group, groupIndex: number) => (\r\n <React.Fragment key={`${group.title}-wrapper`}>\r\n <div\r\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'\r\n key={`${group.title}`}\r\n >\r\n {group.title}\r\n </div>\r\n {group.commands.map((command: Command, commandIndex: number) => (\r\n <DropdownButton\r\n key={`${command.label}`}\r\n isActive={\r\n selectedGroupIndex === groupIndex && selectedCommandIndex === commandIndex\r\n }\r\n onClick={createCommandClickHandler(groupIndex, commandIndex)}\r\n >\r\n <Icon icon={command.icon} className='mr-1' />\r\n {command.label}\r\n </DropdownButton>\r\n ))}\r\n </React.Fragment>\r\n ))\r\n )}\r\n </div>\r\n </Surface>\r\n )}\r\n </>\r\n )\r\n },\r\n)\r\n"],"names":["ArrowUpCircle","Sparkles","React","forwardRef","useCallback","useEffect","useImperativeHandle","useRef","useState","Markdown","TextareaAutosize","experimental_useObject","useObject","i18next","TiptapSchema","AISelectorCommands","CrazySpinner","DropdownButton","Icon","ScrollArea","Surface","Toolbar","useExtractMarkdown","AICommandPanel","editor","onOpenChange","userPrompt","items","restProps","ref","inputValue","setInputValue","view","scrollContainer","activeItem","selectedGroupIndex","setSelectedGroupIndex","selectedCommandIndex","setSelectedCommandIndex","editorNode","dom","boundigClient","getBoundingClientRect","inputRef","object","submit","isLoading","api","schema","markdown","hasCompletion","Boolean","handleClick","prompt","body","option","command","language","storage","aiCommand","selection","completion","content","selectItem","groupIndex","commandIndex","commands","action","onKeyDown","event","key","length","newCommandIndex","newGroupIndex","current","offsetTop","offsetHeight","scrollTop","createCommandClickHandler","className","style","width","div","dir","resize","value","onChange","e","target","placeholder","t","autoFocus","Button","onClick","messages","onSelect","options","source","map","group","Fragment","title","isActive","icon","label"],"mappings":"AAAA;;AAC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AIH,WAAU;8BACZ7B,8BACC,KAACnC;wBACCS,QAAQA;wBACRsE,UAAUlD;wBACVmD,UAAU,CAACV,OAAOW;4BAChB,IAAIA,SAASzC,WAAW,aAAa;gCACnCV,OAAO;oCAAEQ,QAAQgC;oCAAO/B,MAAM0C;gCAAQ;4BACxC,OAAO;gCACLnD,OAAO;oCACLQ,QAAQgC;oCACR/B,MAAM;wCAAE,GAAG0C,OAAO;wCAAEC,QAAQzE,QAAQkC,SAASC,WAAWF;oCAAS;gCACnE;4BACF;wBACF;yBAGF9B,MAAMuE,GAAG,CAAC,CAACC,OAAOnC,2BAChB,MAAC9D,MAAMkG,QAAQ;;8CACb,KAAClB;oCACCH,WAAU;8CAGToB,MAAME,KAAK;mCAFP,CAAC,EAAEF,MAAME,KAAK,CAAC,CAAC;gCAItBF,MAAMjC,QAAQ,CAACgC,GAAG,CAAC,CAAC1C,SAAkBS,6BACrC,MAAChD;wCAECqF,UACEnE,uBAAuB6B,cAAc3B,yBAAyB4B;wCAEhE4B,SAASf,0BAA0Bd,YAAYC;;0DAE/C,KAAC/C;gDAAKqF,MAAM/C,QAAQ+C,IAAI;gDAAExB,WAAU;;4CACnCvB,QAAQgD,KAAK;;uCAPT,CAAC,EAAEhD,QAAQgD,KAAK,CAAC,CAAC;;2BATR,CAAC,EAAEL,MAAME,KAAK,CAAC,QAAQ,CAAC;;;;;AA2B7D,GACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AIEditorPanel.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AIEditorPanel/AIEditorPanel.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAmBtC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;CACvC,CAAA;AAED,eAAO,MAAM,aAAa,6BAA8B,kBAAkB,
|
|
1
|
+
{"version":3,"file":"AIEditorPanel.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AIEditorPanel/AIEditorPanel.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAmBtC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;CACvC,CAAA;AAED,eAAO,MAAM,aAAa,6BAA8B,kBAAkB,gCAmHzE,CAAA"}
|
|
@@ -68,12 +68,10 @@ export const AIEditorPanel = ({ editor, onOpenChange })=>{
|
|
|
68
68
|
markdown && /*#__PURE__*/ _jsx("div", {
|
|
69
69
|
className: "flex w-full",
|
|
70
70
|
children: /*#__PURE__*/ _jsx(ScrollArea, {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
children:
|
|
75
|
-
children: markdown
|
|
76
|
-
})
|
|
71
|
+
className: "prose p-2 px-4 prose-sm max-h-96",
|
|
72
|
+
dir: i18next.dir(),
|
|
73
|
+
children: /*#__PURE__*/ _jsx(Markdown, {
|
|
74
|
+
children: markdown
|
|
77
75
|
})
|
|
78
76
|
})
|
|
79
77
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AIEditorPanel/AIEditorPanel.tsx"],"sourcesContent":["'use client'\r\n\r\nimport { Editor } from '@tiptap/react'\r\nimport { ArrowRight, Sparkles } from 'lucide-react'\r\nimport { useCallback, useEffect, useRef, useState } from 'react'\r\nimport TextareaAutosize from 'react-textarea-autosize'\r\n\r\nimport { experimental_useObject as useObject } from '@ai-sdk/react'\r\nimport i18next from 'i18next'\r\nimport Markdown from 'react-markdown'\r\nimport { extractMarkdown } from '../../../lib/extract.js'\r\nimport { TiptapSchema } from '../../../lib/tiptapSchema.js'\r\nimport { getPrevText } from '../../../lib/utils/index.js'\r\nimport AICompletionCommands from '../../menus/TextMenu/components/ai-completion-command.js'\r\nimport AISelectorCommands from '../../menus/TextMenu/components/ai-selector-commands.js'\r\nimport { Surface } from '../../ui/Surface.js'\r\nimport { Toolbar } from '../../ui/Toolbar.js'\r\nimport CrazySpinner from '../../ui/crazy-spinner.js'\r\nimport { ScrollArea } from '../../ui/scroll-area.js'\r\nimport { useExtractMarkdown } from './markdown.hook.js'\r\n\r\nexport type AIEditorPanelProps = {\r\n editor: Editor\r\n onOpenChange: (value: boolean) => void\r\n}\r\n\r\nexport const AIEditorPanel = ({ editor, onOpenChange }: AIEditorPanelProps) => {\r\n const [inputValue, setInputValue] = useState('')\r\n const { view } = editor\r\n\r\n const editorNode = view.dom as HTMLElement\r\n const boundigClient = editorNode.getBoundingClientRect()\r\n const inputRef = useRef<HTMLTextAreaElement>(null)\r\n\r\n const { object, submit, isLoading } = useObject({\r\n api: '/api/generate',\r\n schema: TiptapSchema,\r\n })\r\n const hasCompletion = Boolean(object)\r\n\r\n const handleClick = useCallback(() => {\r\n if (object) {\r\n submit({\r\n prompt: object,\r\n body: {\r\n option: 'zap',\r\n command: inputValue,\r\n language: editor?.storage?.aiCommand?.language,\r\n },\r\n })\r\n setInputValue('')\r\n return\r\n }\r\n const text = getPrevText(editor, { chars: 5000 })\r\n\r\n submit({\r\n prompt: text,\r\n body: {\r\n option: 'zap',\r\n command: inputValue,\r\n language: editor?.storage?.aiCommand?.language,\r\n },\r\n })\r\n setInputValue('')\r\n }, [editor?.storage?.aiCommand?.language, inputValue, object, submit])\r\n\r\n const { markdown } = useExtractMarkdown(object)\r\n return (\r\n <Surface\r\n className={`p-2 min-w-[20rem] `}\r\n style={{\r\n width: boundigClient?.width,\r\n }}\r\n >\r\n <>\r\n {markdown && (\r\n <div className='flex w-full'>\r\n <ScrollArea
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AIEditorPanel/AIEditorPanel.tsx"],"sourcesContent":["'use client'\r\n\r\nimport { Editor } from '@tiptap/react'\r\nimport { ArrowRight, Sparkles } from 'lucide-react'\r\nimport { useCallback, useEffect, useRef, useState } from 'react'\r\nimport TextareaAutosize from 'react-textarea-autosize'\r\n\r\nimport { experimental_useObject as useObject } from '@ai-sdk/react'\r\nimport i18next from 'i18next'\r\nimport Markdown from 'react-markdown'\r\nimport { extractMarkdown } from '../../../lib/extract.js'\r\nimport { TiptapSchema } from '../../../lib/tiptapSchema.js'\r\nimport { getPrevText } from '../../../lib/utils/index.js'\r\nimport AICompletionCommands from '../../menus/TextMenu/components/ai-completion-command.js'\r\nimport AISelectorCommands from '../../menus/TextMenu/components/ai-selector-commands.js'\r\nimport { Surface } from '../../ui/Surface.js'\r\nimport { Toolbar } from '../../ui/Toolbar.js'\r\nimport CrazySpinner from '../../ui/crazy-spinner.js'\r\nimport { ScrollArea } from '../../ui/scroll-area.js'\r\nimport { useExtractMarkdown } from './markdown.hook.js'\r\n\r\nexport type AIEditorPanelProps = {\r\n editor: Editor\r\n onOpenChange: (value: boolean) => void\r\n}\r\n\r\nexport const AIEditorPanel = ({ editor, onOpenChange }: AIEditorPanelProps) => {\r\n const [inputValue, setInputValue] = useState('')\r\n const { view } = editor\r\n\r\n const editorNode = view.dom as HTMLElement\r\n const boundigClient = editorNode.getBoundingClientRect()\r\n const inputRef = useRef<HTMLTextAreaElement>(null)\r\n\r\n const { object, submit, isLoading } = useObject({\r\n api: '/api/generate',\r\n schema: TiptapSchema,\r\n })\r\n const hasCompletion = Boolean(object)\r\n\r\n const handleClick = useCallback(() => {\r\n if (object) {\r\n submit({\r\n prompt: object,\r\n body: {\r\n option: 'zap',\r\n command: inputValue,\r\n language: editor?.storage?.aiCommand?.language,\r\n },\r\n })\r\n setInputValue('')\r\n return\r\n }\r\n const text = getPrevText(editor, { chars: 5000 })\r\n\r\n submit({\r\n prompt: text,\r\n body: {\r\n option: 'zap',\r\n command: inputValue,\r\n language: editor?.storage?.aiCommand?.language,\r\n },\r\n })\r\n setInputValue('')\r\n }, [editor?.storage?.aiCommand?.language, inputValue, object, submit])\r\n\r\n const { markdown } = useExtractMarkdown(object)\r\n return (\r\n <Surface\r\n className={`p-2 min-w-[20rem] `}\r\n style={{\r\n width: boundigClient?.width,\r\n }}\r\n >\r\n <>\r\n {markdown && (\r\n <div className='flex w-full'>\r\n <ScrollArea className='prose p-2 px-4 prose-sm max-h-96' dir={i18next.dir()}>\r\n <Markdown>{markdown}</Markdown>\r\n </ScrollArea>\r\n </div>\r\n )}\r\n\r\n {isLoading && (\r\n <div className='flex h-12 w-full items-center px-4 text-sm font-medium text-muted-foreground text-blue-500'>\r\n <Sparkles className='mr-2 h-4 w-4 shrink-0 ' />\r\n AI (Beta) is thinking\r\n <div className='ml-2 mt-1'>\r\n <CrazySpinner />\r\n </div>\r\n </div>\r\n )}\r\n\r\n {!isLoading && (\r\n <>\r\n <div className='flex justify-between items-center'>\r\n <Sparkles className='mr-2 h-4 w-4 shrink-0 text-blue-500 ' />\r\n <TextareaAutosize\r\n ref={inputRef}\r\n className='w-full p-2 text-black bg-white rounded dark:bg-black dark:text-white focus:outline-none'\r\n value={inputValue}\r\n onChange={(e) => {\r\n setInputValue(e.target.value)\r\n }}\r\n placeholder={\r\n hasCompletion\r\n ? i18next.t('tellAiPlaceholder') || 'Tell AI (Beta) what to do next'\r\n : i18next.t('askAiPlaceholder') || 'Ask AI (Beta) to edit or generate...'\r\n }\r\n autoFocus\r\n onKeyDown={(e) => {\r\n if (e.key === 'Enter') handleClick()\r\n }}\r\n />\r\n <Toolbar.Button onClick={handleClick}>\r\n <ArrowRight />\r\n </Toolbar.Button>\r\n </div>\r\n {hasCompletion ? (\r\n <AICompletionCommands\r\n editor={editor}\r\n onDiscard={() => {\r\n editor?.chain()?.focus()?.run()\r\n onOpenChange(false)\r\n }}\r\n completion={object}\r\n />\r\n ) : (\r\n <AISelectorCommands\r\n messages={object}\r\n editor={editor}\r\n onSelect={(value, options) => {\r\n submit({ prompt: value, body: options as any })\r\n }}\r\n />\r\n )}\r\n </>\r\n )}\r\n </>\r\n </Surface>\r\n )\r\n}\r\n"],"names":["ArrowRight","Sparkles","useCallback","useRef","useState","TextareaAutosize","experimental_useObject","useObject","i18next","Markdown","TiptapSchema","getPrevText","AICompletionCommands","AISelectorCommands","Surface","Toolbar","CrazySpinner","ScrollArea","useExtractMarkdown","AIEditorPanel","editor","onOpenChange","inputValue","setInputValue","view","editorNode","dom","boundigClient","getBoundingClientRect","inputRef","object","submit","isLoading","api","schema","hasCompletion","Boolean","handleClick","prompt","body","option","command","language","storage","aiCommand","text","chars","markdown","className","style","width","div","dir","ref","value","onChange","e","target","placeholder","t","autoFocus","onKeyDown","key","Button","onClick","onDiscard","chain","focus","run","completion","messages","onSelect","options"],"mappings":"AAAA;;AAGA,SAASA,UAAU,EAAEC,QAAQ,QAAQ,eAAc;AACnD,SAASC,WAAW,EAAaC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAChE,OAAOC,sBAAsB,0BAAyB;AAEtD,SAASC,0BAA0BC,SAAS,QAAQ,gBAAe;AACnE,OAAOC,aAAa,UAAS;AAC7B,OAAOC,cAAc,iBAAgB;AAErC,SAASC,YAAY,QAAQ,+BAA8B;AAC3D,SAASC,WAAW,QAAQ,8BAA6B;AACzD,OAAOC,0BAA0B,2DAA0D;AAC3F,OAAOC,wBAAwB,0DAAyD;AACxF,SAASC,OAAO,QAAQ,sBAAqB;AAC7C,SAASC,OAAO,QAAQ,sBAAqB;AAC7C,OAAOC,kBAAkB,4BAA2B;AACpD,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,kBAAkB,QAAQ,qBAAoB;AAOvD,OAAO,MAAMC,gBAAgB,CAAC,EAAEC,MAAM,EAAEC,YAAY,EAAsB;IACxE,MAAM,CAACC,YAAYC,cAAc,GAAGnB,SAAS;IAC7C,MAAM,EAAEoB,IAAI,EAAE,GAAGJ;IAEjB,MAAMK,aAAaD,KAAKE,GAAG;IAC3B,MAAMC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U,CAACC;wCACTjC,cAAciC,EAAEC,MAAM,CAACH,KAAK;oCAC9B;oCACAI,aACEvB,gBACI3B,QAAQmD,CAAC,CAAC,wBAAwB,mCAClCnD,QAAQmD,CAAC,CAAC,uBAAuB;oCAEvCC,SAAS;oCACTC,WAAW,CAACL;wCACV,IAAIA,EAAEM,GAAG,KAAK,SAASzB;oCACzB;;8CAEF,KAACtB,QAAQgD,MAAM;oCAACC,SAAS3B;8CACvB,cAAA,KAACrC;;;;wBAGJmC,8BACC,KAACvB;4BACCQ,QAAQA;4BACR6C,WAAW;gCACT7C,QAAQ8C,SAASC,SAASC;gCAC1B/C,aAAa;4BACf;4BACAgD,YAAYvC;2CAGd,KAACjB;4BACCyD,UAAUxC;4BACVV,QAAQA;4BACRmD,UAAU,CAACjB,OAAOkB;gCAChBzC,OAAO;oCAAEO,QAAQgB;oCAAOf,MAAMiC;gCAAe;4BAC/C;;;;;;;AAQhB,EAAC"}
|
|
@@ -19,21 +19,21 @@ export declare const JSONContentSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
19
19
|
attrs?: Record<string, any>;
|
|
20
20
|
}>, "many">>;
|
|
21
21
|
}>, "strip", z.ZodTypeAny, {
|
|
22
|
+
type?: string;
|
|
23
|
+
attrs?: Record<string, any>;
|
|
22
24
|
text?: string;
|
|
23
25
|
marks?: {
|
|
24
26
|
type?: string;
|
|
25
27
|
attrs?: Record<string, any>;
|
|
26
28
|
}[];
|
|
29
|
+
}, {
|
|
27
30
|
type?: string;
|
|
28
31
|
attrs?: Record<string, any>;
|
|
29
|
-
}, {
|
|
30
32
|
text?: string;
|
|
31
33
|
marks?: {
|
|
32
34
|
type?: string;
|
|
33
35
|
attrs?: Record<string, any>;
|
|
34
36
|
}[];
|
|
35
|
-
type?: string;
|
|
36
|
-
attrs?: Record<string, any>;
|
|
37
37
|
}>, z.ZodObject<z.objectUtil.extendShape<{
|
|
38
38
|
type: z.ZodString;
|
|
39
39
|
attrs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
@@ -54,21 +54,21 @@ export declare const JSONContentSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
54
54
|
attrs?: Record<string, any>;
|
|
55
55
|
}>, "many">>;
|
|
56
56
|
}>, "strip", z.ZodTypeAny, {
|
|
57
|
+
type?: string;
|
|
58
|
+
attrs?: Record<string, any>;
|
|
57
59
|
text?: string;
|
|
58
60
|
marks?: {
|
|
59
61
|
type?: string;
|
|
60
62
|
attrs?: Record<string, any>;
|
|
61
63
|
}[];
|
|
64
|
+
}, {
|
|
62
65
|
type?: string;
|
|
63
66
|
attrs?: Record<string, any>;
|
|
64
|
-
}, {
|
|
65
67
|
text?: string;
|
|
66
68
|
marks?: {
|
|
67
69
|
type?: string;
|
|
68
70
|
attrs?: Record<string, any>;
|
|
69
71
|
}[];
|
|
70
|
-
type?: string;
|
|
71
|
-
attrs?: Record<string, any>;
|
|
72
72
|
}>, z.ZodObject<{
|
|
73
73
|
type: z.ZodString;
|
|
74
74
|
attrs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
@@ -80,89 +80,89 @@ export declare const JSONContentSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
80
80
|
attrs?: Record<string, any>;
|
|
81
81
|
}>]>, "many">>;
|
|
82
82
|
}>, "strip", z.ZodTypeAny, {
|
|
83
|
+
type?: string;
|
|
83
84
|
content?: ({
|
|
84
85
|
type?: string;
|
|
85
86
|
attrs?: Record<string, any>;
|
|
86
87
|
} | {
|
|
88
|
+
type?: string;
|
|
89
|
+
attrs?: Record<string, any>;
|
|
87
90
|
text?: string;
|
|
88
91
|
marks?: {
|
|
89
92
|
type?: string;
|
|
90
93
|
attrs?: Record<string, any>;
|
|
91
94
|
}[];
|
|
92
|
-
type?: string;
|
|
93
|
-
attrs?: Record<string, any>;
|
|
94
95
|
})[];
|
|
95
|
-
type?: string;
|
|
96
96
|
attrs?: Record<string, any>;
|
|
97
97
|
}, {
|
|
98
|
+
type?: string;
|
|
98
99
|
content?: ({
|
|
99
100
|
type?: string;
|
|
100
101
|
attrs?: Record<string, any>;
|
|
101
102
|
} | {
|
|
103
|
+
type?: string;
|
|
104
|
+
attrs?: Record<string, any>;
|
|
102
105
|
text?: string;
|
|
103
106
|
marks?: {
|
|
104
107
|
type?: string;
|
|
105
108
|
attrs?: Record<string, any>;
|
|
106
109
|
}[];
|
|
107
|
-
type?: string;
|
|
108
|
-
attrs?: Record<string, any>;
|
|
109
110
|
})[];
|
|
110
|
-
type?: string;
|
|
111
111
|
attrs?: Record<string, any>;
|
|
112
112
|
}>]>, "many">>;
|
|
113
113
|
}>, "strip", z.ZodTypeAny, {
|
|
114
|
+
type?: string;
|
|
114
115
|
content?: ({
|
|
116
|
+
type?: string;
|
|
117
|
+
attrs?: Record<string, any>;
|
|
115
118
|
text?: string;
|
|
116
119
|
marks?: {
|
|
117
120
|
type?: string;
|
|
118
121
|
attrs?: Record<string, any>;
|
|
119
122
|
}[];
|
|
120
|
-
type?: string;
|
|
121
|
-
attrs?: Record<string, any>;
|
|
122
123
|
} | {
|
|
124
|
+
type?: string;
|
|
123
125
|
content?: ({
|
|
124
126
|
type?: string;
|
|
125
127
|
attrs?: Record<string, any>;
|
|
126
128
|
} | {
|
|
129
|
+
type?: string;
|
|
130
|
+
attrs?: Record<string, any>;
|
|
127
131
|
text?: string;
|
|
128
132
|
marks?: {
|
|
129
133
|
type?: string;
|
|
130
134
|
attrs?: Record<string, any>;
|
|
131
135
|
}[];
|
|
132
|
-
type?: string;
|
|
133
|
-
attrs?: Record<string, any>;
|
|
134
136
|
})[];
|
|
135
|
-
type?: string;
|
|
136
137
|
attrs?: Record<string, any>;
|
|
137
138
|
})[];
|
|
138
|
-
type?: string;
|
|
139
139
|
attrs?: Record<string, any>;
|
|
140
140
|
}, {
|
|
141
|
+
type?: string;
|
|
141
142
|
content?: ({
|
|
143
|
+
type?: string;
|
|
144
|
+
attrs?: Record<string, any>;
|
|
142
145
|
text?: string;
|
|
143
146
|
marks?: {
|
|
144
147
|
type?: string;
|
|
145
148
|
attrs?: Record<string, any>;
|
|
146
149
|
}[];
|
|
147
|
-
type?: string;
|
|
148
|
-
attrs?: Record<string, any>;
|
|
149
150
|
} | {
|
|
151
|
+
type?: string;
|
|
150
152
|
content?: ({
|
|
151
153
|
type?: string;
|
|
152
154
|
attrs?: Record<string, any>;
|
|
153
155
|
} | {
|
|
156
|
+
type?: string;
|
|
157
|
+
attrs?: Record<string, any>;
|
|
154
158
|
text?: string;
|
|
155
159
|
marks?: {
|
|
156
160
|
type?: string;
|
|
157
161
|
attrs?: Record<string, any>;
|
|
158
162
|
}[];
|
|
159
|
-
type?: string;
|
|
160
|
-
attrs?: Record<string, any>;
|
|
161
163
|
})[];
|
|
162
|
-
type?: string;
|
|
163
164
|
attrs?: Record<string, any>;
|
|
164
165
|
})[];
|
|
165
|
-
type?: string;
|
|
166
166
|
attrs?: Record<string, any>;
|
|
167
167
|
}>;
|
|
168
168
|
export declare const TiptapSchema: z.ZodObject<{
|
|
@@ -187,21 +187,21 @@ export declare const TiptapSchema: z.ZodObject<{
|
|
|
187
187
|
attrs?: Record<string, any>;
|
|
188
188
|
}>, "many">>;
|
|
189
189
|
}>, "strip", z.ZodTypeAny, {
|
|
190
|
+
type?: string;
|
|
191
|
+
attrs?: Record<string, any>;
|
|
190
192
|
text?: string;
|
|
191
193
|
marks?: {
|
|
192
194
|
type?: string;
|
|
193
195
|
attrs?: Record<string, any>;
|
|
194
196
|
}[];
|
|
197
|
+
}, {
|
|
195
198
|
type?: string;
|
|
196
199
|
attrs?: Record<string, any>;
|
|
197
|
-
}, {
|
|
198
200
|
text?: string;
|
|
199
201
|
marks?: {
|
|
200
202
|
type?: string;
|
|
201
203
|
attrs?: Record<string, any>;
|
|
202
204
|
}[];
|
|
203
|
-
type?: string;
|
|
204
|
-
attrs?: Record<string, any>;
|
|
205
205
|
}>, z.ZodObject<z.objectUtil.extendShape<{
|
|
206
206
|
type: z.ZodString;
|
|
207
207
|
attrs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
@@ -222,21 +222,21 @@ export declare const TiptapSchema: z.ZodObject<{
|
|
|
222
222
|
attrs?: Record<string, any>;
|
|
223
223
|
}>, "many">>;
|
|
224
224
|
}>, "strip", z.ZodTypeAny, {
|
|
225
|
+
type?: string;
|
|
226
|
+
attrs?: Record<string, any>;
|
|
225
227
|
text?: string;
|
|
226
228
|
marks?: {
|
|
227
229
|
type?: string;
|
|
228
230
|
attrs?: Record<string, any>;
|
|
229
231
|
}[];
|
|
232
|
+
}, {
|
|
230
233
|
type?: string;
|
|
231
234
|
attrs?: Record<string, any>;
|
|
232
|
-
}, {
|
|
233
235
|
text?: string;
|
|
234
236
|
marks?: {
|
|
235
237
|
type?: string;
|
|
236
238
|
attrs?: Record<string, any>;
|
|
237
239
|
}[];
|
|
238
|
-
type?: string;
|
|
239
|
-
attrs?: Record<string, any>;
|
|
240
240
|
}>, z.ZodObject<{
|
|
241
241
|
type: z.ZodString;
|
|
242
242
|
attrs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
@@ -248,150 +248,150 @@ export declare const TiptapSchema: z.ZodObject<{
|
|
|
248
248
|
attrs?: Record<string, any>;
|
|
249
249
|
}>]>, "many">>;
|
|
250
250
|
}>, "strip", z.ZodTypeAny, {
|
|
251
|
+
type?: string;
|
|
251
252
|
content?: ({
|
|
252
253
|
type?: string;
|
|
253
254
|
attrs?: Record<string, any>;
|
|
254
255
|
} | {
|
|
256
|
+
type?: string;
|
|
257
|
+
attrs?: Record<string, any>;
|
|
255
258
|
text?: string;
|
|
256
259
|
marks?: {
|
|
257
260
|
type?: string;
|
|
258
261
|
attrs?: Record<string, any>;
|
|
259
262
|
}[];
|
|
260
|
-
type?: string;
|
|
261
|
-
attrs?: Record<string, any>;
|
|
262
263
|
})[];
|
|
263
|
-
type?: string;
|
|
264
264
|
attrs?: Record<string, any>;
|
|
265
265
|
}, {
|
|
266
|
+
type?: string;
|
|
266
267
|
content?: ({
|
|
267
268
|
type?: string;
|
|
268
269
|
attrs?: Record<string, any>;
|
|
269
270
|
} | {
|
|
271
|
+
type?: string;
|
|
272
|
+
attrs?: Record<string, any>;
|
|
270
273
|
text?: string;
|
|
271
274
|
marks?: {
|
|
272
275
|
type?: string;
|
|
273
276
|
attrs?: Record<string, any>;
|
|
274
277
|
}[];
|
|
275
|
-
type?: string;
|
|
276
|
-
attrs?: Record<string, any>;
|
|
277
278
|
})[];
|
|
278
|
-
type?: string;
|
|
279
279
|
attrs?: Record<string, any>;
|
|
280
280
|
}>]>, "many">>;
|
|
281
281
|
}>, "strip", z.ZodTypeAny, {
|
|
282
|
+
type?: string;
|
|
282
283
|
content?: ({
|
|
284
|
+
type?: string;
|
|
285
|
+
attrs?: Record<string, any>;
|
|
283
286
|
text?: string;
|
|
284
287
|
marks?: {
|
|
285
288
|
type?: string;
|
|
286
289
|
attrs?: Record<string, any>;
|
|
287
290
|
}[];
|
|
288
|
-
type?: string;
|
|
289
|
-
attrs?: Record<string, any>;
|
|
290
291
|
} | {
|
|
292
|
+
type?: string;
|
|
291
293
|
content?: ({
|
|
292
294
|
type?: string;
|
|
293
295
|
attrs?: Record<string, any>;
|
|
294
296
|
} | {
|
|
297
|
+
type?: string;
|
|
298
|
+
attrs?: Record<string, any>;
|
|
295
299
|
text?: string;
|
|
296
300
|
marks?: {
|
|
297
301
|
type?: string;
|
|
298
302
|
attrs?: Record<string, any>;
|
|
299
303
|
}[];
|
|
300
|
-
type?: string;
|
|
301
|
-
attrs?: Record<string, any>;
|
|
302
304
|
})[];
|
|
303
|
-
type?: string;
|
|
304
305
|
attrs?: Record<string, any>;
|
|
305
306
|
})[];
|
|
306
|
-
type?: string;
|
|
307
307
|
attrs?: Record<string, any>;
|
|
308
308
|
}, {
|
|
309
|
+
type?: string;
|
|
309
310
|
content?: ({
|
|
311
|
+
type?: string;
|
|
312
|
+
attrs?: Record<string, any>;
|
|
310
313
|
text?: string;
|
|
311
314
|
marks?: {
|
|
312
315
|
type?: string;
|
|
313
316
|
attrs?: Record<string, any>;
|
|
314
317
|
}[];
|
|
315
|
-
type?: string;
|
|
316
|
-
attrs?: Record<string, any>;
|
|
317
318
|
} | {
|
|
319
|
+
type?: string;
|
|
318
320
|
content?: ({
|
|
319
321
|
type?: string;
|
|
320
322
|
attrs?: Record<string, any>;
|
|
321
323
|
} | {
|
|
324
|
+
type?: string;
|
|
325
|
+
attrs?: Record<string, any>;
|
|
322
326
|
text?: string;
|
|
323
327
|
marks?: {
|
|
324
328
|
type?: string;
|
|
325
329
|
attrs?: Record<string, any>;
|
|
326
330
|
}[];
|
|
327
|
-
type?: string;
|
|
328
|
-
attrs?: Record<string, any>;
|
|
329
331
|
})[];
|
|
330
|
-
type?: string;
|
|
331
332
|
attrs?: Record<string, any>;
|
|
332
333
|
})[];
|
|
333
|
-
type?: string;
|
|
334
334
|
attrs?: Record<string, any>;
|
|
335
335
|
}>, "many">;
|
|
336
336
|
}, "strip", z.ZodTypeAny, {
|
|
337
|
+
type?: "doc";
|
|
337
338
|
content?: {
|
|
339
|
+
type?: string;
|
|
338
340
|
content?: ({
|
|
341
|
+
type?: string;
|
|
342
|
+
attrs?: Record<string, any>;
|
|
339
343
|
text?: string;
|
|
340
344
|
marks?: {
|
|
341
345
|
type?: string;
|
|
342
346
|
attrs?: Record<string, any>;
|
|
343
347
|
}[];
|
|
344
|
-
type?: string;
|
|
345
|
-
attrs?: Record<string, any>;
|
|
346
348
|
} | {
|
|
349
|
+
type?: string;
|
|
347
350
|
content?: ({
|
|
348
351
|
type?: string;
|
|
349
352
|
attrs?: Record<string, any>;
|
|
350
353
|
} | {
|
|
354
|
+
type?: string;
|
|
355
|
+
attrs?: Record<string, any>;
|
|
351
356
|
text?: string;
|
|
352
357
|
marks?: {
|
|
353
358
|
type?: string;
|
|
354
359
|
attrs?: Record<string, any>;
|
|
355
360
|
}[];
|
|
356
|
-
type?: string;
|
|
357
|
-
attrs?: Record<string, any>;
|
|
358
361
|
})[];
|
|
359
|
-
type?: string;
|
|
360
362
|
attrs?: Record<string, any>;
|
|
361
363
|
})[];
|
|
362
|
-
type?: string;
|
|
363
364
|
attrs?: Record<string, any>;
|
|
364
365
|
}[];
|
|
365
|
-
type?: "doc";
|
|
366
366
|
}, {
|
|
367
|
+
type?: "doc";
|
|
367
368
|
content?: {
|
|
369
|
+
type?: string;
|
|
368
370
|
content?: ({
|
|
371
|
+
type?: string;
|
|
372
|
+
attrs?: Record<string, any>;
|
|
369
373
|
text?: string;
|
|
370
374
|
marks?: {
|
|
371
375
|
type?: string;
|
|
372
376
|
attrs?: Record<string, any>;
|
|
373
377
|
}[];
|
|
374
|
-
type?: string;
|
|
375
|
-
attrs?: Record<string, any>;
|
|
376
378
|
} | {
|
|
379
|
+
type?: string;
|
|
377
380
|
content?: ({
|
|
378
381
|
type?: string;
|
|
379
382
|
attrs?: Record<string, any>;
|
|
380
383
|
} | {
|
|
384
|
+
type?: string;
|
|
385
|
+
attrs?: Record<string, any>;
|
|
381
386
|
text?: string;
|
|
382
387
|
marks?: {
|
|
383
388
|
type?: string;
|
|
384
389
|
attrs?: Record<string, any>;
|
|
385
390
|
}[];
|
|
386
|
-
type?: string;
|
|
387
|
-
attrs?: Record<string, any>;
|
|
388
391
|
})[];
|
|
389
|
-
type?: string;
|
|
390
392
|
attrs?: Record<string, any>;
|
|
391
393
|
})[];
|
|
392
|
-
type?: string;
|
|
393
394
|
attrs?: Record<string, any>;
|
|
394
395
|
}[];
|
|
395
|
-
type?: "doc";
|
|
396
396
|
}>;
|
|
397
397
|
//# sourceMappingURL=tiptapSchema.d.ts.map
|