mobiledoc-kit
Advanced tools
Comparing version 0.9.5 to 0.9.6
@@ -125,2 +125,4 @@ 'use strict'; | ||
* a custom toolbar. | ||
* * {@link Editor#onTextInput} -- Register callbacks when the user enters text | ||
* that matches a given string or regex. | ||
*/ | ||
@@ -127,0 +129,0 @@ |
@@ -26,2 +26,20 @@ 'use strict'; | ||
function gotoStartOfLine(editor) { | ||
var range = editor.range; | ||
var section = range.tail.section; | ||
editor.run(function (postEditor) { | ||
postEditor.setRange(new _utilsCursorRange['default'](section.headPosition())); | ||
}); | ||
} | ||
function gotoEndOfLine(editor) { | ||
var range = editor.range; | ||
var section = range.tail.section; | ||
editor.run(function (postEditor) { | ||
postEditor.setRange(new _utilsCursorRange['default'](section.tailPosition())); | ||
}); | ||
} | ||
var DEFAULT_KEY_COMMANDS = [{ | ||
@@ -64,10 +82,3 @@ str: 'META+B', | ||
if (_utilsBrowser['default'].isMac) { | ||
(function () { | ||
var range = editor.range; | ||
var section = range.head.section; | ||
editor.run(function (postEditor) { | ||
postEditor.setRange(new _utilsCursorRange['default'](section.headPosition())); | ||
}); | ||
})(); | ||
gotoStartOfLine(editor); | ||
} else { | ||
@@ -78,2 +89,9 @@ selectAll(editor); | ||
}, { | ||
str: 'META+LEFT', | ||
run: function run(editor) { | ||
if (_utilsBrowser['default'].isMac) { | ||
gotoStartOfLine(editor); | ||
} | ||
} | ||
}, { | ||
str: 'META+A', | ||
@@ -88,13 +106,14 @@ run: function run(editor) { | ||
run: function run(editor) { | ||
if (!_utilsBrowser['default'].isMac) { | ||
return false; | ||
if (_utilsBrowser['default'].isMac) { | ||
gotoEndOfLine(editor); | ||
} | ||
var range = editor.range; | ||
var section = range.tail.section; | ||
editor.run(function (postEditor) { | ||
postEditor.setRange(new _utilsCursorRange['default'](section.tailPosition())); | ||
}); | ||
} | ||
}, { | ||
str: 'META+RIGHT', | ||
run: function run(editor) { | ||
if (_utilsBrowser['default'].isMac) { | ||
gotoEndOfLine(editor); | ||
} | ||
} | ||
}, { | ||
str: 'META+K', | ||
@@ -101,0 +120,0 @@ run: function run(editor) { |
@@ -61,2 +61,9 @@ 'use strict'; | ||
}, { | ||
key: 'didRender', | ||
value: function didRender() { | ||
if (this._didRenderCallback) { | ||
this._didRenderCallback(); | ||
} | ||
} | ||
}, { | ||
key: 'display', | ||
@@ -92,2 +99,3 @@ value: function display() { | ||
this._rendered = rendered; | ||
this.didRender(); | ||
} | ||
@@ -105,2 +113,5 @@ }, { | ||
}, | ||
didRender: function didRender(callback) { | ||
return _this2._didRenderCallback = callback; | ||
}, | ||
edit: function edit() { | ||
@@ -107,0 +118,0 @@ return _this2.edit(); |
@@ -108,3 +108,3 @@ 'use strict'; | ||
value: function isMovement() { | ||
return this.isArrow(); | ||
return this.isArrow() || this.isHome() || this.isEnd(); | ||
} | ||
@@ -137,2 +137,12 @@ }, { | ||
}, { | ||
key: 'isHome', | ||
value: function isHome() { | ||
return this.keyCode === _keycodes['default'].HOME; | ||
} | ||
}, { | ||
key: 'isEnd', | ||
value: function isEnd() { | ||
return this.keyCode === _keycodes['default'].END; | ||
} | ||
}, { | ||
key: 'isSpace', | ||
@@ -139,0 +149,0 @@ value: function isSpace() { |
'use strict'; | ||
exports['default'] = '0.9.5'; | ||
exports['default'] = '0.9.6'; |
{ | ||
"name": "mobiledoc-kit", | ||
"version": "0.9.5", | ||
"version": "0.9.6", | ||
"description": "A toolkit for building WYSIWYG editors with Mobiledoc", | ||
@@ -45,3 +45,3 @@ "repository": "https://github.com/bustlelabs/mobiledoc-kit", | ||
"broccoli-inject-livereload": "^0.2.0", | ||
"broccoli-less-single": "^0.6.0", | ||
"broccoli-less-single": "^0.6.2", | ||
"broccoli-merge-trees": "^1.0.0", | ||
@@ -53,3 +53,3 @@ "broccoli-multi-builder": "^0.2.8", | ||
"conventional-changelog": "^1.1.0", | ||
"conventional-changelog-cli": "^1.1.1", | ||
"conventional-changelog-cli": "^1.2.0", | ||
"jquery": "^2.2.2", | ||
@@ -56,0 +56,0 @@ "jsdoc": "^3.4.0", |
@@ -87,2 +87,4 @@ import Tooltip from '../views/tooltip'; | ||
* a custom toolbar. | ||
* * {@link Editor#onTextInput} -- Register callbacks when the user enters text | ||
* that matches a given string or regex. | ||
*/ | ||
@@ -89,0 +91,0 @@ class Editor { |
@@ -14,2 +14,18 @@ import Key from '../utils/key'; | ||
function gotoStartOfLine(editor) { | ||
let {range} = editor; | ||
let {tail: {section}} = range; | ||
editor.run(postEditor => { | ||
postEditor.setRange(new Range(section.headPosition())); | ||
}); | ||
} | ||
function gotoEndOfLine(editor) { | ||
let {range} = editor; | ||
let {tail: {section}} = range; | ||
editor.run(postEditor => { | ||
postEditor.setRange(new Range(section.tailPosition())); | ||
}); | ||
} | ||
export const DEFAULT_KEY_COMMANDS = [{ | ||
@@ -51,7 +67,3 @@ str: 'META+B', | ||
if (Browser.isMac) { | ||
let {range} = editor; | ||
let {head: {section}} = range; | ||
editor.run(postEditor => { | ||
postEditor.setRange(new Range(section.headPosition())); | ||
}); | ||
gotoStartOfLine(editor); | ||
} else { | ||
@@ -62,2 +74,9 @@ selectAll(editor); | ||
}, { | ||
str: 'META+LEFT', | ||
run(editor) { | ||
if (Browser.isMac) { | ||
gotoStartOfLine(editor); | ||
} | ||
} | ||
}, { | ||
str: 'META+A', | ||
@@ -72,10 +91,14 @@ run(editor) { | ||
run(editor) { | ||
if (!Browser.isMac) { return false; } | ||
let {range} = editor; | ||
let {tail: {section}} = range; | ||
editor.run(postEditor => { | ||
postEditor.setRange(new Range(section.tailPosition())); | ||
}); | ||
if (Browser.isMac) { | ||
gotoEndOfLine(editor); | ||
} | ||
} | ||
}, { | ||
str: 'META+RIGHT', | ||
run(editor) { | ||
if (Browser.isMac) { | ||
gotoEndOfLine(editor); | ||
} | ||
} | ||
}, { | ||
str: 'META+K', | ||
@@ -82,0 +105,0 @@ run(editor) { |
@@ -49,2 +49,8 @@ import assert from '../utils/assert'; | ||
didRender() { | ||
if (this._didRenderCallback) { | ||
this._didRenderCallback(); | ||
} | ||
} | ||
get env() { | ||
@@ -55,2 +61,3 @@ return { | ||
onTeardown: (callback) => this._teardownCallback = callback, | ||
didRender: (callback) => this._didRenderCallback = callback, | ||
edit: () => this.edit(), | ||
@@ -95,3 +102,4 @@ save: (payload, transition=true) => { | ||
this._rendered = rendered; | ||
this.didRender(); | ||
} | ||
} |
@@ -98,3 +98,3 @@ import Keycodes from './keycodes'; | ||
isMovement() { | ||
return this.isArrow(); | ||
return this.isArrow() || this.isHome() || this.isEnd(); | ||
} | ||
@@ -124,2 +124,10 @@ | ||
isHome() { | ||
return this.keyCode === Keycodes.HOME; | ||
} | ||
isEnd() { | ||
return this.keyCode === Keycodes.END; | ||
} | ||
get direction() { | ||
@@ -126,0 +134,0 @@ switch (true) { |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2964219
42529
59