mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-09-25 10:21:17 +02:00
Compare commits
2 Commits
fix-zsvicz
...
fix-5855
Author | SHA1 | Date | |
---|---|---|---|
![]() |
555bf6338f | ||
![]() |
0bef3945f6 |
@@ -4755,9 +4755,9 @@ loader-runner@^4.2.0:
|
||||
integrity sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==
|
||||
|
||||
loader-utils@^2.0.0:
|
||||
version "2.0.3"
|
||||
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.3.tgz#d4b15b8504c63d1fc3f2ade52d41bc8459d6ede1"
|
||||
integrity sha512-THWqIsn8QRnvLl0shHYVBN9syumU8pYWEHPTmkiVGd+7K5eFNVSY6AJhRvgGF70gg1Dz+l/k8WicvFCxdEs60A==
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.2.tgz#d6e3b4fb81870721ae4e0868ab11dd638368c129"
|
||||
integrity sha512-TM57VeHptv569d/GKh6TAYdzKblwDNiumOdkFnejjD0XwTH87K90w3O7AiJRqdQoXygvi1VQTJTLGhJl7WqA7A==
|
||||
dependencies:
|
||||
big.js "^5.2.2"
|
||||
emojis-list "^3.0.0"
|
||||
|
@@ -1,27 +0,0 @@
|
||||
import { parseClipboard } from "./clipboard";
|
||||
|
||||
describe("Test parseClipboard", () => {
|
||||
it("should parse valid json correctly", async () => {
|
||||
let text = "123";
|
||||
|
||||
let clipboardData = await parseClipboard({
|
||||
//@ts-ignore
|
||||
clipboardData: {
|
||||
getData: () => text,
|
||||
},
|
||||
});
|
||||
|
||||
expect(clipboardData.text).toBe(text);
|
||||
|
||||
text = "[123]";
|
||||
|
||||
clipboardData = await parseClipboard({
|
||||
//@ts-ignore
|
||||
clipboardData: {
|
||||
getData: () => text,
|
||||
},
|
||||
});
|
||||
|
||||
expect(clipboardData.text).toBe(text);
|
||||
});
|
||||
});
|
@@ -156,13 +156,15 @@ export const parseClipboard = async (
|
||||
files: systemClipboardData.files,
|
||||
};
|
||||
}
|
||||
} catch (e) {}
|
||||
// system clipboard doesn't contain excalidraw elements → return plaintext
|
||||
// unless we set a flag to prefer in-app clipboard because browser didn't
|
||||
// support storing to system clipboard on copy
|
||||
return PREFER_APP_CLIPBOARD && appClipboardData.elements
|
||||
? appClipboardData
|
||||
: { text: systemClipboard };
|
||||
return appClipboardData;
|
||||
} catch {
|
||||
// system clipboard doesn't contain excalidraw elements → return plaintext
|
||||
// unless we set a flag to prefer in-app clipboard because browser didn't
|
||||
// support storing to system clipboard on copy
|
||||
return PREFER_APP_CLIPBOARD && appClipboardData.elements
|
||||
? appClipboardData
|
||||
: { text: systemClipboard };
|
||||
}
|
||||
};
|
||||
|
||||
export const copyBlobToClipboardAsPng = async (blob: Blob | Promise<Blob>) => {
|
||||
|
@@ -411,8 +411,7 @@ const LayerUI = ({
|
||||
onClick={onCollabButtonClick}
|
||||
/>
|
||||
)}
|
||||
{!appState.viewModeEnabled &&
|
||||
renderTopRightUI?.(device.isMobile, appState)}
|
||||
{renderTopRightUI?.(device.isMobile, appState)}
|
||||
{!appState.viewModeEnabled && (
|
||||
<LibraryButton appState={appState} setAppState={setAppState} />
|
||||
)}
|
||||
|
@@ -111,9 +111,8 @@ export const MobileMenu = ({
|
||||
/>
|
||||
</Stack.Row>
|
||||
</Island>
|
||||
{renderTopRightUI && renderTopRightUI(true, appState)}
|
||||
<div className="mobile-misc-tools-container">
|
||||
{!appState.viewModeEnabled &&
|
||||
renderTopRightUI?.(true, appState)}
|
||||
<PenModeButton
|
||||
checked={appState.penMode}
|
||||
onChange={onPenModeToggle}
|
||||
|
@@ -1470,11 +1470,11 @@ export const TextAlignRightIcon = createIcon(
|
||||
export const TextAlignTopIcon = React.memo(({ theme }: { theme: Theme }) =>
|
||||
createIcon(
|
||||
<g
|
||||
strokeWidth="1.5"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||
<line x1="4" y1="4" x2="20" y2="4" />
|
||||
@@ -1488,11 +1488,11 @@ export const TextAlignTopIcon = React.memo(({ theme }: { theme: Theme }) =>
|
||||
export const TextAlignBottomIcon = React.memo(({ theme }: { theme: Theme }) =>
|
||||
createIcon(
|
||||
<g
|
||||
strokeWidth="2"
|
||||
stroke-width="2"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||
<line x1="4" y1="20" x2="20" y2="20" />
|
||||
@@ -1506,11 +1506,11 @@ export const TextAlignBottomIcon = React.memo(({ theme }: { theme: Theme }) =>
|
||||
export const TextAlignMiddleIcon = React.memo(({ theme }: { theme: Theme }) =>
|
||||
createIcon(
|
||||
<g
|
||||
strokeWidth="1.5"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||
<line x1="4" y1="12" x2="9" y2="12" />
|
||||
|
@@ -439,7 +439,7 @@ describe("textWysiwyg", () => {
|
||||
it("should paste text correctly", async () => {
|
||||
Keyboard.keyPress(KEYS.ENTER);
|
||||
await new Promise((r) => setTimeout(r, 0));
|
||||
let text = "A quick brown fox jumps over the lazy dog.";
|
||||
const text = "A quick brown fox jumps over the lazy dog.";
|
||||
|
||||
//@ts-ignore
|
||||
textarea.onpaste({
|
||||
@@ -453,23 +453,6 @@ describe("textWysiwyg", () => {
|
||||
await new Promise((cb) => setTimeout(cb, 0));
|
||||
textarea.blur();
|
||||
expect(textElement.text).toBe(text);
|
||||
|
||||
Keyboard.keyPress(KEYS.ENTER);
|
||||
await new Promise((r) => setTimeout(r, 0));
|
||||
text = "Hello this text should get merged with the existing one";
|
||||
//@ts-ignore
|
||||
textarea.onpaste({
|
||||
preventDefault: () => {},
|
||||
//@ts-ignore
|
||||
clipboardData: {
|
||||
getData: () => text,
|
||||
},
|
||||
});
|
||||
await new Promise((cb) => setTimeout(cb, 0));
|
||||
textarea.blur();
|
||||
expect(textElement.text).toMatchInlineSnapshot(
|
||||
`"A quick brown fox jumps over the lazy dog.Hello this text should get merged with the existing one"`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -922,11 +905,9 @@ describe("textWysiwyg", () => {
|
||||
) as HTMLTextAreaElement;
|
||||
await new Promise((r) => setTimeout(r, 0));
|
||||
const font = "20px Cascadia, width: Segoe UI Emoji" as FontString;
|
||||
let text =
|
||||
"Wikipedia is hosted by the Wikimedia Foundation, a non-profit organization that also hosts a range of other projects.";
|
||||
|
||||
let wrappedText = textElementUtils.wrapText(
|
||||
text,
|
||||
const wrappedText = textElementUtils.wrapText(
|
||||
"Wikipedia is hosted by the Wikimedia Foundation, a non-profit organization that also hosts a range of other projects.",
|
||||
font,
|
||||
getMaxContainerWidth(rectangle),
|
||||
);
|
||||
@@ -945,7 +926,8 @@ describe("textWysiwyg", () => {
|
||||
preventDefault: () => {},
|
||||
//@ts-ignore
|
||||
clipboardData: {
|
||||
getData: () => text,
|
||||
getData: () =>
|
||||
"Wikipedia is hosted by the Wikimedia Foundation, a non-profit organization that also hosts a range of other projects.",
|
||||
},
|
||||
});
|
||||
|
||||
@@ -953,8 +935,9 @@ describe("textWysiwyg", () => {
|
||||
editor.blur();
|
||||
expect(rectangle.width).toBe(100);
|
||||
expect(rectangle.height).toBe(210);
|
||||
expect((h.elements[1] as ExcalidrawTextElement).text)
|
||||
.toMatchInlineSnapshot(`
|
||||
const textElement = h.elements[1] as ExcalidrawTextElement;
|
||||
expect(textElement.text).toMatchInlineSnapshot(
|
||||
`
|
||||
"Wikipedi
|
||||
a is
|
||||
hosted
|
||||
@@ -974,64 +957,7 @@ describe("textWysiwyg", () => {
|
||||
other
|
||||
projects
|
||||
."
|
||||
`);
|
||||
expect(
|
||||
(h.elements[1] as ExcalidrawTextElement).originalText,
|
||||
).toMatchInlineSnapshot(
|
||||
`"Wikipedia is hosted by the Wikimedia Foundation, a non-profit organization that also hosts a range of other projects."`,
|
||||
);
|
||||
|
||||
text = "Hello this text should get merged with the existing one";
|
||||
wrappedText = textElementUtils.wrapText(
|
||||
text,
|
||||
font,
|
||||
getMaxContainerWidth(rectangle),
|
||||
);
|
||||
//@ts-ignore
|
||||
editor.onpaste({
|
||||
preventDefault: () => {},
|
||||
//@ts-ignore
|
||||
clipboardData: {
|
||||
getData: () => text,
|
||||
},
|
||||
});
|
||||
|
||||
await new Promise((cb) => setTimeout(cb, 0));
|
||||
editor.blur();
|
||||
expect((h.elements[1] as ExcalidrawTextElement).text)
|
||||
.toMatchInlineSnapshot(`
|
||||
"Wikipedi
|
||||
a is
|
||||
hosted
|
||||
by the
|
||||
Wikimedi
|
||||
a
|
||||
Foundati
|
||||
on, a
|
||||
non-prof
|
||||
it
|
||||
organiza
|
||||
tion
|
||||
that
|
||||
also
|
||||
hosts a
|
||||
range of
|
||||
other
|
||||
projects
|
||||
.Hello
|
||||
this
|
||||
text
|
||||
should
|
||||
get
|
||||
merged
|
||||
with the
|
||||
existing
|
||||
one"
|
||||
`);
|
||||
expect(
|
||||
(h.elements[1] as ExcalidrawTextElement).originalText,
|
||||
).toMatchInlineSnapshot(
|
||||
`"Wikipedia is hosted by the Wikimedia Foundation, a non-profit organization that also hosts a range of other projects.Hello this text should get merged with the existing one"`,
|
||||
`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@@ -284,17 +284,6 @@ export const textWysiwyg = ({
|
||||
return;
|
||||
}
|
||||
const data = normalizeText(clipboardData.text);
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
|
||||
const text = editable.value;
|
||||
const start = Math.min(editable.selectionStart, editable.selectionEnd);
|
||||
const end = Math.max(editable.selectionStart, editable.selectionEnd);
|
||||
const newText = `${text.substring(0, start)}${data}${text.substring(
|
||||
end,
|
||||
)}`;
|
||||
|
||||
const container = getContainerElement(element);
|
||||
|
||||
const font = getFontString({
|
||||
@@ -302,12 +291,20 @@ export const textWysiwyg = ({
|
||||
fontFamily: app.state.currentItemFontFamily,
|
||||
});
|
||||
|
||||
const wrappedText = container
|
||||
? wrapText(newText, font, getMaxContainerWidth(container))
|
||||
: newText;
|
||||
const dimensions = measureText(wrappedText, font);
|
||||
editable.style.height = `${dimensions.height}px`;
|
||||
onChange(newText);
|
||||
if (data) {
|
||||
const text = editable.value;
|
||||
const start = Math.min(editable.selectionStart, editable.selectionEnd);
|
||||
const end = Math.max(editable.selectionStart, editable.selectionEnd);
|
||||
const newText = `${text.substring(0, start)}${data}${text.substring(
|
||||
end,
|
||||
)}`;
|
||||
const wrappedText = container
|
||||
? wrapText(newText, font, getMaxContainerWidth(container!))
|
||||
: newText;
|
||||
const dimensions = measureText(wrappedText, font);
|
||||
editable.style.height = `${dimensions.height}px`;
|
||||
onChange(newText);
|
||||
}
|
||||
};
|
||||
editable.oninput = () => {
|
||||
const updatedTextElement = Scene.getScene(element)?.getElement(
|
||||
|
@@ -1873,7 +1873,7 @@ compression@^1.7.4:
|
||||
concat-map@0.0.1:
|
||||
version "0.0.1"
|
||||
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
|
||||
integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==
|
||||
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
|
||||
|
||||
connect-history-api-fallback@^2.0.0:
|
||||
version "2.0.0"
|
||||
@@ -2697,9 +2697,9 @@ loader-runner@^4.2.0:
|
||||
integrity sha512-92+huvxMvYlMzMt0iIOukcwYBFpkYJdpl2xsZ7LrlayO7E8SOv+JJUEK17B/dJIHAOLMfh2dZZ/Y18WgmGtYNw==
|
||||
|
||||
loader-utils@^2.0.0:
|
||||
version "2.0.3"
|
||||
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.3.tgz#d4b15b8504c63d1fc3f2ade52d41bc8459d6ede1"
|
||||
integrity sha512-THWqIsn8QRnvLl0shHYVBN9syumU8pYWEHPTmkiVGd+7K5eFNVSY6AJhRvgGF70gg1Dz+l/k8WicvFCxdEs60A==
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.2.tgz#d6e3b4fb81870721ae4e0868ab11dd638368c129"
|
||||
integrity sha512-TM57VeHptv569d/GKh6TAYdzKblwDNiumOdkFnejjD0XwTH87K90w3O7AiJRqdQoXygvi1VQTJTLGhJl7WqA7A==
|
||||
dependencies:
|
||||
big.js "^5.2.2"
|
||||
emojis-list "^3.0.0"
|
||||
@@ -2823,9 +2823,9 @@ minimalistic-assert@^1.0.0:
|
||||
integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==
|
||||
|
||||
minimatch@^3.0.4:
|
||||
version "3.1.2"
|
||||
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
|
||||
integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==
|
||||
version "3.0.4"
|
||||
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
|
||||
integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
|
||||
dependencies:
|
||||
brace-expansion "^1.1.7"
|
||||
|
||||
|
@@ -1915,9 +1915,9 @@ loader-runner@^4.2.0:
|
||||
integrity sha512-92+huvxMvYlMzMt0iIOukcwYBFpkYJdpl2xsZ7LrlayO7E8SOv+JJUEK17B/dJIHAOLMfh2dZZ/Y18WgmGtYNw==
|
||||
|
||||
loader-utils@^2.0.0:
|
||||
version "2.0.4"
|
||||
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.4.tgz#8b5cb38b5c34a9a018ee1fc0e6a066d1dfcc528c"
|
||||
integrity sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.0.tgz#e4cace5b816d425a166b5f097e10cd12b36064b0"
|
||||
integrity sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==
|
||||
dependencies:
|
||||
big.js "^5.2.2"
|
||||
emojis-list "^3.0.0"
|
||||
|
@@ -11263,9 +11263,9 @@ socket.io-client@2.3.1:
|
||||
to-array "0.1.4"
|
||||
|
||||
socket.io-parser@~3.3.0:
|
||||
version "3.3.3"
|
||||
resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-3.3.3.tgz#3a8b84823eba87f3f7624e64a8aaab6d6318a72f"
|
||||
integrity sha512-qOg87q1PMWWTeO01768Yh9ogn7chB9zkKtQnya41Y355S0UmpXgpcrFwAgjYJxu9BdKug5r5e9YtVSeWhKBUZg==
|
||||
version "3.3.2"
|
||||
resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-3.3.2.tgz#ef872009d0adcf704f2fbe830191a14752ad50b6"
|
||||
integrity sha512-FJvDBuOALxdCI9qwRrO/Rfp9yfndRtc1jSgVgV8FDraihmSP/MLGD5PEuJrNfjALvcQ+vMDM/33AWOYP/JSjDg==
|
||||
dependencies:
|
||||
component-emitter "~1.3.0"
|
||||
debug "~3.1.0"
|
||||
|
Reference in New Issue
Block a user