undo-redo

How to insert text into a textarea using JavaScript without messing up edit history?

吃可爱长大的小学妹 提交于 2021-01-27 13:09:44
问题 Basically what i want is if a user selects some text in a textarea and presses ctrl + b then the text within the selection should be surrounded by stars. so basically what I want is : 1) textarea content : "hello this is some text" 2) user selects some text and presses ctrl + b "hello this is some text" (assume the bolded part is a text selection) 3) so I want the textarea content to be : "hello this *is some* text" 4) and if the user presses ctrl + z(or whatever the undo action) the textarea

Implementing undo/redo in fabricjs with multiple canvases

余生颓废 提交于 2020-08-10 23:16:51
问题 I am a newbie in vue and fabricjs and currently working on a complex application which deals with large amount of data. I have multiple canvases with different objects, which may change based on user interaction. All the changes/objects are being stored in the array of objects Demo: https://prkos.csb.app/ I am trying to implement undo/redo in my application. I have a hard time understanding the fabricjs undo/redo approach in the below answer (link) Undo-Redo feature in Fabric.js What I think

internet explorer alternative to document.execCommand(“insertText”,…), for text insertion that can be undone/redone by the user

南笙酒味 提交于 2020-01-20 04:36:46
问题 When the user edits a contenteditable div , and press some keys, I would like to override the default behavior. For instance, I want to insert a normal line break when the user press ENTER. I do that using document.execCommand("insertText",...) This is the only way I have found so far to make this action undoable and redoable by the user. <div id="editor" contenteditable="true" style="white-space:pre-wrap"> Some text.... </div> <script> $("#editor").keydown(function(evt){ console.log(evt

Core Data deleteObject: sets attributes to nil

允我心安 提交于 2020-01-14 13:32:07
问题 I am implementing an undo/redo mechanism in my app. This works fine for lots of cases. However, I can't undo past deleteObject:. the object is correctly saved in the undo queue, and I get it back and reinsterted into the Core Data stack just fine when calling undo. The problem is that all it's attributes are getting set to nil when I delete it. I have an entity "Canvas" with a to-many relationship called "graphics" to a "Graphic" entity, which has its inverse set to "canvas". Deleting a

Paper_trail with accepts_nested_attributes_for

你离开我真会死。 提交于 2020-01-06 13:51:55
问题 I have a rails app that has articles that and the user can add links and reviews as nested attributes. I saw in the paper_trail https://github.com/airblade/paper_trail/ documentation that this is not covered by that gem. How would I go about setting up undo functionality so that nested attributes or has_many associations are restored/updated when a user clicks undo? 回答1: I think if you hook in a "destroy" post to the undo button it will at least remove the links if they click undo. Basically

Disabling undo/redo in an HTML input field

£可爱£侵袭症+ 提交于 2020-01-02 05:44:12
问题 I am using asp.net input fields and they automatically provide undo/redo functionality. I am using JavaScript to format the value of the input field, however this ruins the undo/redo history. Is there a way to disable the undo/redo feature? or Is there a way to interact with the undo/redo history to add the correct values? 回答1: Using JavaScript, try replacing the text field with a new one and then setting the value. New field, new undo buffer, right? jQuery: $('#theTextField').after('

How to implement undo/redo and preserve the value on orientation change in android EditText?

南楼画角 提交于 2019-12-24 11:23:03
问题 I am using the TextViewUndoRedo class for undo/redo operations and it works but I want the value preserved after orientation/onConfigurationChange . There are two methods in that class: storePersistentState(Editor editor, String prefix) and restorePersistentState(SharedPreferences sp, String prefix) , what do they do? I guess, these are for onConfigurationChanged and implement in the following way, but they didn't work? @Override public void onConfigurationChanged(Configuration newConfig) {

Implement Undo/Redo operations for Adding/Deleting ListView Items (Part 2)

血红的双手。 提交于 2019-12-24 10:46:06
问题 Well here I am to talk about the second part of this question Implement Undo/Redo operations for Adding/Deleting ListView Items and this other Extend this Class to Undo/Redo in a Listview. I'm trying to implement Undo/Redo operations for Adding/Deleting ListView Items. I've advanced a little more with the coding of this LV UndoManager code but it is very hard for me always when I try to advance. At the moment I can add single items and then I can Undo/Redo perfectly that ADDED items, no more.

Undo drawing in Paint Application

时光怂恿深爱的人放手 提交于 2019-12-24 10:35:52
问题 I am making a paint application using OpenGl framework and I'm stuck at UNDO/REDO option.. The code I implemented is like this: -(void)undo_called { artbrushAppDelegate *app=(artbrushAppDelegate *)[[UIApplication sharedApplication]delegate]; mbrushscale=app.brushscale; brushimage=app.brush_image; Erase=YES; [self playRayundo]; } -(void)playRayundo { artbrushAppDelegate *app=(artbrushAppDelegate *)[[UIApplication sharedApplication]delegate]; glColor4f(app.r1g, app.b1g, app.g1g, 0); NSLog(@"%f"

how to undo/redo last touch action

社会主义新天地 提交于 2019-12-24 03:27:41
问题 I have an image which I am processing, and I have two buttons, undo and redo. I need the code to undo/redo previous touch action if either of those two buttons are clicked. I know I have to use a stack. How should I implement it? 回答1: There are two main patterns for implementing Undo/Redo: The "memento" pattern. The "command" pattern. 1. Memento Pattern The idea of the memento pattern is that you can save a copy of the entire internal state of an object (without violating encapsulation) to be