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

mobiledoc-kit

Package Overview
Dependencies
Maintainers
3
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.10.15 to 0.10.16

2

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

@@ -1233,3 +1233,3 @@ 'use strict';

// card).
// See: https://github.com/bustlelabs/mobiledoc-kit/issues/286
// See: https://github.com/bustle/mobiledoc-kit/issues/286
postEditor.setRange(card.tailPosition());

@@ -1236,0 +1236,0 @@ });

@@ -80,2 +80,12 @@ 'use strict';

}, {
str: 'META+U',
run: function run(editor) {
editor.toggleMarkup('u');
}
}, {
str: 'CTRL+U',
run: function run(editor) {
editor.toggleMarkup('u');
}
}, {
str: 'CTRL+K',

@@ -82,0 +92,0 @@ run: function run(editor) {

@@ -827,3 +827,3 @@ 'use strict';

// at the end of those.
// Prompted by https://github.com/bustlelabs/mobiledoc-kit/issues/360
// Prompted by https://github.com/bustle/mobiledoc-kit/issues/360

@@ -830,0 +830,0 @@ var markupsOpenAcrossRange = (0, _utilsArrayUtils.reduce)(markers, function (soFar, marker) {

@@ -74,4 +74,4 @@ 'use strict';

// the cursor.
// See https://github.com/bustlelabs/mobiledoc-kit/issues/68
// and https://github.com/bustlelabs/mobiledoc-kit/issues/75
// See https://github.com/bustle/mobiledoc-kit/issues/68
// and https://github.com/bustle/mobiledoc-kit/issues/75
if (marker.isMarker && endsWithSpace(text) && !marker.next) {

@@ -78,0 +78,0 @@ text = text.substr(0, text.length - 1) + NO_BREAK_SPACE;

@@ -214,2 +214,5 @@ 'use strict';

var parentNode = this.editor.element;
selection = (0, _utilsSelectionUtils.constrainSelectionTo)(selection, parentNode);
var _comparePosition = (0, _utilsSelectionUtils.comparePosition)(selection);

@@ -216,0 +219,0 @@

@@ -189,3 +189,3 @@ 'use strict';

/**
* @return {Boolean} If this position is at the head of its section
* @return {Boolean} If this position is at the tail of its section
*/

@@ -192,0 +192,0 @@ }, {

@@ -98,2 +98,50 @@ 'use strict';

function constrainNodeTo(node, parentNode, existingOffset) {
var compare = parentNode.compareDocumentPosition(node);
if (compare & Node.DOCUMENT_POSITION_CONTAINED_BY) {
// the node is inside parentNode, do nothing
return { node: node, offset: existingOffset };
} else if (compare & Node.DOCUMENT_POSITION_CONTAINS) {
// the node contains parentNode. This shouldn't happen.
return { node: node, offset: existingOffset };
} else if (compare & Node.DOCUMENT_POSITION_PRECEDING) {
// node is before parentNode. return start of deepest first child
var child = parentNode.firstChild;
while (child.firstChild) {
child = child.firstChild;
}
return { node: child, offset: 0 };
} else if (compare & Node.DOCUMENT_POSITION_FOLLOWING) {
// node is after parentNode. return end of deepest last child
var child = parentNode.lastChild;
while (child.lastChild) {
child = child.lastChild;
}
var offset = (0, _utilsDomUtils.isTextNode)(child) ? child.textContent.length : 1;
return { node: child, offset: offset };
} else {
return { node: node, offset: existingOffset };
}
}
/*
* Returns a new selection that is constrained within parentNode.
* If the anchorNode or focusNode are outside the parentNode, they are replaced with the beginning
* or end of the parentNode's children
*/
function constrainSelectionTo(selection, parentNode) {
var _constrainNodeTo = constrainNodeTo(selection.anchorNode, parentNode, selection.anchorOffset);
var anchorNode = _constrainNodeTo.node;
var anchorOffset = _constrainNodeTo.offset;
var _constrainNodeTo2 = constrainNodeTo(selection.focusNode, parentNode, selection.focusOffset);
var focusNode = _constrainNodeTo2.node;
var focusOffset = _constrainNodeTo2.offset;
return { anchorNode: anchorNode, anchorOffset: anchorOffset, focusNode: focusNode, focusOffset: focusOffset };
}
function comparePosition(_x3) {

@@ -197,2 +245,3 @@ var _again2 = true;

exports.comparePosition = comparePosition;
exports.findOffsetInNode = findOffsetInNode;
exports.findOffsetInNode = findOffsetInNode;
exports.constrainSelectionTo = constrainSelectionTo;
'use strict';
exports['default'] = '0.10.15';
exports['default'] = '0.10.16';
{
"name": "mobiledoc-kit",
"version": "0.10.15",
"version": "0.10.16",
"description": "A toolkit for building WYSIWYG editors with Mobiledoc",
"repository": "https://github.com/bustlelabs/mobiledoc-kit",
"repository": "https://github.com/bustle/mobiledoc-kit",
"scripts": {

@@ -47,3 +47,3 @@ "start": "broccoli serve --host 0.0.0.0",

"broccoli-cli": "^1.0.0",
"broccoli-funnel": "^1.0.1",
"broccoli-funnel": "^1.2.0",
"broccoli-livereload": "^1.0.0",

@@ -55,10 +55,10 @@ "broccoli-merge-trees": "^2.0.0",

"broccoli-test-builder": "^0.3.0",
"conventional-changelog": "^1.1.0",
"conventional-changelog-cli": "^1.2.0",
"jquery": "^3.0.0",
"conventional-changelog": "^1.1.3",
"conventional-changelog-cli": "^1.3.1",
"jquery": "^3.2.1",
"jsdoc": "^3.4.2",
"saucie": "^3.1.0",
"testem": "^1.7.4"
"testem": "^1.16.0"
},
"main": "dist/commonjs/mobiledoc-kit/index.js"
}

@@ -5,6 +5,6 @@ # Mobiledoc Kit

[![Dependency Status](https://david-dm.org/bustlelabs/mobiledoc-kit/master.svg)](https://david-dm.org/bustlelabs/mobiledoc-kit/master)
[![devDependency Status](https://david-dm.org/bustlelabs/mobiledoc-kit/master/dev-status.svg)](https://david-dm.org/bustlelabs/mobiledoc-kit/master#info=devDependencies)
[![Dependency Status](https://david-dm.org/bustle/mobiledoc-kit/master.svg)](https://david-dm.org/bustle/mobiledoc-kit/master)
[![devDependency Status](https://david-dm.org/bustle/mobiledoc-kit/master/dev-status.svg)](https://david-dm.org/bustle/mobiledoc-kit/master#info=devDependencies)
![Mobiledoc Logo](https://bustlelabs.github.io/mobiledoc-kit/demo/mobiledoc-logo-color-small.png)
![Mobiledoc Logo](https://bustle.github.io/mobiledoc-kit/demo/mobiledoc-logo-color-small.png)

@@ -20,4 +20,4 @@ Mobiledoc Kit (warning: beta) is a library for building WYSIWYG editors

| ----------- | ------- |
| Plain JavaScript | [mobiledoc-kit](https://github.com/bustlelabs/mobiledoc-kit) (this repo) |
| Ember | [ember-mobiledoc-editor](https://github.com/bustlelabs/ember-mobiledoc-editor) |
| Plain JavaScript | [mobiledoc-kit](https://github.com/bustle/mobiledoc-kit) (this repo) |
| Ember | [ember-mobiledoc-editor](https://github.com/bustle/ember-mobiledoc-editor) |
| React | [react-mobiledoc-editor](https://github.com/upworthy/react-mobiledoc-editor) |

@@ -30,6 +30,6 @@ | Vue | [vue-mobiledoc-editor](https://github.com/alidcastano/vue-mobiledoc-editor) |

| ---------- | ------- |
| Plain JavaScript In-Browser (DOM) | [mobiledoc-dom-renderer](https://github.com/bustlelabs/mobiledoc-dom-renderer) |
| Server-Side Rendering (HTML) | see [mobiledoc-dom-renderer's Rendering HTML section](https://github.com/bustlelabs/mobiledoc-dom-renderer#rendering-html) |
| Server-Side Rendering (Text-only, e.g. SEO) | [mobiledoc-text-renderer](https://github.com/bustlelabs/mobiledoc-text-renderer) |
| In-Browser (DOM) Rendering, with Ember | [ember-mobiledoc-dom-renderer](https://github.com/bustlelabs/ember-mobiledoc-dom-renderer) |
| Plain JavaScript In-Browser (DOM) | [mobiledoc-dom-renderer](https://github.com/bustle/mobiledoc-dom-renderer) |
| Server-Side Rendering (HTML) | see [mobiledoc-dom-renderer's Rendering HTML section](https://github.com/bustle/mobiledoc-dom-renderer#rendering-html) |
| Server-Side Rendering (Text-only, e.g. SEO) | [mobiledoc-text-renderer](https://github.com/bustle/mobiledoc-text-renderer) |
| In-Browser (DOM) Rendering, with Ember | [ember-mobiledoc-dom-renderer](https://github.com/bustle/ember-mobiledoc-dom-renderer) |

@@ -40,7 +40,7 @@ Mobiledoc is a deliberately simple and terse format, and you are encouraged to write your own renderer if you have other target output formats (e.g., a PDF renderer, an iOS Native Views Renderer, etc.).

Try a demo at [bustlelabs.github.io/mobiledoc-kit/demo](https://bustlelabs.github.io/mobiledoc-kit/demo/).
Try a demo at [bustle.github.io/mobiledoc-kit/demo](https://bustle.github.io/mobiledoc-kit/demo/).
## API Documentation
API Documentation is [available online](http://bustlelabs.github.io/mobiledoc-kit/demo/docs/).
API Documentation is [available online](http://bustle.github.io/mobiledoc-kit/demo/docs/).

@@ -58,6 +58,6 @@ ## Intro to Mobiledoc Kit

days. To learn more, see the docs for
**[Atoms](https://github.com/bustlelabs/mobiledoc-kit/blob/master/ATOMS.md)**,
**[Cards](https://github.com/bustlelabs/mobiledoc-kit/blob/master/CARDS.md)**
**[Atoms](https://github.com/bustle/mobiledoc-kit/blob/master/ATOMS.md)**,
**[Cards](https://github.com/bustle/mobiledoc-kit/blob/master/CARDS.md)**
and
**[Mobiledoc Renderers](https://github.com/bustlelabs/mobiledoc-kit/blob/master/RENDERERS.md)**
**[Mobiledoc Renderers](https://github.com/bustle/mobiledoc-kit/blob/master/RENDERERS.md)**

@@ -72,3 +72,3 @@ To learn more about the ideas behind Mobiledoc and the editor (note that the

The Mobiledoc kit saves posts in
**[Mobiledoc format](https://github.com/bustlelabs/mobiledoc-kit/blob/master/MOBILEDOC.md)**.
**[Mobiledoc format](https://github.com/bustle/mobiledoc-kit/blob/master/MOBILEDOC.md)**.

@@ -113,3 +113,3 @@ ### Usage

whenever it encounters an unknown atom
* `parserPlugins` - [array] See [DOM Parsing Hooks](https://github.com/bustlelabs/mobiledoc-kit#dom-parsing-hooks)
* `parserPlugins` - [array] See [DOM Parsing Hooks](https://github.com/bustle/mobiledoc-kit#dom-parsing-hooks)

@@ -156,3 +156,3 @@ The editor leverages unicode characters, so HTML documents must opt in to

* `position.marker` - Based on the section and offset, the marker this position
if on. A position may not always have a marker (for example a cursor before
is on. A position may not always have a marker (for example a cursor before
or after a card).

@@ -168,3 +168,3 @@ * `position.toRange(endPosition)` - Create a range based on two positions. Accepts

`Range` represent a range of a document. A range has a starting position
`Range` represents a range of a document. A range has a starting position
(`head`), ending position (`tail`), and a direction (for example highlighting

@@ -174,3 +174,3 @@ text left-to-right is a forward direction, highlighting right-to-left is a

Ranges are retured by serveral APIs, but most often you will be interested in
Ranges are returned by several APIs, but most often you will be interested in
the current range selected by the user (be it their cursor or an actual

@@ -188,3 +188,3 @@ selection). This can be accessed at `editor#range`. Several post editor APIs

* `range.focusedPosition` - If a range has a forward direction, then tail. If
it has a backward direction, the head.
it has a backward direction, then head.
* `range.extend(characterCount)` - Grow a range one character in whatever its

@@ -233,3 +233,6 @@ direction is.

* `editor.onTextInput()` - When the user adds text to the document (see [example](https://github.com/bustlelabs/mobiledoc-kit#responding-to-text-input))
* `editor.inputModeDidChange()` - The active section(s) or markup(s) at the current cursor position or selection have changed. This hook can be used with `Editor#activeMarkups` and `Editor#activeSections` to implement a custom toolbar.
For more details on the lifecycle hooks, see the [Editor documentation](https://bustlelabs.github.io/mobiledoc-kit/demo/docs/Editor.html).
### Programmatic Post Editing

@@ -264,6 +267,6 @@

For more details on the API of `postEditor`, see the [API documentation](https://github.com/bustlelabs/mobiledoc-kit/blob/master/src/js/editor/post.js).
For more details on the API of `postEditor`, see the [API documentation](https://github.com/bustle/mobiledoc-kit/blob/master/src/js/editor/post.js).
For more details on the API for the builder, required to create new sections
atoms, and markers, see the [builder API](https://github.com/bustlelabs/mobiledoc-kit/blob/master/src/js/models/post-node-builder.js).
atoms, and markers, see the [builder API](https://github.com/bustle/mobiledoc-kit/blob/master/src/js/models/post-node-builder.js).

@@ -390,3 +393,3 @@ ### Configuring hot keys

### Mobiledoc-kit and the Grammarly extension
`mobiledoc-kit` and the [Grammarly extension](https://www.grammarly.com/) do not play well together (see [issue 422](https://github.com/bustlelabs/mobiledoc-kit/issues/422)). Until this is resolved, you can avoid any such problems by disabling Grammarly for the `mobiledoc-kit` instances on your page. To do this, add the `data-gramm="false"` attribute to the `mobiledoc-kit` main DOM element.
`mobiledoc-kit` and the [Grammarly extension](https://www.grammarly.com/) do not play well together (see [issue 422](https://github.com/bustle/mobiledoc-kit/issues/422)). Until this is resolved, you can avoid any such problems by disabling Grammarly for the `mobiledoc-kit` instances on your page. To do this, add the `data-gramm="false"` attribute to the `mobiledoc-kit` main DOM element.

@@ -427,3 +430,3 @@ ## Contributing

If you notice a bug or have a feature request please [open an issue on github](https://github.com/bustlelabs/mobiledoc-kit/issues).
If you notice a bug or have a feature request please [open an issue on github](https://github.com/bustle/mobiledoc-kit/issues).
If you have a question about usage you can post in the [slack channel](https://mobiledoc-kit.slack.com/) (automatic invites available from our [slackin app](https://mobiledoc-slack.herokuapp.com/)) or on StackOverflow using the [`mobiledoc-kit` tag](http://stackoverflow.com/questions/tagged/mobiledoc-kit).

@@ -445,4 +448,4 @@

Visit [bustlelabs.github.io/mobiledoc-kit/demo](https://bustlelabs.github.io/mobiledoc-kit/demo).
Visit [bustle.github.io/mobiledoc-kit/demo](https://bustle.github.io/mobiledoc-kit/demo).
*Development of Mobiledoc and the supporting libraries was generously funded by [Bustle Labs](http://www.bustle.com/labs). Bustle Labs is the tech team behind the editorial staff at [Bustle](http://www.bustle.com), a fantastic and successful feminist and women’s interest site based in NYC.*

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

// card).
// See: https://github.com/bustlelabs/mobiledoc-kit/issues/286
// See: https://github.com/bustle/mobiledoc-kit/issues/286
postEditor.setRange(card.tailPosition());

@@ -1050,0 +1050,0 @@ });

@@ -62,2 +62,12 @@ import Key from '../utils/key';

}, {
str: 'META+U',
run(editor) {
editor.toggleMarkup('u');
}
}, {
str: 'CTRL+U',
run(editor) {
editor.toggleMarkup('u');
}
}, {
str: 'CTRL+K',

@@ -64,0 +74,0 @@ run(editor) {

@@ -693,3 +693,3 @@ import Position from '../utils/cursor/position';

// at the end of those.
// Prompted by https://github.com/bustlelabs/mobiledoc-kit/issues/360
// Prompted by https://github.com/bustle/mobiledoc-kit/issues/360

@@ -696,0 +696,0 @@ let markupsOpenAcrossRange = reduce(markers, function (soFar, marker) {

@@ -58,4 +58,4 @@ import CardNode from 'mobiledoc-kit/models/card-node';

// the cursor.
// See https://github.com/bustlelabs/mobiledoc-kit/issues/68
// and https://github.com/bustlelabs/mobiledoc-kit/issues/75
// See https://github.com/bustle/mobiledoc-kit/issues/68
// and https://github.com/bustle/mobiledoc-kit/issues/75
if (marker.isMarker && endsWithSpace(text) && !marker.next) {

@@ -62,0 +62,0 @@ text = text.substr(0, text.length - 1) + NO_BREAK_SPACE;

@@ -9,2 +9,3 @@ import {

import { DIRECTION } from '../utils/key';
import { constrainSelectionTo } from '../utils/selection-utils';

@@ -65,3 +66,5 @@ export { Position, Range };

const { selection, renderTree } = this;
let { selection, renderTree } = this;
let parentNode = this.editor.element;
selection = constrainSelectionTo(selection, parentNode);

@@ -68,0 +71,0 @@ const {

@@ -196,3 +196,3 @@ import { isTextNode } from 'mobiledoc-kit/utils/dom-utils';

/**
* @return {Boolean} If this position is at the head of its section
* @return {Boolean} If this position is at the tail of its section
*/

@@ -199,0 +199,0 @@ isTail() {

@@ -83,2 +83,49 @@ import { DIRECTION } from '../utils/key';

function constrainNodeTo(node, parentNode, existingOffset) {
let compare = parentNode.compareDocumentPosition(node);
if (compare & Node.DOCUMENT_POSITION_CONTAINED_BY) {
// the node is inside parentNode, do nothing
return { node, offset: existingOffset};
} else if (compare & Node.DOCUMENT_POSITION_CONTAINS) {
// the node contains parentNode. This shouldn't happen.
return { node, offset: existingOffset};
} else if (compare & Node.DOCUMENT_POSITION_PRECEDING) {
// node is before parentNode. return start of deepest first child
let child = parentNode.firstChild;
while (child.firstChild) {
child = child.firstChild;
}
return { node: child, offset: 0};
} else if (compare & Node.DOCUMENT_POSITION_FOLLOWING) {
// node is after parentNode. return end of deepest last child
let child = parentNode.lastChild;
while (child.lastChild) {
child = child.lastChild;
}
let offset = isTextNode(child) ? child.textContent.length : 1;
return {node: child, offset};
} else {
return { node, offset: existingOffset};
}
}
/*
* Returns a new selection that is constrained within parentNode.
* If the anchorNode or focusNode are outside the parentNode, they are replaced with the beginning
* or end of the parentNode's children
*/
function constrainSelectionTo(selection, parentNode) {
let {
node: anchorNode,
offset: anchorOffset
} = constrainNodeTo(selection.anchorNode, parentNode, selection.anchorOffset);
let {
node: focusNode,
offset: focusOffset
} = constrainNodeTo(selection.focusNode, parentNode, selection.focusOffset);
return { anchorNode, anchorOffset, focusNode, focusOffset };
}
function comparePosition(selection) {

@@ -161,3 +208,4 @@ let { anchorNode, focusNode, anchorOffset, focusOffset } = selection;

comparePosition,
findOffsetInNode
findOffsetInNode,
constrainSelectionTo
};

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

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