@cyberyozh/text-editor 0.5.0 → 0.5.1
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/editor.js +10 -4
- package/dist/editor.js.map +1 -1
- package/dist/editor.mjs +10 -4
- package/dist/editor.mjs.map +1 -1
- package/package.json +1 -1
- package/src/editor/handlers/insertion-handlers.test.ts +37 -0
- package/src/editor/handlers/insertion-handlers.ts +14 -9
- package/src/editor/handlers/markup-insertion.ts +9 -0
package/dist/editor.js
CHANGED
|
@@ -6964,6 +6964,12 @@ function applyUploadResultsToNodes(imagesToNodes, results) {
|
|
|
6964
6964
|
node.attrs.storageKey = result.storageKey;
|
|
6965
6965
|
});
|
|
6966
6966
|
}
|
|
6967
|
+
function shouldHandleInsertedFile(file, event) {
|
|
6968
|
+
if (!file) return false;
|
|
6969
|
+
event.preventDefault();
|
|
6970
|
+
event.stopPropagation();
|
|
6971
|
+
return file.type.startsWith("image/");
|
|
6972
|
+
}
|
|
6967
6973
|
|
|
6968
6974
|
// src/editor/handlers/insertion-handlers.ts
|
|
6969
6975
|
function useInsertionHandlers(imageHandlers) {
|
|
@@ -6975,9 +6981,7 @@ function useInsertionHandlers(imageHandlers) {
|
|
|
6975
6981
|
}
|
|
6976
6982
|
}, [insertedImage, activeDialog]);
|
|
6977
6983
|
function genericInsertionHandler(file, event) {
|
|
6978
|
-
event
|
|
6979
|
-
event.stopPropagation();
|
|
6980
|
-
if (!file || !file.type.startsWith("image/")) return;
|
|
6984
|
+
if (!file || !shouldHandleInsertedFile(file, event)) return;
|
|
6981
6985
|
if (!imageHandlers?.upload) return;
|
|
6982
6986
|
setInsertedImage(file);
|
|
6983
6987
|
openDialogCommand("image");
|
|
@@ -7013,7 +7017,9 @@ function useInsertionHandlers(imageHandlers) {
|
|
|
7013
7017
|
setDisabled(false);
|
|
7014
7018
|
});
|
|
7015
7019
|
} else {
|
|
7016
|
-
view.dispatch(
|
|
7020
|
+
view.dispatch(
|
|
7021
|
+
view.state.tr.replaceSelection(removeImagesFromSlice(slice))
|
|
7022
|
+
);
|
|
7017
7023
|
}
|
|
7018
7024
|
return true;
|
|
7019
7025
|
}
|