paste 버그 수정
This commit is contained in:
@@ -54,20 +54,44 @@ class EditableInputView {
|
|||||||
this.controller.additionalCallback(this.model.getValue());
|
this.controller.additionalCallback(this.model.getValue());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// this.editableDiv.addEventListener('paste', (event) => {
|
||||||
|
// event.preventDefault();
|
||||||
|
// if (navigator.clipboard && navigator.clipboard.readText) {
|
||||||
|
// navigator.clipboard.readText().then(text => {
|
||||||
|
// this.insertTextAtCursor(text);
|
||||||
|
// }).catch(err => {
|
||||||
|
// console.error('Failed to read clipboard contents: ', err);
|
||||||
|
// // Fallback to using clipboardData from the paste event
|
||||||
|
// const text = (event.clipboardData || window.clipboardData).getData('text');
|
||||||
|
// this.insertTextAtCursor(text);
|
||||||
|
// });
|
||||||
|
// } else {
|
||||||
|
// const text = (event.clipboardData || window.clipboardData).getData('text');
|
||||||
|
// this.insertTextAtCursor(text);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
this.editableDiv.addEventListener('paste', (event) => {
|
this.editableDiv.addEventListener('paste', (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (navigator.clipboard && navigator.clipboard.readText) {
|
let text = (event.clipboardData || window.clipboardData).getData('text/plain'); // Using 'text/plain' for compatibility
|
||||||
|
|
||||||
|
if (text) {
|
||||||
|
console.log('Pasted text:', text); // Debug: Log pasted text
|
||||||
|
this.insertTextAtCursor(text);
|
||||||
|
if (this.controller.additionalCallback) {
|
||||||
|
this.controller.additionalCallback(this.model.getValue());
|
||||||
|
}
|
||||||
|
} else if (navigator.clipboard && navigator.clipboard.readText) {
|
||||||
navigator.clipboard.readText().then(text => {
|
navigator.clipboard.readText().then(text => {
|
||||||
|
console.log('Pasted text from clipboard API:', text); // Debug: Log pasted text
|
||||||
this.insertTextAtCursor(text);
|
this.insertTextAtCursor(text);
|
||||||
|
if (this.controller.additionalCallback) {
|
||||||
|
this.controller.additionalCallback(this.model.getValue());
|
||||||
|
}
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.error('Failed to read clipboard contents: ', err);
|
console.error('Failed to read clipboard contents:', err);
|
||||||
// Fallback to using clipboardData from the paste event
|
|
||||||
const text = (event.clipboardData || window.clipboardData).getData('text');
|
|
||||||
this.insertTextAtCursor(text);
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const text = (event.clipboardData || window.clipboardData).getData('text');
|
console.error('No text found to paste and clipboard API not available.');
|
||||||
this.insertTextAtCursor(text);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user