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

prosemirror-inputrules

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prosemirror-inputrules - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

6

CHANGELOG.md

@@ -0,1 +1,7 @@

## 1.0.3 (2019-05-17)
### Bug fixes
Prevent input rules from running during compositions, since they will annoyingly interrupt them.
## 1.0.2 (2019-05-08)

@@ -2,0 +8,0 @@

39

dist/index.js

@@ -41,2 +41,3 @@ 'use strict';

function inputRules(ref) {
var this$1 = this;
var rules = ref.rules;

@@ -56,16 +57,12 @@

handleTextInput: function handleTextInput(view, from, to, text) {
var this$1 = this;
var state = view.state, $from = state.doc.resolve(from);
if ($from.parent.type.spec.code) { return false }
var textBefore = $from.parent.textBetween(Math.max(0, $from.parentOffset - MAX_MATCH), $from.parentOffset,
null, "\ufffc") + text;
for (var i = 0; i < rules.length; i++) {
var match = rules[i].match.exec(textBefore);
var tr = match && rules[i].handler(state, match, from - (match[0].length - text.length), to);
if (!tr) { continue }
view.dispatch(tr.setMeta(this$1, {transform: tr, from: from, to: to, text: text}));
return true
return run(view, from, to, text, rules, this)
},
handleDOMEvents: {
compositionend: function (view) {
setTimeout(function () {
var ref = view.state.selection;
var $cursor = ref.$cursor;
if ($cursor) { run(view, $cursor.pos, $cursor.pos, "", rules, this$1); }
});
}
return false
}

@@ -78,2 +75,18 @@ },

function run(view, from, to, text, rules, plugin) {
if (view.composing) { return false }
var state = view.state, $from = state.doc.resolve(from);
if ($from.parent.type.spec.code) { return false }
var textBefore = $from.parent.textBetween(Math.max(0, $from.parentOffset - MAX_MATCH), $from.parentOffset,
null, "\ufffc") + text;
for (var i = 0; i < rules.length; i++) {
var match = rules[i].match.exec(textBefore);
var tr = match && rules[i].handler(state, match, from - (match[0].length - text.length), to);
if (!tr) { continue }
view.dispatch(tr.setMeta(plugin, {transform: tr, from: from, to: to, text: text}));
return true
}
return false
}
// :: (EditorState, ?(Transaction)) → bool

@@ -80,0 +93,0 @@ // This is a command that will undo an input rule, if applying such a

{
"name": "prosemirror-inputrules",
"version": "1.0.2",
"version": "1.0.3",
"description": "Automatic transforms on text input for ProseMirror",

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

@@ -65,14 +65,11 @@ import {Plugin} from "prosemirror-state"

handleTextInput(view, from, to, text) {
let state = view.state, $from = state.doc.resolve(from)
if ($from.parent.type.spec.code) return false
let textBefore = $from.parent.textBetween(Math.max(0, $from.parentOffset - MAX_MATCH), $from.parentOffset,
null, "\ufffc") + text
for (let i = 0; i < rules.length; i++) {
let match = rules[i].match.exec(textBefore)
let tr = match && rules[i].handler(state, match, from - (match[0].length - text.length), to)
if (!tr) continue
view.dispatch(tr.setMeta(this, {transform: tr, from, to, text}))
return true
return run(view, from, to, text, rules, this)
},
handleDOMEvents: {
compositionend: (view) => {
setTimeout(() => {
let {$cursor} = view.state.selection
if ($cursor) run(view, $cursor.pos, $cursor.pos, "", rules, this)
})
}
return false
}

@@ -85,2 +82,18 @@ },

function run(view, from, to, text, rules, plugin) {
if (view.composing) return false
let state = view.state, $from = state.doc.resolve(from)
if ($from.parent.type.spec.code) return false
let textBefore = $from.parent.textBetween(Math.max(0, $from.parentOffset - MAX_MATCH), $from.parentOffset,
null, "\ufffc") + text
for (let i = 0; i < rules.length; i++) {
let match = rules[i].match.exec(textBefore)
let tr = match && rules[i].handler(state, match, from - (match[0].length - text.length), to)
if (!tr) continue
view.dispatch(tr.setMeta(plugin, {transform: tr, from, to, text}))
return true
}
return false
}
// :: (EditorState, ?(Transaction)) → bool

@@ -87,0 +100,0 @@ // This is a command that will undo an input rule, if applying such a

Sorry, the diff of this file is not supported yet

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