1

I want set the text selection by code in FabricJS like the image. When I create the IText object I need to select all text to facilitate the editing.

I check the documentation, but no success.

enter image description here

Marlos Carmo
  • 972
  • 1
  • 8
  • 13

1 Answers1

2

I've found it in documentation. And prepared use example for you

import "./styles.css";
import { fabric } from "fabric";

const canvas = new fabric.Canvas("c", { width: 600, height: 600 });

const iText = new fabric.IText("Hello world!");

canvas.setActiveObject(iText);
iText.enterEditing();
iText.selectAll();
canvas.add(iText);

https://codesandbox.io/s/fabricjs-playground-forked-jl0ui?file=/src/index.js

Oro
  • 2,250
  • 1
  • 6
  • 22