mirror of
				https://github.com/excalidraw/excalidraw.git
				synced 2025-11-04 12:54:23 +01:00 
			
		
		
		
	Compare commits
	
		
			10 Commits
		
	
	
		
			v0.17.0
			...
			zsviczian-
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					c1f8eca7de | ||
| 
						 | 
					340b9757c3 | ||
| 
						 | 
					6035ebe95f | ||
| 
						 | 
					1a877fa8c7 | ||
| 
						 | 
					956228f4a1 | ||
| 
						 | 
					cfb9f8d8c7 | ||
| 
						 | 
					da06e8ad27 | ||
| 
						 | 
					27c7e75761 | ||
| 
						 | 
					2b8d69c65d | ||
| 
						 | 
					6d071a8a13 | 
@@ -11,7 +11,7 @@ import {
 | 
			
		||||
  isBoundToContainer,
 | 
			
		||||
  isTextElement,
 | 
			
		||||
} from "./typeChecks";
 | 
			
		||||
import { CLASSES, isFirefox, isSafari, VERTICAL_ALIGN } from "../constants";
 | 
			
		||||
import { CLASSES, VERTICAL_ALIGN } from "../constants";
 | 
			
		||||
import {
 | 
			
		||||
  ExcalidrawElement,
 | 
			
		||||
  ExcalidrawLinearElement,
 | 
			
		||||
@@ -270,12 +270,10 @@ export const textWysiwyg = ({
 | 
			
		||||
      const lineHeight = updatedTextElement.containerId
 | 
			
		||||
        ? approxLineHeight
 | 
			
		||||
        : updatedTextElement.height / lines.length;
 | 
			
		||||
 | 
			
		||||
      if (!container) {
 | 
			
		||||
        maxWidth = (appState.width - 8 - viewportX) / appState.zoom.value;
 | 
			
		||||
        textElementWidth = Math.min(textElementWidth, maxWidth);
 | 
			
		||||
      } else if (isFirefox || isSafari) {
 | 
			
		||||
        // As firefox, Safari needs little higher dimensions on DOM
 | 
			
		||||
        textElementWidth += 0.5;
 | 
			
		||||
      }
 | 
			
		||||
      // Make sure text editor height doesn't go beyond viewport
 | 
			
		||||
      const editorMaxHeight =
 | 
			
		||||
@@ -348,7 +346,32 @@ export const textWysiwyg = ({
 | 
			
		||||
    overflowWrap: "break-word",
 | 
			
		||||
    boxSizing: "content-box",
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  const magicOffset =
 | 
			
		||||
    (excalidrawContainer
 | 
			
		||||
      ? parseFloat(getComputedStyle(excalidrawContainer).fontSize)
 | 
			
		||||
      : 16) / 16;
 | 
			
		||||
 | 
			
		||||
  const onEditableInput = () => {
 | 
			
		||||
    const updatedTextElement = Scene.getScene(element)?.getElement(
 | 
			
		||||
      id,
 | 
			
		||||
    ) as ExcalidrawTextElement;
 | 
			
		||||
    const font = getFontString(updatedTextElement);
 | 
			
		||||
    if (isBoundToContainer(element)) {
 | 
			
		||||
      const container = getContainerElement(element);
 | 
			
		||||
      const wrappedText = wrapText(
 | 
			
		||||
        normalizeText(editable.value),
 | 
			
		||||
        font,
 | 
			
		||||
        getMaxContainerWidth(container!),
 | 
			
		||||
      );
 | 
			
		||||
      const { width, height } = measureText(wrappedText, font);
 | 
			
		||||
      editable.style.width = `${width + magicOffset}px`;
 | 
			
		||||
      editable.style.height = `${height}px`;
 | 
			
		||||
    }
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  updateWysiwygStyle();
 | 
			
		||||
  onEditableInput();
 | 
			
		||||
 | 
			
		||||
  if (onChange) {
 | 
			
		||||
    editable.onpaste = async (event) => {
 | 
			
		||||
@@ -378,21 +401,7 @@ export const textWysiwyg = ({
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    editable.oninput = () => {
 | 
			
		||||
      const updatedTextElement = Scene.getScene(element)?.getElement(
 | 
			
		||||
        id,
 | 
			
		||||
      ) as ExcalidrawTextElement;
 | 
			
		||||
      const font = getFontString(updatedTextElement);
 | 
			
		||||
      if (isBoundToContainer(element)) {
 | 
			
		||||
        const container = getContainerElement(element);
 | 
			
		||||
        const wrappedText = wrapText(
 | 
			
		||||
          normalizeText(editable.value),
 | 
			
		||||
          font,
 | 
			
		||||
          getMaxContainerWidth(container!),
 | 
			
		||||
        );
 | 
			
		||||
        const { width, height } = measureText(wrappedText, font);
 | 
			
		||||
        editable.style.width = `${width}px`;
 | 
			
		||||
        editable.style.height = `${height}px`;
 | 
			
		||||
      }
 | 
			
		||||
      onEditableInput();
 | 
			
		||||
      onChange(normalizeText(editable.value));
 | 
			
		||||
    };
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user