Codemirror, create a new document in the same editor

229
January 21, 2018, at 7:22 PM

What is is correct process for creating a new document (or switching documents) in Code Mirror so that the document history is not transferred to new document?

When I set the content of a new document and then do an undo, the content of the file is replaced with the content of the previous file.

Currently my code that switches files looks something like this:

$('#file-list').on('click', 'li', function () { 
    var el = $(this),
        filename = el.data('file'),
        f = files[filename];
    $('#theme-file-active li').removeClass('active');
    el.addClass('active');
    var doc = cm.getDoc();
    cm.swapDoc(doc);
    doc.clearHistory();
    cm.setValue (f.content);
    doc.setHistory(f.history);
});
Rent Charter Buses Company
READ ALSO
How to simply change,get or set any attribute in react

How to simply change,get or set any attribute in react

I need to convert my jquery application into React completely and don't know how to get, set any attribute in ReactI'm doing it with jquery but no idea how to start it with react

321
Attatch event listener to all elements by selector in JavaScript from document

Attatch event listener to all elements by selector in JavaScript from document

In jQuery, you can add an event listener to the document usingon() with a selector as the 2nd argument to listen to all events sent to specific elements, even if the HTML is dynamically changes

302
.Each will lag the website

.Each will lag the website

I am trying to manupulate the DOM, but code I am using is slowing down the websiteI think

239
Output of different time back-calculations without a change once displayed

Output of different time back-calculations without a change once displayed

I want to show several types of dates depending on the actual day and timeBut I do not want to change the output once generated

193