payload-richtext-tiptap 0.0.144 → 0.0.146
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/LinkPreview/LinkPreview.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/LinkPreview/LinkPreview.js +11 -7
- package/dist/src/fields/TiptapEditor/extensions/LinkPreview/LinkPreview.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/SocialMedia/Facebook/facebook.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Instagram/instagram.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Tiktok/tiktok.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Twitter/twitter.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Youtube/youtube.js.map +1 -1
- 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/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/EmbedContentInlineRenderer.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/serverside/EmbedContentSideRenderer.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/serverside/EmbedContentSidebarRenderer.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/ServersideTiptapBody.js +1 -1
- package/dist/src/fields/TiptapEditor/extensions/serverside/ServersideTiptapBody.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/extensions/serverside/getAssetsAspectRatio.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/panels/AICommandPanel/AICommandPanel.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/tiptapSchema.d.ts +62 -62
- package/dist/src/fields/TiptapEditor/lib/utils/cssVar.js.map +1 -1
- package/dist/src/mobile.css +1 -1
- package/dist/src/styles.css +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +200 -204
|
@@ -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?.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;;AACA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,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ACCS,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
|
+
{"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;;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,MAAM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B,yBAAyB4B;wCAEhE4B,SAASf,0BAA0Bd,YAAYC;;0DAE/C,KAAC/C;gDAAKqF,MAAM/C,QAAQ+C,IAAI;gDAAExB,WAAU;;4CACnCvB,QAAQgD,KAAK;;uCAPT,GAAGhD,QAAQgD,KAAK,EAAE;;2BATR,GAAGL,MAAME,KAAK,CAAC,QAAQ,CAAC;;;;;AA2B7D,GACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AIEditorPanel/utils.ts"],"sourcesContent":["\r\nimport json5 from 'json5';\r\n\r\nexport const convertBody = (body: string) => {\r\n try {\r\n let parsedBody = body.replace('```json', '').replace('```', '');\r\n parsedBody = json5.parse(parsedBody);\r\n return parsedBody as unknown as object[];\r\n } catch (error) {\r\n try {\r\n const fixedJson = jsonFixer(body);\r\n return json5.parse(fixedJson);\r\n } catch (error) {\r\n console.error('Error occured When parsing translated error: ', error);\r\n console.error('Error occured When parsing translated body ', body);\r\n throw new Error(\r\n `Openapi translate with assistant An error occurred while processing your request .error: ${error} body: ${body}`,\r\n );\r\n }\r\n }\r\n}\r\n\r\nexport const jsonFixer = (json: string, provider?: string) => {\r\n if (provider === 'bedrock') {\r\n json += '}';\r\n }\r\n let fixedText = json\r\n .replace('```json', '')\r\n .replace('```', '')\r\n .replace(/”/g, '\"')\r\n .replace(/“/g, '\"')\r\n .replace(/’/g, \"'\")\r\n .replace(/‘/g, \"'\");\r\n\r\n const regex = /\"text\":\\s*\"([^]*)\"/g;\r\n\r\n // Metinde her text alanını kontrol et\r\n fixedText = fixedText.replace(regex, (match, p1) => {\r\n let text = p1.trim();\r\n\r\n if (!text.startsWith('\"')) {\r\n text = '\"' + text;\r\n }\r\n\r\n if (!text.endsWith('\"')) {\r\n text = text + '\"';\r\n }\r\n\r\n return `\"text\": ${text}`;\r\n });\r\n\r\n return fixedText;\r\n};\r\n\r\nexport const formatCompletion = (completion: string) => {\r\n const translatedText = completion\r\n .trim()\r\n .replace(/<translated_text>/g, '')\r\n .replace('</translated_text>', '');\r\n const body = convertBody(translatedText)\r\n return body\r\n}\r\n\r\nexport const checkJsonCompletion = (completion: string) => {\r\n return completion.includes(\"```json\") || completion.includes(\"\\\"type\\\":\") || completion.includes(\"\\\"content\\\":\")\r\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":["\r\nimport json5 from 'json5';\r\n\r\nexport const convertBody = (body: string) => {\r\n try {\r\n let parsedBody = body.replace('```json', '').replace('```', '');\r\n parsedBody = json5.parse(parsedBody);\r\n return parsedBody as unknown as object[];\r\n } catch (error) {\r\n try {\r\n const fixedJson = jsonFixer(body);\r\n return json5.parse(fixedJson);\r\n } catch (error) {\r\n console.error('Error occured When parsing translated error: ', error);\r\n console.error('Error occured When parsing translated body ', body);\r\n throw new Error(\r\n `Openapi translate with assistant An error occurred while processing your request .error: ${error} body: ${body}`,\r\n );\r\n }\r\n }\r\n}\r\n\r\nexport const jsonFixer = (json: string, provider?: string) => {\r\n if (provider === 'bedrock') {\r\n json += '}';\r\n }\r\n let fixedText = json\r\n .replace('```json', '')\r\n .replace('```', '')\r\n .replace(/”/g, '\"')\r\n .replace(/“/g, '\"')\r\n .replace(/’/g, \"'\")\r\n .replace(/‘/g, \"'\");\r\n\r\n const regex = /\"text\":\\s*\"([^]*)\"/g;\r\n\r\n // Metinde her text alanını kontrol et\r\n fixedText = fixedText.replace(regex, (match, p1) => {\r\n let text = p1.trim();\r\n\r\n if (!text.startsWith('\"')) {\r\n text = '\"' + text;\r\n }\r\n\r\n if (!text.endsWith('\"')) {\r\n text = text + '\"';\r\n }\r\n\r\n return `\"text\": ${text}`;\r\n });\r\n\r\n return fixedText;\r\n};\r\n\r\nexport const formatCompletion = (completion: string) => {\r\n const translatedText = completion\r\n .trim()\r\n .replace(/<translated_text>/g, '')\r\n .replace('</translated_text>', '');\r\n const body = convertBody(translatedText)\r\n return body\r\n}\r\n\r\nexport const checkJsonCompletion = (completion: string) => {\r\n return completion.includes(\"```json\") || completion.includes(\"\\\"type\\\":\") || completion.includes(\"\\\"content\\\":\")\r\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,MAAM;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,MAAM;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\";\r\nimport { useEffect, useMemo } from \"react\";\r\n\r\nimport { Editor, useEditor } from \"@tiptap/react\";\r\n\r\nimport ExtensionKit from \"../extensions/extension-kit.js\";\r\nimport { EditorUser } from \"../features/BlockEditor/types.js\";\r\nimport { useSidebar } from \"./useSidebar.js\";\r\n\r\nimport TurndownService from \"turndown\";\r\nimport { gfm } from \"turndown-plugin-gfm\";\r\nimport { AssetReturnType, openAssetHQType } from \"../types.js\";\r\nimport i18next from \"i18next\";\r\n\r\ndeclare global {\r\n interface Window {\r\n editor: Editor | null;\r\n }\r\n}\r\n\r\nconst dummyAssetHqHandler = (\r\n listener: (asset: AssetReturnType) => void,\r\n file?: File\r\n) => {};\r\n\r\nexport const useBlockEditor = ({\r\n content,\r\n handleChange,\r\n openAssetHQHandler,\r\n additionalContext,\r\n autoFocus,\r\n isEditable,\r\n}: {\r\n content: { html: string; json: any };\r\n handleChange?: (data: any) => void;\r\n openAssetHQHandler?: openAssetHQType;\r\n additionalContext?: Record<string, any>;\r\n autoFocus: boolean;\r\n isEditable?: boolean;\r\n}) => {\r\n const leftSidebar = useSidebar();\r\n\r\n const turndownService = new TurndownService({});\r\n // Use the gfm plugin\r\n turndownService.use(gfm);\r\n turndownService.addRule(\"twitter\", {\r\n filter: \"div\",\r\n replacement: function (content) {\r\n return \"\\n\\n\" + content + \"\\n\\n\";\r\n },\r\n });\r\n const dir = i18next.dir()\r\n\r\n const editor = useEditor(\r\n {\r\n content: content?.json ?? content ?? {},\r\n immediatelyRender: false,\r\n autofocus: autoFocus ?? true,\r\n editable: isEditable ?? true,\r\n onCreate: ({ editor }) => ({\r\n // provider?.on('synced', () => {\r\n // if (editor.isEmpty) {\r\n // editor.commands.setContent(initialContent)\r\n // }\r\n // })\r\n }),\r\n extensions: [\r\n ...ExtensionKit({\r\n dir: i18next.dir(),\r\n openAssetHQHandler: openAssetHQHandler ?? dummyAssetHqHandler,\r\n // provider,\r\n }),\r\n // Collaboration.configure({\r\n // document: ydoc,\r\n // }),\r\n // CollaborationCursor.configure({\r\n // provider,\r\n // user: {\r\n // name: randomElement(userNames),\r\n // color: randomElement(userColors),\r\n // },\r\n // }),\r\n ],\r\n editorProps: {\r\n attributes: {\r\n languages: i18next.language,\r\n autocomplete: \"off\",\r\n autocorrect: \"off\",\r\n autocapitalize: \"off\",\r\n class: \"min-h-full\",\r\n },\r\n },\r\n onUpdate: ({ editor }) => {\r\n handleChange(editor?.getJSON() ?? {});\r\n },\r\n },\r\n [dir]\r\n );\r\n\r\n useEffect(() => {\r\n if (editor?.storage?.aiCommand) {\r\n editor.storage.aiCommand.title = additionalContext?.title ?? \"\";\r\n editor.storage.aiCommand.language = additionalContext?.language ?? \"\";\r\n }\r\n }, [editor, additionalContext]);\r\n\r\n const users = useMemo(() => {\r\n if (!editor?.storage?.collaborationCursor?.users) {\r\n return [];\r\n }\r\n\r\n return editor?.storage?.collaborationCursor?.users.map(\r\n (user: EditorUser) => {\r\n const names = user.name?.split(\" \");\r\n const firstName = names?.[0];\r\n const lastName = names?.[names.length - 1];\r\n const initials = `${firstName?.[0] || \"?\"}${lastName?.[0] || \"?\"}`;\r\n\r\n return { ...user, initials: initials.length ? initials : \"?\" };\r\n }\r\n );\r\n }, [editor?.storage.collaborationCursor?.users]);\r\n\r\n const characterCount = editor?.storage.characterCount || {\r\n characters: () => 0,\r\n words: () => 0,\r\n };\r\n\r\n // useEffect(() => {\r\n // provider?.on('status', (event: { status: WebSocketStatus }) => {\r\n // setCollabState(event.status)\r\n // })\r\n // }, [provider])\r\n\r\n if (typeof window != \"undefined\") window.editor = editor;\r\n\r\n return { editor, users, characterCount, leftSidebar };\r\n};\r\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","dir","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,SAAS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AACC,SAAS,CAACC,KAAK,GAAG7B,mBAAmB6B,SAAS;YAC7DnB,OAAOiB,OAAO,CAACC,SAAS,CAACR,QAAQ,GAAGpB,mBAAmBoB,YAAY;QACrE;IACF,GAAG;QAACV;QAAQV;KAAkB;IAE9B,MAAM8B,QAAQ5C,QAAQ;QACpB,IAAI,CAACwB,QAAQiB,SAASI,qBAAqBD,OAAO;YAChD,OAAO,EAAE;QACX;QAEA,OAAOpB,QAAQiB,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,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/fields/TiptapEditor/hooks/useBlockEditor.ts"],"sourcesContent":["\"use client\";\r\nimport { useEffect, useMemo } from \"react\";\r\n\r\nimport { Editor, useEditor } from \"@tiptap/react\";\r\n\r\nimport ExtensionKit from \"../extensions/extension-kit.js\";\r\nimport { EditorUser } from \"../features/BlockEditor/types.js\";\r\nimport { useSidebar } from \"./useSidebar.js\";\r\n\r\nimport TurndownService from \"turndown\";\r\nimport { gfm } from \"turndown-plugin-gfm\";\r\nimport { AssetReturnType, openAssetHQType } from \"../types.js\";\r\nimport i18next from \"i18next\";\r\n\r\ndeclare global {\r\n interface Window {\r\n editor: Editor | null;\r\n }\r\n}\r\n\r\nconst dummyAssetHqHandler = (\r\n listener: (asset: AssetReturnType) => void,\r\n file?: File\r\n) => {};\r\n\r\nexport const useBlockEditor = ({\r\n content,\r\n handleChange,\r\n openAssetHQHandler,\r\n additionalContext,\r\n autoFocus,\r\n isEditable,\r\n}: {\r\n content: { html: string; json: any };\r\n handleChange?: (data: any) => void;\r\n openAssetHQHandler?: openAssetHQType;\r\n additionalContext?: Record<string, any>;\r\n autoFocus: boolean;\r\n isEditable?: boolean;\r\n}) => {\r\n const leftSidebar = useSidebar();\r\n\r\n const turndownService = new TurndownService({});\r\n // Use the gfm plugin\r\n turndownService.use(gfm);\r\n turndownService.addRule(\"twitter\", {\r\n filter: \"div\",\r\n replacement: function (content) {\r\n return \"\\n\\n\" + content + \"\\n\\n\";\r\n },\r\n });\r\n const dir = i18next.dir()\r\n\r\n const editor = useEditor(\r\n {\r\n content: content?.json ?? content ?? {},\r\n immediatelyRender: false,\r\n autofocus: autoFocus ?? true,\r\n editable: isEditable ?? true,\r\n onCreate: ({ editor }) => ({\r\n // provider?.on('synced', () => {\r\n // if (editor.isEmpty) {\r\n // editor.commands.setContent(initialContent)\r\n // }\r\n // })\r\n }),\r\n extensions: [\r\n ...ExtensionKit({\r\n dir: i18next.dir(),\r\n openAssetHQHandler: openAssetHQHandler ?? dummyAssetHqHandler,\r\n // provider,\r\n }),\r\n // Collaboration.configure({\r\n // document: ydoc,\r\n // }),\r\n // CollaborationCursor.configure({\r\n // provider,\r\n // user: {\r\n // name: randomElement(userNames),\r\n // color: randomElement(userColors),\r\n // },\r\n // }),\r\n ],\r\n editorProps: {\r\n attributes: {\r\n languages: i18next.language,\r\n autocomplete: \"off\",\r\n autocorrect: \"off\",\r\n autocapitalize: \"off\",\r\n class: \"min-h-full\",\r\n },\r\n },\r\n onUpdate: ({ editor }) => {\r\n handleChange(editor?.getJSON() ?? {});\r\n },\r\n },\r\n [dir]\r\n );\r\n\r\n useEffect(() => {\r\n if (editor?.storage?.aiCommand) {\r\n editor.storage.aiCommand.title = additionalContext?.title ?? \"\";\r\n editor.storage.aiCommand.language = additionalContext?.language ?? \"\";\r\n }\r\n }, [editor, additionalContext]);\r\n\r\n const users = useMemo(() => {\r\n if (!editor?.storage?.collaborationCursor?.users) {\r\n return [];\r\n }\r\n\r\n return editor?.storage?.collaborationCursor?.users.map(\r\n (user: EditorUser) => {\r\n const names = user.name?.split(\" \");\r\n const firstName = names?.[0];\r\n const lastName = names?.[names.length - 1];\r\n const initials = `${firstName?.[0] || \"?\"}${lastName?.[0] || \"?\"}`;\r\n\r\n return { ...user, initials: initials.length ? initials : \"?\" };\r\n }\r\n );\r\n }, [editor?.storage.collaborationCursor?.users]);\r\n\r\n const characterCount = editor?.storage.characterCount || {\r\n characters: () => 0,\r\n words: () => 0,\r\n };\r\n\r\n // useEffect(() => {\r\n // provider?.on('status', (event: { status: WebSocketStatus }) => {\r\n // setCollabState(event.status)\r\n // })\r\n // }, [provider])\r\n\r\n if (typeof window != \"undefined\") window.editor = editor;\r\n\r\n return { editor, users, characterCount, leftSidebar };\r\n};\r\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","dir","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;IAC7C,qBAAqB;IACrBc,gBAAgBC,GAAG,CAACd;IACpBa,gBAAgBE,OAAO,CAAC,WAAW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AAC,EAAE,IAAI,KAAK;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;QAAgBtC;IAAY;AACtD,EAAE"}
|
|
@@ -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>;
|
|
24
22
|
text?: string;
|
|
25
23
|
marks?: {
|
|
26
24
|
type?: string;
|
|
27
25
|
attrs?: Record<string, any>;
|
|
28
26
|
}[];
|
|
29
|
-
}, {
|
|
30
27
|
type?: string;
|
|
31
28
|
attrs?: Record<string, any>;
|
|
29
|
+
}, {
|
|
32
30
|
text?: string;
|
|
33
31
|
marks?: {
|
|
34
32
|
type?: string;
|
|
35
33
|
attrs?: Record<string, any>;
|
|
36
34
|
}[];
|
|
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>;
|
|
59
57
|
text?: string;
|
|
60
58
|
marks?: {
|
|
61
59
|
type?: string;
|
|
62
60
|
attrs?: Record<string, any>;
|
|
63
61
|
}[];
|
|
64
|
-
}, {
|
|
65
62
|
type?: string;
|
|
66
63
|
attrs?: Record<string, any>;
|
|
64
|
+
}, {
|
|
67
65
|
text?: string;
|
|
68
66
|
marks?: {
|
|
69
67
|
type?: string;
|
|
70
68
|
attrs?: Record<string, any>;
|
|
71
69
|
}[];
|
|
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;
|
|
84
83
|
content?: ({
|
|
85
84
|
type?: string;
|
|
86
85
|
attrs?: Record<string, any>;
|
|
87
86
|
} | {
|
|
88
|
-
type?: string;
|
|
89
|
-
attrs?: Record<string, any>;
|
|
90
87
|
text?: string;
|
|
91
88
|
marks?: {
|
|
92
89
|
type?: string;
|
|
93
90
|
attrs?: Record<string, any>;
|
|
94
91
|
}[];
|
|
92
|
+
type?: string;
|
|
93
|
+
attrs?: Record<string, any>;
|
|
95
94
|
})[];
|
|
95
|
+
type?: string;
|
|
96
96
|
attrs?: Record<string, any>;
|
|
97
97
|
}, {
|
|
98
|
-
type?: string;
|
|
99
98
|
content?: ({
|
|
100
99
|
type?: string;
|
|
101
100
|
attrs?: Record<string, any>;
|
|
102
101
|
} | {
|
|
103
|
-
type?: string;
|
|
104
|
-
attrs?: Record<string, any>;
|
|
105
102
|
text?: string;
|
|
106
103
|
marks?: {
|
|
107
104
|
type?: string;
|
|
108
105
|
attrs?: Record<string, any>;
|
|
109
106
|
}[];
|
|
107
|
+
type?: string;
|
|
108
|
+
attrs?: Record<string, any>;
|
|
110
109
|
})[];
|
|
110
|
+
type?: string;
|
|
111
111
|
attrs?: Record<string, any>;
|
|
112
112
|
}>]>, "many">>;
|
|
113
113
|
}>, "strip", z.ZodTypeAny, {
|
|
114
|
-
type?: string;
|
|
115
114
|
content?: ({
|
|
116
|
-
type?: string;
|
|
117
|
-
attrs?: Record<string, any>;
|
|
118
115
|
text?: string;
|
|
119
116
|
marks?: {
|
|
120
117
|
type?: string;
|
|
121
118
|
attrs?: Record<string, any>;
|
|
122
119
|
}[];
|
|
123
|
-
} | {
|
|
124
120
|
type?: string;
|
|
121
|
+
attrs?: Record<string, any>;
|
|
122
|
+
} | {
|
|
125
123
|
content?: ({
|
|
126
124
|
type?: string;
|
|
127
125
|
attrs?: Record<string, any>;
|
|
128
126
|
} | {
|
|
129
|
-
type?: string;
|
|
130
|
-
attrs?: Record<string, any>;
|
|
131
127
|
text?: string;
|
|
132
128
|
marks?: {
|
|
133
129
|
type?: string;
|
|
134
130
|
attrs?: Record<string, any>;
|
|
135
131
|
}[];
|
|
132
|
+
type?: string;
|
|
133
|
+
attrs?: Record<string, any>;
|
|
136
134
|
})[];
|
|
135
|
+
type?: string;
|
|
137
136
|
attrs?: Record<string, any>;
|
|
138
137
|
})[];
|
|
138
|
+
type?: string;
|
|
139
139
|
attrs?: Record<string, any>;
|
|
140
140
|
}, {
|
|
141
|
-
type?: string;
|
|
142
141
|
content?: ({
|
|
143
|
-
type?: string;
|
|
144
|
-
attrs?: Record<string, any>;
|
|
145
142
|
text?: string;
|
|
146
143
|
marks?: {
|
|
147
144
|
type?: string;
|
|
148
145
|
attrs?: Record<string, any>;
|
|
149
146
|
}[];
|
|
150
|
-
} | {
|
|
151
147
|
type?: string;
|
|
148
|
+
attrs?: Record<string, any>;
|
|
149
|
+
} | {
|
|
152
150
|
content?: ({
|
|
153
151
|
type?: string;
|
|
154
152
|
attrs?: Record<string, any>;
|
|
155
153
|
} | {
|
|
156
|
-
type?: string;
|
|
157
|
-
attrs?: Record<string, any>;
|
|
158
154
|
text?: string;
|
|
159
155
|
marks?: {
|
|
160
156
|
type?: string;
|
|
161
157
|
attrs?: Record<string, any>;
|
|
162
158
|
}[];
|
|
159
|
+
type?: string;
|
|
160
|
+
attrs?: Record<string, any>;
|
|
163
161
|
})[];
|
|
162
|
+
type?: string;
|
|
164
163
|
attrs?: Record<string, any>;
|
|
165
164
|
})[];
|
|
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>;
|
|
192
190
|
text?: string;
|
|
193
191
|
marks?: {
|
|
194
192
|
type?: string;
|
|
195
193
|
attrs?: Record<string, any>;
|
|
196
194
|
}[];
|
|
197
|
-
}, {
|
|
198
195
|
type?: string;
|
|
199
196
|
attrs?: Record<string, any>;
|
|
197
|
+
}, {
|
|
200
198
|
text?: string;
|
|
201
199
|
marks?: {
|
|
202
200
|
type?: string;
|
|
203
201
|
attrs?: Record<string, any>;
|
|
204
202
|
}[];
|
|
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>;
|
|
227
225
|
text?: string;
|
|
228
226
|
marks?: {
|
|
229
227
|
type?: string;
|
|
230
228
|
attrs?: Record<string, any>;
|
|
231
229
|
}[];
|
|
232
|
-
}, {
|
|
233
230
|
type?: string;
|
|
234
231
|
attrs?: Record<string, any>;
|
|
232
|
+
}, {
|
|
235
233
|
text?: string;
|
|
236
234
|
marks?: {
|
|
237
235
|
type?: string;
|
|
238
236
|
attrs?: Record<string, any>;
|
|
239
237
|
}[];
|
|
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;
|
|
252
251
|
content?: ({
|
|
253
252
|
type?: string;
|
|
254
253
|
attrs?: Record<string, any>;
|
|
255
254
|
} | {
|
|
256
|
-
type?: string;
|
|
257
|
-
attrs?: Record<string, any>;
|
|
258
255
|
text?: string;
|
|
259
256
|
marks?: {
|
|
260
257
|
type?: string;
|
|
261
258
|
attrs?: Record<string, any>;
|
|
262
259
|
}[];
|
|
260
|
+
type?: string;
|
|
261
|
+
attrs?: Record<string, any>;
|
|
263
262
|
})[];
|
|
263
|
+
type?: string;
|
|
264
264
|
attrs?: Record<string, any>;
|
|
265
265
|
}, {
|
|
266
|
-
type?: string;
|
|
267
266
|
content?: ({
|
|
268
267
|
type?: string;
|
|
269
268
|
attrs?: Record<string, any>;
|
|
270
269
|
} | {
|
|
271
|
-
type?: string;
|
|
272
|
-
attrs?: Record<string, any>;
|
|
273
270
|
text?: string;
|
|
274
271
|
marks?: {
|
|
275
272
|
type?: string;
|
|
276
273
|
attrs?: Record<string, any>;
|
|
277
274
|
}[];
|
|
275
|
+
type?: string;
|
|
276
|
+
attrs?: Record<string, any>;
|
|
278
277
|
})[];
|
|
278
|
+
type?: string;
|
|
279
279
|
attrs?: Record<string, any>;
|
|
280
280
|
}>]>, "many">>;
|
|
281
281
|
}>, "strip", z.ZodTypeAny, {
|
|
282
|
-
type?: string;
|
|
283
282
|
content?: ({
|
|
284
|
-
type?: string;
|
|
285
|
-
attrs?: Record<string, any>;
|
|
286
283
|
text?: string;
|
|
287
284
|
marks?: {
|
|
288
285
|
type?: string;
|
|
289
286
|
attrs?: Record<string, any>;
|
|
290
287
|
}[];
|
|
291
|
-
} | {
|
|
292
288
|
type?: string;
|
|
289
|
+
attrs?: Record<string, any>;
|
|
290
|
+
} | {
|
|
293
291
|
content?: ({
|
|
294
292
|
type?: string;
|
|
295
293
|
attrs?: Record<string, any>;
|
|
296
294
|
} | {
|
|
297
|
-
type?: string;
|
|
298
|
-
attrs?: Record<string, any>;
|
|
299
295
|
text?: string;
|
|
300
296
|
marks?: {
|
|
301
297
|
type?: string;
|
|
302
298
|
attrs?: Record<string, any>;
|
|
303
299
|
}[];
|
|
300
|
+
type?: string;
|
|
301
|
+
attrs?: Record<string, any>;
|
|
304
302
|
})[];
|
|
303
|
+
type?: string;
|
|
305
304
|
attrs?: Record<string, any>;
|
|
306
305
|
})[];
|
|
306
|
+
type?: string;
|
|
307
307
|
attrs?: Record<string, any>;
|
|
308
308
|
}, {
|
|
309
|
-
type?: string;
|
|
310
309
|
content?: ({
|
|
311
|
-
type?: string;
|
|
312
|
-
attrs?: Record<string, any>;
|
|
313
310
|
text?: string;
|
|
314
311
|
marks?: {
|
|
315
312
|
type?: string;
|
|
316
313
|
attrs?: Record<string, any>;
|
|
317
314
|
}[];
|
|
318
|
-
} | {
|
|
319
315
|
type?: string;
|
|
316
|
+
attrs?: Record<string, any>;
|
|
317
|
+
} | {
|
|
320
318
|
content?: ({
|
|
321
319
|
type?: string;
|
|
322
320
|
attrs?: Record<string, any>;
|
|
323
321
|
} | {
|
|
324
|
-
type?: string;
|
|
325
|
-
attrs?: Record<string, any>;
|
|
326
322
|
text?: string;
|
|
327
323
|
marks?: {
|
|
328
324
|
type?: string;
|
|
329
325
|
attrs?: Record<string, any>;
|
|
330
326
|
}[];
|
|
327
|
+
type?: string;
|
|
328
|
+
attrs?: Record<string, any>;
|
|
331
329
|
})[];
|
|
330
|
+
type?: string;
|
|
332
331
|
attrs?: Record<string, any>;
|
|
333
332
|
})[];
|
|
333
|
+
type?: string;
|
|
334
334
|
attrs?: Record<string, any>;
|
|
335
335
|
}>, "many">;
|
|
336
336
|
}, "strip", z.ZodTypeAny, {
|
|
337
|
-
type?: "doc";
|
|
338
337
|
content?: {
|
|
339
|
-
type?: string;
|
|
340
338
|
content?: ({
|
|
341
|
-
type?: string;
|
|
342
|
-
attrs?: Record<string, any>;
|
|
343
339
|
text?: string;
|
|
344
340
|
marks?: {
|
|
345
341
|
type?: string;
|
|
346
342
|
attrs?: Record<string, any>;
|
|
347
343
|
}[];
|
|
348
|
-
} | {
|
|
349
344
|
type?: string;
|
|
345
|
+
attrs?: Record<string, any>;
|
|
346
|
+
} | {
|
|
350
347
|
content?: ({
|
|
351
348
|
type?: string;
|
|
352
349
|
attrs?: Record<string, any>;
|
|
353
350
|
} | {
|
|
354
|
-
type?: string;
|
|
355
|
-
attrs?: Record<string, any>;
|
|
356
351
|
text?: string;
|
|
357
352
|
marks?: {
|
|
358
353
|
type?: string;
|
|
359
354
|
attrs?: Record<string, any>;
|
|
360
355
|
}[];
|
|
356
|
+
type?: string;
|
|
357
|
+
attrs?: Record<string, any>;
|
|
361
358
|
})[];
|
|
359
|
+
type?: string;
|
|
362
360
|
attrs?: Record<string, any>;
|
|
363
361
|
})[];
|
|
362
|
+
type?: string;
|
|
364
363
|
attrs?: Record<string, any>;
|
|
365
364
|
}[];
|
|
366
|
-
}, {
|
|
367
365
|
type?: "doc";
|
|
366
|
+
}, {
|
|
368
367
|
content?: {
|
|
369
|
-
type?: string;
|
|
370
368
|
content?: ({
|
|
371
|
-
type?: string;
|
|
372
|
-
attrs?: Record<string, any>;
|
|
373
369
|
text?: string;
|
|
374
370
|
marks?: {
|
|
375
371
|
type?: string;
|
|
376
372
|
attrs?: Record<string, any>;
|
|
377
373
|
}[];
|
|
378
|
-
} | {
|
|
379
374
|
type?: string;
|
|
375
|
+
attrs?: Record<string, any>;
|
|
376
|
+
} | {
|
|
380
377
|
content?: ({
|
|
381
378
|
type?: string;
|
|
382
379
|
attrs?: Record<string, any>;
|
|
383
380
|
} | {
|
|
384
|
-
type?: string;
|
|
385
|
-
attrs?: Record<string, any>;
|
|
386
381
|
text?: string;
|
|
387
382
|
marks?: {
|
|
388
383
|
type?: string;
|
|
389
384
|
attrs?: Record<string, any>;
|
|
390
385
|
}[];
|
|
386
|
+
type?: string;
|
|
387
|
+
attrs?: Record<string, any>;
|
|
391
388
|
})[];
|
|
389
|
+
type?: string;
|
|
392
390
|
attrs?: Record<string, any>;
|
|
393
391
|
})[];
|
|
392
|
+
type?: string;
|
|
394
393
|
attrs?: Record<string, any>;
|
|
395
394
|
}[];
|
|
395
|
+
type?: "doc";
|
|
396
396
|
}>;
|
|
397
397
|
//# sourceMappingURL=tiptapSchema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/lib/utils/cssVar.ts"],"sourcesContent":["export const cssVar = (name: string, value?: string) => {\r\n let currentName = name\r\n if (name.substring(0, 2) !== '--') {\r\n currentName = `--${currentName}`\r\n }\r\n\r\n if (value) {\r\n document.documentElement.style.setProperty(currentName, value)\r\n }\r\n\r\n return getComputedStyle(document.body).getPropertyValue(currentName)\r\n}\r\n\r\nexport default cssVar\r\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) => {\r\n let currentName = name\r\n if (name.substring(0, 2) !== '--') {\r\n currentName = `--${currentName}`\r\n }\r\n\r\n if (value) {\r\n document.documentElement.style.setProperty(currentName, value)\r\n }\r\n\r\n return getComputedStyle(document.body).getPropertyValue(currentName)\r\n}\r\n\r\nexport default cssVar\r\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,aAAa;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"}
|