payload-richtext-tiptap 0.0.47 → 0.0.49
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/AICommand/AICommand.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/AICommand/AICommand.js +2 -0
- package/dist/src/fields/TiptapEditor/extensions/AICommand/AICommand.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/ImageUpload/view/ImageUpload.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/ImageUpload/view/ImageUpload.js +21 -9
- package/dist/src/fields/TiptapEditor/extensions/ImageUpload/view/ImageUpload.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/Video/Video.d.ts +52 -0
- package/dist/src/fields/TiptapEditor/extensions/Video/Video.d.ts.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/Video/Video.js +81 -0
- package/dist/src/fields/TiptapEditor/extensions/Video/Video.js.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/Video/index.d.ts +2 -0
- package/dist/src/fields/TiptapEditor/extensions/Video/index.d.ts.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/Video/index.js +3 -0
- package/dist/src/fields/TiptapEditor/extensions/Video/index.js.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/VideoBlock.d.ts +21 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/VideoBlock.d.ts.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/VideoBlock.js +97 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/VideoBlock.js.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockMenu.d.ts +5 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockMenu.d.ts.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockMenu.js +133 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockMenu.js.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.d.ts +16 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.d.ts.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.js +39 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.js.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockWidth.d.ts +7 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockWidth.d.ts.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockWidth.js +39 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockWidth.js.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/index.d.ts +2 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/index.d.ts.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/index.js +3 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/index.js.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/extension-kit.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/extension-kit.js +4 -3
- package/dist/src/fields/TiptapEditor/extensions/extension-kit.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/index.d.ts +1 -0
- package/dist/src/fields/TiptapEditor/extensions/index.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/index.js +1 -0
- package/dist/src/fields/TiptapEditor/extensions/index.js.map +1 -1
- package/dist/src/fields/TiptapEditor/features/BlockEditor/BlockEditor.d.ts +2 -1
- package/dist/src/fields/TiptapEditor/features/BlockEditor/BlockEditor.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/features/BlockEditor/BlockEditor.js +3 -2
- package/dist/src/fields/TiptapEditor/features/BlockEditor/BlockEditor.js.map +1 -1
- package/dist/src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.js +2 -2
- package/dist/src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.js.map +1 -1
- package/dist/src/fields/TiptapEditor/hooks/useBlockEditor.d.ts +2 -1
- package/dist/src/fields/TiptapEditor/hooks/useBlockEditor.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/hooks/useBlockEditor.js +8 -2
- package/dist/src/fields/TiptapEditor/hooks/useBlockEditor.js.map +1 -1
- package/dist/src/fields/TiptapEditor/lib/extract.js +0 -1
- package/dist/src/fields/TiptapEditor/lib/extract.js.map +1 -1
- package/dist/src/fields/TiptapEditor/types.d.js.map +1 -1
- package/dist/src/styles.css +2 -28
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockMenu.tsx"],"sourcesContent":["import { BubbleMenu as BaseBubbleMenu } from \"@tiptap/react\";\nimport { ReactNode, useCallback, useRef } from \"react\";\nimport { Instance, sticky } from \"tippy.js\";\nimport { v4 as uuid } from \"uuid\";\n\nimport {\n AlignHorizontalDistributeCenter,\n AlignHorizontalDistributeEnd,\n AlignHorizontalDistributeStart,\n} from \"lucide-react\";\nimport { MenuProps } from \"../../../features/menus/types.js\";\nimport { Icon } from \"../../../features/ui/Icon.js\";\nimport { Toolbar } from \"../../../features/ui/Toolbar.js\";\nimport { getRenderContainer } from \"../../../lib/utils/index.js\";\nimport { VideoBlockWidth } from \"./VideoBlockWidth.js\";\n\nexport const VideoBlockMenu = ({ editor, appendTo }: MenuProps): ReactNode => {\n const menuRef = useRef<HTMLDivElement>(null);\n const tippyInstance = useRef<Instance | null>(null);\n\n const getReferenceClientRect = useCallback(() => {\n const renderContainer = getRenderContainer(editor, \"node-videoBlock\");\n const rect =\n renderContainer?.getBoundingClientRect() ||\n new DOMRect(-1000, -1000, 0, 0);\n\n return rect;\n }, [editor]);\n\n const shouldShow = useCallback(() => {\n const isActive = editor.isActive(\"videoBlock\");\n\n return isActive;\n }, [editor]);\n\n const onAlignVideoLeft = useCallback(() => {\n editor\n .chain()\n .focus(undefined, { scrollIntoView: false })\n .setVideoBlockAlign(\"left\")\n .run();\n }, [editor]);\n\n const onAlignVideoCenter = useCallback(() => {\n editor\n .chain()\n .focus(undefined, { scrollIntoView: false })\n .setVideoBlockAlign(\"center\")\n .run();\n }, [editor]);\n\n const onAlignVideoRight = useCallback(() => {\n editor\n .chain()\n .focus(undefined, { scrollIntoView: false })\n .setVideoBlockAlign(\"right\")\n .run();\n }, [editor]);\n\n const onWidthChange = useCallback(\n (value: number) => {\n editor\n .chain()\n .focus(undefined, { scrollIntoView: false })\n .setVideoBlockWidth(value)\n .run();\n },\n [editor]\n );\n\n return (\n <BaseBubbleMenu\n editor={editor}\n pluginKey={`videoBlockMenu-${uuid()}`}\n shouldShow={shouldShow}\n updateDelay={0}\n tippyOptions={{\n offset: [0, 8],\n popperOptions: {\n modifiers: [{ name: \"flip\", enabled: false }],\n },\n getReferenceClientRect,\n onCreate: (instance: Instance) => {\n tippyInstance.current = instance;\n },\n appendTo: () => {\n return appendTo?.current;\n },\n plugins: [sticky],\n sticky: \"popper\",\n }}\n >\n <Toolbar.Wrapper shouldShowContent={shouldShow()} ref={menuRef}>\n <Toolbar.Button\n type=\"button\"\n tooltip=\"Align video left\"\n active={editor.isActive(\"videoBlock\", { align: \"left\" })}\n onClick={onAlignVideoLeft}\n >\n <Icon icon={AlignHorizontalDistributeStart} />\n </Toolbar.Button>\n <Toolbar.Button\n type=\"button\"\n tooltip=\"Align video center\"\n active={editor.isActive(\"videoBlock\", { align: \"center\" })}\n onClick={onAlignVideoCenter}\n >\n <Icon icon={AlignHorizontalDistributeCenter} />\n </Toolbar.Button>\n <Toolbar.Button\n type=\"button\"\n tooltip=\"Align video right\"\n active={editor.isActive(\"videoBlock\", { align: \"right\" })}\n onClick={onAlignVideoRight}\n >\n <Icon icon={AlignHorizontalDistributeEnd} />\n </Toolbar.Button>\n <Toolbar.Divider />\n <VideoBlockWidth\n onChange={onWidthChange}\n value={parseInt(editor.getAttributes(\"videoBlock\").width)}\n />\n </Toolbar.Wrapper>\n </BaseBubbleMenu>\n );\n};\n\nexport default VideoBlockMenu;\n"],"names":["BubbleMenu","BaseBubbleMenu","useCallback","useRef","sticky","v4","uuid","AlignHorizontalDistributeCenter","AlignHorizontalDistributeEnd","AlignHorizontalDistributeStart","Icon","Toolbar","getRenderContainer","VideoBlockWidth","VideoBlockMenu","editor","appendTo","menuRef","tippyInstance","getReferenceClientRect","renderContainer","rect","getBoundingClientRect","DOMRect","shouldShow","isActive","onAlignVideoLeft","chain","focus","undefined","scrollIntoView","setVideoBlockAlign","run","onAlignVideoCenter","onAlignVideoRight","onWidthChange","value","setVideoBlockWidth","pluginKey","updateDelay","tippyOptions","offset","popperOptions","modifiers","name","enabled","onCreate","instance","current","plugins","Wrapper","shouldShowContent","ref","Button","type","tooltip","active","align","onClick","icon","Divider","onChange","parseInt","getAttributes","width"],"mappings":";AAAA,SAASA,cAAcC,cAAc,QAAQ,gBAAgB;AAC7D,SAAoBC,WAAW,EAAEC,MAAM,QAAQ,QAAQ;AACvD,SAAmBC,MAAM,QAAQ,WAAW;AAC5C,SAASC,MAAMC,IAAI,QAAQ,OAAO;AAElC,SACEC,+BAA+B,EAC/BC,4BAA4B,EAC5BC,8BAA8B,QACzB,eAAe;AAEtB,SAASC,IAAI,QAAQ,+BAA+B;AACpD,SAASC,OAAO,QAAQ,kCAAkC;AAC1D,SAASC,kBAAkB,QAAQ,8BAA8B;AACjE,SAASC,eAAe,QAAQ,uBAAuB;AAEvD,OAAO,MAAMC,iBAAiB,CAAC,EAAEC,MAAM,EAAEC,QAAQ,EAAa;IAC5D,MAAMC,UAAUd,OAAuB;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OAAO,GAAGD;YAC1B;YACA/B,UAAU;gBACR,OAAOA,UAAUgC;YACnB;YACAC,SAAS;gBAAC7C;aAAO;YACjBA,QAAQ;QACV;kBAEA,cAAA,MAACO,QAAQuC,OAAO;YAACC,mBAAmB3B;YAAc4B,KAAKnC;;8BACrD,KAACN,QAAQ0C,MAAM;oBACbC,MAAK;oBACLC,SAAQ;oBACRC,QAAQzC,OAAOU,QAAQ,CAAC,cAAc;wBAAEgC,OAAO;oBAAO;oBACtDC,SAAShC;8BAET,cAAA,KAAChB;wBAAKiD,MAAMlD;;;8BAEd,KAACE,QAAQ0C,MAAM;oBACbC,MAAK;oBACLC,SAAQ;oBACRC,QAAQzC,OAAOU,QAAQ,CAAC,cAAc;wBAAEgC,OAAO;oBAAS;oBACxDC,SAASzB;8BAET,cAAA,KAACvB;wBAAKiD,MAAMpD;;;8BAEd,KAACI,QAAQ0C,MAAM;oBACbC,MAAK;oBACLC,SAAQ;oBACRC,QAAQzC,OAAOU,QAAQ,CAAC,cAAc;wBAAEgC,OAAO;oBAAQ;oBACvDC,SAASxB;8BAET,cAAA,KAACxB;wBAAKiD,MAAMnD;;;8BAEd,KAACG,QAAQiD,OAAO;8BAChB,KAAC/C;oBACCgD,UAAU1B;oBACVC,OAAO0B,SAAS/C,OAAOgD,aAAa,CAAC,cAAcC,KAAK;;;;;AAKlE,EAAE;AAEF,eAAelD,eAAe"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Node } from "@tiptap/pm/model";
|
|
2
|
+
import { Editor } from "@tiptap/react";
|
|
3
|
+
import React from "react";
|
|
4
|
+
interface VideoBlockViewProps {
|
|
5
|
+
editor: Editor;
|
|
6
|
+
getPos: () => number;
|
|
7
|
+
node: Node & {
|
|
8
|
+
attrs: {
|
|
9
|
+
src: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
updateAttributes: (attrs: Record<string, string>) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const VideoBlockView: (props: VideoBlockViewProps) => React.JSX.Element;
|
|
15
|
+
export default VideoBlockView;
|
|
16
|
+
//# sourceMappingURL=VideoBlockView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VideoBlockView.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAmB,MAAM,eAAe,CAAC;AACxD,OAAO,KAA8B,MAAM,OAAO,CAAC;AAGnD,UAAU,mBAAmB;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,MAAM,CAAC;IACrB,IAAI,EAAE,IAAI,GAAG;QACX,KAAK,EAAE;YACL,GAAG,EAAE,MAAM,CAAC;SACb,CAAC;KACH,CAAC;IACF,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;CAC3D;AAED,eAAO,MAAM,cAAc,UAAW,mBAAmB,sBA+BxD,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { NodeViewWrapper } from "@tiptap/react";
|
|
3
|
+
import React, { useCallback, useRef } from "react";
|
|
4
|
+
import { cn } from "../../../lib/utils/index.js";
|
|
5
|
+
export const VideoBlockView = (props)=>{
|
|
6
|
+
const { editor, getPos, node } = props;
|
|
7
|
+
const videoWrapperRef = useRef(null);
|
|
8
|
+
const { src, poster } = node.attrs;
|
|
9
|
+
const wrapperClassName = cn(node.attrs.align === "left" ? "ml-0" : "ml-auto", node.attrs.align === "right" ? "mr-0" : "mr-auto", node.attrs.align === "center" && "mx-auto");
|
|
10
|
+
const onClick = useCallback(()=>{
|
|
11
|
+
editor.commands.setNodeSelection(getPos());
|
|
12
|
+
}, [
|
|
13
|
+
getPos,
|
|
14
|
+
editor.commands
|
|
15
|
+
]);
|
|
16
|
+
return /*#__PURE__*/ _jsx(NodeViewWrapper, {
|
|
17
|
+
children: /*#__PURE__*/ _jsx("div", {
|
|
18
|
+
className: wrapperClassName,
|
|
19
|
+
style: {
|
|
20
|
+
width: node.attrs.width
|
|
21
|
+
},
|
|
22
|
+
children: /*#__PURE__*/ _jsx("div", {
|
|
23
|
+
contentEditable: false,
|
|
24
|
+
ref: videoWrapperRef,
|
|
25
|
+
children: /*#__PURE__*/ _jsx("video", {
|
|
26
|
+
controls: true,
|
|
27
|
+
className: "block",
|
|
28
|
+
src: src,
|
|
29
|
+
poster: poster,
|
|
30
|
+
title: "",
|
|
31
|
+
onClick: onClick
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
export default VideoBlockView;
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=VideoBlockView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.tsx"],"sourcesContent":["import { Node } from \"@tiptap/pm/model\";\nimport { Editor, NodeViewWrapper } from \"@tiptap/react\";\nimport React, { useCallback, useRef } from \"react\";\nimport { cn } from \"../../../lib/utils/index.js\";\n\ninterface VideoBlockViewProps {\n editor: Editor;\n getPos: () => number;\n node: Node & {\n attrs: {\n src: string;\n };\n };\n updateAttributes: (attrs: Record<string, string>) => void;\n}\n\nexport const VideoBlockView = (props: VideoBlockViewProps) => {\n const { editor, getPos, node } = props;\n const videoWrapperRef = useRef<HTMLDivElement>(null);\n const { src, poster } = node.attrs;\n\n const wrapperClassName = cn(\n node.attrs.align === \"left\" ? \"ml-0\" : \"ml-auto\",\n node.attrs.align === \"right\" ? \"mr-0\" : \"mr-auto\",\n node.attrs.align === \"center\" && \"mx-auto\"\n );\n\n const onClick = useCallback(() => {\n editor.commands.setNodeSelection(getPos());\n }, [getPos, editor.commands]);\n\n return (\n <NodeViewWrapper>\n <div className={wrapperClassName} style={{ width: node.attrs.width }}>\n <div contentEditable={false} ref={videoWrapperRef}>\n <video\n controls\n className=\"block\"\n src={src}\n poster={poster}\n title=\"\"\n onClick={onClick}\n />\n </div>\n </div>\n </NodeViewWrapper>\n );\n};\n\nexport default VideoBlockView;\n"],"names":["NodeViewWrapper","React","useCallback","useRef","cn","VideoBlockView","props","editor","getPos","node","videoWrapperRef","src","poster","attrs","wrapperClassName","align","onClick","commands","setNodeSelection","div","className","style","width","contentEditable","ref","video","controls","title"],"mappings":";AACA,SAAiBA,eAAe,QAAQ,gBAAgB;AACxD,OAAOC,SAASC,WAAW,EAAEC,MAAM,QAAQ,QAAQ;AACnD,SAASC,EAAE,QAAQ,8BAA8B;AAajD,OAAO,MAAMC,iBAAiB,CAACC;IAC7B,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,IAAI,EAAE,GAAGH;IACjC,MAAMI,kBAAkBP,OAAuB;IAC/C,MAAM,EAAEQ,GAAG,EAAEC,MAAM,EAAE,GAAGH,KAAKI,KAAK;IAElC,MAAMC,mBAAmBV,GACvBK,KAAKI,KAAK,CAACE,KAAK,KAAK,SAAS,SAAS,WACvCN,KAAKI,KAAK,CAACE,KAAK,KAAK,UAAU,SAAS,WACxCN,KAAKI,KAAK,CAACE,KAAK,KAAK,YAAY;IAGnC,MAAMC,UAAUd,YAAY;QAC1BK,OAAOU,QAAQ,CAACC,gBAAgB,CAACV;IACnC,GAAG;QAACA;QAAQD,OAAOU,QAAQ;KAAC;IAE5B,qBACE,KAACjB;kBACC,cAAA,KAACmB;YAAIC,WAAWN;YAAkBO,OAAO;gBAAEC,OAAOb,KAAKI,KAAK,CAACS,KAAK;YAAC;sBACjE,cAAA,KAACH;gBAAII,iBAAiB;gBAAOC,KAAKd;0BAChC,cAAA,KAACe;oBACCC,QAAQ;oBACRN,WAAU;oBACVT,KAAKA;oBACLC,QAAQA;oBACRe,OAAM;oBACNX,SAASA;;;;;AAMrB,EAAE;AAEF,eAAeX,eAAe"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type VideoBlockWidthProps = {
|
|
3
|
+
onChange: (value: number) => void;
|
|
4
|
+
value: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const VideoBlockWidth: React.MemoExoticComponent<({ onChange, value }: VideoBlockWidthProps) => React.JSX.Element>;
|
|
7
|
+
//# sourceMappingURL=VideoBlockWidth.d.ts.map
|
package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockWidth.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VideoBlockWidth.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockWidth.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAEtE,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,eAAe,kDACJ,oBAAoB,uBA+B3C,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { memo, useCallback, useEffect, useState } from "react";
|
|
3
|
+
export const VideoBlockWidth = /*#__PURE__*/ memo(({ onChange, value })=>{
|
|
4
|
+
const [currentValue, setCurrentValue] = useState(value);
|
|
5
|
+
useEffect(()=>{
|
|
6
|
+
setCurrentValue(value);
|
|
7
|
+
}, [
|
|
8
|
+
value
|
|
9
|
+
]);
|
|
10
|
+
const handleChange = useCallback((e)=>{
|
|
11
|
+
onChange(parseInt(e.target.value));
|
|
12
|
+
}, [
|
|
13
|
+
onChange
|
|
14
|
+
]);
|
|
15
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
16
|
+
className: "flex items-center gap-2",
|
|
17
|
+
children: [
|
|
18
|
+
/*#__PURE__*/ _jsx("input", {
|
|
19
|
+
className: "h-2 bg-neutral-200 border-0 rounded appearance-none fill-neutral-300",
|
|
20
|
+
type: "range",
|
|
21
|
+
min: "25",
|
|
22
|
+
max: "100",
|
|
23
|
+
step: "25",
|
|
24
|
+
onChange: handleChange,
|
|
25
|
+
value: currentValue
|
|
26
|
+
}),
|
|
27
|
+
/*#__PURE__*/ _jsxs("span", {
|
|
28
|
+
className: "text-xs font-semibold text-neutral-500 select-none",
|
|
29
|
+
children: [
|
|
30
|
+
value,
|
|
31
|
+
"%"
|
|
32
|
+
]
|
|
33
|
+
})
|
|
34
|
+
]
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
VideoBlockWidth.displayName = "VideoBlockWidth";
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=VideoBlockWidth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockWidth.tsx"],"sourcesContent":["import React, { memo, useCallback, useEffect, useState } from \"react\";\n\nexport type VideoBlockWidthProps = {\n onChange: (value: number) => void;\n value: number;\n};\n\nexport const VideoBlockWidth = memo(\n ({ onChange, value }: VideoBlockWidthProps) => {\n const [currentValue, setCurrentValue] = useState(value);\n\n useEffect(() => {\n setCurrentValue(value);\n }, [value]);\n\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n onChange(parseInt(e.target.value));\n },\n [onChange]\n );\n\n return (\n <div className=\"flex items-center gap-2\">\n <input\n className=\"h-2 bg-neutral-200 border-0 rounded appearance-none fill-neutral-300\"\n type=\"range\"\n min=\"25\"\n max=\"100\"\n step=\"25\"\n onChange={handleChange}\n value={currentValue}\n />\n <span className=\"text-xs font-semibold text-neutral-500 select-none\">\n {value}%\n </span>\n </div>\n );\n }\n);\n\nVideoBlockWidth.displayName = \"VideoBlockWidth\";\n"],"names":["React","memo","useCallback","useEffect","useState","VideoBlockWidth","onChange","value","currentValue","setCurrentValue","handleChange","e","parseInt","target","div","className","input","type","min","max","step","span","displayName"],"mappings":";AAAA,OAAOA,SAASC,IAAI,EAAEC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAOtE,OAAO,MAAMC,gCAAkBJ,KAC7B,CAAC,EAAEK,QAAQ,EAAEC,KAAK,EAAwB;IACxC,MAAM,CAACC,cAAcC,gBAAgB,GAAGL,SAASG;IAEjDJ,UAAU;QACRM,gBAAgBF;IAClB,GAAG;QAACA;KAAM;IAEV,MAAMG,eAAeR,YACnB,CAACS;QACCL,SAASM,SAASD,EAAEE,MAAM,CAACN,KAAK;IAClC,GACA;QAACD;KAAS;IAGZ,qBACE,MAACQ;QAAIC,WAAU;;0BACb,KAACC;gBACCD,WAAU;gBACVE,MAAK;gBACLC,KAAI;gBACJC,KAAI;gBACJC,MAAK;gBACLd,UAAUI;gBACVH,OAAOC;;0BAET,MAACa;gBAAKN,WAAU;;oBACbR;oBAAM;;;;;AAIf,GACA;AAEFF,gBAAgBiB,WAAW,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/index.ts"],"sourcesContent":["export * from \"./VideoBlock.js\";\n"],"names":[],"mappings":"AAAA,cAAc,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension-kit.d.ts","sourceRoot":"","sources":["../../../../../src/fields/TiptapEditor/extensions/extension-kit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"extension-kit.d.ts","sourceRoot":"","sources":["../../../../../src/fields/TiptapEditor/extensions/extension-kit.ts"],"names":[],"mappings":"AAyDA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAI9C,UAAU,iBAAiB;IACzB,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IACpB,kBAAkB,EAAE,eAAe,CAAC;CACrC;AAED,eAAO,MAAM,YAAY,iCAGtB,iBAAiB,+LAuHnB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AICommand, BlockquoteFigure, CharacterCount, Color, Column, // emojiSuggestion,
|
|
2
|
-
Columns, Document, Dropcursor, Facebook, Figcaption, FileHandler, Focus, FontFamily, FontSize, Heading, Highlight, HorizontalRule, ImageBlock, InsideLinks, Instagram, Link, Linkedin, Placeholder, Paragraph, Selection, SlashCommand, StarterKit, Subscript, Superscript, Table, TableCell, TableHeader, TableOfContents, TableRow, TaskItem, TaskList, TextAlign, TextStyle, Tiktok, TrailingNode, Twitter, Typography, Underline, Youtube } from "./index.js";
|
|
2
|
+
Columns, Document, Dropcursor, Facebook, Figcaption, FileHandler, Focus, FontFamily, FontSize, Heading, Highlight, HorizontalRule, VideoBlock, ImageBlock, InsideLinks, Instagram, Link, Linkedin, Placeholder, Paragraph, Selection, SlashCommand, StarterKit, Subscript, Superscript, Table, TableCell, TableHeader, TableOfContents, TableRow, TaskItem, TaskList, TextAlign, TextStyle, Tiktok, TrailingNode, Twitter, Typography, Underline, Youtube } from "./index.js";
|
|
3
3
|
import { CodeBlockLowlight } from "@tiptap/extension-code-block-lowlight";
|
|
4
4
|
import lowlight from "lowlight";
|
|
5
5
|
import TextDirection from "tiptap-text-direction";
|
|
@@ -64,6 +64,7 @@ export const ExtensionKit = ({ dir, openAssetHQHandler })=>[
|
|
|
64
64
|
openAssetHQHandler
|
|
65
65
|
}),
|
|
66
66
|
ImageBlock,
|
|
67
|
+
VideoBlock,
|
|
67
68
|
FileHandler.configure({
|
|
68
69
|
allowedMimeTypes: [
|
|
69
70
|
"image/png",
|
|
@@ -74,10 +75,10 @@ export const ExtensionKit = ({ dir, openAssetHQHandler })=>[
|
|
|
74
75
|
onDrop: (currentEditor, files, pos)=>{
|
|
75
76
|
const file = files[0];
|
|
76
77
|
(async ()=>{
|
|
77
|
-
openAssetHQHandler((
|
|
78
|
+
openAssetHQHandler((asset)=>{
|
|
78
79
|
currentEditor.chain().setImageBlockAt({
|
|
79
80
|
pos,
|
|
80
|
-
src:
|
|
81
|
+
src: asset.fullUrl
|
|
81
82
|
}).focus().run();
|
|
82
83
|
}, file);
|
|
83
84
|
})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/fields/TiptapEditor/extensions/extension-kit.ts"],"sourcesContent":["import {\n AICommand,\n BlockquoteFigure,\n CharacterCount,\n Color,\n Column,\n // emojiSuggestion,\n Columns,\n Document,\n Dropcursor,\n Facebook,\n Figcaption,\n FileHandler,\n Focus,\n FontFamily,\n FontSize,\n Heading,\n Highlight,\n HorizontalRule,\n ImageBlock,\n InsideLinks,\n Instagram,\n Link,\n Linkedin,\n Placeholder,\n Paragraph,\n Selection,\n SlashCommand,\n StarterKit,\n Subscript,\n Superscript,\n Table,\n TableCell,\n TableHeader,\n TableOfContents,\n TableRow,\n TaskItem,\n TaskList,\n TextAlign,\n TextStyle,\n Tiktok,\n TrailingNode,\n Twitter,\n Typography,\n Underline,\n Youtube,\n} from \"./index.js\";\n\nimport { CodeBlockLowlight } from \"@tiptap/extension-code-block-lowlight\";\nimport lowlight from \"lowlight\";\nimport TextDirection from \"tiptap-text-direction\";\nimport { ImageUpload } from \"./ImageUpload/ImageUpload.js\";\nimport { TableOfContentsNode } from \"./TableOfContentsNode/TableOfContentsNode.js\";\n\nimport History from \"@tiptap/extension-history\";\nimport API from \"../lib/api.js\";\nimport { openAssetHQType } from \"../types.js\";\nimport { Iframe } from \"./Iframe/iframe.js\";\nimport { Markdown } from \"tiptap-markdown\";\n\ninterface ExtensionKitProps {\n dir?: \"rtl\" | \"ltr\";\n openAssetHQHandler: openAssetHQType;\n}\n\nexport const ExtensionKit = ({\n dir,\n openAssetHQHandler,\n}: ExtensionKitProps) => [\n Markdown,\n Document,\n Columns,\n TaskList,\n TaskItem.configure({\n nested: true,\n }),\n Column,\n Selection,\n Heading.configure({\n levels: [1, 2, 3, 4, 5, 6],\n }),\n HorizontalRule,\n StarterKit.configure({\n document: false,\n dropcursor: false,\n heading: false,\n horizontalRule: false,\n blockquote: false,\n history: false,\n codeBlock: false,\n }),\n CodeBlockLowlight.configure({\n lowlight,\n defaultLanguage: null,\n }),\n TextStyle,\n FontSize,\n FontFamily,\n Color,\n TrailingNode,\n Link.configure({\n openOnClick: false,\n }),\n Highlight.configure({ multicolor: true }),\n Underline,\n CharacterCount.configure({ limit: 50000 }),\n TableOfContents,\n TableOfContentsNode,\n ImageUpload.configure({\n openAssetHQHandler,\n }),\n ImageBlock,\n FileHandler.configure({\n allowedMimeTypes: [\"image/png\", \"image/jpeg\", \"image/gif\", \"image/webp\"],\n onDrop: (currentEditor, files, pos) => {\n const file = files[0];\n (async () => {\n openAssetHQHandler((
|
|
1
|
+
{"version":3,"sources":["../../../../../src/fields/TiptapEditor/extensions/extension-kit.ts"],"sourcesContent":["import {\n AICommand,\n BlockquoteFigure,\n CharacterCount,\n Color,\n Column,\n // emojiSuggestion,\n Columns,\n Document,\n Dropcursor,\n Facebook,\n Figcaption,\n FileHandler,\n Focus,\n FontFamily,\n FontSize,\n Heading,\n Highlight,\n HorizontalRule,\n VideoBlock,\n ImageBlock,\n InsideLinks,\n Instagram,\n Link,\n Linkedin,\n Placeholder,\n Paragraph,\n Selection,\n SlashCommand,\n StarterKit,\n Subscript,\n Superscript,\n Table,\n TableCell,\n TableHeader,\n TableOfContents,\n TableRow,\n TaskItem,\n TaskList,\n TextAlign,\n TextStyle,\n Tiktok,\n TrailingNode,\n Twitter,\n Typography,\n Underline,\n Youtube,\n} from \"./index.js\";\n\nimport { CodeBlockLowlight } from \"@tiptap/extension-code-block-lowlight\";\nimport lowlight from \"lowlight\";\nimport TextDirection from \"tiptap-text-direction\";\nimport { ImageUpload } from \"./ImageUpload/ImageUpload.js\";\nimport { TableOfContentsNode } from \"./TableOfContentsNode/TableOfContentsNode.js\";\n\nimport History from \"@tiptap/extension-history\";\nimport API from \"../lib/api.js\";\nimport { openAssetHQType } from \"../types.js\";\nimport { Iframe } from \"./Iframe/iframe.js\";\nimport { Markdown } from \"tiptap-markdown\";\n\ninterface ExtensionKitProps {\n dir?: \"rtl\" | \"ltr\";\n openAssetHQHandler: openAssetHQType;\n}\n\nexport const ExtensionKit = ({\n dir,\n openAssetHQHandler,\n}: ExtensionKitProps) => [\n Markdown,\n Document,\n Columns,\n TaskList,\n TaskItem.configure({\n nested: true,\n }),\n Column,\n Selection,\n Heading.configure({\n levels: [1, 2, 3, 4, 5, 6],\n }),\n HorizontalRule,\n StarterKit.configure({\n document: false,\n dropcursor: false,\n heading: false,\n horizontalRule: false,\n blockquote: false,\n history: false,\n codeBlock: false,\n }),\n CodeBlockLowlight.configure({\n lowlight,\n defaultLanguage: null,\n }),\n TextStyle,\n FontSize,\n FontFamily,\n Color,\n TrailingNode,\n Link.configure({\n openOnClick: false,\n }),\n Highlight.configure({ multicolor: true }),\n Underline,\n CharacterCount.configure({ limit: 50000 }),\n TableOfContents,\n TableOfContentsNode,\n ImageUpload.configure({\n openAssetHQHandler,\n }),\n ImageBlock,\n VideoBlock,\n FileHandler.configure({\n allowedMimeTypes: [\"image/png\", \"image/jpeg\", \"image/gif\", \"image/webp\"],\n onDrop: (currentEditor, files, pos) => {\n const file = files[0];\n (async () => {\n openAssetHQHandler((asset) => {\n currentEditor\n .chain()\n .setImageBlockAt({ pos, src: asset.fullUrl })\n .focus()\n .run();\n }, file);\n })();\n },\n onPaste: (currentEditor, files) => {\n files.forEach(async () => {\n const url = await API.uploadImage();\n\n return currentEditor\n .chain()\n .setImageBlockAt({\n pos: currentEditor.state.selection.anchor,\n src: url,\n })\n .focus()\n .run();\n });\n },\n }),\n // Emoji.configure({\n // enableEmoticons: true,\n // suggestion: emojiSuggestion,\n // }),\n TextAlign.extend({\n addKeyboardShortcuts() {\n return {};\n },\n }).configure({\n types: [\"heading\", \"paragraph\"],\n }),\n Subscript,\n Superscript,\n Table,\n TableCell,\n TableHeader,\n TableRow,\n Typography,\n Placeholder.configure({\n includeChildren: true,\n showOnlyCurrent: false,\n placeholder: () => \"\",\n }),\n SlashCommand,\n Focus,\n Figcaption,\n BlockquoteFigure,\n Dropcursor.configure({\n width: 2,\n class: \"ProseMirror-dropcursor border-black\",\n }),\n History,\n Iframe,\n Twitter,\n Tiktok,\n Instagram,\n Facebook,\n Linkedin,\n Youtube,\n Paragraph,\n InsideLinks,\n TextDirection.configure({\n types: [\"heading\", \"paragraph\"],\n }),\n AICommand,\n];\n\nexport default ExtensionKit;\n"],"names":["AICommand","BlockquoteFigure","CharacterCount","Color","Column","Columns","Document","Dropcursor","Facebook","Figcaption","FileHandler","Focus","FontFamily","FontSize","Heading","Highlight","HorizontalRule","VideoBlock","ImageBlock","InsideLinks","Instagram","Link","Linkedin","Placeholder","Paragraph","Selection","SlashCommand","StarterKit","Subscript","Superscript","Table","TableCell","TableHeader","TableOfContents","TableRow","TaskItem","TaskList","TextAlign","TextStyle","Tiktok","TrailingNode","Twitter","Typography","Underline","Youtube","CodeBlockLowlight","lowlight","TextDirection","ImageUpload","TableOfContentsNode","History","API","Iframe","Markdown","ExtensionKit","dir","openAssetHQHandler","configure","nested","levels","document","dropcursor","heading","horizontalRule","blockquote","history","codeBlock","defaultLanguage","openOnClick","multicolor","limit","allowedMimeTypes","onDrop","currentEditor","files","pos","file","asset","chain","setImageBlockAt","src","fullUrl","focus","run","onPaste","forEach","url","uploadImage","state","selection","anchor","extend","addKeyboardShortcuts","types","includeChildren","showOnlyCurrent","placeholder","width","class"],"mappings":"AAAA,SACEA,SAAS,EACTC,gBAAgB,EAChBC,cAAc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AS,CAAC;YACnBwC,OAAO;YACPC,OAAO;QACT;QACAhD;QACAE;QACAX;QACAF;QACAnB;QACAZ;QACAc;QACAsB;QACApB;QACAL;QACA4B,cAAcU,SAAS,CAAC;YACtBoC,OAAO;gBAAC;gBAAW;aAAY;QACjC;QACA7F;KACD,CAAC;AAEF,eAAesD,aAAa"}
|
|
@@ -38,6 +38,7 @@ export { QuoteCaption } from "./BlockquoteFigure/QuoteCaption/QuoteCaption.js";
|
|
|
38
38
|
export { Link } from "./Link/Link.js";
|
|
39
39
|
export { ImageUpload } from "./ImageUpload/ImageUpload.js";
|
|
40
40
|
export { ImageBlock } from "./ImageBlock/ImageBlock.js";
|
|
41
|
+
export { VideoBlock } from "./VideoBlock/VideoBlock.js";
|
|
41
42
|
export { Columns, Column } from "./MultiColumn/index.js";
|
|
42
43
|
export { AICommand } from "./AICommand/AICommand.js";
|
|
43
44
|
export { Twitter, Linkedin, Tiktok, Facebook, Instagram, Youtube, } from "./SocialMedia/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/fields/TiptapEditor/extensions/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,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AAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,iDAAiD,CAAC;AAC/E,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,SAAS,EACT,OAAO,GACR,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC"}
|
|
@@ -39,6 +39,7 @@ export { QuoteCaption } from "./BlockquoteFigure/QuoteCaption/QuoteCaption.js";
|
|
|
39
39
|
export { Link } from "./Link/Link.js";
|
|
40
40
|
export { ImageUpload } from "./ImageUpload/ImageUpload.js";
|
|
41
41
|
export { ImageBlock } from "./ImageBlock/ImageBlock.js";
|
|
42
|
+
export { VideoBlock } from "./VideoBlock/VideoBlock.js";
|
|
42
43
|
export { Columns, Column } from "./MultiColumn/index.js";
|
|
43
44
|
export { AICommand } from "./AICommand/AICommand.js";
|
|
44
45
|
export { Twitter, Linkedin, Tiktok, Facebook, Instagram, Youtube } from "./SocialMedia/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/fields/TiptapEditor/extensions/index.ts"],"sourcesContent":["// TODO: File causes circular dependency issue in ESLint\n/* eslint-disable */\nexport { StarterKit } from \"@tiptap/starter-kit\";\nexport { Highlight } from \"@tiptap/extension-highlight\";\nexport { CharacterCount } from \"@tiptap/extension-character-count\";\nexport { Underline } from \"@tiptap/extension-underline\";\nexport { Placeholder } from \"@tiptap/extension-placeholder\";\nexport { Emoji, gitHubEmojis } from \"@tiptap-pro/extension-emoji\";\nexport { TextAlign } from \"@tiptap/extension-text-align\";\nexport { TextStyle } from \"@tiptap/extension-text-style\";\nexport { FontFamily } from \"@tiptap/extension-font-family\";\nexport { Typography } from \"@tiptap/extension-typography\";\nexport { Color } from \"@tiptap/extension-color\";\nexport { FocusClasses as Focus } from \"@tiptap/extension-focus\";\nexport { Dropcursor } from \"@tiptap/extension-dropcursor\";\nexport { CollaborationCursor } from \"@tiptap/extension-collaboration-cursor\";\nexport { Subscript } from \"@tiptap/extension-subscript\";\nexport { TableOfContents } from \"@tiptap-pro/extension-table-of-contents\";\nexport { Superscript } from \"@tiptap/extension-superscript\";\nexport { CodeBlock } from \"@tiptap/extension-code-block\";\nexport { BulletList } from \"@tiptap/extension-bullet-list\";\nexport { OrderedList } from \"@tiptap/extension-ordered-list\";\nexport { Collaboration } from \"@tiptap/extension-collaboration\";\nexport { TaskItem } from \"@tiptap/extension-task-item\";\nexport { TaskList } from \"@tiptap/extension-task-list\";\nexport { FileHandler } from \"@tiptap-pro/extension-file-handler\";\n\nexport { Selection } from \"./Selection/Selection.js\";\nexport { Table, TableCell, TableHeader, TableRow } from \"./Table/index.js\";\nexport { HorizontalRule } from \"./HorizontalRule/HorizontalRule.js\";\nexport { Heading } from \"./Heading/Heading.js\";\nexport { Document } from \"./Document/Document.js\";\nexport { TrailingNode } from \"./TrailingNode/trailing-node.js\";\nexport { SlashCommand } from \"./SlashCommand/SlashCommand.js\";\nexport { FontSize } from \"./FontSize/FontSize.js\";\nexport { Figure } from \"./Figure/Figure.js\";\nexport { Figcaption } from \"./Figcaption/Figcaption.js\";\nexport { BlockquoteFigure } from \"./BlockquoteFigure/BlockquoteFigure.js\";\nexport { Quote } from \"./BlockquoteFigure/Quote/Quote.js\";\nexport { QuoteCaption } from \"./BlockquoteFigure/QuoteCaption/QuoteCaption.js\";\nexport { Link } from \"./Link/Link.js\";\nexport { ImageUpload } from \"./ImageUpload/ImageUpload.js\";\nexport { ImageBlock } from \"./ImageBlock/ImageBlock.js\";\nexport { Columns, Column } from \"./MultiColumn/index.js\";\nexport { AICommand } from \"./AICommand/AICommand.js\";\nexport {\n Twitter,\n Linkedin,\n Tiktok,\n Facebook,\n Instagram,\n Youtube,\n} from \"./SocialMedia/index.js\";\nexport { Paragraph } from \"./Paragraph/Paragraph.js\";\nexport { InsideLinks } from \"./InsideLinks/insideLinks.js\";\n"],"names":["StarterKit","Highlight","CharacterCount","Underline","Placeholder","Emoji","gitHubEmojis","TextAlign","TextStyle","FontFamily","Typography","Color","FocusClasses","Focus","Dropcursor","CollaborationCursor","Subscript","TableOfContents","Superscript","CodeBlock","BulletList","OrderedList","Collaboration","TaskItem","TaskList","FileHandler","Selection","Table","TableCell","TableHeader","TableRow","HorizontalRule","Heading","Document","TrailingNode","SlashCommand","FontSize","Figure","Figcaption","BlockquoteFigure","Quote","QuoteCaption","Link","ImageUpload","ImageBlock","Columns","Column","AICommand","Twitter","Linkedin","Tiktok","Facebook","Instagram","Youtube","Paragraph","InsideLinks"],"mappings":"AAAA,wDAAwD;AACxD,kBAAkB,GAClB,SAASA,UAAU,QAAQ,sBAAsB;AACjD,SAASC,SAAS,QAAQ,8BAA8B;AACxD,SAASC,cAAc,QAAQ,oCAAoC;AACnE,SAASC,SAAS,QAAQ,8BAA8B;AACxD,SAASC,WAAW,QAAQ,gCAAgC;AAC5D,SAASC,KAAK,EAAEC,YAAY,QAAQ,8BAA8B;AAClE,SAASC,SAAS,QAAQ,+BAA+B;AAC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AAyB;AACzD,SAASC,SAAS,QAAQ,2BAA2B;AACrD,SACEC,OAAO,EACPC,QAAQ,EACRC,MAAM,EACNC,QAAQ,EACRC,SAAS,EACTC,OAAO,QACF,yBAAyB;AAChC,SAASC,SAAS,QAAQ,2BAA2B;AACrD,SAASC,WAAW,QAAQ,+BAA+B"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/fields/TiptapEditor/extensions/index.ts"],"sourcesContent":["// TODO: File causes circular dependency issue in ESLint\n/* eslint-disable */\nexport { StarterKit } from \"@tiptap/starter-kit\";\nexport { Highlight } from \"@tiptap/extension-highlight\";\nexport { CharacterCount } from \"@tiptap/extension-character-count\";\nexport { Underline } from \"@tiptap/extension-underline\";\nexport { Placeholder } from \"@tiptap/extension-placeholder\";\nexport { Emoji, gitHubEmojis } from \"@tiptap-pro/extension-emoji\";\nexport { TextAlign } from \"@tiptap/extension-text-align\";\nexport { TextStyle } from \"@tiptap/extension-text-style\";\nexport { FontFamily } from \"@tiptap/extension-font-family\";\nexport { Typography } from \"@tiptap/extension-typography\";\nexport { Color } from \"@tiptap/extension-color\";\nexport { FocusClasses as Focus } from \"@tiptap/extension-focus\";\nexport { Dropcursor } from \"@tiptap/extension-dropcursor\";\nexport { CollaborationCursor } from \"@tiptap/extension-collaboration-cursor\";\nexport { Subscript } from \"@tiptap/extension-subscript\";\nexport { TableOfContents } from \"@tiptap-pro/extension-table-of-contents\";\nexport { Superscript } from \"@tiptap/extension-superscript\";\nexport { CodeBlock } from \"@tiptap/extension-code-block\";\nexport { BulletList } from \"@tiptap/extension-bullet-list\";\nexport { OrderedList } from \"@tiptap/extension-ordered-list\";\nexport { Collaboration } from \"@tiptap/extension-collaboration\";\nexport { TaskItem } from \"@tiptap/extension-task-item\";\nexport { TaskList } from \"@tiptap/extension-task-list\";\nexport { FileHandler } from \"@tiptap-pro/extension-file-handler\";\n\nexport { Selection } from \"./Selection/Selection.js\";\nexport { Table, TableCell, TableHeader, TableRow } from \"./Table/index.js\";\nexport { HorizontalRule } from \"./HorizontalRule/HorizontalRule.js\";\nexport { Heading } from \"./Heading/Heading.js\";\nexport { Document } from \"./Document/Document.js\";\nexport { TrailingNode } from \"./TrailingNode/trailing-node.js\";\nexport { SlashCommand } from \"./SlashCommand/SlashCommand.js\";\nexport { FontSize } from \"./FontSize/FontSize.js\";\nexport { Figure } from \"./Figure/Figure.js\";\nexport { Figcaption } from \"./Figcaption/Figcaption.js\";\nexport { BlockquoteFigure } from \"./BlockquoteFigure/BlockquoteFigure.js\";\nexport { Quote } from \"./BlockquoteFigure/Quote/Quote.js\";\nexport { QuoteCaption } from \"./BlockquoteFigure/QuoteCaption/QuoteCaption.js\";\nexport { Link } from \"./Link/Link.js\";\nexport { ImageUpload } from \"./ImageUpload/ImageUpload.js\";\nexport { ImageBlock } from \"./ImageBlock/ImageBlock.js\";\nexport { VideoBlock } from \"./VideoBlock/VideoBlock.js\";\n\nexport { Columns, Column } from \"./MultiColumn/index.js\";\nexport { AICommand } from \"./AICommand/AICommand.js\";\nexport {\n Twitter,\n Linkedin,\n Tiktok,\n Facebook,\n Instagram,\n Youtube,\n} from \"./SocialMedia/index.js\";\nexport { Paragraph } from \"./Paragraph/Paragraph.js\";\nexport { InsideLinks } from \"./InsideLinks/insideLinks.js\";\n"],"names":["StarterKit","Highlight","CharacterCount","Underline","Placeholder","Emoji","gitHubEmojis","TextAlign","TextStyle","FontFamily","Typography","Color","FocusClasses","Focus","Dropcursor","CollaborationCursor","Subscript","TableOfContents","Superscript","CodeBlock","BulletList","OrderedList","Collaboration","TaskItem","TaskList","FileHandler","Selection","Table","TableCell","TableHeader","TableRow","HorizontalRule","Heading","Document","TrailingNode","SlashCommand","FontSize","Figure","Figcaption","BlockquoteFigure","Quote","QuoteCaption","Link","ImageUpload","ImageBlock","VideoBlock","Columns","Column","AICommand","Twitter","Linkedin","Tiktok","Facebook","Instagram","Youtube","Paragraph","InsideLinks"],"mappings":"AAAA,wDAAwD;AACxD,kBAAkB,GAClB,SAASA,U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,gBAAgB,QAAQ,yCAAyC;AAC1E,SAASC,KAAK,QAAQ,oCAAoC;AAC1D,SAASC,YAAY,QAAQ,kDAAkD;AAC/E,SAASC,IAAI,QAAQ,iBAAiB;AACtC,SAASC,WAAW,QAAQ,+BAA+B;AAC3D,SAASC,UAAU,QAAQ,6BAA6B;AACxD,SAASC,UAAU,QAAQ,6BAA6B;AAExD,SAASC,OAAO,EAAEC,MAAM,QAAQ,yBAAyB;AACzD,SAASC,SAAS,QAAQ,2BAA2B;AACrD,SACEC,OAAO,EACPC,QAAQ,EACRC,MAAM,EACNC,QAAQ,EACRC,SAAS,EACTC,OAAO,QACF,yBAAyB;AAChC,SAASC,SAAS,QAAQ,2BAA2B;AACrD,SAASC,WAAW,QAAQ,+BAA+B"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { openAssetHQType } from "../../types.js";
|
|
2
2
|
import { TiptapProps } from "./types.js";
|
|
3
|
-
export declare const BlockEditor: ({ handleChange, content, openAssetHQHandler, }: TiptapProps & {
|
|
3
|
+
export declare const BlockEditor: ({ handleChange, content, openAssetHQHandler, additionalContext, }: TiptapProps & {
|
|
4
4
|
openAssetHQHandler: openAssetHQType;
|
|
5
|
+
additionalContext?: Record<string, any>;
|
|
5
6
|
}) => import("react").JSX.Element;
|
|
6
7
|
export default BlockEditor;
|
|
7
8
|
//# sourceMappingURL=BlockEditor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlockEditor.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/features/BlockEditor/BlockEditor.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAKjD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"BlockEditor.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/features/BlockEditor/BlockEditor.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAKjD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,eAAO,MAAM,WAAW,sEAKrB,WAAW,GAAG;IACf,kBAAkB,EAAE,eAAe,CAAC;IACpC,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACzC,gCA2FA,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -16,13 +16,14 @@ import { Sidebar } from "../Sidebar/Sidebar.js";
|
|
|
16
16
|
import { ContentItemMenu } from "../menus/ContentItemMenu/ContentItemMenu.js";
|
|
17
17
|
import { TextMenu } from "../menus/TextMenu/TextMenu.js";
|
|
18
18
|
import { LinkMenu } from "../menus/index.js";
|
|
19
|
-
export const BlockEditor = ({ handleChange, content, openAssetHQHandler })=>{
|
|
19
|
+
export const BlockEditor = ({ handleChange, content, openAssetHQHandler, additionalContext })=>{
|
|
20
20
|
const menuContainerRef = useRef(null);
|
|
21
21
|
const editorRef = useRef(null);
|
|
22
22
|
const { editor, users, characterCount, leftSidebar } = useBlockEditor({
|
|
23
23
|
content: content,
|
|
24
24
|
handleChange: handleChange,
|
|
25
|
-
openAssetHQHandler: openAssetHQHandler
|
|
25
|
+
openAssetHQHandler: openAssetHQHandler,
|
|
26
|
+
additionalContext: additionalContext
|
|
26
27
|
});
|
|
27
28
|
const { code } = useLocale();
|
|
28
29
|
const displayedUsers = users.slice(0, 3);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/features/BlockEditor/BlockEditor.tsx"],"sourcesContent":["\"use client\";\nimport { EditorContent } from \"@tiptap/react\";\nimport { useEffect, useMemo, useRef } from \"react\";\n\nimport { useLocale } from \"@payloadcms/ui/providers/Locale\";\nimport { useTranslation } from \"@payloadcms/ui/providers/Translation\";\nimport { EditorContext } from \"../../context/EditorContext.js\";\nimport { IframeMenu } from \"../../extensions/Iframe/menus/index.js\";\nimport ImageBlockMenu from \"../../extensions/ImageBlock/components/ImageBlockMenu.js\";\nimport { InsideLinksMenu } from \"../../extensions/InsideLinks/menus/index.js\";\nimport { ColumnsMenu } from \"../../extensions/MultiColumn/menus/ColumnsMenu.js\";\nimport { SocialMediaMenu } from \"../../extensions/SocialMedia/menus/index.js\";\nimport {\n TableColumnMenu,\n TableRowMenu,\n} from \"../../extensions/Table/menus/index.js\";\nimport { useBlockEditor } from \"../../hooks/useBlockEditor.js\";\nimport { openAssetHQType } from \"../../types.js\";\nimport { Sidebar } from \"../Sidebar/Sidebar.js\";\nimport { ContentItemMenu } from \"../menus/ContentItemMenu/ContentItemMenu.js\";\nimport { TextMenu } from \"../menus/TextMenu/TextMenu.js\";\nimport { LinkMenu } from \"../menus/index.js\";\nimport { TiptapProps } from \"./types.js\";\nexport const BlockEditor = ({\n handleChange,\n content,\n openAssetHQHandler,\n}: TiptapProps & {\n openAssetHQHandler: openAssetHQType;\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 });\n\n const { code } = useLocale();\n\n const displayedUsers = users.slice(0, 3);\n\n const providerValue = useMemo(() => {\n return {};\n }, []);\n\n useEffect(() => {\n if (code === \"ar\" || code === \"fa\") {\n editor?.commands?.setTextDirection(\"rtl\");\n editor?.commands?.setContent(\"dwa\");\n }\n }, [code]);\n\n if (!editor) {\n return null;\n }\n const { i18n } = useTranslation();\n\n // Define the content for different languages\n const contentEn = \"للكتابة...\"; // Content for English or default language\n const contentAr = \"انقر هنا للكتابة...\"; // Content for Arabic language\n const contentFa = \"اینجا کلیک کنید تا شروع به نوشتن کنید...\";\n\n /*switch (i18n.language) {\n case 'ar':\n editor.commands.setContent(contentAr)\n break\n case 'fa':\n editor.commands.setContent(contentFa)\n break\n default:\n editor.commands.setContent(contentEn)\n }*/\n\n return (\n <EditorContext.Provider value={providerValue}>\n <div\n lang={i18n.language}\n className=\"flex h-full overflow-visible\"\n ref={menuContainerRef}\n >\n <Sidebar\n isOpen={leftSidebar.isOpen}\n onClose={leftSidebar.close}\n editor={editor}\n />\n <div className=\"relative flex flex-col flex-1 h-full justify-center items-center \">\n {/* <EditorHeader\n characters={characterCount.characters()}\n users={displayedUsers}\n words={characterCount.words()}\n isSidebarOpen={leftSidebar.isOpen}\n toggleSidebar={leftSidebar.toggle}\n /> */}\n <EditorContent\n editor={editor}\n ref={editorRef}\n lang={i18n.language}\n className=\"flex-1 overflow-y-visible w-full h-full outline-none outline-offset-0\"\n style={{\n outline: \"none\",\n }}\n />\n <ContentItemMenu editor={editor} />\n <LinkMenu editor={editor} appendTo={menuContainerRef} />\n\n <TextMenu editor={editor} />\n <IframeMenu editor={editor} appendTo={menuContainerRef} />\n <SocialMediaMenu editor={editor} appendTo={menuContainerRef} />\n <InsideLinksMenu editor={editor} appendTo={menuContainerRef} />\n <ColumnsMenu editor={editor} appendTo={menuContainerRef} />\n <TableRowMenu editor={editor} appendTo={menuContainerRef} />\n <TableColumnMenu editor={editor} appendTo={menuContainerRef} />\n <ImageBlockMenu editor={editor} appendTo={menuContainerRef} />\n </div>\n </div>\n </EditorContext.Provider>\n );\n};\n\nexport default BlockEditor;\n"],"names":["EditorContent","useEffect","useMemo","useRef","useLocale","useTranslation","EditorContext","IframeMenu","ImageBlockMenu","InsideLinksMenu","ColumnsMenu","SocialMediaMenu","TableColumnMenu","TableRowMenu","useBlockEditor","Sidebar","ContentItemMenu","TextMenu","LinkMenu","BlockEditor","handleChange","content","openAssetHQHandler","menuContainerRef","editorRef","editor","users","characterCount","leftSidebar","code","displayedUsers","slice","providerValue","commands","setTextDirection","setContent","i18n","contentEn","contentAr","contentFa","Provider","value","div","lang","language","className","ref","isOpen","onClose","close","style","outline","appendTo"],"mappings":"AAAA;;AACA,SAASA,aAAa,QAAQ,gBAAgB;AAC9C,SAASC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,QAAQ;AAEnD,SAASC,SAAS,QAAQ,kCAAkC;AAC5D,SAASC,cAAc,QAAQ,uCAAuC;AACtE,SAASC,aAAa,QAAQ,iCAAiC;AAC/D,SAASC,UAAU,QAAQ,yCAAyC;AACpE,OAAOC,oBAAoB,2DAA2D;AACtF,SAASC,eAAe,QAAQ,8CAA8C;AAC9E,SAASC,WAAW,QAAQ,oDAAoD;AAChF,SAASC,eAAe,QAAQ,8CAA8C;AAC9E,SACEC,eAAe,EACfC,YAAY,QACP,wCAAwC;AAC/C,SAASC,cAAc,QAAQ,gCAAgC;AAE/D,SAASC,OAAO,QAAQ,wBAAwB;AAChD,SAASC,eAAe,QAAQ,8CAA8C;AAC9E,SAASC,QAAQ,QAAQ,gCAAgC;AACzD,SAASC,QAAQ,QAAQ,oBAAoB;AAE7C,OAAO,MAAMC,cAAc,CAAC,EAC1BC,YAAY,EACZC,OAAO,EACPC,kBAAkB,
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/features/BlockEditor/BlockEditor.tsx"],"sourcesContent":["\"use client\";\nimport { EditorContent } from \"@tiptap/react\";\nimport { useEffect, useMemo, useRef } from \"react\";\n\nimport { useLocale } from \"@payloadcms/ui/providers/Locale\";\nimport { useTranslation } from \"@payloadcms/ui/providers/Translation\";\nimport { EditorContext } from \"../../context/EditorContext.js\";\nimport { IframeMenu } from \"../../extensions/Iframe/menus/index.js\";\nimport ImageBlockMenu from \"../../extensions/ImageBlock/components/ImageBlockMenu.js\";\nimport { InsideLinksMenu } from \"../../extensions/InsideLinks/menus/index.js\";\nimport { ColumnsMenu } from \"../../extensions/MultiColumn/menus/ColumnsMenu.js\";\nimport { SocialMediaMenu } from \"../../extensions/SocialMedia/menus/index.js\";\nimport {\n TableColumnMenu,\n TableRowMenu,\n} from \"../../extensions/Table/menus/index.js\";\nimport { useBlockEditor } from \"../../hooks/useBlockEditor.js\";\nimport { openAssetHQType } from \"../../types.js\";\nimport { Sidebar } from \"../Sidebar/Sidebar.js\";\nimport { ContentItemMenu } from \"../menus/ContentItemMenu/ContentItemMenu.js\";\nimport { TextMenu } from \"../menus/TextMenu/TextMenu.js\";\nimport { LinkMenu } from \"../menus/index.js\";\nimport { TiptapProps } from \"./types.js\";\nexport const BlockEditor = ({\n handleChange,\n content,\n openAssetHQHandler,\n additionalContext,\n}: TiptapProps & {\n openAssetHQHandler: openAssetHQType;\n additionalContext?: Record<string, any>;\n}) => {\n const menuContainerRef = useRef(null);\n const editorRef = useRef<HTMLDivElement>(null);\n\n const { editor, users, characterCount, leftSidebar } = useBlockEditor({\n content: content,\n handleChange: handleChange,\n openAssetHQHandler: openAssetHQHandler,\n additionalContext: additionalContext,\n });\n\n const { code } = useLocale();\n\n const displayedUsers = users.slice(0, 3);\n\n const providerValue = useMemo(() => {\n return {};\n }, []);\n\n useEffect(() => {\n if (code === \"ar\" || code === \"fa\") {\n editor?.commands?.setTextDirection(\"rtl\");\n editor?.commands?.setContent(\"dwa\");\n }\n }, [code]);\n\n if (!editor) {\n return null;\n }\n const { i18n } = useTranslation();\n\n // Define the content for different languages\n const contentEn = \"للكتابة...\"; // Content for English or default language\n const contentAr = \"انقر هنا للكتابة...\"; // Content for Arabic language\n const contentFa = \"اینجا کلیک کنید تا شروع به نوشتن کنید...\";\n\n /*switch (i18n.language) {\n case 'ar':\n editor.commands.setContent(contentAr)\n break\n case 'fa':\n editor.commands.setContent(contentFa)\n break\n default:\n editor.commands.setContent(contentEn)\n }*/\n\n return (\n <EditorContext.Provider value={providerValue}>\n <div\n lang={i18n.language}\n className=\"flex h-full overflow-visible\"\n ref={menuContainerRef}\n >\n <Sidebar\n isOpen={leftSidebar.isOpen}\n onClose={leftSidebar.close}\n editor={editor}\n />\n <div className=\"relative flex flex-col flex-1 h-full justify-center items-center \">\n {/* <EditorHeader\n characters={characterCount.characters()}\n users={displayedUsers}\n words={characterCount.words()}\n isSidebarOpen={leftSidebar.isOpen}\n toggleSidebar={leftSidebar.toggle}\n /> */}\n <EditorContent\n editor={editor}\n ref={editorRef}\n lang={i18n.language}\n className=\"flex-1 overflow-y-visible w-full h-full outline-none outline-offset-0\"\n style={{\n outline: \"none\",\n }}\n />\n <ContentItemMenu editor={editor} />\n <LinkMenu editor={editor} appendTo={menuContainerRef} />\n\n <TextMenu editor={editor} />\n <IframeMenu editor={editor} appendTo={menuContainerRef} />\n <SocialMediaMenu editor={editor} appendTo={menuContainerRef} />\n <InsideLinksMenu editor={editor} appendTo={menuContainerRef} />\n <ColumnsMenu editor={editor} appendTo={menuContainerRef} />\n <TableRowMenu editor={editor} appendTo={menuContainerRef} />\n <TableColumnMenu editor={editor} appendTo={menuContainerRef} />\n <ImageBlockMenu editor={editor} appendTo={menuContainerRef} />\n </div>\n </div>\n </EditorContext.Provider>\n );\n};\n\nexport default BlockEditor;\n"],"names":["EditorContent","useEffect","useMemo","useRef","useLocale","useTranslation","EditorContext","IframeMenu","ImageBlockMenu","InsideLinksMenu","ColumnsMenu","SocialMediaMenu","TableColumnMenu","TableRowMenu","useBlockEditor","Sidebar","ContentItemMenu","TextMenu","LinkMenu","BlockEditor","handleChange","content","openAssetHQHandler","additionalContext","menuContainerRef","editorRef","editor","users","characterCount","leftSidebar","code","displayedUsers","slice","providerValue","commands","setTextDirection","setContent","i18n","contentEn","contentAr","contentFa","Provider","value","div","lang","language","className","ref","isOpen","onClose","close","style","outline","appendTo"],"mappings":"AAAA;;AACA,SAASA,aAAa,QAAQ,gBAAgB;AAC9C,SAASC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,QAAQ;AAEnD,SAASC,SAAS,QAAQ,kCAAkC;AAC5D,SAASC,cAAc,QAAQ,uCAAuC;AACtE,SAASC,aAAa,QAAQ,iCAAiC;AAC/D,SAASC,UAAU,QAAQ,yCAAyC;AACpE,OAAOC,oBAAoB,2DAA2D;AACtF,SAASC,eAAe,QAAQ,8CAA8C;AAC9E,SAASC,WAAW,QAAQ,o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YAAYmB,MAAM;oBAC1BC,SAASpB,YAAYqB,KAAK;oBAC1BxB,QAAQA;;8BAEV,MAACiB;oBAAIG,WAAU;;sCAQb,KAAC9C;4BACC0B,QAAQA;4BACRqB,KAAKtB;4BACLmB,MAAMP,KAAKQ,QAAQ;4BACnBC,WAAU;4BACVK,OAAO;gCACLC,SAAS;4BACX;;sCAEF,KAACpC;4BAAgBU,QAAQA;;sCACzB,KAACR;4BAASQ,QAAQA;4BAAQ2B,UAAU7B;;sCAEpC,KAACP;4BAASS,QAAQA;;sCAClB,KAACnB;4BAAWmB,QAAQA;4BAAQ2B,UAAU7B;;sCACtC,KAACb;4BAAgBe,QAAQA;4BAAQ2B,UAAU7B;;sCAC3C,KAACf;4BAAgBiB,QAAQA;4BAAQ2B,UAAU7B;;sCAC3C,KAACd;4BAAYgB,QAAQA;4BAAQ2B,UAAU7B;;sCACvC,KAACX;4BAAaa,QAAQA;4BAAQ2B,UAAU7B;;sCACxC,KAACZ;4BAAgBc,QAAQA;4BAAQ2B,UAAU7B;;sCAC3C,KAAChB;4BAAekB,QAAQA;4BAAQ2B,UAAU7B;;;;;;;AAKpD,EAAE;AAEF,eAAeL,YAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AICommandPanel.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.tsx"],"names":[],"mappings":"AAIA,OAAO,KAON,MAAM,OAAO,CAAC;AAKf,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAEL,KAAK,EACN,MAAM,uDAAuD,CAAC;AAW/D,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,KAAK,EAAE,KAAK,EAAE,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"AICommandPanel.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.tsx"],"names":[],"mappings":"AAIA,OAAO,KAON,MAAM,OAAO,CAAC;AAKf,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAEL,KAAK,EACN,MAAM,uDAAuD,CAAC;AAW/D,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,KAAK,EAAE,KAAK,EAAE,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,cAAc,qFA6U1B,CAAC"}
|
|
@@ -69,8 +69,8 @@ export const AICommandPanel = /*#__PURE__*/ forwardRef(({ editor, onOpenChange,
|
|
|
69
69
|
complete(text, {
|
|
70
70
|
body: {
|
|
71
71
|
option: "zap",
|
|
72
|
-
command: inputValue,
|
|
73
|
-
language: code ?? "en"
|
|
72
|
+
command: (editor.storage.aiCommand.title ? editor.storage.aiCommand.title + "," : "") + inputValue,
|
|
73
|
+
language: editor.storage.aiCommand.language ?? code ?? "en"
|
|
74
74
|
}
|
|
75
75
|
}).then(()=>setInputValue(""));
|
|
76
76
|
}, [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.tsx"],"sourcesContent":["\"use client\";\n\nimport { useCompletion } from \"ai/react\";\nimport { ArrowUpCircle, Sparkles } from \"lucide-react\";\nimport React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from \"react\";\nimport Markdown from \"react-markdown\";\nimport TextareaAutosize from \"react-textarea-autosize\";\n\nimport { useLocale } from \"@payloadcms/ui/providers/Locale\";\nimport { Editor } from \"@tiptap/react\";\n\nimport {\n Command,\n Group,\n} from \"src/fields/TiptapEditor/extensions/AICommand/types.js\";\nimport { getPrevText } from \"../../../lib/utils/index.js\";\nimport { isRTL } from \"../../../lib/utils/isRtl.js\";\nimport CrazySpinner from \"../../ui/crazy-spinner.js\";\nimport { DropdownButton } from \"../../ui/Dropdown/Dropdown.js\";\nimport { Icon } from \"../../ui/Icon.js\";\nimport { ScrollArea } from \"../../ui/scroll-area.js\";\nimport { Surface } from \"../../ui/Surface.js\";\nimport { Toolbar } from \"../../ui/Toolbar.js\";\nimport AISelectorCommands from \"../../menus/TextMenu/components/ai-selector-commands.js\";\n\nexport type AICommandPanelProps = {\n editor: Editor;\n userPrompt?: string;\n onOpenChange: (value: boolean) => void;\n items: Group[];\n};\n\nexport const AICommandPanel = forwardRef(\n (\n {\n editor,\n onOpenChange,\n userPrompt,\n items,\n ...restProps\n }: AICommandPanelProps,\n ref\n ) => {\n const [inputValue, setInputValue] = useState(userPrompt ?? \"\");\n const { code } = useLocale();\n const { view } = editor;\n const scrollContainer = useRef<HTMLDivElement>(null);\n const activeItem = useRef<HTMLButtonElement>(null);\n const [selectedGroupIndex, setSelectedGroupIndex] = useState(0);\n const [selectedCommandIndex, setSelectedCommandIndex] = useState(0);\n\n const editorNode = view.dom as HTMLElement;\n const boundigClient = editorNode.getBoundingClientRect();\n const inputRef = useRef<HTMLTextAreaElement>(null);\n\n // const { status, messages, input, submitMessage, handleInputChange } = useAssistant({\n // // id: \"novel\",\n // api: \"/api/assistant\",\n // onResponse: (response) => {\n // if (response.status === 429) {\n // toast.error(\"You have reached your request limit for the day.\");\n // return;\n // }\n // },\n // onError: (e) => {\n // toast.error(e.message);\n // },\n // });\n\n const { completion, complete, isLoading } = useCompletion({\n // id: \"novel\",\n api: \"/api/generate\",\n onResponse: (response) => {\n if (response.status === 429) {\n console.log(\"You have reached your request limit for the day.\");\n\n return;\n }\n },\n\n onError: (e) => {\n console.log(\"ERROR\", e.message);\n },\n });\n\n const hasCompletion = completion.length > 0;\n const handleClick = useCallback(() => {\n if (completion) {\n return complete(completion, {\n body: { option: \"zap\", command: inputValue, language: code ?? \"en\" },\n }).then(() => setInputValue(\"\"));\n }\n const text = getPrevText(editor, { chars: 5000 });\n\n complete(text, {\n body: { option: \"zap\", command: inputValue, language: code ?? \"en\" },\n }).then(() => setInputValue(\"\"));\n }, [code, inputValue]);\n\n useEffect(() => {\n if (userPrompt) setInputValue(userPrompt);\n }, [userPrompt]);\n useEffect(() => {\n editor.storage.aiCommand.completion = completion;\n // if (!isLoading && completion) {\n // const selection = editor.state.selection;\n // editor\n // .chain()\n // .focus()\n // .insertContentAt(selection.to - 1, completion)\n // .insertContentAt(selection.to, \" \")\n // .run();\n\n // }\n }, [completion, isLoading]);\n\n // Anytime the groups change, i.e. the user types to narrow it down, we want to\n // reset the current selection to the first menu item\n useEffect(() => {\n setSelectedGroupIndex(0);\n setSelectedCommandIndex(0);\n }, [items]);\n\n const selectItem = useCallback(\n (groupIndex: number, commandIndex: number) => {\n const command = items[groupIndex].commands[commandIndex];\n\n setInputValue(command.action(editor));\n // props.command(command);\n },\n [items, editor]\n );\n\n useImperativeHandle(ref, () => ({\n onKeyDown: ({ event }: { event: React.KeyboardEvent }) => {\n if (event.key === \"ArrowDown\") {\n if (!items.length) {\n return false;\n }\n\n const commands = items[selectedGroupIndex].commands;\n\n let newCommandIndex = selectedCommandIndex + 1;\n let newGroupIndex = selectedGroupIndex;\n\n if (commands.length - 1 < newCommandIndex) {\n newCommandIndex = 0;\n newGroupIndex = selectedGroupIndex + 1;\n }\n\n if (items.length - 1 < newGroupIndex) {\n newGroupIndex = 0;\n }\n\n setSelectedCommandIndex(newCommandIndex);\n setSelectedGroupIndex(newGroupIndex);\n\n return true;\n }\n\n if (event.key === \"ArrowUp\") {\n if (!items.length) {\n return false;\n }\n\n let newCommandIndex = selectedCommandIndex - 1;\n let newGroupIndex = selectedGroupIndex;\n\n if (newCommandIndex < 0) {\n newGroupIndex = selectedGroupIndex - 1;\n newCommandIndex = items[newGroupIndex]?.commands.length - 1 || 0;\n }\n\n if (newGroupIndex < 0) {\n newGroupIndex = items.length - 1;\n newCommandIndex = items[newGroupIndex].commands.length - 1;\n }\n\n setSelectedCommandIndex(newCommandIndex);\n setSelectedGroupIndex(newGroupIndex);\n\n return true;\n }\n\n if (event.key === \"Enter\") {\n if (\n !items.length ||\n selectedGroupIndex === -1 ||\n selectedCommandIndex === -1\n ) {\n return false;\n }\n\n selectItem(selectedGroupIndex, selectedCommandIndex);\n\n return true;\n }\n\n return false;\n },\n }));\n\n useEffect(() => {\n if (activeItem.current && scrollContainer.current) {\n const offsetTop = activeItem.current.offsetTop;\n const offsetHeight = activeItem.current.offsetHeight;\n\n scrollContainer.current.scrollTop = offsetTop - offsetHeight;\n }\n }, [selectedCommandIndex, selectedGroupIndex]);\n\n const createCommandClickHandler = useCallback(\n (groupIndex: number, commandIndex: number) => {\n return () => {\n selectItem(groupIndex, commandIndex);\n };\n },\n [selectItem]\n );\n\n return (\n <>\n <Surface\n className={`p-2 min-w-[20rem] flex flex-col gap-2 w-full`}\n style={{\n width: boundigClient?.width,\n }}\n >\n <>\n {hasCompletion && (\n <div className=\"flex w-full\">\n <ScrollArea\n className=\"h-72 prose p-2 px-4 prose-sm w-full max-w-none\"\n dir={isRTL(completion) ? \"rtl\" : \"ltr\"}\n >\n <Markdown className=\"w-full\">{completion}</Markdown>\n </ScrollArea>\n </div>\n )}\n\n {isLoading && (\n <div\n className=\"flex h-12 w-full items-center px-4 text-sm font-medium text-muted-foreground text-blue-500\"\n style={{\n width: boundigClient?.width,\n }}\n >\n <Sparkles className=\"mr-2 h-4 w-4 shrink-0 \" />\n AI is thinking\n <div className=\"ml-2 mt-1\">\n <CrazySpinner />\n </div>\n </div>\n )}\n\n {!isLoading && (\n <>\n <div className=\"flex justify-between items-center \">\n {/* <CommandInput\n value={inputValue}\n onValueChange={setInputValue}\n autoFocus\n placeholder={\n hasCompletion ? 'Tell AI what to do next' : 'Ask AI to edit or generate...'\n }\n // onFocus={() => addAIHighlight(editor)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') handleClick()\n }}\n /> */}\n <Sparkles className=\"mr-2 h-4 w-4 shrink-0 text-blue-500 \" />\n <TextareaAutosize\n ref={inputRef}\n style={{ resize: \"none\" }}\n className=\"w-full p-2 text-black bg-white rounded dark:bg-black dark:text-white focus:outline-none outline-none border-0 \"\n value={inputValue}\n onChange={(e) => {\n editor.storage.aiCommand.userPrompt = e.target.value;\n\n setInputValue(e.target.value);\n }}\n placeholder={\n hasCompletion\n ? \"Tell AI what to do next\"\n : \"Ask AI to edit or generate...\"\n }\n autoFocus\n // onFocus={() => {\n // addAIHighlight(editor)}}\n\n onKeyDown={(e) => {\n if (e.key === \"Enter\") handleClick();\n }}\n />\n <Toolbar.Button\n // size=\"icon\"\n\n // className=\"absolute right-2 top-1/2 h-6 w-6 -translate-y-1/2 rounded-full bg-zinc-100 hover:bg-zinc-150\"\n onClick={handleClick}\n >\n <ArrowUpCircle />\n </Toolbar.Button>\n </div>\n </>\n )}\n </>\n </Surface>\n {!isLoading && (\n <Surface\n ref={scrollContainer}\n className=\"text-black max-h-[min(80vh,24rem)] overflow-auto flex-wrap mb-8 p-2\"\n >\n <div className=\"grid grid-cols-1 gap-0.5\">\n {hasCompletion ? (\n <AISelectorCommands\n editor={editor}\n messages={completion}\n onSelect={(value, options) => {\n console.log(\"VALUE\", value, options);\n complete(value, { body: options });\n }}\n />\n ) : (\n items.map((group, groupIndex: number) => (\n <React.Fragment key={`${group.title}-wrapper`}>\n <div\n className=\"text-neutral-500 text-[0.65rem] col-[1/-1] mx-2 mt-4 font-semibold tracking-wider select-none uppercase first:mt-0.5\"\n key={`${group.title}`}\n >\n {group.title}\n </div>\n {group.commands.map(\n (command: Command, commandIndex: number) => (\n <DropdownButton\n key={`${command.label}`}\n isActive={\n selectedGroupIndex === groupIndex &&\n selectedCommandIndex === commandIndex\n }\n onClick={createCommandClickHandler(\n groupIndex,\n commandIndex\n )}\n >\n <Icon icon={command.icon} className=\"mr-1\" />\n {command.label}\n </DropdownButton>\n )\n )}\n </React.Fragment>\n ))\n )}\n </div>\n </Surface>\n )}\n </>\n );\n }\n);\n"],"names":["useCompletion","ArrowUpCircle","Sparkles","React","forwardRef","useCallback","useEffect","useImperativeHandle","useRef","useState","Markdown","TextareaAutosize","useLocale","getPrevText","isRTL","CrazySpinner","DropdownButton","Icon","ScrollArea","Surface","Toolbar","AISelectorCommands","AICommandPanel","editor","onOpenChange","userPrompt","items","restProps","ref","inputValue","setInputValue","code","view","scrollContainer","activeItem","selectedGroupIndex","setSelectedGroupIndex","selectedCommandIndex","setSelectedCommandIndex","editorNode","dom","boundigClient","getBoundingClientRect","inputRef","completion","complete","isLoading","api","onResponse","response","status","console","log","onError","e","message","hasCompletion","length","handleClick","body","option","command","language","then","text","chars","storage","aiCommand","selectItem","groupIndex","commandIndex","commands","action","onKeyDown","event","key","newCommandIndex","newGroupIndex","current","offsetTop","offsetHeight","scrollTop","createCommandClickHandler","className","style","width","div","dir","resize","value","onChange","target","placeholder","autoFocus","Button","onClick","messages","onSelect","options","map","group","Fragment","title","isActive","icon","label"],"mappings":"AAAA;;AAEA,SAASA,aAAa,QAAQ,WAAW;AACzC,SAASC,aAAa,EAAEC,QAAQ,QAAQ,eAAe;AACvD,OAAOC,SACLC,UAAU,EACVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,MAAM,EACNC,QAAQ,QACH,QAAQ;AACf,OAAOC,cAAc,iBAAiB;AACtC,OAAOC,sBAAsB,0BAA0B;AAEvD,SAASC,SAAS,QAAQ,kCAAkC;AAO5D,SAASC,WAAW,QAAQ,8BAA8B;AAC1D,SAASC,KAAK,QAAQ,8BAA8B;AACpD,OAAOC,kBAAkB,4BAA4B;AACrD,SAASC,cAAc,QAAQ,gCAAgC;AAC/D,SAASC,IAAI,QAAQ,mBAAmB;AACxC,SAASC,UAAU,QAAQ,0BAA0B;AACrD,SAASC,OAAO,QAA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AUpD;wBACVqD,UAAU,CAACR,OAAOS;4BAChB/C,QAAQC,GAAG,CAAC,SAASqC,OAAOS;4BAC5BrD,SAAS4C,OAAO;gCAAE9B,MAAMuC;4BAAQ;wBAClC;yBAGFxE,MAAMyE,GAAG,CAAC,CAACC,OAAO/B,2BAChB,MAAClE,MAAMkG,QAAQ;;8CACb,KAACf;oCACCH,WAAU;8CAGTiB,MAAME,KAAK;mCAFP,CAAC,EAAEF,MAAME,KAAK,CAAC,CAAC;gCAItBF,MAAM7B,QAAQ,CAAC4B,GAAG,CACjB,CAACtC,SAAkBS,6BACjB,MAACtD;wCAECuF,UACEpE,uBAAuBkC,cACvBhC,yBAAyBiC;wCAE3ByB,SAASb,0BACPb,YACAC;;0DAGF,KAACrD;gDAAKuF,MAAM3C,QAAQ2C,IAAI;gDAAErB,WAAU;;4CACnCtB,QAAQ4C,KAAK;;uCAXT,CAAC,EAAE5C,QAAQ4C,KAAK,CAAC,CAAC;;2BAVV,CAAC,EAAEL,MAAME,KAAK,CAAC,QAAQ,CAAC;;;;;AAiC7D,GACA"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.tsx"],"sourcesContent":["\"use client\";\n\nimport { useCompletion } from \"ai/react\";\nimport { ArrowUpCircle, Sparkles } from \"lucide-react\";\nimport React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from \"react\";\nimport Markdown from \"react-markdown\";\nimport TextareaAutosize from \"react-textarea-autosize\";\n\nimport { useLocale } from \"@payloadcms/ui/providers/Locale\";\nimport { Editor } from \"@tiptap/react\";\n\nimport {\n Command,\n Group,\n} from \"src/fields/TiptapEditor/extensions/AICommand/types.js\";\nimport { getPrevText } from \"../../../lib/utils/index.js\";\nimport { isRTL } from \"../../../lib/utils/isRtl.js\";\nimport CrazySpinner from \"../../ui/crazy-spinner.js\";\nimport { DropdownButton } from \"../../ui/Dropdown/Dropdown.js\";\nimport { Icon } from \"../../ui/Icon.js\";\nimport { ScrollArea } from \"../../ui/scroll-area.js\";\nimport { Surface } from \"../../ui/Surface.js\";\nimport { Toolbar } from \"../../ui/Toolbar.js\";\nimport AISelectorCommands from \"../../menus/TextMenu/components/ai-selector-commands.js\";\n\nexport type AICommandPanelProps = {\n editor: Editor;\n userPrompt?: string;\n onOpenChange: (value: boolean) => void;\n items: Group[];\n};\n\nexport const AICommandPanel = forwardRef(\n (\n {\n editor,\n onOpenChange,\n userPrompt,\n items,\n ...restProps\n }: AICommandPanelProps,\n ref\n ) => {\n const [inputValue, setInputValue] = useState(userPrompt ?? \"\");\n const { code } = useLocale();\n const { view } = editor;\n const scrollContainer = useRef<HTMLDivElement>(null);\n const activeItem = useRef<HTMLButtonElement>(null);\n const [selectedGroupIndex, setSelectedGroupIndex] = useState(0);\n const [selectedCommandIndex, setSelectedCommandIndex] = useState(0);\n\n const editorNode = view.dom as HTMLElement;\n const boundigClient = editorNode.getBoundingClientRect();\n const inputRef = useRef<HTMLTextAreaElement>(null);\n\n // const { status, messages, input, submitMessage, handleInputChange } = useAssistant({\n // // id: \"novel\",\n // api: \"/api/assistant\",\n // onResponse: (response) => {\n // if (response.status === 429) {\n // toast.error(\"You have reached your request limit for the day.\");\n // return;\n // }\n // },\n // onError: (e) => {\n // toast.error(e.message);\n // },\n // });\n\n const { completion, complete, isLoading } = useCompletion({\n // id: \"novel\",\n api: \"/api/generate\",\n onResponse: (response) => {\n if (response.status === 429) {\n console.log(\"You have reached your request limit for the day.\");\n\n return;\n }\n },\n\n onError: (e) => {\n console.log(\"ERROR\", e.message);\n },\n });\n\n const hasCompletion = completion.length > 0;\n const handleClick = useCallback(() => {\n if (completion) {\n return complete(completion, {\n body: { option: \"zap\", command: inputValue, language: code ?? \"en\" },\n }).then(() => setInputValue(\"\"));\n }\n const text = getPrevText(editor, { chars: 5000 });\n\n complete(text, {\n body: {\n option: \"zap\",\n command:\n (editor.storage.aiCommand.title\n ? editor.storage.aiCommand.title + \",\"\n : \"\") + inputValue,\n language: editor.storage.aiCommand.language ?? code ?? \"en\",\n },\n }).then(() => setInputValue(\"\"));\n }, [code, inputValue]);\n\n useEffect(() => {\n if (userPrompt) setInputValue(userPrompt);\n }, [userPrompt]);\n useEffect(() => {\n editor.storage.aiCommand.completion = completion;\n // if (!isLoading && completion) {\n // const selection = editor.state.selection;\n // editor\n // .chain()\n // .focus()\n // .insertContentAt(selection.to - 1, completion)\n // .insertContentAt(selection.to, \" \")\n // .run();\n\n // }\n }, [completion, isLoading]);\n\n // Anytime the groups change, i.e. the user types to narrow it down, we want to\n // reset the current selection to the first menu item\n useEffect(() => {\n setSelectedGroupIndex(0);\n setSelectedCommandIndex(0);\n }, [items]);\n\n const selectItem = useCallback(\n (groupIndex: number, commandIndex: number) => {\n const command = items[groupIndex].commands[commandIndex];\n\n setInputValue(command.action(editor));\n // props.command(command);\n },\n [items, editor]\n );\n\n useImperativeHandle(ref, () => ({\n onKeyDown: ({ event }: { event: React.KeyboardEvent }) => {\n if (event.key === \"ArrowDown\") {\n if (!items.length) {\n return false;\n }\n\n const commands = items[selectedGroupIndex].commands;\n\n let newCommandIndex = selectedCommandIndex + 1;\n let newGroupIndex = selectedGroupIndex;\n\n if (commands.length - 1 < newCommandIndex) {\n newCommandIndex = 0;\n newGroupIndex = selectedGroupIndex + 1;\n }\n\n if (items.length - 1 < newGroupIndex) {\n newGroupIndex = 0;\n }\n\n setSelectedCommandIndex(newCommandIndex);\n setSelectedGroupIndex(newGroupIndex);\n\n return true;\n }\n\n if (event.key === \"ArrowUp\") {\n if (!items.length) {\n return false;\n }\n\n let newCommandIndex = selectedCommandIndex - 1;\n let newGroupIndex = selectedGroupIndex;\n\n if (newCommandIndex < 0) {\n newGroupIndex = selectedGroupIndex - 1;\n newCommandIndex = items[newGroupIndex]?.commands.length - 1 || 0;\n }\n\n if (newGroupIndex < 0) {\n newGroupIndex = items.length - 1;\n newCommandIndex = items[newGroupIndex].commands.length - 1;\n }\n\n setSelectedCommandIndex(newCommandIndex);\n setSelectedGroupIndex(newGroupIndex);\n\n return true;\n }\n\n if (event.key === \"Enter\") {\n if (\n !items.length ||\n selectedGroupIndex === -1 ||\n selectedCommandIndex === -1\n ) {\n return false;\n }\n\n selectItem(selectedGroupIndex, selectedCommandIndex);\n\n return true;\n }\n\n return false;\n },\n }));\n\n useEffect(() => {\n if (activeItem.current && scrollContainer.current) {\n const offsetTop = activeItem.current.offsetTop;\n const offsetHeight = activeItem.current.offsetHeight;\n\n scrollContainer.current.scrollTop = offsetTop - offsetHeight;\n }\n }, [selectedCommandIndex, selectedGroupIndex]);\n\n const createCommandClickHandler = useCallback(\n (groupIndex: number, commandIndex: number) => {\n return () => {\n selectItem(groupIndex, commandIndex);\n };\n },\n [selectItem]\n );\n\n return (\n <>\n <Surface\n className={`p-2 min-w-[20rem] flex flex-col gap-2 w-full`}\n style={{\n width: boundigClient?.width,\n }}\n >\n <>\n {hasCompletion && (\n <div className=\"flex w-full\">\n <ScrollArea\n className=\"h-72 prose p-2 px-4 prose-sm w-full max-w-none\"\n dir={isRTL(completion) ? \"rtl\" : \"ltr\"}\n >\n <Markdown className=\"w-full\">{completion}</Markdown>\n </ScrollArea>\n </div>\n )}\n\n {isLoading && (\n <div\n className=\"flex h-12 w-full items-center px-4 text-sm font-medium text-muted-foreground text-blue-500\"\n style={{\n width: boundigClient?.width,\n }}\n >\n <Sparkles className=\"mr-2 h-4 w-4 shrink-0 \" />\n AI is thinking\n <div className=\"ml-2 mt-1\">\n <CrazySpinner />\n </div>\n </div>\n )}\n\n {!isLoading && (\n <>\n <div className=\"flex justify-between items-center \">\n {/* <CommandInput\n value={inputValue}\n onValueChange={setInputValue}\n autoFocus\n placeholder={\n hasCompletion ? 'Tell AI what to do next' : 'Ask AI to edit or generate...'\n }\n // onFocus={() => addAIHighlight(editor)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') handleClick()\n }}\n /> */}\n <Sparkles className=\"mr-2 h-4 w-4 shrink-0 text-blue-500 \" />\n <TextareaAutosize\n ref={inputRef}\n style={{ resize: \"none\" }}\n className=\"w-full p-2 text-black bg-white rounded dark:bg-black dark:text-white focus:outline-none outline-none border-0 \"\n value={inputValue}\n onChange={(e) => {\n editor.storage.aiCommand.userPrompt = e.target.value;\n\n setInputValue(e.target.value);\n }}\n placeholder={\n hasCompletion\n ? \"Tell AI what to do next\"\n : \"Ask AI to edit or generate...\"\n }\n autoFocus\n // onFocus={() => {\n // addAIHighlight(editor)}}\n\n onKeyDown={(e) => {\n if (e.key === \"Enter\") handleClick();\n }}\n />\n <Toolbar.Button\n // size=\"icon\"\n\n // className=\"absolute right-2 top-1/2 h-6 w-6 -translate-y-1/2 rounded-full bg-zinc-100 hover:bg-zinc-150\"\n onClick={handleClick}\n >\n <ArrowUpCircle />\n </Toolbar.Button>\n </div>\n </>\n )}\n </>\n </Surface>\n {!isLoading && (\n <Surface\n ref={scrollContainer}\n className=\"text-black max-h-[min(80vh,24rem)] overflow-auto flex-wrap mb-8 p-2\"\n >\n <div className=\"grid grid-cols-1 gap-0.5\">\n {hasCompletion ? (\n <AISelectorCommands\n editor={editor}\n messages={completion}\n onSelect={(value, options) => {\n console.log(\"VALUE\", value, options);\n complete(value, { body: options });\n }}\n />\n ) : (\n items.map((group, groupIndex: number) => (\n <React.Fragment key={`${group.title}-wrapper`}>\n <div\n className=\"text-neutral-500 text-[0.65rem] col-[1/-1] mx-2 mt-4 font-semibold tracking-wider select-none uppercase first:mt-0.5\"\n key={`${group.title}`}\n >\n {group.title}\n </div>\n {group.commands.map(\n (command: Command, commandIndex: number) => (\n <DropdownButton\n key={`${command.label}`}\n isActive={\n selectedGroupIndex === groupIndex &&\n selectedCommandIndex === commandIndex\n }\n onClick={createCommandClickHandler(\n groupIndex,\n commandIndex\n )}\n >\n <Icon icon={command.icon} className=\"mr-1\" />\n {command.label}\n </DropdownButton>\n )\n )}\n </React.Fragment>\n ))\n )}\n </div>\n </Surface>\n )}\n </>\n );\n }\n);\n"],"names":["useCompletion","ArrowUpCircle","Sparkles","React","forwardRef","useCallback","useEffect","useImperativeHandle","useRef","useState","Markdown","TextareaAutosize","useLocale","getPrevText","isRTL","CrazySpinner","DropdownButton","Icon","ScrollArea","Surface","Toolbar","AISelectorCommands","AICommandPanel","editor","onOpenChange","userPrompt","items","restProps","ref","inputValue","setInputValue","code","view","scrollContainer","activeItem","selectedGroupIndex","setSelectedGroupIndex","selectedCommandIndex","setSelectedCommandIndex","editorNode","dom","boundigClient","getBoundingClientRect","inputRef","completion","complete","isLoading","api","onResponse","response","status","console","log","onError","e","message","hasCompletion","length","handleClick","body","option","command","language","then","text","chars","storage","aiCommand","title","selectItem","groupIndex","commandIndex","commands","action","onKeyDown","event","key","newCommandIndex","newGroupIndex","current","offsetTop","offsetHeight","scrollTop","createCommandClickHandler","className","style","width","div","dir","resize","value","onChange","target","placeholder","autoFocus","Button","onClick","messages","onSelect","options","map","group","Fragment","isActive","icon","label"],"mappings":"AAAA;;AAEA,SAASA,aAAa,QAAQ,WAAW;AACzC,SAASC,aAAa,EAAEC,QAAQ,QAAQ,eAAe;AACvD,OAAOC,SACLC,UAAU,EACVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,MAAM,EACNC,QAAQ,QACH,QAAQ;AACf,OAAOC,cAAc,iBAAiB;AACtC,OAAOC,sBAAsB,0BAA0B;AAEvD,SAASC,SAAS,QAAQ,kCAAkC;AAO5D,SAASC,WAAW,QAAQ,8BAA8B;AAC1D,SAASC,KAAK,QAAQ,8BAA8B;AACpD,OAAOC,kBAAkB,4BAA4B;AACrD,SAASC,cAAc,QAAQ,gCAAgC;AAC/D,SAASC,IAAI,QAAQ,mBAAmB;AACxC,SAASC,UAAU,QAAQ,0BAA0B;AACrD,SAASC,OAAO,QAAQ,sBAAsB;AAC9C,SAASC,OAAO,QAAQ,sBAAsB;AAC9C,OAAOC,wBAAwB,0DAA0D;AASzF,OAAO,MAAMC,+BAAiBlB,WAC5B,CACE,EACEmB,MAAM,EACNC,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KAACnC;wBACCE,QAAQA;wBACR0E,UAAUrD;wBACVsD,UAAU,CAACR,OAAOS;4BAChBhD,QAAQC,GAAG,CAAC,SAASsC,OAAOS;4BAC5BtD,SAAS6C,OAAO;gCAAE/B,MAAMwC;4BAAQ;wBAClC;yBAGFzE,MAAM0E,GAAG,CAAC,CAACC,OAAO/B,2BAChB,MAACnE,MAAMmG,QAAQ;;8CACb,KAACf;oCACCH,WAAU;8CAGTiB,MAAMjC,KAAK;mCAFP,CAAC,EAAEiC,MAAMjC,KAAK,CAAC,CAAC;gCAItBiC,MAAM7B,QAAQ,CAAC4B,GAAG,CACjB,CAACvC,SAAkBU,6BACjB,MAACvD;wCAECuF,UACEpE,uBAAuBmC,cACvBjC,yBAAyBkC;wCAE3ByB,SAASb,0BACPb,YACAC;;0DAGF,KAACtD;gDAAKuF,MAAM3C,QAAQ2C,IAAI;gDAAEpB,WAAU;;4CACnCvB,QAAQ4C,KAAK;;uCAXT,CAAC,EAAE5C,QAAQ4C,KAAK,CAAC,CAAC;;2BAVV,CAAC,EAAEJ,MAAMjC,KAAK,CAAC,QAAQ,CAAC;;;;;AAiC7D,GACA"}
|
|
@@ -5,13 +5,14 @@ declare global {
|
|
|
5
5
|
editor: Editor | null;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
-
export declare const useBlockEditor: ({ content, handleChange, openAssetHQHandler, }: {
|
|
8
|
+
export declare const useBlockEditor: ({ content, handleChange, openAssetHQHandler, additionalContext, }: {
|
|
9
9
|
content: {
|
|
10
10
|
html: string;
|
|
11
11
|
json: any;
|
|
12
12
|
};
|
|
13
13
|
handleChange: (data: any) => void;
|
|
14
14
|
openAssetHQHandler: openAssetHQType;
|
|
15
|
+
additionalContext?: Record<string, any>;
|
|
15
16
|
}) => {
|
|
16
17
|
editor: Editor;
|
|
17
18
|
users: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBlockEditor.d.ts","sourceRoot":"","sources":["../../../../../src/fields/TiptapEditor/hooks/useBlockEditor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAa,MAAM,eAAe,CAAC;AASlD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;KACvB;CACF;AAED,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"useBlockEditor.d.ts","sourceRoot":"","sources":["../../../../../src/fields/TiptapEditor/hooks/useBlockEditor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAa,MAAM,eAAe,CAAC;AASlD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;KACvB;CACF;AAED,eAAO,MAAM,cAAc,sEAKxB;IACD,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,GAAG,CAAA;KAAE,CAAC;IACrC,YAAY,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IAClC,kBAAkB,EAAE,eAAe,CAAC;IACpC,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACzC;;;;;CA2FA,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useMemo } from "react";
|
|
2
|
+
import { useEffect, useMemo } from "react";
|
|
3
3
|
import { useEditor } from "@tiptap/react";
|
|
4
4
|
import ExtensionKit from "../extensions/extension-kit.js";
|
|
5
5
|
import { useSidebar } from "./useSidebar.js";
|
|
6
6
|
import { useTranslation } from "@payloadcms/ui/providers/Translation";
|
|
7
7
|
import TurndownService from "turndown";
|
|
8
8
|
import { gfm } from "turndown-plugin-gfm";
|
|
9
|
-
export const useBlockEditor = ({ content, handleChange, openAssetHQHandler })=>{
|
|
9
|
+
export const useBlockEditor = ({ content, handleChange, openAssetHQHandler, additionalContext })=>{
|
|
10
10
|
const leftSidebar = useSidebar();
|
|
11
11
|
const turndownService = new TurndownService({});
|
|
12
12
|
// Use the gfm plugin
|
|
@@ -46,6 +46,12 @@ export const useBlockEditor = ({ content, handleChange, openAssetHQHandler })=>{
|
|
|
46
46
|
handleChange(editor?.getJSON() ?? {});
|
|
47
47
|
}
|
|
48
48
|
}, []);
|
|
49
|
+
useEffect(()=>{
|
|
50
|
+
editor.storage.aiCommand.title = additionalContext?.title ?? "";
|
|
51
|
+
editor.storage.aiCommand.language = additionalContext?.language ?? "";
|
|
52
|
+
}, [
|
|
53
|
+
additionalContext
|
|
54
|
+
]);
|
|
49
55
|
const users = useMemo(()=>{
|
|
50
56
|
if (!editor?.storage.collaborationCursor?.users) {
|
|
51
57
|
return [];
|