payload-richtext-tiptap 0.0.46 → 0.0.48
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/AIMenuList.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/AICommand/AIMenuList.js +10 -123
- package/dist/src/fields/TiptapEditor/extensions/AICommand/AIMenuList.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/SlashCommand/MenuList.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/SlashCommand/MenuList.js +26 -33
- package/dist/src/fields/TiptapEditor/extensions/SlashCommand/MenuList.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/menus/TextMenu/components/ai-selector-commands.d.ts +2 -1
- package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/ai-selector-commands.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/ai-selector-commands.js +5 -5
- package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/ai-selector-commands.js.map +1 -1
- package/dist/src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.d.ts +4 -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 +196 -69
- package/dist/src/fields/TiptapEditor/features/panels/AICommandPanel/AICommandPanel.js.map +1 -1
- package/dist/src/fields/TiptapEditor/features/panels/AIEditorPanel/AIEditorPanel.js +5 -3
- package/dist/src/fields/TiptapEditor/features/panels/AIEditorPanel/AIEditorPanel.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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AIMenuList.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/extensions/AICommand/AIMenuList.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"AIMenuList.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/extensions/AICommand/AIMenuList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAI7C,eAAO,MAAM,UAAU,iFAkBrB,CAAC;AAIH,eAAe,UAAU,CAAC"}
|
|
@@ -1,132 +1,19 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
2
|
-
import React, {
|
|
3
|
-
import { DropdownButton } from "../../features/ui/Dropdown/Dropdown.js";
|
|
4
|
-
import { Surface } from "../../features/ui/Surface.js";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import React, { useState } from "react";
|
|
5
3
|
import { AICommandPanel } from "../../features/panels/AICommandPanel/AICommandPanel.js";
|
|
6
|
-
import { Icon } from "../../features/ui/Icon.js";
|
|
7
4
|
export const AIMenuList = /*#__PURE__*/ React.forwardRef((props, ref)=>{
|
|
8
|
-
const scrollContainer = useRef(null);
|
|
9
|
-
const activeItem = useRef(null);
|
|
10
|
-
const [selectedGroupIndex, setSelectedGroupIndex] = useState(0);
|
|
11
|
-
const [selectedCommandIndex, setSelectedCommandIndex] = useState(0);
|
|
12
5
|
const [userPrompt, setUserPrompt] = useState("");
|
|
13
|
-
// Anytime the groups change, i.e. the user types to narrow it down, we want to
|
|
14
|
-
// reset the current selection to the first menu item
|
|
15
|
-
useEffect(()=>{
|
|
16
|
-
setSelectedGroupIndex(0);
|
|
17
|
-
setSelectedCommandIndex(0);
|
|
18
|
-
}, [
|
|
19
|
-
props.items
|
|
20
|
-
]);
|
|
21
|
-
const selectItem = useCallback((groupIndex, commandIndex)=>{
|
|
22
|
-
const command = props.items[groupIndex].commands[commandIndex];
|
|
23
|
-
setUserPrompt(command.action(props.editor));
|
|
24
|
-
// props.command(command);
|
|
25
|
-
}, [
|
|
26
|
-
props
|
|
27
|
-
]);
|
|
28
|
-
React.useImperativeHandle(ref, ()=>({
|
|
29
|
-
onKeyDown: ({ event })=>{
|
|
30
|
-
if (event.key === "ArrowDown") {
|
|
31
|
-
if (!props.items.length) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
const commands = props.items[selectedGroupIndex].commands;
|
|
35
|
-
let newCommandIndex = selectedCommandIndex + 1;
|
|
36
|
-
let newGroupIndex = selectedGroupIndex;
|
|
37
|
-
if (commands.length - 1 < newCommandIndex) {
|
|
38
|
-
newCommandIndex = 0;
|
|
39
|
-
newGroupIndex = selectedGroupIndex + 1;
|
|
40
|
-
}
|
|
41
|
-
if (props.items.length - 1 < newGroupIndex) {
|
|
42
|
-
newGroupIndex = 0;
|
|
43
|
-
}
|
|
44
|
-
setSelectedCommandIndex(newCommandIndex);
|
|
45
|
-
setSelectedGroupIndex(newGroupIndex);
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
if (event.key === "ArrowUp") {
|
|
49
|
-
if (!props.items.length) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
let newCommandIndex = selectedCommandIndex - 1;
|
|
53
|
-
let newGroupIndex = selectedGroupIndex;
|
|
54
|
-
if (newCommandIndex < 0) {
|
|
55
|
-
newGroupIndex = selectedGroupIndex - 1;
|
|
56
|
-
newCommandIndex = props.items[newGroupIndex]?.commands.length - 1 || 0;
|
|
57
|
-
}
|
|
58
|
-
if (newGroupIndex < 0) {
|
|
59
|
-
newGroupIndex = props.items.length - 1;
|
|
60
|
-
newCommandIndex = props.items[newGroupIndex].commands.length - 1;
|
|
61
|
-
}
|
|
62
|
-
setSelectedCommandIndex(newCommandIndex);
|
|
63
|
-
setSelectedGroupIndex(newGroupIndex);
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
if (event.key === "Enter") {
|
|
67
|
-
if (!props.items.length || selectedGroupIndex === -1 || selectedCommandIndex === -1) {
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
selectItem(selectedGroupIndex, selectedCommandIndex);
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
}));
|
|
76
|
-
useEffect(()=>{
|
|
77
|
-
if (activeItem.current && scrollContainer.current) {
|
|
78
|
-
const offsetTop = activeItem.current.offsetTop;
|
|
79
|
-
const offsetHeight = activeItem.current.offsetHeight;
|
|
80
|
-
scrollContainer.current.scrollTop = offsetTop - offsetHeight;
|
|
81
|
-
}
|
|
82
|
-
}, [
|
|
83
|
-
selectedCommandIndex,
|
|
84
|
-
selectedGroupIndex
|
|
85
|
-
]);
|
|
86
|
-
const createCommandClickHandler = useCallback((groupIndex, commandIndex)=>{
|
|
87
|
-
return ()=>{
|
|
88
|
-
selectItem(groupIndex, commandIndex);
|
|
89
|
-
};
|
|
90
|
-
}, [
|
|
91
|
-
selectItem
|
|
92
|
-
]);
|
|
93
6
|
if (!props.items.length) {
|
|
94
7
|
return null;
|
|
95
8
|
}
|
|
96
|
-
return /*#__PURE__*/
|
|
97
|
-
children:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
ref: scrollContainer,
|
|
105
|
-
className: "text-black max-h-[min(80vh,24rem)] overflow-auto flex-wrap mb-8 p-2",
|
|
106
|
-
children: /*#__PURE__*/ _jsx("div", {
|
|
107
|
-
className: "grid grid-cols-1 gap-0.5",
|
|
108
|
-
children: props.items.map((group, groupIndex)=>/*#__PURE__*/ _jsxs(React.Fragment, {
|
|
109
|
-
children: [
|
|
110
|
-
/*#__PURE__*/ _jsx("div", {
|
|
111
|
-
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",
|
|
112
|
-
children: group.title
|
|
113
|
-
}, `${group.title}`),
|
|
114
|
-
group.commands.map((command, commandIndex)=>/*#__PURE__*/ _jsxs(DropdownButton, {
|
|
115
|
-
isActive: selectedGroupIndex === groupIndex && selectedCommandIndex === commandIndex,
|
|
116
|
-
onClick: createCommandClickHandler(groupIndex, commandIndex),
|
|
117
|
-
children: [
|
|
118
|
-
/*#__PURE__*/ _jsx(Icon, {
|
|
119
|
-
icon: command.icon,
|
|
120
|
-
className: "mr-1"
|
|
121
|
-
}),
|
|
122
|
-
command.label
|
|
123
|
-
]
|
|
124
|
-
}, `${command.label}`))
|
|
125
|
-
]
|
|
126
|
-
}, `${group.title}-wrapper`))
|
|
127
|
-
})
|
|
128
|
-
})
|
|
129
|
-
]
|
|
9
|
+
return /*#__PURE__*/ _jsx(_Fragment, {
|
|
10
|
+
children: /*#__PURE__*/ _jsx(AICommandPanel, {
|
|
11
|
+
editor: props?.editor,
|
|
12
|
+
onOpenChange: ()=>{},
|
|
13
|
+
userPrompt: userPrompt,
|
|
14
|
+
items: props?.items,
|
|
15
|
+
ref: ref
|
|
16
|
+
})
|
|
130
17
|
});
|
|
131
18
|
});
|
|
132
19
|
AIMenuList.displayName = "AIMenuList";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/extensions/AICommand/AIMenuList.tsx"],"sourcesContent":["import React, {
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/extensions/AICommand/AIMenuList.tsx"],"sourcesContent":["import React, { useState } from \"react\";\n\nimport { AIMenuListProps } from \"./types.js\";\n\nimport { AICommandPanel } from \"../../features/panels/AICommandPanel/AICommandPanel.js\";\n\nexport const AIMenuList = React.forwardRef((props: AIMenuListProps, ref) => {\n const [userPrompt, setUserPrompt] = useState(\"\");\n\n if (!props.items.length) {\n return null;\n }\n\n return (\n <>\n <AICommandPanel\n editor={props?.editor as any}\n onOpenChange={() => {}}\n userPrompt={userPrompt}\n items={props?.items}\n ref={ref}\n />\n </>\n );\n});\n\nAIMenuList.displayName = \"AIMenuList\";\n\nexport default AIMenuList;\n"],"names":["React","useState","AICommandPanel","AIMenuList","forwardRef","props","ref","userPrompt","setUserPrompt","items","length","editor","onOpenChange","displayName"],"mappings":";AAAA,OAAOA,SAASC,QAAQ,QAAQ,QAAQ;AAIxC,SAASC,cAAc,QAAQ,yDAAyD;AAExF,OAAO,MAAMC,2BAAaH,MAAMI,UAAU,CAAC,CAACC,OAAwBC;IAClE,MAAM,CAACC,YAAYC,cAAc,GAAGP,SAAS;IAE7C,IAAI,CAACI,MAAMI,KAAK,CAACC,MAAM,EAAE;QACvB,OAAO;IACT;IAEA,qBACE;kBACE,cAAA,KAACR;YACCS,QAAQN,OAAOM;YACfC,cAAc,KAAO;YACrBL,YAAYA;YACZE,OAAOJ,OAAOI;YACdH,KAAKA;;;AAIb,GAAG;AAEHH,WAAWU,WAAW,GAAG;AAEzB,eAAeV,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageUpload.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/ImageUpload/view/ImageUpload.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAmB,MAAM,eAAe,CAAC;AAExD,OAAO,
|
|
1
|
+
{"version":3,"file":"ImageUpload.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/ImageUpload/view/ImageUpload.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAmB,MAAM,eAAe,CAAC;AAExD,OAAO,EAEL,eAAe,EAChB,MAAM,kCAAkC,CAAC;AAC1C,eAAO,MAAM,kBAAkB,uBAAwB,eAAe,2BAIjE;IACD,MAAM,EAAE,MAAM,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB,gCA4EF,CAAC"}
|
|
@@ -3,14 +3,26 @@ import { NodeViewWrapper } from "@tiptap/react";
|
|
|
3
3
|
import { useCallback } from "react";
|
|
4
4
|
export const ImageUploadBuilder = (openAssetHQHandler)=>{
|
|
5
5
|
const ImageUpload = ({ getPos, editor })=>{
|
|
6
|
-
const onUpload = useCallback((
|
|
7
|
-
if (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
const onUpload = useCallback((asset)=>{
|
|
7
|
+
if (asset) {
|
|
8
|
+
console.log("asset in ImageUpload itself:", asset);
|
|
9
|
+
if (asset.type === "IMAGE") {
|
|
10
|
+
editor.chain().focus().setImageBlock({
|
|
11
|
+
src: asset.fullUrl
|
|
12
|
+
}) //TODO: should also set other fields to data-media-id ... it'd be easier to later find which media id is this.
|
|
13
|
+
.deleteRange({
|
|
14
|
+
from: getPos(),
|
|
15
|
+
to: getPos()
|
|
16
|
+
}).focus().run();
|
|
17
|
+
} else {
|
|
18
|
+
editor.chain().focus().setVideoBlock({
|
|
19
|
+
src: asset.videoUrl,
|
|
20
|
+
poster: asset.fullUrl
|
|
21
|
+
}).deleteRange({
|
|
22
|
+
from: getPos(),
|
|
23
|
+
to: getPos()
|
|
24
|
+
}).focus().run();
|
|
25
|
+
}
|
|
14
26
|
}
|
|
15
27
|
}, [
|
|
16
28
|
getPos,
|
|
@@ -33,7 +45,7 @@ export const ImageUploadBuilder = (openAssetHQHandler)=>{
|
|
|
33
45
|
e.preventDefault();
|
|
34
46
|
openAssetHQHandler(onUpload);
|
|
35
47
|
},
|
|
36
|
-
children: "
|
|
48
|
+
children: "Select an asset"
|
|
37
49
|
})
|
|
38
50
|
})
|
|
39
51
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/ImageUpload/view/ImageUpload.tsx"],"sourcesContent":["import { Editor, NodeViewWrapper } from \"@tiptap/react\";\nimport { useCallback } from \"react\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/ImageUpload/view/ImageUpload.tsx"],"sourcesContent":["import { Editor, NodeViewWrapper } from \"@tiptap/react\";\nimport { useCallback } from \"react\";\nimport {\n AssetReturnType,\n openAssetHQType,\n} from \"src/fields/TiptapEditor/types.js\";\nexport const ImageUploadBuilder = (openAssetHQHandler: openAssetHQType) => {\n const ImageUpload = ({\n getPos,\n editor,\n }: {\n getPos: () => number;\n editor: Editor;\n }) => {\n const onUpload = useCallback(\n (asset: AssetReturnType) => {\n if (asset) {\n console.log(\"asset in ImageUpload itself:\", asset);\n if (asset.type === \"IMAGE\") {\n editor\n .chain()\n .focus()\n .setImageBlock({ src: asset.fullUrl }) //TODO: should also set other fields to data-media-id ... it'd be easier to later find which media id is this.\n .deleteRange({ from: getPos(), to: getPos() })\n .focus()\n .run();\n } else {\n editor\n .chain()\n .focus()\n .setVideoBlock({ src: asset.videoUrl, poster: asset.fullUrl })\n .deleteRange({ from: getPos(), to: getPos() })\n .focus()\n .run();\n }\n }\n },\n [getPos, editor]\n );\n\n return (\n <NodeViewWrapper>\n <div className=\"p-0 m-0\" data-drag-handle>\n {/* <RenderFields\n fieldMap={[\n {\n name: \"media\",\n type: \"upload\",\n cellComponentProps: {\n name: \"media\",\n schemaPath: \"media\",\n },\n fieldComponentProps: {},\n fieldIsPresentational: true,\n isFieldAffectingData: false,\n localized: false,\n },\n ]}\n path=\"media\"\n readOnly={false}\n schemaPath=\"\"\n // fieldTypes={fieldTypes}\n // fields={sidebarFields}\n // permissions={permissions.fields}\n // readOnly={!hasSavePermission}\n /> */}\n <a\n href=\"#\"\n style={{\n padding: 5,\n borderRadius: 5,\n backgroundColor: \"blue\",\n color: \"white\",\n cursor: \"pointer\",\n }}\n onClick={(e) => {\n e.preventDefault();\n openAssetHQHandler(onUpload);\n }}\n >\n Select an asset\n </a>\n {/* <ImageUploader onUpload={onUpload} /> */}\n </div>\n </NodeViewWrapper>\n );\n };\n\n return ImageUpload;\n};\n"],"names":["NodeViewWrapper","useCallback","ImageUploadBuilder","openAssetHQHandler","ImageUpload","getPos","editor","onUpload","asset","console","log","type","chain","focus","setImageBlock","src","fullUrl","deleteRange","from","to","run","setVideoBlock","videoUrl","poster","div","className","data-drag-handle","a","href","style","padding","borderRadius","backgroundColor","color","cursor","onClick","e","preventDefault"],"mappings":";AAAA,SAAiBA,eAAe,QAAQ,gBAAgB;AACxD,SAASC,WAAW,QAAQ,QAAQ;AAKpC,OAAO,MAAMC,qBAAqB,CAACC;IACjC,MAAMC,cAAc,CAAC,EACnBC,MAAM,EACNC,MAAM,EAIP;QACC,MAAMC,WAAWN,YACf,CAACO;YACC,IAAIA,OAAO;gBACTC,QAAQC,GAAG,CAAC,gCAAgCF;gBAC5C,IAAIA,MAAMG,IAAI,KAAK,SAAS;oBAC1BL,OACGM,KAAK,GACLC,KAAK,GACLC,aAAa,CAAC;wBAAEC,KAAKP,MAAMQ,OAAO;oBAAC,GAAG,8GAA8G;qBACpJC,WAAW,CAAC;wBAAEC,MAAMb;wBAAUc,IAAId;oBAAS,GAC3CQ,KAAK,GACLO,GAAG;gBACR,OAAO;oBACLd,OACGM,KAAK,GACLC,KAAK,GACLQ,aAAa,CAAC;wBAAEN,KAAKP,MAAMc,QAAQ;wBAAEC,QAAQf,MAAMQ,OAAO;oBAAC,GAC3DC,WAAW,CAAC;wBAAEC,MAAMb;wBAAUc,IAAId;oBAAS,GAC3CQ,KAAK,GACLO,GAAG;gBACR;YACF;QACF,GACA;YAACf;YAAQC;SAAO;QAGlB,qBACE,KAACN;sBACC,cAAA,KAACwB;gBAAIC,WAAU;gBAAUC,kBAAgB;0BAwBvC,cAAA,KAACC;oBACCC,MAAK;oBACLC,OAAO;wBACLC,SAAS;wBACTC,cAAc;wBACdC,iBAAiB;wBACjBC,OAAO;wBACPC,QAAQ;oBACV;oBACAC,SAAS,CAACC;wBACRA,EAAEC,cAAc;wBAChBlC,mBAAmBI;oBACrB;8BACD;;;;IAOT;IAEA,OAAOH;AACT,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuList.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/extensions/SlashCommand/MenuList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAIxE,OAAO,EAAW,aAAa,EAAE,MAAM,YAAY,CAAC;AAKpD,eAAO,MAAM,QAAQ,+
|
|
1
|
+
{"version":3,"file":"MenuList.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/extensions/SlashCommand/MenuList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAIxE,OAAO,EAAW,aAAa,EAAE,MAAM,YAAY,CAAC;AAKpD,eAAO,MAAM,QAAQ,+EAmJnB,CAAC;AAIH,eAAe,QAAQ,CAAC"}
|
|
@@ -3,7 +3,6 @@ import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
|
3
3
|
import { DropdownButton } from "../../features/ui/Dropdown/Dropdown.js";
|
|
4
4
|
import { Surface } from "../../features/ui/Surface.js";
|
|
5
5
|
import { Icon } from "../../features/ui/Icon.js";
|
|
6
|
-
import { AICommandPanel } from "../../features/panels/AICommandPanel/AICommandPanel.js";
|
|
7
6
|
export const MenuList = /*#__PURE__*/ React.forwardRef((props, ref)=>{
|
|
8
7
|
const scrollContainer = useRef(null);
|
|
9
8
|
const activeItem = useRef(null);
|
|
@@ -91,39 +90,33 @@ export const MenuList = /*#__PURE__*/ React.forwardRef((props, ref)=>{
|
|
|
91
90
|
if (!props.items.length) {
|
|
92
91
|
return null;
|
|
93
92
|
}
|
|
94
|
-
return /*#__PURE__*/
|
|
95
|
-
children:
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
children:
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
command.label
|
|
120
|
-
]
|
|
121
|
-
}, `${command.label}`))
|
|
122
|
-
]
|
|
123
|
-
}, `${group.title}-wrapper`))
|
|
124
|
-
})
|
|
93
|
+
return /*#__PURE__*/ _jsx(_Fragment, {
|
|
94
|
+
children: /*#__PURE__*/ _jsx(Surface, {
|
|
95
|
+
ref: scrollContainer,
|
|
96
|
+
className: "text-black max-h-[min(80vh,24rem)] overflow-auto flex-wrap mb-8 p-2",
|
|
97
|
+
children: /*#__PURE__*/ _jsx("div", {
|
|
98
|
+
className: "grid grid-cols-1 gap-0.5",
|
|
99
|
+
children: props.items.map((group, groupIndex)=>/*#__PURE__*/ _jsxs(React.Fragment, {
|
|
100
|
+
children: [
|
|
101
|
+
/*#__PURE__*/ _jsx("div", {
|
|
102
|
+
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",
|
|
103
|
+
children: group.title
|
|
104
|
+
}, `${group.title}`),
|
|
105
|
+
group.commands.map((command, commandIndex)=>/*#__PURE__*/ _jsxs(DropdownButton, {
|
|
106
|
+
isActive: selectedGroupIndex === groupIndex && selectedCommandIndex === commandIndex,
|
|
107
|
+
onClick: createCommandClickHandler(groupIndex, commandIndex),
|
|
108
|
+
children: [
|
|
109
|
+
/*#__PURE__*/ _jsx(Icon, {
|
|
110
|
+
icon: command.icon,
|
|
111
|
+
className: "mr-1"
|
|
112
|
+
}),
|
|
113
|
+
command.label
|
|
114
|
+
]
|
|
115
|
+
}, `${command.label}`))
|
|
116
|
+
]
|
|
117
|
+
}, `${group.title}-wrapper`))
|
|
125
118
|
})
|
|
126
|
-
|
|
119
|
+
})
|
|
127
120
|
});
|
|
128
121
|
});
|
|
129
122
|
MenuList.displayName = "MenuList";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/extensions/SlashCommand/MenuList.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { DropdownButton } from \"../../features/ui/Dropdown/Dropdown.js\";\nimport { Surface } from \"../../features/ui/Surface.js\";\nimport { Command, MenuListProps } from \"./types.js\";\n\nimport { Icon } from \"../../features/ui/Icon.js\";\nimport { AICommandPanel } from \"../../features/panels/AICommandPanel/AICommandPanel.js\";\n\nexport const MenuList = React.forwardRef((props: MenuListProps, ref) => {\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 // 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 }, [props.items]);\n\n const selectItem = useCallback(\n (groupIndex: number, commandIndex: number) => {\n const command = props.items[groupIndex].commands[commandIndex];\n props.command(command);\n },\n [props]\n );\n\n React.useImperativeHandle(ref, () => ({\n onKeyDown: ({ event }: { event: React.KeyboardEvent }) => {\n if (event.key === \"ArrowDown\") {\n if (!props.items.length) {\n return false;\n }\n\n const commands = props.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 (props.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 (!props.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 =\n props.items[newGroupIndex]?.commands.length - 1 || 0;\n }\n\n if (newGroupIndex < 0) {\n newGroupIndex = props.items.length - 1;\n newCommandIndex = props.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 !props.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 if (!props.items.length) {\n return null;\n }\n\n return (\n <>\n <
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/extensions/SlashCommand/MenuList.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { DropdownButton } from \"../../features/ui/Dropdown/Dropdown.js\";\nimport { Surface } from \"../../features/ui/Surface.js\";\nimport { Command, MenuListProps } from \"./types.js\";\n\nimport { Icon } from \"../../features/ui/Icon.js\";\nimport { AICommandPanel } from \"../../features/panels/AICommandPanel/AICommandPanel.js\";\n\nexport const MenuList = React.forwardRef((props: MenuListProps, ref) => {\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 // 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 }, [props.items]);\n\n const selectItem = useCallback(\n (groupIndex: number, commandIndex: number) => {\n const command = props.items[groupIndex].commands[commandIndex];\n props.command(command);\n },\n [props]\n );\n\n React.useImperativeHandle(ref, () => ({\n onKeyDown: ({ event }: { event: React.KeyboardEvent }) => {\n if (event.key === \"ArrowDown\") {\n if (!props.items.length) {\n return false;\n }\n\n const commands = props.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 (props.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 (!props.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 =\n props.items[newGroupIndex]?.commands.length - 1 || 0;\n }\n\n if (newGroupIndex < 0) {\n newGroupIndex = props.items.length - 1;\n newCommandIndex = props.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 !props.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 if (!props.items.length) {\n return null;\n }\n\n return (\n <>\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 {props.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((command: Command, commandIndex: number) => (\n <DropdownButton\n key={`${command.label}`}\n isActive={\n selectedGroupIndex === groupIndex &&\n selectedCommandIndex === commandIndex\n }\n onClick={createCommandClickHandler(groupIndex, commandIndex)}\n >\n <Icon icon={command.icon} className=\"mr-1\" />\n {command.label}\n </DropdownButton>\n ))}\n </React.Fragment>\n ))}\n </div>\n </Surface>\n </>\n );\n});\n\nMenuList.displayName = \"MenuList\";\n\nexport default MenuList;\n"],"names":["React","useCallback","useEffect","useRef","useState","DropdownButton","Surface","Icon","MenuList","forwardRef","props","ref","scrollContainer","activeItem","selectedGroupIndex","setSelectedGroupIndex","selectedCommandIndex","setSelectedCommandIndex","items","selectItem","groupIndex","commandIndex","command","commands","useImperativeHandle","onKeyDown","event","key","length","newCommandIndex","newGroupIndex","current","offsetTop","offsetHeight","scrollTop","createCommandClickHandler","className","div","map","group","Fragment","title","isActive","onClick","icon","label","displayName"],"mappings":"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"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Node } from "@tiptap/core";
|
|
2
|
+
export interface VideoOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Controls if the image node should be inline or not.
|
|
5
|
+
* @default false
|
|
6
|
+
* @example true
|
|
7
|
+
*/
|
|
8
|
+
inline: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Controls if base64 images are allowed. Enable this if you want to allow
|
|
11
|
+
* base64 image urls in the `src` attribute.
|
|
12
|
+
* @default false
|
|
13
|
+
* @example true
|
|
14
|
+
*/
|
|
15
|
+
allowBase64: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* HTML attributes to add to the image element.
|
|
18
|
+
* @default {}
|
|
19
|
+
* @example { class: 'foo' }
|
|
20
|
+
*/
|
|
21
|
+
HTMLAttributes: Record<string, any>;
|
|
22
|
+
}
|
|
23
|
+
declare module "@tiptap/core" {
|
|
24
|
+
interface Commands<ReturnType> {
|
|
25
|
+
video: {
|
|
26
|
+
/**
|
|
27
|
+
* Add an image
|
|
28
|
+
* @param options The image attributes
|
|
29
|
+
* @example
|
|
30
|
+
* editor
|
|
31
|
+
* .commands
|
|
32
|
+
* .setVideo({ src: 'https://tiptap.dev/logo.png', alt: 'tiptap', title: 'tiptap logo' })
|
|
33
|
+
*/
|
|
34
|
+
setVideo: (options: {
|
|
35
|
+
src: string;
|
|
36
|
+
alt?: string;
|
|
37
|
+
title?: string;
|
|
38
|
+
poster?: string;
|
|
39
|
+
}) => ReturnType;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Matches an image to a  on input.
|
|
45
|
+
*/
|
|
46
|
+
export declare const inputRegex: RegExp;
|
|
47
|
+
/**
|
|
48
|
+
* This extension allows you to insert images.
|
|
49
|
+
* @see https://www.tiptap.dev/api/nodes/image
|
|
50
|
+
*/
|
|
51
|
+
export declare const Video: Node<VideoOptions, any>;
|
|
52
|
+
//# sourceMappingURL=Video.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Video.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/extensions/Video/Video.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,IAAI,EAAiB,MAAM,cAAc,CAAC;AAEpE,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,MAAM,EAAE,OAAO,CAAC;IAEhB;;;;;OAKG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB;;;;OAIG;IACH,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACrC;AAED,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,KAAK,EAAE;YACL;;;;;;;eAOG;YACH,QAAQ,EAAE,CAAC,OAAO,EAAE;gBAClB,GAAG,EAAE,MAAM,CAAC;gBACZ,GAAG,CAAC,EAAE,MAAM,CAAC;gBACb,KAAK,CAAC,EAAE,MAAM,CAAC;gBACf,MAAM,CAAC,EAAE,MAAM,CAAC;aACjB,KAAK,UAAU,CAAC;SAClB,CAAC;KACH;CACF;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,QACqC,CAAC;AAE7D;;;GAGG;AACH,eAAO,MAAM,KAAK,yBAiFhB,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { mergeAttributes, Node, nodeInputRule } from "@tiptap/core";
|
|
2
|
+
/**
|
|
3
|
+
* Matches an image to a  on input.
|
|
4
|
+
*/ export const inputRegex = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/;
|
|
5
|
+
/**
|
|
6
|
+
* This extension allows you to insert images.
|
|
7
|
+
* @see https://www.tiptap.dev/api/nodes/image
|
|
8
|
+
*/ export const Video = Node.create({
|
|
9
|
+
name: "video",
|
|
10
|
+
addOptions () {
|
|
11
|
+
return {
|
|
12
|
+
inline: false,
|
|
13
|
+
allowBase64: false,
|
|
14
|
+
HTMLAttributes: {}
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
inline () {
|
|
18
|
+
return this.options.inline;
|
|
19
|
+
},
|
|
20
|
+
group () {
|
|
21
|
+
return this.options.inline ? "inline" : "block";
|
|
22
|
+
},
|
|
23
|
+
draggable: true,
|
|
24
|
+
addAttributes () {
|
|
25
|
+
return {
|
|
26
|
+
src: {
|
|
27
|
+
default: null
|
|
28
|
+
},
|
|
29
|
+
alt: {
|
|
30
|
+
default: null
|
|
31
|
+
},
|
|
32
|
+
title: {
|
|
33
|
+
default: null
|
|
34
|
+
},
|
|
35
|
+
poster: {
|
|
36
|
+
default: null
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
parseHTML () {
|
|
41
|
+
return [
|
|
42
|
+
{
|
|
43
|
+
tag: this.options.allowBase64 ? "video[src]" : 'video[src]:not([src^="data:"])'
|
|
44
|
+
}
|
|
45
|
+
];
|
|
46
|
+
},
|
|
47
|
+
renderHTML ({ HTMLAttributes }) {
|
|
48
|
+
return [
|
|
49
|
+
"video",
|
|
50
|
+
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)
|
|
51
|
+
];
|
|
52
|
+
},
|
|
53
|
+
addCommands () {
|
|
54
|
+
return {
|
|
55
|
+
setVideo: (options)=>({ commands })=>{
|
|
56
|
+
return commands.insertContent({
|
|
57
|
+
type: this.name,
|
|
58
|
+
attrs: options
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
addInputRules () {
|
|
64
|
+
return [
|
|
65
|
+
nodeInputRule({
|
|
66
|
+
find: inputRegex,
|
|
67
|
+
type: this.type,
|
|
68
|
+
getAttributes: (match)=>{
|
|
69
|
+
const [, , alt, src, title] = match;
|
|
70
|
+
return {
|
|
71
|
+
src,
|
|
72
|
+
alt,
|
|
73
|
+
title
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
//# sourceMappingURL=Video.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/extensions/Video/Video.ts"],"sourcesContent":["import { mergeAttributes, Node, nodeInputRule } from \"@tiptap/core\";\n\nexport interface VideoOptions {\n /**\n * Controls if the image node should be inline or not.\n * @default false\n * @example true\n */\n inline: boolean;\n\n /**\n * Controls if base64 images are allowed. Enable this if you want to allow\n * base64 image urls in the `src` attribute.\n * @default false\n * @example true\n */\n allowBase64: boolean;\n\n /**\n * HTML attributes to add to the image element.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>;\n}\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n video: {\n /**\n * Add an image\n * @param options The image attributes\n * @example\n * editor\n * .commands\n * .setVideo({ src: 'https://tiptap.dev/logo.png', alt: 'tiptap', title: 'tiptap logo' })\n */\n setVideo: (options: {\n src: string;\n alt?: string;\n title?: string;\n poster?: string;\n }) => ReturnType;\n };\n }\n}\n\n/**\n * Matches an image to a  on input.\n */\nexport const inputRegex =\n /(?:^|\\s)(!\\[(.+|:?)]\\((\\S+)(?:(?:\\s+)[\"'](\\S+)[\"'])?\\))$/;\n\n/**\n * This extension allows you to insert images.\n * @see https://www.tiptap.dev/api/nodes/image\n */\nexport const Video = Node.create<VideoOptions>({\n name: \"video\",\n\n addOptions() {\n return {\n inline: false,\n allowBase64: false,\n HTMLAttributes: {},\n };\n },\n\n inline() {\n return this.options.inline;\n },\n\n group() {\n return this.options.inline ? \"inline\" : \"block\";\n },\n\n draggable: true,\n\n addAttributes() {\n return {\n src: {\n default: null,\n },\n alt: {\n default: null,\n },\n title: {\n default: null,\n },\n poster: {\n default: null,\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: this.options.allowBase64\n ? \"video[src]\"\n : 'video[src]:not([src^=\"data:\"])',\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\n \"video\",\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n ];\n },\n\n addCommands() {\n return {\n setVideo:\n (options) =>\n ({ commands }) => {\n return commands.insertContent({\n type: this.name,\n attrs: options,\n });\n },\n };\n },\n\n addInputRules() {\n return [\n nodeInputRule({\n find: inputRegex,\n type: this.type,\n getAttributes: (match) => {\n const [, , alt, src, title] = match;\n\n return { src, alt, title };\n },\n }),\n ];\n },\n});\n"],"names":["mergeAttributes","Node","nodeInputRule","inputRegex","Video","create","name","addOptions","inline","allowBase64","HTMLAttributes","options","group","draggable","addAttributes","src","default","alt","title","poster","parseHTML","tag","renderHTML","addCommands","setVideo","commands","insertContent","type","attrs","addInputRules","find","getAttributes","match"],"mappings":"AAAA,SAASA,eAAe,EAAEC,IAAI,EAAEC,aAAa,QAAQ,eAAe;AA+CpE;;CAEC,GACD,OAAO,MAAMC,aACX,2DAA2D;AAE7D;;;CAGC,GACD,OAAO,MAAMC,QAAQH,KAAKI,MAAM,CAAe;IAC7CC,MAAM;IAENC;QACE,OAAO;YACLC,QAAQ;YACRC,aAAa;YACbC,gBAAgB,CAAC;QACnB;IACF;IAEAF;QACE,OAAO,IAAI,CAACG,OAAO,CAACH,MAAM;IAC5B;IAEAI;QACE,OAAO,IAAI,CAACD,OAAO,CAACH,MAAM,GAAG,WAAW;IAC1C;IAEAK,WAAW;IAEXC;QACE,OAAO;YACLC,KAAK;gBACHC,SAAS;YACX;YACAC,KAAK;gBACHD,SAAS;YACX;YACAE,OAAO;gBACLF,SAAS;YACX;YACAG,QAAQ;gBACNH,SAAS;YACX;QACF;IACF;IAEAI;QACE,OAAO;YACL;gBACEC,KAAK,IAAI,CAACV,OAAO,CAACF,WAAW,GACzB,eACA;YACN;SACD;IACH;IAEAa,YAAW,EAAEZ,cAAc,EAAE;QAC3B,OAAO;YACL;YACAV,gBAAgB,IAAI,CAACW,OAAO,CAACD,cAAc,EAAEA;SAC9C;IACH;IAEAa;QACE,OAAO;YACLC,UACE,CAACb,UACD,CAAC,EAAEc,QAAQ,EAAE;oBACX,OAAOA,SAASC,aAAa,CAAC;wBAC5BC,MAAM,IAAI,CAACrB,IAAI;wBACfsB,OAAOjB;oBACT;gBACF;QACJ;IACF;IAEAkB;QACE,OAAO;YACL3B,cAAc;gBACZ4B,MAAM3B;gBACNwB,MAAM,IAAI,CAACA,IAAI;gBACfI,eAAe,CAACC;oBACd,MAAM,KAAKf,KAAKF,KAAKG,MAAM,GAAGc;oBAE9B,OAAO;wBAAEjB;wBAAKE;wBAAKC;oBAAM;gBAC3B;YACF;SACD;IACH;AACF,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/extensions/Video/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/extensions/Video/index.ts"],"sourcesContent":["export * from \"./Video.js\";\n"],"names":[],"mappings":"AAAA,cAAc,aAAa"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Range } from "@tiptap/core";
|
|
2
|
+
declare module "@tiptap/core" {
|
|
3
|
+
interface Commands<ReturnType> {
|
|
4
|
+
videoBlock: {
|
|
5
|
+
setVideoBlock: (attributes: {
|
|
6
|
+
src: string;
|
|
7
|
+
poster: string;
|
|
8
|
+
}) => ReturnType;
|
|
9
|
+
setVideoBlockAt: (attributes: {
|
|
10
|
+
src: string;
|
|
11
|
+
poster: string;
|
|
12
|
+
pos: number | Range;
|
|
13
|
+
}) => ReturnType;
|
|
14
|
+
setVideoBlockAlign: (align: "left" | "center" | "right") => ReturnType;
|
|
15
|
+
setVideoBlockWidth: (width: number) => ReturnType;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export declare const VideoBlock: import("@tiptap/react").Node<import("../Video/Video.js").VideoOptions, any>;
|
|
20
|
+
export default VideoBlock;
|
|
21
|
+
//# sourceMappingURL=VideoBlock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VideoBlock.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/VideoBlock.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,KAAK,EAAE,MAAM,cAAc,CAAC;AAKtD,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,UAAU,EAAE;YACV,aAAa,EAAE,CAAC,UAAU,EAAE;gBAC1B,GAAG,EAAE,MAAM,CAAC;gBACZ,MAAM,EAAE,MAAM,CAAC;aAChB,KAAK,UAAU,CAAC;YACjB,eAAe,EAAE,CAAC,UAAU,EAAE;gBAC5B,GAAG,EAAE,MAAM,CAAC;gBACZ,MAAM,EAAE,MAAM,CAAC;gBACf,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC;aACrB,KAAK,UAAU,CAAC;YACjB,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,KAAK,UAAU,CAAC;YACvE,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,UAAU,CAAC;SACnD,CAAC;KACH;CACF;AAED,eAAO,MAAM,UAAU,6EAqGrB,CAAC;AAEH,eAAe,UAAU,CAAC"}
|