How does tinyMCE's undo work? - tinymce

One of my users has a major frustration with the undo feature in tinyMCE. Instead of undoing the last minor change, it undoes many changes. Is this a timing thing were a snapshot is taken every few seconds? Is this configurable?
Additional Information: The user is copying and pasting information from Word to the editor. Then cleaning up the crud that Word leaves behind. This includes deleting the extra blank lines between bullets, deleting extra garbage that the Paste from Word function leaves behind, etc. What happens is she does an oops and deletes too much. So she hits undo and it'll undo a lot more than the last oops. Making her do everything again. The undo has even completely removed all of the text she has pasted in initially (even though that wasn't the last edit).

Undo works in a special way. There are undo steps (snapshots of the editors content) produced by tinymce when special events occur (return, delete, paste, ... ). There is no interval in what snapshots are taken.
You even may catch events and add your own undo steps. Here is an example (i use in one of my own plugins):
// save undo step when space is pressed
ed.onKeyUp.add(function(ed, evt)
if (evt.keyCode == 32) {
ed.undoManager.add();
}
});
For more information have a look at the undomanager section of the tinymce api.

Related

VSCode annoying problem focus behavior, keeps jumping to a problem

Last Edit:
It appears I've had an F8 key being pressed non-stop, and it seems to be a shortcut for "Go to Next Error or Warning".
I've wrote a piece of code, it has an error which I'm aware of. Specifically, I'm trying to run a function which doesn't exist yet:
All good, I'm glad it is telling me there's a problem, but... I wish to keep writing stuff in the same file and I simply can't. Every so often the GUI keeps sending the caret (the place where my next piece of text will be written) to the beginning of the problematic piece of code. Simply speaking, I can't keep doing anything until I resolve the problem, since it forcefully intrudes my every action. Even more than that! When I go to a different file, with means of fixing the problem and adding the missing function, it once again interrupts me and forcefully takes me back to the problematic file to show me that there's a problem (??!?!?!). Closing it with "Esc" only closes it once, but it keeps on returning every several seconds.
I don't think it was like that just a week ago, and I didn't install any new plugin since then. I'm currently using the last version, 1.58.2.
How do I stop this work-flow-intruding behavior?
Edit:
I've kept on working for some time and it turns out the issue is much bigger than that. Whenever I type a name of some property, half way through some wild problem would jump and tell me "Cannot find name 'quar'. Did you mean 'quarter'?". The issue is basically the time delay of the problem checks, it's non-existent. It's also too intrusive, moving the caret and jumping between files to show me the existing problems. It's very recent, it didn't happen earlier this week. I've tried disabling different plugins I have and they're not the cause.
This is not exactly your issue, but could be related to what you are experiencing: https://github.com/microsoft/vscode/issues/68776
Try disabling the Outline Explorer and see what happens then.
Furthermore, see if disabling autosave improves anything.

ms-word object model: custom spellchecking underlines

in making a MS Word add-in spellchecker, i'm faced with the issue of "underlines". I can use the formatting functions of the Word Object Model in order to color the misspelled words or to underline them just how a user would with the U button, but it's not the same as the native ms-word curly underline which doesn't show if you copy-paste the text elsewhere, doesn't get printed or saved and doesn't show in undo actions. I have been searching how to do it, but everyone keeps saying it's not possible.
There is this English spellchecker called Grammarly, they do have a ms-word add-in and they somehow underline the misspelled words (though it's not curly, just a straight thick line) and it works just like MS-Word:
a) it doesn't get copy-pasted when you move the text with the underlines elsewhere, nor does it gets saved when you save the document
b) it doesn't get added in the undo stack.
So from a) and b) I conclude that it's not text formatting
So there must be a way, I was wondering how can I achieve this.
Thank you in advance for any ideas or tips.
Unfortunately, MS Word doesn't provide out of the box functionality that would allow you to implement this. The way how Grammarly and other add-ons with similar functionality do it is they show the transparent window on top of MS Word window using Windows API. Then they identify coordinates of words that need to be highlighted and draw the highlighting (rectangles or underlines) inside of that transparent window on top of those words. This is not an easy solution because it requires to identify the visible range which is currently shown on the screen, find the words in that range that need to be highlighted and also track the user's actions such as scrolling and window resizing so that to redraw the highlighting after those actions. But for sure it's possible because we have recently done it in the product I'm working on. As far as I know, there is no ready open-source solution for this so you will need to implement everything yourself.
You may also consider a much easier solution which is highlighting the words using the Find.HitHighlight functionality. An example of how it works you can see when you search for a simple word in MS Word. Although this is not a very flexible solution because the only thing you can change is the color of the highlighting.
I believe the way Grammarly adds emphasis to words and phrases it wants to flag is to change the document temporarily in a very smart and controlled way. Grammarly only works when one clicks the Open Grammarly button on the Grammarly ribbon. If you do a simple experiment, you may be able to observe how Grammarly controls its temporary changes.
First create an unsaved document with some misspelled words that trigger Microsoft Word to display the wavy red lines. Then click the Open Grammarly button. Notice that the add-in turns off spell checking and replaces Word's wavy red lines with its own web-triggered markings. These are probably generated in the document using code similar to:
myRange.Font.Underline = Microsoft.Office.Interop.Word.WdUnderline.wdUnderlineThick;
myRange.Font.UnderlineColor = Microsoft.Office.Interop.Word.WdColor.wdColorRed;
After observing this, save the document. If you look carefully at your screen (and if your computer is not super fast), you will see a small blink wherein the red thick underlines disappear for a brief moment. That is the Document.BeforeSave event removing the Grammarly markings before saving the document. By relying on user actions (such as when the user clicks the Grammarly ribbon button), Grammarly controls at what points in time the markings appear. It then uses code and events to make sure the markings are not saved with the document or interfere with other operations. The main events you would want to look at to replicate this behavior for your own spelling checker add-in would be:
Document.BeforeSave Event
Document.BeforePrint Event
Document.BeforeClose Event

Visual studio code editor deleting tabs after delay

Anyone knows how to disable automatic removing tabs on new line after delay? Like you can see on picture below, VS Code deletes tabs on new line everytime when I don't start typing very fast.
Something similar is situation when I'm writing comment, create space and wait for a while. VS Code will delete my last space.
I fixed this by turning off the setting "files.autoSave", (I didn't want that in any case.) or disable your formatting tool. (most likely cause)
My problem was that I had a formatting tool run on save, which was removing excess white space and therefore squashing my tabs during editing. Looks like you have the same problem to me.
You can affect a delay if you want to use the auto-save feature by setting auto save to afterDelay and setting the delay to your liking

How to generate track changes from files before and after changes are made?

I have two versions of a word document as two different files.
How can I get a track changed version?
Is there a way to compare them and merge as track changed version of these two documents?
PS: MS Word's comparing tool seems a solution it doesn't work for me. I need its "track changes" version.
First, turn on Track Changing
On the Review tab, in the Tracking group, click the Track Changes image.
To add a track changes indicator to the status bar, right-click the status bar and click Track Changes. Click the Track Changes indicator on the status bar to turn Track Changes on or off.
NOTE If the Track Changes command is unavailable, you might have to turn off document protection. On the Review tab, in the Protect group, click Protect Document, and then click Stop Protection at the bottom of the Protect Document task pane. (You might need to know the document password.)
NOW,
On the Tools menu, click Track Changes.
When the Track Changes feature is enabled, TRK appears on the status bar at the bottom of your document. When you turn off change tracking, TRK is dimmed.
Make the changes you want by inserting, deleting, or moving text or graphics. You can also change formatting.
Track changes while you edit
You can easily make and view tracked changes and comments while you work in a document. By default, Microsoft Office Word 2007 uses balloons to display deletions, comments, formatting changes, and content that has moved. If you want to see all of your changes inline, you can change settings so that tracked changes and comments display the way you want.
Balloons show formatting changes, comments, and deletions.
NOTE To prevent you from inadvertently distributing documents that contain tracked changes and comments, Word displays tracked changes and comments by default. Final Showing Markup is the default option in the Display for Review box.
Track changes while you edit
Open the document that you want to revise.
On the Review tab, in the Tracking group, click the Track Changes image.
To add a track changes indicator to the status bar, right-click the status bar and click Track Changes. Click the Track Changes indicator on the status bar to turn track changes on or off.
Make the changes that you want by inserting, deleting, moving, or formatting text or graphics. You can also add comments.

Eclipse IDE last edit location history - multiple steps back?

I'm now in a process of transition from Netbeans to Eclipse (Indigo).
Ctr+Q seems to have the same function - going back to the last edit location. But in Netbeans I was able to press Ctr+Q repeatedly and go further back without the need of altering the file content (undo and redo hack).
Is there such functionality in Eclipse?
Some info:
I'm using the JavaScript Development Toolkit, PDT, and YAML editor.
It seems that Back action (Alt+Left) is more or less the same. The difference is that it tracks any action, not only edits. Actions as "Go to declarations" are also included in the history of Alt+Left.
I think, in a way, it's more useful because I track back my real actions as in "real browsing" the code. Though I will switch the keyboard shortcuts for Last Edit and Previous Action so that I keep the Ctr+Q habit.
It is currently not possible in Eclipse. There is an old feature request for this functionality with Bugzilla id 72773 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=72773).
9 years later, check out Eclipse 4.17 (2020_09)
Multiple Last Edit Locations
Previous Edit Location navigation (formerly named Last Edit Location) is now expanded to remember multiple edit locations.
The last 15 edit locations are now remembered.
For convenience, similar edit locations in close proximity to each other are also merged so that each of the 15 remembered locations remains distinct.
How to use
Two new keyboard shortcuts are introduced:
Ctrl+Alt+LEFT_ARROW (or on Mac Ctrl+Opt+LEFT_ARROW) navigates to the most recent edit location, just as Ctrl+Q always has in prior releases.
However, now continuing to hold Ctrl+Alt and then pressing LEFT_ARROW again begins a traversal through the history of prior edit locations, with each additional press of LEFT_ARROW moving a step further back in history.
Once traversal stops, future Ctrl+Alt+LEFT_ARROW actions are now temporarily anchored to this older historical location for easy exploration of that code region.
The classic Ctrl+Q mapping has been likewise enhanced with this new functionality, so that Ctrl+Q and Ctrl+Alt+LEFT_ARROW are synonymous.
Ctrl+Alt+RIGHT_ARROW (or on Mac Ctrl+Opt+RIGHT_ARROW) conversely moves the anchor forward through edit history, so after traversing backward with Ctrl+Alt+LEFT_ARROW, you can go forward again by holding Ctrl+Alt and repeatedly pressing RIGHT_ARROW.
A new menu item has likewise been added for this forward navigation as well.
New edit locations are always inserted at the end, so original historical ordering is always maintained.
New edits also reset the last location "anchor" back to the most recent edit, so that pressing Ctrl+Alt+LEFT_ARROW once again brings you to the most recent edit rather than a historical one.
You can use the local history if you lost your undo redo functions.
to do that: 1/ right click anywhere on your code, 2/ Team, 3/ Show Local History, then choose the version you want according to edit time.