@limetech/lime-elements 38.13.0 → 38.13.2-dev.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/CHANGELOG.md +16 -0
- package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js +59 -9
- package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js.map +1 -1
- package/dist/collection/components/text-editor/prosemirror-adapter/plugins/image/inserter.js +59 -9
- package/dist/collection/components/text-editor/prosemirror-adapter/plugins/image/inserter.js.map +1 -1
- package/dist/esm/limel-prosemirror-adapter.entry.js +59 -9
- package/dist/esm/limel-prosemirror-adapter.entry.js.map +1 -1
- package/dist/lime-elements/lime-elements.esm.js +1 -1
- package/dist/lime-elements/{p-587f6b6d.entry.js → p-d5ac8f59.entry.js} +2 -2
- package/dist/lime-elements/p-d5ac8f59.entry.js.map +1 -0
- package/package.json +1 -1
- package/dist/lime-elements/p-587f6b6d.entry.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
## [38.13.2-dev.1](https://github.com/Lundalogik/lime-elements/compare/v38.13.1...v38.13.2-dev.1) (2025-05-23)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
* trigger release ([f9e216b](https://github.com/Lundalogik/lime-elements/commit/f9e216b7b035cf3fb6cebd204a0ab24793022402))
|
|
8
|
+
|
|
9
|
+
## [38.13.1](https://github.com/Lundalogik/lime-elements/compare/v38.13.0...v38.13.1) (2025-05-21)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
* **text-editor:** prevent Excel tables from being processed as images when pasted ([8ec93fb](https://github.com/Lundalogik/lime-elements/commit/8ec93fbeb751ba3c984d572a117a71de40f5c94a))
|
|
16
|
+
|
|
1
17
|
## [38.13.0](https://github.com/Lundalogik/lime-elements/compare/v38.12.5...v38.13.0) (2025-05-20)
|
|
2
18
|
|
|
3
19
|
|
|
@@ -26458,9 +26458,29 @@ const processPasteEvent = (view, event, slice) => {
|
|
|
26458
26458
|
if (!clipboardData) {
|
|
26459
26459
|
return false;
|
|
26460
26460
|
}
|
|
26461
|
+
const isImageFilePasted = handlePastedImages(view, clipboardData);
|
|
26462
|
+
const filteredSlice = new Slice(filterImageNodes(slice.content), slice.openStart, slice.openEnd);
|
|
26463
|
+
if (filteredSlice.content.childCount < slice.content.childCount) {
|
|
26464
|
+
const { state, dispatch } = view;
|
|
26465
|
+
const tr = state.tr.replaceSelection(filteredSlice);
|
|
26466
|
+
dispatch(tr);
|
|
26467
|
+
return true;
|
|
26468
|
+
}
|
|
26469
|
+
return isImageFilePasted;
|
|
26470
|
+
};
|
|
26471
|
+
/**
|
|
26472
|
+
* Processes any image files found in the clipboard data and dispatches an imagePasted event.
|
|
26473
|
+
*
|
|
26474
|
+
* @param view - The ProseMirror editor view
|
|
26475
|
+
* @param clipboardData - The clipboard data transfer object containing potential image files
|
|
26476
|
+
* @returns True if at least one valid image file was found and processed, false otherwise
|
|
26477
|
+
*/
|
|
26478
|
+
function handlePastedImages(view, clipboardData) {
|
|
26479
|
+
let isImageFilePasted = false;
|
|
26461
26480
|
const files$1 = Array.from(clipboardData.files || []);
|
|
26462
26481
|
for (const file of files$1) {
|
|
26463
|
-
if (file
|
|
26482
|
+
if (isImageFile(file, clipboardData)) {
|
|
26483
|
+
isImageFilePasted = true;
|
|
26464
26484
|
const reader = new FileReader();
|
|
26465
26485
|
reader.onloadend = () => {
|
|
26466
26486
|
view.dom.dispatchEvent(new CustomEvent('imagePasted', {
|
|
@@ -26470,15 +26490,45 @@ const processPasteEvent = (view, event, slice) => {
|
|
|
26470
26490
|
reader.readAsDataURL(file);
|
|
26471
26491
|
}
|
|
26472
26492
|
}
|
|
26473
|
-
|
|
26474
|
-
|
|
26475
|
-
|
|
26476
|
-
|
|
26477
|
-
|
|
26478
|
-
|
|
26493
|
+
return isImageFilePasted;
|
|
26494
|
+
}
|
|
26495
|
+
/**
|
|
26496
|
+
* Determines if a file is an image that should be processed by the image handler.
|
|
26497
|
+
*
|
|
26498
|
+
* This function checks both the file's MIME type and the clipboard HTML content.
|
|
26499
|
+
* It filters out HTML content from Excel and HTML tables, as they are not relevant for image processing.
|
|
26500
|
+
*
|
|
26501
|
+
* @param file - The file object to check
|
|
26502
|
+
* @param clipboardData - The full clipboard data transfer object to examine for context
|
|
26503
|
+
* @returns True if the file is an image that should be processed, false otherwise
|
|
26504
|
+
*/
|
|
26505
|
+
function isImageFile(file, clipboardData) {
|
|
26506
|
+
var _a, _b;
|
|
26507
|
+
if (!isContentTypeImage(file)) {
|
|
26508
|
+
return false;
|
|
26479
26509
|
}
|
|
26480
|
-
|
|
26481
|
-
|
|
26510
|
+
const html = (_b = (_a = clipboardData === null || clipboardData === void 0 ? void 0 : clipboardData.getData('text/html')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '';
|
|
26511
|
+
return !isHtmlFromExcel(html) && !isHtmlTable(html);
|
|
26512
|
+
}
|
|
26513
|
+
function isContentTypeImage(file) {
|
|
26514
|
+
if (!(file === null || file === void 0 ? void 0 : file.type)) {
|
|
26515
|
+
return false;
|
|
26516
|
+
}
|
|
26517
|
+
return file.type.startsWith('image/');
|
|
26518
|
+
}
|
|
26519
|
+
function isHtmlFromExcel(html) {
|
|
26520
|
+
if (!html) {
|
|
26521
|
+
return false;
|
|
26522
|
+
}
|
|
26523
|
+
return (html.includes('name=generator content="microsoft excel"') ||
|
|
26524
|
+
html.includes('xmlns:x="urn:schemas-microsoft-com:office:excel"'));
|
|
26525
|
+
}
|
|
26526
|
+
function isHtmlTable(html) {
|
|
26527
|
+
if (!html) {
|
|
26528
|
+
return false;
|
|
26529
|
+
}
|
|
26530
|
+
return html.includes('<table');
|
|
26531
|
+
}
|
|
26482
26532
|
|
|
26483
26533
|
const MIN_WIDTH = 10;
|
|
26484
26534
|
const createImageViewPlugin = (language) => {
|