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