el-text-editor 0.0.52 → 0.0.53
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.
@@ -1255,10 +1255,40 @@ class ElTextEditorComponent {
|
|
1255
1255
|
}
|
1256
1256
|
}
|
1257
1257
|
}
|
1258
|
+
// onPaste(event: ClipboardEvent) {
|
1259
|
+
// event.preventDefault();
|
1260
|
+
// const clipboardData = event.clipboardData;
|
1261
|
+
// if (clipboardData) {
|
1262
|
+
// const pastedText = clipboardData.getData('text/plain');
|
1263
|
+
// if (this.isTableData(pastedText)) {
|
1264
|
+
// const html = this.convertTextToTable(pastedText);
|
1265
|
+
// this.insertHtmlAtCaret(html);
|
1266
|
+
// } else {
|
1267
|
+
// this.insertHtmlAtCaret(pastedText);
|
1268
|
+
// }
|
1269
|
+
// }
|
1270
|
+
// }
|
1258
1271
|
onPaste(event) {
|
1259
1272
|
event.preventDefault();
|
1260
1273
|
const clipboardData = event.clipboardData;
|
1261
1274
|
if (clipboardData) {
|
1275
|
+
// Handle image data
|
1276
|
+
const items = clipboardData.items;
|
1277
|
+
for (let i = 0; i < items.length; i++) {
|
1278
|
+
if (items[i].type.startsWith('image/')) {
|
1279
|
+
const file = items[i].getAsFile();
|
1280
|
+
if (file) {
|
1281
|
+
const reader = new FileReader();
|
1282
|
+
reader.onload = (e) => {
|
1283
|
+
const imgHtml = `<img src="${e.target.result}" alt="Pasted Image" style="max-width: 100%;"/>`;
|
1284
|
+
this.insertHtmlAtCaret(imgHtml);
|
1285
|
+
};
|
1286
|
+
reader.readAsDataURL(file);
|
1287
|
+
return; // Exit if an image is handled
|
1288
|
+
}
|
1289
|
+
}
|
1290
|
+
}
|
1291
|
+
// Handle text or table data
|
1262
1292
|
const pastedText = clipboardData.getData('text/plain');
|
1263
1293
|
if (this.isTableData(pastedText)) {
|
1264
1294
|
const html = this.convertTextToTable(pastedText);
|