enh: large pasted text as file

Co-Authored-By: Taylor Wilsdon <6508528+taylorwilsdon@users.noreply.github.com>
This commit is contained in:
Timothy Jaeryang Baek
2024-11-18 20:50:12 -08:00
parent 8bb3061101
commit 11e78eac91
3 changed files with 36 additions and 1 deletions
@@ -23,6 +23,7 @@
import { keymap } from 'prosemirror-keymap';
import { baseKeymap, chainCommands } from 'prosemirror-commands';
import { DOMParser, DOMSerializer, Schema, Fragment } from 'prosemirror-model';
import { PASTED_TEXT_CHARACTER_LIMIT } from '$lib/constants';
export let className = 'input-prose';
export let shiftEnter = false;
@@ -412,6 +413,13 @@
// Extract plain text from clipboard and paste it without formatting
const plainText = event.clipboardData.getData('text/plain');
if (plainText) {
if (plainText.length > PASTED_TEXT_CHARACTER_LIMIT) {
// Dispatch paste event to parent component
eventDispatch('paste', { event });
event.preventDefault();
return true;
}
const modifiedText = handleTabIndentation(plainText);
console.log(modifiedText);