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

mobiledoc-kit

Package Overview
Dependencies
Maintainers
2
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobiledoc-kit - npm Package Compare versions

Comparing version 0.9.4-beta.1 to 0.9.4-beta.2

108

dist/commonjs/mobiledoc-kit/editor/editor.js

@@ -965,3 +965,5 @@ 'use strict';

* Inserts the text at the current cursor position. If the editor has
* no current cursor position, nothing will be inserted.
* no current cursor position, nothing will be inserted. If the editor's
* range is not collapsed, it will be deleted before insertion.
*
* @param {String} text

@@ -973,2 +975,8 @@ * @public

value: function insertText(text) {
if (!this.hasCursor()) {
return;
}
if (this.post.isBlank) {
this._insertEmptyMarkupSectionAtCursor();
}
var activeMarkups = this.activeMarkups;

@@ -988,2 +996,100 @@ var range = this.range;

/**
* Inserts an atom at the current cursor position. If the editor has
* no current cursor position, nothing will be inserted. If the editor's
* range is not collapsed, it will be deleted before insertion.
* @param {String} atomName
* @param {String} [atomText='']
* @param {Object} [atomPayload={}]
* @public
*/
}, {
key: 'insertAtom',
value: function insertAtom(atomName) {
var atomText = arguments.length <= 1 || arguments[1] === undefined ? '' : arguments[1];
var atomPayload = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
if (!this.hasCursor()) {
return;
}
if (this.post.isBlank) {
this._insertEmptyMarkupSectionAtCursor();
}
var range = this.range;
this.run(function (postEditor) {
var position = range.head;
var atom = postEditor.builder.createAtom(atomName, atomText, atomPayload);
if (!range.isCollapsed) {
position = postEditor.deleteRange(range);
}
postEditor.insertMarkers(position, [atom]);
});
}
/**
* Inserts a card at the section after the current cursor position. If the editor has
* no current cursor position, nothing will be inserted. If the editor's
* range is not collapsed, it will be deleted before insertion. If the cursor is in
* a blank section, it will be replaced with a card section.
* The editor's cursor will be placed at the end of the inserted card.
* @param {String} cardName
* @param {Object} [cardPayload={}]
* @param {Boolean} [inEditMode=false] Whether the card should be inserted in edit mode.
* @public
*/
}, {
key: 'insertCard',
value: function insertCard(cardName) {
var _this7 = this;
var cardPayload = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var inEditMode = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2];
if (!this.hasCursor()) {
return;
}
if (this.post.isBlank) {
this._insertEmptyMarkupSectionAtCursor();
}
var range = this.range;
this.run(function (postEditor) {
var position = range.tail;
var card = postEditor.builder.createCardSection(cardName, cardPayload);
if (inEditMode) {
_this7.editCard(card);
}
if (!range.isCollapsed) {
position = postEditor.deleteRange(range);
}
var section = position.section;
if (section.isNested) {
section = section.parent;
}
if (section.isBlank) {
postEditor.replaceSection(section, card);
} else {
var collection = _this7.post.sections;
postEditor.insertSectionBefore(collection, card, section.next);
}
// It is important to explicitly set the range to the end of the card.
// Otherwise it is possible to create an inconsistent state in the
// browser. For instance, if the user clicked a button that
// called `editor.insertCard`, the editor surface may retain
// the selection but lose focus, and the next keystroke by the user
// will cause an unexpected DOM mutation (which can wipe out the
// card).
// See: https://github.com/bustlelabs/mobiledoc-kit/issues/286
postEditor.setRange(new _utilsCursorRange['default'](card.tailPosition()));
});
}
/**
* @param {integer} x x-position in viewport

@@ -990,0 +1096,0 @@ * @param {integer} y y-position in viewport

2

dist/commonjs/mobiledoc-kit/version.js
'use strict';
exports['default'] = '0.9.4-beta.1';
exports['default'] = '0.9.4-beta.2';
{
"name": "mobiledoc-kit",
"version": "0.9.4-beta.1",
"version": "0.9.4-beta.2",
"description": "A toolkit for building WYSIWYG editors with Mobiledoc",

@@ -5,0 +5,0 @@ "repository": "https://github.com/bustlelabs/mobiledoc-kit",

@@ -856,3 +856,5 @@ import Tooltip from '../views/tooltip';

* Inserts the text at the current cursor position. If the editor has
* no current cursor position, nothing will be inserted.
* no current cursor position, nothing will be inserted. If the editor's
* range is not collapsed, it will be deleted before insertion.
*
* @param {String} text

@@ -862,2 +864,6 @@ * @public

insertText(text) {
if (!this.hasCursor()) { return; }
if (this.post.isBlank) {
this._insertEmptyMarkupSectionAtCursor();
}
let { activeMarkups, range, range: { head: position } } = this;

@@ -875,2 +881,80 @@

/**
* Inserts an atom at the current cursor position. If the editor has
* no current cursor position, nothing will be inserted. If the editor's
* range is not collapsed, it will be deleted before insertion.
* @param {String} atomName
* @param {String} [atomText='']
* @param {Object} [atomPayload={}]
* @public
*/
insertAtom(atomName, atomText='', atomPayload={}) {
if (!this.hasCursor()) { return; }
if (this.post.isBlank) {
this._insertEmptyMarkupSectionAtCursor();
}
let { range } = this;
this.run(postEditor => {
let position = range.head;
let atom = postEditor.builder.createAtom(atomName, atomText, atomPayload);
if (!range.isCollapsed) {
position = postEditor.deleteRange(range);
}
postEditor.insertMarkers(position, [atom]);
});
}
/**
* Inserts a card at the section after the current cursor position. If the editor has
* no current cursor position, nothing will be inserted. If the editor's
* range is not collapsed, it will be deleted before insertion. If the cursor is in
* a blank section, it will be replaced with a card section.
* The editor's cursor will be placed at the end of the inserted card.
* @param {String} cardName
* @param {Object} [cardPayload={}]
* @param {Boolean} [inEditMode=false] Whether the card should be inserted in edit mode.
* @public
*/
insertCard(cardName, cardPayload={}, inEditMode=false) {
if (!this.hasCursor()) { return; }
if (this.post.isBlank) {
this._insertEmptyMarkupSectionAtCursor();
}
let { range } = this;
this.run(postEditor => {
let position = range.tail;
let card = postEditor.builder.createCardSection(cardName, cardPayload);
if (inEditMode) {
this.editCard(card);
}
if (!range.isCollapsed) {
position = postEditor.deleteRange(range);
}
let section = position.section;
if (section.isNested) { section = section.parent; }
if (section.isBlank) {
postEditor.replaceSection(section, card);
} else {
let collection = this.post.sections;
postEditor.insertSectionBefore(collection, card, section.next);
}
// It is important to explicitly set the range to the end of the card.
// Otherwise it is possible to create an inconsistent state in the
// browser. For instance, if the user clicked a button that
// called `editor.insertCard`, the editor surface may retain
// the selection but lose focus, and the next keystroke by the user
// will cause an unexpected DOM mutation (which can wipe out the
// card).
// See: https://github.com/bustlelabs/mobiledoc-kit/issues/286
postEditor.setRange(new Range(card.tailPosition()));
});
}
/**
* @param {integer} x x-position in viewport

@@ -877,0 +961,0 @@ * @param {integer} y y-position in viewport

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

export default '0.9.4-beta.1';
export default '0.9.4-beta.2';

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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