@prosekit/extensions 0.11.5 → 0.11.6
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/drop-indicator-E7nCfdnR.js +58 -0
- package/dist/drop-indicator-E7nCfdnR.js.map +1 -0
- package/dist/file-DVUhe5KJ.js +134 -0
- package/dist/file-DVUhe5KJ.js.map +1 -0
- package/dist/index-DY6lIIYV.d.ts +134 -0
- package/dist/index-DY6lIIYV.d.ts.map +1 -0
- package/dist/{mark-rule-BCqIZMDu.js → mark-rule-CGmswjQ_.js} +1 -1
- package/dist/{mark-rule-BCqIZMDu.js.map → mark-rule-CGmswjQ_.js.map} +1 -1
- package/dist/{paste-rule-DIEJKIje.js → paste-rule-BIztzELg.js} +1 -1
- package/dist/{paste-rule-DIEJKIje.js.map → paste-rule-BIztzELg.js.map} +1 -1
- package/dist/prosekit-extensions-code-block.d.ts +1 -1
- package/dist/prosekit-extensions-drop-indicator.d.ts +3 -106
- package/dist/prosekit-extensions-drop-indicator.d.ts.map +1 -1
- package/dist/prosekit-extensions-drop-indicator.js +1 -1
- package/dist/prosekit-extensions-file.d.ts +2 -126
- package/dist/prosekit-extensions-file.js +2 -128
- package/dist/prosekit-extensions-hard-break.d.ts +0 -4
- package/dist/prosekit-extensions-hard-break.d.ts.map +1 -1
- package/dist/prosekit-extensions-image.d.ts +79 -3
- package/dist/prosekit-extensions-image.d.ts.map +1 -1
- package/dist/prosekit-extensions-image.js +88 -8
- package/dist/prosekit-extensions-image.js.map +1 -1
- package/dist/prosekit-extensions-link.js +2 -2
- package/dist/prosekit-extensions-list.js +2 -2
- package/dist/prosekit-extensions-mark-rule.js +1 -1
- package/dist/prosekit-extensions-paragraph.d.ts +0 -4
- package/dist/prosekit-extensions-paragraph.d.ts.map +1 -1
- package/dist/prosekit-extensions-paste-rule.js +1 -1
- package/dist/prosekit-extensions-placeholder.js +2 -2
- package/dist/prosekit-extensions-table.js +2 -2
- package/dist/prosekit-extensions.d.ts +1 -1
- package/dist/{shiki-highlighter-chunk-DSPM0T27.d.ts → shiki-highlighter-chunk-Cwu1Jr9o.d.ts} +1 -1
- package/dist/{shiki-highlighter-chunk-DSPM0T27.d.ts.map → shiki-highlighter-chunk-Cwu1Jr9o.d.ts.map} +1 -1
- package/dist/shiki-highlighter-chunk.d.ts +1 -1
- package/dist/{table-Bi7WsMI3.js → table-BNwuK7xg.js} +2 -2
- package/dist/{table-Bi7WsMI3.js.map → table-BNwuK7xg.js.map} +1 -1
- package/package.json +7 -6
- package/src/drop-indicator/drop-indicator-facet.ts +6 -28
- package/src/drop-indicator/drop-indicator.ts +3 -5
- package/src/drop-indicator/index.ts +6 -6
- package/src/file/file-upload.ts +29 -8
- package/src/image/image-commands.ts +12 -3
- package/src/image/image-upload-handler.ts +156 -0
- package/src/image/index.ts +9 -0
- package/dist/drop-indicator-D1eHOhSi.js +0 -267
- package/dist/drop-indicator-D1eHOhSi.js.map +0 -1
- package/dist/prosekit-extensions-file.d.ts.map +0 -1
- package/dist/prosekit-extensions-file.js.map +0 -1
- package/src/drop-indicator/drop-indicator-plugin.ts +0 -147
- package/src/drop-indicator/drop-target.ts +0 -168
- package/src/drop-indicator/types.ts +0 -90
|
@@ -1,126 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
//#region src/file/file-drop-handler.d.ts
|
|
5
|
-
interface FileDropHandlerOptions {
|
|
6
|
-
/**
|
|
7
|
-
* The editor view.
|
|
8
|
-
*/
|
|
9
|
-
view: EditorView;
|
|
10
|
-
/**
|
|
11
|
-
* The event that triggered the drop.
|
|
12
|
-
*/
|
|
13
|
-
event: DragEvent;
|
|
14
|
-
/**
|
|
15
|
-
* The file that was dropped.
|
|
16
|
-
*/
|
|
17
|
-
file: File;
|
|
18
|
-
/**
|
|
19
|
-
* The position of the document where the file was dropped.
|
|
20
|
-
*/
|
|
21
|
-
pos: number;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* A function that handles one of the files in a drop event.
|
|
25
|
-
*
|
|
26
|
-
* Returns `true` if the file was handled and thus should not be handled by
|
|
27
|
-
* other handlers.
|
|
28
|
-
*/
|
|
29
|
-
type FileDropHandler = (options: FileDropHandlerOptions) => boolean | void;
|
|
30
|
-
declare function defineFileDropHandler(handler: FileDropHandler): PlainExtension;
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region src/file/file-paste-handler.d.ts
|
|
33
|
-
interface FilePasteHandlerOptions {
|
|
34
|
-
/**
|
|
35
|
-
* The editor view.
|
|
36
|
-
*/
|
|
37
|
-
view: EditorView;
|
|
38
|
-
/**
|
|
39
|
-
* The event that triggered the paste.
|
|
40
|
-
*/
|
|
41
|
-
event: ClipboardEvent;
|
|
42
|
-
/**
|
|
43
|
-
* The file that was pasted.
|
|
44
|
-
*/
|
|
45
|
-
file: File;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* A function that handles one of the files in a paste event.
|
|
49
|
-
*
|
|
50
|
-
* Returns `true` if the file was handled and thus should not be handled by
|
|
51
|
-
* other handlers.
|
|
52
|
-
*/
|
|
53
|
-
type FilePasteHandler = (options: FilePasteHandlerOptions) => boolean | void;
|
|
54
|
-
declare function defineFilePasteHandler(handler: FilePasteHandler): PlainExtension;
|
|
55
|
-
//#endregion
|
|
56
|
-
//#region src/file/file-upload.d.ts
|
|
57
|
-
/**
|
|
58
|
-
* An interface representing the upload progress.
|
|
59
|
-
*/
|
|
60
|
-
interface UploadProgress {
|
|
61
|
-
loaded: number;
|
|
62
|
-
total: number;
|
|
63
|
-
}
|
|
64
|
-
interface UploaderOptions {
|
|
65
|
-
/**
|
|
66
|
-
* The file to be uploaded.
|
|
67
|
-
*/
|
|
68
|
-
file: File;
|
|
69
|
-
/**
|
|
70
|
-
* A callback function that should be called with the upload progress updates.
|
|
71
|
-
*/
|
|
72
|
-
onProgress: (progress: UploadProgress) => void;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* The implementation of the actual upload function. You need to implement this
|
|
76
|
-
* function to upload files to your desired destination.
|
|
77
|
-
*/
|
|
78
|
-
type Uploader<Result> = (options: UploaderOptions) => Promise<Result>;
|
|
79
|
-
/**
|
|
80
|
-
* A class that represents a upload task.
|
|
81
|
-
*/
|
|
82
|
-
declare class UploadTask<Result> {
|
|
83
|
-
/**
|
|
84
|
-
* An [object URL](https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL)
|
|
85
|
-
* representing the file to be uploaded. This URL will be revoked once the
|
|
86
|
-
* upload is complete successfully.
|
|
87
|
-
*/
|
|
88
|
-
readonly objectURL: string;
|
|
89
|
-
/**
|
|
90
|
-
* A boolean indicating whether the upload is complete (either successfully or with an error).
|
|
91
|
-
*/
|
|
92
|
-
protected done: boolean;
|
|
93
|
-
/**
|
|
94
|
-
* A promise that fulfills once the upload is complete, or rejects if an error occurs.
|
|
95
|
-
*/
|
|
96
|
-
readonly finished: Promise<Result>;
|
|
97
|
-
private subscribers;
|
|
98
|
-
/**
|
|
99
|
-
* Creates a new upload task. You can find the upload task by its object URL
|
|
100
|
-
* later using `UploadTask.get()`.
|
|
101
|
-
*
|
|
102
|
-
* @param options - The options for the upload task.
|
|
103
|
-
*/
|
|
104
|
-
constructor({
|
|
105
|
-
file,
|
|
106
|
-
uploader
|
|
107
|
-
}: {
|
|
108
|
-
file: File;
|
|
109
|
-
uploader: Uploader<Result>;
|
|
110
|
-
});
|
|
111
|
-
/**
|
|
112
|
-
* Subscribes to progress updates. Returns a function to unsubscribe.
|
|
113
|
-
*/
|
|
114
|
-
subscribeProgress(callback: (progress: UploadProgress) => void): VoidFunction;
|
|
115
|
-
/**
|
|
116
|
-
* Finds an upload task by its object URL.
|
|
117
|
-
*/
|
|
118
|
-
static get<Result = unknown>(objectURL: string): UploadTask<Result> | undefined;
|
|
119
|
-
/**
|
|
120
|
-
* Deletes an upload task by its object URL.
|
|
121
|
-
*/
|
|
122
|
-
static delete(objectURL: string): void;
|
|
123
|
-
}
|
|
124
|
-
//#endregion
|
|
125
|
-
export { type FileDropHandler, type FileDropHandlerOptions, type FilePasteHandler, type FilePasteHandlerOptions, type UploadProgress, UploadTask, type Uploader, type UploaderOptions, defineFileDropHandler, defineFilePasteHandler };
|
|
126
|
-
//# sourceMappingURL=prosekit-extensions-file.d.ts.map
|
|
1
|
+
import { FileDropHandler, FileDropHandlerOptions, FilePasteHandler, FilePasteHandlerOptions, UploadProgress, UploadTask, Uploader, UploaderOptions, defineFileDropHandler, defineFilePasteHandler } from "./index-DY6lIIYV.js";
|
|
2
|
+
export { FileDropHandler, FileDropHandlerOptions, FilePasteHandler, FilePasteHandlerOptions, UploadProgress, UploadTask, Uploader, UploaderOptions, defineFileDropHandler, defineFilePasteHandler };
|
|
@@ -1,129 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UploadTask, defineFileDropHandler, defineFilePasteHandler } from "./file-DVUhe5KJ.js";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
function handleFile(view, event, file, handlers) {
|
|
5
|
-
for (let i = handlers.length - 1; i >= 0; i--) {
|
|
6
|
-
const handler = handlers[i];
|
|
7
|
-
if (handler({
|
|
8
|
-
view,
|
|
9
|
-
event,
|
|
10
|
-
file
|
|
11
|
-
})) return true;
|
|
12
|
-
}
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
function handleEvent(view, event, handlers, getFiles$2) {
|
|
16
|
-
const files = getFiles$2(event);
|
|
17
|
-
let handled = false;
|
|
18
|
-
for (const file of files) if (handleFile(view, event, file, handlers)) handled = true;
|
|
19
|
-
return handled;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
//#endregion
|
|
23
|
-
//#region src/file/file-drop-handler.ts
|
|
24
|
-
function defineFileDropHandler(handler) {
|
|
25
|
-
return defineFacetPayload(facet$1, [handler]);
|
|
26
|
-
}
|
|
27
|
-
function getFiles$1(event) {
|
|
28
|
-
return Array.from(event.dataTransfer?.files ?? []);
|
|
29
|
-
}
|
|
30
|
-
const facet$1 = defineFacet({
|
|
31
|
-
parent: editorEventFacet,
|
|
32
|
-
singleton: true,
|
|
33
|
-
reducer: (handlers) => {
|
|
34
|
-
const dropHandler = (view, event) => {
|
|
35
|
-
const position = view.posAtCoords({
|
|
36
|
-
left: event.x,
|
|
37
|
-
top: event.y
|
|
38
|
-
});
|
|
39
|
-
if (!position) return false;
|
|
40
|
-
const pos = position.inside > 0 ? position.inside : position.pos;
|
|
41
|
-
return handleEvent(view, event, handlers.map((handler) => (options) => handler({
|
|
42
|
-
...options,
|
|
43
|
-
pos
|
|
44
|
-
})), getFiles$1);
|
|
45
|
-
};
|
|
46
|
-
return ["drop", dropHandler];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region src/file/file-paste-handler.ts
|
|
52
|
-
function defineFilePasteHandler(handler) {
|
|
53
|
-
return defineFacetPayload(facet, [handler]);
|
|
54
|
-
}
|
|
55
|
-
function getFiles(event) {
|
|
56
|
-
return Array.from(event.clipboardData?.files ?? []);
|
|
57
|
-
}
|
|
58
|
-
const facet = defineFacet({
|
|
59
|
-
parent: editorEventFacet,
|
|
60
|
-
singleton: true,
|
|
61
|
-
reducer: (handlers) => {
|
|
62
|
-
const pasteHandler = (view, event) => {
|
|
63
|
-
return handleEvent(view, event, handlers, getFiles);
|
|
64
|
-
};
|
|
65
|
-
return ["paste", pasteHandler];
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
//#endregion
|
|
70
|
-
//#region src/file/file-upload.ts
|
|
71
|
-
/**
|
|
72
|
-
* A class that represents a upload task.
|
|
73
|
-
*/
|
|
74
|
-
var UploadTask = class {
|
|
75
|
-
/**
|
|
76
|
-
* Creates a new upload task. You can find the upload task by its object URL
|
|
77
|
-
* later using `UploadTask.get()`.
|
|
78
|
-
*
|
|
79
|
-
* @param options - The options for the upload task.
|
|
80
|
-
*/
|
|
81
|
-
constructor({ file, uploader }) {
|
|
82
|
-
this.done = false;
|
|
83
|
-
this.subscribers = [];
|
|
84
|
-
this.objectURL = URL.createObjectURL(file);
|
|
85
|
-
this.finished = new Promise((resolve, reject) => {
|
|
86
|
-
const maybePromise = uploader({
|
|
87
|
-
file,
|
|
88
|
-
onProgress: (progress) => {
|
|
89
|
-
for (const subscriber of this.subscribers) subscriber(progress);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
Promise.resolve(maybePromise).then((result) => {
|
|
93
|
-
this.done = true;
|
|
94
|
-
URL.revokeObjectURL(this.objectURL);
|
|
95
|
-
resolve(result);
|
|
96
|
-
}, (error) => {
|
|
97
|
-
this.done = true;
|
|
98
|
-
reject(new Error("[prosekit] Failed to upload file", { cause: error }));
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
store.set(this.objectURL, this);
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Subscribes to progress updates. Returns a function to unsubscribe.
|
|
105
|
-
*/
|
|
106
|
-
subscribeProgress(callback) {
|
|
107
|
-
this.subscribers.push(callback);
|
|
108
|
-
return () => {
|
|
109
|
-
this.subscribers = this.subscribers.filter((subscriber) => subscriber !== callback);
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Finds an upload task by its object URL.
|
|
114
|
-
*/
|
|
115
|
-
static get(objectURL) {
|
|
116
|
-
return store.get(objectURL);
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Deletes an upload task by its object URL.
|
|
120
|
-
*/
|
|
121
|
-
static delete(objectURL) {
|
|
122
|
-
store.delete(objectURL);
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
const store = /* @__PURE__ */ new Map();
|
|
126
|
-
|
|
127
|
-
//#endregion
|
|
128
|
-
export { UploadTask, defineFileDropHandler, defineFilePasteHandler };
|
|
129
|
-
//# sourceMappingURL=prosekit-extensions-file.js.map
|
|
3
|
+
export { UploadTask, defineFileDropHandler, defineFilePasteHandler };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-hard-break.d.ts","names":[],"sources":["../src/hard-break/hard-break-commands.ts","../src/hard-break/hard-break-spec.ts","../src/hard-break/hard-break.ts","../src/hard-break/hard-break-keymap.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAUY,KAAA,0BAAA,GAA6B,SAAA,CAAA;EAgBzB,QAAA,EAAA
|
|
1
|
+
{"version":3,"file":"prosekit-extensions-hard-break.d.ts","names":[],"sources":["../src/hard-break/hard-break-commands.ts","../src/hard-break/hard-break-spec.ts","../src/hard-break/hard-break.ts","../src/hard-break/hard-break-keymap.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAUY,KAAA,0BAAA,GAA6B,SAAA,CAAA;EAgBzB,QAAA,EAAA;;;;;ACRhB;;iBDQgB,uBAAA,CAAA,GAA2B;;;;;;AAhB/B,KCDA,sBAAA,GAAyB,SDCI,CAAA;EAgBzB,KAAA,EAAA;eCfD;;;AAFf;;;AAAqC,iBASrB,mBAAA,CAAA,CATqB,EASE,sBATF;;;;;ADCrC;AAgBgB,KERJ,kBAAA,GAAqB,KFQM,CAAA,CEPpC,wBAAwB;ADV3B;;;AAAqC,iBCgBrB,eAAA,CAAA,CDhBqB,ECgBF,kBDhBE;;;;;;iBECrB,qBAAA,CAAA,GAAyB"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FileDropHandlerOptions, FilePasteHandlerOptions, UploadTask, Uploader } from "./index-DY6lIIYV.js";
|
|
2
|
+
import { Extension, PlainExtension, Union } from "@prosekit/core";
|
|
3
|
+
import { Command } from "@prosekit/pm/state";
|
|
2
4
|
|
|
3
5
|
//#region src/image/image-spec.d.ts
|
|
4
|
-
|
|
5
6
|
/**
|
|
6
7
|
* @public
|
|
7
8
|
*/
|
|
@@ -32,6 +33,13 @@ type ImageCommandsExtension = Extension<{
|
|
|
32
33
|
insertImage: [attrs?: ImageAttrs];
|
|
33
34
|
};
|
|
34
35
|
}>;
|
|
36
|
+
/**
|
|
37
|
+
* Returns a command that inserts an image node with the given attributes at the
|
|
38
|
+
* current selection position.
|
|
39
|
+
*
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
declare function insertImage(attrs?: ImageAttrs): Command;
|
|
35
43
|
/**
|
|
36
44
|
* @internal
|
|
37
45
|
*/
|
|
@@ -47,5 +55,73 @@ type ImageExtension = Union<[ImageSpecExtension, ImageCommandsExtension]>;
|
|
|
47
55
|
*/
|
|
48
56
|
declare function defineImage(): ImageExtension;
|
|
49
57
|
//#endregion
|
|
50
|
-
|
|
58
|
+
//#region src/image/image-upload-handler.d.ts
|
|
59
|
+
/**
|
|
60
|
+
* A predicate to determine if the pasted file should be uploaded and inserted as an image.
|
|
61
|
+
*/
|
|
62
|
+
type ImageCanPastePredicate = (options: FilePasteHandlerOptions) => boolean;
|
|
63
|
+
/**
|
|
64
|
+
* A predicate to determine if the dropped file should be uploaded and inserted as an image.
|
|
65
|
+
*/
|
|
66
|
+
type ImageCanDropPredicate = (options: FileDropHandlerOptions) => boolean;
|
|
67
|
+
/**
|
|
68
|
+
* A handler to be called when an error occurs during the upload.
|
|
69
|
+
*/
|
|
70
|
+
type ImageUploadErrorHandler = (options: ImageUploadErrorHandlerOptions) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Options for the {@link ImageUploadErrorHandler} callback.
|
|
73
|
+
*/
|
|
74
|
+
interface ImageUploadErrorHandlerOptions {
|
|
75
|
+
/**
|
|
76
|
+
* The file that was uploaded.
|
|
77
|
+
*/
|
|
78
|
+
file: File;
|
|
79
|
+
/**
|
|
80
|
+
* The error that occurred during the upload.
|
|
81
|
+
*/
|
|
82
|
+
error: unknown;
|
|
83
|
+
/**
|
|
84
|
+
* The upload task that was used to upload the file.
|
|
85
|
+
*/
|
|
86
|
+
uploadTask: UploadTask<string>;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Options for {@link defineImageUploadHandler}.
|
|
90
|
+
*/
|
|
91
|
+
interface ImageUploadHandlerOptions {
|
|
92
|
+
/**
|
|
93
|
+
* The uploader used to upload the file. It should return a promise that
|
|
94
|
+
* resolves to the URL of the uploaded image.
|
|
95
|
+
*/
|
|
96
|
+
uploader: Uploader<string>;
|
|
97
|
+
/**
|
|
98
|
+
* A predicate to determine if the pasted file should be uploaded and inserted as an image.
|
|
99
|
+
* If not provided, it defaults to only allowing paste of files with a content type starting with `image/`.
|
|
100
|
+
*/
|
|
101
|
+
canPaste?: ImageCanPastePredicate;
|
|
102
|
+
/**
|
|
103
|
+
* A predicate to determine if the dropped file should be uploaded and inserted as an image.
|
|
104
|
+
* If not provided, it defaults to only allowing drop of files with a content type starting with `image/`.
|
|
105
|
+
*/
|
|
106
|
+
canDrop?: ImageCanDropPredicate;
|
|
107
|
+
/**
|
|
108
|
+
* A handler to be called when an error occurs during the upload.
|
|
109
|
+
* If not provided, it defaults to logging the error to the console.
|
|
110
|
+
*/
|
|
111
|
+
onError?: ImageUploadErrorHandler;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Returns an extension that handles image file uploads when pasting or dropping
|
|
115
|
+
* images into the editor.
|
|
116
|
+
*
|
|
117
|
+
* @param options
|
|
118
|
+
*/
|
|
119
|
+
declare function defineImageUploadHandler({
|
|
120
|
+
uploader,
|
|
121
|
+
canPaste,
|
|
122
|
+
canDrop,
|
|
123
|
+
onError
|
|
124
|
+
}: ImageUploadHandlerOptions): PlainExtension;
|
|
125
|
+
//#endregion
|
|
126
|
+
export { type ImageAttrs, type ImageCanDropPredicate, type ImageCanPastePredicate, type ImageCommandsExtension, type ImageExtension, type ImageSpecExtension, type ImageUploadErrorHandler, type ImageUploadErrorHandlerOptions, type ImageUploadHandlerOptions, defineImage, defineImageCommands, defineImageSpec, defineImageUploadHandler, insertImage };
|
|
51
127
|
//# sourceMappingURL=prosekit-extensions-image.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-image.d.ts","names":[],"sources":["../src/image/image-spec.ts","../src/image/image-commands.ts","../src/image/image.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prosekit-extensions-image.d.ts","names":[],"sources":["../src/image/image-spec.ts","../src/image/image-commands.ts","../src/image/image.ts","../src/image/image-upload-handler.ts"],"sourcesContent":[],"mappings":";;;;;;;;UAQiB,UAAA;EAAA,GAAA,CAAA,EAAA,MAAA,GAAU,IAAA;EASf,KAAA,CAAA,EAAA,MAAA,GAAA,IAAkB;EAAA,MAAA,CAAA,EAAA,MAAA,GAAA,IAAA;;;;AAS9B;KATY,kBAAA,GAAqB;;WAEtB;ECPC,CAAA;CAAsB,CAAA;;;;AAYlB,iBDEA,eAAA,CAAA,CCFW,EDEQ,kBCFR;;;;;ADhB3B;AASY,KCLA,sBAAA,GAAyB,SDKP,CAAA;EAAA,QAAA,EAAA;IAEnB,WAAA,EAAA,CAAA,KAAA,GCLe,UDKf,CAAA;;CAF+B,CAAA;AAS1C;;;;ACdA;;AAE0B,iBAUV,WAAA,CAVU,KAAA,CAAA,EAUU,UAVV,CAAA,EAUuB,OAVvB;;;AAU1B;AAA2B,iBAOX,mBAAA,CAAA,CAPW,EAOY,sBAPZ;;;;;ADhB3B;AASY,KEAA,cAAA,GAAiB,KFAC,CAAA,CEAM,kBFAN,EEA0B,sBFA1B,CAAA,CAAA;;;;AAAY,iBEK1B,WAAA,CAAA,CFL0B,EEKX,cFLW;;;;;;AATzB,KGgBL,sBAAA,GHhBe,CAAA,OAAA,EGgBoB,uBHhBpB,EAAA,GAAA,OAAA;AAS3B;;;AAAiC,KGYrB,qBAAA,GHZqB,CAAA,OAAA,EGYa,sBHZb,EAAA,GAAA,OAAA;;AASjC;;KGQY,uBAAA,aAAoC;;AFtBhD;;AAE0B,UEyBT,8BAAA,CFzBS;;;AAU1B;EAA2B,IAAA,EEmBnB,IFnBmB;;;;EAOX,KAAA,EAAA,OAAA;;;;ECdJ,UAAA,ECkCE,UDlCY,CAAA,MAAA,CAAA;;;;;AAAQ,UCwCjB,yBAAA,CDxCiB;EAKlB;;;;ECEJ,QAAA,EAsCA,QAtCA,CAAA,MAAsB,CAAA;EAKtB;AAKZ;AAKA;;UAIQ,CAAA,EAwBK,sBAxBL;;;AAcR;;SAKY,CAAA,EAUA,qBAVA;;;;;EAiCI,OAAA,CAAA,EAlBJ,uBAkB4B;;;;;;;;AAKK,iBAL7B,wBAAA,CAK6B;EAAA,QAAA;EAAA,QAAA;EAAA,OAAA;EAAA;AAAA,CAAA,EAA1C,yBAA0C,CAAA,EAAd,cAAc"}
|
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UploadTask, defineFileDropHandler, defineFilePasteHandler } from "./file-DVUhe5KJ.js";
|
|
2
|
+
import { ProseKitError, defineCommands, defineNodeSpec, insertNode, union } from "@prosekit/core";
|
|
2
3
|
|
|
3
4
|
//#region src/image/image-commands.ts
|
|
4
5
|
/**
|
|
6
|
+
* Returns a command that inserts an image node with the given attributes at the
|
|
7
|
+
* current selection position.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
function insertImage(attrs) {
|
|
12
|
+
return insertNode({
|
|
13
|
+
type: "image",
|
|
14
|
+
attrs
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
5
18
|
* @internal
|
|
6
19
|
*/
|
|
7
20
|
function defineImageCommands() {
|
|
8
|
-
return defineCommands({ insertImage
|
|
9
|
-
return insertNode({
|
|
10
|
-
type: "image",
|
|
11
|
-
attrs
|
|
12
|
-
});
|
|
13
|
-
} });
|
|
21
|
+
return defineCommands({ insertImage });
|
|
14
22
|
}
|
|
15
23
|
|
|
16
24
|
//#endregion
|
|
@@ -76,5 +84,77 @@ function defineImage() {
|
|
|
76
84
|
}
|
|
77
85
|
|
|
78
86
|
//#endregion
|
|
79
|
-
|
|
87
|
+
//#region src/image/image-upload-handler.ts
|
|
88
|
+
function defaultCanUpload({ file }) {
|
|
89
|
+
return file.type.startsWith("image/");
|
|
90
|
+
}
|
|
91
|
+
const defaultOnError = ({ error }) => {
|
|
92
|
+
console.error("[prosekit] Failed to upload image:", error);
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Returns an extension that handles image file uploads when pasting or dropping
|
|
96
|
+
* images into the editor.
|
|
97
|
+
*
|
|
98
|
+
* @param options
|
|
99
|
+
*/
|
|
100
|
+
function defineImageUploadHandler({ uploader, canPaste = defaultCanUpload, canDrop = defaultCanUpload, onError = defaultOnError }) {
|
|
101
|
+
const handleInsert = (view, file, pos) => {
|
|
102
|
+
const uploadTask = new UploadTask({
|
|
103
|
+
file,
|
|
104
|
+
uploader
|
|
105
|
+
});
|
|
106
|
+
const objectURL = uploadTask.objectURL;
|
|
107
|
+
const attrs = { src: objectURL };
|
|
108
|
+
uploadTask.finished.then((resultURL) => {
|
|
109
|
+
if (view.isDestroyed) return;
|
|
110
|
+
else if (typeof resultURL !== "string") {
|
|
111
|
+
const error = new ProseKitError(`Unexpected upload result. Expected a string but got ${typeof resultURL}`);
|
|
112
|
+
onError({
|
|
113
|
+
file,
|
|
114
|
+
error,
|
|
115
|
+
uploadTask
|
|
116
|
+
});
|
|
117
|
+
} else {
|
|
118
|
+
replaceImageURL(view, objectURL, resultURL);
|
|
119
|
+
UploadTask.delete(objectURL);
|
|
120
|
+
}
|
|
121
|
+
}).catch((error) => {
|
|
122
|
+
onError({
|
|
123
|
+
file,
|
|
124
|
+
error,
|
|
125
|
+
uploadTask
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
return insertNode({
|
|
129
|
+
type: "image",
|
|
130
|
+
attrs,
|
|
131
|
+
pos
|
|
132
|
+
})(view.state, view.dispatch, view);
|
|
133
|
+
};
|
|
134
|
+
const handlePaste = (options) => {
|
|
135
|
+
if (!canPaste(options)) return false;
|
|
136
|
+
return handleInsert(options.view, options.file);
|
|
137
|
+
};
|
|
138
|
+
const handleDrop = (options) => {
|
|
139
|
+
if (!canDrop(options)) return false;
|
|
140
|
+
return handleInsert(options.view, options.file, options.pos);
|
|
141
|
+
};
|
|
142
|
+
return union(defineFilePasteHandler(handlePaste), defineFileDropHandler(handleDrop));
|
|
143
|
+
}
|
|
144
|
+
function replaceImageURL(view, oldURL, newURL) {
|
|
145
|
+
const positions = [];
|
|
146
|
+
view.state.doc.descendants((node, pos) => {
|
|
147
|
+
if (node.type.name === "image") {
|
|
148
|
+
if (node.attrs.src === oldURL) positions.push(pos);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
if (positions.length > 0) {
|
|
152
|
+
const tr = view.state.tr;
|
|
153
|
+
for (const pos of positions) tr.setNodeAttribute(pos, "src", newURL);
|
|
154
|
+
view.dispatch(tr);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
//#endregion
|
|
159
|
+
export { defineImage, defineImageCommands, defineImageSpec, defineImageUploadHandler, insertImage };
|
|
80
160
|
//# sourceMappingURL=prosekit-extensions-image.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-image.js","names":["width: number | null","height: number | null"],"sources":["../src/image/image-commands.ts","../src/image/image-spec.ts","../src/image/image.ts"],"sourcesContent":["import {\n defineCommands,\n insertNode,\n type Extension,\n} from '@prosekit/core'\n\nimport type { ImageAttrs } from './image-spec'\n\n/**\n * @internal\n */\nexport type ImageCommandsExtension = Extension<{\n Commands: {\n insertImage: [attrs?: ImageAttrs]\n }\n}>\n\n/**\n * @internal\n */\nexport function defineImageCommands(): ImageCommandsExtension {\n return defineCommands({\n insertImage: (attrs?: ImageAttrs) => {\n return insertNode({ type: 'image', attrs })\n },\n })\n}\n","import {\n defineNodeSpec,\n type Extension,\n} from '@prosekit/core'\n\n/**\n * @public\n */\nexport interface ImageAttrs {\n src?: string | null\n width?: number | null\n height?: number | null\n}\n\n/**\n * @internal\n */\nexport type ImageSpecExtension = Extension<{\n Nodes: {\n image: ImageAttrs\n }\n}>\n\n/**\n * @internal\n */\nexport function defineImageSpec(): ImageSpecExtension {\n return defineNodeSpec({\n name: 'image',\n attrs: {\n src: { default: null, validate: 'string|null' },\n width: { default: null, validate: 'number|null' },\n height: { default: null, validate: 'number|null' },\n },\n group: 'block',\n defining: true,\n draggable: true,\n parseDOM: [\n {\n tag: 'img[src]',\n getAttrs: (element): ImageAttrs => {\n if (typeof element === 'string') {\n return { src: null }\n }\n\n const src = element.getAttribute('src') || null\n\n let width: number | null = null\n let height: number | null = null\n\n const rect = element.getBoundingClientRect()\n if (rect.width > 0 && rect.height > 0) {\n width = rect.width\n height = rect.height\n } else if (\n element instanceof HTMLImageElement\n && element.naturalWidth > 0\n && element.naturalHeight > 0\n ) {\n width = element.naturalWidth\n height = element.naturalHeight\n }\n return { src, width, height }\n },\n },\n ],\n toDOM(node) {\n const attrs = node.attrs as ImageAttrs\n return ['img', attrs]\n },\n })\n}\n","import {\n union,\n type Union,\n} from '@prosekit/core'\n\nimport {\n defineImageCommands,\n type ImageCommandsExtension,\n} from './image-commands'\nimport {\n defineImageSpec,\n type ImageSpecExtension,\n} from './image-spec'\n\n/**\n * @internal\n */\nexport type ImageExtension = Union<[ImageSpecExtension, ImageCommandsExtension]>\n\n/**\n * @public\n */\nexport function defineImage(): ImageExtension {\n return union(defineImageSpec(), defineImageCommands())\n}\n"],"mappings":";;;;;;AAoBA,SAAgB,sBAA8C;AAC5D,QAAO,eAAe,EACpB,cAAc,UAAuB;AACnC,SAAO,WAAW;GAAE,MAAM;GAAS;GAAO,CAAC;IAE9C,CAAC;;;;;;;;ACCJ,SAAgB,kBAAsC;AACpD,QAAO,eAAe;EACpB,MAAM;EACN,OAAO;GACL,KAAK;IAAE,SAAS;IAAM,UAAU;IAAe;GAC/C,OAAO;IAAE,SAAS;IAAM,UAAU;IAAe;GACjD,QAAQ;IAAE,SAAS;IAAM,UAAU;IAAe;GACnD;EACD,OAAO;EACP,UAAU;EACV,WAAW;EACX,UAAU,CACR;GACE,KAAK;GACL,WAAW,YAAwB;AACjC,QAAI,OAAO,YAAY,SACrB,QAAO,EAAE,KAAK,MAAM;IAGtB,MAAM,MAAM,QAAQ,aAAa,MAAM,IAAI;IAE3C,IAAIA,QAAuB;IAC3B,IAAIC,SAAwB;IAE5B,MAAM,OAAO,QAAQ,uBAAuB;AAC5C,QAAI,KAAK,QAAQ,KAAK,KAAK,SAAS,GAAG;AACrC,aAAQ,KAAK;AACb,cAAS,KAAK;eAEd,mBAAmB,oBAChB,QAAQ,eAAe,KACvB,QAAQ,gBAAgB,GAC3B;AACA,aAAQ,QAAQ;AAChB,cAAS,QAAQ;;AAEnB,WAAO;KAAE;KAAK;KAAO;KAAQ;;GAEhC,CACF;EACD,MAAM,MAAM;AAEV,UAAO,CAAC,OADM,KAAK,MACE;;EAExB,CAAC;;;;;;;;AChDJ,SAAgB,cAA8B;AAC5C,QAAO,MAAM,iBAAiB,EAAE,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"prosekit-extensions-image.js","names":["width: number | null","height: number | null","defaultOnError: ImageUploadErrorHandler","attrs: ImageAttrs","handlePaste: FilePasteHandler","handleDrop: FileDropHandler","positions: number[]"],"sources":["../src/image/image-commands.ts","../src/image/image-spec.ts","../src/image/image.ts","../src/image/image-upload-handler.ts"],"sourcesContent":["import {\n defineCommands,\n insertNode,\n type Extension,\n} from '@prosekit/core'\nimport type { Command } from '@prosekit/pm/state'\n\nimport type { ImageAttrs } from './image-spec'\n\n/**\n * @internal\n */\nexport type ImageCommandsExtension = Extension<{\n Commands: {\n insertImage: [attrs?: ImageAttrs]\n }\n}>\n\n/**\n * Returns a command that inserts an image node with the given attributes at the\n * current selection position.\n *\n * @public\n */\nexport function insertImage(attrs?: ImageAttrs): Command {\n return insertNode({ type: 'image', attrs })\n}\n\n/**\n * @internal\n */\nexport function defineImageCommands(): ImageCommandsExtension {\n return defineCommands({\n insertImage,\n })\n}\n","import {\n defineNodeSpec,\n type Extension,\n} from '@prosekit/core'\n\n/**\n * @public\n */\nexport interface ImageAttrs {\n src?: string | null\n width?: number | null\n height?: number | null\n}\n\n/**\n * @internal\n */\nexport type ImageSpecExtension = Extension<{\n Nodes: {\n image: ImageAttrs\n }\n}>\n\n/**\n * @internal\n */\nexport function defineImageSpec(): ImageSpecExtension {\n return defineNodeSpec({\n name: 'image',\n attrs: {\n src: { default: null, validate: 'string|null' },\n width: { default: null, validate: 'number|null' },\n height: { default: null, validate: 'number|null' },\n },\n group: 'block',\n defining: true,\n draggable: true,\n parseDOM: [\n {\n tag: 'img[src]',\n getAttrs: (element): ImageAttrs => {\n if (typeof element === 'string') {\n return { src: null }\n }\n\n const src = element.getAttribute('src') || null\n\n let width: number | null = null\n let height: number | null = null\n\n const rect = element.getBoundingClientRect()\n if (rect.width > 0 && rect.height > 0) {\n width = rect.width\n height = rect.height\n } else if (\n element instanceof HTMLImageElement\n && element.naturalWidth > 0\n && element.naturalHeight > 0\n ) {\n width = element.naturalWidth\n height = element.naturalHeight\n }\n return { src, width, height }\n },\n },\n ],\n toDOM(node) {\n const attrs = node.attrs as ImageAttrs\n return ['img', attrs]\n },\n })\n}\n","import {\n union,\n type Union,\n} from '@prosekit/core'\n\nimport {\n defineImageCommands,\n type ImageCommandsExtension,\n} from './image-commands'\nimport {\n defineImageSpec,\n type ImageSpecExtension,\n} from './image-spec'\n\n/**\n * @internal\n */\nexport type ImageExtension = Union<[ImageSpecExtension, ImageCommandsExtension]>\n\n/**\n * @public\n */\nexport function defineImage(): ImageExtension {\n return union(defineImageSpec(), defineImageCommands())\n}\n","import {\n insertNode,\n ProseKitError,\n union,\n type PlainExtension,\n} from '@prosekit/core'\nimport type { EditorView } from '@prosekit/pm/view'\n\nimport {\n defineFileDropHandler,\n defineFilePasteHandler,\n UploadTask,\n type FileDropHandler,\n type FileDropHandlerOptions,\n type FilePasteHandler,\n type FilePasteHandlerOptions,\n type Uploader,\n} from '../file'\n\nimport type { ImageAttrs } from './image-spec'\n\n/**\n * A predicate to determine if the pasted file should be uploaded and inserted as an image.\n */\nexport type ImageCanPastePredicate = (options: FilePasteHandlerOptions) => boolean\n\n/**\n * A predicate to determine if the dropped file should be uploaded and inserted as an image.\n */\nexport type ImageCanDropPredicate = (options: FileDropHandlerOptions) => boolean\n\n/**\n * A handler to be called when an error occurs during the upload.\n */\nexport type ImageUploadErrorHandler = (options: ImageUploadErrorHandlerOptions) => void\n\n/**\n * Options for the {@link ImageUploadErrorHandler} callback.\n */\nexport interface ImageUploadErrorHandlerOptions {\n /**\n * The file that was uploaded.\n */\n file: File\n /**\n * The error that occurred during the upload.\n */\n error: unknown\n /**\n * The upload task that was used to upload the file.\n */\n uploadTask: UploadTask<string>\n}\n\n/**\n * Options for {@link defineImageUploadHandler}.\n */\nexport interface ImageUploadHandlerOptions {\n /**\n * The uploader used to upload the file. It should return a promise that\n * resolves to the URL of the uploaded image.\n */\n uploader: Uploader<string>\n /**\n * A predicate to determine if the pasted file should be uploaded and inserted as an image.\n * If not provided, it defaults to only allowing paste of files with a content type starting with `image/`.\n */\n canPaste?: ImageCanPastePredicate\n /**\n * A predicate to determine if the dropped file should be uploaded and inserted as an image.\n * If not provided, it defaults to only allowing drop of files with a content type starting with `image/`.\n */\n canDrop?: ImageCanDropPredicate\n /**\n * A handler to be called when an error occurs during the upload.\n * If not provided, it defaults to logging the error to the console.\n */\n onError?: ImageUploadErrorHandler\n}\n\nfunction defaultCanUpload({ file }: { file: File }): boolean {\n // Only handle image files by default\n return file.type.startsWith('image/')\n}\n\nconst defaultOnError: ImageUploadErrorHandler = ({ error }) => {\n console.error('[prosekit] Failed to upload image:', error)\n}\n\n/**\n * Returns an extension that handles image file uploads when pasting or dropping\n * images into the editor.\n *\n * @param options\n */\nexport function defineImageUploadHandler({\n uploader,\n canPaste = defaultCanUpload,\n canDrop = defaultCanUpload,\n onError = defaultOnError,\n}: ImageUploadHandlerOptions): PlainExtension {\n const handleInsert = (view: EditorView, file: File, pos?: number): boolean => {\n const uploadTask = new UploadTask({ file, uploader })\n const objectURL = uploadTask.objectURL\n const attrs: ImageAttrs = { src: objectURL }\n uploadTask.finished.then((resultURL) => {\n if (view.isDestroyed) {\n return\n } else if (typeof resultURL !== 'string') {\n const error = new ProseKitError(`Unexpected upload result. Expected a string but got ${typeof resultURL}`)\n onError({ file, error, uploadTask })\n } else {\n replaceImageURL(view, objectURL, resultURL)\n UploadTask.delete(objectURL)\n }\n }).catch((error) => {\n onError({ file, error, uploadTask })\n })\n const command = insertNode({ type: 'image', attrs, pos })\n return command(view.state, view.dispatch, view)\n }\n\n const handlePaste: FilePasteHandler = (options) => {\n if (!canPaste(options)) return false\n return handleInsert(options.view, options.file)\n }\n\n const handleDrop: FileDropHandler = (options) => {\n if (!canDrop(options)) return false\n return handleInsert(options.view, options.file, options.pos)\n }\n\n return union(\n defineFilePasteHandler(handlePaste),\n defineFileDropHandler(handleDrop),\n )\n}\n\nfunction replaceImageURL(view: EditorView, oldURL: string, newURL: string) {\n const positions: number[] = []\n view.state.doc.descendants((node, pos) => {\n if (node.type.name === 'image') {\n const attrs = node.attrs as ImageAttrs\n if (attrs.src === oldURL) {\n positions.push(pos)\n }\n }\n })\n if (positions.length > 0) {\n const tr = view.state.tr\n for (const pos of positions) {\n tr.setNodeAttribute(pos, 'src', newURL)\n }\n view.dispatch(tr)\n }\n}\n"],"mappings":";;;;;;;;;;AAwBA,SAAgB,YAAY,OAA6B;AACvD,QAAO,WAAW;EAAE,MAAM;EAAS;EAAO,CAAC;;;;;AAM7C,SAAgB,sBAA8C;AAC5D,QAAO,eAAe,EACpB,aACD,CAAC;;;;;;;;ACRJ,SAAgB,kBAAsC;AACpD,QAAO,eAAe;EACpB,MAAM;EACN,OAAO;GACL,KAAK;IAAE,SAAS;IAAM,UAAU;IAAe;GAC/C,OAAO;IAAE,SAAS;IAAM,UAAU;IAAe;GACjD,QAAQ;IAAE,SAAS;IAAM,UAAU;IAAe;GACnD;EACD,OAAO;EACP,UAAU;EACV,WAAW;EACX,UAAU,CACR;GACE,KAAK;GACL,WAAW,YAAwB;AACjC,QAAI,OAAO,YAAY,SACrB,QAAO,EAAE,KAAK,MAAM;IAGtB,MAAM,MAAM,QAAQ,aAAa,MAAM,IAAI;IAE3C,IAAIA,QAAuB;IAC3B,IAAIC,SAAwB;IAE5B,MAAM,OAAO,QAAQ,uBAAuB;AAC5C,QAAI,KAAK,QAAQ,KAAK,KAAK,SAAS,GAAG;AACrC,aAAQ,KAAK;AACb,cAAS,KAAK;eAEd,mBAAmB,oBAChB,QAAQ,eAAe,KACvB,QAAQ,gBAAgB,GAC3B;AACA,aAAQ,QAAQ;AAChB,cAAS,QAAQ;;AAEnB,WAAO;KAAE;KAAK;KAAO;KAAQ;;GAEhC,CACF;EACD,MAAM,MAAM;AAEV,UAAO,CAAC,OADM,KAAK,MACE;;EAExB,CAAC;;;;;;;;AChDJ,SAAgB,cAA8B;AAC5C,QAAO,MAAM,iBAAiB,EAAE,qBAAqB,CAAC;;;;;ACyDxD,SAAS,iBAAiB,EAAE,QAAiC;AAE3D,QAAO,KAAK,KAAK,WAAW,SAAS;;AAGvC,MAAMC,kBAA2C,EAAE,YAAY;AAC7D,SAAQ,MAAM,sCAAsC,MAAM;;;;;;;;AAS5D,SAAgB,yBAAyB,EACvC,UACA,WAAW,kBACX,UAAU,kBACV,UAAU,kBACkC;CAC5C,MAAM,gBAAgB,MAAkB,MAAY,QAA0B;EAC5E,MAAM,aAAa,IAAI,WAAW;GAAE;GAAM;GAAU,CAAC;EACrD,MAAM,YAAY,WAAW;EAC7B,MAAMC,QAAoB,EAAE,KAAK,WAAW;AAC5C,aAAW,SAAS,MAAM,cAAc;AACtC,OAAI,KAAK,YACP;YACS,OAAO,cAAc,UAAU;IACxC,MAAM,QAAQ,IAAI,cAAc,uDAAuD,OAAO,YAAY;AAC1G,YAAQ;KAAE;KAAM;KAAO;KAAY,CAAC;UAC/B;AACL,oBAAgB,MAAM,WAAW,UAAU;AAC3C,eAAW,OAAO,UAAU;;IAE9B,CAAC,OAAO,UAAU;AAClB,WAAQ;IAAE;IAAM;IAAO;IAAY,CAAC;IACpC;AAEF,SADgB,WAAW;GAAE,MAAM;GAAS;GAAO;GAAK,CAAC,CAC1C,KAAK,OAAO,KAAK,UAAU,KAAK;;CAGjD,MAAMC,eAAiC,YAAY;AACjD,MAAI,CAAC,SAAS,QAAQ,CAAE,QAAO;AAC/B,SAAO,aAAa,QAAQ,MAAM,QAAQ,KAAK;;CAGjD,MAAMC,cAA+B,YAAY;AAC/C,MAAI,CAAC,QAAQ,QAAQ,CAAE,QAAO;AAC9B,SAAO,aAAa,QAAQ,MAAM,QAAQ,MAAM,QAAQ,IAAI;;AAG9D,QAAO,MACL,uBAAuB,YAAY,EACnC,sBAAsB,WAAW,CAClC;;AAGH,SAAS,gBAAgB,MAAkB,QAAgB,QAAgB;CACzE,MAAMC,YAAsB,EAAE;AAC9B,MAAK,MAAM,IAAI,aAAa,MAAM,QAAQ;AACxC,MAAI,KAAK,KAAK,SAAS,SAErB;OADc,KAAK,MACT,QAAQ,OAChB,WAAU,KAAK,IAAI;;GAGvB;AACF,KAAI,UAAU,SAAS,GAAG;EACxB,MAAM,KAAK,KAAK,MAAM;AACtB,OAAK,MAAM,OAAO,UAChB,IAAG,iBAAiB,KAAK,OAAO,OAAO;AAEzC,OAAK,SAAS,GAAG"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineInputRule } from "./input-rule-B17tpW4m.js";
|
|
2
2
|
import { defineEnterRule } from "./enter-rule-RdhEA900.js";
|
|
3
|
-
import { defineMarkRule } from "./mark-rule-
|
|
4
|
-
import { defineMarkPasteRule } from "./paste-rule-
|
|
3
|
+
import { defineMarkRule } from "./mark-rule-CGmswjQ_.js";
|
|
4
|
+
import { defineMarkPasteRule } from "./paste-rule-BIztzELg.js";
|
|
5
5
|
import { addMark, defineCommands, defineMarkSpec, expandMark, removeMark, toggleMark, union } from "@prosekit/core";
|
|
6
6
|
import { InputRule } from "@prosekit/pm/inputrules";
|
|
7
7
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { defineInputRule } from "./input-rule-B17tpW4m.js";
|
|
2
|
-
import { defineDropIndicator } from "./drop-indicator-
|
|
2
|
+
import { defineDropIndicator } from "./drop-indicator-E7nCfdnR.js";
|
|
3
3
|
import { defineClipboardSerializer, defineCommands, defineKeymap, defineNodeSpec, definePlugin, insertNode, union } from "@prosekit/core";
|
|
4
4
|
import { Plugin } from "@prosekit/pm/state";
|
|
5
5
|
import { chainCommands, deleteSelection } from "@prosekit/pm/commands";
|
|
6
|
-
import { isElementLike } from "@ocavue/utils";
|
|
7
6
|
import { ListDOMSerializer, createDedentListCommand, createIndentListCommand, createListEventPlugin, createListRenderingPlugin, createListSpec, createMoveListCommand, createSafariInputMethodWorkaroundPlugin, createSplitListCommand, createToggleCollapsedCommand, createToggleListCommand, createUnwrapListCommand, createWrapInListCommand, deleteCommand, enterCommand, joinCollapsedListBackward, joinListElements, joinListUp, listInputRules, listToDOM, protectCollapsed, unwrapListSlice } from "prosemirror-flat-list";
|
|
7
|
+
import { isElementLike } from "@ocavue/utils";
|
|
8
8
|
|
|
9
9
|
//#region src/list/list-commands.ts
|
|
10
10
|
function insertList(attrs) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-extensions-paragraph.d.ts","names":[],"sources":["../src/paragraph/paragraph-commands.ts","../src/paragraph/paragraph-spec.ts","../src/paragraph/paragraph.ts","../src/paragraph/paragraph-keymap.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAUY,KAAA,0BAAA,GAA6B,SAAA,CAAA;EAgBzB,QAAA,EAAA
|
|
1
|
+
{"version":3,"file":"prosekit-extensions-paragraph.d.ts","names":[],"sources":["../src/paragraph/paragraph-commands.ts","../src/paragraph/paragraph-spec.ts","../src/paragraph/paragraph.ts","../src/paragraph/paragraph-keymap.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAUY,KAAA,0BAAA,GAA6B,SAAA,CAAA;EAgBzB,QAAA,EAAA;;;;;ACNhB;;iBDMgB,uBAAA,CAAA,GAA2B;;;;;;AAhB/B,KCDA,sBAAA,GAAyB,SDCI,CAAA;EAgBzB,KAAA,EAAA;eCfD;;;AAFf;;;;;AAWgB,iBAAA,mBAAA,CAAA,CAAuB,EAAA,sBAAsB;;;;;ADV7D;AAgBgB,KENJ,kBAAA,GAAqB,KFMM,CAAA,CENC,sBFMG,EENqB,0BFMK,CAAA,CAAA;;;;ACjBrE;;;;;AAWgB,iBCUA,eAAA,CAAA,CDVuB,ECUJ,kBDV0B;;;;;;iBEV7C,qBAAA,CAAA,GAAyB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./drop-indicator-
|
|
2
|
-
import { findTable } from "./table-
|
|
1
|
+
import "./drop-indicator-E7nCfdnR.js";
|
|
2
|
+
import { findTable } from "./table-BNwuK7xg.js";
|
|
3
3
|
import { definePlugin, isInCodeBlock, maybeRun } from "@prosekit/core";
|
|
4
4
|
import { Plugin, PluginKey } from "@prosekit/pm/state";
|
|
5
5
|
import { Decoration, DecorationSet } from "@prosekit/pm/view";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./drop-indicator-
|
|
2
|
-
import { defineTable, defineTableCellSpec, defineTableCommands, defineTableDropIndicator, defineTableHeaderCellSpec, defineTablePlugins, defineTableRowSpec, defineTableSpec, exitTable, findTable, insertTable, isCellSelection, moveTableColumn, moveTableRow, selectTable, selectTableCell, selectTableColumn, selectTableRow } from "./table-
|
|
1
|
+
import "./drop-indicator-E7nCfdnR.js";
|
|
2
|
+
import { defineTable, defineTableCellSpec, defineTableCommands, defineTableDropIndicator, defineTableHeaderCellSpec, defineTablePlugins, defineTableRowSpec, defineTableSpec, exitTable, findTable, insertTable, isCellSelection, moveTableColumn, moveTableRow, selectTable, selectTableCell, selectTableColumn, selectTableRow } from "./table-BNwuK7xg.js";
|
|
3
3
|
|
|
4
4
|
export { defineTable, defineTableCellSpec, defineTableCommands, defineTableDropIndicator, defineTableHeaderCellSpec, defineTablePlugins, defineTableRowSpec, defineTableSpec, exitTable, findTable, insertTable, isCellSelection, moveTableColumn, moveTableRow, selectTable, selectTableCell, selectTableColumn, selectTableRow };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { };
|
package/dist/{shiki-highlighter-chunk-DSPM0T27.d.ts → shiki-highlighter-chunk-Cwu1Jr9o.d.ts}
RENAMED
|
@@ -16,4 +16,4 @@ type HighlighterResult = {
|
|
|
16
16
|
declare function createOrGetHighlighter(options: HighlighterOptions): HighlighterResult;
|
|
17
17
|
//#endregion
|
|
18
18
|
export { HighlighterOptions, HighlighterResult, ShikiHighlighterOptions, createOrGetHighlighter };
|
|
19
|
-
//# sourceMappingURL=shiki-highlighter-chunk-
|
|
19
|
+
//# sourceMappingURL=shiki-highlighter-chunk-Cwu1Jr9o.d.ts.map
|
package/dist/{shiki-highlighter-chunk-DSPM0T27.d.ts.map → shiki-highlighter-chunk-Cwu1Jr9o.d.ts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shiki-highlighter-chunk-
|
|
1
|
+
{"version":3,"file":"shiki-highlighter-chunk-Cwu1Jr9o.d.ts","names":[],"sources":["../src/code-block/shiki-highlighter-chunk.ts"],"sourcesContent":[],"mappings":";;;UAeiB,uBAAA,SAAgC,0BAA0B,iBAAiB;AAA3E,UAEA,kBAAA,SAA2B,IAFH,CAEQ,uBAFR,EAAA,OAAA,GAAA,QAAA,CAAA,CAAA;EAAA,MAAA,EAG/B,YAH+B,EAAA;OAAkC,EAAA,CAIjE,eAJiE,GAI/C,eAJ+C,CAAA,EAAA;;AAA1B,KAwCrC,iBAAA,GAxCqC;EAAyB,WAAA,EA0CzD,WA1CyD;EAEzD,OAAA,CAAA,EAAA,SAAA;CAAmB,GAAA;aAAa,CAAA,EAAA,SAAA;SACvC,EA4CG,OA5CH,CAAA,IAAA,CAAA;;AACkB,iBA8CZ,sBAAA,CA9CY,OAAA,EA+CjB,kBA/CiB,CAAA,EAgDzB,iBAhDyB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { HighlighterOptions, HighlighterResult, ShikiHighlighterOptions, createOrGetHighlighter } from "./shiki-highlighter-chunk-
|
|
1
|
+
import { HighlighterOptions, HighlighterResult, ShikiHighlighterOptions, createOrGetHighlighter } from "./shiki-highlighter-chunk-Cwu1Jr9o.js";
|
|
2
2
|
export { HighlighterOptions, HighlighterResult, ShikiHighlighterOptions, createOrGetHighlighter };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineDropIndicator } from "./drop-indicator-
|
|
1
|
+
import { defineDropIndicator } from "./drop-indicator-E7nCfdnR.js";
|
|
2
2
|
import { defaultBlockAt, defineCommands, defineNodeSpec, definePlugin, getNodeType, insertNode, union } from "@prosekit/core";
|
|
3
3
|
import { TextSelection } from "@prosekit/pm/state";
|
|
4
4
|
import { CellSelection, TableMap, addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, columnResizing, deleteCellSelection, deleteColumn, deleteRow, deleteTable, findCellPos, findCellRange, findTable, mergeCells, moveTableColumn, moveTableRow, splitCell, tableEditing, tableNodes } from "prosemirror-tables";
|
|
@@ -294,4 +294,4 @@ function defineTable() {
|
|
|
294
294
|
|
|
295
295
|
//#endregion
|
|
296
296
|
export { defineTable, defineTableCellSpec, defineTableCommands, defineTableDropIndicator, defineTableHeaderCellSpec, defineTablePlugins, defineTableRowSpec, defineTableSpec, exitTable, findTable, insertTable, isCellSelection, moveTableColumn, moveTableRow, selectTable, selectTableCell, selectTableColumn, selectTableRow };
|
|
297
|
-
//# sourceMappingURL=table-
|
|
297
|
+
//# sourceMappingURL=table-BNwuK7xg.js.map
|