New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

scribe-editor

Package Overview
Dependencies
Maintainers
9
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scribe-editor - npm Package Compare versions

Comparing version 1.2.10 to 1.2.11

4

CHANGELOG.md

@@ -0,1 +1,5 @@

# 1.2.11
Added configuration for removing `scribe.undoManager`
# 1.2.10

@@ -2,0 +6,0 @@

2

package.json
{
"name": "scribe-editor",
"version": "1.2.10",
"version": "1.2.11",
"main": "src/scribe.js",

@@ -5,0 +5,0 @@ "dependencies": {

@@ -52,3 +52,5 @@ Scribe [![Build Status](https://travis-ci.org/guardian/scribe.svg?branch=master)](https://travis-ci.org/guardian/scribe)

<dt><pre>defaultCommandPatches</pre></dt>
<dd>Defines which command patches should be loaded by default</dd>
<dd>Defines which command patches should be loaded by default</dd>
<dt><pre>undo: { enabled: false }</pre></dt>
<dd>Enable/disable Scribe's custom undo manager</dd>
</dl>

@@ -190,2 +192,11 @@

Scribe's undo manager can be turned off by configuration eg:
``` js
var scribe = new Scribe(scribeElement, {
undo: {
enabled: false
}
})
```
[browser inconsistencies]: https://github.com/guardian/scribe/blob/master/BROWSERINCONSISTENCIES.md

@@ -192,0 +203,0 @@ [Executing Commands]: https://developer.mozilla.org/en-US/docs/Rich-Text_Editing_in_Mozilla#Executing_Commands

@@ -10,2 +10,3 @@ define(function () {

redoCommand.execute = function () {
var historyItem = scribe.undoManager.redo();

@@ -24,8 +25,11 @@

scribe.el.addEventListener('keydown', function (event) {
if (event.shiftKey && (event.metaKey || event.ctrlKey) && event.keyCode === 90) {
event.preventDefault();
redoCommand.execute();
}
});
//is scribe is configured to undo assign listener
if (scribe.options.undo.enabled) {
scribe.el.addEventListener('keydown', function (event) {
if (event.shiftKey && (event.metaKey || event.ctrlKey) && event.keyCode === 90) {
event.preventDefault();
redoCommand.execute();
}
});
}
};

@@ -32,0 +36,0 @@ };

@@ -23,9 +23,11 @@ define(function () {

scribe.el.addEventListener('keydown', function (event) {
// TODO: use lib to abstract meta/ctrl keys?
if (! event.shiftKey && (event.metaKey || event.ctrlKey) && event.keyCode === 90) {
event.preventDefault();
undoCommand.execute();
}
});
if (scribe.options.undo.enabled) {
scribe.el.addEventListener('keydown', function (event) {
// TODO: use lib to abstract meta/ctrl keys?
if (! event.shiftKey && (event.metaKey || event.ctrlKey) && event.keyCode === 90) {
event.preventDefault();
undoCommand.execute();
}
});
}
};

@@ -32,0 +34,0 @@ };

@@ -95,5 +95,7 @@ define([

if (isEditorActive) {
// Discard the last history item, as we're going to be adding
// a new clean history item next.
scribe.undoManager.undo();
if (scribe.undoManager) {
// Discard the last history item, as we're going to be adding
// a new clean history item next.
scribe.undoManager.undo();
}

@@ -100,0 +102,0 @@ // Pass content through formatters, place caret back

@@ -50,3 +50,5 @@ define([], function () {

*/
scribe.undoManager.undo();
if (scribe.undoManager) {
scribe.undoManager.undo();
}

@@ -53,0 +55,0 @@ scribe.transactionManager.run(function () {

@@ -50,2 +50,3 @@ define([

debug: false,
undo: { enabled: true },
defaultCommandPatches: [

@@ -75,4 +76,8 @@ 'bold',

var UndoManager = buildUndoManager(this);
this.undoManager = new UndoManager();
//added for explicit checking later eg if (scribe.undoManager) { ... }
this.undoManager = false;
if (this.options.undo.enabled) {
var UndoManager = buildUndoManager(this);
this.undoManager = new UndoManager();
}

@@ -180,26 +185,31 @@ this.el.setAttribute('contenteditable', true);

Scribe.prototype.pushHistory = function () {
var previousUndoItem = this.undoManager.stack[this.undoManager.position];
var previousContent = previousUndoItem && previousUndoItem
.replace(/<em class="scribe-marker">/g, '').replace(/<\/em>/g, '');
if (this.options.undo.enabled) {
var previousUndoItem = this.undoManager.stack[this.undoManager.position];
var previousContent = previousUndoItem && previousUndoItem
.replace(/<em class="scribe-marker">/g, '').replace(/<\/em>/g, '');
/**
* Chrome and Firefox: If we did push to the history, this would break
* browser magic around `Document.queryCommandState` (http://jsbin.com/eDOxacI/1/edit?js,console,output).
* This happens when doing any DOM manipulation.
*/
/**
* Chrome and Firefox: If we did push to the history, this would break
* browser magic around `Document.queryCommandState` (http://jsbin.com/eDOxacI/1/edit?js,console,output).
* This happens when doing any DOM manipulation.
*/
// We only want to push the history if the content actually changed.
if (! previousUndoItem || (previousUndoItem && this.getHTML() !== previousContent)) {
var selection = new this.api.Selection();
// We only want to push the history if the content actually changed.
if (! previousUndoItem || (previousUndoItem && this.getHTML() !== previousContent)) {
var selection = new this.api.Selection();
selection.placeMarkers();
var html = this.getHTML();
selection.removeMarkers();
selection.placeMarkers();
var html = this.getHTML();
selection.removeMarkers();
this.undoManager.push(html);
this.undoManager.push(html);
return true;
return true;
} else {
return false;
}
} else {
return false;
}
};

@@ -266,3 +276,3 @@

};
/**

@@ -269,0 +279,0 @@ * Applies HTML formatting to all editor text.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc