feat: support multi-embed pasting & x.com domain (#7516)

This commit is contained in:
David Luzar
2024-01-04 13:27:52 +01:00
committed by GitHub
parent 4249b7dec8
commit 43ccc875fb
4 changed files with 63 additions and 27 deletions

View File

@@ -1,4 +1,4 @@
import { getFontString, arrayToMap, isTestEnv } from "../utils";
import { getFontString, arrayToMap, isTestEnv, normalizeEOL } from "../utils";
import {
ExcalidrawElement,
ExcalidrawElementType,
@@ -39,15 +39,13 @@ import { ExtractSetType } from "../utility-types";
export const normalizeText = (text: string) => {
return (
text
normalizeEOL(text)
// replace tabs with spaces so they render and measure correctly
.replace(/\t/g, " ")
// normalize newlines
.replace(/\r?\n|\r/g, "\n")
);
};
export const splitIntoLines = (text: string) => {
const splitIntoLines = (text: string) => {
return normalizeText(text).split("\n");
};