|  | @@ -463,14 +463,21 @@ describe("textWysiwyg", () => {
 | 
	
		
			
				|  |  |        });
 | 
	
		
			
				|  |  |      });
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    it("should bind text to container when double clicked on center of filled container", async () => {
 | 
	
		
			
				|  |  | +    it("should bind text to container when double clicked inside filled container", async () => {
 | 
	
		
			
				|  |  | +      const rectangle = API.createElement({
 | 
	
		
			
				|  |  | +        type: "rectangle",
 | 
	
		
			
				|  |  | +        x: 10,
 | 
	
		
			
				|  |  | +        y: 20,
 | 
	
		
			
				|  |  | +        width: 90,
 | 
	
		
			
				|  |  | +        height: 75,
 | 
	
		
			
				|  |  | +        backgroundColor: "red",
 | 
	
		
			
				|  |  | +      });
 | 
	
		
			
				|  |  | +      h.elements = [rectangle];
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |        expect(h.elements.length).toBe(1);
 | 
	
		
			
				|  |  |        expect(h.elements[0].id).toBe(rectangle.id);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -      mouse.doubleClickAt(
 | 
	
		
			
				|  |  | -        rectangle.x + rectangle.width / 2,
 | 
	
		
			
				|  |  | -        rectangle.y + rectangle.height / 2,
 | 
	
		
			
				|  |  | -      );
 | 
	
		
			
				|  |  | +      mouse.doubleClickAt(rectangle.x + 10, rectangle.y + 10);
 | 
	
		
			
				|  |  |        expect(h.elements.length).toBe(2);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |        const text = h.elements[1] as ExcalidrawTextElementWithContainer;
 | 
	
	
		
			
				|  | @@ -504,24 +511,37 @@ describe("textWysiwyg", () => {
 | 
	
		
			
				|  |  |        });
 | 
	
		
			
				|  |  |        h.elements = [rectangle];
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +      mouse.doubleClickAt(rectangle.x + 10, rectangle.y + 10);
 | 
	
		
			
				|  |  | +      expect(h.elements.length).toBe(2);
 | 
	
		
			
				|  |  | +      let text = h.elements[1] as ExcalidrawTextElementWithContainer;
 | 
	
		
			
				|  |  | +      expect(text.type).toBe("text");
 | 
	
		
			
				|  |  | +      expect(text.containerId).toBe(null);
 | 
	
		
			
				|  |  | +      mouse.down();
 | 
	
		
			
				|  |  | +      let editor = document.querySelector(
 | 
	
		
			
				|  |  | +        ".excalidraw-textEditorContainer > textarea",
 | 
	
		
			
				|  |  | +      ) as HTMLTextAreaElement;
 | 
	
		
			
				|  |  | +      await new Promise((r) => setTimeout(r, 0));
 | 
	
		
			
				|  |  | +      editor.blur();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |        mouse.doubleClickAt(
 | 
	
		
			
				|  |  |          rectangle.x + rectangle.width / 2,
 | 
	
		
			
				|  |  |          rectangle.y + rectangle.height / 2,
 | 
	
		
			
				|  |  |        );
 | 
	
		
			
				|  |  | -      expect(h.elements.length).toBe(2);
 | 
	
		
			
				|  |  | +      expect(h.elements.length).toBe(3);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -      const text = h.elements[1] as ExcalidrawTextElementWithContainer;
 | 
	
		
			
				|  |  | +      text = h.elements[1] as ExcalidrawTextElementWithContainer;
 | 
	
		
			
				|  |  |        expect(text.type).toBe("text");
 | 
	
		
			
				|  |  |        expect(text.containerId).toBe(rectangle.id);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |        mouse.down();
 | 
	
		
			
				|  |  | -      const editor = document.querySelector(
 | 
	
		
			
				|  |  | +      editor = document.querySelector(
 | 
	
		
			
				|  |  |          ".excalidraw-textEditorContainer > textarea",
 | 
	
		
			
				|  |  |        ) as HTMLTextAreaElement;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |        fireEvent.change(editor, { target: { value: "Hello World!" } });
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |        await new Promise((r) => setTimeout(r, 0));
 | 
	
		
			
				|  |  |        editor.blur();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |        expect(rectangle.boundElements).toStrictEqual([
 | 
	
		
			
				|  |  |          { id: text.id, type: "text" },
 | 
	
		
			
				|  |  |        ]);
 | 
	
	
		
			
				|  | @@ -551,6 +571,43 @@ describe("textWysiwyg", () => {
 | 
	
		
			
				|  |  |        ]);
 | 
	
		
			
				|  |  |      });
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    it("should bind text to container when double clicked on container stroke", async () => {
 | 
	
		
			
				|  |  | +      const rectangle = API.createElement({
 | 
	
		
			
				|  |  | +        type: "rectangle",
 | 
	
		
			
				|  |  | +        x: 10,
 | 
	
		
			
				|  |  | +        y: 20,
 | 
	
		
			
				|  |  | +        width: 90,
 | 
	
		
			
				|  |  | +        height: 75,
 | 
	
		
			
				|  |  | +        strokeWidth: 4,
 | 
	
		
			
				|  |  | +      });
 | 
	
		
			
				|  |  | +      h.elements = [rectangle];
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +      expect(h.elements.length).toBe(1);
 | 
	
		
			
				|  |  | +      expect(h.elements[0].id).toBe(rectangle.id);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +      mouse.doubleClickAt(rectangle.x + 2, rectangle.y + 2);
 | 
	
		
			
				|  |  | +      expect(h.elements.length).toBe(2);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +      const text = h.elements[1] as ExcalidrawTextElementWithContainer;
 | 
	
		
			
				|  |  | +      expect(text.type).toBe("text");
 | 
	
		
			
				|  |  | +      expect(text.containerId).toBe(rectangle.id);
 | 
	
		
			
				|  |  | +      expect(rectangle.boundElements).toStrictEqual([
 | 
	
		
			
				|  |  | +        { id: text.id, type: "text" },
 | 
	
		
			
				|  |  | +      ]);
 | 
	
		
			
				|  |  | +      mouse.down();
 | 
	
		
			
				|  |  | +      const editor = document.querySelector(
 | 
	
		
			
				|  |  | +        ".excalidraw-textEditorContainer > textarea",
 | 
	
		
			
				|  |  | +      ) as HTMLTextAreaElement;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +      fireEvent.change(editor, { target: { value: "Hello World!" } });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +      await new Promise((r) => setTimeout(r, 0));
 | 
	
		
			
				|  |  | +      editor.blur();
 | 
	
		
			
				|  |  | +      expect(rectangle.boundElements).toStrictEqual([
 | 
	
		
			
				|  |  | +        { id: text.id, type: "text" },
 | 
	
		
			
				|  |  | +      ]);
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      it("shouldn't bind to non-text-bindable containers", async () => {
 | 
	
		
			
				|  |  |        const freedraw = API.createElement({
 | 
	
		
			
				|  |  |          type: "freedraw",
 |