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.0-beta.1 to 0.9.0

2

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

@@ -65,2 +65,4 @@ 'use strict';

var log = _utilsLogger['default']['for']('editor'); /* jshint ignore:line */
_utilsLogger['default'].enableTypes(['mutation-handler', 'event-manager', 'editor']);

@@ -67,0 +69,0 @@ _utilsLogger['default'].disable();

25

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

@@ -155,24 +155,15 @@ 'use strict';

var key = _utilsKey['default'].fromEvent(event);
var range = undefined,
nextPosition = undefined;
var range = editor.range;
switch (true) {
case key.isHorizontalArrow():
range = editor.cursor.offsets;
var position = range.tail;
if (range.direction === _utilsKey.DIRECTION.BACKWARD) {
position = range.head;
var newRange = undefined;
if (key.isShift()) {
newRange = range.extend(key.direction);
} else {
newRange = range.move(key.direction);
}
var newRange = undefined;
nextPosition = position.move(key.direction);
if (nextPosition) {
if (key.isShift()) {
newRange = range.moveFocusedPosition(key.direction);
} else {
newRange = new _utilsCursorRange['default'](nextPosition);
}
editor.selectRange(newRange);
event.preventDefault();
}
editor.selectRange(newRange);
event.preventDefault();
break;

@@ -179,0 +170,0 @@ case key.isDelete():

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

/**
* @return {Position|null}
* The position to the left of this position.
* If this position is the post's headPosition it returns itself.
* @return {Position}
*/

@@ -125,3 +127,3 @@ }, {

var prev = this.section.previousLeafSection();
return prev && prev.tailPosition();
return prev ? prev.tailPosition() : this;
} else {

@@ -140,3 +142,5 @@ var offset = this.offset - 1;

/**
* @return {Position|null}
* The position to the right of this position.
* If this position is the post's tailPosition it returns itself.
* @return {Position}
*/

@@ -148,3 +152,3 @@ }, {

var next = this.section.nextLeafSection();
return next && next.headPosition();
return next ? next.headPosition() : this;
} else {

@@ -151,0 +155,0 @@ var offset = this.offset + 1;

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

var tail = arguments.length <= 1 || arguments[1] === undefined ? head : arguments[1];
var direction = arguments.length <= 2 || arguments[2] === undefined ? _key.DIRECTION.FORWARD : arguments[2];
var direction = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2];
return (function () {

@@ -45,15 +45,53 @@ _classCallCheck(this, Range);

}
/**
* Expands the range in the given direction
* @param {Direction} newDirection
* @return {Range} Always returns an expanded, non-collapsed range
* @public
*/
}, {
key: 'moveFocusedPosition',
value: function moveFocusedPosition(direction) {
switch (this.direction) {
key: 'extend',
value: function extend(newDirection) {
var head = this.head;
var tail = this.tail;
var direction = this.direction;
switch (direction) {
case _key.DIRECTION.FORWARD:
return new Range(this.head, this.tail.move(direction), this.direction);
return new Range(head, tail.move(newDirection), direction);
case _key.DIRECTION.BACKWARD:
return new Range(this.head.move(direction), this.tail, this.direction);
return new Range(head.move(newDirection), tail, direction);
default:
return new Range(this.head, this.tail, direction).moveFocusedPosition(direction);
return new Range(head, tail, newDirection).extend(newDirection);
}
}
/**
* Moves this range in {newDirection}.
* If the range is collapsed, returns a collapsed range shifted 1 unit in
* {newDirection}, otherwise collapses this range to the position at the
* {newDirection} end of the range.
* @param {Direction} newDirection
* @return {Range} Always returns a collapsed range
* @public
*/
}, {
key: 'move',
value: function move(newDirection) {
var focusedPosition = this.focusedPosition;
var isCollapsed = this.isCollapsed;
if (isCollapsed) {
return new Range(focusedPosition.move(newDirection));
} else {
return this._collapse(newDirection);
}
}
}, {
key: '_collapse',
value: function _collapse(direction) {
return new Range(direction === _key.DIRECTION.BACKWARD ? this.head : this.tail);
}
}, {
key: 'isEqual',

@@ -64,2 +102,7 @@ value: function isEqual(other) {

}, {
key: 'focusedPosition',
get: function get() {
return this.direction === _key.DIRECTION.BACKWARD ? this.head : this.tail;
}
}, {
key: 'isBlank',

@@ -121,4 +164,5 @@ get: function get() {

var tailOffset = arguments.length <= 3 || arguments[3] === undefined ? headOffset : arguments[3];
var direction = arguments.length <= 4 || arguments[4] === undefined ? null : arguments[4];
return (function () {
return new Range(new _position['default'](headSection, headOffset), new _position['default'](tailSection, tailOffset));
return new Range(new _position['default'](headSection, headOffset), new _position['default'](tailSection, tailOffset), direction);
})();

@@ -125,0 +169,0 @@ }

'use strict';
exports['default'] = '0.8.5';
exports['default'] = '0.9.0';
{
"name": "mobiledoc-kit",
"version": "0.9.0-beta.1",
"version": "0.9.0",
"description": "A toolkit for building WYSIWYG editors with Mobiledoc",

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

@@ -304,2 +304,3 @@ ## Mobiledoc Kit

* `npm run build`
* `git tag v<version>`
* `git push <origin> --follow-tags`

@@ -306,0 +307,0 @@ * `npm publish`

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

import Logger from 'mobiledoc-kit/utils/logger';
let log = Logger.for('editor'); /* jshint ignore:line */

@@ -42,0 +43,0 @@ Logger.enableTypes([

@@ -10,3 +10,2 @@ import assert from 'mobiledoc-kit/utils/assert';

import { TAB } from 'mobiledoc-kit/utils/characters';
import { DIRECTION } from 'mobiledoc-kit/utils/key';

@@ -111,23 +110,15 @@ const ELEMENT_EVENT_TYPES = ['keydown', 'keyup', 'cut', 'copy', 'paste', 'keypress'];

let key = Key.fromEvent(event);
let range, nextPosition;
let range = editor.range;
switch(true) {
case key.isHorizontalArrow():
range = editor.cursor.offsets;
let position = range.tail;
if (range.direction === DIRECTION.BACKWARD) {
position = range.head;
let newRange;
if (key.isShift()) {
newRange = range.extend(key.direction);
} else {
newRange = range.move(key.direction);
}
let newRange;
nextPosition = position.move(key.direction);
if (nextPosition) {
if (key.isShift()) {
newRange = range.moveFocusedPosition(key.direction);
} else {
newRange = new Range(nextPosition);
}
editor.selectRange(newRange);
event.preventDefault();
}
editor.selectRange(newRange);
event.preventDefault();
break;

@@ -134,0 +125,0 @@ case key.isDelete():

@@ -142,3 +142,5 @@ import {

/**
* @return {Position|null}
* The position to the left of this position.
* If this position is the post's headPosition it returns itself.
* @return {Position}
*/

@@ -148,3 +150,3 @@ moveLeft() {

let prev = this.section.previousLeafSection();
return prev && prev.tailPosition();
return prev ? prev.tailPosition() : this;
} else {

@@ -163,3 +165,5 @@ let offset = this.offset - 1;

/**
* @return {Position|null}
* The position to the right of this position.
* If this position is the post's tailPosition it returns itself.
* @return {Position}
*/

@@ -169,3 +173,3 @@ moveRight() {

let next = this.section.nextLeafSection();
return next && next.headPosition();
return next ? next.headPosition() : this;
} else {

@@ -172,0 +176,0 @@ let offset = this.offset + 1;

@@ -5,3 +5,3 @@ import Position from './position';

export default class Range {
constructor(head, tail=head, direction=DIRECTION.FORWARD) {
constructor(head, tail=head, direction=null) {
this.head = head;

@@ -12,6 +12,7 @@ this.tail = tail;

static create(headSection, headOffset, tailSection=headSection, tailOffset=headOffset) {
static create(headSection, headOffset, tailSection=headSection, tailOffset=headOffset, direction=null) {
return new Range(
new Position(headSection, headOffset),
new Position(tailSection, tailOffset)
new Position(tailSection, tailOffset),
direction
);

@@ -48,13 +49,47 @@ }

moveFocusedPosition(direction) {
switch (this.direction) {
/**
* Expands the range in the given direction
* @param {Direction} newDirection
* @return {Range} Always returns an expanded, non-collapsed range
* @public
*/
extend(newDirection) {
let { head, tail, direction } = this;
switch (direction) {
case DIRECTION.FORWARD:
return new Range(this.head, this.tail.move(direction), this.direction);
return new Range(head, tail.move(newDirection), direction);
case DIRECTION.BACKWARD:
return new Range(this.head.move(direction), this.tail, this.direction);
return new Range(head.move(newDirection), tail, direction);
default:
return new Range(this.head, this.tail, direction).moveFocusedPosition(direction);
return new Range(head, tail, newDirection).extend(newDirection);
}
}
/**
* Moves this range in {newDirection}.
* If the range is collapsed, returns a collapsed range shifted 1 unit in
* {newDirection}, otherwise collapses this range to the position at the
* {newDirection} end of the range.
* @param {Direction} newDirection
* @return {Range} Always returns a collapsed range
* @public
*/
move(newDirection) {
let { focusedPosition, isCollapsed } = this;
if (isCollapsed) {
return new Range(focusedPosition.move(newDirection));
} else {
return this._collapse(newDirection);
}
}
_collapse(direction) {
return new Range(direction === DIRECTION.BACKWARD ? this.head : this.tail);
}
get focusedPosition() {
return this.direction === DIRECTION.BACKWARD ? this.head : this.tail;
}
isEqual(other) {

@@ -61,0 +96,0 @@ return other &&

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

export default '0.9.0-beta.1';
export default '0.9.0';

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