You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched and referenced existing issues, feature requests and discussions
I am filing a FEATURE request.
Description
I noticed that there are _exitEditing and exitEditing methods for exiting text editing, but there is no _enterEditing method for entering text editing; there is only enterEditing. I hope there will be a _enterEditing method for entering text editing.
I have a requirement where entering and exiting text editing triggers undoRedo, so I listen for text:editing:entered and text:editing:exited. After performing the undo operation, I will execute _exitEditing and _enterEditing to blur and focus without triggering the aforementioned listener events. However, currently, there is no _enterEditing method.
Current State
Here is a minimal implementation example to represent the idea I mentioned.
constmapId={};constundo=[];constredo=[];canvas.on("text:editing:entered",e=>{if(!e.target.id)e.target.id=Date.now();mapId[e.target.id]=e.target;undo.push({type: "text:entered",data: {id: e.target.id}});redo=[];})canvas.on("text:editing:exited",e=>{undo.push({type: "text:exited",data: {id: e.target.id}});redo=[];})// key press: command + zfunctionkeyPressUndo(){constdata=undo[undo.length-1];if(data.type=="text:exited"){// Use method _enterEditing instead of method enterEditing to prevent it from entering the aforementioned event listener.mapId[data.data.id]._enterEditing();}elseif(data.type=="text:entered"){// Use method _exitEditing instead of method exitEditing to prevent it from entering the aforementioned event listener.mapId[data.data.id]._exitEditing();}redo.push(data);}// key press: shift + command + zfunctionkeyPressRedo(){constdata=redo[redo.length-1];if(data.type=="text:exited"){mapId[data.data.id]._exitEditing();}elseif(){mapId[data.data.id]._enterEditing();}undo.push(data);}
Additional Context
No response
The text was updated successfully, but these errors were encountered:
What is the reason to trigger undo/redo from an operation that does not actually do any change to the text?
I m not opposed to consolidate the pattern with and without events to be clear.
What is the reason to trigger undo/redo from an operation that does not actually do any change to the text? I m not opposed to consolidate the pattern with and without events to be clear.
The undo and redo functionality includes the user's entry into and exit from text editing, so I listen for text:editing:entered and text:editing:exited to log them to meet my needs. When the user normally enters and exits text editing, all operations are recorded in an array. When the user actively triggers an undo, the latest entry is taken from the recorded array. If this data is 'exit editing', I need to actively trigger 'enter editing'. However, currently, the internal 'enter editing' in Fabric triggers the text:editing:entered event, which gets recorded in the undo array (considered a normal entry into editing). This is not what I want; I need a clean 'enter editing' event that does not trigger the text:editing:entered event, so I submitted this PR.
CheckList
Description
I noticed that there are _exitEditing and exitEditing methods for exiting text editing, but there is no _enterEditing method for entering text editing; there is only enterEditing. I hope there will be a _enterEditing method for entering text editing.
I have a requirement where entering and exiting text editing triggers undoRedo, so I listen for text:editing:entered and text:editing:exited. After performing the undo operation, I will execute _exitEditing and _enterEditing to blur and focus without triggering the aforementioned listener events. However, currently, there is no _enterEditing method.
Current State
Here is a minimal implementation example to represent the idea I mentioned.
Additional Context
No response
The text was updated successfully, but these errors were encountered: