payload-richtext-tiptap 0.0.137 → 0.0.139

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.
Files changed (74) hide show
  1. package/dist/src/fields/TiptapEditor/extensions/AICommand/AICommand.d.ts +1 -1
  2. package/dist/src/fields/TiptapEditor/extensions/AICommand/AICommand.d.ts.map +1 -1
  3. package/dist/src/fields/TiptapEditor/extensions/AICommand/AICommand.js +32 -32
  4. package/dist/src/fields/TiptapEditor/extensions/AICommand/AICommand.js.map +1 -1
  5. package/dist/src/fields/TiptapEditor/extensions/AudioBlock/AudioBlock.js.map +1 -1
  6. package/dist/src/fields/TiptapEditor/extensions/AudioBlock/components/AudioBlockMenu.js.map +1 -1
  7. package/dist/src/fields/TiptapEditor/extensions/FontSize/FontSize.js.map +1 -1
  8. package/dist/src/fields/TiptapEditor/extensions/Heading/Heading.js.map +1 -1
  9. package/dist/src/fields/TiptapEditor/extensions/ImageBlock/ImageBlock.js.map +1 -1
  10. package/dist/src/fields/TiptapEditor/extensions/ImageBlock/components/ImageBlockMenu.js.map +1 -1
  11. package/dist/src/fields/TiptapEditor/extensions/InsideLinks/InsideLink.client.js.map +1 -1
  12. package/dist/src/fields/TiptapEditor/extensions/MultiColumn/Columns.js +3 -3
  13. package/dist/src/fields/TiptapEditor/extensions/MultiColumn/Columns.js.map +1 -1
  14. package/dist/src/fields/TiptapEditor/extensions/MultiColumn/menus/ColumnsMenu.js.map +1 -1
  15. package/dist/src/fields/TiptapEditor/extensions/SlashCommand/MenuList.js.map +1 -1
  16. package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Facebook/facebook.js.map +1 -1
  17. package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Instagram/instagram.js.map +1 -1
  18. package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Tiktok/tiktok.js.map +1 -1
  19. package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Twitter/twitter.js.map +1 -1
  20. package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Youtube/youtube.js.map +1 -1
  21. package/dist/src/fields/TiptapEditor/extensions/VideoBlock/VideoBlock.js.map +1 -1
  22. package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockMenu.js.map +1 -1
  23. package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientside.d.ts.map +1 -1
  24. package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientside.js +7 -5
  25. package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientside.js.map +1 -1
  26. package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/quality-selector/events.d.ts.map +1 -1
  27. package/dist/src/fields/TiptapEditor/extensions/extension-kit.d.ts +1 -1
  28. package/dist/src/fields/TiptapEditor/extensions/serverside/EmbedContentInlineRenderer.js.map +1 -1
  29. package/dist/src/fields/TiptapEditor/extensions/serverside/EmbedContentSideRenderer.js.map +1 -1
  30. package/dist/src/fields/TiptapEditor/extensions/serverside/EmbedContentSidebarRenderer.js.map +1 -1
  31. package/dist/src/fields/TiptapEditor/extensions/serverside/FacebookServerside.js.map +1 -1
  32. package/dist/src/fields/TiptapEditor/extensions/serverside/InstagramServerside.js.map +1 -1
  33. package/dist/src/fields/TiptapEditor/extensions/serverside/LinkedinServerside.js.map +1 -1
  34. package/dist/src/fields/TiptapEditor/extensions/serverside/TiktokServerside.js.map +1 -1
  35. package/dist/src/fields/TiptapEditor/extensions/serverside/TwitterBlockServerside.js.map +1 -1
  36. package/dist/src/fields/TiptapEditor/extensions/serverside/YouTubeServerside.js.map +1 -1
  37. package/dist/src/fields/TiptapEditor/extensions/serverside/getAssetsAspectRatio.js.map +1 -1
  38. package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/FontFamilyPicker.js.map +1 -1
  39. package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/FontSizePicker.js.map +1 -1
  40. package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/ai-completion-command.d.ts +2 -2
  41. package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/ai-completion-command.d.ts.map +1 -1
  42. package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/ai-completion-command.js +4 -5
  43. package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/ai-completion-command.js.map +1 -1
  44. package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/ai-selector-commands.d.ts +3 -3
  45. package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/ai-selector-commands.d.ts.map +1 -1
  46. package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/ai-selector-commands.js +32 -31
  47. package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/ai-selector-commands.js.map +1 -1
  48. package/dist/src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.d.ts +3 -3
  49. package/dist/src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.d.ts.map +1 -1
  50. package/dist/src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.js +63 -87
  51. package/dist/src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.js.map +1 -1
  52. package/dist/src/fields/TiptapEditor/features/panels/AIEditorPanel/AIEditorPanel.d.ts +1 -1
  53. package/dist/src/fields/TiptapEditor/features/panels/AIEditorPanel/AIEditorPanel.d.ts.map +1 -1
  54. package/dist/src/fields/TiptapEditor/features/panels/AIEditorPanel/AIEditorPanel.js +50 -64
  55. package/dist/src/fields/TiptapEditor/features/panels/AIEditorPanel/AIEditorPanel.js.map +1 -1
  56. package/dist/src/fields/TiptapEditor/features/panels/AIEditorPanel/EditorPreview.d.ts +11 -0
  57. package/dist/src/fields/TiptapEditor/features/panels/AIEditorPanel/EditorPreview.d.ts.map +1 -0
  58. package/dist/src/fields/TiptapEditor/features/panels/AIEditorPanel/EditorPreview.js +80 -0
  59. package/dist/src/fields/TiptapEditor/features/panels/AIEditorPanel/EditorPreview.js.map +1 -0
  60. package/dist/src/fields/TiptapEditor/features/panels/AIEditorPanel/markdown.hook.d.ts +5 -0
  61. package/dist/src/fields/TiptapEditor/features/panels/AIEditorPanel/markdown.hook.d.ts.map +1 -0
  62. package/dist/src/fields/TiptapEditor/features/panels/AIEditorPanel/markdown.hook.js +67 -0
  63. package/dist/src/fields/TiptapEditor/features/panels/AIEditorPanel/markdown.hook.js.map +1 -0
  64. package/dist/src/fields/TiptapEditor/features/panels/AIEditorPanel/utils.js.map +1 -1
  65. package/dist/src/fields/TiptapEditor/hooks/useBlockEditor.js.map +1 -1
  66. package/dist/src/fields/TiptapEditor/lib/tiptapSchema.d.ts +397 -0
  67. package/dist/src/fields/TiptapEditor/lib/tiptapSchema.d.ts.map +1 -0
  68. package/dist/src/fields/TiptapEditor/lib/tiptapSchema.js +31 -0
  69. package/dist/src/fields/TiptapEditor/lib/tiptapSchema.js.map +1 -0
  70. package/dist/src/fields/TiptapEditor/lib/utils/cssVar.js.map +1 -1
  71. package/dist/src/mobile.css +1 -1
  72. package/dist/src/styles.css +1 -1
  73. package/dist/tsconfig.tsbuildinfo +1 -1
  74. package/package.json +30 -27
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditorPreview.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AIEditorPanel/EditorPreview.tsx"],"names":[],"mappings":"AAMA,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,WAAW,EACZ,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAMnD,eAAO,MAAM,aAAa,uFAOvB,WAAW,GAAG;IACf,kBAAkB,CAAC,EAAE,eAAe,CAAA;IACpC,iBAAiB,CAAC,EAAE,qBAAqB,CAAA;IACzC,iBAAiB,CAAC,EAAE,qBAAqB,CAAA;IACzC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAAA;CAC7B,gCAsEA,CAAA;AAED,eAAe,aAAa,CAAA"}
@@ -0,0 +1,80 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { EditorContent } from '@tiptap/react';
4
+ import i18n from 'i18next';
5
+ import { useEffect, useMemo, useRef } from 'react';
6
+ import i18next from 'i18next';
7
+ import { useBlockEditor } from '../../../hooks/useBlockEditor.js';
8
+ import { EditorContext } from '../../../context/EditorContext.js';
9
+ const DEFAULT_LANG = 'en';
10
+ export const EditorPreview = ({ handleChange, content, openAssetHQHandler, additionalContext, isEditable = true, dir })=>{
11
+ const menuContainerRef = useRef(null);
12
+ const editorRef = useRef(null);
13
+ const { editor, users, characterCount, leftSidebar } = useBlockEditor({
14
+ content: content,
15
+ handleChange: handleChange,
16
+ openAssetHQHandler: openAssetHQHandler,
17
+ additionalContext: additionalContext,
18
+ isEditable,
19
+ autoFocus: true
20
+ });
21
+ const displayedUsers = users.slice(0, 3);
22
+ const providerValue = useMemo(()=>{
23
+ return {};
24
+ }, []);
25
+ useEffect(()=>{
26
+ if (!additionalContext) {
27
+ i18n.init({
28
+ fallbackLng: DEFAULT_LANG,
29
+ lng: DEFAULT_LANG,
30
+ returnEmptyString: true,
31
+ resources: {}
32
+ });
33
+ return;
34
+ }
35
+ if (additionalContext.language && additionalContext.translations) {
36
+ i18n.init({
37
+ fallbackLng: additionalContext.language,
38
+ lng: additionalContext.language,
39
+ returnEmptyString: true,
40
+ resources: {
41
+ [additionalContext.language]: {
42
+ translation: additionalContext.translations
43
+ }
44
+ }
45
+ });
46
+ return;
47
+ }
48
+ if (additionalContext.language) {
49
+ i18n.init({
50
+ fallbackLng: additionalContext?.language,
51
+ lng: additionalContext?.language,
52
+ returnEmptyString: true,
53
+ resources: {}
54
+ });
55
+ }
56
+ }, []);
57
+ return editor && /*#__PURE__*/ _jsx(EditorContext.Provider, {
58
+ value: providerValue,
59
+ children: /*#__PURE__*/ _jsx("div", {
60
+ className: "flex h-full overflow-visible",
61
+ ref: menuContainerRef,
62
+ dir: i18next.dir(),
63
+ children: /*#__PURE__*/ _jsx("div", {
64
+ className: "relative flex flex-col flex-1 h-full justify-center items-center ",
65
+ children: /*#__PURE__*/ _jsx(EditorContent, {
66
+ dir: i18next.dir(),
67
+ editor: editor,
68
+ ref: editorRef,
69
+ className: "flex-1 overflow-y-visible w-full h-full outline-none outline-offset-0",
70
+ style: {
71
+ outline: 'none'
72
+ }
73
+ })
74
+ })
75
+ })
76
+ });
77
+ };
78
+ export default EditorPreview;
79
+
80
+ //# sourceMappingURL=EditorPreview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AIEditorPanel/EditorPreview.tsx"],"sourcesContent":["'use client'\nimport { EditorContent } from '@tiptap/react'\nimport i18n from 'i18next'\nimport { useEffect, useMemo, useRef } from 'react'\n\nimport i18next from 'i18next'\nimport {\n AdditionalContextType,\n FetchSiteMetadataType,\n TiptapProps,\n} from '../../BlockEditor/types.jsx'\nimport { openAssetHQType } from '../../../types.js'\nimport { useBlockEditor } from '../../../hooks/useBlockEditor.js'\nimport { EditorContext } from '../../../context/EditorContext.js'\n\nconst DEFAULT_LANG = 'en'\n\nexport const EditorPreview = ({\n handleChange,\n content,\n openAssetHQHandler,\n additionalContext,\n isEditable = true,\n dir,\n}: TiptapProps & {\n openAssetHQHandler?: openAssetHQType\n additionalContext?: AdditionalContextType\n fetchSiteMetadata?: FetchSiteMetadataType\n isEditable?: boolean\n dir?: 'ltr' | 'rtl' | 'auto'\n}) => {\n const menuContainerRef = useRef(null)\n const editorRef = useRef<HTMLDivElement>(null)\n\n const { editor, users, characterCount, leftSidebar } = useBlockEditor({\n content: content,\n handleChange: handleChange,\n openAssetHQHandler: openAssetHQHandler,\n additionalContext: additionalContext,\n isEditable,\n autoFocus: true,\n })\n\n const displayedUsers = users.slice(0, 3)\n const providerValue = useMemo(() => {\n return {}\n }, [])\n useEffect(() => {\n if (!additionalContext) {\n i18n.init({\n fallbackLng: DEFAULT_LANG,\n lng: DEFAULT_LANG,\n returnEmptyString: true,\n resources: {},\n })\n return\n }\n\n if (additionalContext.language && additionalContext.translations) {\n i18n.init({\n fallbackLng: additionalContext.language,\n lng: additionalContext.language,\n returnEmptyString: true,\n resources: {\n [additionalContext.language]: {\n translation: additionalContext.translations,\n },\n },\n })\n return\n }\n if (additionalContext.language) {\n i18n.init({\n fallbackLng: additionalContext?.language,\n lng: additionalContext?.language,\n returnEmptyString: true,\n resources: {},\n })\n }\n }, [])\n\n return (\n editor && (\n <EditorContext.Provider value={providerValue}>\n <div className='flex h-full overflow-visible' ref={menuContainerRef} dir={i18next.dir()}>\n <div className='relative flex flex-col flex-1 h-full justify-center items-center '>\n <EditorContent\n dir={i18next.dir()}\n editor={editor}\n ref={editorRef}\n className='flex-1 overflow-y-visible w-full h-full outline-none outline-offset-0'\n style={{\n outline: 'none',\n }}\n />\n </div>\n </div>\n </EditorContext.Provider>\n )\n )\n}\n\nexport default EditorPreview\n"],"names":["EditorContent","i18n","useEffect","useMemo","useRef","i18next","useBlockEditor","EditorContext","DEFAULT_LANG","EditorPreview","handleChange","content","openAssetHQHandler","additionalContext","isEditable","dir","menuContainerRef","editorRef","editor","users","characterCount","leftSidebar","autoFocus","displayedUsers","slice","providerValue","init","fallbackLng","lng","returnEmptyString","resources","language","translations","translation","Provider","value","div","className","ref","style","outline"],"mappings":"AAAA;;AACA,SAASA,aAAa,QAAQ,gBAAe;AAC7C,OAAOC,UAAU,UAAS;AAC1B,SAASC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,QAAO;AAElD,OAAOC,aAAa,UAAS;AAO7B,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,aAAa,QAAQ,oCAAmC;AAEjE,MAAMC,eAAe;AAErB,OAAO,MAAMC,gBAAgB,CAAC,EAC5BC,YAAY,EACZC,OAAO,EACPC,kBAAkB,EAClBC,iBAAiB,EACjBC,aAAa,IAAI,EACjBC,GAAG,EAOJ;IACC,MAAMC,mBAA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,SAAS;oBACX;;;;;AAOd,EAAC;AAED,eAAe/B,cAAa"}
@@ -0,0 +1,5 @@
1
+ import { JSONContent } from '@tiptap/react';
2
+ export declare const useExtractMarkdown: (value?: JSONContent | null) => {
3
+ markdown: string;
4
+ };
5
+ //# sourceMappingURL=markdown.hook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown.hook.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AIEditorPanel/markdown.hook.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAI3C,eAAO,MAAM,kBAAkB,WAAY,WAAW,GAAG,IAAI;;CA2B5D,CAAA"}
@@ -0,0 +1,67 @@
1
+ import { useCallback, useEffect, useRef } from 'react';
2
+ import { extractMarkdown } from '../../../lib/extract.js';
3
+ export const useExtractMarkdown = (value)=>{
4
+ const markdownRef = useRef('');
5
+ const updateMarkdown = useCallback(()=>{
6
+ let latestJson = JSON.parse(JSON.stringify(value));
7
+ // Remove nodes without content from the JSON structure
8
+ if (value) {
9
+ latestJson = cleanJson(value);
10
+ }
11
+ const extracted = extractMarkdown(latestJson);
12
+ if (extracted && typeof extracted === 'string') {
13
+ markdownRef.current = extracted;
14
+ }
15
+ }, [
16
+ value
17
+ ]);
18
+ useEffect(()=>{
19
+ if (value && value?.content?.length > 0) {
20
+ updateMarkdown();
21
+ } else {
22
+ markdownRef.current = '';
23
+ }
24
+ }, [
25
+ value
26
+ ]);
27
+ return {
28
+ markdown: markdownRef.current
29
+ };
30
+ };
31
+ const cleanJson = (node)=>{
32
+ if (!node) return null;
33
+ // If node has no type, remove it
34
+ if (!node?.type && !node?.attrs) {
35
+ return null;
36
+ }
37
+ if ([
38
+ 'tiktok',
39
+ 'twitter',
40
+ 'instagram',
41
+ 'facebook',
42
+ 'linkedin',
43
+ 'youtube',
44
+ 'insideLinks',
45
+ 'iframe',
46
+ 'videoBlock',
47
+ 'imageBlock',
48
+ 'linkPreview'
49
+ ].includes(node?.type)) {
50
+ return null;
51
+ }
52
+ // If node has content, recursively clean its children
53
+ if (Array.isArray(node.content)) {
54
+ const cleanContent = node.content.map(cleanJson).filter(Boolean);
55
+ // If no valid children remain, return null
56
+ if (cleanContent.length === 0) {
57
+ return null;
58
+ }
59
+ return {
60
+ ...node,
61
+ content: cleanContent
62
+ };
63
+ }
64
+ return node;
65
+ };
66
+
67
+ //# sourceMappingURL=markdown.hook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AIEditorPanel/markdown.hook.tsx"],"sourcesContent":["import { JSONContent } from '@tiptap/react'\nimport { useCallback, useEffect, useRef } from 'react'\nimport { extractMarkdown } from '../../../lib/extract.js'\n\nexport const useExtractMarkdown = (value?: JSONContent | null) => {\n const markdownRef = useRef<string>('')\n\n const updateMarkdown = useCallback(() => {\n let latestJson = JSON.parse(JSON.stringify(value))\n // Remove nodes without content from the JSON structure\n if (value) {\n latestJson = cleanJson(value)\n }\n\n const extracted = extractMarkdown(latestJson)\n if (extracted && typeof extracted === 'string') {\n markdownRef.current = extracted\n }\n }, [value])\n\n useEffect(() => {\n if (value && value?.content?.length > 0) {\n updateMarkdown()\n } else {\n markdownRef.current = ''\n }\n }, [value])\n\n return {\n markdown: markdownRef.current,\n }\n}\n\nconst cleanJson = (node: any): any => {\n if (!node) return null\n\n // If node has no type, remove it\n if (!node?.type && !node?.attrs) {\n return null\n }\n\n if (\n [\n 'tiktok',\n 'twitter',\n 'instagram',\n 'facebook',\n 'linkedin',\n 'youtube',\n 'insideLinks',\n 'iframe',\n 'videoBlock',\n 'imageBlock',\n 'linkPreview',\n ].includes(node?.type)\n ) {\n return null\n }\n\n // If node has content, recursively clean its children\n if (Array.isArray(node.content)) {\n const cleanContent = node.content.map(cleanJson).filter(Boolean)\n\n // If no valid children remain, return null\n if (cleanContent.length === 0) {\n return null\n }\n\n return {\n ...node,\n content: cleanContent,\n }\n }\n\n return node\n}\n"],"names":["useCallback","useEffect","useRef","extractMarkdown","useExtractMarkdown","value","markdownRef","updateMarkdown","latestJson","JSON","parse","stringify","cleanJson","extracted","current","content","length","markdown","node","type","attrs","includes","Array","isArray","cleanContent","map","filter","Boolean"],"mappings":"AACA,SAASA,WAAW,EAAEC,SAAS,EAAEC,MAAM,QAAQ,QAAO;AACtD,SAASC,eAAe,QAAQ,0BAAyB;AAEzD,OAAO,MAAMC,qBAAqB,CAACC;IACjC,MAAMC,cAAcJ,OAAe;IAEnC,MAAMK,iBAAiBP,YAAY;QACjC,IAAIQ,aAAaC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACN;QAC3C,uDAAuD;QACvD,IAAIA,OAAO;YACTG,aAAaI,UAAUP;QACzB;QAEA,MAAMQ,YAAYV,gBAAgBK;QAClC,IAAIK,aAAa,OAAOA,cAAc,UAAU;YAC9CP,YAAYQ,OAAO,GAAGD;QACxB;IACF,GAAG;QAACR;KAAM;IAEVJ,UAAU;QACR,IAAII,SAASA,OAAOU,SAASC,SAAS,GAAG;YACvCT;QACF,OAAO;YACLD,YAAYQ,OAAO,GAAG;QACxB;IACF,GAAG;QAACT;KAAM;IAEV,OAAO;QACLY,UAAUX,YAAYQ,OAAO;IAC/B;AACF,EAAC;AAED,MAAMF,YAAY,CAACM;IACjB,IAAI,CAACA,MAAM,OAAO;IAElB,kCAAkC;IAClC,IAAI,CAACA,MAAMC,QAAQ,CAACD,MAAME,OAAO;QAC/B,OAAO;IACT;IAEA,IACE;QACE;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;KACD,CAACC,QAAQ,CAACH,MAAMC,OACjB;QACA,OAAO;IACT;IAEA,sDAAsD;IACtD,IAAIG,MAAMC,OAAO,CAACL,KAAKH,OAAO,GAAG;QAC/B,MAAMS,eAAeN,KAAKH,OAAO,CAACU,GAAG,CAACb,WAAWc,MAAM,CAACC;QAExD,2CAA2C;QAC3C,IAAIH,aAAaR,MAAM,KAAK,GAAG;YAC7B,OAAO;QACT;QAEA,OAAO;YACL,GAAGE,IAAI;YACPH,SAASS;QACX;IACF;IAEA,OAAON;AACT"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AIEditorPanel/utils.ts"],"sourcesContent":["\nimport json5 from 'json5';\n\nexport const convertBody = (body: string) => {\n try {\n let parsedBody = body.replace('```json', '').replace('```', '');\n parsedBody = json5.parse(parsedBody);\n return parsedBody as unknown as object[];\n } catch (error) {\n try {\n const fixedJson = jsonFixer(body);\n return json5.parse(fixedJson);\n } catch (error) {\n console.error('Error occured When parsing translated error: ', error);\n console.error('Error occured When parsing translated body ', body);\n throw new Error(\n `Openapi translate with assistant An error occurred while processing your request .error: ${error} body: ${body}`,\n );\n }\n }\n}\n\nexport const jsonFixer = (json: string, provider?: string) => {\n if (provider === 'bedrock') {\n json += '}';\n }\n let fixedText = json\n .replace('```json', '')\n .replace('```', '')\n .replace(/”/g, '\"')\n .replace(/“/g, '\"')\n .replace(/’/g, \"'\")\n .replace(/‘/g, \"'\");\n\n const regex = /\"text\":\\s*\"([^]*)\"/g;\n\n // Metinde her text alanını kontrol et\n fixedText = fixedText.replace(regex, (match, p1) => {\n let text = p1.trim();\n\n if (!text.startsWith('\"')) {\n text = '\"' + text;\n }\n\n if (!text.endsWith('\"')) {\n text = text + '\"';\n }\n\n return `\"text\": ${text}`;\n });\n\n return fixedText;\n};\n\nexport const formatCompletion = (completion: string) => {\n const translatedText = completion\n .trim()\n .replace(/<translated_text>/g, '')\n .replace('</translated_text>', '');\n const body = convertBody(translatedText)\n return body\n}\n\nexport const checkJsonCompletion = (completion: string) => {\n return completion.includes(\"```json\") || completion.includes(\"\\\"type\\\":\") || completion.includes(\"\\\"content\\\":\")\n}"],"names":["json5","convertBody","body","parsedBody","replace","parse","error","fixedJson","jsonFixer","console","Error","json","provider","fixedText","regex","match","p1","text","trim","startsWith","endsWith","formatCompletion","completion","translatedText","checkJsonCompletion","includes"],"mappings":"A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OrB;AACX,EAAC;AAED,OAAO,MAAMsB,sBAAsB,CAACF;IAChC,OAAOA,WAAWG,QAAQ,CAAC,cAAcH,WAAWG,QAAQ,CAAC,gBAAgBH,WAAWG,QAAQ,CAAC;AACrG,EAAC"}
1
+ {"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AIEditorPanel/utils.ts"],"sourcesContent":["\nimport json5 from 'json5';\n\nexport const convertBody = (body: string) => {\n try {\n let parsedBody = body.replace('```json', '').replace('```', '');\n parsedBody = json5.parse(parsedBody);\n return parsedBody as unknown as object[];\n } catch (error) {\n try {\n const fixedJson = jsonFixer(body);\n return json5.parse(fixedJson);\n } catch (error) {\n console.error('Error occured When parsing translated error: ', error);\n console.error('Error occured When parsing translated body ', body);\n throw new Error(\n `Openapi translate with assistant An error occurred while processing your request .error: ${error} body: ${body}`,\n );\n }\n }\n}\n\nexport const jsonFixer = (json: string, provider?: string) => {\n if (provider === 'bedrock') {\n json += '}';\n }\n let fixedText = json\n .replace('```json', '')\n .replace('```', '')\n .replace(/”/g, '\"')\n .replace(/“/g, '\"')\n .replace(/’/g, \"'\")\n .replace(/‘/g, \"'\");\n\n const regex = /\"text\":\\s*\"([^]*)\"/g;\n\n // Metinde her text alanını kontrol et\n fixedText = fixedText.replace(regex, (match, p1) => {\n let text = p1.trim();\n\n if (!text.startsWith('\"')) {\n text = '\"' + text;\n }\n\n if (!text.endsWith('\"')) {\n text = text + '\"';\n }\n\n return `\"text\": ${text}`;\n });\n\n return fixedText;\n};\n\nexport const formatCompletion = (completion: string) => {\n const translatedText = completion\n .trim()\n .replace(/<translated_text>/g, '')\n .replace('</translated_text>', '');\n const body = convertBody(translatedText)\n return body\n}\n\nexport const checkJsonCompletion = (completion: string) => {\n return completion.includes(\"```json\") || completion.includes(\"\\\"type\\\":\") || completion.includes(\"\\\"content\\\":\")\n}"],"names":["json5","convertBody","body","parsedBody","replace","parse","error","fixedJson","jsonFixer","console","Error","json","provider","fixedText","regex","match","p1","text","trim","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IAC9BA,OAAO,CAAC,sBAAsB;IACnC,MAAMF,OAAOD,YAAYsB;IACzB,OAAOrB;AACX,EAAC;AAED,OAAO,MAAMsB,sBAAsB,CAACF;IAChC,OAAOA,WAAWG,QAAQ,CAAC,cAAcH,WAAWG,QAAQ,CAAC,gBAAgBH,WAAWG,QAAQ,CAAC;AACrG,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/fields/TiptapEditor/hooks/useBlockEditor.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useMemo } from \"react\";\n\nimport { Editor, useEditor } from \"@tiptap/react\";\n\nimport ExtensionKit from \"../extensions/extension-kit.js\";\nimport { EditorUser } from \"../features/BlockEditor/types.js\";\nimport { useSidebar } from \"./useSidebar.js\";\n\nimport TurndownService from \"turndown\";\nimport { gfm } from \"turndown-plugin-gfm\";\nimport { AssetReturnType, openAssetHQType } from \"../types.js\";\nimport i18next from \"i18next\";\n\ndeclare global {\n interface Window {\n editor: Editor | null;\n }\n}\n\nconst dummyAssetHqHandler = (\n listener: (asset: AssetReturnType) => void,\n file?: File\n) => {};\n\nexport const useBlockEditor = ({\n content,\n handleChange,\n openAssetHQHandler,\n additionalContext,\n autoFocus,\n isEditable,\n}: {\n content: { html: string; json: any };\n handleChange?: (data: any) => void;\n openAssetHQHandler?: openAssetHQType;\n additionalContext?: Record<string, any>;\n autoFocus: boolean;\n isEditable?: boolean;\n}) => {\n const leftSidebar = useSidebar();\n\n const turndownService = new TurndownService({});\n // Use the gfm plugin\n turndownService.use(gfm);\n turndownService.addRule(\"twitter\", {\n filter: \"div\",\n replacement: function (content) {\n return \"\\n\\n\" + content + \"\\n\\n\";\n },\n });\n const dir = i18next.dir()\n\n const editor = useEditor(\n {\n content: content?.json ?? content ?? {},\n immediatelyRender: false,\n autofocus: autoFocus ?? true,\n editable: isEditable ?? true,\n onCreate: ({ editor }) => ({\n // provider?.on('synced', () => {\n // if (editor.isEmpty) {\n // editor.commands.setContent(initialContent)\n // }\n // })\n }),\n extensions: [\n ...ExtensionKit({\n dir: i18next.dir(),\n openAssetHQHandler: openAssetHQHandler ?? dummyAssetHqHandler,\n // provider,\n }),\n // Collaboration.configure({\n // document: ydoc,\n // }),\n // CollaborationCursor.configure({\n // provider,\n // user: {\n // name: randomElement(userNames),\n // color: randomElement(userColors),\n // },\n // }),\n ],\n editorProps: {\n attributes: {\n languages: i18next.language,\n autocomplete: \"off\",\n autocorrect: \"off\",\n autocapitalize: \"off\",\n class: \"min-h-full\",\n },\n },\n onUpdate: ({ editor }) => {\n handleChange(editor?.getJSON() ?? {});\n },\n },\n [dir]\n );\n\n useEffect(() => {\n if (editor?.storage?.aiCommand) {\n editor.storage.aiCommand.title = additionalContext?.title ?? \"\";\n editor.storage.aiCommand.language = additionalContext?.language ?? \"\";\n }\n }, [editor, additionalContext]);\n\n const users = useMemo(() => {\n if (!editor?.storage?.collaborationCursor?.users) {\n return [];\n }\n\n return editor?.storage?.collaborationCursor?.users.map(\n (user: EditorUser) => {\n const names = user.name?.split(\" \");\n const firstName = names?.[0];\n const lastName = names?.[names.length - 1];\n const initials = `${firstName?.[0] || \"?\"}${lastName?.[0] || \"?\"}`;\n\n return { ...user, initials: initials.length ? initials : \"?\" };\n }\n );\n }, [editor?.storage.collaborationCursor?.users]);\n\n const characterCount = editor?.storage.characterCount || {\n characters: () => 0,\n words: () => 0,\n };\n\n // useEffect(() => {\n // provider?.on('status', (event: { status: WebSocketStatus }) => {\n // setCollabState(event.status)\n // })\n // }, [provider])\n\n if (typeof window != \"undefined\") window.editor = editor;\n\n return { editor, users, characterCount, leftSidebar };\n};\n"],"names":["useEffect","useMemo","useEditor","ExtensionKit","useSidebar","TurndownService","gfm","i18next","dummyAssetHqHandler","listener","file","useBlockEditor","content","handleChange","openAssetHQHandler","additionalContext","autoFocus","isEditable","leftSidebar","turndownService","use","addRule","filter","replacement","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;QACjCC,QAAQ;QACRC,aAAa,SAAUX,OAAO;YAC5B,OAAO,SAASA,UAAU;QAC5B;IACF;IACD,MAAMY,MAAMjB,QAAQiB,GAAG;IAEtB,MAAMC,SAASvB,UACb;QACEU,SAASA,SAASc,QAAQd,WAAW,CAAC;QACtCe,mBAAmB;QACnBC,WAAWZ,aAAa;QACxBa,UAAUZ,cAAc;QACxBa,UAAU,CAAC,EAAEL,MAAM,EAAE,GAAM,CAAA;YAM3B,CAAA;QACAM,YAAY;eACP5B,aAAa;gBACdqB,KAAKjB,QAAQiB,GAAG;gBAChBV,oBAAoBA,sBAAsBN;YAE5C;SAWD;QACDwB,aAAa;YACXC,YAAY;gBACVC,WAAW3B,QAAQ4B,QAAQ;gBAC3BC,cAAc;gBACdC,aAAa;gBACbC,gBAAgB;gBAChBC,OAAO;YACT;QACF;QACAC,UAAU,CAAC,EAAEf,MAAM,EAAE;YACnBZ,aAAaY,QAAQgB,aAAa,CAAC;QACrC;IACF,GACA;QAACjB;KAAI;IAGPxB,UAAU;QACR,IAAIyB,QAAQiB,SAASC,WAAW;YAC9BlB,OAAOiB,OAAO,CAACC,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,GAAGH,WAAW,CAAC,EAAE,IAAI,MAAMC,UAAU,CAAC,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"}
1
+ {"version":3,"sources":["../../../../../src/fields/TiptapEditor/hooks/useBlockEditor.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useMemo } from \"react\";\n\nimport { Editor, useEditor } from \"@tiptap/react\";\n\nimport ExtensionKit from \"../extensions/extension-kit.js\";\nimport { EditorUser } from \"../features/BlockEditor/types.js\";\nimport { useSidebar } from \"./useSidebar.js\";\n\nimport TurndownService from \"turndown\";\nimport { gfm } from \"turndown-plugin-gfm\";\nimport { AssetReturnType, openAssetHQType } from \"../types.js\";\nimport i18next from \"i18next\";\n\ndeclare global {\n interface Window {\n editor: Editor | null;\n }\n}\n\nconst dummyAssetHqHandler = (\n listener: (asset: AssetReturnType) => void,\n file?: File\n) => {};\n\nexport const useBlockEditor = ({\n content,\n handleChange,\n openAssetHQHandler,\n additionalContext,\n autoFocus,\n isEditable,\n}: {\n content: { html: string; json: any };\n handleChange?: (data: any) => void;\n openAssetHQHandler?: openAssetHQType;\n additionalContext?: Record<string, any>;\n autoFocus: boolean;\n isEditable?: boolean;\n}) => {\n const leftSidebar = useSidebar();\n\n const turndownService = new TurndownService({});\n // Use the gfm plugin\n turndownService.use(gfm);\n turndownService.addRule(\"twitter\", {\n filter: \"div\",\n replacement: function (content) {\n return \"\\n\\n\" + content + \"\\n\\n\";\n },\n });\n const dir = i18next.dir()\n\n const editor = useEditor(\n {\n content: content?.json ?? content ?? {},\n immediatelyRender: false,\n autofocus: autoFocus ?? true,\n editable: isEditable ?? true,\n onCreate: ({ editor }) => ({\n // provider?.on('synced', () => {\n // if (editor.isEmpty) {\n // editor.commands.setContent(initialContent)\n // }\n // })\n }),\n extensions: [\n ...ExtensionKit({\n dir: i18next.dir(),\n openAssetHQHandler: openAssetHQHandler ?? dummyAssetHqHandler,\n // provider,\n }),\n // Collaboration.configure({\n // document: ydoc,\n // }),\n // CollaborationCursor.configure({\n // provider,\n // user: {\n // name: randomElement(userNames),\n // color: randomElement(userColors),\n // },\n // }),\n ],\n editorProps: {\n attributes: {\n languages: i18next.language,\n autocomplete: \"off\",\n autocorrect: \"off\",\n autocapitalize: \"off\",\n class: \"min-h-full\",\n },\n },\n onUpdate: ({ editor }) => {\n handleChange(editor?.getJSON() ?? {});\n },\n },\n [dir]\n );\n\n useEffect(() => {\n if (editor?.storage?.aiCommand) {\n editor.storage.aiCommand.title = additionalContext?.title ?? \"\";\n editor.storage.aiCommand.language = additionalContext?.language ?? \"\";\n }\n }, [editor, additionalContext]);\n\n const users = useMemo(() => {\n if (!editor?.storage?.collaborationCursor?.users) {\n return [];\n }\n\n return editor?.storage?.collaborationCursor?.users.map(\n (user: EditorUser) => {\n const names = user.name?.split(\" \");\n const firstName = names?.[0];\n const lastName = names?.[names.length - 1];\n const initials = `${firstName?.[0] || \"?\"}${lastName?.[0] || \"?\"}`;\n\n return { ...user, initials: initials.length ? initials : \"?\" };\n }\n );\n }, [editor?.storage.collaborationCursor?.users]);\n\n const characterCount = editor?.storage.characterCount || {\n characters: () => 0,\n words: () => 0,\n };\n\n // useEffect(() => {\n // provider?.on('status', (event: { status: WebSocketStatus }) => {\n // setCollabState(event.status)\n // })\n // }, [provider])\n\n if (typeof window != \"undefined\") window.editor = editor;\n\n return { editor, users, characterCount, leftSidebar };\n};\n"],"names":["useEffect","useMemo","useEditor","ExtensionKit","useSidebar","TurndownService","gfm","i18next","dummyAssetHqHandler","listener","file","useBlockEditor","content","handleChange","openAssetHQHandler","additionalContext","autoFocus","isEditable","leftSidebar","turndownService","use","addRule","filter","replacement","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,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B,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,CAAC,EAAEH,WAAW,CAAC,EAAE,IAAI,IAAI,EAAEC,UAAU,CAAC,EAAE,IAAI,IAAI,CAAC;YAElE,OAAO;gBAAE,GAAGL,IAAI;gBAAEO,UAAUA,SAASD,MAAM,GAAGC,WAAW;YAAI;QAC/D;IAEJ,GAAG;QAAC9B,QAAQiB,QAAQI,qBAAqBD;KAAM;IAE/C,MAAMW,iBAAiB/B,QAAQiB,QAAQc,kBAAkB;QACvDC,YAAY,IAAM;QAClBC,OAAO,IAAM;IACf;IAEA,oBAAoB;IACpB,qEAAqE;IACrE,mCAAmC;IACnC,OAAO;IACP,iBAAiB;IAEjB,IAAI,OAAOC,UAAU,aAAaA,OAAOlC,MAAM,GAAGA;IAElD,OAAO;QAAEA;QAAQoB;QAAOW;QAAgBtC;IAAY;AACtD,EAAE"}
@@ -0,0 +1,397 @@
1
+ import { z } from 'zod';
2
+ export declare const JSONContentSchema: z.ZodObject<z.objectUtil.extendShape<{
3
+ type: z.ZodString;
4
+ attrs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
5
+ }, {
6
+ content: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodObject<z.objectUtil.extendShape<{
7
+ type: z.ZodString;
8
+ attrs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
9
+ }, {
10
+ text: z.ZodString;
11
+ marks: z.ZodOptional<z.ZodArray<z.ZodObject<{
12
+ type: z.ZodString;
13
+ attrs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
14
+ }, "strip", z.ZodTypeAny, {
15
+ type?: string;
16
+ attrs?: Record<string, any>;
17
+ }, {
18
+ type?: string;
19
+ attrs?: Record<string, any>;
20
+ }>, "many">>;
21
+ }>, "strip", z.ZodTypeAny, {
22
+ type?: string;
23
+ attrs?: Record<string, any>;
24
+ text?: string;
25
+ marks?: {
26
+ type?: string;
27
+ attrs?: Record<string, any>;
28
+ }[];
29
+ }, {
30
+ type?: string;
31
+ attrs?: Record<string, any>;
32
+ text?: string;
33
+ marks?: {
34
+ type?: string;
35
+ attrs?: Record<string, any>;
36
+ }[];
37
+ }>, z.ZodObject<z.objectUtil.extendShape<{
38
+ type: z.ZodString;
39
+ attrs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
40
+ }, {
41
+ content: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodObject<z.objectUtil.extendShape<{
42
+ type: z.ZodString;
43
+ attrs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
44
+ }, {
45
+ text: z.ZodString;
46
+ marks: z.ZodOptional<z.ZodArray<z.ZodObject<{
47
+ type: z.ZodString;
48
+ attrs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
49
+ }, "strip", z.ZodTypeAny, {
50
+ type?: string;
51
+ attrs?: Record<string, any>;
52
+ }, {
53
+ type?: string;
54
+ attrs?: Record<string, any>;
55
+ }>, "many">>;
56
+ }>, "strip", z.ZodTypeAny, {
57
+ type?: string;
58
+ attrs?: Record<string, any>;
59
+ text?: string;
60
+ marks?: {
61
+ type?: string;
62
+ attrs?: Record<string, any>;
63
+ }[];
64
+ }, {
65
+ type?: string;
66
+ attrs?: Record<string, any>;
67
+ text?: string;
68
+ marks?: {
69
+ type?: string;
70
+ attrs?: Record<string, any>;
71
+ }[];
72
+ }>, z.ZodObject<{
73
+ type: z.ZodString;
74
+ attrs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
75
+ }, "strip", z.ZodTypeAny, {
76
+ type?: string;
77
+ attrs?: Record<string, any>;
78
+ }, {
79
+ type?: string;
80
+ attrs?: Record<string, any>;
81
+ }>]>, "many">>;
82
+ }>, "strip", z.ZodTypeAny, {
83
+ type?: string;
84
+ attrs?: Record<string, any>;
85
+ content?: ({
86
+ type?: string;
87
+ attrs?: Record<string, any>;
88
+ } | {
89
+ type?: string;
90
+ attrs?: Record<string, any>;
91
+ text?: string;
92
+ marks?: {
93
+ type?: string;
94
+ attrs?: Record<string, any>;
95
+ }[];
96
+ })[];
97
+ }, {
98
+ type?: string;
99
+ attrs?: Record<string, any>;
100
+ content?: ({
101
+ type?: string;
102
+ attrs?: Record<string, any>;
103
+ } | {
104
+ type?: string;
105
+ attrs?: Record<string, any>;
106
+ text?: string;
107
+ marks?: {
108
+ type?: string;
109
+ attrs?: Record<string, any>;
110
+ }[];
111
+ })[];
112
+ }>]>, "many">>;
113
+ }>, "strip", z.ZodTypeAny, {
114
+ type?: string;
115
+ attrs?: Record<string, any>;
116
+ content?: ({
117
+ type?: string;
118
+ attrs?: Record<string, any>;
119
+ text?: string;
120
+ marks?: {
121
+ type?: string;
122
+ attrs?: Record<string, any>;
123
+ }[];
124
+ } | {
125
+ type?: string;
126
+ attrs?: Record<string, any>;
127
+ content?: ({
128
+ type?: string;
129
+ attrs?: Record<string, any>;
130
+ } | {
131
+ type?: string;
132
+ attrs?: Record<string, any>;
133
+ text?: string;
134
+ marks?: {
135
+ type?: string;
136
+ attrs?: Record<string, any>;
137
+ }[];
138
+ })[];
139
+ })[];
140
+ }, {
141
+ type?: string;
142
+ attrs?: Record<string, any>;
143
+ content?: ({
144
+ type?: string;
145
+ attrs?: Record<string, any>;
146
+ text?: string;
147
+ marks?: {
148
+ type?: string;
149
+ attrs?: Record<string, any>;
150
+ }[];
151
+ } | {
152
+ type?: string;
153
+ attrs?: Record<string, any>;
154
+ content?: ({
155
+ type?: string;
156
+ attrs?: Record<string, any>;
157
+ } | {
158
+ type?: string;
159
+ attrs?: Record<string, any>;
160
+ text?: string;
161
+ marks?: {
162
+ type?: string;
163
+ attrs?: Record<string, any>;
164
+ }[];
165
+ })[];
166
+ })[];
167
+ }>;
168
+ export declare const TiptapSchema: z.ZodObject<{
169
+ type: z.ZodLiteral<"doc">;
170
+ content: z.ZodArray<z.ZodObject<z.objectUtil.extendShape<{
171
+ type: z.ZodString;
172
+ attrs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
173
+ }, {
174
+ content: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodObject<z.objectUtil.extendShape<{
175
+ type: z.ZodString;
176
+ attrs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
177
+ }, {
178
+ text: z.ZodString;
179
+ marks: z.ZodOptional<z.ZodArray<z.ZodObject<{
180
+ type: z.ZodString;
181
+ attrs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
182
+ }, "strip", z.ZodTypeAny, {
183
+ type?: string;
184
+ attrs?: Record<string, any>;
185
+ }, {
186
+ type?: string;
187
+ attrs?: Record<string, any>;
188
+ }>, "many">>;
189
+ }>, "strip", z.ZodTypeAny, {
190
+ type?: string;
191
+ attrs?: Record<string, any>;
192
+ text?: string;
193
+ marks?: {
194
+ type?: string;
195
+ attrs?: Record<string, any>;
196
+ }[];
197
+ }, {
198
+ type?: string;
199
+ attrs?: Record<string, any>;
200
+ text?: string;
201
+ marks?: {
202
+ type?: string;
203
+ attrs?: Record<string, any>;
204
+ }[];
205
+ }>, z.ZodObject<z.objectUtil.extendShape<{
206
+ type: z.ZodString;
207
+ attrs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
208
+ }, {
209
+ content: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodObject<z.objectUtil.extendShape<{
210
+ type: z.ZodString;
211
+ attrs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
212
+ }, {
213
+ text: z.ZodString;
214
+ marks: z.ZodOptional<z.ZodArray<z.ZodObject<{
215
+ type: z.ZodString;
216
+ attrs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
217
+ }, "strip", z.ZodTypeAny, {
218
+ type?: string;
219
+ attrs?: Record<string, any>;
220
+ }, {
221
+ type?: string;
222
+ attrs?: Record<string, any>;
223
+ }>, "many">>;
224
+ }>, "strip", z.ZodTypeAny, {
225
+ type?: string;
226
+ attrs?: Record<string, any>;
227
+ text?: string;
228
+ marks?: {
229
+ type?: string;
230
+ attrs?: Record<string, any>;
231
+ }[];
232
+ }, {
233
+ type?: string;
234
+ attrs?: Record<string, any>;
235
+ text?: string;
236
+ marks?: {
237
+ type?: string;
238
+ attrs?: Record<string, any>;
239
+ }[];
240
+ }>, z.ZodObject<{
241
+ type: z.ZodString;
242
+ attrs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
243
+ }, "strip", z.ZodTypeAny, {
244
+ type?: string;
245
+ attrs?: Record<string, any>;
246
+ }, {
247
+ type?: string;
248
+ attrs?: Record<string, any>;
249
+ }>]>, "many">>;
250
+ }>, "strip", z.ZodTypeAny, {
251
+ type?: string;
252
+ attrs?: Record<string, any>;
253
+ content?: ({
254
+ type?: string;
255
+ attrs?: Record<string, any>;
256
+ } | {
257
+ type?: string;
258
+ attrs?: Record<string, any>;
259
+ text?: string;
260
+ marks?: {
261
+ type?: string;
262
+ attrs?: Record<string, any>;
263
+ }[];
264
+ })[];
265
+ }, {
266
+ type?: string;
267
+ attrs?: Record<string, any>;
268
+ content?: ({
269
+ type?: string;
270
+ attrs?: Record<string, any>;
271
+ } | {
272
+ type?: string;
273
+ attrs?: Record<string, any>;
274
+ text?: string;
275
+ marks?: {
276
+ type?: string;
277
+ attrs?: Record<string, any>;
278
+ }[];
279
+ })[];
280
+ }>]>, "many">>;
281
+ }>, "strip", z.ZodTypeAny, {
282
+ type?: string;
283
+ attrs?: Record<string, any>;
284
+ content?: ({
285
+ type?: string;
286
+ attrs?: Record<string, any>;
287
+ text?: string;
288
+ marks?: {
289
+ type?: string;
290
+ attrs?: Record<string, any>;
291
+ }[];
292
+ } | {
293
+ type?: string;
294
+ attrs?: Record<string, any>;
295
+ content?: ({
296
+ type?: string;
297
+ attrs?: Record<string, any>;
298
+ } | {
299
+ type?: string;
300
+ attrs?: Record<string, any>;
301
+ text?: string;
302
+ marks?: {
303
+ type?: string;
304
+ attrs?: Record<string, any>;
305
+ }[];
306
+ })[];
307
+ })[];
308
+ }, {
309
+ type?: string;
310
+ attrs?: Record<string, any>;
311
+ content?: ({
312
+ type?: string;
313
+ attrs?: Record<string, any>;
314
+ text?: string;
315
+ marks?: {
316
+ type?: string;
317
+ attrs?: Record<string, any>;
318
+ }[];
319
+ } | {
320
+ type?: string;
321
+ attrs?: Record<string, any>;
322
+ content?: ({
323
+ type?: string;
324
+ attrs?: Record<string, any>;
325
+ } | {
326
+ type?: string;
327
+ attrs?: Record<string, any>;
328
+ text?: string;
329
+ marks?: {
330
+ type?: string;
331
+ attrs?: Record<string, any>;
332
+ }[];
333
+ })[];
334
+ })[];
335
+ }>, "many">;
336
+ }, "strip", z.ZodTypeAny, {
337
+ type?: "doc";
338
+ content?: {
339
+ type?: string;
340
+ attrs?: Record<string, any>;
341
+ content?: ({
342
+ type?: string;
343
+ attrs?: Record<string, any>;
344
+ text?: string;
345
+ marks?: {
346
+ type?: string;
347
+ attrs?: Record<string, any>;
348
+ }[];
349
+ } | {
350
+ type?: string;
351
+ attrs?: Record<string, any>;
352
+ content?: ({
353
+ type?: string;
354
+ attrs?: Record<string, any>;
355
+ } | {
356
+ type?: string;
357
+ attrs?: Record<string, any>;
358
+ text?: string;
359
+ marks?: {
360
+ type?: string;
361
+ attrs?: Record<string, any>;
362
+ }[];
363
+ })[];
364
+ })[];
365
+ }[];
366
+ }, {
367
+ type?: "doc";
368
+ content?: {
369
+ type?: string;
370
+ attrs?: Record<string, any>;
371
+ content?: ({
372
+ type?: string;
373
+ attrs?: Record<string, any>;
374
+ text?: string;
375
+ marks?: {
376
+ type?: string;
377
+ attrs?: Record<string, any>;
378
+ }[];
379
+ } | {
380
+ type?: string;
381
+ attrs?: Record<string, any>;
382
+ content?: ({
383
+ type?: string;
384
+ attrs?: Record<string, any>;
385
+ } | {
386
+ type?: string;
387
+ attrs?: Record<string, any>;
388
+ text?: string;
389
+ marks?: {
390
+ type?: string;
391
+ attrs?: Record<string, any>;
392
+ }[];
393
+ })[];
394
+ })[];
395
+ }[];
396
+ }>;
397
+ //# sourceMappingURL=tiptapSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tiptapSchema.d.ts","sourceRoot":"","sources":["../../../../../src/fields/TiptapEditor/lib/tiptapSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AA8BvB,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAoB,CAAA;AAElD,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGvB,CAAA"}