@puckeditor/plugin-ai 0.9.0-canary.0c69e82d → 0.9.0-canary.0f91c5e1
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/index.js +57 -1
- package/dist/index.mjs +57 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1814,6 +1814,42 @@ var matchesAccept = (file, accept) => {
|
|
|
1814
1814
|
return file.type === entry;
|
|
1815
1815
|
});
|
|
1816
1816
|
};
|
|
1817
|
+
var documentExtensionByMediaType = {
|
|
1818
|
+
"application/msword": "doc",
|
|
1819
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
|
|
1820
|
+
"text/markdown": "md",
|
|
1821
|
+
"application/pdf": "pdf",
|
|
1822
|
+
"text/plain": "txt"
|
|
1823
|
+
};
|
|
1824
|
+
var mediaTypeToExtension = (mediaType) => {
|
|
1825
|
+
const mapped = documentExtensionByMediaType[mediaType];
|
|
1826
|
+
if (mapped) {
|
|
1827
|
+
return mapped;
|
|
1828
|
+
}
|
|
1829
|
+
const subtype = mediaType.split("/")[1] ?? "";
|
|
1830
|
+
return subtype.split("+")[0] || "bin";
|
|
1831
|
+
};
|
|
1832
|
+
var getFilesFromClipboard = (data) => {
|
|
1833
|
+
const files = [];
|
|
1834
|
+
for (const item of data.items ? Array.from(data.items) : []) {
|
|
1835
|
+
if (item.kind === "file") {
|
|
1836
|
+
const file = item.getAsFile();
|
|
1837
|
+
if (file) {
|
|
1838
|
+
files.push(file);
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
if (files.length === 0 && data.files) {
|
|
1843
|
+
files.push(...Array.from(data.files));
|
|
1844
|
+
}
|
|
1845
|
+
return files.map(
|
|
1846
|
+
(file, index) => file.name ? file : new File(
|
|
1847
|
+
[file],
|
|
1848
|
+
`pasted-${Date.now()}-${index}.${mediaTypeToExtension(file.type)}`,
|
|
1849
|
+
{ type: file.type }
|
|
1850
|
+
)
|
|
1851
|
+
);
|
|
1852
|
+
};
|
|
1817
1853
|
var getAttachmentIdFromRef = (url) => url.startsWith("attachment://") ? url.slice("attachment://".length) : null;
|
|
1818
1854
|
var resolveAttachmentUrl = (url, attachmentEndpoint) => {
|
|
1819
1855
|
if (!attachmentEndpoint) {
|
|
@@ -1896,6 +1932,16 @@ function PromptForm({
|
|
|
1896
1932
|
},
|
|
1897
1933
|
[canDrop, onFileDrop]
|
|
1898
1934
|
);
|
|
1935
|
+
const handlePaste = (0, import_react19.useCallback)(
|
|
1936
|
+
(e) => {
|
|
1937
|
+
if (!canDrop) return;
|
|
1938
|
+
const files = getFilesFromClipboard(e.clipboardData);
|
|
1939
|
+
if (files.length === 0) return;
|
|
1940
|
+
e.preventDefault();
|
|
1941
|
+
onFileDrop(files);
|
|
1942
|
+
},
|
|
1943
|
+
[canDrop, onFileDrop]
|
|
1944
|
+
);
|
|
1899
1945
|
(0, import_react19.useEffect)(() => {
|
|
1900
1946
|
setPrompt(value);
|
|
1901
1947
|
}, [setPrompt, value]);
|
|
@@ -1997,6 +2043,7 @@ function PromptForm({
|
|
|
1997
2043
|
internalRef.current = node;
|
|
1998
2044
|
},
|
|
1999
2045
|
onChange: (e) => setPrompt(e.target.value),
|
|
2046
|
+
onPaste: onFileDrop ? handlePaste : void 0,
|
|
2000
2047
|
onKeyDown: (e) => {
|
|
2001
2048
|
if (!e.shiftKey && e.key === "Enter") {
|
|
2002
2049
|
e.preventDefault();
|
|
@@ -4473,6 +4520,14 @@ var getDocumentSize = (root) => {
|
|
|
4473
4520
|
};
|
|
4474
4521
|
};
|
|
4475
4522
|
|
|
4523
|
+
// src/lib/screenshot-overflow.ts
|
|
4524
|
+
init_react_import();
|
|
4525
|
+
var applyBrowserOverflowStylesTo = (document2) => {
|
|
4526
|
+
for (const element of [document2.documentElement, document2.body]) {
|
|
4527
|
+
element?.style.setProperty("overflow", "visible", "important");
|
|
4528
|
+
}
|
|
4529
|
+
};
|
|
4530
|
+
|
|
4476
4531
|
// src/lib/capture-screenshot.ts
|
|
4477
4532
|
var editorOnlyClassPrefixes = ["_DraggableComponent--hover", "_ActionBar"];
|
|
4478
4533
|
var releaseCanvas = (canvas) => {
|
|
@@ -4541,6 +4596,7 @@ var captureScreenshot = async (root, { scale = CAPTURE_SCALE, quality = 0.8, wid
|
|
|
4541
4596
|
allowTaint: false,
|
|
4542
4597
|
useCORS: true,
|
|
4543
4598
|
scrollY: 0,
|
|
4599
|
+
onclone: applyBrowserOverflowStylesTo,
|
|
4544
4600
|
ignoreElements: (el) => Array.from(el.classList).some(
|
|
4545
4601
|
(c) => editorOnlyClassPrefixes.some((prefix) => c.startsWith(prefix))
|
|
4546
4602
|
)
|
|
@@ -4575,7 +4631,7 @@ var q = (0, import_qler.default)();
|
|
|
4575
4631
|
var DEFAULT_API_VERSION = "v2";
|
|
4576
4632
|
var BUILD_OP_DEBOUNCE_MS = 1e3 / 60;
|
|
4577
4633
|
var CLIENT_TOOL_ENDPOINT_UNAVAILABLE_ERROR_MESSAGE = "Unable to verify the page data. Please enable the `/chat/tool` endpoint on the server and try again.";
|
|
4578
|
-
var PLUGIN_AI_VERSION = true ? "0.9.0-canary.
|
|
4634
|
+
var PLUGIN_AI_VERSION = true ? "0.9.0-canary.0f91c5e1" : "unknown";
|
|
4579
4635
|
var BENCHMARK = false;
|
|
4580
4636
|
var prefixedUlid = (prefix = "") => `${prefix ? `${prefix}_` : ""}${(0, import_ulid.ulid)()}`;
|
|
4581
4637
|
var getClassName18 = getClassNameFactory("Chat", styles_module_default);
|
package/dist/index.mjs
CHANGED
|
@@ -1834,6 +1834,42 @@ var matchesAccept = (file, accept) => {
|
|
|
1834
1834
|
return file.type === entry;
|
|
1835
1835
|
});
|
|
1836
1836
|
};
|
|
1837
|
+
var documentExtensionByMediaType = {
|
|
1838
|
+
"application/msword": "doc",
|
|
1839
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
|
|
1840
|
+
"text/markdown": "md",
|
|
1841
|
+
"application/pdf": "pdf",
|
|
1842
|
+
"text/plain": "txt"
|
|
1843
|
+
};
|
|
1844
|
+
var mediaTypeToExtension = (mediaType) => {
|
|
1845
|
+
const mapped = documentExtensionByMediaType[mediaType];
|
|
1846
|
+
if (mapped) {
|
|
1847
|
+
return mapped;
|
|
1848
|
+
}
|
|
1849
|
+
const subtype = mediaType.split("/")[1] ?? "";
|
|
1850
|
+
return subtype.split("+")[0] || "bin";
|
|
1851
|
+
};
|
|
1852
|
+
var getFilesFromClipboard = (data) => {
|
|
1853
|
+
const files = [];
|
|
1854
|
+
for (const item of data.items ? Array.from(data.items) : []) {
|
|
1855
|
+
if (item.kind === "file") {
|
|
1856
|
+
const file = item.getAsFile();
|
|
1857
|
+
if (file) {
|
|
1858
|
+
files.push(file);
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
if (files.length === 0 && data.files) {
|
|
1863
|
+
files.push(...Array.from(data.files));
|
|
1864
|
+
}
|
|
1865
|
+
return files.map(
|
|
1866
|
+
(file, index) => file.name ? file : new File(
|
|
1867
|
+
[file],
|
|
1868
|
+
`pasted-${Date.now()}-${index}.${mediaTypeToExtension(file.type)}`,
|
|
1869
|
+
{ type: file.type }
|
|
1870
|
+
)
|
|
1871
|
+
);
|
|
1872
|
+
};
|
|
1837
1873
|
var getAttachmentIdFromRef = (url) => url.startsWith("attachment://") ? url.slice("attachment://".length) : null;
|
|
1838
1874
|
var resolveAttachmentUrl = (url, attachmentEndpoint) => {
|
|
1839
1875
|
if (!attachmentEndpoint) {
|
|
@@ -1916,6 +1952,16 @@ function PromptForm({
|
|
|
1916
1952
|
},
|
|
1917
1953
|
[canDrop, onFileDrop]
|
|
1918
1954
|
);
|
|
1955
|
+
const handlePaste = useCallback4(
|
|
1956
|
+
(e) => {
|
|
1957
|
+
if (!canDrop) return;
|
|
1958
|
+
const files = getFilesFromClipboard(e.clipboardData);
|
|
1959
|
+
if (files.length === 0) return;
|
|
1960
|
+
e.preventDefault();
|
|
1961
|
+
onFileDrop(files);
|
|
1962
|
+
},
|
|
1963
|
+
[canDrop, onFileDrop]
|
|
1964
|
+
);
|
|
1919
1965
|
useEffect8(() => {
|
|
1920
1966
|
setPrompt(value);
|
|
1921
1967
|
}, [setPrompt, value]);
|
|
@@ -2017,6 +2063,7 @@ function PromptForm({
|
|
|
2017
2063
|
internalRef.current = node;
|
|
2018
2064
|
},
|
|
2019
2065
|
onChange: (e) => setPrompt(e.target.value),
|
|
2066
|
+
onPaste: onFileDrop ? handlePaste : void 0,
|
|
2020
2067
|
onKeyDown: (e) => {
|
|
2021
2068
|
if (!e.shiftKey && e.key === "Enter") {
|
|
2022
2069
|
e.preventDefault();
|
|
@@ -4505,6 +4552,14 @@ var getDocumentSize = (root) => {
|
|
|
4505
4552
|
};
|
|
4506
4553
|
};
|
|
4507
4554
|
|
|
4555
|
+
// src/lib/screenshot-overflow.ts
|
|
4556
|
+
init_react_import();
|
|
4557
|
+
var applyBrowserOverflowStylesTo = (document2) => {
|
|
4558
|
+
for (const element of [document2.documentElement, document2.body]) {
|
|
4559
|
+
element?.style.setProperty("overflow", "visible", "important");
|
|
4560
|
+
}
|
|
4561
|
+
};
|
|
4562
|
+
|
|
4508
4563
|
// src/lib/capture-screenshot.ts
|
|
4509
4564
|
var editorOnlyClassPrefixes = ["_DraggableComponent--hover", "_ActionBar"];
|
|
4510
4565
|
var releaseCanvas = (canvas) => {
|
|
@@ -4573,6 +4628,7 @@ var captureScreenshot = async (root, { scale = CAPTURE_SCALE, quality = 0.8, wid
|
|
|
4573
4628
|
allowTaint: false,
|
|
4574
4629
|
useCORS: true,
|
|
4575
4630
|
scrollY: 0,
|
|
4631
|
+
onclone: applyBrowserOverflowStylesTo,
|
|
4576
4632
|
ignoreElements: (el) => Array.from(el.classList).some(
|
|
4577
4633
|
(c) => editorOnlyClassPrefixes.some((prefix) => c.startsWith(prefix))
|
|
4578
4634
|
)
|
|
@@ -4607,7 +4663,7 @@ var q = qler();
|
|
|
4607
4663
|
var DEFAULT_API_VERSION = "v2";
|
|
4608
4664
|
var BUILD_OP_DEBOUNCE_MS = 1e3 / 60;
|
|
4609
4665
|
var CLIENT_TOOL_ENDPOINT_UNAVAILABLE_ERROR_MESSAGE = "Unable to verify the page data. Please enable the `/chat/tool` endpoint on the server and try again.";
|
|
4610
|
-
var PLUGIN_AI_VERSION = true ? "0.9.0-canary.
|
|
4666
|
+
var PLUGIN_AI_VERSION = true ? "0.9.0-canary.0f91c5e1" : "unknown";
|
|
4611
4667
|
var BENCHMARK = false;
|
|
4612
4668
|
var prefixedUlid = (prefix = "") => `${prefix ? `${prefix}_` : ""}${ulid()}`;
|
|
4613
4669
|
var getClassName18 = getClassNameFactory("Chat", styles_module_default);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@puckeditor/plugin-ai",
|
|
3
|
-
"version": "0.9.0-canary.
|
|
3
|
+
"version": "0.9.0-canary.0f91c5e1",
|
|
4
4
|
"author": "Chris Villa <chris@puckeditor.com>",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -52,12 +52,12 @@
|
|
|
52
52
|
"tsup": "^8.2.4",
|
|
53
53
|
"typescript": "^5.5.4",
|
|
54
54
|
"vitest": "^4.1.11",
|
|
55
|
-
"@puckeditor/ai-types": "0.9.0-canary.
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
55
|
+
"@puckeditor/ai-types": "0.9.0-canary.0f91c5e1",
|
|
56
|
+
"tsconfig": "0.9.0-canary.0f91c5e1",
|
|
57
|
+
"tsup-config": "0.9.0-canary.0f91c5e1",
|
|
58
|
+
"eslint-config-custom": "0.9.0-canary.0f91c5e1",
|
|
59
|
+
"@puckeditor/platform-types": "0.9.0-canary.0f91c5e1",
|
|
60
|
+
"reducer": "0.9.0-canary.0f91c5e1"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"@puckeditor/core": "^0",
|