feat: changed text copy/paste behaviour (#5786)

Co-authored-by: dwelle <luzar.david@gmail.com>
Co-authored-by: Antonio Della Fortuna <a.dellafortuna00@gmail.com>
This commit is contained in:
Antonio Della Fortuna 2022-11-26 23:44:26 +01:00 committed by GitHub
parent d2181847be
commit baf9651d34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 324 additions and 33 deletions

View file

@ -21,6 +21,7 @@ import {
getContainerDims,
getContainerElement,
measureText,
normalizeText,
wrapText,
} from "./textElement";
import {
@ -32,16 +33,6 @@ import App from "../components/App";
import { getMaxContainerWidth } from "./newElement";
import { parseClipboard } from "../clipboard";
const normalizeText = (text: string) => {
return (
text
// replace tabs with spaces so they render and measure correctly
.replace(/\t/g, " ")
// normalize newlines
.replace(/\r?\n|\r/g, "\n")
);
};
const getTransform = (
width: number,
height: number,
@ -279,7 +270,7 @@ export const textWysiwyg = ({
if (onChange) {
editable.onpaste = async (event) => {
event.preventDefault();
const clipboardData = await parseClipboard(event);
const clipboardData = await parseClipboard(event, true);
if (!clipboardData.text) {
return;
}