Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

draftmirror

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

draftmirror - npm Package Compare versions

Comparing version 0.6.1 to 0.7.0

lib/modifiers/raw.js

29

lib/editor.js

@@ -20,9 +20,11 @@ var React = require('react');

return {
spellCheck: true,
textAlignment: 'left',
decorators: [],
keymaps: [Keymap.createBase()],
inputRules: [],
getTooltip: function() { },
onChange: function() { }
spellCheck: true,
textAlignment: 'left',
decorators: [],
keymaps: [Keymap.createBase()],
inputRules: [],
getTooltip: function() { },
onChange: function() { },
onPasteText: function(text) { return text; },
onPastedContent: function(slice) { return slice; }
};

@@ -75,2 +77,13 @@ },

/**
* Transform pasted text
*/
onTransformPastedText: function(text) {
return this.props.onPasteText(text);
},
onTransformPastedContent: function(slice) {
return this.props.onPastedContent(slice);
},
/**
* Update decorators

@@ -185,2 +198,4 @@ */

this.editor.on.filterTransform[action](this.onFilterTransform);
this.editor.on.transformPastedText[action](this.onTransformPastedText);
this.editor.on.transformPasted[action](this.onTransformPastedContent);
this.editor.on.flush[action](this.onChanged);

@@ -187,0 +202,0 @@ },

@@ -15,2 +15,3 @@ var Editor = require('./editor');

var ListUtils = require('./modifiers/list');
var RawUtils = require('./modifiers/raw');

@@ -32,3 +33,4 @@ var createWidget = require('./widgets/createWidget');

module.exports.ListUtils = ListUtils;
module.exports.RawUtils = RawUtils;
module.exports.createWidget = createWidget;
module.exports.createDecorator = createDecorator;

@@ -203,6 +203,7 @@ var Immutable = require('immutable');

*/
EditorState.createForText = function(schema, text, docType, textType, styleType) {
EditorState.createForText = function(schema, text, docType, textType, styleType, brType) {
docType = docType || 'doc';
textType = textType || 'unstyled';
styleType = styleType || 'text';
brType = brType || 'hard_break';

@@ -216,6 +217,6 @@ text = normalizeNewline(text);

'content': line? [
{
line? {
type: styleType,
text: line
}
} : { type: brType }
] : []

@@ -222,0 +223,0 @@ };

@@ -53,2 +53,3 @@ var SelectionContext = require('../models/selectionContext');

*/
// TODO add 'separator' parameter
function getText(editorState) {

@@ -115,2 +116,21 @@ var selection = editorState.getSelection();

/**
* Surround the selection with some text before and after
* @param {EditorState} editorState
* @param {String} beforeText
* @param {String} afterText
* @return {EditorState}
*/
function surroundWithText(editorState, beforeText, afterText) {
return editorState.applyTransform(function (editor) {
var selection = editor.selection;
// After before before, to avoid messing up indexes
if (afterText) editor.tr.insertText(selection.to, afterText).apply();
if (beforeText) editor.tr.insertText(selection.from, beforeText).apply();
// Inserting at the end of the selection expand the selection
editor.setTextSelection(selection.from + beforeText.length, selection.to + beforeText.length);
});
}
/**
* Move cursor at the end of the document

@@ -156,3 +176,4 @@ * @param {EditorState} editorState

removeAt: removeAt,
replaceWithText: replaceWithText
replaceWithText: replaceWithText,
surroundWithText: surroundWithText
};
{
"name": "draftmirror",
"version": "0.6.1",
"version": "0.7.0",
"description": "React component for ProseMirror providing a Draft.js like API",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

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