diff --git a/.eslintrc b/.eslintrc
index 3d3271873..e48b87ac4 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -1,8 +1,6 @@
{
- "plugins": [
- "import",
- "react"
- ],
+ "extends": ["prettier", "prettier/react"],
+ "plugins": ["import", "react", "prettier"],
"settings": {
"import/extensions": [".js"]
},
@@ -18,19 +16,8 @@
"node": true
},
"rules": {
- "arrow-parens": ["error", "as-needed", { "requireForBlockBody": true }],
- "arrow-spacing": "error",
- "block-spacing": "error",
- "comma-dangle": ["error", "only-multiline"],
- "comma-spacing": ["error", { "before": false, "after": true }],
- "comma-style": ["error", "last"],
- "computed-property-spacing": ["error", "never"],
"constructor-super": "error",
- "curly": ["error", "multi-line"],
- "dot-location": ["error", "property"],
"dot-notation": ["error", { "allowKeywords": true }],
- "eol-last": "error",
- "func-call-spacing": ["error", "never"],
"import/default": "error",
"import/export": "error",
"import/first": "error",
@@ -38,18 +25,25 @@
"import/namespace": "error",
"import/newline-after-import": "error",
"import/no-deprecated": "error",
- "import/no-extraneous-dependencies": ["error", { "peerDependencies": true }],
+ "import/no-extraneous-dependencies": [
+ "error",
+ { "peerDependencies": true }
+ ],
"import/no-mutable-exports": "error",
"import/no-named-as-default": "error",
"import/no-named-as-default-member": "error",
"import/no-unresolved": "error",
- "indent": ["error", 2, { "SwitchCase": 1, "MemberExpression": 1 }],
- "jsx-quotes": ["error", "prefer-double"],
- "key-spacing": ["error", { "beforeColon": false, "afterColon": true }],
- "keyword-spacing": ["error", { "before": true, "after": true }],
"linebreak-style": "error",
- "lines-around-comment": ["error", { "beforeBlockComment": true, "afterBlockComment": true, "allowBlockStart": true, "allowObjectStart": true, "allowArrayStart": true }],
- "new-parens": "error",
+ "lines-around-comment": [
+ "error",
+ {
+ "beforeBlockComment": true,
+ "afterBlockComment": true,
+ "allowBlockStart": true,
+ "allowObjectStart": true,
+ "allowArrayStart": true
+ }
+ ],
"no-array-constructor": "error",
"no-class-assign": "error",
"no-console": "error",
@@ -68,9 +62,6 @@
"no-func-assign": "error",
"no-invalid-regexp": "error",
"no-lonely-if": "error",
- "no-mixed-spaces-and-tabs": ["error", false],
- "no-multi-spaces": "error",
- "no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1 }],
"no-native-reassign": "error",
"no-negated-in-lhs": "error",
"no-new-object": "error",
@@ -78,15 +69,29 @@
"no-path-concat": "error",
"no-redeclare": "error",
"no-regex-spaces": "error",
- "no-restricted-globals": ["error", "Debug", "document", "Document", "event", "history", "History", "length", "Map", "Node", "parent", "Range", "Selection", "Set", "Text"],
+ "no-restricted-globals": [
+ "error",
+ "Debug",
+ "document",
+ "Document",
+ "event",
+ "history",
+ "History",
+ "length",
+ "Map",
+ "Node",
+ "parent",
+ "Range",
+ "Selection",
+ "Set",
+ "Text"
+ ],
"no-sequences": "error",
"no-shadow": "error",
"no-shadow-restricted-names": "error",
- "no-spaced-func": "error",
"no-tabs": "error",
"no-this-before-super": "error",
"no-throw-literal": "error",
- "no-trailing-spaces": "error",
"no-undef": "error",
"no-unneeded-ternary": "error",
"no-unreachable": "error",
@@ -100,31 +105,24 @@
"no-useless-rename": "error",
"no-var": "error",
"no-void": "error",
- "no-whitespace-before-property": "error",
"no-with": "error",
- "object-curly-spacing": ["error", "always", { "objectsInObjects": false }],
- "object-property-newline": ["error", { "allowMultiplePropertiesPerLine": true }],
"object-shorthand": ["error", "always"],
- "operator-linebreak": ["error", "after", { "overrides": { "?": "ignore", ":": "ignore" }}],
- "padded-blocks": ["error", { "blocks": "never", "classes": "always" }],
"prefer-arrow-callback": "error",
- "prefer-const": ["error", { "destructuring": "all", "ignoreReadBeforeAssign": true }],
+ "prefer-const": [
+ "error",
+ { "destructuring": "all", "ignoreReadBeforeAssign": true }
+ ],
"prefer-rest-params": "error",
"prefer-spread": "error",
"prefer-template": "error",
- "quotes": ["error", "single", { "allowTemplateLiterals": true }],
+ "prettier/prettier": "error",
"radix": "error",
"react/jsx-boolean-value": ["error", "never"],
- "react/jsx-closing-bracket-location": "error",
- "react/jsx-curly-spacing": ["error", "never"],
- "react/jsx-equals-spacing": "error",
- "react/jsx-first-prop-new-line": ["error", "multiline"],
"react/jsx-key": "error",
"react/jsx-no-bind": "error",
"react/jsx-no-duplicate-props": "error",
"react/jsx-no-target-blank": "error",
"react/jsx-no-undef": "error",
- "react/jsx-tag-spacing": ["error", { "beforeSelfClosing": "always" }],
"react/jsx-uses-react": "error",
"react/jsx-uses-vars": "error",
"react/jsx-wrap-multilines": "error",
@@ -136,19 +134,12 @@
"react/react-in-jsx-scope": "error",
"react/self-closing-comp": "error",
"react/sort-prop-types": "error",
- "rest-spread-spacing": ["error", "never"],
- "semi": ["error", "never"],
- "space-before-blocks": "error",
- "space-before-function-paren": ["error", { "anonymous": "always", "named": "never" }],
- "space-in-parens": "error",
- "space-infix-ops": "error",
- "space-unary-ops": ["error", { "words": true, "nonwords": false }],
- "spaced-comment": ["error", "always", { "exceptions": ["-"]}],
- "template-curly-spacing": "error",
- "template-tag-spacing": ["error", "never"],
- "unicode-bom": ["error", "never"],
+ "spaced-comment": ["error", "always", { "exceptions": ["-"] }],
"use-isnan": "error",
- "valid-jsdoc": ["error", { "prefer": { "return": "returns" }, "requireReturn": false }],
+ "valid-jsdoc": [
+ "error",
+ { "prefer": { "return": "returns" }, "requireReturn": false }
+ ],
"valid-typeof": "error",
"yield-star-spacing": ["error", "after"],
"yoda": ["error", "never"]
diff --git a/.prettierignore b/.prettierignore
new file mode 100644
index 000000000..a790ef1b4
--- /dev/null
+++ b/.prettierignore
@@ -0,0 +1,5 @@
+examples/build.prod.js
+package.json
+packages/*/dist/
+packages/*/lib/
+tmp/
diff --git a/examples/check-lists/index.js b/examples/check-lists/index.js
index 348ad2dcc..a637caeec 100644
--- a/examples/check-lists/index.js
+++ b/examples/check-lists/index.js
@@ -1,4 +1,3 @@
-
import { Editor } from 'slate-react'
import { Value } from 'slate'
@@ -12,17 +11,16 @@ import initialValue from './value.json'
*/
class CheckListItem extends React.Component {
-
/**
* On change, set the new checked value on the block.
*
* @param {Event} event
*/
- onChange = (event) => {
+ onChange = event => {
const checked = event.target.checked
const { editor, node } = this.props
- editor.change(c => c.setNodeByKey(node.key, { data: { checked }}))
+ editor.change(c => c.setNodeByKey(node.key, { data: { checked } }))
}
/**
@@ -42,11 +40,7 @@ class CheckListItem extends React.Component {
{...attributes}
>
-
+
{children}
@@ -54,7 +48,6 @@ class CheckListItem extends React.Component {
)
}
-
}
/**
@@ -64,7 +57,6 @@ class CheckListItem extends React.Component {
*/
class CheckLists extends React.Component {
-
/**
* Deserialize the initial editor value.
*
@@ -72,7 +64,7 @@ class CheckLists extends React.Component {
*/
state = {
- value: Value.fromJSON(initialValue)
+ value: Value.fromJSON(initialValue),
}
/**
@@ -102,11 +94,8 @@ class CheckLists extends React.Component {
onKeyDown = (event, change) => {
const { value } = change
- if (
- event.key == 'Enter' &&
- value.startBlock.type == 'check-list-item'
- ) {
- change.splitBlock().setBlock({ data: { checked: false }})
+ if (event.key == 'Enter' && value.startBlock.type == 'check-list-item') {
+ change.splitBlock().setBlock({ data: { checked: false } })
return true
}
@@ -151,12 +140,12 @@ class CheckLists extends React.Component {
* @return {Element}
*/
- renderNode = (props) => {
+ renderNode = props => {
switch (props.node.type) {
- case 'check-list-item': return
))} diff --git a/packages/slate-html-serializer/benchmark/index.js b/packages/slate-html-serializer/benchmark/index.js index 103cf99e9..0023012c0 100644 --- a/packages/slate-html-serializer/benchmark/index.js +++ b/packages/slate-html-serializer/benchmark/index.js @@ -9,9 +9,11 @@ import { __clear } from '../../slate/lib/utils/memoize' */ const categoryDir = resolve(__dirname) -const categories = fs.readdirSync(categoryDir).filter(c => c[0] != '.' && c != 'index.js') +const categories = fs + .readdirSync(categoryDir) + .filter(c => c[0] != '.' && c != 'index.js') -categories.forEach((category) => { +categories.forEach(category => { suite(category, () => { set('iterations', 50) set('mintime', 1000) @@ -23,9 +25,12 @@ categories.forEach((category) => { } const benchmarkDir = resolve(categoryDir, category) - const benchmarks = fs.readdirSync(benchmarkDir).filter(b => b[0] != '.' && !!~b.indexOf('.js')).map(b => basename(b, extname(b))) + const benchmarks = fs + .readdirSync(benchmarkDir) + .filter(b => b[0] != '.' && !!~b.indexOf('.js')) + .map(b => basename(b, extname(b))) - benchmarks.forEach((benchmark) => { + benchmarks.forEach(benchmark => { const dir = resolve(benchmarkDir, benchmark) const module = require(dir) const fn = module.default diff --git a/packages/slate-html-serializer/src/index.js b/packages/slate-html-serializer/src/index.js index 86413a87d..0278350d2 100644 --- a/packages/slate-html-serializer/src/index.js +++ b/packages/slate-html-serializer/src/index.js @@ -1,4 +1,3 @@ - import React from 'react' import { renderToStaticMarkup } from 'react-dom/server' import typeOf from 'type-of' @@ -13,7 +12,7 @@ import { Record } from 'immutable' const String = new Record({ object: 'string', - text: '' + text: '', }) /** @@ -24,15 +23,16 @@ const String = new Record({ */ const TEXT_RULE = { - deserialize(el) { if (el.tagName && el.tagName.toLowerCase() === 'br') { return { object: 'text', - leaves: [{ - object: 'leaf', - text: '\n' - }] + leaves: [ + { + object: 'leaf', + text: '\n', + }, + ], } } @@ -41,26 +41,25 @@ const TEXT_RULE = { return { object: 'text', - leaves: [{ - object: 'leaf', - text: el.nodeValue - }] + leaves: [ + { + object: 'leaf', + text: el.nodeValue, + }, + ], } } }, serialize(obj, children) { if (obj.object === 'string') { - return children - .split('\n') - .reduce((array, text, i) => { - if (i != 0) array.push(- This is editable rich text, much better than a textarea! + This is editable rich text, much better than a + textarea!
-- one - +one
-- one - +one
diff --git a/packages/slate-plain-serializer/src/index.js b/packages/slate-plain-serializer/src/index.js index 4856d045a..2988d5a0b 100644 --- a/packages/slate-plain-serializer/src/index.js +++ b/packages/slate-plain-serializer/src/index.js @@ -1,4 +1,3 @@ - import { Block, Mark, Node, Value } from 'slate' import { Set } from 'immutable' @@ -14,11 +13,7 @@ import { Set } from 'immutable' */ function deserialize(string, options = {}) { - let { - defaultBlock = 'line', - defaultMarks = [], - toJSON = false, - } = options + let { defaultBlock = 'line', defaultMarks = [], toJSON = false } = options if (Set.isSet(defaultMarks)) { defaultMarks = defaultMarks.toArray() @@ -32,7 +27,7 @@ function deserialize(string, options = {}) { document: { object: 'document', data: {}, - nodes: string.split('\n').map((line) => { + nodes: string.split('\n').map(line => { return { ...defaultBlock, object: 'block', @@ -46,13 +41,13 @@ function deserialize(string, options = {}) { object: 'leaf', text: line, marks: defaultMarks, - } - ] - } - ] + }, + ], + }, + ], } }), - } + }, } const ret = toJSON ? json : Value.fromJSON(json) @@ -79,7 +74,7 @@ function serialize(value) { function serializeNode(node) { if ( - (node.object == 'document') || + node.object == 'document' || (node.object == 'block' && Block.isBlockList(node.nodes)) ) { return node.nodes.map(serializeNode).join('\n') @@ -96,5 +91,5 @@ function serializeNode(node) { export default { deserialize, - serialize + serialize, } diff --git a/packages/slate-plain-serializer/test/deserialize/line-multiple.js b/packages/slate-plain-serializer/test/deserialize/line-multiple.js index f3dcb1b50..9f20b8954 100644 --- a/packages/slate-plain-serializer/test/deserialize/line-multiple.js +++ b/packages/slate-plain-serializer/test/deserialize/line-multiple.js @@ -10,12 +10,8 @@ two export const output = (- This is editable rich text, much better than a textarea! + This is editable rich text, much better than a + textarea!
-- one - -- two - +one +two
- - four - +four
-- one - -- two - +one +two
-- three - -- four - +three +four
-- one - -- two - +one +two -- three - -- four - +three +four
-diff --git a/packages/slate-plain-serializer/test/serialize/block-nested-with-inlines.js b/packages/slate-plain-serializer/test/serialize/block-nested-with-inlines.js index 48a8c85d0..490b8f1c1 100644 --- a/packages/slate-plain-serializer/test/serialize/block-nested-with-inlines.js +++ b/packages/slate-plain-serializer/test/serialize/block-nested-with-inlines.js @@ -7,14 +7,10 @@ export const input = (- one - +one - - two - +two
- - one - + one - - two - + two
diff --git a/packages/slate-react/src/components/content.js b/packages/slate-react/src/components/content.js index ebdb8e460..72024ed6d 100644 --- a/packages/slate-react/src/components/content.js +++ b/packages/slate-react/src/components/content.js @@ -1,4 +1,3 @@ - import Debug from 'debug' import React from 'react' import Types from 'prop-types' @@ -15,7 +14,7 @@ import { IS_FIREFOX, IS_IOS, IS_ANDROID, - SUPPORTED_EVENTS + SUPPORTED_EVENTS, } from '../constants/environment' /** @@ -33,7 +32,6 @@ const debug = Debug('slate:content') */ class Content extends React.Component { - /** * Property types. * @@ -77,8 +75,8 @@ class Content extends React.Component { this.tmp.key = 0 this.tmp.isUpdatingSelection = false - EVENT_HANDLERS.forEach((handler) => { - this[handler] = (event) => { + EVENT_HANDLERS.forEach(handler => { + this[handler] = event => { this.onEvent(handler, event) } }) @@ -96,7 +94,10 @@ class Content extends React.Component { const { editor } = this.props const window = getWindow(this.element) - window.document.addEventListener('selectionchange', this.onNativeSelectionChange) + window.document.addEventListener( + 'selectionchange', + this.onNativeSelectionChange + ) // COMPAT: Restrict scope of `beforeinput` to mobile. if ((IS_IOS || IS_ANDROID) && SUPPORTED_EVENTS.beforeinput) { @@ -118,7 +119,10 @@ class Content extends React.Component { const window = getWindow(this.element) if (window) { - window.document.removeEventListener('selectionchange', this.onNativeSelectionChange) + window.document.removeEventListener( + 'selectionchange', + this.onNativeSelectionChange + ) } // COMPAT: Restrict scope of `beforeinput` to mobile. @@ -169,16 +173,14 @@ class Content extends React.Component { const range = findDOMRange(selection, window) if (!range) { - logger.error('Unable to find a native DOM range from the current selection.', { selection }) + logger.error( + 'Unable to find a native DOM range from the current selection.', + { selection } + ) return } - const { - startContainer, - startOffset, - endContainer, - endOffset, - } = range + const { startContainer, startOffset, endContainer, endOffset } = range // If the new range matches the current selection, there is nothing to fix. // COMPAT: The native `Range` object always has it's "start" first and "end" @@ -186,18 +188,14 @@ class Content extends React.Component { // to check both orientations here. (2017/10/31) if (current) { if ( - ( - startContainer == current.startContainer && + (startContainer == current.startContainer && startOffset == current.startOffset && endContainer == current.endContainer && - endOffset == current.endOffset - ) || - ( - startContainer == current.endContainer && + endOffset == current.endOffset) || + (startContainer == current.endContainer && startOffset == current.endOffset && endContainer == current.startContainer && - endOffset == current.startOffset - ) + endOffset == current.startOffset) ) { return } @@ -251,7 +249,7 @@ class Content extends React.Component { * @param {Element} element */ - ref = (element) => { + ref = element => { this.element = element } @@ -264,13 +262,13 @@ class Content extends React.Component { * @return {Boolean} */ - isInEditor = (target) => { + isInEditor = target => { const { element } = this // COMPAT: Text nodes don't have `isContentEditable` property. So, when // `target` is a text node use its parent node for check. const el = target.nodeType === 3 ? target.parentNode : target return ( - (el.isContentEditable) && + el.isContentEditable && (el === element || el.closest('[data-slate-editor]') === element) ) } @@ -295,11 +293,7 @@ class Content extends React.Component { // programmatically while updating selection. if ( this.tmp.isUpdatingSelection && - ( - handler == 'onSelect' || - handler == 'onBlur' || - handler == 'onFocus' - ) + (handler == 'onSelect' || handler == 'onBlur' || handler == 'onFocus') ) { return } @@ -368,11 +362,11 @@ class Content extends React.Component { * @param {InputEvent} event */ - onNativeBeforeInput = (event) => { + onNativeBeforeInput = event => { if (this.props.readOnly) return if (!this.isInEditor(event.target)) return - const [ targetRange ] = event.getTargetRanges() + const [targetRange] = event.getTargetRanges() if (!targetRange) return const { editor } = this.props @@ -391,7 +385,7 @@ class Content extends React.Component { event.preventDefault() const range = findRange(targetRange, editor.value) - editor.change((change) => { + editor.change(change => { if (change.value.isInVoid) { change.collapseToStartOfNextText() } else { @@ -407,9 +401,10 @@ class Content extends React.Component { // `dataTransfer` should have the text for the `insertReplacementText` // input type, but Safari uses `insertText` for spell check replacements // and sets `data` to `null`. - const text = event.data == null - ? event.dataTransfer.getData('text/plain') - : event.data + const text = + event.data == null + ? event.dataTransfer.getData('text/plain') + : event.data if (text == null) return @@ -419,7 +414,7 @@ class Content extends React.Component { const { selection } = value const range = findRange(targetRange, value) - editor.change((change) => { + editor.change(change => { change.insertTextAtRange(range, text, selection.marks) // If the text was successfully inserted, and the selection had marks @@ -443,7 +438,7 @@ class Content extends React.Component { * @param {Event} event */ - onNativeSelectionChange = throttle((event) => { + onNativeSelectionChange = throttle(event => { if (this.props.readOnly) return const window = getWindow(event.target) @@ -526,7 +521,7 @@ class Content extends React.Component { autoCorrect={props.autoCorrect ? 'on' : 'off'} spellCheck={spellCheck} style={style} - role={readOnly ? null : (role || 'textbox')} + role={readOnly ? null : role || 'textbox'} tabIndex={tabIndex} // COMPAT: The Grammarly Chrome extension works by changing the DOM out // from under `contenteditable` elements, which leads to weird behaviors @@ -567,14 +562,13 @@ class Content extends React.Component { /> ) } - } /** * Mix in handler prop types. */ -EVENT_HANDLERS.forEach((handler) => { +EVENT_HANDLERS.forEach(handler => { Content.propTypes[handler] = Types.func.isRequired }) diff --git a/packages/slate-react/src/components/editor.js b/packages/slate-react/src/components/editor.js index e656eec23..b6c52ec61 100644 --- a/packages/slate-react/src/components/editor.js +++ b/packages/slate-react/src/components/editor.js @@ -1,4 +1,3 @@ - import Debug from 'debug' import Portal from 'react-portal' import React from 'react' @@ -28,7 +27,6 @@ const debug = Debug('slate:editor') */ class Editor extends React.Component { - /** * Property types. * @@ -95,7 +93,7 @@ class Editor extends React.Component { this.state.value = change.value // Create a bound event handler for each event. - EVENT_HANDLERS.forEach((handler) => { + EVENT_HANDLERS.forEach(handler => { this[handler] = (...args) => { this.onEvent(handler, ...args) } @@ -109,7 +107,7 @@ class Editor extends React.Component { * @param {Object} props */ - componentWillReceiveProps = (props) => { + componentWillReceiveProps = props => { let { schema, stack } = this // Increment the updates counter as a baseline. @@ -117,7 +115,10 @@ class Editor extends React.Component { // If the plugins or the schema have changed, we need to re-resolve the // plugins, since it will result in a new stack and new validations. - if (props.plugins != this.props.plugins || props.schema != this.props.schema) { + if ( + props.plugins != this.props.plugins || + props.schema != this.props.schema + ) { const plugins = this.resolvePlugins(props.plugins, props.schema) stack = Stack.create({ plugins }) schema = Schema.create({ plugins }) @@ -129,7 +130,9 @@ class Editor extends React.Component { // If we've resolved a few times already, and it's exactly in line with // the updates, then warn the user that they may be doing something wrong. if (this.tmp.resolves > 5 && this.tmp.resolves == this.tmp.updates) { - logger.warn('A Slate- This is editable rich text, much better than a textarea! + This is editable rich text, much better than a + textarea!
- word
-
-
- word
-
-
- word
-
+ word
+ word
+ word
- word
-
+ word
-- مرحبا بالعالم - -- שלום עולם - +مرحبا بالعالم +שלום עולם
diff --git a/packages/slate/benchmark/changes/delete-forward.js b/packages/slate/benchmark/changes/delete-forward.js index 64a39a45b..a5fe3e995 100644 --- a/packages/slate/benchmark/changes/delete-forward.js +++ b/packages/slate/benchmark/changes/delete-forward.js @@ -3,7 +3,7 @@ import h from '../../test/helpers/h' -export default function (change) { +export default function(change) { change.deleteForward() } @@ -19,7 +19,8 @@ export const input = ( - This is editable rich text, much better than a textarea! + This is editable rich text, much better than a + textarea! {i == 0 ? : ''} diff --git a/packages/slate/benchmark/changes/insert-text-by-key-multiple.js b/packages/slate/benchmark/changes/insert-text-by-key-multiple.js index 5a6dd563e..76ce1da63 100644 --- a/packages/slate/benchmark/changes/insert-text-by-key-multiple.js +++ b/packages/slate/benchmark/changes/insert-text-by-key-multiple.js @@ -4,7 +4,7 @@ import h from '../../test/helpers/h' import { __clear } from '../../lib/utils/memoize' -export default function ({ change, keys }) { +export default function({ change, keys }) { for (const key of keys) { change.insertTextByKey(key, 0, 'a') } @@ -12,7 +12,10 @@ export default function ({ change, keys }) { export function before(value) { const change = value.change() - const keys = value.document.getTexts().toArray().map(t => t.key) + const keys = value.document + .getTexts() + .toArray() + .map(t => t.key) __clear() return { change, keys } } @@ -24,7 +27,8 @@ export const input = ( - This is editable rich text, much better than a textarea! + This is editable rich text, much better than a + textarea! {i == 0 ? : ''} diff --git a/packages/slate/benchmark/changes/insert-text-by-key.js b/packages/slate/benchmark/changes/insert-text-by-key.js index 906f7da14..5ddb79af6 100644 --- a/packages/slate/benchmark/changes/insert-text-by-key.js +++ b/packages/slate/benchmark/changes/insert-text-by-key.js @@ -4,7 +4,7 @@ import h from '../../test/helpers/h' import { __clear } from '../../lib/utils/memoize' -export default function ({ change, text }) { +export default function({ change, text }) { change.insertTextByKey(text.key, 0, 'a') } @@ -22,7 +22,8 @@ export const input = ( - This is editable rich text, much better than a textarea! + This is editable rich text, much better than a + textarea! {i == 0 ? : ''} diff --git a/packages/slate/benchmark/changes/insert-text.js b/packages/slate/benchmark/changes/insert-text.js index 62bc8f1ff..66e3ea0f8 100644 --- a/packages/slate/benchmark/changes/insert-text.js +++ b/packages/slate/benchmark/changes/insert-text.js @@ -3,7 +3,7 @@ import h from '../../test/helpers/h' -export default function (change) { +export default function(change) { change.insertText('a') } @@ -19,7 +19,8 @@ export const input = ( - This is editable rich text, much better than a textarea! + This is editable rich text, much better than a + textarea! {i == 0 ? : ''} diff --git a/packages/slate/benchmark/changes/normalize.js b/packages/slate/benchmark/changes/normalize.js index a2841b556..2497fee16 100644 --- a/packages/slate/benchmark/changes/normalize.js +++ b/packages/slate/benchmark/changes/normalize.js @@ -3,7 +3,7 @@ import h from '../../test/helpers/h' -export default function (change) { +export default function(change) { change.normalize() } @@ -18,7 +18,8 @@ export const input = ( - This is editable rich text, much better than a textarea! + This is editable rich text, much better than a + textarea! {i == 0 ? : ''} diff --git a/packages/slate/benchmark/changes/split-block.js b/packages/slate/benchmark/changes/split-block.js index bc9701d97..060568690 100644 --- a/packages/slate/benchmark/changes/split-block.js +++ b/packages/slate/benchmark/changes/split-block.js @@ -3,7 +3,7 @@ import h from '../../test/helpers/h' -export default function (change) { +export default function(change) { change.splitBlock() } @@ -19,7 +19,8 @@ export const input = ( - This is editable rich text, much better than a textarea! + This is editable rich text, much better than a + textarea! {i == 0 ? : ''} diff --git a/packages/slate/benchmark/index.js b/packages/slate/benchmark/index.js index 3b6eb11e5..ceafa34d6 100644 --- a/packages/slate/benchmark/index.js +++ b/packages/slate/benchmark/index.js @@ -9,9 +9,11 @@ import { __clear } from '../lib/utils/memoize' */ const categoryDir = resolve(__dirname) -const categories = fs.readdirSync(categoryDir).filter(c => c[0] != '.' && c != 'index.js') +const categories = fs + .readdirSync(categoryDir) + .filter(c => c[0] != '.' && c != 'index.js') -categories.forEach((category) => { +categories.forEach(category => { suite(category, () => { set('iterations', 100) set('mintime', 1000) @@ -23,9 +25,12 @@ categories.forEach((category) => { } const benchmarkDir = resolve(categoryDir, category) - const benchmarks = fs.readdirSync(benchmarkDir).filter(b => b[0] != '.' && !!~b.indexOf('.js')).map(b => basename(b, extname(b))) + const benchmarks = fs + .readdirSync(benchmarkDir) + .filter(b => b[0] != '.' && !!~b.indexOf('.js')) + .map(b => basename(b, extname(b))) - benchmarks.forEach((benchmark) => { + benchmarks.forEach(benchmark => { const dir = resolve(benchmarkDir, benchmark) const module = require(dir) const fn = module.default diff --git a/packages/slate/benchmark/models/from-json.js b/packages/slate/benchmark/models/from-json.js index 6b4ca1abc..661773253 100644 --- a/packages/slate/benchmark/models/from-json.js +++ b/packages/slate/benchmark/models/from-json.js @@ -2,7 +2,7 @@ import { Value } from '../..' -export default function (json) { +export default function(json) { Value.fromJSON(json) } @@ -35,12 +35,12 @@ export const input = { }, { text: ' better than a textarea!', - } - ] - } - ] - } - ] - })) - } + }, + ], + }, + ], + }, + ], + })), + }, } diff --git a/packages/slate/benchmark/models/get-blocks-at-range.js b/packages/slate/benchmark/models/get-blocks-at-range.js index 60522007b..d07561873 100644 --- a/packages/slate/benchmark/models/get-blocks-at-range.js +++ b/packages/slate/benchmark/models/get-blocks-at-range.js @@ -3,15 +3,12 @@ import h from '../../test/helpers/h' -export default function (value) { +export default function(value) { value.document.getBlocksAtRange(value.selection) } export function before(value) { - return value - .change() - .selectAll() - .value + return value.change().selectAll().value } export const input = ( @@ -21,7 +18,8 @@ export const input = ( - This is editable rich text, much better than a textarea! + This is editable rich text, much better than a + textarea! {i == 0 ? : ''} diff --git a/packages/slate/benchmark/models/get-blocks.js b/packages/slate/benchmark/models/get-blocks.js index d0f00e696..dfe4ddfe1 100644 --- a/packages/slate/benchmark/models/get-blocks.js +++ b/packages/slate/benchmark/models/get-blocks.js @@ -3,7 +3,7 @@ import h from '../../test/helpers/h' -export default function (value) { +export default function(value) { value.document.getBlocks() } @@ -14,7 +14,8 @@ export const input = (- This is editable rich text, much better than a textarea! + This is editable rich text, much better than a + textarea! diff --git a/packages/slate/benchmark/models/get-characters-at-range.js b/packages/slate/benchmark/models/get-characters-at-range.js index b88eefdaa..4c34adae7 100644 --- a/packages/slate/benchmark/models/get-characters-at-range.js +++ b/packages/slate/benchmark/models/get-characters-at-range.js @@ -3,15 +3,12 @@ import h from '../../test/helpers/h' -export default function (value) { +export default function(value) { value.document.getCharactersAtRange(value.selection) } export function before(value) { - return value - .change() - .selectAll() - .value + return value.change().selectAll().value } export const input = ( @@ -21,7 +18,8 @@ export const input = (- This is editable rich text, much better than a textarea! + This is editable rich text, much better than a + textarea! diff --git a/packages/slate/benchmark/models/get-characters.js b/packages/slate/benchmark/models/get-characters.js index a11ec727d..6e194313a 100644 --- a/packages/slate/benchmark/models/get-characters.js +++ b/packages/slate/benchmark/models/get-characters.js @@ -3,7 +3,7 @@ import h from '../../test/helpers/h' -export default function (value) { +export default function(value) { value.document.getCharacters() } @@ -14,7 +14,8 @@ export const input = (- This is editable rich text, much better than a textarea! + This is editable rich text, much better than a + textarea! diff --git a/packages/slate/benchmark/models/get-inlines-at-range.js b/packages/slate/benchmark/models/get-inlines-at-range.js index 82e7b1eb6..b31dfe4a8 100644 --- a/packages/slate/benchmark/models/get-inlines-at-range.js +++ b/packages/slate/benchmark/models/get-inlines-at-range.js @@ -3,15 +3,12 @@ import h from '../../test/helpers/h' -export default function (value) { +export default function(value) { value.document.getInlinesAtRange(value.selection) } export function before(value) { - return value - .change() - .selectAll() - .value + return value.change().selectAll().value } export const input = ( @@ -21,7 +18,8 @@ export const input = (- This is editable rich text, much better than a textarea! + This is editable rich text, much better than a + textarea! diff --git a/packages/slate/benchmark/models/get-inlines.js b/packages/slate/benchmark/models/get-inlines.js index e57be4961..cef280292 100644 --- a/packages/slate/benchmark/models/get-inlines.js +++ b/packages/slate/benchmark/models/get-inlines.js @@ -3,7 +3,7 @@ import h from '../../test/helpers/h' -export default function (value) { +export default function(value) { value.document.getInlines() } @@ -14,7 +14,8 @@ export const input = (- This is editable rich text, much better than a textarea! + This is editable rich text, much better than a + textarea! diff --git a/packages/slate/benchmark/models/get-leaves.js b/packages/slate/benchmark/models/get-leaves.js index 42340e408..cb1db3787 100644 --- a/packages/slate/benchmark/models/get-leaves.js +++ b/packages/slate/benchmark/models/get-leaves.js @@ -4,7 +4,7 @@ import h from '../../test/helpers/h' import { __clear } from '../../lib/utils/memoize' -export default function (text) { +export default function(text) { text.getLeaves() } @@ -21,7 +21,8 @@ export const input = (- This is editable rich text, much better than a textarea! + This is editable rich text, much better than a + textarea! diff --git a/packages/slate/benchmark/models/get-marks-at-range.js b/packages/slate/benchmark/models/get-marks-at-range.js index af89a824b..701d58d84 100644 --- a/packages/slate/benchmark/models/get-marks-at-range.js +++ b/packages/slate/benchmark/models/get-marks-at-range.js @@ -3,15 +3,12 @@ import h from '../../test/helpers/h' -export default function (value) { +export default function(value) { value.document.getMarksAtRange(value.selection) } export function before(value) { - return value - .change() - .selectAll() - .value + return value.change().selectAll().value } export const input = ( @@ -21,7 +18,8 @@ export const input = (- This is editable rich text, much better than a textarea! + This is editable rich text, much better than a + textarea! diff --git a/packages/slate/benchmark/models/get-marks.js b/packages/slate/benchmark/models/get-marks.js index c18bcfa71..99fa6e0d8 100644 --- a/packages/slate/benchmark/models/get-marks.js +++ b/packages/slate/benchmark/models/get-marks.js @@ -3,7 +3,7 @@ import h from '../../test/helpers/h' -export default function (value) { +export default function(value) { value.document.getMarks() } @@ -14,7 +14,8 @@ export const input = (- This is editable rich text, much better than a textarea! + This is editable rich text, much better than a + textarea! diff --git a/packages/slate/benchmark/models/get-path.js b/packages/slate/benchmark/models/get-path.js index 8328c0f06..fa260a20f 100644 --- a/packages/slate/benchmark/models/get-path.js +++ b/packages/slate/benchmark/models/get-path.js @@ -4,7 +4,7 @@ import h from '../../test/helpers/h' import { __clear } from '../../lib/utils/memoize' -export default function ({ value, text }) { +export default function({ value, text }) { value.document.getPath(text.key) } @@ -21,7 +21,8 @@ export const input = (- This is editable rich text, much better than a textarea! + This is editable rich text, much better than a + textarea! diff --git a/packages/slate/benchmark/models/get-texts-at-range.js b/packages/slate/benchmark/models/get-texts-at-range.js index 2244c37a6..250c600f1 100644 --- a/packages/slate/benchmark/models/get-texts-at-range.js +++ b/packages/slate/benchmark/models/get-texts-at-range.js @@ -3,15 +3,12 @@ import h from '../../test/helpers/h' -export default function (value) { +export default function(value) { value.document.getTextsAtRange(value.selection) } export function before(value) { - return value - .change() - .selectAll() - .value + return value.change().selectAll().value } export const input = ( @@ -21,7 +18,8 @@ export const input = (- This is editable rich text, much better than a textarea! + This is editable rich text, much better than a + textarea! diff --git a/packages/slate/benchmark/models/get-texts.js b/packages/slate/benchmark/models/get-texts.js index 4b8a748c1..ead94832e 100644 --- a/packages/slate/benchmark/models/get-texts.js +++ b/packages/slate/benchmark/models/get-texts.js @@ -3,7 +3,7 @@ import h from '../../test/helpers/h' -export default function (value) { +export default function(value) { value.document.getTexts() } @@ -14,7 +14,8 @@ export const input = (- This is editable rich text, much better than a textarea! + This is editable rich text, much better than a + textarea! diff --git a/packages/slate/benchmark/models/has-node-multiple.js b/packages/slate/benchmark/models/has-node-multiple.js index bae49bc48..56f2432db 100644 --- a/packages/slate/benchmark/models/has-node-multiple.js +++ b/packages/slate/benchmark/models/has-node-multiple.js @@ -4,14 +4,17 @@ import h from '../../test/helpers/h' import { __clear } from '../../lib/utils/memoize' -export default function ({ value, keys }) { - keys.forEach((key) => { +export default function({ value, keys }) { + keys.forEach(key => { value.document.hasNode(key) }) } export function before(value) { - const keys = value.document.getTexts().toArray().map(t => t.key) + const keys = value.document + .getTexts() + .toArray() + .map(t => t.key) __clear() return { value, keys } } @@ -23,7 +26,8 @@ export const input = (- This is editable rich text, much better than a textarea! + This is editable rich text, much better than a + textarea! diff --git a/packages/slate/benchmark/models/has-node.js b/packages/slate/benchmark/models/has-node.js index 79e48b9f3..bb616d4d5 100644 --- a/packages/slate/benchmark/models/has-node.js +++ b/packages/slate/benchmark/models/has-node.js @@ -4,7 +4,7 @@ import h from '../../test/helpers/h' import { __clear } from '../../lib/utils/memoize' -export default function ({ value, text }) { +export default function({ value, text }) { value.document.hasNode(text.key) } @@ -21,7 +21,8 @@ export const input = (- This is editable rich text, much better than a textarea! + This is editable rich text, much better than a + textarea! diff --git a/packages/slate/benchmark/models/to-json.js b/packages/slate/benchmark/models/to-json.js index 74347f1bc..9a3b05e70 100644 --- a/packages/slate/benchmark/models/to-json.js +++ b/packages/slate/benchmark/models/to-json.js @@ -3,7 +3,7 @@ import h from '../../test/helpers/h' -export default function (value) { +export default function(value) { value.toJSON() } @@ -14,7 +14,8 @@ export const input = (- This is editable rich text, much better than a textarea! + This is editable rich text, much better than a + textarea! diff --git a/packages/slate/benchmark/models/update-node.js b/packages/slate/benchmark/models/update-node.js index 6861f4944..a4022ebf6 100644 --- a/packages/slate/benchmark/models/update-node.js +++ b/packages/slate/benchmark/models/update-node.js @@ -4,7 +4,7 @@ import h from '../../test/helpers/h' import { __clear } from '../../lib/utils/memoize' -export default function ({ value, next }) { +export default function({ value, next }) { value.document.updateNode(next) } @@ -24,7 +24,8 @@ export const input = (- This is editable rich text, much better than a textarea! + This is editable rich text, much better than a + textarea! diff --git a/packages/slate/src/changes/at-current-range.js b/packages/slate/src/changes/at-current-range.js index 5776ff520..e3c0dafcf 100644 --- a/packages/slate/src/changes/at-current-range.js +++ b/packages/slate/src/changes/at-current-range.js @@ -1,4 +1,3 @@ - import Block from '../models/block' import Inline from '../models/inline' import Mark from '../models/mark' @@ -34,7 +33,7 @@ const PROXY_TRANSFORMS = [ 'wrapInline', ] -PROXY_TRANSFORMS.forEach((method) => { +PROXY_TRANSFORMS.forEach(method => { Changes[method] = (change, ...args) => { const { value } = change const { selection } = value @@ -57,15 +56,11 @@ Changes.addMark = (change, mark) => { if (selection.isExpanded) { change.addMarkAtRange(selection, mark) - } - - else if (selection.marks) { + } else if (selection.marks) { const marks = selection.marks.add(mark) const sel = selection.set('marks', marks) change.select(sel) - } - - else { + } else { const marks = document.getActiveMarksAtRange(selection).add(mark) const sel = selection.set('marks', marks) change.select(sel) @@ -89,7 +84,7 @@ Changes.addMarks = (change, marks) => { * @param {Change} change */ -Changes.delete = (change) => { +Changes.delete = change => { const { value } = change const { selection } = value change.deleteAtRange(selection) @@ -134,11 +129,10 @@ Changes.insertFragment = (change, fragment) => { const lastText = fragment.getLastText() const lastInline = fragment.getClosestInline(lastText.key) const keys = document.getTexts().map(text => text.key) - const isAppending = ( + const isAppending = !startInline || selection.hasEdgeAtStartOf(startText) || selection.hasEdgeAtEndOf(endText) - ) change.insertFragmentAtRange(selection, fragment) value = change.value @@ -149,13 +143,11 @@ Changes.insertFragment = (change, fragment) => { if (newText && lastInline) { change.select(selection.collapseToEndOf(newText)) - } - - else if (newText) { - change.select(selection.collapseToStartOf(newText).move(lastText.text.length)) - } - - else { + } else if (newText) { + change.select( + selection.collapseToStartOf(newText).move(lastText.text.length) + ) + } else { change.select(selection.collapseToStart().move(lastText.text.length)) } } @@ -209,9 +201,7 @@ Changes.insertText = (change, text, marks) => { Changes.splitBlock = (change, depth = 1) => { const { value } = change const { selection } = value - change - .splitBlockAtRange(selection, depth) - .collapseToEnd() + change.splitBlockAtRange(selection, depth).collapseToEnd() } /** @@ -228,15 +218,11 @@ Changes.removeMark = (change, mark) => { if (selection.isExpanded) { change.removeMarkAtRange(selection, mark) - } - - else if (selection.marks) { + } else if (selection.marks) { const marks = selection.marks.remove(mark) const sel = selection.set('marks', marks) change.select(sel) - } - - else { + } else { const marks = document.getActiveMarksAtRange(selection).remove(mark) const sel = selection.set('marks', marks) change.select(sel) diff --git a/packages/slate/src/changes/at-range.js b/packages/slate/src/changes/at-range.js index 3f6e18105..c40161a43 100644 --- a/packages/slate/src/changes/at-range.js +++ b/packages/slate/src/changes/at-range.js @@ -1,4 +1,3 @@ - import { List } from 'immutable' import Block from '../models/block' @@ -34,7 +33,7 @@ Changes.addMarkAtRange = (change, range, mark, options = {}) => { const { startKey, startOffset, endKey, endOffset } = range const texts = document.getTextsAtRange(range) - texts.forEach((node) => { + texts.forEach(node => { const { key } = node let index = 0 let length = node.text.length @@ -89,13 +88,12 @@ Changes.deleteAtRange = (change, range, options = {}) => { // Check if we have a "hanging" selection case where the even though the // selection extends into the start of the end node, we actually want to // ignore that for UX reasons. - const isHanging = ( + const isHanging = startOffset == 0 && endOffset == 0 && isStartVoid == false && startKey == startBlock.getFirstText().key && endKey == endBlock.getFirstText().key - ) // If it's a hanging selection, nudge it back to end in the previous text. if (isHanging && isEndVoid) { @@ -146,22 +144,18 @@ Changes.deleteAtRange = (change, range, options = {}) => { if (startKey == endKey && isHanging) { change.removeNodeByKey(startBlock.key, { normalize }) return - } - - // Otherwise, if it wasn't hanging, we're inside a single text node, so we can - // simply remove the text in the range. - else if (startKey == endKey) { + } else if (startKey == endKey) { + // Otherwise, if it wasn't hanging, we're inside a single text node, so we can + // simply remove the text in the range. const index = startOffset const length = endOffset - startOffset change.removeTextByKey(startKey, index, length, { normalize }) return - } - - // Otherwise, we need to recursively remove text and nodes inside the start - // block after the start offset and inside the end block before the end - // offset. Then remove any blocks that are in between the start and end - // blocks. Then finally merge the start and end nodes. - else { + } else { + // Otherwise, we need to recursively remove text and nodes inside the start + // block after the start offset and inside the end block before the end + // offset. Then remove any blocks that are in between the start and end + // blocks. Then finally merge the start and end nodes. startBlock = document.getClosestBlock(startKey) endBlock = document.getClosestBlock(endKey) const startText = document.getNode(startKey) @@ -188,7 +182,7 @@ Changes.deleteAtRange = (change, range, options = {}) => { const index = parent.nodes.indexOf(child) const afters = parent.nodes.slice(index + 1) - afters.reverse().forEach((node) => { + afters.reverse().forEach(node => { change.removeNodeByKey(node.key, { normalize: false }) }) @@ -200,7 +194,7 @@ Changes.deleteAtRange = (change, range, options = {}) => { const endChildIndex = ancestor.nodes.indexOf(endChild) const middles = ancestor.nodes.slice(startChildIndex + 1, endChildIndex) - middles.reverse().forEach((node) => { + middles.reverse().forEach(node => { change.removeNodeByKey(node.key, { normalize: false }) }) @@ -212,7 +206,7 @@ Changes.deleteAtRange = (change, range, options = {}) => { const index = parent.nodes.indexOf(child) const befores = parent.nodes.slice(0, index) - befores.reverse().forEach((node) => { + befores.reverse().forEach(node => { change.removeNodeByKey(node.key, { normalize: false }) }) @@ -221,7 +215,9 @@ Changes.deleteAtRange = (change, range, options = {}) => { // Remove any overlapping text content from the leaf text nodes. if (startLength != 0) { - change.removeTextByKey(startKey, startOffset, startLength, { normalize: false }) + change.removeTextByKey(startKey, startOffset, startLength, { + normalize: false, + }) } if (endLength != 0) { @@ -236,7 +232,12 @@ Changes.deleteAtRange = (change, range, options = {}) => { // Move the end block to be right after the start block. if (endParentIndex != startParentIndex + 1) { - change.moveNodeByKey(endBlock.key, startParent.key, startParentIndex + 1, { normalize: false }) + change.moveNodeByKey( + endBlock.key, + startParent.key, + startParentIndex + 1, + { normalize: false } + ) } // If the selection is hanging, just remove the start block, otherwise @@ -296,11 +297,10 @@ Changes.deleteLineBackwardAtRange = (change, range, options) => { const { startKey, startOffset } = range const startBlock = document.getClosestBlock(startKey) const offset = startBlock.getOffset(startKey) - const startWithVoidInline = ( + const startWithVoidInline = startBlock.nodes.size > 1 && startBlock.nodes.get(0).text == '' && startBlock.nodes.get(1).object == 'inline' - ) let o = offset + startOffset @@ -458,7 +458,7 @@ Changes.deleteBackwardAtRange = (change, range, n = 1, options = {}) => { range = range.merge({ focusKey: node.key, focusOffset: offset, - isBackward: true + isBackward: true, }) change.deleteAtRange(range, { normalize }) @@ -602,7 +602,7 @@ Changes.deleteForwardAtRange = (change, range, n = 1, options = {}) => { if (n == 1 && nextBlock != block) { range = range.merge({ focusKey: next.key, - focusOffset: 0 + focusOffset: 0, }) change.deleteAtRange(range, { normalize }) @@ -613,9 +613,9 @@ Changes.deleteForwardAtRange = (change, range, n = 1, options = {}) => { // If the remaining characters to the end of the node is greater than or equal // to the number of characters to delete, just remove the characters forwards // inside the current node. - if (n <= (text.text.length - focusOffset)) { + if (n <= text.text.length - focusOffset) { range = range.merge({ - focusOffset: focusOffset + n + focusOffset: focusOffset + n, }) change.deleteAtRange(range, { normalize }) @@ -682,22 +682,16 @@ Changes.insertBlockAtRange = (change, range, block, options = {}) => { if (startBlock.isVoid) { const extra = range.isAtEndOf(startBlock) ? 1 : 0 change.insertNodeByKey(parent.key, index + extra, block, { normalize }) - } - - else if (startBlock.isEmpty) { + } else if (startBlock.isEmpty) { change.insertNodeByKey(parent.key, index + 1, block, { normalize }) - } - - else if (range.isAtStartOf(startBlock)) { + } else if (range.isAtStartOf(startBlock)) { change.insertNodeByKey(parent.key, index, block, { normalize }) - } - - else if (range.isAtEndOf(startBlock)) { + } else if (range.isAtEndOf(startBlock)) { change.insertNodeByKey(parent.key, index + 1, block, { normalize }) - } - - else { - change.splitDescendantsByKey(startBlock.key, startKey, startOffset, { normalize: false }) + } else { + change.splitDescendantsByKey(startBlock.key, startKey, startOffset, { + normalize: false, + }) change.insertNodeByKey(parent.key, index + 1, block, { normalize }) } @@ -757,7 +751,10 @@ Changes.insertFragmentAtRange = (change, range, fragment, options = {}) => { // If the first and last block aren't the same, we need to insert all of the // nodes after the fragment's first block at the index. if (firstBlock != lastBlock) { - const lonelyParent = fragment.getFurthest(firstBlock.key, p => p.nodes.size == 1) + const lonelyParent = fragment.getFurthest( + firstBlock.key, + p => p.nodes.size == 1 + ) const lonelyChild = lonelyParent || firstBlock const startIndex = parent.nodes.indexOf(startBlock) fragment = fragment.removeDescendant(lonelyChild.key) @@ -770,7 +767,9 @@ Changes.insertFragmentAtRange = (change, range, fragment, options = {}) => { // Check if we need to split the node. if (startOffset != 0) { - change.splitDescendantsByKey(startChild.key, startKey, startOffset, { normalize: false }) + change.splitDescendantsByKey(startChild.key, startKey, startOffset, { + normalize: false, + }) } // Update our variables with the new value. @@ -783,13 +782,19 @@ Changes.insertFragmentAtRange = (change, range, fragment, options = {}) => { // starting block's children after the split into the last block of the // fragment, which has already been inserted. if (firstBlock != lastBlock) { - const nextChild = isAtStart ? startChild : startBlock.getNextSibling(startChild.key) - const nextNodes = nextChild ? startBlock.nodes.skipUntil(n => n.key == nextChild.key) : List() + const nextChild = isAtStart + ? startChild + : startBlock.getNextSibling(startChild.key) + const nextNodes = nextChild + ? startBlock.nodes.skipUntil(n => n.key == nextChild.key) + : List() const lastIndex = lastBlock.nodes.size nextNodes.forEach((node, i) => { const newIndex = lastIndex + i - change.moveNodeByKey(node.key, lastBlock.key, newIndex, { normalize: false }) + change.moveNodeByKey(node.key, lastBlock.key, newIndex, { + normalize: false, + }) }) } @@ -798,18 +803,18 @@ Changes.insertFragmentAtRange = (change, range, fragment, options = {}) => { if (startBlock.isEmpty) { change.removeNodeByKey(startBlock.key, { normalize: false }) change.insertNodeByKey(parent.key, index, firstBlock, { normalize: false }) - } - - // Otherwise, we maintain the starting block, and insert all of the first - // block's inline nodes into it at the split point. - else { + } else { + // Otherwise, we maintain the starting block, and insert all of the first + // block's inline nodes into it at the split point. const inlineChild = startBlock.getFurthestAncestor(startText.key) const inlineIndex = startBlock.nodes.indexOf(inlineChild) firstBlock.nodes.forEach((inline, i) => { const o = startOffset == 0 ? 0 : 1 const newIndex = inlineIndex + i + o - change.insertNodeByKey(startBlock.key, newIndex, inline, { normalize: false }) + change.insertNodeByKey(startBlock.key, newIndex, inline, { + normalize: false, + }) }) } @@ -914,7 +919,7 @@ Changes.removeMarkAtRange = (change, range, mark, options = {}) => { const texts = document.getTextsAtRange(range) const { startKey, startOffset, endKey, endOffset } = range - texts.forEach((node) => { + texts.forEach(node => { const { key } = node let index = 0 let length = node.text.length @@ -943,7 +948,7 @@ Changes.setBlockAtRange = (change, range, properties, options = {}) => { const { document } = value const blocks = document.getBlocksAtRange(range) - blocks.forEach((block) => { + blocks.forEach(block => { change.setNodeByKey(block.key, properties, { normalize }) }) } @@ -964,7 +969,7 @@ Changes.setInlineAtRange = (change, range, properties, options = {}) => { const { document } = value const inlines = document.getInlinesAtRange(range) - inlines.forEach((inline) => { + inlines.forEach(inline => { change.setNodeByKey(inline.key, properties, { normalize }) }) } @@ -1013,7 +1018,12 @@ Changes.splitBlockAtRange = (change, range, height = 1, options = {}) => { * @property {Boolean} normalize */ -Changes.splitInlineAtRange = (change, range, height = Infinity, options = {}) => { +Changes.splitInlineAtRange = ( + change, + range, + height = Infinity, + options = {} +) => { const normalize = change.getFlag('normalize', options) if (range.isExpanded) { @@ -1084,12 +1094,15 @@ Changes.unwrapBlockAtRange = (change, range, properties, options = {}) => { let { document } = value const blocks = document.getBlocksAtRange(range) const wrappers = blocks - .map((block) => { - return document.getClosest(block.key, (parent) => { + .map(block => { + return document.getClosest(block.key, parent => { if (parent.object != 'block') return false - if (properties.type != null && parent.type != properties.type) return false - if (properties.isVoid != null && parent.isVoid != properties.isVoid) return false - if (properties.data != null && !parent.data.isSuperset(properties.data)) return false + if (properties.type != null && parent.type != properties.type) + return false + if (properties.isVoid != null && parent.isVoid != properties.isVoid) + return false + if (properties.data != null && !parent.data.isSuperset(properties.data)) + return false return true }) }) @@ -1097,13 +1110,13 @@ Changes.unwrapBlockAtRange = (change, range, properties, options = {}) => { .toOrderedSet() .toList() - wrappers.forEach((block) => { + wrappers.forEach(block => { const first = block.nodes.first() const last = block.nodes.last() const parent = document.getParent(block.key) const index = parent.nodes.indexOf(block) - const children = block.nodes.filter((child) => { + const children = block.nodes.filter(child => { return blocks.some(b => child == b || child.hasDescendant(b.key)) }) @@ -1112,32 +1125,32 @@ Changes.unwrapBlockAtRange = (change, range, properties, options = {}) => { if (first == firstMatch && last == lastMatch) { block.nodes.forEach((child, i) => { - change.moveNodeByKey(child.key, parent.key, index + i, { normalize: false }) + change.moveNodeByKey(child.key, parent.key, index + i, { + normalize: false, + }) }) change.removeNodeByKey(block.key, { normalize: false }) - } - - else if (last == lastMatch) { - block.nodes - .skipUntil(n => n == firstMatch) - .forEach((child, i) => { - change.moveNodeByKey(child.key, parent.key, index + 1 + i, { normalize: false }) + } else if (last == lastMatch) { + block.nodes.skipUntil(n => n == firstMatch).forEach((child, i) => { + change.moveNodeByKey(child.key, parent.key, index + 1 + i, { + normalize: false, }) - } - - else if (first == firstMatch) { + }) + } else if (first == firstMatch) { block.nodes .takeUntil(n => n == lastMatch) .push(lastMatch) .forEach((child, i) => { - change.moveNodeByKey(child.key, parent.key, index + i, { normalize: false }) + change.moveNodeByKey(child.key, parent.key, index + i, { + normalize: false, + }) }) - } - - else { + } else { const firstText = firstMatch.getFirstText() - change.splitDescendantsByKey(block.key, firstText.key, 0, { normalize: false }) + change.splitDescendantsByKey(block.key, firstText.key, 0, { + normalize: false, + }) document = change.value.document children.forEach((child, i) => { @@ -1147,7 +1160,9 @@ Changes.unwrapBlockAtRange = (change, range, properties, options = {}) => { change.removeNodeByKey(extra.key, { normalize: false }) } - change.moveNodeByKey(child.key, parent.key, index + 1 + i, { normalize: false }) + change.moveNodeByKey(child.key, parent.key, index + 1 + i, { + normalize: false, + }) }) } }) @@ -1176,12 +1191,15 @@ Changes.unwrapInlineAtRange = (change, range, properties, options = {}) => { const { document } = value const texts = document.getTextsAtRange(range) const inlines = texts - .map((text) => { - return document.getClosest(text.key, (parent) => { + .map(text => { + return document.getClosest(text.key, parent => { if (parent.object != 'inline') return false - if (properties.type != null && parent.type != properties.type) return false - if (properties.isVoid != null && parent.isVoid != properties.isVoid) return false - if (properties.data != null && !parent.data.isSuperset(properties.data)) return false + if (properties.type != null && parent.type != properties.type) + return false + if (properties.isVoid != null && parent.isVoid != properties.isVoid) + return false + if (properties.data != null && !parent.data.isSuperset(properties.data)) + return false return true }) }) @@ -1189,12 +1207,14 @@ Changes.unwrapInlineAtRange = (change, range, properties, options = {}) => { .toOrderedSet() .toList() - inlines.forEach((inline) => { + inlines.forEach(inline => { const parent = change.value.document.getParent(inline.key) const index = parent.nodes.indexOf(inline) inline.nodes.forEach((child, i) => { - change.moveNodeByKey(child.key, parent.key, index + i, { normalize: false }) + change.moveNodeByKey(child.key, parent.key, index + i, { + normalize: false, + }) }) }) @@ -1232,11 +1252,9 @@ Changes.wrapBlockAtRange = (change, range, block, options = {}) => { if (blocks.length === 1) { parent = document.getParent(firstblock.key) siblings = blocks - } - - // Determine closest shared parent to all blocks in selection. - else { - parent = document.getClosest(firstblock.key, (p1) => { + } else { + // Determine closest shared parent to all blocks in selection. + parent = document.getClosest(firstblock.key, p1 => { return !!document.getClosest(lastblock.key, p2 => p1 == p2) }) } @@ -1310,8 +1328,12 @@ Changes.wrapInlineAtRange = (change, range, inline, options = {}) => { let startChild = startBlock.getFurthestAncestor(startKey) let endChild = endBlock.getFurthestAncestor(endKey) - change.splitDescendantsByKey(endChild.key, endKey, endOffset, { normalize: false }) - change.splitDescendantsByKey(startChild.key, startKey, startOffset, { normalize: false }) + change.splitDescendantsByKey(endChild.key, endKey, endOffset, { + normalize: false, + }) + change.splitDescendantsByKey(startChild.key, startKey, startOffset, { + normalize: false, + }) document = change.value.document startBlock = document.getDescendant(startBlock.key) @@ -1328,7 +1350,8 @@ Changes.wrapInlineAtRange = (change, range, inline, options = {}) => { const startInner = document.getNextSibling(startChild.key) const startInnerIndex = startBlock.nodes.indexOf(startInner) - const endInner = startKey == endKey ? startInner : startBlock.getFurthestAncestor(endKey) + const endInner = + startKey == endKey ? startInner : startBlock.getFurthestAncestor(endKey) const inlines = startBlock.nodes .skipUntil(n => n == startInner) .takeUntil(n => n == endInner) @@ -1336,7 +1359,9 @@ Changes.wrapInlineAtRange = (change, range, inline, options = {}) => { const node = inline.regenerateKey() - change.insertNodeByKey(startBlock.key, startInnerIndex, node, { normalize: false }) + change.insertNodeByKey(startBlock.key, startInnerIndex, node, { + normalize: false, + }) inlines.forEach((child, i) => { change.moveNodeByKey(child.key, node.key, i, { normalize: false }) @@ -1345,16 +1370,18 @@ Changes.wrapInlineAtRange = (change, range, inline, options = {}) => { if (normalize) { change.normalizeNodeByKey(startBlock.key) } - } - - else { + } else { const startInlines = startBlock.nodes.slice(startIndex + 1) const endInlines = endBlock.nodes.slice(0, endIndex + 1) const startNode = inline.regenerateKey() const endNode = inline.regenerateKey() - change.insertNodeByKey(startBlock.key, startIndex + 1, startNode, { normalize: false }) - change.insertNodeByKey(endBlock.key, endIndex, endNode, { normalize: false }) + change.insertNodeByKey(startBlock.key, startIndex + 1, startNode, { + normalize: false, + }) + change.insertNodeByKey(endBlock.key, endIndex, endNode, { + normalize: false, + }) startInlines.forEach((child, i) => { change.moveNodeByKey(child.key, startNode.key, i, { normalize: false }) @@ -1365,12 +1392,10 @@ Changes.wrapInlineAtRange = (change, range, inline, options = {}) => { }) if (normalize) { - change - .normalizeNodeByKey(startBlock.key) - .normalizeNodeByKey(endBlock.key) + change.normalizeNodeByKey(startBlock.key).normalizeNodeByKey(endBlock.key) } - blocks.slice(1, -1).forEach((block) => { + blocks.slice(1, -1).forEach(block => { const node = inline.regenerateKey() change.insertNodeByKey(block.key, 0, node, { normalize: false }) @@ -1396,7 +1421,13 @@ Changes.wrapInlineAtRange = (change, range, inline, options = {}) => { * @property {Boolean} normalize */ -Changes.wrapTextAtRange = (change, range, prefix, suffix = prefix, options = {}) => { +Changes.wrapTextAtRange = ( + change, + range, + prefix, + suffix = prefix, + options = {} +) => { const normalize = change.getFlag('normalize', options) const { startKey, endKey } = range const start = range.collapseToStart() diff --git a/packages/slate/src/changes/by-key.js b/packages/slate/src/changes/by-key.js index e9ac3a7d1..2504a983d 100644 --- a/packages/slate/src/changes/by-key.js +++ b/packages/slate/src/changes/by-key.js @@ -1,4 +1,3 @@ - import Block from '../models/block' import Inline from '../models/inline' import Mark from '../models/mark' @@ -38,7 +37,7 @@ Changes.addMarkByKey = (change, key, offset, length, mark, options = {}) => { const by = offset + length let o = 0 - leaves.forEach((leaf) => { + leaves.forEach(leaf => { const ax = o const ay = ax + leaf.text.length @@ -181,7 +180,8 @@ Changes.mergeNodeByKey = (change, key, options = {}) => { throw new Error(`Unable to merge node with key "${key}", no previous key.`) } - const position = previous.object == 'text' ? previous.text.length : previous.nodes.size + const position = + previous.object == 'text' ? previous.text.length : previous.nodes.size change.applyOperation({ type: 'merge_node', @@ -261,7 +261,7 @@ Changes.removeMarkByKey = (change, key, offset, length, mark, options = {}) => { const by = offset + length let o = 0 - leaves.forEach((leaf) => { + leaves.forEach(leaf => { const ax = o const ay = ax + leaf.text.length @@ -310,8 +310,8 @@ Changes.removeAllMarksByKey = (change, key, options = {}) => { const node = document.getNode(key) const texts = node.object === 'text' ? [node] : node.getTextsAsArray() - texts.forEach((text) => { - text.getMarksAsArray().forEach((mark) => { + texts.forEach(text => { + text.getMarksAsArray().forEach(mark => { change.removeMarkByKey(text.key, 0, text.text.length, mark, options) }) }) @@ -371,7 +371,7 @@ Changes.removeTextByKey = (change, key, offset, length, options = {}) => { const by = offset + length let o = 0 - leaves.forEach((leaf) => { + leaves.forEach(leaf => { const ax = o const ay = ax + leaf.text.length @@ -441,7 +441,15 @@ Changes.replaceNodeByKey = (change, key, newNode, options = {}) => { * @property {Boolean} normalize */ -Changes.setMarkByKey = (change, key, offset, length, mark, properties, options = {}) => { +Changes.setMarkByKey = ( + change, + key, + offset, + length, + mark, + properties, + options = {} +) => { mark = Mark.create(mark) properties = Mark.createProperties(properties) const normalize = change.getFlag('normalize', options) @@ -541,7 +549,13 @@ Changes.splitNodeByKey = (change, key, position, options = {}) => { * @property {Boolean} normalize */ -Changes.splitDescendantsByKey = (change, key, textKey, textOffset, options = {}) => { +Changes.splitDescendantsByKey = ( + change, + key, + textKey, + textOffset, + options = {} +) => { if (key == textKey) { change.splitNodeByKey(textKey, textOffset, options) return @@ -553,15 +567,21 @@ Changes.splitDescendantsByKey = (change, key, textKey, textOffset, options = {}) const text = document.getNode(textKey) const ancestors = document.getAncestors(textKey) - const nodes = ancestors.skipUntil(a => a.key == key).reverse().unshift(text) + const nodes = ancestors + .skipUntil(a => a.key == key) + .reverse() + .unshift(text) let previous let index - nodes.forEach((node) => { + nodes.forEach(node => { const prevIndex = index == null ? null : index index = previous ? node.nodes.indexOf(previous) + 1 : textOffset previous = node - change.splitNodeByKey(node.key, index, { normalize: false, target: prevIndex }) + change.splitNodeByKey(node.key, index, { + normalize: false, + target: prevIndex, + }) }) if (normalize) { @@ -638,26 +658,24 @@ Changes.unwrapNodeByKey = (change, key, options = {}) => { const parentIndex = parentParent.nodes.indexOf(parent) if (parent.nodes.size === 1) { - change.moveNodeByKey(key, parentParent.key, parentIndex, { normalize: false }) + change.moveNodeByKey(key, parentParent.key, parentIndex, { + normalize: false, + }) change.removeNodeByKey(parent.key, options) - } - - else if (isFirst) { + } else if (isFirst) { // Just move the node before its parent. change.moveNodeByKey(key, parentParent.key, parentIndex, options) - } - - else if (isLast) { + } else if (isLast) { // Just move the node after its parent. change.moveNodeByKey(key, parentParent.key, parentIndex + 1, options) - } - - else { + } else { // Split the parent. change.splitNodeByKey(parent.key, index, { normalize: false }) // Extract the node in between the splitted parent. - change.moveNodeByKey(key, parentParent.key, parentIndex + 1, { normalize: false }) + change.moveNodeByKey(key, parentParent.key, parentIndex + 1, { + normalize: false, + }) if (normalize) { change.normalizeNodeByKey(parentParent.key) diff --git a/packages/slate/src/changes/index.js b/packages/slate/src/changes/index.js index bab841ec1..d9d49c615 100644 --- a/packages/slate/src/changes/index.js +++ b/packages/slate/src/changes/index.js @@ -1,4 +1,3 @@ - import AtCurrentRange from './at-current-range' import AtRange from './at-range' import ByKey from './by-key' diff --git a/packages/slate/src/changes/on-history.js b/packages/slate/src/changes/on-history.js index 00530bde3..985652923 100644 --- a/packages/slate/src/changes/on-history.js +++ b/packages/slate/src/changes/on-history.js @@ -1,4 +1,3 @@ - import invert from '../operations/invert' import omit from 'lodash/omit' @@ -16,7 +15,7 @@ const Changes = {} * @param {Change} change */ -Changes.redo = (change) => { +Changes.redo = change => { let { value } = change let { history } = value if (!history) return @@ -30,7 +29,7 @@ Changes.redo = (change) => { undos = undos.push(next) // Replay the next operations. - next.forEach((op) => { + next.forEach(op => { const { type, properties } = op // When the operation mutates the selection, omit its `isFocused` value to @@ -55,7 +54,7 @@ Changes.redo = (change) => { * @param {Change} change */ -Changes.undo = (change) => { +Changes.undo = change => { let { value } = change let { history } = value if (!history) return @@ -69,17 +68,21 @@ Changes.undo = (change) => { redos = redos.push(previous) // Replay the inverse of the previous operations. - previous.slice().reverse().map(invert).forEach((inverse) => { - const { type, properties } = inverse + previous + .slice() + .reverse() + .map(invert) + .forEach(inverse => { + const { type, properties } = inverse - // When the operation mutates the selection, omit its `isFocused` value to - // prevent the editor focus from changing during undoing. - if (type == 'set_selection') { - inverse = inverse.set('properties', omit(properties, 'isFocused')) - } + // When the operation mutates the selection, omit its `isFocused` value to + // prevent the editor focus from changing during undoing. + if (type == 'set_selection') { + inverse = inverse.set('properties', omit(properties, 'isFocused')) + } - change.applyOperation(inverse, { save: false }) - }) + change.applyOperation(inverse, { save: false }) + }) // Update the history. value = change.value diff --git a/packages/slate/src/changes/on-selection.js b/packages/slate/src/changes/on-selection.js index 9f6af8b70..c553f112c 100644 --- a/packages/slate/src/changes/on-selection.js +++ b/packages/slate/src/changes/on-selection.js @@ -1,4 +1,3 @@ - import isEmpty from 'is-empty' import pick from 'lodash/pick' @@ -40,12 +39,9 @@ Changes.select = (change, properties, options = {}) => { // If the selection moves, clear any marks, unless the new selection // properties change the marks in some way. - const moved = [ - 'anchorKey', - 'anchorOffset', - 'focusKey', - 'focusOffset', - ].some(p => props.hasOwnProperty(p)) + const moved = ['anchorKey', 'anchorOffset', 'focusKey', 'focusOffset'].some( + p => props.hasOwnProperty(p) + ) if (sel.marks && properties.marks == sel.marks && moved) { props.marks = null @@ -57,12 +53,15 @@ Changes.select = (change, properties, options = {}) => { } // Apply the operation. - change.applyOperation({ - type: 'set_selection', - value, - properties: props, - selection: sel, - }, snapshot ? { skip: false, merge: false } : {}) + change.applyOperation( + { + type: 'set_selection', + value, + properties: props, + selection: sel, + }, + snapshot ? { skip: false, merge: false } : {} + ) } /** @@ -71,7 +70,7 @@ Changes.select = (change, properties, options = {}) => { * @param {Change} change */ -Changes.selectAll = (change) => { +Changes.selectAll = change => { const { value } = change const { document, selection } = value const next = selection.moveToRangeOf(document) @@ -84,7 +83,7 @@ Changes.selectAll = (change) => { * @param {Change} change */ -Changes.snapshotSelection = (change) => { +Changes.snapshotSelection = change => { const { value } = change const { selection } = value change.select(selection, { snapshot: true }) @@ -96,13 +95,14 @@ Changes.snapshotSelection = (change) => { * @param {Change} change */ -Changes.moveAnchorCharBackward = (change) => { +Changes.moveAnchorCharBackward = change => { const { value } = change const { document, selection, anchorText, anchorBlock } = value const { anchorOffset } = selection const previousText = document.getPreviousText(anchorText.key) const isInVoid = document.hasVoidParent(anchorText.key) - const isPreviousInVoid = previousText && document.hasVoidParent(previousText.key) + const isPreviousInVoid = + previousText && document.hasVoidParent(previousText.key) if (!isInVoid && anchorOffset > 0) { change.moveAnchor(-1) @@ -126,7 +126,7 @@ Changes.moveAnchorCharBackward = (change) => { * @param {Change} change */ -Changes.moveAnchorCharForward = (change) => { +Changes.moveAnchorCharForward = change => { const { value } = change const { document, selection, anchorText, anchorBlock } = value const { anchorOffset } = selection @@ -156,13 +156,14 @@ Changes.moveAnchorCharForward = (change) => { * @param {Change} change */ -Changes.moveFocusCharBackward = (change) => { +Changes.moveFocusCharBackward = change => { const { value } = change const { document, selection, focusText, focusBlock } = value const { focusOffset } = selection const previousText = document.getPreviousText(focusText.key) const isInVoid = document.hasVoidParent(focusText.key) - const isPreviousInVoid = previousText && document.hasVoidParent(previousText.key) + const isPreviousInVoid = + previousText && document.hasVoidParent(previousText.key) if (!isInVoid && focusOffset > 0) { change.moveFocus(-1) @@ -186,7 +187,7 @@ Changes.moveFocusCharBackward = (change) => { * @param {Change} change */ -Changes.moveFocusCharForward = (change) => { +Changes.moveFocusCharForward = change => { const { value } = change const { document, selection, focusText, focusBlock } = value const { focusOffset } = selection @@ -214,20 +215,17 @@ Changes.moveFocusCharForward = (change) => { * Mix in move methods. */ -const MOVE_DIRECTIONS = [ - 'Forward', - 'Backward', -] +const MOVE_DIRECTIONS = ['Forward', 'Backward'] -MOVE_DIRECTIONS.forEach((direction) => { +MOVE_DIRECTIONS.forEach(direction => { const anchor = `moveAnchorChar${direction}` const focus = `moveFocusChar${direction}` - Changes[`moveChar${direction}`] = (change) => { + Changes[`moveChar${direction}`] = change => { change[anchor]()[focus]() } - Changes[`moveStartChar${direction}`] = (change) => { + Changes[`moveStartChar${direction}`] = change => { if (change.value.isBackward) { change[focus]() } else { @@ -235,7 +233,7 @@ MOVE_DIRECTIONS.forEach((direction) => { } } - Changes[`moveEndChar${direction}`] = (change) => { + Changes[`moveEndChar${direction}`] = change => { if (change.value.isBackward) { change[anchor]() } else { @@ -243,12 +241,13 @@ MOVE_DIRECTIONS.forEach((direction) => { } } - Changes[`extendChar${direction}`] = (change) => { + Changes[`extendChar${direction}`] = change => { change[`moveFocusChar${direction}`]() } - Changes[`collapseChar${direction}`] = (change) => { - const collapse = direction == 'Forward' ? 'collapseToEnd' : 'collapseToStart' + Changes[`collapseChar${direction}`] = change => { + const collapse = + direction == 'Forward' ? 'collapseToEnd' : 'collapseToStart' change[collapse]()[`moveChar${direction}`]() } }) @@ -264,8 +263,8 @@ const ALIAS_METHODS = [ ['extendLineForward', 'extendToEndOfBlock'], ] -ALIAS_METHODS.forEach(([ alias, method ]) => { - Changes[alias] = function (change, ...args) { +ALIAS_METHODS.forEach(([alias, method]) => { + Changes[alias] = function(change, ...args) { change[method](change, ...args) } }) @@ -316,7 +315,7 @@ const PROXY_TRANSFORMS = [ 'deselect', ] -PROXY_TRANSFORMS.forEach((method) => { +PROXY_TRANSFORMS.forEach(method => { Changes[method] = (change, ...args) => { const normalize = method != 'deselect' const { value } = change @@ -341,34 +340,24 @@ const PREFIXES = [ 'extendTo', ] -const DIRECTIONS = [ - 'Next', - 'Previous', -] +const DIRECTIONS = ['Next', 'Previous'] -const OBJECTS = [ - 'Block', - 'Inline', - 'Text', -] +const OBJECTS = ['Block', 'Inline', 'Text'] -PREFIXES.forEach((prefix) => { - const edges = [ - 'Start', - 'End', - ] +PREFIXES.forEach(prefix => { + const edges = ['Start', 'End'] if (prefix == 'moveTo') { edges.push('Range') } - edges.forEach((edge) => { + edges.forEach(edge => { const method = `${prefix}${edge}Of` - OBJECTS.forEach((object) => { + OBJECTS.forEach(object => { const getNode = object == 'Text' ? 'getNode' : `getClosest${object}` - Changes[`${method}${object}`] = (change) => { + Changes[`${method}${object}`] = change => { const { value } = change const { document, selection } = value const node = document[getNode](selection.startKey) @@ -376,11 +365,11 @@ PREFIXES.forEach((prefix) => { change[method](node) } - DIRECTIONS.forEach((direction) => { + DIRECTIONS.forEach(direction => { const getDirectionNode = `get${direction}${object}` const directionKey = direction == 'Next' ? 'startKey' : 'endKey' - Changes[`${method}${direction}${object}`] = (change) => { + Changes[`${method}${direction}${object}`] = change => { const { value } = change const { document, selection } = value const node = document[getNode](selection[directionKey]) diff --git a/packages/slate/src/changes/on-value.js b/packages/slate/src/changes/on-value.js index 36c969a4c..d46394788 100644 --- a/packages/slate/src/changes/on-value.js +++ b/packages/slate/src/changes/on-value.js @@ -1,4 +1,3 @@ - import Value from '../models/value' /** @@ -21,11 +20,14 @@ Changes.setValue = (change, properties, options = {}) => { properties = Value.createProperties(properties) const { value } = change - change.applyOperation({ - type: 'set_value', - properties, - value, - }, options) + change.applyOperation( + { + type: 'set_value', + properties, + value, + }, + options + ) } /** diff --git a/packages/slate/src/changes/with-schema.js b/packages/slate/src/changes/with-schema.js index 0e8515cc1..f2486dfed 100644 --- a/packages/slate/src/changes/with-schema.js +++ b/packages/slate/src/changes/with-schema.js @@ -1,5 +1,3 @@ - - /** * Changes. * @@ -14,7 +12,7 @@ const Changes = {} * @param {Change} change */ -Changes.normalize = (change) => { +Changes.normalize = change => { change.normalizeDocument() } @@ -24,7 +22,7 @@ Changes.normalize = (change) => { * @param {Change} change */ -Changes.normalizeDocument = (change) => { +Changes.normalizeDocument = change => { const { value } = change const { document } = value change.normalizeNodeByKey(document.key) @@ -48,7 +46,7 @@ Changes.normalizeNodeByKey = (change, key) => { const ancestors = document.getAncestors(key) if (!ancestors) return - ancestors.forEach((ancestor) => { + ancestors.forEach(ancestor => { normalizeNode(change, ancestor, schema) }) } @@ -136,7 +134,9 @@ function normalizeNode(change, node, schema) { iterations++ if (iterations > max) { - throw new Error('A schema rule could not be validated after sufficient iterations. This is usually due to a `rule.validate` or `rule.normalize` function of a schema being incorrectly written, causing an infinite loop.') + throw new Error( + 'A schema rule could not be validated after sufficient iterations. This is usually due to a `rule.validate` or `rule.normalize` function of a schema being incorrectly written, causing an infinite loop.' + ) } // Otherwise, iterate again. diff --git a/packages/slate/src/constants/core-schema-rules.js b/packages/slate/src/constants/core-schema-rules.js index ba54e78bd..4a8294af1 100644 --- a/packages/slate/src/constants/core-schema-rules.js +++ b/packages/slate/src/constants/core-schema-rules.js @@ -1,4 +1,3 @@ - import { List } from 'immutable' import Text from '../models/text' @@ -10,7 +9,6 @@ import Text from '../models/text' */ const CORE_SCHEMA_RULES = [ - /** * Only allow block nodes in documents. * @@ -23,12 +21,12 @@ const CORE_SCHEMA_RULES = [ const invalids = node.nodes.filter(n => n.object != 'block') if (!invalids.size) return - return (change) => { - invalids.forEach((child) => { + return change => { + invalids.forEach(child => { change.removeNodeByKey(child.key, { normalize: false }) }) } - } + }, }, /** @@ -46,12 +44,12 @@ const CORE_SCHEMA_RULES = [ const invalids = node.nodes.filter(n => !objects.includes(n.object)) if (!invalids.size) return - return (change) => { - invalids.forEach((child) => { + return change => { + invalids.forEach(child => { change.removeNodeByKey(child.key, { normalize: false }) }) } - } + }, }, /** @@ -63,15 +61,17 @@ const CORE_SCHEMA_RULES = [ { validateNode(node) { if (node.object != 'inline') return - const invalids = node.nodes.filter(n => n.object != 'inline' && n.object != 'text') + const invalids = node.nodes.filter( + n => n.object != 'inline' && n.object != 'text' + ) if (!invalids.size) return - return (change) => { - invalids.forEach((child) => { + return change => { + invalids.forEach(child => { change.removeNodeByKey(child.key, { normalize: false }) }) } - } + }, }, /** @@ -85,11 +85,11 @@ const CORE_SCHEMA_RULES = [ if (node.object != 'block' && node.object != 'inline') return if (node.nodes.size > 0) return - return (change) => { + return change => { const text = Text.create() change.insertNodeByKey(node.key, 0, text, { normalize: false }) } - } + }, }, /** @@ -104,17 +104,17 @@ const CORE_SCHEMA_RULES = [ if (node.object != 'block' && node.object != 'inline') return if (node.text == ' ' && node.nodes.size == 1) return - return (change) => { + return change => { const text = Text.create(' ') const index = node.nodes.size change.insertNodeByKey(node.key, index, text, { normalize: false }) - node.nodes.forEach((child) => { + node.nodes.forEach(child => { change.removeNodeByKey(child.key, { normalize: false }) }) } - } + }, }, /** @@ -131,10 +131,12 @@ const CORE_SCHEMA_RULES = [ { validateNode(node) { if (node.object != 'block') return - const invalids = node.nodes.filter(n => n.object == 'inline' && n.text == '') + const invalids = node.nodes.filter( + n => n.object == 'inline' && n.text == '' + ) if (!invalids.size) return - return (change) => { + return change => { // If all of the block's nodes are invalid, insert an empty text node so // that the selection will be preserved when they are all removed. if (node.nodes.size == invalids.size) { @@ -142,11 +144,11 @@ const CORE_SCHEMA_RULES = [ change.insertNodeByKey(node.key, 1, text, { normalize: false }) } - invalids.forEach((child) => { + invalids.forEach(child => { change.removeNodeByKey(child.key, { normalize: false }) }) } - } + }, }, /** @@ -167,7 +169,7 @@ const CORE_SCHEMA_RULES = [ const next = node.nodes.get(index + 1) // We don't test if "prev" is inline, since it has already been processed in the loop const insertBefore = !prev - const insertAfter = !next || (next.object == 'inline') + const insertAfter = !next || next.object == 'inline' if (insertAfter || insertBefore) { list = list.push({ insertAfter, insertBefore, index }) @@ -178,23 +180,27 @@ const CORE_SCHEMA_RULES = [ if (!invalids.size) return - return (change) => { + return change => { // Shift for every text node inserted previously. let shift = 0 invalids.forEach(({ index, insertAfter, insertBefore }) => { if (insertBefore) { - change.insertNodeByKey(node.key, shift + index, Text.create(), { normalize: false }) + change.insertNodeByKey(node.key, shift + index, Text.create(), { + normalize: false, + }) shift++ } if (insertAfter) { - change.insertNodeByKey(node.key, shift + index + 1, Text.create(), { normalize: false }) + change.insertNodeByKey(node.key, shift + index + 1, Text.create(), { + normalize: false, + }) shift++ } }) } - } + }, }, /** @@ -218,14 +224,14 @@ const CORE_SCHEMA_RULES = [ if (!invalids.size) return - return (change) => { + return change => { // Reverse the list to handle consecutive merges, since the earlier nodes // will always exist after each merge. - invalids.reverse().forEach((n) => { + invalids.reverse().forEach(n => { change.mergeNodeByKey(n.key, { normalize: false }) }) } - } + }, }, /** @@ -254,7 +260,8 @@ const CORE_SCHEMA_RULES = [ if (!next && prev.object == 'inline') return // If it's surrounded by inlines, preserve it. - if (next && prev && next.object == 'inline' && prev.object == 'inline') return + if (next && prev && next.object == 'inline' && prev.object == 'inline') + return // Otherwise, remove it. return true @@ -262,14 +269,13 @@ const CORE_SCHEMA_RULES = [ if (!invalids.size) return - return (change) => { - invalids.forEach((text) => { + return change => { + invalids.forEach(text => { change.removeNodeByKey(text.key, { normalize: false }) }) } - } - } - + }, + }, ] /** diff --git a/packages/slate/src/constants/model-types.js b/packages/slate/src/constants/model-types.js index 16362e4f1..6ac97d325 100644 --- a/packages/slate/src/constants/model-types.js +++ b/packages/slate/src/constants/model-types.js @@ -1,4 +1,3 @@ - /** * Slate-specific model types. * diff --git a/packages/slate/src/constants/operation-attributes.js b/packages/slate/src/constants/operation-attributes.js index 894848804..f3cb84dcb 100644 --- a/packages/slate/src/constants/operation-attributes.js +++ b/packages/slate/src/constants/operation-attributes.js @@ -1,4 +1,3 @@ - /** * Slate operation attributes. * @@ -6,86 +5,19 @@ */ const OPERATION_ATTRIBUTES = { - add_mark: [ - 'value', - 'path', - 'offset', - 'length', - 'mark', - ], - insert_node: [ - 'value', - 'path', - 'node', - ], - insert_text: [ - 'value', - 'path', - 'offset', - 'text', - 'marks', - ], - merge_node: [ - 'value', - 'path', - 'position', - 'properties', - 'target', - ], - move_node: [ - 'value', - 'path', - 'newPath', - ], - remove_mark: [ - 'value', - 'path', - 'offset', - 'length', - 'mark', - ], - remove_node: [ - 'value', - 'path', - 'node', - ], - remove_text: [ - 'value', - 'path', - 'offset', - 'text', - 'marks', - ], - set_mark: [ - 'value', - 'path', - 'offset', - 'length', - 'mark', - 'properties', - ], - set_node: [ - 'value', - 'path', - 'node', - 'properties', - ], - set_selection: [ - 'value', - 'selection', - 'properties', - ], - set_value: [ - 'value', - 'properties', - ], - split_node: [ - 'value', - 'path', - 'position', - 'properties', - 'target', - ], + add_mark: ['value', 'path', 'offset', 'length', 'mark'], + insert_node: ['value', 'path', 'node'], + insert_text: ['value', 'path', 'offset', 'text', 'marks'], + merge_node: ['value', 'path', 'position', 'properties', 'target'], + move_node: ['value', 'path', 'newPath'], + remove_mark: ['value', 'path', 'offset', 'length', 'mark'], + remove_node: ['value', 'path', 'node'], + remove_text: ['value', 'path', 'offset', 'text', 'marks'], + set_mark: ['value', 'path', 'offset', 'length', 'mark', 'properties'], + set_node: ['value', 'path', 'node', 'properties'], + set_selection: ['value', 'selection', 'properties'], + set_value: ['value', 'properties'], + split_node: ['value', 'path', 'position', 'properties', 'target'], } /** diff --git a/packages/slate/src/index.js b/packages/slate/src/index.js index e58502adf..86262a813 100644 --- a/packages/slate/src/index.js +++ b/packages/slate/src/index.js @@ -1,4 +1,3 @@ - import Block from './models/block' import Change from './models/change' import Changes from './changes' diff --git a/packages/slate/src/models/block.js b/packages/slate/src/models/block.js index fb7b956ae..4a5341c0b 100644 --- a/packages/slate/src/models/block.js +++ b/packages/slate/src/models/block.js @@ -1,4 +1,3 @@ - /** * Prevent circular dependencies. */ @@ -38,7 +37,6 @@ const DEFAULTS = { */ class Block extends Record(DEFAULTS) { - /** * Create a new `Block` from `attrs`. * @@ -59,7 +57,9 @@ class Block extends Record(DEFAULTS) { return Block.fromJSON(attrs) } - throw new Error(`\`Block.create\` only accepts objects, strings or blocks, but you passed it: ${attrs}`) + throw new Error( + `\`Block.create\` only accepts objects, strings or blocks, but you passed it: ${attrs}` + ) } /** @@ -75,7 +75,9 @@ class Block extends Record(DEFAULTS) { return list } - throw new Error(`\`Block.createList\` only accepts arrays or lists, but you passed it: ${attrs}`) + throw new Error( + `\`Block.createList\` only accepts arrays or lists, but you passed it: ${attrs}` + ) } /** @@ -152,7 +154,10 @@ class Block extends Record(DEFAULTS) { } get kind() { - logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.') + logger.deprecate( + 'slate@0.32.0', + 'The `kind` property of Slate objects has been renamed to `object`.' + ) return this.object } @@ -206,7 +211,6 @@ class Block extends Record(DEFAULTS) { toJS(options) { return this.toJSON(options) } - } /** @@ -219,7 +223,7 @@ Block.prototype[MODEL_TYPES.BLOCK] = true * Mix in `Node` methods. */ -Object.getOwnPropertyNames(Node.prototype).forEach((method) => { +Object.getOwnPropertyNames(Node.prototype).forEach(method => { if (method == 'constructor') return Block.prototype[method] = Node.prototype[method] }) diff --git a/packages/slate/src/models/change.js b/packages/slate/src/models/change.js index 00ae550d5..fe3dc9f64 100644 --- a/packages/slate/src/models/change.js +++ b/packages/slate/src/models/change.js @@ -1,4 +1,3 @@ - import Debug from 'debug' import isPlainObject from 'is-plain-object' import logger from 'slate-dev-logger' @@ -25,7 +24,6 @@ const debug = Debug('slate:change') */ class Change { - /** * Check if `any` is a `Change`. * @@ -50,7 +48,7 @@ class Change { this.operations = new List() this.flags = { normalize: true, - ...pick(attrs, ['merge', 'save', 'normalize']) + ...pick(attrs, ['merge', 'save', 'normalize']), } } @@ -65,7 +63,10 @@ class Change { } get kind() { - logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.') + logger.deprecate( + 'slate@0.32.0', + 'The `kind` property of Slate objects has been renamed to `object`.' + ) return this.object } @@ -187,9 +188,7 @@ class Change { */ getFlag(key, options = {}) { - return options[key] !== undefined ? - options[key] : - this.flags[key] + return options[key] !== undefined ? options[key] : this.flags[key] } /** @@ -203,7 +202,6 @@ class Change { delete this.flags[key] return this } - } /** @@ -216,8 +214,8 @@ Change.prototype[MODEL_TYPES.CHANGE] = true * Add a change method for each of the changes. */ -Object.keys(Changes).forEach((type) => { - Change.prototype[type] = function (...args) { +Object.keys(Changes).forEach(type => { + Change.prototype[type] = function(...args) { debug(type, { args }) this.call(Changes[type], ...args) return this diff --git a/packages/slate/src/models/character.js b/packages/slate/src/models/character.js index b8a3572aa..936807523 100644 --- a/packages/slate/src/models/character.js +++ b/packages/slate/src/models/character.js @@ -1,4 +1,3 @@ - import isPlainObject from 'is-plain-object' import logger from 'slate-dev-logger' import { List, Record, Set } from 'immutable' @@ -23,7 +22,6 @@ const DEFAULTS = { */ class Character extends Record(DEFAULTS) { - /** * Create a `Character` with `attrs`. * @@ -44,7 +42,9 @@ class Character extends Record(DEFAULTS) { return Character.fromJSON(attrs) } - throw new Error(`\`Character.create\` only accepts objects, strings or characters, but you passed it: ${attrs}`) + throw new Error( + `\`Character.create\` only accepts objects, strings or characters, but you passed it: ${attrs}` + ) } /** @@ -64,7 +64,9 @@ class Character extends Record(DEFAULTS) { return list } - throw new Error(`\`Block.createList\` only accepts strings, arrays or lists, but you passed it: ${elements}`) + throw new Error( + `\`Block.createList\` only accepts strings, arrays or lists, but you passed it: ${elements}` + ) } /** @@ -75,10 +77,7 @@ class Character extends Record(DEFAULTS) { */ static fromJSON(object) { - const { - text, - marks = [], - } = object + const { text, marks = [] } = object if (typeof text != 'string') { throw new Error('`Character.fromJSON` requires a block `text` string.') @@ -131,7 +130,10 @@ class Character extends Record(DEFAULTS) { } get kind() { - logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.') + logger.deprecate( + 'slate@0.32.0', + 'The `kind` property of Slate objects has been renamed to `object`.' + ) return this.object } @@ -158,7 +160,6 @@ class Character extends Record(DEFAULTS) { toJS() { return this.toJSON() } - } /** diff --git a/packages/slate/src/models/data.js b/packages/slate/src/models/data.js index f8ef25c7d..e51ef8733 100644 --- a/packages/slate/src/models/data.js +++ b/packages/slate/src/models/data.js @@ -1,4 +1,3 @@ - import isPlainObject from 'is-plain-object' import { Map } from 'immutable' @@ -12,7 +11,6 @@ import { Map } from 'immutable' */ class Data { - /** * Create a new `Data` with `attrs`. * @@ -29,7 +27,9 @@ class Data { return Data.fromJSON(attrs) } - throw new Error(`\`Data.create\` only accepts objects or maps, but you passed it: ${attrs}`) + throw new Error( + `\`Data.create\` only accepts objects or maps, but you passed it: ${attrs}` + ) } /** @@ -48,7 +48,6 @@ class Data { */ static fromJS = Data.fromJSON - } /** diff --git a/packages/slate/src/models/document.js b/packages/slate/src/models/document.js index a316520f1..58d350c3c 100644 --- a/packages/slate/src/models/document.js +++ b/packages/slate/src/models/document.js @@ -1,4 +1,3 @@ - /** * Prevent circular dependencies. */ @@ -37,7 +36,6 @@ const DEFAULTS = { */ class Document extends Record(DEFAULTS) { - /** * Create a new `Document` with `attrs`. * @@ -58,7 +56,9 @@ class Document extends Record(DEFAULTS) { return Document.fromJSON(attrs) } - throw new Error(`\`Document.create\` only accepts objects, arrays, lists or documents, but you passed it: ${attrs}`) + throw new Error( + `\`Document.create\` only accepts objects, arrays, lists or documents, but you passed it: ${attrs}` + ) } /** @@ -73,11 +73,7 @@ class Document extends Record(DEFAULTS) { return object } - const { - data = {}, - key = generateKey(), - nodes = [], - } = object + const { data = {}, key = generateKey(), nodes = [] } = object const document = new Document({ key, @@ -116,7 +112,10 @@ class Document extends Record(DEFAULTS) { } get kind() { - logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.') + logger.deprecate( + 'slate@0.32.0', + 'The `kind` property of Slate objects has been renamed to `object`.' + ) return this.object } @@ -168,7 +167,6 @@ class Document extends Record(DEFAULTS) { toJS(options) { return this.toJSON(options) } - } /** @@ -181,7 +179,7 @@ Document.prototype[MODEL_TYPES.DOCUMENT] = true * Mix in `Node` methods. */ -Object.getOwnPropertyNames(Node.prototype).forEach((method) => { +Object.getOwnPropertyNames(Node.prototype).forEach(method => { if (method == 'constructor') return Document.prototype[method] = Node.prototype[method] }) diff --git a/packages/slate/src/models/history.js b/packages/slate/src/models/history.js index f36dd6d96..0c4b483ab 100644 --- a/packages/slate/src/models/history.js +++ b/packages/slate/src/models/history.js @@ -1,4 +1,3 @@ - import Debug from 'debug' import isEqual from 'lodash/isEqual' import isPlainObject from 'is-plain-object' @@ -33,7 +32,6 @@ const DEFAULTS = { */ class History extends Record(DEFAULTS) { - /** * Create a new `History` with `attrs`. * @@ -50,7 +48,9 @@ class History extends Record(DEFAULTS) { return History.fromJSON(attrs) } - throw new Error(`\`History.create\` only accepts objects or histories, but you passed it: ${attrs}`) + throw new Error( + `\`History.create\` only accepts objects or histories, but you passed it: ${attrs}` + ) } /** @@ -61,10 +61,7 @@ class History extends Record(DEFAULTS) { */ static fromJSON(object) { - const { - redos = [], - undos = [], - } = object + const { redos = [], undos = [] } = object const history = new History({ redos: new Stack(redos), @@ -102,7 +99,10 @@ class History extends Record(DEFAULTS) { } get kind() { - logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.') + logger.deprecate( + 'slate@0.32.0', + 'The `kind` property of Slate objects has been renamed to `object`.' + ) return this.object } @@ -140,10 +140,8 @@ class History extends Record(DEFAULTS) { const batch = prevBatch.push(operation) undos = undos.pop() undos = undos.push(batch) - } - - // Otherwise, create a new batch with the operation. - else { + } else { + // Otherwise, create a new batch with the operation. const batch = new List([operation]) undos = undos.push(batch) } @@ -182,7 +180,6 @@ class History extends Record(DEFAULTS) { toJS() { return this.toJSON() } - } /** @@ -202,22 +199,16 @@ History.prototype[MODEL_TYPES.HISTORY] = true function shouldMerge(o, p) { if (!p) return false - const merge = ( - ( - o.type == 'set_selection' && - p.type == 'set_selection' - ) || ( - o.type == 'insert_text' && + const merge = + (o.type == 'set_selection' && p.type == 'set_selection') || + (o.type == 'insert_text' && p.type == 'insert_text' && o.offset == p.offset + p.text.length && - isEqual(o.path, p.path) - ) || ( - o.type == 'remove_text' && + isEqual(o.path, p.path)) || + (o.type == 'remove_text' && p.type == 'remove_text' && o.offset + o.text.length == p.offset && - isEqual(o.path, p.path) - ) - ) + isEqual(o.path, p.path)) return merge } @@ -233,10 +224,7 @@ function shouldMerge(o, p) { function shouldSkip(o, p) { if (!p) return false - const skip = ( - o.type == 'set_selection' && - p.type == 'set_selection' - ) + const skip = o.type == 'set_selection' && p.type == 'set_selection' return skip } diff --git a/packages/slate/src/models/inline.js b/packages/slate/src/models/inline.js index 6bcea0e60..29ebf4f57 100644 --- a/packages/slate/src/models/inline.js +++ b/packages/slate/src/models/inline.js @@ -1,4 +1,3 @@ - /** * Prevent circular dependencies. */ @@ -38,7 +37,6 @@ const DEFAULTS = { */ class Inline extends Record(DEFAULTS) { - /** * Create a new `Inline` with `attrs`. * @@ -59,7 +57,9 @@ class Inline extends Record(DEFAULTS) { return Inline.fromJSON(attrs) } - throw new Error(`\`Inline.create\` only accepts objects, strings or inlines, but you passed it: ${attrs}`) + throw new Error( + `\`Inline.create\` only accepts objects, strings or inlines, but you passed it: ${attrs}` + ) } /** @@ -75,7 +75,9 @@ class Inline extends Record(DEFAULTS) { return list } - throw new Error(`\`Inline.createList\` only accepts arrays or lists, but you passed it: ${elements}`) + throw new Error( + `\`Inline.createList\` only accepts arrays or lists, but you passed it: ${elements}` + ) } /** @@ -152,7 +154,10 @@ class Inline extends Record(DEFAULTS) { } get kind() { - logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.') + logger.deprecate( + 'slate@0.32.0', + 'The `kind` property of Slate objects has been renamed to `object`.' + ) return this.object } @@ -206,7 +211,6 @@ class Inline extends Record(DEFAULTS) { toJS(options) { return this.toJSON(options) } - } /** @@ -219,7 +223,7 @@ Inline.prototype[MODEL_TYPES.INLINE] = true * Mix in `Node` methods. */ -Object.getOwnPropertyNames(Node.prototype).forEach((method) => { +Object.getOwnPropertyNames(Node.prototype).forEach(method => { if (method == 'constructor') return Inline.prototype[method] = Node.prototype[method] }) diff --git a/packages/slate/src/models/leaf.js b/packages/slate/src/models/leaf.js index 8aabad780..58fce24b8 100644 --- a/packages/slate/src/models/leaf.js +++ b/packages/slate/src/models/leaf.js @@ -1,4 +1,3 @@ - import isPlainObject from 'is-plain-object' import logger from 'slate-dev-logger' import { List, Record, Set } from 'immutable' @@ -25,7 +24,6 @@ const DEFAULTS = { */ class Leaf extends Record(DEFAULTS) { - /** * Create a new `Leaf` with `attrs`. * @@ -46,7 +44,9 @@ class Leaf extends Record(DEFAULTS) { return Leaf.fromJSON(attrs) } - throw new Error(`\`Leaf.create\` only accepts objects, strings or leaves, but you passed it: ${attrs}`) + throw new Error( + `\`Leaf.create\` only accepts objects, strings or leaves, but you passed it: ${attrs}` + ) } /** @@ -62,7 +62,9 @@ class Leaf extends Record(DEFAULTS) { return list } - throw new Error(`\`Leaf.createList\` only accepts arrays or lists, but you passed it: ${attrs}`) + throw new Error( + `\`Leaf.createList\` only accepts arrays or lists, but you passed it: ${attrs}` + ) } /** @@ -73,10 +75,7 @@ class Leaf extends Record(DEFAULTS) { */ static fromJSON(object) { - const { - text = '', - marks = [], - } = object + const { text = '', marks = [] } = object const leaf = new Leaf({ text, @@ -125,7 +124,10 @@ class Leaf extends Record(DEFAULTS) { } get kind() { - logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.') + logger.deprecate( + 'slate@0.32.0', + 'The `kind` property of Slate objects has been renamed to `object`.' + ) return this.object } @@ -137,14 +139,14 @@ class Leaf extends Record(DEFAULTS) { getCharacters() { const { marks } = this - const characters = Character.createList(this.text - .split('') - .map((char) => { + const characters = Character.createList( + this.text.split('').map(char => { return Character.create({ text: char, - marks + marks, }) - })) + }) + ) return characters } @@ -172,7 +174,6 @@ class Leaf extends Record(DEFAULTS) { toJS() { return this.toJSON() } - } /** diff --git a/packages/slate/src/models/mark.js b/packages/slate/src/models/mark.js index 5f6792597..c4f30dc40 100644 --- a/packages/slate/src/models/mark.js +++ b/packages/slate/src/models/mark.js @@ -1,4 +1,3 @@ - import isPlainObject from 'is-plain-object' import logger from 'slate-dev-logger' import { Map, Record, Set } from 'immutable' @@ -25,7 +24,6 @@ const DEFAULTS = { */ class Mark extends Record(DEFAULTS) { - /** * Create a new `Mark` with `attrs`. * @@ -46,7 +44,9 @@ class Mark extends Record(DEFAULTS) { return Mark.fromJSON(attrs) } - throw new Error(`\`Mark.create\` only accepts objects, strings or marks, but you passed it: ${attrs}`) + throw new Error( + `\`Mark.create\` only accepts objects, strings or marks, but you passed it: ${attrs}` + ) } /** @@ -66,7 +66,9 @@ class Mark extends Record(DEFAULTS) { return new Set() } - throw new Error(`\`Mark.createSet\` only accepts sets, arrays or null, but you passed it: ${elements}`) + throw new Error( + `\`Mark.createSet\` only accepts sets, arrays or null, but you passed it: ${elements}` + ) } /** @@ -95,7 +97,9 @@ class Mark extends Record(DEFAULTS) { return props } - throw new Error(`\`Mark.createProperties\` only accepts objects, strings or marks, but you passed it: ${attrs}`) + throw new Error( + `\`Mark.createProperties\` only accepts objects, strings or marks, but you passed it: ${attrs}` + ) } /** @@ -106,10 +110,7 @@ class Mark extends Record(DEFAULTS) { */ static fromJSON(object) { - const { - data = {}, - type, - } = object + const { data = {}, type } = object if (typeof type != 'string') { throw new Error('`Mark.fromJS` requires a `type` string.') @@ -160,7 +161,10 @@ class Mark extends Record(DEFAULTS) { } get kind() { - logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.') + logger.deprecate( + 'slate@0.32.0', + 'The `kind` property of Slate objects has been renamed to `object`.' + ) return this.object } @@ -198,7 +202,6 @@ class Mark extends Record(DEFAULTS) { toJS() { return this.toJSON() } - } /** @@ -211,9 +214,7 @@ Mark.prototype[MODEL_TYPES.MARK] = true * Memoize read methods. */ -memoize(Mark.prototype, [ - 'getComponent', -], { +memoize(Mark.prototype, ['getComponent'], { takesArguments: true, }) diff --git a/packages/slate/src/models/node.js b/packages/slate/src/models/node.js index 9bcba188e..7e8c564c2 100644 --- a/packages/slate/src/models/node.js +++ b/packages/slate/src/models/node.js @@ -1,4 +1,3 @@ - import direction from 'direction' import isPlainObject from 'is-plain-object' import logger from 'slate-dev-logger' @@ -24,7 +23,6 @@ import memoize from '../utils/memoize' */ class Node { - /** * Create a new `Node` with `attrs`. * @@ -41,22 +39,31 @@ class Node { let { object } = attrs if (!object && attrs.kind) { - logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.') + logger.deprecate( + 'slate@0.32.0', + 'The `kind` property of Slate objects has been renamed to `object`.' + ) object = attrs.kind } switch (object) { - case 'block': return Block.create(attrs) - case 'document': return Document.create(attrs) - case 'inline': return Inline.create(attrs) - case 'text': return Text.create(attrs) + case 'block': + return Block.create(attrs) + case 'document': + return Document.create(attrs) + case 'inline': + return Inline.create(attrs) + case 'text': + return Text.create(attrs) default: { throw new Error('`Node.create` requires a `object` string.') } } } - throw new Error(`\`Node.create\` only accepts objects or nodes but you passed it: ${attrs}`) + throw new Error( + `\`Node.create\` only accepts objects or nodes but you passed it: ${attrs}` + ) } /** @@ -72,7 +79,9 @@ class Node { return list } - throw new Error(`\`Node.createList\` only accepts lists or arrays, but you passed it: ${elements}`) + throw new Error( + `\`Node.createList\` only accepts lists or arrays, but you passed it: ${elements}` + ) } /** @@ -103,7 +112,9 @@ class Node { return props } - throw new Error(`\`Node.createProperties\` only accepts objects, strings, blocks or inlines, but you passed it: ${attrs}`) + throw new Error( + `\`Node.createProperties\` only accepts objects, strings, blocks or inlines, but you passed it: ${attrs}` + ) } /** @@ -117,17 +128,26 @@ class Node { let { object } = value if (!object && value.kind) { - logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.') + logger.deprecate( + 'slate@0.32.0', + 'The `kind` property of Slate objects has been renamed to `object`.' + ) object = value.kind } switch (object) { - case 'block': return Block.fromJSON(value) - case 'document': return Document.fromJSON(value) - case 'inline': return Inline.fromJSON(value) - case 'text': return Text.fromJSON(value) + case 'block': + return Block.fromJSON(value) + case 'document': + return Document.fromJSON(value) + case 'inline': + return Inline.fromJSON(value) + case 'text': + return Text.fromJSON(value) default: { - throw new Error(`\`Node.fromJSON\` requires an \`object\` of either 'block', 'document', 'inline' or 'text', but you passed: ${value}`) + throw new Error( + `\`Node.fromJSON\` requires an \`object\` of either 'block', 'document', 'inline' or 'text', but you passed: ${value}` + ) } } } @@ -333,7 +353,7 @@ class Node { if (this.hasChild(key)) return List([this]) let ancestors - this.nodes.find((node) => { + this.nodes.find(node => { if (node.object == 'text') return false ancestors = node.getAncestors(key) return ancestors @@ -490,15 +510,13 @@ class Node { range = range.normalize(this) if (range.isUnset) return [] - return this - .getTextsAtRange(range) - .reduce((arr, text) => { - const chars = text.characters - .filter((char, i) => isIndexInRange(i, text, range)) - .toArray() + return this.getTextsAtRange(range).reduce((arr, text) => { + const chars = text.characters + .filter((char, i) => isIndexInRange(i, text, range)) + .toArray() - return arr.concat(chars) - }, []) + return arr.concat(chars) + }, []) } /** @@ -621,9 +639,7 @@ class Node { getDepth(key, startAt = 1) { this.assertDescendant(key) if (this.hasChild(key)) return startAt - return this - .getFurthestAncestor(key) - .getDepth(key, startAt + 1) + return this.getFurthestAncestor(key).getDepth(key, startAt + 1) } /** @@ -635,10 +651,20 @@ class Node { getDescendant(key) { key = assertKey(key) - // Use the cache by getAncestors - const ancestors = this.getAncestors(key) - if (!ancestors || ancestors.size === 0) return null - return ancestors.last().getChild(key) + let descendantFound = null + + const found = this.nodes.find(node => { + if (node.key === key) { + return node + } else if (node.object !== 'text') { + descendantFound = node.getDescendant(key) + return descendantFound + } else { + return false + } + }) + + return descendantFound || found } /** @@ -669,7 +695,7 @@ class Node { getFirstText() { let descendantFound = null - const found = this.nodes.find((node) => { + const found = this.nodes.find(node => { if (node.object == 'text') return true descendantFound = node.getFirstText() return descendantFound @@ -701,11 +727,10 @@ class Node { let previous let parent - while (parent = node.getParent(child.key)) { + while ((parent = node.getParent(child.key))) { const index = parent.nodes.indexOf(child) - const position = child.object == 'text' - ? startOffset - : child.nodes.indexOf(previous) + const position = + child.object == 'text' ? startOffset : child.nodes.indexOf(previous) parent = parent.splitNode(index, position) node = node.updateNode(parent) @@ -715,11 +740,12 @@ class Node { child = startKey == endKey ? node.getNextText(startKey) : endText - while (parent = node.getParent(child.key)) { + while ((parent = node.getParent(child.key))) { const index = parent.nodes.indexOf(child) - const position = child.object == 'text' - ? startKey == endKey ? endOffset - startOffset : endOffset - : child.nodes.indexOf(previous) + const position = + child.object == 'text' + ? startKey == endKey ? endOffset - startOffset : endOffset + : child.nodes.indexOf(previous) parent = parent.splitNode(index, position) node = node.updateNode(parent) @@ -728,10 +754,15 @@ class Node { } // Get the start and end nodes. - const startNode = node.getNextSibling(node.getFurthestAncestor(startKey).key) - const endNode = startKey == endKey - ? node.getNextSibling(node.getNextSibling(node.getFurthestAncestor(endKey).key).key) - : node.getNextSibling(node.getFurthestAncestor(endKey).key) + const startNode = node.getNextSibling( + node.getFurthestAncestor(startKey).key + ) + const endNode = + startKey == endKey + ? node.getNextSibling( + node.getNextSibling(node.getFurthestAncestor(endKey).key).key + ) + : node.getNextSibling(node.getFurthestAncestor(endKey).key) // Get children range of nodes from start to end nodes const startIndex = node.nodes.indexOf(startNode) @@ -792,7 +823,7 @@ class Node { getFurthestAncestor(key) { key = assertKey(key) - return this.nodes.find((node) => { + return this.nodes.find(node => { if (node.key == key) return true if (node.object == 'text') return false return node.hasDescendant(key) @@ -814,13 +845,16 @@ class Node { throw new Error(`Could not find a descendant node with key "${key}".`) } - return ancestors - // Skip this node... - .skipLast() - // Take parents until there are more than one child... - .reverse().takeUntil(p => p.nodes.size > 1) - // And pick the highest. - .last() + return ( + ancestors + // Skip this node... + .skipLast() + // Take parents until there are more than one child... + .reverse() + .takeUntil(p => p.nodes.size > 1) + // And pick the highest. + .last() + ) } /** @@ -843,7 +877,7 @@ class Node { getInlinesAsArray() { let array = [] - this.nodes.forEach((child) => { + this.nodes.forEach(child => { if (child.object == 'text') return if (child.isLeafInline()) { array.push(child) @@ -879,8 +913,7 @@ class Node { range = range.normalize(this) if (range.isUnset) return [] - return this - .getTextsAtRangeAsArray(range) + return this.getTextsAtRangeAsArray(range) .map(text => this.getClosestInline(text.key)) .filter(exists => exists) } @@ -926,7 +959,7 @@ class Node { getKeysAsArray() { const keys = [] - this.forEachDescendant((desc) => { + this.forEachDescendant(desc => { keys.push(desc.key) }) @@ -953,7 +986,7 @@ class Node { getLastText() { let descendantFound = null - const found = this.nodes.findLast((node) => { + const found = this.nodes.findLast(node => { if (node.object == 'text') return true descendantFound = node.getLastText() return descendantFound @@ -1056,12 +1089,10 @@ class Node { if (range.isUnset) return [] if (range.isCollapsed) return this.getMarksAtCollaspsedRangeAsArray(range) - return this - .getCharactersAtRange(range) - .reduce((memo, char) => { - char.marks.toArray().forEach(c => memo.push(c)) - return memo - }, []) + return this.getCharactersAtRange(range).reduce((memo, char) => { + char.marks.toArray().forEach(c => memo.push(c)) + return memo + }, []) } /** @@ -1124,7 +1155,7 @@ class Node { let memo = first.marks - chars.slice(1).forEach((char) => { + chars.slice(1).forEach(char => { memo = memo.intersect(char.marks) return memo.size != 0 }) @@ -1206,8 +1237,7 @@ class Node { key = assertKey(key) const parent = this.getParent(key) - const after = parent.nodes - .skipUntil(child => child.key == key) + const after = parent.nodes.skipUntil(child => child.key == key) if (after.size == 0) { throw new Error(`Could not find a child node with key "${key}".`) @@ -1269,9 +1299,7 @@ class Node { .reduce((memo, n) => memo + n.text.length, 0) // Recurse if need be. - return this.hasChild(key) - ? offset - : offset + child.getOffset(key) + return this.hasChild(key) ? offset : offset + child.getOffset(key) } /** @@ -1308,7 +1336,7 @@ class Node { let node = null - this.nodes.find((child) => { + this.nodes.find(child => { if (child.object == 'text') { return false } else { @@ -1332,7 +1360,7 @@ class Node { const ancestors = this.getAncestors(key) const path = [] - ancestors.reverse().forEach((ancestor) => { + ancestors.reverse().forEach(ancestor => { const index = ancestor.nodes.indexOf(child) path.unshift(index) child = ancestor @@ -1421,8 +1449,7 @@ class Node { getPreviousSibling(key) { key = assertKey(key) const parent = this.getParent(key) - const before = parent.nodes - .takeUntil(child => child.key == key) + const before = parent.nodes.takeUntil(child => child.key == key) if (before.size == parent.nodes.size) { throw new Error(`Could not find a child node with key "${key}".`) @@ -1525,12 +1552,10 @@ class Node { let length = 0 - return this - .getTexts() - .find((node, i, nodes) => { - length += node.text.length - return length > offset - }) + return this.getTexts().find((node, i, nodes) => { + length += node.text.length + return length > offset + }) } /** @@ -1564,7 +1589,7 @@ class Node { getTextsAsArray() { let array = [] - this.nodes.forEach((node) => { + this.nodes.forEach(node => { if (node.object == 'text') { array.push(node) } else { @@ -1672,10 +1697,8 @@ class Node { } if (node.object != 'text') { - node = node.mapDescendants((desc) => { - return keys.contains(desc.key) - ? desc.regenerateKey() - : desc + node = node.mapDescendants(desc => { + return keys.contains(desc.key) ? desc.regenerateKey() : desc }) } @@ -1718,7 +1741,7 @@ class Node { const texts = node.getTextsAtRange(range) let memo = false - texts.forEach((text) => { + texts.forEach(text => { if (node.hasDescendant(text.key)) memo = true return memo }) @@ -1733,10 +1756,7 @@ class Node { */ isLeafBlock() { - return ( - this.object == 'block' && - this.nodes.every(n => n.object != 'block') - ) + return this.object == 'block' && this.nodes.every(n => n.object != 'block') } /** @@ -1747,8 +1767,7 @@ class Node { isLeafInline() { return ( - this.object == 'inline' && - this.nodes.every(n => n.object != 'inline') + this.object == 'inline' && this.nodes.every(n => n.object != 'inline') ) } @@ -1768,17 +1787,19 @@ class Node { const two = node.nodes.get(index) if (one.object != two.object) { - throw new Error(`Tried to merge two nodes of different objects: "${one.object}" and "${two.object}".`) + throw new Error( + `Tried to merge two nodes of different objects: "${one.object}" and "${ + two.object + }".` + ) } // If the nodes are text nodes, concatenate their characters together. if (one.object == 'text') { const characters = one.characters.concat(two.characters) one = one.set('characters', characters) - } - - // Otherwise, concatenate their child nodes together. - else { + } else { + // Otherwise, concatenate their child nodes together. const nodes = one.nodes.concat(two.nodes) one = one.set('nodes', nodes) } @@ -1855,7 +1876,8 @@ class Node { let node = this let parent = node.getParent(key) - if (!parent) throw new Error(`Could not find a descendant node with key "${key}".`) + if (!parent) + throw new Error(`Could not find a descendant node with key "${key}".`) const index = parent.nodes.findIndex(n => n.key === key) const nodes = parent.nodes.splice(index, 1) @@ -1898,11 +1920,9 @@ class Node { const afters = child.characters.skip(position) one = child.set('characters', befores) two = child.set('characters', afters).regenerateKey() - } - - // Otherwise, if the child is not a text node, the `position` refers to the - // index at which to split its children. - else { + } else { + // Otherwise, if the child is not a text node, the `position` refers to the + // index at which to split its children. const befores = child.nodes.take(position) const afters = child.nodes.skip(position) one = child.set('nodes', befores) @@ -1931,7 +1951,7 @@ class Node { let child = this.assertDescendant(node.key) const ancestors = this.getAncestors(node.key) - ancestors.reverse().forEach((parent) => { + ancestors.reverse().forEach(parent => { let { nodes } = parent const index = nodes.indexOf(child) child = parent @@ -1953,7 +1973,6 @@ class Node { validate(schema) { return schema.validateNode(this) } - } /** @@ -1965,98 +1984,108 @@ class Node { function assertKey(arg) { if (typeof arg == 'string') return arg - throw new Error(`Invalid \`key\` argument! It must be a key string, but you passed: ${arg}`) + throw new Error( + `Invalid \`key\` argument! It must be a key string, but you passed: ${arg}` + ) } /** * Memoize read methods. */ -memoize(Node.prototype, [ - 'getBlocks', - 'getBlocksAsArray', - 'getCharacters', - 'getCharactersAsArray', - 'getFirstText', - 'getInlines', - 'getInlinesAsArray', - 'getKeys', - 'getKeysAsArray', - 'getLastText', - 'getMarks', - 'getOrderedMarks', - 'getMarksAsArray', - 'getText', - 'getTextDirection', - 'getTexts', - 'getTextsAsArray', - 'isLeafBlock', - 'isLeafInline', -], { - takesArguments: false -}) +memoize( + Node.prototype, + [ + 'getBlocks', + 'getBlocksAsArray', + 'getCharacters', + 'getCharactersAsArray', + 'getFirstText', + 'getInlines', + 'getInlinesAsArray', + 'getKeys', + 'getKeysAsArray', + 'getLastText', + 'getMarks', + 'getOrderedMarks', + 'getMarksAsArray', + 'getText', + 'getTextDirection', + 'getTexts', + 'getTextsAsArray', + 'isLeafBlock', + 'isLeafInline', + ], + { + takesArguments: false, + } +) -memoize(Node.prototype, [ - 'areDescendantsSorted', - 'getActiveMarksAtRange', - 'getActiveMarksAtRangeAsArray', - 'getAncestors', - 'getBlocksAtRange', - 'getBlocksAtRangeAsArray', - 'getBlocksByType', - 'getBlocksByTypeAsArray', - 'getCharactersAtRange', - 'getCharactersAtRangeAsArray', - 'getChild', - 'getClosestBlock', - 'getClosestInline', - 'getClosestVoid', - 'getCommonAncestor', - 'getDecorations', - 'getDepth', - 'getDescendant', - 'getDescendantAtPath', - 'getFragmentAtRange', - 'getFurthestBlock', - 'getFurthestInline', - 'getFurthestAncestor', - 'getFurthestOnlyChildAncestor', - 'getInlinesAtRange', - 'getInlinesAtRangeAsArray', - 'getInlinesByType', - 'getInlinesByTypeAsArray', - 'getMarksAtRange', - 'getInsertMarksAtRange', - 'getOrderedMarksAtRange', - 'getMarksAtRangeAsArray', - 'getInsertMarksAtRangeAsArray', - 'getMarksByType', - 'getOrderedMarksByType', - 'getMarksByTypeAsArray', - 'getNextBlock', - 'getNextSibling', - 'getNextText', - 'getNode', - 'getNodeAtPath', - 'getOffset', - 'getOffsetAtRange', - 'getParent', - 'getPath', - 'getPlaceholder', - 'getPreviousBlock', - 'getPreviousSibling', - 'getPreviousText', - 'getTextAtOffset', - 'getTextsAtRange', - 'getTextsAtRangeAsArray', - 'hasChild', - 'hasDescendant', - 'hasNode', - 'hasVoidParent', - 'validate', -], { - takesArguments: true -}) +memoize( + Node.prototype, + [ + 'areDescendantsSorted', + 'getActiveMarksAtRange', + 'getActiveMarksAtRangeAsArray', + 'getAncestors', + 'getBlocksAtRange', + 'getBlocksAtRangeAsArray', + 'getBlocksByType', + 'getBlocksByTypeAsArray', + 'getCharactersAtRange', + 'getCharactersAtRangeAsArray', + 'getChild', + 'getClosestBlock', + 'getClosestInline', + 'getClosestVoid', + 'getCommonAncestor', + 'getDecorations', + 'getDepth', + 'getDescendant', + 'getDescendantAtPath', + 'getFragmentAtRange', + 'getFurthestBlock', + 'getFurthestInline', + 'getFurthestAncestor', + 'getFurthestOnlyChildAncestor', + 'getInlinesAtRange', + 'getInlinesAtRangeAsArray', + 'getInlinesByType', + 'getInlinesByTypeAsArray', + 'getMarksAtRange', + 'getInsertMarksAtRange', + 'getOrderedMarksAtRange', + 'getMarksAtRangeAsArray', + 'getInsertMarksAtRangeAsArray', + 'getMarksByType', + 'getOrderedMarksByType', + 'getMarksByTypeAsArray', + 'getNextBlock', + 'getNextSibling', + 'getNextText', + 'getNode', + 'getNodeAtPath', + 'getOffset', + 'getOffsetAtRange', + 'getParent', + 'getPath', + 'getPlaceholder', + 'getPreviousBlock', + 'getPreviousSibling', + 'getPreviousText', + 'getTextAtOffset', + 'getTextsAtRange', + 'getTextsAtRangeAsArray', + 'hasChild', + 'hasDescendant', + 'hasNode', + 'hasVoidParent', + 'validate', + ], + { + takesArguments: true, + } +) /** * Export. diff --git a/packages/slate/src/models/operation.js b/packages/slate/src/models/operation.js index 2b10a4d1c..50807f0bb 100644 --- a/packages/slate/src/models/operation.js +++ b/packages/slate/src/models/operation.js @@ -1,4 +1,3 @@ - import isPlainObject from 'is-plain-object' import logger from 'slate-dev-logger' import { List, Record } from 'immutable' @@ -40,7 +39,6 @@ const DEFAULTS = { */ class Operation extends Record(DEFAULTS) { - /** * Create a new `Operation` with `attrs`. * @@ -57,7 +55,9 @@ class Operation extends Record(DEFAULTS) { return Operation.fromJSON(attrs) } - throw new Error(`\`Operation.create\` only accepts objects or operations, but you passed it: ${attrs}`) + throw new Error( + `\`Operation.create\` only accepts objects or operations, but you passed it: ${attrs}` + ) } /** @@ -73,7 +73,9 @@ class Operation extends Record(DEFAULTS) { return list } - throw new Error(`\`Operation.createList\` only accepts arrays or lists, but you passed it: ${elements}`) + throw new Error( + `\`Operation.createList\` only accepts arrays or lists, but you passed it: ${elements}` + ) } /** @@ -93,7 +95,9 @@ class Operation extends Record(DEFAULTS) { const attrs = { type } if (!ATTRIBUTES) { - throw new Error(`\`Operation.fromJSON\` was passed an unrecognized operation type: "${type}"`) + throw new Error( + `\`Operation.fromJSON\` was passed an unrecognized operation type: "${type}"` + ) } for (const key of ATTRIBUTES) { @@ -107,7 +111,9 @@ class Operation extends Record(DEFAULTS) { if (key == 'value') continue if (key == 'node' && type != 'insert_node') continue - throw new Error(`\`Operation.fromJSON\` was passed a "${type}" operation without the required "${key}" attribute.`) + throw new Error( + `\`Operation.fromJSON\` was passed a "${type}" operation without the required "${key}" attribute.` + ) } if (key == 'mark') { @@ -147,15 +153,13 @@ class Operation extends Record(DEFAULTS) { v = Range.createProperties(rest) if (anchorKey !== undefined) { - v.anchorPath = anchorKey === null - ? null - : value.document.getPath(anchorKey) + v.anchorPath = + anchorKey === null ? null : value.document.getPath(anchorKey) } if (focusKey !== undefined) { - v.focusPath = focusKey === null - ? null - : value.document.getPath(focusKey) + v.focusPath = + focusKey === null ? null : value.document.getPath(focusKey) } } @@ -213,7 +217,10 @@ class Operation extends Record(DEFAULTS) { } get kind() { - logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.') + logger.deprecate( + 'slate@0.32.0', + 'The `kind` property of Slate objects has been renamed to `object`.' + ) return this.object } @@ -273,7 +280,8 @@ class Operation extends Record(DEFAULTS) { if ('focusPath' in value) v.focusPath = value.focusPath if ('isBackward' in value) v.isBackward = value.isBackward if ('isFocused' in value) v.isFocused = value.isFocused - if ('marks' in value) v.marks = value.marks == null ? null : value.marks.toJSON() + if ('marks' in value) + v.marks = value.marks == null ? null : value.marks.toJSON() value = v } @@ -305,7 +313,6 @@ class Operation extends Record(DEFAULTS) { toJS(options) { return this.toJSON(options) } - } /** diff --git a/packages/slate/src/models/range.js b/packages/slate/src/models/range.js index 66ea2e957..96c379a0f 100644 --- a/packages/slate/src/models/range.js +++ b/packages/slate/src/models/range.js @@ -1,4 +1,3 @@ - import isPlainObject from 'is-plain-object' import logger from 'slate-dev-logger' import { List, Record, Set } from 'immutable' @@ -29,7 +28,6 @@ const DEFAULTS = { */ class Range extends Record(DEFAULTS) { - /** * Create a new `Range` with `attrs`. * @@ -46,7 +44,9 @@ class Range extends Record(DEFAULTS) { return Range.fromJSON(attrs) } - throw new Error(`\`Range.create\` only accepts objects or ranges, but you passed it: ${attrs}`) + throw new Error( + `\`Range.create\` only accepts objects or ranges, but you passed it: ${attrs}` + ) } /** @@ -62,7 +62,9 @@ class Range extends Record(DEFAULTS) { return list } - throw new Error(`\`Range.createList\` only accepts arrays or lists, but you passed it: ${elements}`) + throw new Error( + `\`Range.createList\` only accepts arrays or lists, but you passed it: ${elements}` + ) } /** @@ -95,11 +97,14 @@ class Range extends Record(DEFAULTS) { if ('focusPath' in attrs) props.focusPath = attrs.focusPath if ('isBackward' in attrs) props.isBackward = attrs.isBackward if ('isFocused' in attrs) props.isFocused = attrs.isFocused - if ('marks' in attrs) props.marks = attrs.marks == null ? null : Mark.createSet(attrs.marks) + if ('marks' in attrs) + props.marks = attrs.marks == null ? null : Mark.createSet(attrs.marks) return props } - throw new Error(`\`Range.createProperties\` only accepts objects or ranges, but you passed it: ${attrs}`) + throw new Error( + `\`Range.createProperties\` only accepts objects or ranges, but you passed it: ${attrs}` + ) } /** @@ -161,7 +166,10 @@ class Range extends Record(DEFAULTS) { } get kind() { - logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.') + logger.deprecate( + 'slate@0.32.0', + 'The `kind` property of Slate objects has been renamed to `object`.' + ) return this.object } @@ -183,8 +191,7 @@ class Range extends Record(DEFAULTS) { get isCollapsed() { return ( - this.anchorKey == this.focusKey && - this.anchorOffset == this.focusOffset + this.anchorKey == this.focusKey && this.anchorOffset == this.focusOffset ) } @@ -411,7 +418,7 @@ class Range extends Record(DEFAULTS) { focus() { return this.merge({ - isFocused: true + isFocused: true, }) } @@ -423,7 +430,7 @@ class Range extends Record(DEFAULTS) { blur() { return this.merge({ - isFocused: false + isFocused: false, }) } @@ -440,7 +447,7 @@ class Range extends Record(DEFAULTS) { focusKey: null, focusOffset: 0, isFocused: false, - isBackward: false + isBackward: false, }) } @@ -472,9 +479,8 @@ class Range extends Record(DEFAULTS) { const anchorOffset = this.anchorOffset + n return this.merge({ anchorOffset, - isBackward: anchorKey == focusKey - ? anchorOffset > focusOffset - : isBackward + isBackward: + anchorKey == focusKey ? anchorOffset > focusOffset : isBackward, }) } @@ -490,9 +496,8 @@ class Range extends Record(DEFAULTS) { const focusOffset = this.focusOffset + n return this.merge({ focusOffset, - isBackward: focusKey == anchorKey - ? anchorOffset > focusOffset - : isBackward + isBackward: + focusKey == anchorKey ? anchorOffset > focusOffset : isBackward, }) } @@ -509,9 +514,10 @@ class Range extends Record(DEFAULTS) { return this.merge({ anchorKey: key, anchorOffset: offset, - isBackward: key == focusKey - ? offset > focusOffset - : key == anchorKey ? isBackward : null + isBackward: + key == focusKey + ? offset > focusOffset + : key == anchorKey ? isBackward : null, }) } @@ -528,9 +534,10 @@ class Range extends Record(DEFAULTS) { return this.merge({ focusKey: key, focusOffset: offset, - isBackward: key == anchorKey - ? anchorOffset > offset - : key == focusKey ? isBackward : null + isBackward: + key == anchorKey + ? anchorOffset > offset + : key == focusKey ? isBackward : null, }) } @@ -544,9 +551,10 @@ class Range extends Record(DEFAULTS) { moveAnchorOffsetTo(anchorOffset) { return this.merge({ anchorOffset, - isBackward: this.anchorKey == this.focusKey - ? anchorOffset > this.focusOffset - : this.isBackward + isBackward: + this.anchorKey == this.focusKey + ? anchorOffset > this.focusOffset + : this.isBackward, }) } @@ -560,9 +568,10 @@ class Range extends Record(DEFAULTS) { moveFocusOffsetTo(focusOffset) { return this.merge({ focusOffset, - isBackward: this.anchorKey == this.focusKey - ? this.anchorOffset > focusOffset - : this.isBackward + isBackward: + this.anchorKey == this.focusKey + ? this.anchorOffset > focusOffset + : this.isBackward, }) } @@ -575,9 +584,7 @@ class Range extends Record(DEFAULTS) { */ moveOffsetsTo(anchorOffset, focusOffset = anchorOffset) { - return this - .moveAnchorOffsetTo(anchorOffset) - .moveFocusOffsetTo(focusOffset) + return this.moveAnchorOffsetTo(anchorOffset).moveFocusOffsetTo(focusOffset) } /** @@ -658,9 +665,7 @@ class Range extends Record(DEFAULTS) { moveToRangeOf(start, end = start) { const range = this.isBackward ? this.flip() : this - return range - .moveAnchorToStartOf(start) - .moveFocusToEndOf(end) + return range.moveAnchorToStartOf(start).moveFocusToEndOf(end) } /** @@ -678,7 +683,9 @@ class Range extends Record(DEFAULTS) { const anchorOffsetType = typeof anchorOffset const focusOffsetType = typeof focusOffset if (anchorOffsetType != 'number' || focusOffsetType != 'number') { - logger.warn(`The range offsets should be numbers, but they were of type "${anchorOffsetType}" and "${focusOffsetType}".`) + logger.warn( + `The range offsets should be numbers, but they were of type "${anchorOffsetType}" and "${focusOffsetType}".` + ) } // If the range is unset, make sure it is properly zeroed out. @@ -698,7 +705,10 @@ class Range extends Record(DEFAULTS) { // If the range is malformed, warn and zero it out. if (!anchorNode || !focusNode) { - logger.warn('The range was invalid and was reset. The range in question was:', range) + logger.warn( + 'The range was invalid and was reset. The range in question was:', + range + ) const first = node.getFirstText() return range.merge({ anchorKey: first ? first.key : null, @@ -711,7 +721,10 @@ class Range extends Record(DEFAULTS) { // If the anchor node isn't a text node, match it to one. if (anchorNode.object != 'text') { - logger.warn('The range anchor was set to a Node that is not a Text node. This should not happen and can degrade performance. The node in question was:', anchorNode) + logger.warn( + 'The range anchor was set to a Node that is not a Text node. This should not happen and can degrade performance. The node in question was:', + anchorNode + ) const anchorText = anchorNode.getTextAtOffset(anchorOffset) const offset = anchorNode.getOffset(anchorText.key) anchorOffset = anchorOffset - offset @@ -720,7 +733,10 @@ class Range extends Record(DEFAULTS) { // If the focus node isn't a text node, match it to one. if (focusNode.object != 'text') { - logger.warn('The range focus was set to a Node that is not a Text node. This should not happen and can degrade performance. The node in question was:', focusNode) + logger.warn( + 'The range focus was set to a Node that is not a Text node. This should not happen and can degrade performance. The node in question was:', + focusNode + ) const focusText = focusNode.getTextAtOffset(focusOffset) const offset = focusNode.getOffset(focusText.key) focusOffset = focusOffset - offset @@ -742,7 +758,7 @@ class Range extends Record(DEFAULTS) { anchorOffset, focusKey: focusNode.key, focusOffset, - isBackward + isBackward, }) } @@ -761,7 +777,8 @@ class Range extends Record(DEFAULTS) { focusOffset: this.focusOffset, isBackward: this.isBackward, isFocused: this.isFocused, - marks: this.marks == null ? null : this.marks.toArray().map(m => m.toJSON()), + marks: + this.marks == null ? null : this.marks.toArray().map(m => m.toJSON()), } return object @@ -774,7 +791,6 @@ class Range extends Record(DEFAULTS) { toJS() { return this.toJSON() } - } /** @@ -794,11 +810,9 @@ const MOVE_METHODS = [ ['move', 'ToEndOf'], ] -MOVE_METHODS.forEach(([ p, s ]) => { - Range.prototype[`${p}${s}`] = function (...args) { - return this - [`${p}Anchor${s}`](...args) - [`${p}Focus${s}`](...args) +MOVE_METHODS.forEach(([p, s]) => { + Range.prototype[`${p}${s}`] = function(...args) { + return this[`${p}Anchor${s}`](...args)[`${p}Focus${s}`](...args) } }) @@ -818,24 +832,20 @@ const EDGE_METHODS = [ ['move', 'OffsetTo'], ] -EDGE_METHODS.forEach(([ p, s, hasEdge ]) => { +EDGE_METHODS.forEach(([p, s, hasEdge]) => { const anchor = `${p}Anchor${s}` const focus = `${p}Focus${s}` - Range.prototype[`${p}Start${s}`] = function (...args) { - return this.isBackward - ? this[focus](...args) - : this[anchor](...args) + Range.prototype[`${p}Start${s}`] = function(...args) { + return this.isBackward ? this[focus](...args) : this[anchor](...args) } - Range.prototype[`${p}End${s}`] = function (...args) { - return this.isBackward - ? this[anchor](...args) - : this[focus](...args) + Range.prototype[`${p}End${s}`] = function(...args) { + return this.isBackward ? this[anchor](...args) : this[focus](...args) } if (hasEdge) { - Range.prototype[`${p}Edge${s}`] = function (...args) { + Range.prototype[`${p}Edge${s}`] = function(...args) { return this[anchor](...args) || this[focus](...args) } } @@ -859,8 +869,8 @@ const ALIAS_METHODS = [ ['extendToEndOf', 'moveFocusToEndOf'], ] -ALIAS_METHODS.forEach(([ alias, method ]) => { - Range.prototype[alias] = function (...args) { +ALIAS_METHODS.forEach(([alias, method]) => { + Range.prototype[alias] = function(...args) { return this[method](...args) } }) diff --git a/packages/slate/src/models/schema.js b/packages/slate/src/models/schema.js index 9085f9902..8158ff5d9 100644 --- a/packages/slate/src/models/schema.js +++ b/packages/slate/src/models/schema.js @@ -1,4 +1,3 @@ - import Debug from 'debug' import isPlainObject from 'is-plain-object' import logger from 'slate-dev-logger' @@ -55,7 +54,6 @@ const DEFAULTS = { */ class Schema extends Record(DEFAULTS) { - /** * Create a new `Schema` with `attrs`. * @@ -72,7 +70,9 @@ class Schema extends Record(DEFAULTS) { return Schema.fromJSON(attrs) } - throw new Error(`\`Schema.create\` only accepts objects or schemas, but you passed it: ${attrs}`) + throw new Error( + `\`Schema.create\` only accepts objects or schemas, but you passed it: ${attrs}` + ) } /** @@ -90,11 +90,15 @@ class Schema extends Record(DEFAULTS) { let { plugins } = object if (object.rules) { - throw new Error('Schemas in Slate have changed! They are no longer accept a `rules` property.') + throw new Error( + 'Schemas in Slate have changed! They are no longer accept a `rules` property.' + ) } if (object.nodes) { - throw new Error('Schemas in Slate have changed! They are no longer accept a `nodes` property.') + throw new Error( + 'Schemas in Slate have changed! They are no longer accept a `nodes` property.' + ) } if (!plugins) { @@ -102,7 +106,7 @@ class Schema extends Record(DEFAULTS) { } const schema = resolveSchema(plugins) - const stack = Stack.create({ plugins: [ ...CORE_SCHEMA_RULES, ...plugins ] }) + const stack = Stack.create({ plugins: [...CORE_SCHEMA_RULES, ...plugins] }) const ret = new Schema({ ...schema, stack }) return ret } @@ -135,7 +139,10 @@ class Schema extends Record(DEFAULTS) { } get kind() { - logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.') + logger.deprecate( + 'slate@0.32.0', + 'The `kind` property of Slate objects has been renamed to `object`.' + ) return this.object } @@ -148,9 +155,12 @@ class Schema extends Record(DEFAULTS) { getRule(object) { switch (object.object) { - case 'document': return this.document - case 'block': return this.blocks[object.type] - case 'inline': return this.inlines[object.type] + case 'document': + return this.document + case 'block': + return this.blocks[object.type] + case 'inline': + return this.inlines[object.type] } } @@ -188,7 +198,7 @@ class Schema extends Record(DEFAULTS) { */ fail(violation, context) { - return (change) => { + return change => { debug(`normalizing`, { violation, context }) const { rule } = context const { size } = change.operations @@ -216,7 +226,9 @@ class Schema extends Record(DEFAULTS) { case LAST_CHILD_OBJECT_INVALID: case LAST_CHILD_TYPE_INVALID: { const { child, node } = context - return child.object == 'text' && node.object == 'block' && node.nodes.size == 1 + return child.object == 'text' && + node.object == 'block' && + node.nodes.size == 1 ? change.removeNodeByKey(node.key) : change.removeNodeByKey(child.key) } @@ -245,7 +257,9 @@ class Schema extends Record(DEFAULTS) { case NODE_MARK_INVALID: { const { node, mark } = context - return node.getTexts().forEach(t => change.removeMarkByKey(t.key, 0, t.text.length, mark)) + return node + .getTexts() + .forEach(t => change.removeMarkByKey(t.key, 0, t.text.length, mark)) } } } @@ -365,15 +379,30 @@ class Schema extends Record(DEFAULTS) { } while (nextChild()) { - if (parents != null && child.object != 'text' && child.type in parents) { + if ( + parents != null && + child.object != 'text' && + child.type in parents + ) { const r = parents[child.type] - if (r.parent.objects != null && !r.parent.objects.includes(node.object)) { - return this.fail(PARENT_OBJECT_INVALID, { node: child, parent: node, rule: r }) + if ( + r.parent.objects != null && + !r.parent.objects.includes(node.object) + ) { + return this.fail(PARENT_OBJECT_INVALID, { + node: child, + parent: node, + rule: r, + }) } if (r.parent.types != null && !r.parent.types.includes(node.type)) { - return this.fail(PARENT_TYPE_INVALID, { node: child, parent: node, rule: r }) + return this.fail(PARENT_TYPE_INVALID, { + node: child, + parent: node, + rule: r, + }) } } @@ -436,7 +465,6 @@ class Schema extends Record(DEFAULTS) { toJS() { return this.toJSON() } - } /** @@ -453,34 +481,41 @@ function resolveSchema(plugins = []) { inlines: {}, } - plugins.slice().reverse().forEach((plugin) => { - if (!plugin.schema) return + plugins + .slice() + .reverse() + .forEach(plugin => { + if (!plugin.schema) return - if (plugin.schema.rules) { - throw new Error('Schemas in Slate have changed! They are no longer accept a `rules` property.') - } + if (plugin.schema.rules) { + throw new Error( + 'Schemas in Slate have changed! They are no longer accept a `rules` property.' + ) + } - if (plugin.schema.nodes) { - throw new Error('Schemas in Slate have changed! They are no longer accept a `nodes` property.') - } + if (plugin.schema.nodes) { + throw new Error( + 'Schemas in Slate have changed! They are no longer accept a `nodes` property.' + ) + } - const { document = {}, blocks = {}, inlines = {}} = plugin.schema - const d = resolveDocumentRule(document) - const bs = {} - const is = {} + const { document = {}, blocks = {}, inlines = {} } = plugin.schema + const d = resolveDocumentRule(document) + const bs = {} + const is = {} - for (const key in blocks) { - bs[key] = resolveNodeRule('block', key, blocks[key]) - } + for (const key in blocks) { + bs[key] = resolveNodeRule('block', key, blocks[key]) + } - for (const key in inlines) { - is[key] = resolveNodeRule('inline', key, inlines[key]) - } + for (const key in inlines) { + is[key] = resolveNodeRule('inline', key, inlines[key]) + } - mergeWith(schema.document, d, customizer) - mergeWith(schema.blocks, bs, customizer) - mergeWith(schema.inlines, is, customizer) - }) + mergeWith(schema.document, d, customizer) + mergeWith(schema.blocks, bs, customizer) + mergeWith(schema.inlines, is, customizer) + }) return schema } @@ -532,8 +567,8 @@ function resolveNodeRule(object, type, obj) { */ function customizer(target, source, key) { - if (key == 'objects' || key == 'types') { - return target == null ? source : target.concat(source) + if (key == 'objects' || key == 'types') { + return target == null ? source : target.concat(source) } else { return source == null ? target : source } @@ -549,9 +584,7 @@ Schema.prototype[MODEL_TYPES.SCHEMA] = true * Memoize read methods. */ -memoize(Schema.prototype, [ - 'getParentRules', -], { +memoize(Schema.prototype, ['getParentRules'], { takesArguments: true, }) diff --git a/packages/slate/src/models/stack.js b/packages/slate/src/models/stack.js index 286b53108..37351458a 100644 --- a/packages/slate/src/models/stack.js +++ b/packages/slate/src/models/stack.js @@ -1,4 +1,3 @@ - import logger from 'slate-dev-logger' import { Record } from 'immutable' @@ -22,7 +21,6 @@ const DEFAULTS = { */ class Stack extends Record(DEFAULTS) { - /** * Constructor. * @@ -57,7 +55,10 @@ class Stack extends Record(DEFAULTS) { } get kind() { - logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.') + logger.deprecate( + 'slate@0.32.0', + 'The `kind` property of Slate objects has been renamed to `object`.' + ) return this.object } @@ -133,7 +134,9 @@ class Stack extends Record(DEFAULTS) { */ render(property, props, ...args) { - const plugins = this.getPluginsWith(property).slice().reverse() + const plugins = this.getPluginsWith(property) + .slice() + .reverse() let { children = null } = props for (const plugin of plugins) { @@ -144,7 +147,6 @@ class Stack extends Record(DEFAULTS) { return children } - } /** @@ -157,9 +159,7 @@ Stack.prototype[MODEL_TYPES.STACK] = true * Memoize read methods. */ -memoize(Stack.prototype, [ - 'getPluginsWith', -], { +memoize(Stack.prototype, ['getPluginsWith'], { takesArguments: true, }) diff --git a/packages/slate/src/models/text.js b/packages/slate/src/models/text.js index 324cca4fa..29c8fc21f 100644 --- a/packages/slate/src/models/text.js +++ b/packages/slate/src/models/text.js @@ -1,4 +1,3 @@ - import isPlainObject from 'is-plain-object' import logger from 'slate-dev-logger' import { List, OrderedSet, Record, Set, is } from 'immutable' @@ -28,7 +27,6 @@ const DEFAULTS = { */ class Text extends Record(DEFAULTS) { - /** * Create a new `Text` with `attrs`. * @@ -54,7 +52,9 @@ class Text extends Record(DEFAULTS) { return Text.fromJSON(attrs) } - throw new Error(`\`Text.create\` only accepts objects, arrays, strings or texts, but you passed it: ${attrs}`) + throw new Error( + `\`Text.create\` only accepts objects, arrays, strings or texts, but you passed it: ${attrs}` + ) } /** @@ -70,7 +70,9 @@ class Text extends Record(DEFAULTS) { return list } - throw new Error(`\`Text.createList\` only accepts arrays or lists, but you passed it: ${elements}`) + throw new Error( + `\`Text.createList\` only accepts arrays or lists, but you passed it: ${elements}` + ) } /** @@ -85,10 +87,7 @@ class Text extends Record(DEFAULTS) { return object } - const { - leaves = [], - key = generateKey(), - } = object + const { leaves = [], key = generateKey() } = object const characters = leaves .map(Leaf.fromJSON) @@ -141,7 +140,10 @@ class Text extends Record(DEFAULTS) { } get kind() { - logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.') + logger.deprecate( + 'slate@0.32.0', + 'The `kind` property of Slate objects has been renamed to `object`.' + ) return this.object } @@ -215,7 +217,7 @@ class Text extends Record(DEFAULTS) { // PERF: Exit early if there are no characters to be decorated. if (characters.size == 0) return characters - decorations.forEach((range) => { + decorations.forEach(range => { const { startKey, endKey, startOffset, endOffset, marks } = range const hasStart = startKey == key const hasEnd = endKey == key @@ -256,10 +258,8 @@ class Text extends Record(DEFAULTS) { // If there are no characters, return one empty range. if (characters.size == 0) { leaves.push({}) - } - - // Otherwise, loop the characters and build the leaves... - else { + } else { + // Otherwise, loop the characters and build the leaves... characters.forEach((char, i) => { const { marks, text } = char @@ -342,9 +342,7 @@ class Text extends Record(DEFAULTS) { */ getNode(key) { - return this.key == key - ? this - : null + return this.key == key ? this : null } /** @@ -369,9 +367,12 @@ class Text extends Record(DEFAULTS) { insertText(index, text, marks) { let { characters } = this - const chars = Character.createList(text.split('').map(char => ({ text: char, marks }))) + const chars = Character.createList( + text.split('').map(char => ({ text: char, marks })) + ) - characters = characters.slice(0, index) + characters = characters + .slice(0, index) .concat(chars) .concat(characters.slice(index)) @@ -437,7 +438,9 @@ class Text extends Record(DEFAULTS) { toJSON(options = {}) { const object = { object: this.object, - leaves: this.getLeaves().toArray().map(r => r.toJSON()), + leaves: this.getLeaves() + .toArray() + .map(r => r.toJSON()), } if (options.preserveKeys) { @@ -492,7 +495,6 @@ class Text extends Record(DEFAULTS) { validate(schema) { return schema.validateNode(this) } - } /** @@ -505,22 +507,23 @@ Text.prototype[MODEL_TYPES.TEXT] = true * Memoize read methods. */ -memoize(Text.prototype, [ - 'getMarks', - 'getMarksAsArray', -], { +memoize(Text.prototype, ['getMarks', 'getMarksAsArray'], { takesArguments: false, }) -memoize(Text.prototype, [ - 'getDecoratedCharacters', - 'getDecorations', - 'getLeaves', - 'getMarksAtIndex', - 'validate' -], { - takesArguments: true, -}) +memoize( + Text.prototype, + [ + 'getDecoratedCharacters', + 'getDecorations', + 'getLeaves', + 'getMarksAtIndex', + 'validate', + ], + { + takesArguments: true, + } +) /** * Export. diff --git a/packages/slate/src/models/value.js b/packages/slate/src/models/value.js index 44dc2b149..59c5bcf49 100644 --- a/packages/slate/src/models/value.js +++ b/packages/slate/src/models/value.js @@ -1,4 +1,3 @@ - import isPlainObject from 'is-plain-object' import logger from 'slate-dev-logger' import { Record, Set, List, Map } from 'immutable' @@ -33,7 +32,6 @@ const DEFAULTS = { */ class Value extends Record(DEFAULTS) { - /** * Create a new `Value` with `attrs`. * @@ -51,7 +49,9 @@ class Value extends Record(DEFAULTS) { return Value.fromJSON(attrs) } - throw new Error(`\`Value.create\` only accepts objects or values, but you passed it: ${attrs}`) + throw new Error( + `\`Value.create\` only accepts objects or values, but you passed it: ${attrs}` + ) } /** @@ -73,12 +73,15 @@ class Value extends Record(DEFAULTS) { if (isPlainObject(attrs)) { const props = {} if ('data' in attrs) props.data = Data.create(attrs.data) - if ('decorations' in attrs) props.decorations = Range.createList(attrs.decorations) + if ('decorations' in attrs) + props.decorations = Range.createList(attrs.decorations) if ('schema' in attrs) props.schema = Schema.create(attrs.schema) return props } - throw new Error(`\`Value.createProperties\` only accepts objects or values, but you passed it: ${attrs}`) + throw new Error( + `\`Value.createProperties\` only accepts objects or values, but you passed it: ${attrs}` + ) } /** @@ -92,11 +95,7 @@ class Value extends Record(DEFAULTS) { */ static fromJSON(object, options = {}) { - let { - document = {}, - selection = {}, - schema = {}, - } = object + let { document = {}, selection = {}, schema = {} } = object let data = new Map() @@ -163,7 +162,10 @@ class Value extends Record(DEFAULTS) { } get kind() { - logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.') + logger.deprecate( + 'slate@0.32.0', + 'The `kind` property of Slate objects has been renamed to `object`.' + ) return this.object } @@ -540,7 +542,8 @@ class Value extends Record(DEFAULTS) { get activeMarks() { return this.selection.isUnset ? new Set() - : this.selection.marks || this.document.getActiveMarksAtRange(this.selection) + : this.selection.marks || + this.document.getActiveMarksAtRange(this.selection) } /** @@ -643,7 +646,9 @@ class Value extends Record(DEFAULTS) { } if (options.preserveDecorations) { - object.decorations = this.decorations ? this.decorations.toArray().map(d => d.toJSON()) : null + object.decorations = this.decorations + ? this.decorations.toArray().map(d => d.toJSON()) + : null } if (options.preserveHistory) { @@ -660,8 +665,12 @@ class Value extends Record(DEFAULTS) { if (options.preserveSelection && !options.preserveKeys) { const { document, selection } = this - object.selection.anchorPath = selection.isSet ? document.getPath(selection.anchorKey) : null - object.selection.focusPath = selection.isSet ? document.getPath(selection.focusKey) : null + object.selection.anchorPath = selection.isSet + ? document.getPath(selection.anchorKey) + : null + object.selection.focusPath = selection.isSet + ? document.getPath(selection.focusKey) + : null delete object.selection.anchorKey delete object.selection.focusKey } @@ -676,7 +685,6 @@ class Value extends Record(DEFAULTS) { toJS(options) { return this.toJSON(options) } - } /** diff --git a/packages/slate/src/operations/apply.js b/packages/slate/src/operations/apply.js index 6be000570..b354552a9 100644 --- a/packages/slate/src/operations/apply.js +++ b/packages/slate/src/operations/apply.js @@ -1,4 +1,3 @@ - import Debug from 'debug' import Operation from '../models/operation' @@ -18,7 +17,6 @@ const debug = Debug('slate:operation:apply') */ const APPLIERS = { - /** * Add mark to text at `offset` and `length` in node by `path`. * @@ -97,7 +95,9 @@ const APPLIERS = { merge_node(value, operation) { const { path } = operation - const withPath = path.slice(0, path.length - 1).concat([path[path.length - 1] - 1]) + const withPath = path + .slice(0, path.length - 1) + .concat([path[path.length - 1] - 1]) let { document, selection } = value const one = document.assertPath(withPath) const two = document.assertPath(path) @@ -116,12 +116,18 @@ const APPLIERS = { let normalize = false if (anchorKey == two.key) { - selection = selection.moveAnchorTo(one.key, one.text.length + anchorOffset) + selection = selection.moveAnchorTo( + one.key, + one.text.length + anchorOffset + ) normalize = true } if (focusKey == two.key) { - selection = selection.moveFocusTo(one.key, one.text.length + focusOffset) + selection = selection.moveFocusTo( + one.key, + one.text.length + focusOffset + ) normalize = true } @@ -163,24 +169,20 @@ const APPLIERS = { // If the old path and the rest of the new path are the same, then the new // target is the old parent. if ( - (oldParentPath.every((x, i) => x === newParentPath[i])) && - (oldParentPath.length === newParentPath.length) + oldParentPath.every((x, i) => x === newParentPath[i]) && + oldParentPath.length === newParentPath.length ) { target = parent - } - - // Otherwise, if the old path removal resulted in the new path being no longer - // correct, we need to decrement the new path at the old path's last index. - else if ( - (oldParentPath.every((x, i) => x === newParentPath[i])) && - (oldIndex < newParentPath[oldParentPath.length]) + } else if ( + oldParentPath.every((x, i) => x === newParentPath[i]) && + oldIndex < newParentPath[oldParentPath.length] ) { + // Otherwise, if the old path removal resulted in the new path being no longer + // correct, we need to decrement the new path at the old path's last index. newParentPath[oldParentPath.length]-- target = document.assertPath(newParentPath) - } - - // Otherwise, we can just grab the target normally... - else { + } else { + // Otherwise, we can just grab the target normally... target = document.assertPath(newParentPath) } @@ -359,11 +361,13 @@ const APPLIERS = { let { document, selection } = value if (anchorPath !== undefined) { - props.anchorKey = anchorPath === null ? null : document.assertPath(anchorPath).key + props.anchorKey = + anchorPath === null ? null : document.assertPath(anchorPath).key } if (focusPath !== undefined) { - props.focusKey = focusPath === null ? null : document.assertPath(focusPath).key + props.focusKey = + focusPath === null ? null : document.assertPath(focusPath).key } selection = selection.merge(props) @@ -440,7 +444,6 @@ const APPLIERS = { value = value.set('document', document).set('selection', selection) return value }, - } /** diff --git a/packages/slate/src/operations/index.js b/packages/slate/src/operations/index.js index 967a2aa96..bf84bb7d0 100644 --- a/packages/slate/src/operations/index.js +++ b/packages/slate/src/operations/index.js @@ -1,4 +1,3 @@ - import apply from './apply' import invert from './invert' diff --git a/packages/slate/src/operations/invert.js b/packages/slate/src/operations/invert.js index ddbc6cd1b..40245e810 100644 --- a/packages/slate/src/operations/invert.js +++ b/packages/slate/src/operations/invert.js @@ -1,4 +1,3 @@ - import Debug from 'debug' import pick from 'lodash/pick' @@ -56,10 +55,13 @@ function invertOperation(op) { // If the node's old position was a left sibling of an ancestor of // its new position, we need to adjust part of the path by -1. - if (path.length < inversePath.length && - path.slice(0, pathLast).every((e, i) => e == inversePath[i]) && - path[pathLast] < inversePath[pathLast]) { - inversePath = inversePath.slice(0, pathLast) + if ( + path.length < inversePath.length && + path.slice(0, pathLast).every((e, i) => e == inversePath[i]) && + path[pathLast] < inversePath[pathLast] + ) { + inversePath = inversePath + .slice(0, pathLast) .concat([inversePath[pathLast] - 1]) .concat(inversePath.slice(pathLast + 1, inversePath.length)) } @@ -67,10 +69,13 @@ function invertOperation(op) { // If the node's new position is an ancestor of the old position, // or a left sibling of an ancestor of its old position, we need // to adjust part of the path by 1. - if (newPath.length < inverseNewPath.length && - newPath.slice(0, newPathLast).every((e, i) => e == inverseNewPath[i]) && - newPath[newPathLast] <= inverseNewPath[newPathLast]) { - inverseNewPath = inverseNewPath.slice(0, newPathLast) + if ( + newPath.length < inverseNewPath.length && + newPath.slice(0, newPathLast).every((e, i) => e == inverseNewPath[i]) && + newPath[newPathLast] <= inverseNewPath[newPathLast] + ) { + inverseNewPath = inverseNewPath + .slice(0, newPathLast) .concat([inverseNewPath[newPathLast] + 1]) .concat(inverseNewPath.slice(newPathLast + 1, inverseNewPath.length)) } @@ -113,7 +118,9 @@ function invertOperation(op) { const { properties, node } = op const inverseNode = node.merge(properties) const inverseProperties = pick(node, Object.keys(properties)) - const inverse = op.set('node', inverseNode).set('properties', inverseProperties) + const inverse = op + .set('node', inverseNode) + .set('properties', inverseProperties) return inverse } @@ -161,7 +168,9 @@ function invertOperation(op) { const { properties, mark } = op const inverseMark = mark.merge(properties) const inverseProperties = pick(mark, Object.keys(properties)) - const inverse = op.set('mark', inverseMark).set('properties', inverseProperties) + const inverse = op + .set('mark', inverseMark) + .set('properties', inverseProperties) return inverse } @@ -175,35 +184,37 @@ function invertOperation(op) { const { document } = value if (anchorPath !== undefined) { - props.anchorKey = anchorPath === null - ? null - : document.assertPath(anchorPath).key + props.anchorKey = + anchorPath === null ? null : document.assertPath(anchorPath).key } if (focusPath !== undefined) { - props.focusKey = focusPath === null - ? null - : document.assertPath(focusPath).key + props.focusKey = + focusPath === null ? null : document.assertPath(focusPath).key } const inverseSelection = selection.merge(props) const inverseProps = pick(selection, Object.keys(props)) if (anchorPath !== undefined) { - inverseProps.anchorPath = inverseProps.anchorKey === null - ? null - : document.getPath(inverseProps.anchorKey) + inverseProps.anchorPath = + inverseProps.anchorKey === null + ? null + : document.getPath(inverseProps.anchorKey) delete inverseProps.anchorKey } if (focusPath !== undefined) { - inverseProps.focusPath = inverseProps.focusKey === null - ? null - : document.getPath(inverseProps.focusKey) + inverseProps.focusPath = + inverseProps.focusKey === null + ? null + : document.getPath(inverseProps.focusKey) delete inverseProps.focusKey } - const inverse = op.set('selection', inverseSelection).set('properties', inverseProps) + const inverse = op + .set('selection', inverseSelection) + .set('properties', inverseProps) return inverse } @@ -215,7 +226,9 @@ function invertOperation(op) { const { properties, value } = op const inverseValue = value.merge(properties) const inverseProperties = pick(value, Object.keys(properties)) - const inverse = op.set('value', inverseValue).set('properties', inverseProperties) + const inverse = op + .set('value', inverseValue) + .set('properties', inverseProperties) return inverse } } diff --git a/packages/slate/src/utils/generate-key.js b/packages/slate/src/utils/generate-key.js index 90240d12e..62fae4f81 100644 --- a/packages/slate/src/utils/generate-key.js +++ b/packages/slate/src/utils/generate-key.js @@ -1,4 +1,3 @@ - /** * An auto-incrementing index for generating keys. * @@ -56,8 +55,4 @@ resetKeyGenerator() * @type {Object} */ -export { - generateKey as default, - setKeyGenerator, - resetKeyGenerator -} +export { generateKey as default, setKeyGenerator, resetKeyGenerator } diff --git a/packages/slate/src/utils/is-index-in-range.js b/packages/slate/src/utils/is-index-in-range.js index 837a136e0..39decf945 100644 --- a/packages/slate/src/utils/is-index-in-range.js +++ b/packages/slate/src/utils/is-index-in-range.js @@ -1,4 +1,3 @@ - /** * Check if an `index` of a `text` node is in a `range`. * diff --git a/packages/slate/src/utils/is-react-component.js b/packages/slate/src/utils/is-react-component.js index a879c69ea..21e2bdcf1 100644 --- a/packages/slate/src/utils/is-react-component.js +++ b/packages/slate/src/utils/is-react-component.js @@ -1,4 +1,3 @@ - /** * Check if an `object` is a React component. * @@ -7,11 +6,7 @@ */ function isReactComponent(object) { - return ( - object && - object.prototype && - object.prototype.isReactComponent - ) + return object && object.prototype && object.prototype.isReactComponent } /** diff --git a/packages/slate/src/utils/memoize.js b/packages/slate/src/utils/memoize.js index 6d7791b92..c6ed27cc2 100644 --- a/packages/slate/src/utils/memoize.js +++ b/packages/slate/src/utils/memoize.js @@ -1,15 +1,13 @@ - /** * Is in development? * * @type {Boolean} */ -const IS_DEV = ( +const IS_DEV = typeof process !== 'undefined' && process.env && process.env.NODE_ENV !== 'production' -) /** * GLOBAL: True if memoization should is enabled. Only effective when `IS_DEV`. @@ -72,7 +70,7 @@ function memoize(object, properties, options = {}) { throw new Error(`Object does not have a property named "${property}".`) } - object[property] = function (...args) { + object[property] = function(...args) { if (IS_DEV) { // If memoization is disabled, call into the original method. if (!ENABLED) return original.apply(this, args) @@ -199,8 +197,4 @@ function __enable(enabled) { * @type {Object} */ -export { - memoize as default, - __clear, - __enable -} +export { memoize as default, __clear, __enable } diff --git a/packages/slate/src/utils/string.js b/packages/slate/src/utils/string.js index eff8b65cd..060c57942 100644 --- a/packages/slate/src/utils/string.js +++ b/packages/slate/src/utils/string.js @@ -1,4 +1,3 @@ - import { reverse } from 'esrever' /** @@ -7,8 +6,8 @@ import { reverse } from 'esrever' * @type {Number} */ -const SURROGATE_START = 0xD800 -const SURROGATE_END = 0xDFFF +const SURROGATE_START = 0xd800 +const SURROGATE_END = 0xdfff /** * A regex to match space characters. @@ -78,9 +77,7 @@ function isWord(char, remaining) { */ function getCharLength(char) { - return isSurrogate(char.charCodeAt(0)) - ? 2 - : 1 + return isSurrogate(char.charCodeAt(0)) ? 2 : 1 } /** @@ -135,7 +132,7 @@ function getWordOffset(text) { let started = false let char - while (char = text.charAt(i)) { + while ((char = text.charAt(i))) { const l = getCharLength(char) char = text.slice(i, i + l) const rest = text.slice(i + l) @@ -194,5 +191,5 @@ export default { getCharOffsetForward, getCharOffsetBackward, getWordOffsetBackward, - getWordOffsetForward + getWordOffsetForward, } diff --git a/packages/slate/test/changes/at-current-range/add-mark/across-blocks.js b/packages/slate/test/changes/at-current-range/add-mark/across-blocks.js index 07a3f2a12..11f760cb4 100644 --- a/packages/slate/test/changes/at-current-range/add-mark/across-blocks.js +++ b/packages/slate/test/changes/at-current-range/add-mark/across-blocks.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.addMark('bold') } @@ -23,10 +23,12 @@ export const output = (- This is editable rich text, much better than a textarea! + This is editable rich text, much better than a + textarea! diff --git a/packages/slate/test/changes/at-current-range/add-mark/across-inlines.js b/packages/slate/test/changes/at-current-range/add-mark/across-inlines.js index 061abc35e..095cbf980 100644 --- a/packages/slate/test/changes/at-current-range/add-mark/across-inlines.js +++ b/packages/slate/test/changes/at-current-range/add-mark/across-inlines.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.addMark('bold') } @@ -10,10 +10,14 @@ export const input = ( - wo rd + wo + rd - an other + an + other @@ -24,12 +28,14 @@ export const output = ( - wo rd + + wo rd + - an other + + an other + diff --git a/packages/slate/test/changes/at-current-range/add-mark/collapsed-selection.js b/packages/slate/test/changes/at-current-range/add-mark/collapsed-selection.js index 572c09dab..c8991b0d0 100644 --- a/packages/slate/test/changes/at-current-range/add-mark/collapsed-selection.js +++ b/packages/slate/test/changes/at-current-range/add-mark/collapsed-selection.js @@ -2,10 +2,8 @@ import h from '../../../helpers/h' -export default function (change) { - change - .addMark('bold') - .insertText('a') +export default function(change) { + change.addMark('bold').insertText('a') } export const input = ( @@ -22,7 +20,8 @@ export const output = ( - wo rd + wo + rd - an other + an + other diff --git a/packages/slate/test/changes/at-current-range/add-mark/existing-marks.js b/packages/slate/test/changes/at-current-range/add-mark/existing-marks.js index a1e7db82e..afdd2635e 100644 --- a/packages/slate/test/changes/at-current-range/add-mark/existing-marks.js +++ b/packages/slate/test/changes/at-current-range/add-mark/existing-marks.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.addMark('bold') } @@ -10,7 +10,10 @@ export const input = ( - a word + a + word @@ -20,7 +23,12 @@ export const output = ( - wo rd + + + wo rd + diff --git a/packages/slate/test/changes/at-current-range/add-mark/first-character.js b/packages/slate/test/changes/at-current-range/add-mark/first-character.js index 524d06446..6c5cdc8ae 100644 --- a/packages/slate/test/changes/at-current-range/add-mark/first-character.js +++ b/packages/slate/test/changes/at-current-range/add-mark/first-character.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.addMark('bold') } @@ -20,7 +20,9 @@ export const output = ( - wo rd + + + wo + + + rd diff --git a/packages/slate/test/changes/at-current-range/add-mark/last-character.js b/packages/slate/test/changes/at-current-range/add-mark/last-character.js index 197aa641f..f53697732 100644 --- a/packages/slate/test/changes/at-current-range/add-mark/last-character.js +++ b/packages/slate/test/changes/at-current-range/add-mark/last-character.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.addMark('bold') } @@ -20,7 +20,9 @@ export const output = ( - w ord + + w + ord diff --git a/packages/slate/test/changes/at-current-range/add-mark/middle-character.js b/packages/slate/test/changes/at-current-range/add-mark/middle-character.js index 59ee28278..2b0982a25 100644 --- a/packages/slate/test/changes/at-current-range/add-mark/middle-character.js +++ b/packages/slate/test/changes/at-current-range/add-mark/middle-character.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.addMark('bold') } @@ -20,7 +20,9 @@ export const output = ( - wor d + wor + d + diff --git a/packages/slate/test/changes/at-current-range/add-mark/whole-word.js b/packages/slate/test/changes/at-current-range/add-mark/whole-word.js index ab94b3282..a32a95c24 100644 --- a/packages/slate/test/changes/at-current-range/add-mark/whole-word.js +++ b/packages/slate/test/changes/at-current-range/add-mark/whole-word.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.addMark('bold') } @@ -20,7 +20,9 @@ export const output = ( - w o rd + w + o + rd diff --git a/packages/slate/test/changes/at-current-range/add-mark/with-mark-object.js b/packages/slate/test/changes/at-current-range/add-mark/with-mark-object.js index eb72c4566..b39f3d10b 100644 --- a/packages/slate/test/changes/at-current-range/add-mark/with-mark-object.js +++ b/packages/slate/test/changes/at-current-range/add-mark/with-mark-object.js @@ -4,12 +4,13 @@ import h from '../../../helpers/h' import { Mark } from '../../../..' - -export default function (change) { - change.addMark(Mark.create({ - type: 'bold', - data: { thing: 'value' } - })) +export default function(change) { + change.addMark( + Mark.create({ + type: 'bold', + data: { thing: 'value' }, + }) + ) } export const input = ( @@ -26,7 +27,9 @@ export const output = ( - word + + word + diff --git a/packages/slate/test/changes/at-current-range/add-mark/with-plain-object.js b/packages/slate/test/changes/at-current-range/add-mark/with-plain-object.js index e9cf55d42..60291bcae 100644 --- a/packages/slate/test/changes/at-current-range/add-mark/with-plain-object.js +++ b/packages/slate/test/changes/at-current-range/add-mark/with-plain-object.js @@ -2,10 +2,10 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.addMark({ type: 'bold', - data: { thing: 'value' } + data: { thing: 'value' }, }) } @@ -23,7 +23,9 @@ export const output = ( - w ord + + w + ord diff --git a/packages/slate/test/changes/at-current-range/add-marks/across-blocks.js b/packages/slate/test/changes/at-current-range/add-marks/across-blocks.js index 84d3e3705..9b1bef99b 100644 --- a/packages/slate/test/changes/at-current-range/add-marks/across-blocks.js +++ b/packages/slate/test/changes/at-current-range/add-marks/across-blocks.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.addMarks(['bold', 'italic']) } @@ -23,10 +23,16 @@ export const output = ( - w ord + + w + ord diff --git a/packages/slate/test/changes/at-current-range/add-marks/across-inlines.js b/packages/slate/test/changes/at-current-range/add-marks/across-inlines.js index a70c1bfde..04a31271f 100644 --- a/packages/slate/test/changes/at-current-range/add-marks/across-inlines.js +++ b/packages/slate/test/changes/at-current-range/add-marks/across-inlines.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.addMarks(['bold', 'italic']) } @@ -10,10 +10,14 @@ export const input = ( - wo rd + wo + + rd + - an other + + an + + other @@ -24,12 +28,18 @@ export const output = ( - wo rd + + wo rd + - an other + + an other + diff --git a/packages/slate/test/changes/at-current-range/add-marks/collapsed-selection.js b/packages/slate/test/changes/at-current-range/add-marks/collapsed-selection.js index 1786ecfd8..39cc194dd 100644 --- a/packages/slate/test/changes/at-current-range/add-marks/collapsed-selection.js +++ b/packages/slate/test/changes/at-current-range/add-marks/collapsed-selection.js @@ -2,10 +2,8 @@ import h from '../../../helpers/h' -export default function (change) { - change - .addMarks(['bold', 'italic']) - .insertText('a') +export default function(change) { + change.addMarks(['bold', 'italic']).insertText('a') } export const input = ( @@ -22,7 +20,10 @@ export const output = ( - wo rd + wo + + rd + - an other + + an + + other diff --git a/packages/slate/test/changes/at-current-range/add-marks/existing-marks.js b/packages/slate/test/changes/at-current-range/add-marks/existing-marks.js index 84ffecc1e..8ba16a851 100644 --- a/packages/slate/test/changes/at-current-range/add-marks/existing-marks.js +++ b/packages/slate/test/changes/at-current-range/add-marks/existing-marks.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.addMarks(['bold', 'underline']) } @@ -10,7 +10,10 @@ export const input = ( - a word + + a + + word @@ -20,7 +23,14 @@ export const output = ( - wo rd + + + wo rd + diff --git a/packages/slate/test/changes/at-current-range/add-marks/first-character.js b/packages/slate/test/changes/at-current-range/add-marks/first-character.js index a38b37bf7..20db8ef85 100644 --- a/packages/slate/test/changes/at-current-range/add-marks/first-character.js +++ b/packages/slate/test/changes/at-current-range/add-marks/first-character.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.addMarks(['bold', 'italic']) } @@ -20,7 +20,11 @@ export const output = ( - wo rd + + + + wo + + + + rd diff --git a/packages/slate/test/changes/at-current-range/add-marks/last-character.js b/packages/slate/test/changes/at-current-range/add-marks/last-character.js index 0a1958ee5..6b6205131 100644 --- a/packages/slate/test/changes/at-current-range/add-marks/last-character.js +++ b/packages/slate/test/changes/at-current-range/add-marks/last-character.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.addMarks(['bold', 'italic']) } @@ -20,7 +20,11 @@ export const output = ( - w ord + + + w + + ord diff --git a/packages/slate/test/changes/at-current-range/add-marks/middle-character.js b/packages/slate/test/changes/at-current-range/add-marks/middle-character.js index c93680e99..ac96b7e35 100644 --- a/packages/slate/test/changes/at-current-range/add-marks/middle-character.js +++ b/packages/slate/test/changes/at-current-range/add-marks/middle-character.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.addMarks(['bold', 'italic']) } @@ -20,7 +20,11 @@ export const output = ( - wor d + wor + + d + + diff --git a/packages/slate/test/changes/at-current-range/add-marks/whole-word.js b/packages/slate/test/changes/at-current-range/add-marks/whole-word.js index 3d4de7b48..eba575791 100644 --- a/packages/slate/test/changes/at-current-range/add-marks/whole-word.js +++ b/packages/slate/test/changes/at-current-range/add-marks/whole-word.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.addMarks(['bold', 'italic']) } @@ -20,7 +20,11 @@ export const output = ( - w o rd + w + + o + + rd diff --git a/packages/slate/test/changes/at-current-range/add-marks/with-mark-object.js b/packages/slate/test/changes/at-current-range/add-marks/with-mark-object.js index 16fa88d63..4c562f3a3 100644 --- a/packages/slate/test/changes/at-current-range/add-marks/with-mark-object.js +++ b/packages/slate/test/changes/at-current-range/add-marks/with-mark-object.js @@ -4,18 +4,21 @@ import h from '../../../helpers/h' import { Mark } from '../../../..' - -export default function (change) { +export default function(change) { const marks = [] - marks.push(Mark.create({ - type: 'bold', - data: { thing: 'value' } - })) - marks.push(Mark.create({ - type: 'italic', - data: { thing2: 'value2' } - })) + marks.push( + Mark.create({ + type: 'bold', + data: { thing: 'value' }, + }) + ) + marks.push( + Mark.create({ + type: 'italic', + data: { thing2: 'value2' }, + }) + ) change.addMarks(marks) } @@ -34,7 +37,11 @@ export const output = ( - word + + + word + + diff --git a/packages/slate/test/changes/at-current-range/add-marks/with-plain-object.js b/packages/slate/test/changes/at-current-range/add-marks/with-plain-object.js index 474471519..a759e2b2c 100644 --- a/packages/slate/test/changes/at-current-range/add-marks/with-plain-object.js +++ b/packages/slate/test/changes/at-current-range/add-marks/with-plain-object.js @@ -2,16 +2,16 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { const marks = [] marks.push({ type: 'bold', - data: { thing: 'value' } + data: { thing: 'value' }, }) marks.push({ type: 'italic', - data: { thing2: 'value2' } + data: { thing2: 'value2' }, }) change.addMarks(marks) @@ -31,7 +31,11 @@ export const output = ( - w ord + + + w + + ord diff --git a/packages/slate/test/changes/at-current-range/delete-backward/empty-after-void-block.js b/packages/slate/test/changes/at-current-range/delete-backward/empty-after-void-block.js index 94567ab5c..b8fa5f419 100644 --- a/packages/slate/test/changes/at-current-range/delete-backward/empty-after-void-block.js +++ b/packages/slate/test/changes/at-current-range/delete-backward/empty-after-void-block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteBackward() } @@ -21,7 +21,8 @@ export const output = ( - w ord + + + w + + ord diff --git a/packages/slate/test/changes/at-current-range/delete-backward/first-character.js b/packages/slate/test/changes/at-current-range/delete-backward/first-character.js index 8c47250d7..ded9ed370 100644 --- a/packages/slate/test/changes/at-current-range/delete-backward/first-character.js +++ b/packages/slate/test/changes/at-current-range/delete-backward/first-character.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteBackward() } diff --git a/packages/slate/test/changes/at-current-range/delete-backward/inline-after.js b/packages/slate/test/changes/at-current-range/delete-backward/inline-after.js index 3fa4ee366..a4c9b00d0 100644 --- a/packages/slate/test/changes/at-current-range/delete-backward/inline-after.js +++ b/packages/slate/test/changes/at-current-range/delete-backward/inline-after.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteBackward() } @@ -20,7 +20,8 @@ export const output = ( - {' '} + {' '} + diff --git a/packages/slate/test/changes/at-current-range/delete-backward/inline-before.js b/packages/slate/test/changes/at-current-range/delete-backward/inline-before.js index 5128fa649..41ab7461d 100644 --- a/packages/slate/test/changes/at-current-range/delete-backward/inline-before.js +++ b/packages/slate/test/changes/at-current-range/delete-backward/inline-before.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteBackward() } @@ -10,7 +10,8 @@ export const input = ( - onetwo + onetwo + @@ -20,7 +21,8 @@ export const output = ( - a two + a + two diff --git a/packages/slate/test/changes/at-current-range/delete-backward/inline-end.js b/packages/slate/test/changes/at-current-range/delete-backward/inline-end.js index b55620b88..bbc07648c 100644 --- a/packages/slate/test/changes/at-current-range/delete-backward/inline-end.js +++ b/packages/slate/test/changes/at-current-range/delete-backward/inline-end.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteBackward() } @@ -10,7 +10,8 @@ export const input = ( - two + + two @@ -20,7 +21,8 @@ export const output = ( - onetwo + onetwo + diff --git a/packages/slate/test/changes/at-current-range/delete-backward/inline-inside.js b/packages/slate/test/changes/at-current-range/delete-backward/inline-inside.js index 8532a4f9e..27b4080e5 100644 --- a/packages/slate/test/changes/at-current-range/delete-backward/inline-inside.js +++ b/packages/slate/test/changes/at-current-range/delete-backward/inline-inside.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteBackward() } @@ -10,7 +10,9 @@ export const input = ( - onetw + onetw + diff --git a/packages/slate/test/changes/at-current-range/delete-backward/join-blocks-with-inline-void.js b/packages/slate/test/changes/at-current-range/delete-backward/join-blocks-with-inline-void.js index 299bb9851..e7eac5d12 100644 --- a/packages/slate/test/changes/at-current-range/delete-backward/join-blocks-with-inline-void.js +++ b/packages/slate/test/changes/at-current-range/delete-backward/join-blocks-with-inline-void.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteBackward() } @@ -23,7 +23,8 @@ export const output = ( - onea two + one + a + two diff --git a/packages/slate/test/changes/at-current-range/delete-backward/join-blocks-with-inline.js b/packages/slate/test/changes/at-current-range/delete-backward/join-blocks-with-inline.js index 728776b7c..c25ab3cd5 100644 --- a/packages/slate/test/changes/at-current-range/delete-backward/join-blocks-with-inline.js +++ b/packages/slate/test/changes/at-current-range/delete-backward/join-blocks-with-inline.js @@ -2,16 +2,14 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteBackward() } export const input = ( - word + + word - - one - +one diff --git a/packages/slate/test/changes/at-current-range/delete-backward/join-blocks.js b/packages/slate/test/changes/at-current-range/delete-backward/join-blocks.js index c233f6928..514565144 100644 --- a/packages/slate/test/changes/at-current-range/delete-backward/join-blocks.js +++ b/packages/slate/test/changes/at-current-range/delete-backward/join-blocks.js @@ -2,16 +2,14 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteBackward() } export const input = ( twothreefour - - word - +word diff --git a/packages/slate/test/changes/at-current-range/delete-backward/join-nested-blocks.js b/packages/slate/test/changes/at-current-range/delete-backward/join-nested-blocks.js index 55eabe2c7..de7c3b174 100644 --- a/packages/slate/test/changes/at-current-range/delete-backward/join-nested-blocks.js +++ b/packages/slate/test/changes/at-current-range/delete-backward/join-nested-blocks.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteBackward() } @@ -10,9 +10,7 @@ export const input = ( another ) diff --git a/packages/slate/test/changes/at-current-range/delete-forward/join-nested-blocks.js b/packages/slate/test/changes/at-current-range/delete-forward/join-nested-blocks.js index 7bf884674..cc0bbe9fb 100644 --- a/packages/slate/test/changes/at-current-range/delete-forward/join-nested-blocks.js +++ b/packages/slate/test/changes/at-current-range/delete-forward/join-nested-blocks.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteForward() } @@ -13,9 +13,7 @@ export const input = ( -- word - +word diff --git a/packages/slate/test/changes/at-current-range/delete-backward/last-character.js b/packages/slate/test/changes/at-current-range/delete-backward/last-character.js index 9f5866676..199d98b59 100644 --- a/packages/slate/test/changes/at-current-range/delete-backward/last-character.js +++ b/packages/slate/test/changes/at-current-range/delete-backward/last-character.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteBackward() } diff --git a/packages/slate/test/changes/at-current-range/delete-backward/middle-character.js b/packages/slate/test/changes/at-current-range/delete-backward/middle-character.js index c2d5284fb..7009b5bd5 100644 --- a/packages/slate/test/changes/at-current-range/delete-backward/middle-character.js +++ b/packages/slate/test/changes/at-current-range/delete-backward/middle-character.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteBackward() } diff --git a/packages/slate/test/changes/at-current-range/delete-backward/multiple-characters.js b/packages/slate/test/changes/at-current-range/delete-backward/multiple-characters.js index a7be1c430..6250fd527 100644 --- a/packages/slate/test/changes/at-current-range/delete-backward/multiple-characters.js +++ b/packages/slate/test/changes/at-current-range/delete-backward/multiple-characters.js @@ -2,14 +2,16 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteBackward(3) } export const input = ( another ) @@ -17,7 +19,9 @@ export const input = ( export const output = ( - word ++ word + ) diff --git a/packages/slate/test/changes/at-current-range/delete-backward/single-non-void-block.js b/packages/slate/test/changes/at-current-range/delete-backward/single-non-void-block.js index 840647c3e..816545ef7 100644 --- a/packages/slate/test/changes/at-current-range/delete-backward/single-non-void-block.js +++ b/packages/slate/test/changes/at-current-range/delete-backward/single-non-void-block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteBackward() } diff --git a/packages/slate/test/changes/at-current-range/delete-backward/single-void-block.js b/packages/slate/test/changes/at-current-range/delete-backward/single-void-block.js index 3a4232402..3bcf69115 100644 --- a/packages/slate/test/changes/at-current-range/delete-backward/single-void-block.js +++ b/packages/slate/test/changes/at-current-range/delete-backward/single-void-block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteBackward() } diff --git a/packages/slate/test/changes/at-current-range/delete-backward/start-of-document.js b/packages/slate/test/changes/at-current-range/delete-backward/start-of-document.js index e736812aa..59e800f76 100644 --- a/packages/slate/test/changes/at-current-range/delete-backward/start-of-document.js +++ b/packages/slate/test/changes/at-current-range/delete-backward/start-of-document.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteBackward() } diff --git a/packages/slate/test/changes/at-current-range/delete-char-backward/inline-after-emoji.js b/packages/slate/test/changes/at-current-range/delete-char-backward/inline-after-emoji.js index fcae94f2d..b535832f6 100644 --- a/packages/slate/test/changes/at-current-range/delete-char-backward/inline-after-emoji.js +++ b/packages/slate/test/changes/at-current-range/delete-char-backward/inline-after-emoji.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteCharBackward() } @@ -20,7 +20,8 @@ export const output = ( - w ++ w + diff --git a/packages/slate/test/changes/at-current-range/delete-char-backward/inline-end-emoji.js b/packages/slate/test/changes/at-current-range/delete-char-backward/inline-end-emoji.js index 29df9e0cd..46d2f19b2 100644 --- a/packages/slate/test/changes/at-current-range/delete-char-backward/inline-end-emoji.js +++ b/packages/slate/test/changes/at-current-range/delete-char-backward/inline-end-emoji.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteCharBackward() } @@ -10,7 +10,9 @@ export const input = ( - word + word + @@ -20,7 +22,9 @@ export const output = ( - word📛 + + word📛 + diff --git a/packages/slate/test/changes/at-current-range/delete-char-backward/inline-inside-emoji.js b/packages/slate/test/changes/at-current-range/delete-char-backward/inline-inside-emoji.js index babe36067..b85c2ccda 100644 --- a/packages/slate/test/changes/at-current-range/delete-char-backward/inline-inside-emoji.js +++ b/packages/slate/test/changes/at-current-range/delete-char-backward/inline-inside-emoji.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteCharBackward() } @@ -10,7 +10,9 @@ export const input = ( - word + + word + @@ -20,7 +22,9 @@ export const output = ( - wor📛 d + + wor📛 d + diff --git a/packages/slate/test/changes/at-current-range/delete-char-backward/inline-only-emoji.js b/packages/slate/test/changes/at-current-range/delete-char-backward/inline-only-emoji.js index 9b274e867..4f6691789 100644 --- a/packages/slate/test/changes/at-current-range/delete-char-backward/inline-only-emoji.js +++ b/packages/slate/test/changes/at-current-range/delete-char-backward/inline-only-emoji.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteCharBackward() } @@ -10,7 +10,9 @@ export const input = ( - wor d + + wor d + diff --git a/packages/slate/test/changes/at-current-range/delete-char-backward/text-end.js b/packages/slate/test/changes/at-current-range/delete-char-backward/text-end.js index d8f6f6185..21ed969f9 100644 --- a/packages/slate/test/changes/at-current-range/delete-char-backward/text-end.js +++ b/packages/slate/test/changes/at-current-range/delete-char-backward/text-end.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteCharBackward() } diff --git a/packages/slate/test/changes/at-current-range/delete-char-backward/text-middle.js b/packages/slate/test/changes/at-current-range/delete-char-backward/text-middle.js index c3a6d9f66..f320ce47b 100644 --- a/packages/slate/test/changes/at-current-range/delete-char-backward/text-middle.js +++ b/packages/slate/test/changes/at-current-range/delete-char-backward/text-middle.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteCharBackward() } diff --git a/packages/slate/test/changes/at-current-range/delete-char-backward/text-start.js b/packages/slate/test/changes/at-current-range/delete-char-backward/text-start.js index dc89dc050..e9d2309ee 100644 --- a/packages/slate/test/changes/at-current-range/delete-char-backward/text-start.js +++ b/packages/slate/test/changes/at-current-range/delete-char-backward/text-start.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteCharBackward() } diff --git a/packages/slate/test/changes/at-current-range/delete-char-forward/inline-before-emoji.js b/packages/slate/test/changes/at-current-range/delete-char-forward/inline-before-emoji.js index d2a3c8fd8..82a88a377 100644 --- a/packages/slate/test/changes/at-current-range/delete-char-forward/inline-before-emoji.js +++ b/packages/slate/test/changes/at-current-range/delete-char-forward/inline-before-emoji.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteCharForward() } @@ -20,7 +20,8 @@ export const output = ( - 📛 + + 📛 + diff --git a/packages/slate/test/changes/at-current-range/delete-char-forward/inline-middle-emoji.js b/packages/slate/test/changes/at-current-range/delete-char-forward/inline-middle-emoji.js index 6fd71cd5a..a8cb79f15 100644 --- a/packages/slate/test/changes/at-current-range/delete-char-forward/inline-middle-emoji.js +++ b/packages/slate/test/changes/at-current-range/delete-char-forward/inline-middle-emoji.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteCharForward() } @@ -10,7 +10,9 @@ export const input = ( - word + + word @@ -20,7 +22,9 @@ export const output = ( - wo 📛rd + + wo 📛rd + diff --git a/packages/slate/test/changes/at-current-range/delete-char-forward/inline-start-emoji.js b/packages/slate/test/changes/at-current-range/delete-char-forward/inline-start-emoji.js index 10d6a282e..c17394cda 100644 --- a/packages/slate/test/changes/at-current-range/delete-char-forward/inline-start-emoji.js +++ b/packages/slate/test/changes/at-current-range/delete-char-forward/inline-start-emoji.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteCharForward() } @@ -10,7 +10,9 @@ export const input = ( - wo rd + + wo rd + @@ -20,7 +22,9 @@ export const output = ( - 📛word + + 📛word + diff --git a/packages/slate/test/changes/at-current-range/delete-char-forward/text-last.js b/packages/slate/test/changes/at-current-range/delete-char-forward/text-last.js index 4d2ee57b5..2200c5468 100644 --- a/packages/slate/test/changes/at-current-range/delete-char-forward/text-last.js +++ b/packages/slate/test/changes/at-current-range/delete-char-forward/text-last.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteCharForward() } diff --git a/packages/slate/test/changes/at-current-range/delete-char-forward/text-middle.js b/packages/slate/test/changes/at-current-range/delete-char-forward/text-middle.js index eae6f82f8..4cac26a63 100644 --- a/packages/slate/test/changes/at-current-range/delete-char-forward/text-middle.js +++ b/packages/slate/test/changes/at-current-range/delete-char-forward/text-middle.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteCharForward() } diff --git a/packages/slate/test/changes/at-current-range/delete-char-forward/text-start.js b/packages/slate/test/changes/at-current-range/delete-char-forward/text-start.js index 8b9795de3..7d56bc20a 100644 --- a/packages/slate/test/changes/at-current-range/delete-char-forward/text-start.js +++ b/packages/slate/test/changes/at-current-range/delete-char-forward/text-start.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteCharForward() } diff --git a/packages/slate/test/changes/at-current-range/delete-forward/before-inline-sibling.js b/packages/slate/test/changes/at-current-range/delete-forward/before-inline-sibling.js index 5a2b5410b..7bba5592b 100644 --- a/packages/slate/test/changes/at-current-range/delete-forward/before-inline-sibling.js +++ b/packages/slate/test/changes/at-current-range/delete-forward/before-inline-sibling.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteForward() } @@ -10,7 +10,8 @@ export const input = ( - word + + word + @@ -20,7 +21,8 @@ export const output = ( - onetwo a + onetwo + a diff --git a/packages/slate/test/changes/at-current-range/delete-forward/empty-before-void-block.js b/packages/slate/test/changes/at-current-range/delete-forward/empty-before-void-block.js index ec06ef54d..aafb1633a 100644 --- a/packages/slate/test/changes/at-current-range/delete-forward/empty-before-void-block.js +++ b/packages/slate/test/changes/at-current-range/delete-forward/empty-before-void-block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteForward() } diff --git a/packages/slate/test/changes/at-current-range/delete-forward/end-of-document.js b/packages/slate/test/changes/at-current-range/delete-forward/end-of-document.js index 04a854c55..b8efee8b1 100644 --- a/packages/slate/test/changes/at-current-range/delete-forward/end-of-document.js +++ b/packages/slate/test/changes/at-current-range/delete-forward/end-of-document.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteForward() } diff --git a/packages/slate/test/changes/at-current-range/delete-forward/first-character.js b/packages/slate/test/changes/at-current-range/delete-forward/first-character.js index 3731542a2..c660e43c8 100644 --- a/packages/slate/test/changes/at-current-range/delete-forward/first-character.js +++ b/packages/slate/test/changes/at-current-range/delete-forward/first-character.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteForward() } diff --git a/packages/slate/test/changes/at-current-range/delete-forward/inside-inline-sibling.js b/packages/slate/test/changes/at-current-range/delete-forward/inside-inline-sibling.js index 767a517a9..2a671e971 100644 --- a/packages/slate/test/changes/at-current-range/delete-forward/inside-inline-sibling.js +++ b/packages/slate/test/changes/at-current-range/delete-forward/inside-inline-sibling.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteForward() } @@ -10,7 +10,9 @@ export const input = ( - onetwo + onetwo + @@ -19,7 +21,9 @@ export const input = ( export const output = ( - one atwo + one + a + two ) diff --git a/packages/slate/test/changes/at-current-range/delete-forward/join-blocks-with-inline-void.js b/packages/slate/test/changes/at-current-range/delete-forward/join-blocks-with-inline-void.js index 65b4c820c..f1338635f 100644 --- a/packages/slate/test/changes/at-current-range/delete-forward/join-blocks-with-inline-void.js +++ b/packages/slate/test/changes/at-current-range/delete-forward/join-blocks-with-inline-void.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteForward() } @@ -23,7 +23,8 @@ export const output = ( - one +two + one two + diff --git a/packages/slate/test/changes/at-current-range/delete-forward/join-blocks-with-inline.js b/packages/slate/test/changes/at-current-range/delete-forward/join-blocks-with-inline.js index 7eeec87ff..0b9e04603 100644 --- a/packages/slate/test/changes/at-current-range/delete-forward/join-blocks-with-inline.js +++ b/packages/slate/test/changes/at-current-range/delete-forward/join-blocks-with-inline.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteForward() } diff --git a/packages/slate/test/changes/at-current-range/delete-forward/join-blocks.js b/packages/slate/test/changes/at-current-range/delete-forward/join-blocks.js index dfedf0eea..7d072bfdf 100644 --- a/packages/slate/test/changes/at-current-range/delete-forward/join-blocks.js +++ b/packages/slate/test/changes/at-current-range/delete-forward/join-blocks.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.deleteForward() } @@ -12,9 +12,7 @@ export const input = ( - word + word + word -- another - +another word -- another - +another
- three - four - +four
-diff --git a/packages/slate/test/changes/at-current-range/delete/across-texts-and-inlines.js b/packages/slate/test/changes/at-current-range/delete/across-texts-and-inlines.js index 44a25e553..d57ebc9d1 100644 --- a/packages/slate/test/changes/at-current-range/delete/across-texts-and-inlines.js +++ b/packages/slate/test/changes/at-current-range/delete/across-texts-and-inlines.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.delete() } diff --git a/packages/slate/test/changes/at-current-range/delete/before-inline-sibling.js b/packages/slate/test/changes/at-current-range/delete/before-inline-sibling.js index 9d0fa7f7b..b9122478b 100644 --- a/packages/slate/test/changes/at-current-range/delete/before-inline-sibling.js +++ b/packages/slate/test/changes/at-current-range/delete/before-inline-sibling.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.delete() } @@ -10,7 +10,8 @@ export const input = (- four - +four
diff --git a/packages/slate/test/changes/at-current-range/delete/hanging-selection-single-block.js b/packages/slate/test/changes/at-current-range/delete/hanging-selection-single-block.js index 3b2364eed..1fe732486 100644 --- a/packages/slate/test/changes/at-current-range/delete/hanging-selection-single-block.js +++ b/packages/slate/test/changes/at-current-range/delete/hanging-selection-single-block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.delete() } diff --git a/packages/slate/test/changes/at-current-range/delete/inside-inline-sibling.js b/packages/slate/test/changes/at-current-range/delete/inside-inline-sibling.js index 2f0de19f8..92489226b 100644 --- a/packages/slate/test/changes/at-current-range/delete/inside-inline-sibling.js +++ b/packages/slate/test/changes/at-current-range/delete/inside-inline-sibling.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.delete() } @@ -10,7 +10,9 @@ export const input = (three
diff --git a/packages/slate/test/changes/at-current-range/insert-block/block-middle.js b/packages/slate/test/changes/at-current-range/insert-block/block-middle.js index 2a0b8c462..aa91b5ab5 100644 --- a/packages/slate/test/changes/at-current-range/insert-block/block-middle.js +++ b/packages/slate/test/changes/at-current-range/insert-block/block-middle.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertBlock('quote') } @@ -19,15 +19,11 @@ export const input = ( export const output = (
-
-
-
-
-
-
- one --
- two --
- three -+
one+
two+
three
- two -+
two
diff --git a/packages/slate/test/changes/at-current-range/insert-fragment/end-block.js b/packages/slate/test/changes/at-current-range/insert-fragment/end-block.js index 4dad5aed3..674abb284 100644 --- a/packages/slate/test/changes/at-current-range/insert-fragment/end-block.js +++ b/packages/slate/test/changes/at-current-range/insert-fragment/end-block.js @@ -2,14 +2,12 @@ import h from '../../../helpers/h' -export default function (change) { - change.insertFragment(( +export default function(change) { + change.insertFragment(three
- fragment -+
fragment
- fragment -+
fragment
- one --
- two -+
one+
two
diff --git a/packages/slate/test/changes/at-current-range/insert-fragment/fragment-nested-blocks.js b/packages/slate/test/changes/at-current-range/insert-fragment/fragment-nested-blocks.js index 5ccffa6c1..fd4a9a0ed 100644 --- a/packages/slate/test/changes/at-current-range/insert-fragment/fragment-nested-blocks.js +++ b/packages/slate/test/changes/at-current-range/insert-fragment/fragment-nested-blocks.js @@ -2,19 +2,15 @@ import h from '../../../helpers/h' -export default function (change) { - change.insertFragment(( +export default function(change) { + change.insertFragment(tword
-- one --- two -+one+two
tword diff --git a/packages/slate/test/changes/at-current-range/insert-fragment/middle-block.js b/packages/slate/test/changes/at-current-range/insert-fragment/middle-block.js index fa3759c9a..6ce73c436 100644 --- a/packages/slate/test/changes/at-current-range/insert-fragment/middle-block.js +++ b/packages/slate/test/changes/at-current-range/insert-fragment/middle-block.js @@ -2,14 +2,12 @@ import h from '../../../helpers/h' -export default function (change) { - change.insertFragment(( +export default function(change) { + change.insertFragment( - - )) + ) } export const input = ( diff --git a/packages/slate/test/changes/at-current-range/insert-fragment/middle-inline-fragment-inline.js b/packages/slate/test/changes/at-current-range/insert-fragment/middle-inline-fragment-inline.js index b02ca5125..2432bc152 100644 --- a/packages/slate/test/changes/at-current-range/insert-fragment/middle-inline-fragment-inline.js +++ b/packages/slate/test/changes/at-current-range/insert-fragment/middle-inline-fragment-inline.js @@ -2,21 +2,23 @@ import h from '../../../helpers/h' -export default function (change) { - change.insertFragment(( +export default function(change) { + change.insertFragment(- fragment -+fragment- )) + ) } export const input = ( fragment @@ -27,7 +29,10 @@ export const output = ( - wo rd + + wo rd + diff --git a/packages/slate/test/changes/at-current-range/insert-fragment/middle-inline.js b/packages/slate/test/changes/at-current-range/insert-fragment/middle-inline.js index cc7f32a7d..5d430d878 100644 --- a/packages/slate/test/changes/at-current-range/insert-fragment/middle-inline.js +++ b/packages/slate/test/changes/at-current-range/insert-fragment/middle-inline.js @@ -2,21 +2,21 @@ import h from '../../../helpers/h' -export default function (change) { - change.insertFragment(( +export default function(change) { + change.insertFragment( - wo fragment rd + wo + fragment ++ rd - - )) + ) } export const input = (- fragment -+fragment@@ -26,7 +26,8 @@ export const output = ( - wo rd + + wo rd + diff --git a/packages/slate/test/changes/at-current-range/insert-fragment/nested-block-fragment-nested-blocks.js b/packages/slate/test/changes/at-current-range/insert-fragment/nested-block-fragment-nested-blocks.js index 71ed55aad..33e36133c 100644 --- a/packages/slate/test/changes/at-current-range/insert-fragment/nested-block-fragment-nested-blocks.js +++ b/packages/slate/test/changes/at-current-range/insert-fragment/nested-block-fragment-nested-blocks.js @@ -2,19 +2,15 @@ import h from '../../../helpers/h' -export default function (change) { - change.insertFragment(( +export default function(change) { + change.insertFragment( - wo fragmentrd + wo + fragmentrd - )) + ) } export const input = ( @@ -33,9 +29,7 @@ export const output = ( -- one --- two -+one+twodiff --git a/packages/slate/test/history/undo/wrap-inline-across-blocks.js b/packages/slate/test/history/undo/wrap-inline-across-blocks.js index 0b406fd93..1a1601a59 100644 --- a/packages/slate/test/history/undo/wrap-inline-across-blocks.js +++ b/packages/slate/test/history/undo/wrap-inline-across-blocks.js @@ -2,14 +2,12 @@ import h from '../../helpers/h' -export default function (value) { +export default function(value) { return value .change() .wrapInline('hashtag') - .value - .change() - .undo() - .value + .value.change() + .undo().value } export const input = ( diff --git a/packages/slate/test/index.js b/packages/slate/test/index.js index ebae54271..3924d6b13 100644 --- a/packages/slate/test/index.js +++ b/packages/slate/test/index.js @@ -1,4 +1,3 @@ - /** * Dependencies. */ diff --git a/packages/slate/test/models/change/without-normalization-normalize-flag-false.js b/packages/slate/test/models/change/without-normalization-normalize-flag-false.js index 0967041fd..26b5d6618 100644 --- a/packages/slate/test/models/change/without-normalization-normalize-flag-false.js +++ b/packages/slate/test/models/change/without-normalization-normalize-flag-false.js @@ -2,7 +2,6 @@ import h from '../../helpers/h' - export const flags = { normalize: false } export const schema = { @@ -10,15 +9,13 @@ export const schema = { paragraph: {}, item: { parent: { types: ['list'] }, - nodes: [ - { objects: ['text'] } - ] + nodes: [{ objects: ['text'] }], }, list: {}, - } + }, } -export const customChange = (change) => { +export const customChange = change => { // this change function and schema are designed such that if // validation takes place before both wrapBlock calls complete // the node gets deleted by the default schema diff --git a/packages/slate/test/models/change/without-normalization-normalize-flag-true.js b/packages/slate/test/models/change/without-normalization-normalize-flag-true.js index 671bbea62..d89098c35 100644 --- a/packages/slate/test/models/change/without-normalization-normalize-flag-true.js +++ b/packages/slate/test/models/change/without-normalization-normalize-flag-true.js @@ -2,7 +2,6 @@ import h from '../../helpers/h' - export const flags = { normalize: true } export const schema = { @@ -10,15 +9,13 @@ export const schema = { paragraph: {}, item: { parent: { types: ['list'] }, - nodes: [ - { objects: ['text'] } - ] + nodes: [{ objects: ['text'] }], }, list: {}, - } + }, } -export const customChange = (change) => { +export const customChange = change => { // this change function and schema are designed such that if // validation takes place before both wrapBlock calls complete // the node gets deleted by the default schema diff --git a/packages/slate/test/models/change/without-normalization-option-override.js b/packages/slate/test/models/change/without-normalization-option-override.js index fd56859be..3f3865972 100644 --- a/packages/slate/test/models/change/without-normalization-option-override.js +++ b/packages/slate/test/models/change/without-normalization-option-override.js @@ -2,23 +2,20 @@ import h from '../../helpers/h' - -export const flags = { } +export const flags = {} export const schema = { blocks: { paragraph: {}, item: { parent: { types: ['list'] }, - nodes: [ - { objects: ['text'] } - ] + nodes: [{ objects: ['text'] }], }, list: {}, - } + }, } -export const customChange = (change) => { +export const customChange = change => { // see if we can break the expected validation sequence by toggling // the normalization option const target = change.value.document.nodes.get(0) diff --git a/packages/slate/test/models/change/without-normalization.js b/packages/slate/test/models/change/without-normalization.js index d55edc4ee..511553414 100644 --- a/packages/slate/test/models/change/without-normalization.js +++ b/packages/slate/test/models/change/without-normalization.js @@ -2,22 +2,20 @@ import h from '../../helpers/h' -export const flags = { } +export const flags = {} export const schema = { blocks: { paragraph: {}, item: { parent: { types: ['list'] }, - nodes: [ - { objects: ['text'] } - ] + nodes: [{ objects: ['text'] }], }, list: {}, - } + }, } -export const customChange = (change) => { +export const customChange = change => { // this change function and schema are designed such that if // validation takes place before both wrapBlock calls complete // the node gets deleted by the default schema diff --git a/packages/slate/test/models/index.js b/packages/slate/test/models/index.js index d8a722ad0..788a4bd5c 100644 --- a/packages/slate/test/models/index.js +++ b/packages/slate/test/models/index.js @@ -1,4 +1,3 @@ - import assert from 'assert' import fs from 'fs' import { Schema } from '../..' @@ -12,7 +11,10 @@ describe('models', () => { describe('change', () => { describe('withoutNormalization', () => { const testsDir = resolve(__dirname, 'change') - const tests = fs.readdirSync(testsDir).filter(t => t[0] != '.').map(t => basename(t, extname(t))) + const tests = fs + .readdirSync(testsDir) + .filter(t => t[0] != '.') + .map(t => basename(t, extname(t))) for (const test of tests) { it(test, async () => { diff --git a/packages/slate/test/operations/apply/remove_text/cursor-inside-removed-text.js b/packages/slate/test/operations/apply/remove_text/cursor-inside-removed-text.js index cfc446704..2e86f4e79 100644 --- a/packages/slate/test/operations/apply/remove_text/cursor-inside-removed-text.js +++ b/packages/slate/test/operations/apply/remove_text/cursor-inside-removed-text.js @@ -2,13 +2,15 @@ import h from '../../../helpers/h' -export default [{ - type: 'remove_text', - path: [0, 0], - offset: 2, - text: 'is is some text inside ', - marks: [] -}] +export default [ + { + type: 'remove_text', + path: [0, 0], + offset: 2, + text: 'is is some text inside ', + marks: [], + }, +] export const input = ( -- woone - +woone tword diff --git a/packages/slate/test/changes/at-current-range/insert-fragment/start-block-multiple-blocks.js b/packages/slate/test/changes/at-current-range/insert-fragment/start-block-multiple-blocks.js index e233402a9..c543c9387 100644 --- a/packages/slate/test/changes/at-current-range/insert-fragment/start-block-multiple-blocks.js +++ b/packages/slate/test/changes/at-current-range/insert-fragment/start-block-multiple-blocks.js @@ -2,20 +2,14 @@ import h from '../../../helpers/h' -export default function (change) { - change.insertFragment(( +export default function(change) { + change.insertFragment( - - )) + ) } export const input = ( @@ -31,12 +25,8 @@ export const input = ( export const output = (- one --- two --- three -+one+two+three) @@ -28,9 +24,7 @@ export const output = ( - - one - -- two -+one +twodiff --git a/packages/slate/test/changes/at-current-range/insert-fragment/start-block.js b/packages/slate/test/changes/at-current-range/insert-fragment/start-block.js index a7d5b3ebd..bae71e656 100644 --- a/packages/slate/test/changes/at-current-range/insert-fragment/start-block.js +++ b/packages/slate/test/changes/at-current-range/insert-fragment/start-block.js @@ -2,14 +2,12 @@ import h from '../../../helpers/h' -export default function (change) { - change.insertFragment(( +export default function(change) { + change.insertFragment(threeword - - )) + ) } export const input = ( diff --git a/packages/slate/test/changes/at-current-range/insert-fragment/start-inline.js b/packages/slate/test/changes/at-current-range/insert-fragment/start-inline.js index b99cfa063..ce71ead8e 100644 --- a/packages/slate/test/changes/at-current-range/insert-fragment/start-inline.js +++ b/packages/slate/test/changes/at-current-range/insert-fragment/start-inline.js @@ -2,21 +2,21 @@ import h from '../../../helpers/h' -export default function (change) { - change.insertFragment(( +export default function(change) { + change.insertFragment(- fragment -+fragment- - )) + ) } export const input = (- fragment -+fragment@@ -26,7 +26,9 @@ export const output = ( - word + + word + diff --git a/packages/slate/test/changes/at-current-range/insert-fragment/start-second-block.js b/packages/slate/test/changes/at-current-range/insert-fragment/start-second-block.js index 745633b43..d01d00a70 100644 --- a/packages/slate/test/changes/at-current-range/insert-fragment/start-second-block.js +++ b/packages/slate/test/changes/at-current-range/insert-fragment/start-second-block.js @@ -2,22 +2,18 @@ import h from '../../../helpers/h' -export default function (change) { - change.insertFragment(( +export default function(change) { + change.insertFragment( - fragment word + fragment + word + - - )) + ) } export const input = (- fragment -+fragmentdiff --git a/packages/slate/test/changes/at-current-range/unwrap-block/with-object.js b/packages/slate/test/changes/at-current-range/unwrap-block/with-object.js index ea9de3cec..20a75f4a8 100644 --- a/packages/slate/test/changes/at-current-range/unwrap-block/with-object.js +++ b/packages/slate/test/changes/at-current-range/unwrap-block/with-object.js @@ -2,10 +2,10 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.unwrapBlock({ type: 'quote', - data: { thing: 'value' } + data: { thing: 'value' }, }) } @@ -13,9 +13,7 @@ export const input = ( - - word - +word @@ -28,9 +24,7 @@ export const input = ( export const output = ( another ) @@ -22,15 +20,11 @@ export const input = ( export const output = ( - - word - +word diff --git a/packages/slate/test/changes/at-current-range/insert-fragment/with-delete-across-blocks.js b/packages/slate/test/changes/at-current-range/insert-fragment/with-delete-across-blocks.js index 8cff3b8ee..e3c551538 100644 --- a/packages/slate/test/changes/at-current-range/insert-fragment/with-delete-across-blocks.js +++ b/packages/slate/test/changes/at-current-range/insert-fragment/with-delete-across-blocks.js @@ -2,14 +2,12 @@ import h from '../../../helpers/h' -export default function (change) { - change.insertFragment(( +export default function(change) { + change.insertFragment( fragmentanother - - )) + ) } export const input = ( diff --git a/packages/slate/test/changes/at-current-range/insert-inline/block-end.js b/packages/slate/test/changes/at-current-range/insert-inline/block-end.js index 26973d263..147355711 100644 --- a/packages/slate/test/changes/at-current-range/insert-inline/block-end.js +++ b/packages/slate/test/changes/at-current-range/insert-inline/block-end.js @@ -2,10 +2,10 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertInline({ type: 'emoji', - isVoid: true + isVoid: true, }) } @@ -23,7 +23,10 @@ export const output = (- fragment -+fragmentdiff --git a/packages/slate/test/changes/at-current-range/insert-inline/block-middle.js b/packages/slate/test/changes/at-current-range/insert-inline/block-middle.js index ed21fb720..294a7ea4a 100644 --- a/packages/slate/test/changes/at-current-range/insert-inline/block-middle.js +++ b/packages/slate/test/changes/at-current-range/insert-inline/block-middle.js @@ -2,17 +2,19 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertInline({ type: 'emoji', - isVoid: true + isVoid: true, }) } export const input = ( - word {' '} + word+ {' '} + + ) @@ -21,7 +23,10 @@ export const output = ( - wo +rd + wo rd + diff --git a/packages/slate/test/changes/at-current-range/insert-inline/block-start.js b/packages/slate/test/changes/at-current-range/insert-inline/block-start.js index 5b5c202f8..f72bd8567 100644 --- a/packages/slate/test/changes/at-current-range/insert-inline/block-start.js +++ b/packages/slate/test/changes/at-current-range/insert-inline/block-start.js @@ -2,10 +2,10 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertInline({ type: 'emoji', - isVoid: true + isVoid: true, }) } @@ -23,7 +23,10 @@ export const output = ( - wo {' '} rd + wo+ {' '} + rd+ diff --git a/packages/slate/test/changes/at-current-range/insert-inline/inline-middle.js b/packages/slate/test/changes/at-current-range/insert-inline/inline-middle.js index f58d167ff..8414eb7c0 100644 --- a/packages/slate/test/changes/at-current-range/insert-inline/inline-middle.js +++ b/packages/slate/test/changes/at-current-range/insert-inline/inline-middle.js @@ -2,10 +2,10 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertInline({ type: 'emoji', - isVoid: true + isVoid: true, }) } @@ -13,7 +13,9 @@ export const input = ( - {' '} word ++ {' '} + word+ @@ -23,7 +25,12 @@ export const output = ( - wo rd + + wo rd + diff --git a/packages/slate/test/changes/at-current-range/insert-inline/is-empty.js b/packages/slate/test/changes/at-current-range/insert-inline/is-empty.js index 006d843b2..e696168ac 100644 --- a/packages/slate/test/changes/at-current-range/insert-inline/is-empty.js +++ b/packages/slate/test/changes/at-current-range/insert-inline/is-empty.js @@ -2,10 +2,10 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertInline({ type: 'emoji', - isVoid: true + isVoid: true, }) } @@ -23,7 +23,10 @@ export const output = ( - wo {' '} rd + + wo+ {' '} + rd ++ diff --git a/packages/slate/test/changes/at-current-range/insert-inline/is-void.js b/packages/slate/test/changes/at-current-range/insert-inline/is-void.js index 92c7af714..8b4ab3900 100644 --- a/packages/slate/test/changes/at-current-range/insert-inline/is-void.js +++ b/packages/slate/test/changes/at-current-range/insert-inline/is-void.js @@ -2,10 +2,10 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertInline({ type: 'emoji', - isVoid: true + isVoid: true, }) } diff --git a/packages/slate/test/changes/at-current-range/insert-inline/with-inline.js b/packages/slate/test/changes/at-current-range/insert-inline/with-inline.js index 147655748..08b8ff562 100644 --- a/packages/slate/test/changes/at-current-range/insert-inline/with-inline.js +++ b/packages/slate/test/changes/at-current-range/insert-inline/with-inline.js @@ -3,17 +3,21 @@ import h from '../../../helpers/h' import { Inline } from '../../../..' -export default function (change) { - change.insertInline(Inline.create({ - type: 'emoji', - isVoid: true - })) +export default function(change) { + change.insertInline( + Inline.create({ + type: 'emoji', + isVoid: true, + }) + ) } export const input = ( - {' '} ++ {' '} + + ) @@ -22,7 +26,10 @@ export const output = ( - wo +rd + wo rd + diff --git a/packages/slate/test/changes/at-current-range/insert-text/after-mark.js b/packages/slate/test/changes/at-current-range/insert-text/after-mark.js index dc6b30d84..90e4bc46b 100644 --- a/packages/slate/test/changes/at-current-range/insert-text/after-mark.js +++ b/packages/slate/test/changes/at-current-range/insert-text/after-mark.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertText('a') } @@ -10,7 +10,9 @@ export const input = ( - wo {' '} rd + wo+ {' '} + rd+ @@ -20,7 +22,9 @@ export const output = ( - wor d + w + or + d diff --git a/packages/slate/test/changes/at-current-range/insert-text/before-mark.js b/packages/slate/test/changes/at-current-range/insert-text/before-mark.js index d5466e50b..c568f4a2d 100644 --- a/packages/slate/test/changes/at-current-range/insert-text/before-mark.js +++ b/packages/slate/test/changes/at-current-range/insert-text/before-mark.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertText('a') } @@ -10,7 +10,8 @@ export const input = ( - wora d + w + ora + d @@ -20,7 +21,8 @@ export const output = ( - w ord + w + ord diff --git a/packages/slate/test/changes/at-current-range/insert-text/during-mark.js b/packages/slate/test/changes/at-current-range/insert-text/during-mark.js index 4b0f8fade..f30165b02 100644 --- a/packages/slate/test/changes/at-current-range/insert-text/during-mark.js +++ b/packages/slate/test/changes/at-current-range/insert-text/during-mark.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertText('a') } @@ -10,7 +10,9 @@ export const input = ( - wa ord + wa + ord @@ -20,7 +22,9 @@ export const output = ( - wo rd + w + o r + d diff --git a/packages/slate/test/changes/at-current-range/insert-text/first-character.js b/packages/slate/test/changes/at-current-range/insert-text/first-character.js index 48d375405..d8d02a9df 100644 --- a/packages/slate/test/changes/at-current-range/insert-text/first-character.js +++ b/packages/slate/test/changes/at-current-range/insert-text/first-character.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertText('a') } diff --git a/packages/slate/test/changes/at-current-range/insert-text/first-space.js b/packages/slate/test/changes/at-current-range/insert-text/first-space.js index ad00cdd48..92817174c 100644 --- a/packages/slate/test/changes/at-current-range/insert-text/first-space.js +++ b/packages/slate/test/changes/at-current-range/insert-text/first-space.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertText(' ') } @@ -20,7 +20,8 @@ export const output = ( - woa rd + w + oa r + d diff --git a/packages/slate/test/changes/at-current-range/insert-text/first-words.js b/packages/slate/test/changes/at-current-range/insert-text/first-words.js index b0a6103f9..585c1ec88 100644 --- a/packages/slate/test/changes/at-current-range/insert-text/first-words.js +++ b/packages/slate/test/changes/at-current-range/insert-text/first-words.js @@ -2,14 +2,16 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertText('a few words') } export const input = ( - {' '} word + {' '} + word ) diff --git a/packages/slate/test/changes/at-current-range/insert-text/hanging-selection-multiple-blocks.js b/packages/slate/test/changes/at-current-range/insert-text/hanging-selection-multiple-blocks.js index 369975c60..abbbb1145 100644 --- a/packages/slate/test/changes/at-current-range/insert-text/hanging-selection-multiple-blocks.js +++ b/packages/slate/test/changes/at-current-range/insert-text/hanging-selection-multiple-blocks.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertText('a') } @@ -12,9 +12,7 @@ export const input = ( - + word + word + - one - two - +two diff --git a/packages/slate/test/changes/at-current-range/insert-text/hanging-selection-single-block.js b/packages/slate/test/changes/at-current-range/insert-text/hanging-selection-single-block.js index 69e803420..1dcd13263 100644 --- a/packages/slate/test/changes/at-current-range/insert-text/hanging-selection-single-block.js +++ b/packages/slate/test/changes/at-current-range/insert-text/hanging-selection-single-block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertText('a') } diff --git a/packages/slate/test/changes/at-current-range/insert-text/inside-void.js b/packages/slate/test/changes/at-current-range/insert-text/inside-void.js index 93946cd19..79640d8c8 100644 --- a/packages/slate/test/changes/at-current-range/insert-text/inside-void.js +++ b/packages/slate/test/changes/at-current-range/insert-text/inside-void.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertText('a') } diff --git a/packages/slate/test/changes/at-current-range/insert-text/last-character.js b/packages/slate/test/changes/at-current-range/insert-text/last-character.js index 96e1770a4..902a342d4 100644 --- a/packages/slate/test/changes/at-current-range/insert-text/last-character.js +++ b/packages/slate/test/changes/at-current-range/insert-text/last-character.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertText('a') } diff --git a/packages/slate/test/changes/at-current-range/insert-text/last-space.js b/packages/slate/test/changes/at-current-range/insert-text/last-space.js index 2bc9cd903..b5a045735 100644 --- a/packages/slate/test/changes/at-current-range/insert-text/last-space.js +++ b/packages/slate/test/changes/at-current-range/insert-text/last-space.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertText(' ') } diff --git a/packages/slate/test/changes/at-current-range/insert-text/last-words.js b/packages/slate/test/changes/at-current-range/insert-text/last-words.js index 97374ddfb..b144919c4 100644 --- a/packages/slate/test/changes/at-current-range/insert-text/last-words.js +++ b/packages/slate/test/changes/at-current-range/insert-text/last-words.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertText(' a few words') } diff --git a/packages/slate/test/changes/at-current-range/insert-text/middle-character.js b/packages/slate/test/changes/at-current-range/insert-text/middle-character.js index a3f0ffe47..86f7e1f6f 100644 --- a/packages/slate/test/changes/at-current-range/insert-text/middle-character.js +++ b/packages/slate/test/changes/at-current-range/insert-text/middle-character.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertText('a') } diff --git a/packages/slate/test/changes/at-current-range/insert-text/middle-space.js b/packages/slate/test/changes/at-current-range/insert-text/middle-space.js index cea5b4614..f63eae718 100644 --- a/packages/slate/test/changes/at-current-range/insert-text/middle-space.js +++ b/packages/slate/test/changes/at-current-range/insert-text/middle-space.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertText(' ') } diff --git a/packages/slate/test/changes/at-current-range/insert-text/middle-words.js b/packages/slate/test/changes/at-current-range/insert-text/middle-words.js index 3bd47f8f0..dcb8a21e6 100644 --- a/packages/slate/test/changes/at-current-range/insert-text/middle-words.js +++ b/packages/slate/test/changes/at-current-range/insert-text/middle-words.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertText(' a few words ') } diff --git a/packages/slate/test/changes/at-current-range/insert-text/with-marks.js b/packages/slate/test/changes/at-current-range/insert-text/with-marks.js index 35a47f58e..f9f35765c 100644 --- a/packages/slate/test/changes/at-current-range/insert-text/with-marks.js +++ b/packages/slate/test/changes/at-current-range/insert-text/with-marks.js @@ -3,7 +3,7 @@ import h from '../../../helpers/h' import { Mark } from '../../../..' -export default function (change) { +export default function(change) { const marks = Mark.createSet([{ type: 'bold' }]) change.insertText('a', marks) } @@ -22,7 +22,8 @@ export const output = (three diff --git a/packages/slate/test/changes/at-current-range/remove-mark/across-blocks.js b/packages/slate/test/changes/at-current-range/remove-mark/across-blocks.js index f7c6e5fed..61b29470e 100644 --- a/packages/slate/test/changes/at-current-range/remove-mark/across-blocks.js +++ b/packages/slate/test/changes/at-current-range/remove-mark/across-blocks.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.removeMark('bold') } @@ -10,10 +10,12 @@ export const input = ( - worda + worda + diff --git a/packages/slate/test/changes/at-current-range/remove-mark/across-inlines.js b/packages/slate/test/changes/at-current-range/remove-mark/across-inlines.js index 84944a353..32bb08b7d 100644 --- a/packages/slate/test/changes/at-current-range/remove-mark/across-inlines.js +++ b/packages/slate/test/changes/at-current-range/remove-mark/across-inlines.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.removeMark('bold') } @@ -10,10 +10,16 @@ export const input = ( - wo rd + wo + rd - an other + an + other @@ -23,10 +29,14 @@ export const output = ( - wo rd + + wo + rd + - an other + + an + other + diff --git a/packages/slate/test/changes/at-current-range/remove-mark/collapsed-selection.js b/packages/slate/test/changes/at-current-range/remove-mark/collapsed-selection.js index 2fa83fdbd..86c3a6c70 100644 --- a/packages/slate/test/changes/at-current-range/remove-mark/collapsed-selection.js +++ b/packages/slate/test/changes/at-current-range/remove-mark/collapsed-selection.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change .addMark('bold') .removeMark('bold') diff --git a/packages/slate/test/changes/at-current-range/remove-mark/existing-marks.js b/packages/slate/test/changes/at-current-range/remove-mark/existing-marks.js index f32d5536e..aa5d2f511 100644 --- a/packages/slate/test/changes/at-current-range/remove-mark/existing-marks.js +++ b/packages/slate/test/changes/at-current-range/remove-mark/existing-marks.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.removeMark('bold') } @@ -10,7 +10,12 @@ export const input = ( - wo rd + + wo rd + - an other + + an other + @@ -20,7 +25,9 @@ export const output = ( - wo rd + + + wo + + + rd diff --git a/packages/slate/test/changes/at-current-range/remove-mark/first-character.js b/packages/slate/test/changes/at-current-range/remove-mark/first-character.js index f91c1b343..9b9bc8052 100644 --- a/packages/slate/test/changes/at-current-range/remove-mark/first-character.js +++ b/packages/slate/test/changes/at-current-range/remove-mark/first-character.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.removeMark('bold') } @@ -10,7 +10,9 @@ export const input = ( - wo rd + + wo rd + diff --git a/packages/slate/test/changes/at-current-range/remove-mark/last-character.js b/packages/slate/test/changes/at-current-range/remove-mark/last-character.js index a6f28891c..283e0c473 100644 --- a/packages/slate/test/changes/at-current-range/remove-mark/last-character.js +++ b/packages/slate/test/changes/at-current-range/remove-mark/last-character.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.removeMark('bold') } @@ -10,7 +10,9 @@ export const input = ( - w ord + + w + ord diff --git a/packages/slate/test/changes/at-current-range/remove-mark/middle-character.js b/packages/slate/test/changes/at-current-range/remove-mark/middle-character.js index 5dffa8f4a..5589a7b3e 100644 --- a/packages/slate/test/changes/at-current-range/remove-mark/middle-character.js +++ b/packages/slate/test/changes/at-current-range/remove-mark/middle-character.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.removeMark('bold') } @@ -10,7 +10,9 @@ export const input = ( - wor d + wor + d + diff --git a/packages/slate/test/changes/at-current-range/remove-mark/whole-word.js b/packages/slate/test/changes/at-current-range/remove-mark/whole-word.js index 8466e8d45..27b98093e 100644 --- a/packages/slate/test/changes/at-current-range/remove-mark/whole-word.js +++ b/packages/slate/test/changes/at-current-range/remove-mark/whole-word.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.removeMark('bold') } @@ -10,7 +10,9 @@ export const input = ( - w o rd + w + o + rd diff --git a/packages/slate/test/changes/at-current-range/remove-mark/with-mark-object.js b/packages/slate/test/changes/at-current-range/remove-mark/with-mark-object.js index e18e9ed31..0deab0213 100644 --- a/packages/slate/test/changes/at-current-range/remove-mark/with-mark-object.js +++ b/packages/slate/test/changes/at-current-range/remove-mark/with-mark-object.js @@ -3,18 +3,22 @@ import h from '../../../helpers/h' import { Mark } from '../../../..' -export default function (change) { - change.removeMark(Mark.create({ - type: 'bold', - data: { thing: 'value' } - })) +export default function(change) { + change.removeMark( + Mark.create({ + type: 'bold', + data: { thing: 'value' }, + }) + ) } export const input = ( - word + + word + diff --git a/packages/slate/test/changes/at-current-range/remove-mark/with-plain-object.js b/packages/slate/test/changes/at-current-range/remove-mark/with-plain-object.js index 3eed5ab75..29e501305 100644 --- a/packages/slate/test/changes/at-current-range/remove-mark/with-plain-object.js +++ b/packages/slate/test/changes/at-current-range/remove-mark/with-plain-object.js @@ -2,10 +2,10 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.removeMark({ type: 'bold', - data: { thing: 'value' } + data: { thing: 'value' }, }) } @@ -13,7 +13,9 @@ export const input = ( - w ord + + w + ord diff --git a/packages/slate/test/changes/at-current-range/set-block/across-blocks.js b/packages/slate/test/changes/at-current-range/set-block/across-blocks.js index ccd718f6d..f8aa5ad34 100644 --- a/packages/slate/test/changes/at-current-range/set-block/across-blocks.js +++ b/packages/slate/test/changes/at-current-range/set-block/across-blocks.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.setBlock({ type: 'code' }) } diff --git a/packages/slate/test/changes/at-current-range/set-block/across-inlines.js b/packages/slate/test/changes/at-current-range/set-block/across-inlines.js index 8e74535bd..6c0fe2dbf 100644 --- a/packages/slate/test/changes/at-current-range/set-block/across-inlines.js +++ b/packages/slate/test/changes/at-current-range/set-block/across-inlines.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.setBlock({ type: 'code' }) } @@ -10,10 +10,14 @@ export const input = ( - w ord + + w + ord @@ -23,10 +27,14 @@ export const output = ( - word + + word + - another + + another + diff --git a/packages/slate/test/changes/at-current-range/set-block/data-only.js b/packages/slate/test/changes/at-current-range/set-block/data-only.js index 34f5972da..b1a7a0060 100644 --- a/packages/slate/test/changes/at-current-range/set-block/data-only.js +++ b/packages/slate/test/changes/at-current-range/set-block/data-only.js @@ -4,8 +4,7 @@ import h from '../../../helpers/h' import { Data } from '../../../..' - -export default function (change) { +export default function(change) { change.setBlock({ data: Data.create({ thing: 'value' }) }) } diff --git a/packages/slate/test/changes/at-current-range/set-block/nested-block.js b/packages/slate/test/changes/at-current-range/set-block/nested-block.js index bd9b5274f..8c7d0721b 100644 --- a/packages/slate/test/changes/at-current-range/set-block/nested-block.js +++ b/packages/slate/test/changes/at-current-range/set-block/nested-block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.setBlock({ type: 'code' }) } diff --git a/packages/slate/test/changes/at-current-range/set-block/single-block-string-shorthand.js b/packages/slate/test/changes/at-current-range/set-block/single-block-string-shorthand.js index bef060241..a0bcb2f80 100644 --- a/packages/slate/test/changes/at-current-range/set-block/single-block-string-shorthand.js +++ b/packages/slate/test/changes/at-current-range/set-block/single-block-string-shorthand.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.setBlock('code') } diff --git a/packages/slate/test/changes/at-current-range/set-block/single-block.js b/packages/slate/test/changes/at-current-range/set-block/single-block.js index 10eca9933..282cb9076 100644 --- a/packages/slate/test/changes/at-current-range/set-block/single-block.js +++ b/packages/slate/test/changes/at-current-range/set-block/single-block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.setBlock({ type: 'code' }) } diff --git a/packages/slate/test/changes/at-current-range/set-block/with-data-as-map.js b/packages/slate/test/changes/at-current-range/set-block/with-data-as-map.js index 9decbbf5d..8b1cc485b 100644 --- a/packages/slate/test/changes/at-current-range/set-block/with-data-as-map.js +++ b/packages/slate/test/changes/at-current-range/set-block/with-data-as-map.js @@ -3,10 +3,10 @@ import h from '../../../helpers/h' import { Data } from '../../../..' -export default function (change) { +export default function(change) { change.setBlock({ type: 'code', - data: Data.create({ thing: 'value' }) + data: Data.create({ thing: 'value' }), }) } diff --git a/packages/slate/test/changes/at-current-range/set-block/with-data-as-object.js b/packages/slate/test/changes/at-current-range/set-block/with-data-as-object.js index c087617fb..db7c44e5d 100644 --- a/packages/slate/test/changes/at-current-range/set-block/with-data-as-object.js +++ b/packages/slate/test/changes/at-current-range/set-block/with-data-as-object.js @@ -2,10 +2,10 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.setBlock({ type: 'code', - data: { thing: 'value' } + data: { thing: 'value' }, }) } diff --git a/packages/slate/test/changes/at-current-range/set-block/with-is-void.js b/packages/slate/test/changes/at-current-range/set-block/with-is-void.js index 5acf294a0..e58bfaf40 100644 --- a/packages/slate/test/changes/at-current-range/set-block/with-is-void.js +++ b/packages/slate/test/changes/at-current-range/set-block/with-is-void.js @@ -2,10 +2,10 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.setBlock({ type: 'image', - isVoid: true + isVoid: true, }) } diff --git a/packages/slate/test/changes/at-current-range/set-inline/across-inlines.js b/packages/slate/test/changes/at-current-range/set-inline/across-inlines.js index 92c90ac05..f2fb9378e 100644 --- a/packages/slate/test/changes/at-current-range/set-inline/across-inlines.js +++ b/packages/slate/test/changes/at-current-range/set-inline/across-inlines.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.setInline({ type: 'hashtag' }) } @@ -10,10 +10,14 @@ export const input = ( -
word + + word + -
another + + another + @@ -23,10 +27,14 @@ export const output = ( - word + + word + - another + + another + diff --git a/packages/slate/test/changes/at-current-range/set-inline/data-only.js b/packages/slate/test/changes/at-current-range/set-inline/data-only.js index 2bf693b91..2ac1a9355 100644 --- a/packages/slate/test/changes/at-current-range/set-inline/data-only.js +++ b/packages/slate/test/changes/at-current-range/set-inline/data-only.js @@ -3,7 +3,7 @@ import h from '../../../helpers/h' import { Data } from '../../../..' -export default function (change) { +export default function(change) { change.setInline({ data: Data.create({ thing: 'value' }) }) } @@ -11,7 +11,9 @@ export const input = ( - + word + word + - + another + another + @@ -21,7 +23,9 @@ export const output = ( - word + + word + diff --git a/packages/slate/test/changes/at-current-range/set-inline/nested-inline.js b/packages/slate/test/changes/at-current-range/set-inline/nested-inline.js index 5353f71e0..cffc55510 100644 --- a/packages/slate/test/changes/at-current-range/set-inline/nested-inline.js +++ b/packages/slate/test/changes/at-current-range/set-inline/nested-inline.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.setInline({ type: 'comment' }) } @@ -11,7 +11,9 @@ export const input = ( - word + + word + @@ -23,7 +25,9 @@ export const output = ( - word + + word + diff --git a/packages/slate/test/changes/at-current-range/set-inline/single-inline-string-shorthand.js b/packages/slate/test/changes/at-current-range/set-inline/single-inline-string-shorthand.js index 6c07514d0..7c9be6522 100644 --- a/packages/slate/test/changes/at-current-range/set-inline/single-inline-string-shorthand.js +++ b/packages/slate/test/changes/at-current-range/set-inline/single-inline-string-shorthand.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.setInline('hashtag') } @@ -10,7 +10,9 @@ export const input = ( - + word + word + @@ -20,7 +22,9 @@ export const output = ( - word + + word + diff --git a/packages/slate/test/changes/at-current-range/set-inline/single-inline.js b/packages/slate/test/changes/at-current-range/set-inline/single-inline.js index 2c9163c83..dc8bdeb95 100644 --- a/packages/slate/test/changes/at-current-range/set-inline/single-inline.js +++ b/packages/slate/test/changes/at-current-range/set-inline/single-inline.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.setInline({ type: 'hashtag' }) } @@ -10,7 +10,9 @@ export const input = ( - + word + word + @@ -20,7 +22,9 @@ export const output = ( - word + + word + diff --git a/packages/slate/test/changes/at-current-range/set-inline/with-data-object.js b/packages/slate/test/changes/at-current-range/set-inline/with-data-object.js index 44c3de3c9..2df2f1f12 100644 --- a/packages/slate/test/changes/at-current-range/set-inline/with-data-object.js +++ b/packages/slate/test/changes/at-current-range/set-inline/with-data-object.js @@ -2,10 +2,10 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.setInline({ type: 'hashtag', - data: { thing: 'value' } + data: { thing: 'value' }, }) } @@ -13,7 +13,9 @@ export const input = ( - + word + word + @@ -23,7 +25,9 @@ export const output = ( - word + + word + diff --git a/packages/slate/test/changes/at-current-range/set-inline/with-data.js b/packages/slate/test/changes/at-current-range/set-inline/with-data.js index 0a41236fb..d79fd6f86 100644 --- a/packages/slate/test/changes/at-current-range/set-inline/with-data.js +++ b/packages/slate/test/changes/at-current-range/set-inline/with-data.js @@ -3,10 +3,10 @@ import h from '../../../helpers/h' import { Data } from '../../../..' -export default function (change) { +export default function(change) { change.setInline({ type: 'hashtag', - data: Data.create({ thing: 'value' }) + data: Data.create({ thing: 'value' }), }) } @@ -14,7 +14,9 @@ export const input = ( - + word + word + @@ -24,7 +26,9 @@ export const output = ( - word + + word + diff --git a/packages/slate/test/changes/at-current-range/set-inline/with-is-void.js b/packages/slate/test/changes/at-current-range/set-inline/with-is-void.js index 912fb8366..bc3a6f521 100644 --- a/packages/slate/test/changes/at-current-range/set-inline/with-is-void.js +++ b/packages/slate/test/changes/at-current-range/set-inline/with-is-void.js @@ -2,10 +2,10 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.setInline({ type: 'emoji', - isVoid: true + isVoid: true, }) } @@ -13,7 +13,9 @@ export const input = ( - + word + word + @@ -24,7 +26,8 @@ export const output = ( - word + + word + diff --git a/packages/slate/test/changes/at-current-range/split-block/after-inline-void.js b/packages/slate/test/changes/at-current-range/split-block/after-inline-void.js index 1aa9b8098..b859f83f7 100644 --- a/packages/slate/test/changes/at-current-range/split-block/after-inline-void.js +++ b/packages/slate/test/changes/at-current-range/split-block/after-inline-void.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.splitBlock() } @@ -10,7 +10,8 @@ export const input = ( - {' '} ++ diff --git a/packages/slate/test/changes/at-current-range/split-block/after-inline.js b/packages/slate/test/changes/at-current-range/split-block/after-inline.js index 8aae8e4ad..7c1d142e3 100644 --- a/packages/slate/test/changes/at-current-range/split-block/after-inline.js +++ b/packages/slate/test/changes/at-current-range/split-block/after-inline.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.splitBlock() } @@ -10,7 +10,8 @@ export const input = ( - one two + one + two diff --git a/packages/slate/test/changes/at-current-range/split-block/before-inline.js b/packages/slate/test/changes/at-current-range/split-block/before-inline.js index baacba20c..3f5748023 100644 --- a/packages/slate/test/changes/at-current-range/split-block/before-inline.js +++ b/packages/slate/test/changes/at-current-range/split-block/before-inline.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.splitBlock() } @@ -10,7 +10,9 @@ export const input = ( - wordhyperlink word + wordhyperlink + word @@ -19,11 +21,11 @@ export const input = ( export const output = ( - word hyperlinkword + word + hyperlink + word diff --git a/packages/slate/test/changes/at-current-range/split-block/block-end.js b/packages/slate/test/changes/at-current-range/split-block/block-end.js index 9aad74825..655f721fe 100644 --- a/packages/slate/test/changes/at-current-range/split-block/block-end.js +++ b/packages/slate/test/changes/at-current-range/split-block/block-end.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.splitBlock() } @@ -12,9 +12,7 @@ export const input = ( + word - word - -- hyperlinkword + + hyperlink + word word -- another - +another ) diff --git a/packages/slate/test/changes/at-current-range/split-block/block-middle.js b/packages/slate/test/changes/at-current-range/split-block/block-middle.js index 40597bff8..cc2f15d6f 100644 --- a/packages/slate/test/changes/at-current-range/split-block/block-middle.js +++ b/packages/slate/test/changes/at-current-range/split-block/block-middle.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.splitBlock() } @@ -19,9 +19,7 @@ export const input = ( export const output = ( - - word - +word - - another - +another diff --git a/packages/slate/test/changes/at-current-range/split-inline/block-end.js b/packages/slate/test/changes/at-current-range/split-inline/block-end.js index 28bae6fd9..4cfffa337 100644 --- a/packages/slate/test/changes/at-current-range/split-inline/block-end.js +++ b/packages/slate/test/changes/at-current-range/split-inline/block-end.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.splitInline() } @@ -10,7 +10,9 @@ export const input = ( - - wo - +wo diff --git a/packages/slate/test/changes/at-current-range/split-block/block-start.js b/packages/slate/test/changes/at-current-range/split-block/block-start.js index c5d42d617..5effb8315 100644 --- a/packages/slate/test/changes/at-current-range/split-block/block-start.js +++ b/packages/slate/test/changes/at-current-range/split-block/block-start.js @@ -2,16 +2,14 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.splitBlock() } export const input = ( rd diff --git a/packages/slate/test/changes/at-current-range/split-block/with-delete-across-blocks.js b/packages/slate/test/changes/at-current-range/split-block/with-delete-across-blocks.js index 7c061ab58..432384140 100644 --- a/packages/slate/test/changes/at-current-range/split-block/with-delete-across-blocks.js +++ b/packages/slate/test/changes/at-current-range/split-block/with-delete-across-blocks.js @@ -2,15 +2,19 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.splitBlock() } export const input = ( - - word - +word @@ -22,9 +20,7 @@ export const input = ( export const output = ( another - diff --git a/packages/slate/test/changes/at-current-range/split-block/with-delete-across-blocks-and-inlines.js b/packages/slate/test/changes/at-current-range/split-block/with-delete-across-blocks-and-inlines.js index f8a86b6e7..71b88b828 100644 --- a/packages/slate/test/changes/at-current-range/split-block/with-delete-across-blocks-and-inlines.js +++ b/packages/slate/test/changes/at-current-range/split-block/with-delete-across-blocks-and-inlines.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.splitBlock() } @@ -10,10 +10,14 @@ export const input = (- word - +word another diff --git a/packages/slate/test/changes/at-current-range/split-block/depth.js b/packages/slate/test/changes/at-current-range/split-block/depth.js index d62c89b82..f32e09a8f 100644 --- a/packages/slate/test/changes/at-current-range/split-block/depth.js +++ b/packages/slate/test/changes/at-current-range/split-block/depth.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.splitBlock(Infinity) } @@ -11,7 +11,9 @@ export const input = ( @@ -28,7 +30,9 @@ export const output = ( - wo +rd + wo rd + - + rd + rd + @@ -26,7 +30,9 @@ export const output = ( wo - wo rd + + wo rd + - an +other + an other + - + other + other + ) @@ -19,7 +23,9 @@ export const output = ( - wo -rd an +other + wo +rd + + an other + ) diff --git a/packages/slate/test/changes/at-current-range/split-block/with-delete.js b/packages/slate/test/changes/at-current-range/split-block/with-delete.js index 36e4232bd..b1ad8aa29 100644 --- a/packages/slate/test/changes/at-current-range/split-block/with-delete.js +++ b/packages/slate/test/changes/at-current-range/split-block/with-delete.js @@ -2,14 +2,16 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.splitBlock() } export const input = ( wo -+ other + other + ) @@ -18,7 +20,9 @@ export const output = ( - w +or d + w or d + ) diff --git a/packages/slate/test/changes/at-current-range/split-block/with-inline.js b/packages/slate/test/changes/at-current-range/split-block/with-inline.js index 2a1d18a7d..07aa141ea 100644 --- a/packages/slate/test/changes/at-current-range/split-block/with-inline.js +++ b/packages/slate/test/changes/at-current-range/split-block/with-inline.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.splitBlock() } @@ -10,7 +10,9 @@ export const input = ( w -+ d + d + @@ -23,7 +25,9 @@ export const output = ( wo - wo rd + + wo rd + - rd + + rd + @@ -20,7 +22,9 @@ export const output = ( - word + + word + diff --git a/packages/slate/test/changes/at-current-range/split-inline/block-middle.js b/packages/slate/test/changes/at-current-range/split-inline/block-middle.js index 5a8ff3fe5..9d39f69b4 100644 --- a/packages/slate/test/changes/at-current-range/split-inline/block-middle.js +++ b/packages/slate/test/changes/at-current-range/split-inline/block-middle.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.splitInline() } @@ -10,7 +10,9 @@ export const input = ( - word + + word + @@ -20,7 +22,10 @@ export const output = ( - wo rd + + wo rd + diff --git a/packages/slate/test/changes/at-current-range/split-inline/block-start.js b/packages/slate/test/changes/at-current-range/split-inline/block-start.js index 79a2308fe..c2db3042f 100644 --- a/packages/slate/test/changes/at-current-range/split-inline/block-start.js +++ b/packages/slate/test/changes/at-current-range/split-inline/block-start.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.splitInline() } @@ -10,7 +10,9 @@ export const input = ( - wo rd + wo + + rd + @@ -20,7 +22,9 @@ export const output = ( - word + + word + diff --git a/packages/slate/test/changes/at-current-range/split-inline/depth.js b/packages/slate/test/changes/at-current-range/split-inline/depth.js index f019f74d3..b3371c3b4 100644 --- a/packages/slate/test/changes/at-current-range/split-inline/depth.js +++ b/packages/slate/test/changes/at-current-range/split-inline/depth.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.splitInline(1) } @@ -10,7 +10,11 @@ export const input = ( - word + + word + @@ -20,7 +24,12 @@ export const output = ( - wo rd + + + wo rd + + diff --git a/packages/slate/test/changes/at-current-range/split-inline/with-delete.js b/packages/slate/test/changes/at-current-range/split-inline/with-delete.js index 208fe9675..ef129c711 100644 --- a/packages/slate/test/changes/at-current-range/split-inline/with-delete.js +++ b/packages/slate/test/changes/at-current-range/split-inline/with-delete.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.splitInline() } @@ -10,7 +10,9 @@ export const input = ( - wo rd + + wo + + rd + + @@ -20,7 +22,10 @@ export const output = ( - w or d + + w or d + diff --git a/packages/slate/test/changes/at-current-range/split-inline/with-marks.js b/packages/slate/test/changes/at-current-range/split-inline/with-marks.js index 794865a10..95cbaf94a 100644 --- a/packages/slate/test/changes/at-current-range/split-inline/with-marks.js +++ b/packages/slate/test/changes/at-current-range/split-inline/with-marks.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.splitInline() } @@ -10,7 +10,11 @@ export const input = ( - w d + w + + d + @@ -20,7 +24,14 @@ export const output = ( - wo rd + + + wo rd + + diff --git a/packages/slate/test/changes/at-current-range/toggle-mark/add-across-blocks.js b/packages/slate/test/changes/at-current-range/toggle-mark/add-across-blocks.js index e16bd38d5..47f0a8b69 100644 --- a/packages/slate/test/changes/at-current-range/toggle-mark/add-across-blocks.js +++ b/packages/slate/test/changes/at-current-range/toggle-mark/add-across-blocks.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.toggleMark('bold') } @@ -23,10 +23,12 @@ export const output = ( - wo rd + + wo + + + + rd + + diff --git a/packages/slate/test/changes/at-current-range/toggle-mark/add-across-inlines.js b/packages/slate/test/changes/at-current-range/toggle-mark/add-across-inlines.js index 32464b636..236f0e787 100644 --- a/packages/slate/test/changes/at-current-range/toggle-mark/add-across-inlines.js +++ b/packages/slate/test/changes/at-current-range/toggle-mark/add-across-inlines.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.toggleMark('bold') } @@ -10,10 +10,14 @@ export const input = ( - wo rd + wo + rd - an other + an + other @@ -23,11 +27,15 @@ export const output = ( - wo rd + + wo rd + - an other + + an other + diff --git a/packages/slate/test/changes/at-current-range/toggle-mark/add-collapsed-selection-beginning.js b/packages/slate/test/changes/at-current-range/toggle-mark/add-collapsed-selection-beginning.js index d3346c866..7d3973076 100644 --- a/packages/slate/test/changes/at-current-range/toggle-mark/add-collapsed-selection-beginning.js +++ b/packages/slate/test/changes/at-current-range/toggle-mark/add-collapsed-selection-beginning.js @@ -2,10 +2,8 @@ import h from '../../../helpers/h' -export default function (change) { - change - .toggleMark('bold') - .insertText('a') +export default function(change) { + change.toggleMark('bold').insertText('a') } export const input = ( @@ -22,7 +20,8 @@ export const output = ( - wo rd + + wo + rd + - an other + an + other diff --git a/packages/slate/test/changes/at-current-range/toggle-mark/add-collapsed-selection.js b/packages/slate/test/changes/at-current-range/toggle-mark/add-collapsed-selection.js index 1e95ccea6..47b3e0071 100644 --- a/packages/slate/test/changes/at-current-range/toggle-mark/add-collapsed-selection.js +++ b/packages/slate/test/changes/at-current-range/toggle-mark/add-collapsed-selection.js @@ -2,10 +2,8 @@ import h from '../../../helpers/h' -export default function (change) { - change - .toggleMark('bold') - .insertText('s') +export default function(change) { + change.toggleMark('bold').insertText('s') } export const input = ( @@ -22,7 +20,8 @@ export const output = ( - a word + a + word diff --git a/packages/slate/test/changes/at-current-range/toggle-mark/add-existing-marks-partially-marked.js b/packages/slate/test/changes/at-current-range/toggle-mark/add-existing-marks-partially-marked.js index 810257fc1..e95459321 100644 --- a/packages/slate/test/changes/at-current-range/toggle-mark/add-existing-marks-partially-marked.js +++ b/packages/slate/test/changes/at-current-range/toggle-mark/add-existing-marks-partially-marked.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.toggleMark('bold') } @@ -10,7 +10,11 @@ export const input = ( - words + words + @@ -20,7 +24,12 @@ export const output = ( - awo rd + + a + + wo rd + diff --git a/packages/slate/test/changes/at-current-range/toggle-mark/add-existing-marks.js b/packages/slate/test/changes/at-current-range/toggle-mark/add-existing-marks.js index 725f383d1..583f69d8d 100644 --- a/packages/slate/test/changes/at-current-range/toggle-mark/add-existing-marks.js +++ b/packages/slate/test/changes/at-current-range/toggle-mark/add-existing-marks.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.toggleMark('bold') } @@ -10,7 +10,9 @@ export const input = ( - awo rd + + + awo + + + rd @@ -20,7 +22,12 @@ export const output = ( - wo rd + + wo rd + diff --git a/packages/slate/test/changes/at-current-range/toggle-mark/add-first-character.js b/packages/slate/test/changes/at-current-range/toggle-mark/add-first-character.js index 9f16f7123..343e309db 100644 --- a/packages/slate/test/changes/at-current-range/toggle-mark/add-first-character.js +++ b/packages/slate/test/changes/at-current-range/toggle-mark/add-first-character.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.toggleMark('bold') } @@ -20,7 +20,9 @@ export const output = ( - wo rd + + + wo + + + rd diff --git a/packages/slate/test/changes/at-current-range/toggle-mark/add-last-character.js b/packages/slate/test/changes/at-current-range/toggle-mark/add-last-character.js index 5ba5aefb3..9e9617e8e 100644 --- a/packages/slate/test/changes/at-current-range/toggle-mark/add-last-character.js +++ b/packages/slate/test/changes/at-current-range/toggle-mark/add-last-character.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.toggleMark('bold') } @@ -20,7 +20,9 @@ export const output = ( - w ord + + w + ord diff --git a/packages/slate/test/changes/at-current-range/toggle-mark/add-middle-character.js b/packages/slate/test/changes/at-current-range/toggle-mark/add-middle-character.js index 4d08d59bb..a26ff9b98 100644 --- a/packages/slate/test/changes/at-current-range/toggle-mark/add-middle-character.js +++ b/packages/slate/test/changes/at-current-range/toggle-mark/add-middle-character.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.toggleMark('bold') } @@ -20,7 +20,9 @@ export const output = ( - wor d + wor + d + diff --git a/packages/slate/test/changes/at-current-range/toggle-mark/add-partially-marked.js b/packages/slate/test/changes/at-current-range/toggle-mark/add-partially-marked.js index 2d6c5624f..176d62cbb 100644 --- a/packages/slate/test/changes/at-current-range/toggle-mark/add-partially-marked.js +++ b/packages/slate/test/changes/at-current-range/toggle-mark/add-partially-marked.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.toggleMark('bold') } @@ -10,7 +10,8 @@ export const input = ( - w o rd + w + o + rd @@ -20,7 +21,9 @@ export const output = ( - aword + aword + diff --git a/packages/slate/test/changes/at-current-range/toggle-mark/add-whole-word.js b/packages/slate/test/changes/at-current-range/toggle-mark/add-whole-word.js index c588c217f..733e751c3 100644 --- a/packages/slate/test/changes/at-current-range/toggle-mark/add-whole-word.js +++ b/packages/slate/test/changes/at-current-range/toggle-mark/add-whole-word.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.toggleMark('bold') } @@ -20,7 +20,9 @@ export const output = ( - aword + + aword + diff --git a/packages/slate/test/changes/at-current-range/toggle-mark/add-with-mark-object.js b/packages/slate/test/changes/at-current-range/toggle-mark/add-with-mark-object.js index 4135fb288..258a768f8 100644 --- a/packages/slate/test/changes/at-current-range/toggle-mark/add-with-mark-object.js +++ b/packages/slate/test/changes/at-current-range/toggle-mark/add-with-mark-object.js @@ -3,11 +3,13 @@ import h from '../../../helpers/h' import { Mark } from '../../../..' -export default function (change) { - change.toggleMark(Mark.create({ - type: 'bold', - data: { thing: 'value' } - })) +export default function(change) { + change.toggleMark( + Mark.create({ + type: 'bold', + data: { thing: 'value' }, + }) + ) } export const input = ( @@ -24,7 +26,9 @@ export const output = ( - word + + word + diff --git a/packages/slate/test/changes/at-current-range/toggle-mark/add-with-plain-object.js b/packages/slate/test/changes/at-current-range/toggle-mark/add-with-plain-object.js index f8f1d41c3..a172d8138 100644 --- a/packages/slate/test/changes/at-current-range/toggle-mark/add-with-plain-object.js +++ b/packages/slate/test/changes/at-current-range/toggle-mark/add-with-plain-object.js @@ -2,10 +2,10 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.toggleMark({ type: 'bold', - data: { thing: 'value' } + data: { thing: 'value' }, }) } @@ -23,7 +23,9 @@ export const output = ( - w ord + + w + ord diff --git a/packages/slate/test/changes/at-current-range/toggle-mark/remove-across-blocks.js b/packages/slate/test/changes/at-current-range/toggle-mark/remove-across-blocks.js index 49d790969..5405a205f 100644 --- a/packages/slate/test/changes/at-current-range/toggle-mark/remove-across-blocks.js +++ b/packages/slate/test/changes/at-current-range/toggle-mark/remove-across-blocks.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.toggleMark('bold') } @@ -10,10 +10,12 @@ export const input = ( - w ord + + w + ord diff --git a/packages/slate/test/changes/at-current-range/toggle-mark/remove-across-inlines.js b/packages/slate/test/changes/at-current-range/toggle-mark/remove-across-inlines.js index ecb63424a..f40bf80bb 100644 --- a/packages/slate/test/changes/at-current-range/toggle-mark/remove-across-inlines.js +++ b/packages/slate/test/changes/at-current-range/toggle-mark/remove-across-inlines.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.toggleMark('bold') } @@ -10,10 +10,17 @@ export const input = ( - wo rd + wo + rd - an other + an + other @@ -23,10 +30,14 @@ export const output = ( - wo rd + + wo + rd + + - an other + + an + other + diff --git a/packages/slate/test/changes/at-current-range/toggle-mark/remove-collapsed-selection-beginning.js b/packages/slate/test/changes/at-current-range/toggle-mark/remove-collapsed-selection-beginning.js index 1767a558a..73d9d91f4 100644 --- a/packages/slate/test/changes/at-current-range/toggle-mark/remove-collapsed-selection-beginning.js +++ b/packages/slate/test/changes/at-current-range/toggle-mark/remove-collapsed-selection-beginning.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change .toggleMark('bold') .toggleMark('bold') diff --git a/packages/slate/test/changes/at-current-range/toggle-mark/remove-collapsed-selection.js b/packages/slate/test/changes/at-current-range/toggle-mark/remove-collapsed-selection.js index c55f7a572..a9c6bf8f3 100644 --- a/packages/slate/test/changes/at-current-range/toggle-mark/remove-collapsed-selection.js +++ b/packages/slate/test/changes/at-current-range/toggle-mark/remove-collapsed-selection.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change .toggleMark('bold') .toggleMark('bold') diff --git a/packages/slate/test/changes/at-current-range/toggle-mark/remove-existing-marks.js b/packages/slate/test/changes/at-current-range/toggle-mark/remove-existing-marks.js index b97bf3d73..4db3ace9e 100644 --- a/packages/slate/test/changes/at-current-range/toggle-mark/remove-existing-marks.js +++ b/packages/slate/test/changes/at-current-range/toggle-mark/remove-existing-marks.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.toggleMark('bold') } @@ -10,7 +10,12 @@ export const input = ( - wo rd + + wo rd + - an other + + an other + @@ -20,7 +25,9 @@ export const output = ( - wo rd + + + wo + + + rd diff --git a/packages/slate/test/changes/at-current-range/toggle-mark/remove-first-character.js b/packages/slate/test/changes/at-current-range/toggle-mark/remove-first-character.js index c10cf3965..09d28d045 100644 --- a/packages/slate/test/changes/at-current-range/toggle-mark/remove-first-character.js +++ b/packages/slate/test/changes/at-current-range/toggle-mark/remove-first-character.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.toggleMark('bold') } @@ -10,7 +10,9 @@ export const input = ( - wo rd + + wo rd + diff --git a/packages/slate/test/changes/at-current-range/toggle-mark/remove-last-character.js b/packages/slate/test/changes/at-current-range/toggle-mark/remove-last-character.js index 233d62e4c..7d858e7ee 100644 --- a/packages/slate/test/changes/at-current-range/toggle-mark/remove-last-character.js +++ b/packages/slate/test/changes/at-current-range/toggle-mark/remove-last-character.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.toggleMark('bold') } @@ -10,7 +10,9 @@ export const input = ( - w ord + + w + ord diff --git a/packages/slate/test/changes/at-current-range/toggle-mark/remove-middle-character.js b/packages/slate/test/changes/at-current-range/toggle-mark/remove-middle-character.js index ac49b5fb1..73359b548 100644 --- a/packages/slate/test/changes/at-current-range/toggle-mark/remove-middle-character.js +++ b/packages/slate/test/changes/at-current-range/toggle-mark/remove-middle-character.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.toggleMark('bold') } @@ -10,7 +10,9 @@ export const input = ( - wor d + wor + d + diff --git a/packages/slate/test/changes/at-current-range/toggle-mark/remove-whole-word.js b/packages/slate/test/changes/at-current-range/toggle-mark/remove-whole-word.js index bf06d4d3a..ad3a01073 100644 --- a/packages/slate/test/changes/at-current-range/toggle-mark/remove-whole-word.js +++ b/packages/slate/test/changes/at-current-range/toggle-mark/remove-whole-word.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.toggleMark('bold') } @@ -10,7 +10,9 @@ export const input = ( - w o rd + w + o + rd diff --git a/packages/slate/test/changes/at-current-range/toggle-mark/remove-with-mark-object.js b/packages/slate/test/changes/at-current-range/toggle-mark/remove-with-mark-object.js index 2ba731cd5..1674a1b6d 100644 --- a/packages/slate/test/changes/at-current-range/toggle-mark/remove-with-mark-object.js +++ b/packages/slate/test/changes/at-current-range/toggle-mark/remove-with-mark-object.js @@ -3,18 +3,22 @@ import h from '../../../helpers/h' import { Mark } from '../../../..' -export default function (change) { - change.toggleMark(Mark.create({ - type: 'bold', - data: { thing: 'value' } - })) +export default function(change) { + change.toggleMark( + Mark.create({ + type: 'bold', + data: { thing: 'value' }, + }) + ) } export const input = ( - word + + word + diff --git a/packages/slate/test/changes/at-current-range/toggle-mark/remove-with-plain-object.js b/packages/slate/test/changes/at-current-range/toggle-mark/remove-with-plain-object.js index af5865a08..edc7b37dc 100644 --- a/packages/slate/test/changes/at-current-range/toggle-mark/remove-with-plain-object.js +++ b/packages/slate/test/changes/at-current-range/toggle-mark/remove-with-plain-object.js @@ -2,10 +2,10 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.toggleMark({ type: 'bold', - data: { thing: 'value' } + data: { thing: 'value' }, }) } @@ -13,7 +13,9 @@ export const input = ( - w ord + + w + ord diff --git a/packages/slate/test/changes/at-current-range/unwrap-block/across-blocks.js b/packages/slate/test/changes/at-current-range/unwrap-block/across-blocks.js index f2be8c3ac..939f66d0c 100644 --- a/packages/slate/test/changes/at-current-range/unwrap-block/across-blocks.js +++ b/packages/slate/test/changes/at-current-range/unwrap-block/across-blocks.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.unwrapBlock('quote') } diff --git a/packages/slate/test/changes/at-current-range/unwrap-block/across-inlines.js b/packages/slate/test/changes/at-current-range/unwrap-block/across-inlines.js index c87e53b17..2abe0fc0e 100644 --- a/packages/slate/test/changes/at-current-range/unwrap-block/across-inlines.js +++ b/packages/slate/test/changes/at-current-range/unwrap-block/across-inlines.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.unwrapBlock('quote') } @@ -11,10 +11,14 @@ export const input = ( - w ord + + w + ord @@ -25,10 +29,14 @@ export const output = ( - wo rd + + wo rd + - an other + + an other + diff --git a/packages/slate/test/changes/at-current-range/unwrap-block/ending-child-blocks.js b/packages/slate/test/changes/at-current-range/unwrap-block/ending-child-blocks.js index c6be64551..c72d2d403 100644 --- a/packages/slate/test/changes/at-current-range/unwrap-block/ending-child-blocks.js +++ b/packages/slate/test/changes/at-current-range/unwrap-block/ending-child-blocks.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.unwrapBlock('quote') } @@ -10,18 +10,10 @@ export const input = ( - wo rd + + wo rd + - an other + + an other + @@ -43,18 +35,10 @@ export const output = ( -- one - -- two - -- three - -- four - +one +two +three +four @@ -37,18 +29,10 @@ export const output = ( five -- one - -- two - -- three - -- four - +one +two +three +four five diff --git a/packages/slate/test/changes/at-current-range/unwrap-block/middle-child-blocks-with-backward-selection.js b/packages/slate/test/changes/at-current-range/unwrap-block/middle-child-blocks-with-backward-selection.js index 100944c83..89ebd89eb 100644 --- a/packages/slate/test/changes/at-current-range/unwrap-block/middle-child-blocks-with-backward-selection.js +++ b/packages/slate/test/changes/at-current-range/unwrap-block/middle-child-blocks-with-backward-selection.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.unwrapBlock('quote') } @@ -10,24 +10,16 @@ export const input = ( @@ -37,12 +29,8 @@ export const output = ( -- one - -- two - +one +two three - four - five - -- six - +five +six ) - diff --git a/packages/slate/test/changes/at-current-range/unwrap-block/middle-child-blocks.js b/packages/slate/test/changes/at-current-range/unwrap-block/middle-child-blocks.js index 281a49342..329851a8f 100644 --- a/packages/slate/test/changes/at-current-range/unwrap-block/middle-child-blocks.js +++ b/packages/slate/test/changes/at-current-range/unwrap-block/middle-child-blocks.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.unwrapBlock('quote') } @@ -10,24 +10,16 @@ export const input = ( -- one - -- two - +one +two three @@ -51,14 +39,9 @@ export const output = ( four -- five - -- six - +five +six @@ -37,12 +29,8 @@ export const output = ( -- one - -- two - +one +two three - four - five - -- six - +five +six diff --git a/packages/slate/test/changes/at-current-range/unwrap-block/nested-block.js b/packages/slate/test/changes/at-current-range/unwrap-block/nested-block.js index 89226311f..71ac9e33e 100644 --- a/packages/slate/test/changes/at-current-range/unwrap-block/nested-block.js +++ b/packages/slate/test/changes/at-current-range/unwrap-block/nested-block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.unwrapBlock('quote') } diff --git a/packages/slate/test/changes/at-current-range/unwrap-block/single-block.js b/packages/slate/test/changes/at-current-range/unwrap-block/single-block.js index 43bda4fbb..76d337c69 100644 --- a/packages/slate/test/changes/at-current-range/unwrap-block/single-block.js +++ b/packages/slate/test/changes/at-current-range/unwrap-block/single-block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.unwrapBlock('quote') } diff --git a/packages/slate/test/changes/at-current-range/unwrap-block/starting-child-blocks.js b/packages/slate/test/changes/at-current-range/unwrap-block/starting-child-blocks.js index 9ae1a7953..952fc027d 100644 --- a/packages/slate/test/changes/at-current-range/unwrap-block/starting-child-blocks.js +++ b/packages/slate/test/changes/at-current-range/unwrap-block/starting-child-blocks.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.unwrapBlock('quote') } @@ -16,18 +16,10 @@ export const input = ( -- one - -- two - +one +two three @@ -51,12 +39,8 @@ export const output = ( four -- five - -- six - +five +six - two - three - -- four - -- five - -- six - +three +four +five +six two -- three - -- four - -- five - -- six - +three +four +five +six @@ -24,9 +22,7 @@ export const input = ( export const output = ( -- word - +word ) diff --git a/packages/slate/test/changes/at-current-range/unwrap-inline/across-blocks.js b/packages/slate/test/changes/at-current-range/unwrap-inline/across-blocks.js index ba977008b..c84ce8bd4 100644 --- a/packages/slate/test/changes/at-current-range/unwrap-inline/across-blocks.js +++ b/packages/slate/test/changes/at-current-range/unwrap-inline/across-blocks.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.unwrapInline('hashtag') } diff --git a/packages/slate/test/changes/at-current-range/unwrap-inline/across-inlines-and-text.js b/packages/slate/test/changes/at-current-range/unwrap-inline/across-inlines-and-text.js index 24838dc15..62eae7967 100644 --- a/packages/slate/test/changes/at-current-range/unwrap-inline/across-inlines-and-text.js +++ b/packages/slate/test/changes/at-current-range/unwrap-inline/across-inlines-and-text.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.unwrapInline('link') } @@ -10,7 +10,11 @@ export const input = ( - - word - +word diff --git a/packages/slate/test/changes/at-current-range/unwrap-inline/across-inlines.js b/packages/slate/test/changes/at-current-range/unwrap-inline/across-inlines.js index 783474402..26d5539c6 100644 --- a/packages/slate/test/changes/at-current-range/unwrap-inline/across-inlines.js +++ b/packages/slate/test/changes/at-current-range/unwrap-inline/across-inlines.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.unwrapInline('hashtag') } @@ -10,7 +10,18 @@ export const input = ( - onetwothree + + one + two + three + @@ -20,7 +31,14 @@ export const output = ( - wo rd an other + + wo + + + rd + ++ an + + + other + diff --git a/packages/slate/test/changes/at-current-range/unwrap-inline/nested-block.js b/packages/slate/test/changes/at-current-range/unwrap-inline/nested-block.js index 97281a7e1..e079059bf 100644 --- a/packages/slate/test/changes/at-current-range/unwrap-inline/nested-block.js +++ b/packages/slate/test/changes/at-current-range/unwrap-inline/nested-block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.unwrapInline('hashtag') } @@ -11,7 +11,10 @@ export const input = ( - wo rdanot her + + wo + + rd + an + + ot her + diff --git a/packages/slate/test/changes/at-current-range/unwrap-inline/only-one.js b/packages/slate/test/changes/at-current-range/unwrap-inline/only-one.js index dc24412ff..c00aea811 100644 --- a/packages/slate/test/changes/at-current-range/unwrap-inline/only-one.js +++ b/packages/slate/test/changes/at-current-range/unwrap-inline/only-one.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.unwrapInline('hashtag') } @@ -10,7 +10,9 @@ export const input = ( - w or d + w+ + or d+ @@ -20,7 +22,8 @@ export const output = ( - he ll ow or d + hell ow + or d+ ) diff --git a/packages/slate/test/changes/at-current-range/unwrap-inline/single-block.js b/packages/slate/test/changes/at-current-range/unwrap-inline/single-block.js index c7410fdbb..2cde7ee57 100644 --- a/packages/slate/test/changes/at-current-range/unwrap-inline/single-block.js +++ b/packages/slate/test/changes/at-current-range/unwrap-inline/single-block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.unwrapInline('hashtag') } @@ -10,7 +10,10 @@ export const input = ( - he + hell owor d ll owor d + @@ -19,7 +22,9 @@ export const input = ( export const output = ( - w or d + w+ + or d+ ) diff --git a/packages/slate/test/changes/at-current-range/unwrap-inline/with-object.js b/packages/slate/test/changes/at-current-range/unwrap-inline/with-object.js index b7786c9c8..d73cd71b0 100644 --- a/packages/slate/test/changes/at-current-range/unwrap-inline/with-object.js +++ b/packages/slate/test/changes/at-current-range/unwrap-inline/with-object.js @@ -2,10 +2,10 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.unwrapInline({ type: 'hashtag', - data: { thing: 'value' } + data: { thing: 'value' }, }) } @@ -13,7 +13,11 @@ export const input = ( - w +or d + w or d + @@ -23,7 +27,9 @@ export const output = ( - w d + w or + d+ +or + diff --git a/packages/slate/test/changes/at-current-range/wrap-block/across-blocks.js b/packages/slate/test/changes/at-current-range/wrap-block/across-blocks.js index 1ec7e479c..5f4b03835 100644 --- a/packages/slate/test/changes/at-current-range/wrap-block/across-blocks.js +++ b/packages/slate/test/changes/at-current-range/wrap-block/across-blocks.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.wrapBlock('quote') } diff --git a/packages/slate/test/changes/at-current-range/wrap-block/across-inlines.js b/packages/slate/test/changes/at-current-range/wrap-block/across-inlines.js index e39b3f23f..e841260b7 100644 --- a/packages/slate/test/changes/at-current-range/wrap-block/across-inlines.js +++ b/packages/slate/test/changes/at-current-range/wrap-block/across-inlines.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.wrapBlock('quote') } @@ -10,10 +10,14 @@ export const input = ( - w d + w or + dor + @@ -24,10 +28,14 @@ export const output = ( - wo rd + + wo rd + - an other + + an other + diff --git a/packages/slate/test/changes/at-current-range/wrap-block/nested-block.js b/packages/slate/test/changes/at-current-range/wrap-block/nested-block.js index e9da0360f..215789d0c 100644 --- a/packages/slate/test/changes/at-current-range/wrap-block/nested-block.js +++ b/packages/slate/test/changes/at-current-range/wrap-block/nested-block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.wrapBlock('quote') } diff --git a/packages/slate/test/changes/at-current-range/wrap-block/single-block.js b/packages/slate/test/changes/at-current-range/wrap-block/single-block.js index cb797bb90..60bcc250a 100644 --- a/packages/slate/test/changes/at-current-range/wrap-block/single-block.js +++ b/packages/slate/test/changes/at-current-range/wrap-block/single-block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.wrapBlock('quote') } diff --git a/packages/slate/test/changes/at-current-range/wrap-block/with-object.js b/packages/slate/test/changes/at-current-range/wrap-block/with-object.js index c0c708220..30d14dd4e 100644 --- a/packages/slate/test/changes/at-current-range/wrap-block/with-object.js +++ b/packages/slate/test/changes/at-current-range/wrap-block/with-object.js @@ -2,10 +2,10 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.wrapBlock({ type: 'quote', - data: { thing: 'value' } + data: { thing: 'value' }, }) } diff --git a/packages/slate/test/changes/at-current-range/wrap-inline/across-blocks.js b/packages/slate/test/changes/at-current-range/wrap-inline/across-blocks.js index 55b82da35..43cb2fdbf 100644 --- a/packages/slate/test/changes/at-current-range/wrap-inline/across-blocks.js +++ b/packages/slate/test/changes/at-current-range/wrap-inline/across-blocks.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.wrapInline('hashtag') } @@ -23,10 +23,13 @@ export const output = ( - wo rd + + wo rd + - an other + + an other + diff --git a/packages/slate/test/changes/at-current-range/wrap-inline/across-inlines.js b/packages/slate/test/changes/at-current-range/wrap-inline/across-inlines.js index 046af6f73..a897590d0 100644 --- a/packages/slate/test/changes/at-current-range/wrap-inline/across-inlines.js +++ b/packages/slate/test/changes/at-current-range/wrap-inline/across-inlines.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.wrapInline('hashtag') } @@ -10,7 +10,12 @@ export const input = ( - wo + wo rd + rd + - an other + an +other @@ -20,7 +25,16 @@ export const output = ( - wo rdan other + + wo rd + + + an other + diff --git a/packages/slate/test/changes/at-current-range/wrap-inline/inline-void.js b/packages/slate/test/changes/at-current-range/wrap-inline/inline-void.js index 1aa2fb4df..c9ba3be84 100644 --- a/packages/slate/test/changes/at-current-range/wrap-inline/inline-void.js +++ b/packages/slate/test/changes/at-current-range/wrap-inline/inline-void.js @@ -2,9 +2,9 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.wrapInline({ - type: 'link' + type: 'link', }) } @@ -12,7 +12,9 @@ export const input = ( - wo rdan other + wo + + + + +rd + + an + other + @@ -23,7 +25,9 @@ export const output = ( - + {' '} + {' '} + diff --git a/packages/slate/test/changes/at-current-range/wrap-inline/nested-block.js b/packages/slate/test/changes/at-current-range/wrap-inline/nested-block.js index 7a84583b3..d7a0d1cc7 100644 --- a/packages/slate/test/changes/at-current-range/wrap-inline/nested-block.js +++ b/packages/slate/test/changes/at-current-range/wrap-inline/nested-block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.wrapInline('hashtag') } @@ -23,7 +23,10 @@ export const output = ( - + {' '} + {' '} + diff --git a/packages/slate/test/changes/at-current-range/wrap-inline/single-block.js b/packages/slate/test/changes/at-current-range/wrap-inline/single-block.js index e4d62e4ef..771687e7f 100644 --- a/packages/slate/test/changes/at-current-range/wrap-inline/single-block.js +++ b/packages/slate/test/changes/at-current-range/wrap-inline/single-block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.wrapInline('hashtag') } @@ -20,7 +20,10 @@ export const output = ( - w or d + w + +or + d diff --git a/packages/slate/test/changes/at-current-range/wrap-inline/twice.js b/packages/slate/test/changes/at-current-range/wrap-inline/twice.js index 4570bbc59..b06cf9551 100644 --- a/packages/slate/test/changes/at-current-range/wrap-inline/twice.js +++ b/packages/slate/test/changes/at-current-range/wrap-inline/twice.js @@ -2,16 +2,16 @@ import h from '../../../helpers/h' -export default function (change) { - change - .wrapInline('link') - .wrapInline('hashtag') +export default function(change) { + change.wrapInline('link').wrapInline('hashtag') } export const input = ( - w or d + w + +or + d ) @@ -20,7 +20,12 @@ export const output = ( - w +or d + w or d + diff --git a/packages/slate/test/changes/at-current-range/wrap-inline/whole-block.js b/packages/slate/test/changes/at-current-range/wrap-inline/whole-block.js index 60a62e80d..5843ad9fd 100644 --- a/packages/slate/test/changes/at-current-range/wrap-inline/whole-block.js +++ b/packages/slate/test/changes/at-current-range/wrap-inline/whole-block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.wrapInline('hashtag') } @@ -20,7 +20,10 @@ export const output = ( - w or d + w + + +or + + d diff --git a/packages/slate/test/changes/at-current-range/wrap-inline/with-object.js b/packages/slate/test/changes/at-current-range/wrap-inline/with-object.js index 43ba0d9a6..c851b4225 100644 --- a/packages/slate/test/changes/at-current-range/wrap-inline/with-object.js +++ b/packages/slate/test/changes/at-current-range/wrap-inline/with-object.js @@ -2,10 +2,10 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.wrapInline({ type: 'hashtag', - data: { thing: 'value' } + data: { thing: 'value' }, }) } @@ -23,7 +23,10 @@ export const output = ( - word + + +word + diff --git a/packages/slate/test/changes/at-current-range/wrap-text/across-blocks.js b/packages/slate/test/changes/at-current-range/wrap-text/across-blocks.js index 74a501d33..254b6e047 100644 --- a/packages/slate/test/changes/at-current-range/wrap-text/across-blocks.js +++ b/packages/slate/test/changes/at-current-range/wrap-text/across-blocks.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.wrapText('[[', ']]') } diff --git a/packages/slate/test/changes/at-current-range/wrap-text/across-inlines.js b/packages/slate/test/changes/at-current-range/wrap-text/across-inlines.js index c2320997e..fd62cf5c3 100644 --- a/packages/slate/test/changes/at-current-range/wrap-text/across-inlines.js +++ b/packages/slate/test/changes/at-current-range/wrap-text/across-inlines.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.wrapText('[[', ']]') } @@ -10,8 +10,12 @@ export const input = ( - w or d + w + +or + d @@ -21,8 +25,12 @@ export const output = ( - wo rd - an other + + wo rd + + + an other + diff --git a/packages/slate/test/changes/at-current-range/wrap-text/backwards-selection.js b/packages/slate/test/changes/at-current-range/wrap-text/backwards-selection.js index 1b6697b3b..67fb004d8 100644 --- a/packages/slate/test/changes/at-current-range/wrap-text/backwards-selection.js +++ b/packages/slate/test/changes/at-current-range/wrap-text/backwards-selection.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.wrapText('[[', ']]') } diff --git a/packages/slate/test/changes/at-current-range/wrap-text/empty-block.js b/packages/slate/test/changes/at-current-range/wrap-text/empty-block.js index 9fbe18503..038b6c83e 100644 --- a/packages/slate/test/changes/at-current-range/wrap-text/empty-block.js +++ b/packages/slate/test/changes/at-current-range/wrap-text/empty-block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.wrapText('[[', ']]') } diff --git a/packages/slate/test/changes/at-current-range/wrap-text/end-of-block.js b/packages/slate/test/changes/at-current-range/wrap-text/end-of-block.js index 2c75683f2..a90cd9226 100644 --- a/packages/slate/test/changes/at-current-range/wrap-text/end-of-block.js +++ b/packages/slate/test/changes/at-current-range/wrap-text/end-of-block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.wrapText('[[', ']]') } diff --git a/packages/slate/test/changes/at-current-range/wrap-text/middle-of-block.js b/packages/slate/test/changes/at-current-range/wrap-text/middle-of-block.js index 25f6ca058..f9f681d62 100644 --- a/packages/slate/test/changes/at-current-range/wrap-text/middle-of-block.js +++ b/packages/slate/test/changes/at-current-range/wrap-text/middle-of-block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.wrapText('[[', ']]') } diff --git a/packages/slate/test/changes/at-current-range/wrap-text/start-of-block.js b/packages/slate/test/changes/at-current-range/wrap-text/start-of-block.js index 547c4ad44..7b63bcde1 100644 --- a/packages/slate/test/changes/at-current-range/wrap-text/start-of-block.js +++ b/packages/slate/test/changes/at-current-range/wrap-text/start-of-block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.wrapText('[[', ']]') } diff --git a/packages/slate/test/changes/at-current-range/wrap-text/whole-block.js b/packages/slate/test/changes/at-current-range/wrap-text/whole-block.js index 4a166f107..d47a1cb24 100644 --- a/packages/slate/test/changes/at-current-range/wrap-text/whole-block.js +++ b/packages/slate/test/changes/at-current-range/wrap-text/whole-block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.wrapText('[[', ']]') } diff --git a/packages/slate/test/changes/at-current-range/wrap-text/without-suffix.js b/packages/slate/test/changes/at-current-range/wrap-text/without-suffix.js index c4557294a..c76e99143 100644 --- a/packages/slate/test/changes/at-current-range/wrap-text/without-suffix.js +++ b/packages/slate/test/changes/at-current-range/wrap-text/without-suffix.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.wrapText('**') } diff --git a/packages/slate/test/changes/by-key/insert-fragment-by-key/end-of-target.js b/packages/slate/test/changes/by-key/insert-fragment-by-key/end-of-target.js index 588455773..64911e972 100644 --- a/packages/slate/test/changes/by-key/insert-fragment-by-key/end-of-target.js +++ b/packages/slate/test/changes/by-key/insert-fragment-by-key/end-of-target.js @@ -2,25 +2,21 @@ import h from '../../../helpers/h' -export default function (change) { - change.insertFragmentByKey('a', 1, ( +export default function(change) { + change.insertFragmentByKey( + 'a', + 1, - wo[[ rd - an ]]other + + wo[[ rd + + + an ]]other + - - )) + ) } export const input = (- one - -- two - +one +two ) @@ -28,15 +24,9 @@ export const input = ( export const output = ( - - word - +word ) diff --git a/packages/slate/test/changes/by-key/insert-fragment-by-key/middle-of-target.js b/packages/slate/test/changes/by-key/insert-fragment-by-key/middle-of-target.js index 69ebb3509..abdb43c4d 100644 --- a/packages/slate/test/changes/by-key/insert-fragment-by-key/middle-of-target.js +++ b/packages/slate/test/changes/by-key/insert-fragment-by-key/middle-of-target.js @@ -2,28 +2,22 @@ import h from '../../../helpers/h' -export default function (change) { - change.insertFragmentByKey('a', 1, ( +export default function(change) { + change.insertFragmentByKey( + 'a', + 1, - - word - -- one - -- two - +word +one +two - - )) + ) } export const input = (- one - -- two - +one +two ) @@ -31,18 +25,10 @@ export const input = ( export const output = ( - - word - -- another - +word +another ) diff --git a/packages/slate/test/changes/by-key/insert-fragment-by-key/start-of-target.js b/packages/slate/test/changes/by-key/insert-fragment-by-key/start-of-target.js index 3991696c1..d3185732b 100644 --- a/packages/slate/test/changes/by-key/insert-fragment-by-key/start-of-target.js +++ b/packages/slate/test/changes/by-key/insert-fragment-by-key/start-of-target.js @@ -2,17 +2,15 @@ import h from '../../../helpers/h' -export default function (change) { - change.insertFragmentByKey('a', 0, ( +export default function(change) { + change.insertFragmentByKey( + 'a', + 0, - - word - -- one - -- two - -- another - +word +one +two +another - - )) + ) } export const input = ( @@ -28,12 +26,8 @@ export const input = ( export const output = (- one - -- two - +one +two ) @@ -22,9 +20,7 @@ export const input = ( export const output = ( - - one - -- two - +one +two diff --git a/packages/slate/test/changes/by-key/insert-node-by-key/block.js b/packages/slate/test/changes/by-key/insert-node-by-key/block.js index 3c7d868bd..fbdaa34fc 100644 --- a/packages/slate/test/changes/by-key/insert-node-by-key/block.js +++ b/packages/slate/test/changes/by-key/insert-node-by-key/block.js @@ -3,7 +3,7 @@ import h from '../../../helpers/h' import { Block } from '../../../..' -export default function (change) { +export default function(change) { change.insertNodeByKey('a', 0, Block.create('paragraph')) } diff --git a/packages/slate/test/changes/by-key/insert-node-by-key/duplicate.js b/packages/slate/test/changes/by-key/insert-node-by-key/duplicate.js index 74ab65b02..a141961b9 100644 --- a/packages/slate/test/changes/by-key/insert-node-by-key/duplicate.js +++ b/packages/slate/test/changes/by-key/insert-node-by-key/duplicate.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { const node = change.value.document.getBlocks().first() change.insertNodeByKey('a', 0, node) } @@ -20,9 +20,7 @@ export const input = ( export const output = ( word ) @@ -27,11 +29,10 @@ export const output = ( - - one - +one diff --git a/packages/slate/test/changes/by-key/insert-node-by-key/inline.js b/packages/slate/test/changes/by-key/insert-node-by-key/inline.js index e111af245..ebdc05174 100644 --- a/packages/slate/test/changes/by-key/insert-node-by-key/inline.js +++ b/packages/slate/test/changes/by-key/insert-node-by-key/inline.js @@ -3,11 +3,15 @@ import h from '../../../helpers/h' import { Inline } from '../../../..' -export default function (change) { - change.insertNodeByKey('a', 0, Inline.create({ - type: 'emoji', - isVoid: true - })) +export default function(change) { + change.insertNodeByKey( + 'a', + 0, + Inline.create({ + type: 'emoji', + isVoid: true, + }) + ) } export const input = ( @@ -16,9 +20,7 @@ export const input = ( one - one - two - +two ) diff --git a/packages/slate/test/changes/by-key/insert-text-by-key/selection-after.js b/packages/slate/test/changes/by-key/insert-text-by-key/selection-after.js index 85dc4992a..efb437180 100644 --- a/packages/slate/test/changes/by-key/insert-text-by-key/selection-after.js +++ b/packages/slate/test/changes/by-key/insert-text-by-key/selection-after.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertTextByKey('a', 4, 'x') } @@ -10,7 +10,9 @@ export const input = ( - -one - - two + ++ one two diff --git a/packages/slate/test/changes/by-key/insert-text-by-key/selection-before.js b/packages/slate/test/changes/by-key/insert-text-by-key/selection-before.js index f16e63e08..77ad74bc4 100644 --- a/packages/slate/test/changes/by-key/insert-text-by-key/selection-before.js +++ b/packages/slate/test/changes/by-key/insert-text-by-key/selection-before.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertTextByKey('a', 0, 'x') } @@ -10,7 +10,9 @@ export const input = ( - w +or d + w or d + diff --git a/packages/slate/test/changes/by-key/insert-text-by-key/selection-end.js b/packages/slate/test/changes/by-key/insert-text-by-key/selection-end.js index 87b2baa20..73f3f7254 100644 --- a/packages/slate/test/changes/by-key/insert-text-by-key/selection-end.js +++ b/packages/slate/test/changes/by-key/insert-text-by-key/selection-end.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertTextByKey('a', 3, 'x') } @@ -10,7 +10,9 @@ export const input = ( - w +or d + w or d + diff --git a/packages/slate/test/changes/by-key/insert-text-by-key/selection-middle.js b/packages/slate/test/changes/by-key/insert-text-by-key/selection-middle.js index b9a895065..f72d3b44f 100644 --- a/packages/slate/test/changes/by-key/insert-text-by-key/selection-middle.js +++ b/packages/slate/test/changes/by-key/insert-text-by-key/selection-middle.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertTextByKey('a', 2, 'x') } @@ -10,7 +10,9 @@ export const input = ( - w +or d + w or d + diff --git a/packages/slate/test/changes/by-key/insert-text-by-key/selection-start.js b/packages/slate/test/changes/by-key/insert-text-by-key/selection-start.js index 108509ba7..40d66fe48 100644 --- a/packages/slate/test/changes/by-key/insert-text-by-key/selection-start.js +++ b/packages/slate/test/changes/by-key/insert-text-by-key/selection-start.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertTextByKey('a', 1, 'x') } @@ -10,7 +10,9 @@ export const input = ( - w +or d + w or d + diff --git a/packages/slate/test/changes/by-key/insert-text-by-key/start-text.js b/packages/slate/test/changes/by-key/insert-text-by-key/start-text.js index 06a6b252b..463083c12 100644 --- a/packages/slate/test/changes/by-key/insert-text-by-key/start-text.js +++ b/packages/slate/test/changes/by-key/insert-text-by-key/start-text.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertTextByKey('a', 0, 'a') } @@ -10,7 +10,9 @@ export const input = ( - w +or d + w or d + diff --git a/packages/slate/test/changes/by-key/insert-text-by-key/text-end.js b/packages/slate/test/changes/by-key/insert-text-by-key/text-end.js index 8e98e17bf..90611a173 100644 --- a/packages/slate/test/changes/by-key/insert-text-by-key/text-end.js +++ b/packages/slate/test/changes/by-key/insert-text-by-key/text-end.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertTextByKey('a', 4, 'x') } @@ -19,9 +19,7 @@ export const input = ( export const output = ( - wo +rd + wo rd + ) diff --git a/packages/slate/test/changes/by-key/insert-text-by-key/text-middle-with-marks.js b/packages/slate/test/changes/by-key/insert-text-by-key/text-middle-with-marks.js index 7df1092a4..eaaa50c95 100644 --- a/packages/slate/test/changes/by-key/insert-text-by-key/text-middle-with-marks.js +++ b/packages/slate/test/changes/by-key/insert-text-by-key/text-middle-with-marks.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertTextByKey('a', 2, 'x', [{ type: 'bold' }]) } diff --git a/packages/slate/test/changes/by-key/insert-text-by-key/text-middle.js b/packages/slate/test/changes/by-key/insert-text-by-key/text-middle.js index 3c8866e47..a8bbefd7e 100644 --- a/packages/slate/test/changes/by-key/insert-text-by-key/text-middle.js +++ b/packages/slate/test/changes/by-key/insert-text-by-key/text-middle.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.insertTextByKey('a', 2, 'x') } @@ -19,9 +19,7 @@ export const input = ( export const output = ( - - wordx - +wordx ) diff --git a/packages/slate/test/changes/by-key/merge-node-by-key/block.js b/packages/slate/test/changes/by-key/merge-node-by-key/block.js index 1c5eb1f89..17e385eb6 100644 --- a/packages/slate/test/changes/by-key/merge-node-by-key/block.js +++ b/packages/slate/test/changes/by-key/merge-node-by-key/block.js @@ -2,19 +2,15 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.mergeNodeByKey('a') } export const input = ( - - woxrd - +woxrd ) @@ -22,9 +18,7 @@ export const input = ( export const output = ( - - one - -- two - +one +two ) diff --git a/packages/slate/test/changes/by-key/move-node-by-key/block.js b/packages/slate/test/changes/by-key/move-node-by-key/block.js index 2c7b8fdc1..56d574eee 100644 --- a/packages/slate/test/changes/by-key/move-node-by-key/block.js +++ b/packages/slate/test/changes/by-key/move-node-by-key/block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.moveNodeByKey('a', 'b', 1) } @@ -12,9 +12,7 @@ export const input = ( - - onetwo - +onetwo - one - two - +two ) @@ -30,14 +28,11 @@ export const output = ( - - two - +two diff --git a/packages/slate/test/changes/by-key/move-node-by-key/inline.js b/packages/slate/test/changes/by-key/move-node-by-key/inline.js index dd525ff3d..ecf556b22 100644 --- a/packages/slate/test/changes/by-key/move-node-by-key/inline.js +++ b/packages/slate/test/changes/by-key/move-node-by-key/inline.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.moveNodeByKey('a', 'b', 3) } @@ -10,7 +10,9 @@ export const input = ( one diff --git a/packages/slate/test/changes/by-key/move-node-by-key/text.js b/packages/slate/test/changes/by-key/move-node-by-key/text.js index f472bb894..7aab1c000 100644 --- a/packages/slate/test/changes/by-key/move-node-by-key/text.js +++ b/packages/slate/test/changes/by-key/move-node-by-key/text.js @@ -2,16 +2,14 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.moveNodeByKey('a', 'b', 1) } export const input = ( @@ -22,7 +24,9 @@ export const output = ( - one + + one + two two - one + + one + @@ -25,9 +23,7 @@ export const output = ( - - one - +one @@ -22,9 +20,7 @@ export const input = ( export const output = ( two diff --git a/packages/slate/test/changes/by-key/move-node-by-key/to-sibling.js b/packages/slate/test/changes/by-key/move-node-by-key/to-sibling.js index 1c0103c3f..f9ede1fef 100644 --- a/packages/slate/test/changes/by-key/move-node-by-key/to-sibling.js +++ b/packages/slate/test/changes/by-key/move-node-by-key/to-sibling.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.moveNodeByKey('a', 'b', 1) } @@ -13,9 +13,7 @@ export const input = ( - - onetwo - +onetwo one -- two - +two ) @@ -23,9 +21,7 @@ export const output = ( -- two - +two diff --git a/packages/slate/test/changes/by-key/remove-node-by-key/block.js b/packages/slate/test/changes/by-key/remove-node-by-key/block.js index 8490df57e..07373ad79 100644 --- a/packages/slate/test/changes/by-key/remove-node-by-key/block.js +++ b/packages/slate/test/changes/by-key/remove-node-by-key/block.js @@ -2,19 +2,15 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.removeNodeByKey('a') } export const input = ( one ) @@ -22,9 +18,7 @@ export const input = ( export const output = ( - - one - -- two - +one +two ) diff --git a/packages/slate/test/changes/by-key/remove-node-by-key/inline.js b/packages/slate/test/changes/by-key/remove-node-by-key/inline.js index 46ec87fbf..af5846d85 100644 --- a/packages/slate/test/changes/by-key/remove-node-by-key/inline.js +++ b/packages/slate/test/changes/by-key/remove-node-by-key/inline.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.removeNodeByKey('a') } @@ -12,9 +12,7 @@ export const input = ( - - one - +one one -- two - +two ) diff --git a/packages/slate/test/changes/by-key/remove-node-by-key/selection-inside.js b/packages/slate/test/changes/by-key/remove-node-by-key/selection-inside.js index eef73e3c4..de92168c5 100644 --- a/packages/slate/test/changes/by-key/remove-node-by-key/selection-inside.js +++ b/packages/slate/test/changes/by-key/remove-node-by-key/selection-inside.js @@ -2,18 +2,18 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.removeNodeByKey('a') } export const input = ( - - two - +two diff --git a/packages/slate/test/changes/by-key/remove-node-by-key/text.js b/packages/slate/test/changes/by-key/remove-node-by-key/text.js index a114adfa7..6446f4ecc 100644 --- a/packages/slate/test/changes/by-key/remove-node-by-key/text.js +++ b/packages/slate/test/changes/by-key/remove-node-by-key/text.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.removeNodeByKey('a') } @@ -10,11 +10,11 @@ export const input = ( + one - one - -- t +wo + t wo + ) diff --git a/packages/slate/test/changes/by-key/remove-text-by-key/adjacent-non-void-inlines.js b/packages/slate/test/changes/by-key/remove-text-by-key/adjacent-non-void-inlines.js index f6c2f6199..106f14188 100644 --- a/packages/slate/test/changes/by-key/remove-text-by-key/adjacent-non-void-inlines.js +++ b/packages/slate/test/changes/by-key/remove-text-by-key/adjacent-non-void-inlines.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.removeTextByKey('a', 0, 1) } @@ -10,7 +10,9 @@ export const input = ( - -- one - two + ++ one + two @@ -20,7 +22,8 @@ export const output = ( - one a two + one +a + twodiff --git a/packages/slate/test/changes/by-key/remove-text-by-key/inline-last-character.js b/packages/slate/test/changes/by-key/remove-text-by-key/inline-last-character.js index 8824b6ae1..7af8bf964 100644 --- a/packages/slate/test/changes/by-key/remove-text-by-key/inline-last-character.js +++ b/packages/slate/test/changes/by-key/remove-text-by-key/inline-last-character.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.removeTextByKey('a', 0, 1) } @@ -10,7 +10,9 @@ export const input = ( - onetwo + one + two diff --git a/packages/slate/test/changes/by-key/remove-text-by-key/inline-nested-last-character.js b/packages/slate/test/changes/by-key/remove-text-by-key/inline-nested-last-character.js index 53eab291b..6004d6afe 100644 --- a/packages/slate/test/changes/by-key/remove-text-by-key/inline-nested-last-character.js +++ b/packages/slate/test/changes/by-key/remove-text-by-key/inline-nested-last-character.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.removeTextByKey('a', 0, 1) } @@ -10,7 +10,13 @@ export const input = ( - a + +a +diff --git a/packages/slate/test/changes/by-key/remove-text-by-key/inline-void.js b/packages/slate/test/changes/by-key/remove-text-by-key/inline-void.js index 1dbea7013..dd69661a7 100644 --- a/packages/slate/test/changes/by-key/remove-text-by-key/inline-void.js +++ b/packages/slate/test/changes/by-key/remove-text-by-key/inline-void.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.removeTextByKey('a', 0, 1) } @@ -11,7 +11,9 @@ export const input = ( - + + a + ++ +a + @@ -22,7 +24,8 @@ export const output = ( - + {' '} + {' '} + diff --git a/packages/slate/test/changes/by-key/remove-text-by-key/inline.js b/packages/slate/test/changes/by-key/remove-text-by-key/inline.js index aa0fbae8c..87037acc4 100644 --- a/packages/slate/test/changes/by-key/remove-text-by-key/inline.js +++ b/packages/slate/test/changes/by-key/remove-text-by-key/inline.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.removeTextByKey('a', 3, 1) } @@ -10,7 +10,9 @@ export const input = ( - + + diff --git a/packages/slate/test/changes/by-key/remove-text-by-key/next-void-inline.js b/packages/slate/test/changes/by-key/remove-text-by-key/next-void-inline.js index 5220c7202..4a88c9f6a 100644 --- a/packages/slate/test/changes/by-key/remove-text-by-key/next-void-inline.js +++ b/packages/slate/test/changes/by-key/remove-text-by-key/next-void-inline.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.removeTextByKey('a', 0, 1) } @@ -10,7 +10,9 @@ export const input = ( - word + +word +@@ -20,7 +22,8 @@ export const output = ( - one a + one + a +diff --git a/packages/slate/test/changes/by-key/remove-text-by-key/previous-void-inline.js b/packages/slate/test/changes/by-key/remove-text-by-key/previous-void-inline.js index 32c996b46..310de2ba7 100644 --- a/packages/slate/test/changes/by-key/remove-text-by-key/previous-void-inline.js +++ b/packages/slate/test/changes/by-key/remove-text-by-key/previous-void-inline.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.removeTextByKey('a', 0, 1) } @@ -10,7 +10,9 @@ export const input = ( - one + one + @@ -20,7 +22,8 @@ export const output = ( - a two ++ a + twodiff --git a/packages/slate/test/changes/by-key/remove-text-by-key/selection-after.js b/packages/slate/test/changes/by-key/remove-text-by-key/selection-after.js index 79150ca94..ec3741498 100644 --- a/packages/slate/test/changes/by-key/remove-text-by-key/selection-after.js +++ b/packages/slate/test/changes/by-key/remove-text-by-key/selection-after.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.removeTextByKey('a', 3, 1) } @@ -10,7 +10,9 @@ export const input = ( - two + + two diff --git a/packages/slate/test/changes/by-key/remove-text-by-key/selection-before.js b/packages/slate/test/changes/by-key/remove-text-by-key/selection-before.js index eb0fc6eaf..842a77cf0 100644 --- a/packages/slate/test/changes/by-key/remove-text-by-key/selection-before.js +++ b/packages/slate/test/changes/by-key/remove-text-by-key/selection-before.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.removeTextByKey('a', 0, 1) } @@ -10,7 +10,9 @@ export const input = ( - w +or d + w or d + diff --git a/packages/slate/test/changes/by-key/remove-text-by-key/selection-middle.js b/packages/slate/test/changes/by-key/remove-text-by-key/selection-middle.js index 8bc9b0a88..f909d2450 100644 --- a/packages/slate/test/changes/by-key/remove-text-by-key/selection-middle.js +++ b/packages/slate/test/changes/by-key/remove-text-by-key/selection-middle.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.removeTextByKey('a', 2, 1) } @@ -10,7 +10,9 @@ export const input = ( - w +or d + w or d + diff --git a/packages/slate/test/changes/by-key/remove-text-by-key/selection-start.js b/packages/slate/test/changes/by-key/remove-text-by-key/selection-start.js index de1cd2756..75c2f2326 100644 --- a/packages/slate/test/changes/by-key/remove-text-by-key/selection-start.js +++ b/packages/slate/test/changes/by-key/remove-text-by-key/selection-start.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.removeTextByKey('a', 2, 1) } @@ -10,7 +10,9 @@ export const input = ( - + word + word + diff --git a/packages/slate/test/changes/by-key/remove-text-by-key/text.js b/packages/slate/test/changes/by-key/remove-text-by-key/text.js index 4ea9405f4..c38a3aa1f 100644 --- a/packages/slate/test/changes/by-key/remove-text-by-key/text.js +++ b/packages/slate/test/changes/by-key/remove-text-by-key/text.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.removeTextByKey('a', 3, 1) } @@ -19,9 +19,7 @@ export const input = ( export const output = ( - w +or d + w or d + ) diff --git a/packages/slate/test/changes/by-key/replace-node-by-key/block.js b/packages/slate/test/changes/by-key/replace-node-by-key/block.js index 56c9a12a1..3b4294986 100644 --- a/packages/slate/test/changes/by-key/replace-node-by-key/block.js +++ b/packages/slate/test/changes/by-key/replace-node-by-key/block.js @@ -2,19 +2,15 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.replaceNodeByKey('a', { object: 'block', type: 'quote' }) } export const input = ( - - wor - +wor ) @@ -22,9 +18,7 @@ export const input = ( export const output = ( - - one - -- two - +one +two diff --git a/packages/slate/test/changes/by-key/replace-node-by-key/inline.js b/packages/slate/test/changes/by-key/replace-node-by-key/inline.js index 141c1b9b2..d4f9b91fd 100644 --- a/packages/slate/test/changes/by-key/replace-node-by-key/inline.js +++ b/packages/slate/test/changes/by-key/replace-node-by-key/inline.js @@ -2,8 +2,12 @@ import h from '../../../helpers/h' -export default function (change) { - change.replaceNodeByKey('a', { object: 'inline', type: 'emoji', isVoid: true }) +export default function(change) { + change.replaceNodeByKey('a', { + object: 'inline', + type: 'emoji', + isVoid: true, + }) } export const input = ( diff --git a/packages/slate/test/changes/by-key/replace-node-by-key/text.js b/packages/slate/test/changes/by-key/replace-node-by-key/text.js index 1182cb81f..11aafe268 100644 --- a/packages/slate/test/changes/by-key/replace-node-by-key/text.js +++ b/packages/slate/test/changes/by-key/replace-node-by-key/text.js @@ -2,16 +2,14 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.replaceNodeByKey('a', { object: 'text', leaves: [{ text: 'three' }] }) } export const input = ( - - one - +one ) @@ -30,14 +28,11 @@ export const output = ( - - one - +one @@ -22,12 +20,8 @@ export const input = ( export const output = ( one ) diff --git a/packages/slate/test/changes/by-key/set-mark-by-key/with-data.js b/packages/slate/test/changes/by-key/set-mark-by-key/with-data.js index f483fb6da..cbb57aef7 100644 --- a/packages/slate/test/changes/by-key/set-mark-by-key/with-data.js +++ b/packages/slate/test/changes/by-key/set-mark-by-key/with-data.js @@ -2,20 +2,28 @@ import h from '../../../helpers/h' -export default function (change) { - change.setMarkByKey('a', 0, 2, { - type: 'bold', - data: { thing: 'value' }, - }, { - data: { thing: false }, - }) +export default function(change) { + change.setMarkByKey( + 'a', + 0, + 2, + { + type: 'bold', + data: { thing: 'value' }, + }, + { + data: { thing: false }, + } + ) } export const input = ( - - one - -- three - +one +three @@ -25,7 +33,8 @@ export const output = ( - word ++ word + diff --git a/packages/slate/test/changes/by-key/set-node-by-key/block.js b/packages/slate/test/changes/by-key/set-node-by-key/block.js index 05deb2d29..b6d907342 100644 --- a/packages/slate/test/changes/by-key/set-node-by-key/block.js +++ b/packages/slate/test/changes/by-key/set-node-by-key/block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.setNodeByKey('a', { type: 'quote', data: { thing: false }, @@ -12,9 +12,7 @@ export default function (change) { export const input = ( - word + wo + rd ) @@ -22,9 +20,7 @@ export const input = ( export const output = ( - - word - +word ) diff --git a/packages/slate/test/changes/by-key/set-node-by-key/inline-with-is-void.js b/packages/slate/test/changes/by-key/set-node-by-key/inline-with-is-void.js index dec228d55..bb12869eb 100644 --- a/packages/slate/test/changes/by-key/set-node-by-key/inline-with-is-void.js +++ b/packages/slate/test/changes/by-key/set-node-by-key/inline-with-is-void.js @@ -2,10 +2,10 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.setNodeByKey('a', { type: 'emoji', - isVoid: true + isVoid: true, }) } @@ -13,7 +13,9 @@ export const input = ( - - word -+word@@ -23,7 +25,8 @@ export const output = ( - word + + word + diff --git a/packages/slate/test/changes/by-key/set-node-by-key/string-shorthand.js b/packages/slate/test/changes/by-key/set-node-by-key/string-shorthand.js index 682eb8c96..755593220 100644 --- a/packages/slate/test/changes/by-key/set-node-by-key/string-shorthand.js +++ b/packages/slate/test/changes/by-key/set-node-by-key/string-shorthand.js @@ -2,16 +2,14 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.setNodeByKey('a', 'quote') } export const input = ( - + + ) @@ -19,9 +17,7 @@ export const input = ( export const output = ( - - word - +word ) diff --git a/packages/slate/test/changes/by-key/split-descendants-by-key/block-with-selection.js b/packages/slate/test/changes/by-key/split-descendants-by-key/block-with-selection.js index 2b3b368e5..5be2b996f 100644 --- a/packages/slate/test/changes/by-key/split-descendants-by-key/block-with-selection.js +++ b/packages/slate/test/changes/by-key/split-descendants-by-key/block-with-selection.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.splitDescendantsByKey('a', 'b', 2) } @@ -10,7 +10,9 @@ export const input = ( - - word -+worddiff --git a/packages/slate/test/changes/by-key/split-descendants-by-key/block.js b/packages/slate/test/changes/by-key/split-descendants-by-key/block.js index 9356b91cb..630283af3 100644 --- a/packages/slate/test/changes/by-key/split-descendants-by-key/block.js +++ b/packages/slate/test/changes/by-key/split-descendants-by-key/block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.splitDescendantsByKey('a', 'b', 2) } @@ -19,12 +19,8 @@ export const input = ( export const output = ( - w +or d + w or d + ) diff --git a/packages/slate/test/changes/by-key/split-node-by-key/block-with-selection.js b/packages/slate/test/changes/by-key/split-node-by-key/block-with-selection.js index 512b1c47e..c5ac39e0d 100644 --- a/packages/slate/test/changes/by-key/split-node-by-key/block-with-selection.js +++ b/packages/slate/test/changes/by-key/split-node-by-key/block-with-selection.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.splitNodeByKey('a', 2) } @@ -10,7 +10,12 @@ export const input = ( - - wo - -- rd - +wo +rd @@ -20,10 +25,14 @@ export const output = ( - o netw o + + o ne + + + tw o + diff --git a/packages/slate/test/changes/by-key/split-node-by-key/block.js b/packages/slate/test/changes/by-key/split-node-by-key/block.js index 9e0ffb3a3..9c68b6cbe 100644 --- a/packages/slate/test/changes/by-key/split-node-by-key/block.js +++ b/packages/slate/test/changes/by-key/split-node-by-key/block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.splitNodeByKey('a', 2) } @@ -10,7 +10,8 @@ export const input = ( - o ne + + o ne + - tw o + + tw o + diff --git a/packages/slate/test/changes/by-key/unwrap-block-by-key/single-block.js b/packages/slate/test/changes/by-key/unwrap-block-by-key/single-block.js index fbfd704f8..5f6e15506 100644 --- a/packages/slate/test/changes/by-key/unwrap-block-by-key/single-block.js +++ b/packages/slate/test/changes/by-key/unwrap-block-by-key/single-block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.unwrapBlockByKey('a', 'quote') } @@ -10,14 +10,10 @@ export const input = ( - onetwo + one + two @@ -26,13 +22,9 @@ export const input = ( export const output = ( -- word - +word -- word - +word diff --git a/packages/slate/test/changes/by-key/unwrap-inline-by-key/single-block.js b/packages/slate/test/changes/by-key/unwrap-inline-by-key/single-block.js index 8d7cda31d..c223c3ec9 100644 --- a/packages/slate/test/changes/by-key/unwrap-inline-by-key/single-block.js +++ b/packages/slate/test/changes/by-key/unwrap-inline-by-key/single-block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.unwrapInlineByKey('a', 'link') } diff --git a/packages/slate/test/changes/by-key/unwrap-node-by-key/block.js b/packages/slate/test/changes/by-key/unwrap-node-by-key/block.js index 86aeaad32..91d6a06a6 100644 --- a/packages/slate/test/changes/by-key/unwrap-node-by-key/block.js +++ b/packages/slate/test/changes/by-key/unwrap-node-by-key/block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.unwrapNodeByKey('a') } @@ -10,9 +10,7 @@ export const input = ( - - word - +word -- word - +word @@ -21,9 +19,7 @@ export const input = ( export const output = ( -- word - +word ) diff --git a/packages/slate/test/changes/by-key/unwrap-node-by-key/first-block.js b/packages/slate/test/changes/by-key/unwrap-node-by-key/first-block.js index 71c7a8f4c..3482fdda6 100644 --- a/packages/slate/test/changes/by-key/unwrap-node-by-key/first-block.js +++ b/packages/slate/test/changes/by-key/unwrap-node-by-key/first-block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.unwrapNodeByKey('a') } @@ -10,12 +10,8 @@ export const input = ( - - word - +word @@ -24,13 +20,9 @@ export const input = ( export const output = ( -- one - -- two - +one +two diff --git a/packages/slate/test/changes/by-key/unwrap-node-by-key/last-block.js b/packages/slate/test/changes/by-key/unwrap-node-by-key/last-block.js index 67d244f16..87a69a40d 100644 --- a/packages/slate/test/changes/by-key/unwrap-node-by-key/last-block.js +++ b/packages/slate/test/changes/by-key/unwrap-node-by-key/last-block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.unwrapNodeByKey('a') } @@ -10,12 +10,8 @@ export const input = ( - - one - +one -- two - +two @@ -25,13 +21,9 @@ export const output = ( -- one - -- two - +one +two ) diff --git a/packages/slate/test/changes/by-key/unwrap-node-by-key/middle-block.js b/packages/slate/test/changes/by-key/unwrap-node-by-key/middle-block.js index b1cc95036..c46a020cc 100644 --- a/packages/slate/test/changes/by-key/unwrap-node-by-key/middle-block.js +++ b/packages/slate/test/changes/by-key/unwrap-node-by-key/middle-block.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.unwrapNodeByKey('a') } @@ -10,15 +10,9 @@ export const input = ( --- one - +one - two - +two @@ -28,17 +22,11 @@ export const output = ( -- one - -- two - -- three - +one +two +three diff --git a/packages/slate/test/changes/by-key/wrap-block-by-key/block.js b/packages/slate/test/changes/by-key/wrap-block-by-key/block.js index 33c485a1c..f046378c9 100644 --- a/packages/slate/test/changes/by-key/wrap-block-by-key/block.js +++ b/packages/slate/test/changes/by-key/wrap-block-by-key/block.js @@ -2,16 +2,14 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.wrapBlockByKey('a', 'quote') } export const input = ( --- one - +one - two - +two -- three - +three ) @@ -20,9 +18,7 @@ export const output = ( - - word - +word diff --git a/packages/slate/test/changes/by-key/wrap-block-by-key/text.js b/packages/slate/test/changes/by-key/wrap-block-by-key/text.js index 29818b822..0966708a1 100644 --- a/packages/slate/test/changes/by-key/wrap-block-by-key/text.js +++ b/packages/slate/test/changes/by-key/wrap-block-by-key/text.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.wrapBlockByKey('a', 'quote') } @@ -20,9 +20,7 @@ export const output = ( -- word - +word diff --git a/packages/slate/test/changes/general/call/call-no-arguments.js b/packages/slate/test/changes/general/call/call-no-arguments.js index dc7b83493..899e17a66 100644 --- a/packages/slate/test/changes/general/call/call-no-arguments.js +++ b/packages/slate/test/changes/general/call/call-no-arguments.js @@ -9,7 +9,7 @@ function insertImageBlock(change, blockType) { }) } -export default function (change) { +export default function(change) { change.call(insertImageBlock) } @@ -19,9 +19,7 @@ export const input = ( - - word -+word- one - two - +two ) diff --git a/packages/slate/test/changes/general/call/call-with-arguments.js b/packages/slate/test/changes/general/call/call-with-arguments.js index b825f7fab..a10213835 100644 --- a/packages/slate/test/changes/general/call/call-with-arguments.js +++ b/packages/slate/test/changes/general/call/call-with-arguments.js @@ -9,7 +9,7 @@ function insertVoid(change, blockType) { }) } -export default function (change) { +export default function(change) { change.call(insertVoid, 'image') } @@ -19,9 +19,7 @@ export const input = ( - {' '} -+ {' '} + - one - -- two - +one +two - one - two - +two ) diff --git a/packages/slate/test/changes/index.js b/packages/slate/test/changes/index.js index 963fcf11c..a6df28834 100644 --- a/packages/slate/test/changes/index.js +++ b/packages/slate/test/changes/index.js @@ -1,4 +1,3 @@ - import assert from 'assert' import fs from 'fs-promise' // eslint-disable-line import/no-extraneous-dependencies import toCamel from 'to-camel-case' // eslint-disable-line import/no-extraneous-dependencies @@ -10,7 +9,9 @@ import { basename, extname, resolve } from 'path' describe('changes', async () => { const dir = resolve(__dirname) - const categories = fs.readdirSync(dir).filter(c => c[0] != '.' && c != 'index.js') + const categories = fs + .readdirSync(dir) + .filter(c => c[0] != '.' && c != 'index.js') for (const category of categories) { describe(category, () => { @@ -20,7 +21,10 @@ describe('changes', async () => { for (const method of methods) { describe(toCamel(method), () => { const testDir = resolve(categoryDir, method) - const tests = fs.readdirSync(testDir).filter(t => t[0] != '.' && !!~t.indexOf('.js')).map(t => basename(t, extname(t))) + const tests = fs + .readdirSync(testDir) + .filter(t => t[0] != '.' && !!~t.indexOf('.js')) + .map(t => basename(t, extname(t))) for (const test of tests) { it(test, async () => { diff --git a/packages/slate/test/changes/on-selection/blur/basic.js b/packages/slate/test/changes/on-selection/blur/basic.js index 6ed2def84..43543532e 100644 --- a/packages/slate/test/changes/on-selection/blur/basic.js +++ b/packages/slate/test/changes/on-selection/blur/basic.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.blur() } @@ -19,9 +19,7 @@ export const input = ( export const output = ( - {' '} -+ {' '} + - one - -- two - +one +two ) diff --git a/packages/slate/test/changes/on-selection/collapse-to-anchor/already-collapsed.js b/packages/slate/test/changes/on-selection/collapse-to-anchor/already-collapsed.js index 0f76bd508..067549e3f 100644 --- a/packages/slate/test/changes/on-selection/collapse-to-anchor/already-collapsed.js +++ b/packages/slate/test/changes/on-selection/collapse-to-anchor/already-collapsed.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.collapseToAnchor() } diff --git a/packages/slate/test/changes/on-selection/collapse-to-anchor/basic.js b/packages/slate/test/changes/on-selection/collapse-to-anchor/basic.js index 4a90c4938..f07f958c7 100644 --- a/packages/slate/test/changes/on-selection/collapse-to-anchor/basic.js +++ b/packages/slate/test/changes/on-selection/collapse-to-anchor/basic.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.collapseToAnchor() } diff --git a/packages/slate/test/changes/on-selection/collapse-to-end/already-collapsed.js b/packages/slate/test/changes/on-selection/collapse-to-end/already-collapsed.js index 8ccdf4c7f..fb1a38b48 100644 --- a/packages/slate/test/changes/on-selection/collapse-to-end/already-collapsed.js +++ b/packages/slate/test/changes/on-selection/collapse-to-end/already-collapsed.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.collapseToEnd() } diff --git a/packages/slate/test/changes/on-selection/collapse-to-end/basic.js b/packages/slate/test/changes/on-selection/collapse-to-end/basic.js index 19a7b94d6..81e88a288 100644 --- a/packages/slate/test/changes/on-selection/collapse-to-end/basic.js +++ b/packages/slate/test/changes/on-selection/collapse-to-end/basic.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.collapseToEnd() } diff --git a/packages/slate/test/changes/on-selection/collapse-to-end/void.js b/packages/slate/test/changes/on-selection/collapse-to-end/void.js index 1cc1d95e8..b1842c0cd 100644 --- a/packages/slate/test/changes/on-selection/collapse-to-end/void.js +++ b/packages/slate/test/changes/on-selection/collapse-to-end/void.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.collapseToEnd() } @@ -10,7 +10,7 @@ export const input = ( - - one - +one @@ -20,7 +20,8 @@ export const output = ( - {' '} + diff --git a/packages/slate/test/changes/on-selection/collapse-to-focus/already-collapsed.js b/packages/slate/test/changes/on-selection/collapse-to-focus/already-collapsed.js index c3bd182fb..4d1bc40d3 100644 --- a/packages/slate/test/changes/on-selection/collapse-to-focus/already-collapsed.js +++ b/packages/slate/test/changes/on-selection/collapse-to-focus/already-collapsed.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.collapseToFocus() } diff --git a/packages/slate/test/changes/on-selection/collapse-to-focus/basic.js b/packages/slate/test/changes/on-selection/collapse-to-focus/basic.js index 4be87eef7..382c6fac1 100644 --- a/packages/slate/test/changes/on-selection/collapse-to-focus/basic.js +++ b/packages/slate/test/changes/on-selection/collapse-to-focus/basic.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.collapseToFocus() } diff --git a/packages/slate/test/changes/on-selection/collapse-to-start/already-collapsed.js b/packages/slate/test/changes/on-selection/collapse-to-start/already-collapsed.js index fcb0b5cda..69703022a 100644 --- a/packages/slate/test/changes/on-selection/collapse-to-start/already-collapsed.js +++ b/packages/slate/test/changes/on-selection/collapse-to-start/already-collapsed.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.collapseToStart() } diff --git a/packages/slate/test/changes/on-selection/collapse-to-start/basic.js b/packages/slate/test/changes/on-selection/collapse-to-start/basic.js index c65b82702..b92027eb9 100644 --- a/packages/slate/test/changes/on-selection/collapse-to-start/basic.js +++ b/packages/slate/test/changes/on-selection/collapse-to-start/basic.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.collapseToStart() } diff --git a/packages/slate/test/changes/on-selection/collapse-to-start/void.js b/packages/slate/test/changes/on-selection/collapse-to-start/void.js index edb61f401..fc2720b00 100644 --- a/packages/slate/test/changes/on-selection/collapse-to-start/void.js +++ b/packages/slate/test/changes/on-selection/collapse-to-start/void.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.collapseToStart() } @@ -10,7 +10,7 @@ export const input = ( - {' '} + {' '} + diff --git a/packages/slate/test/changes/on-selection/focus/basic.js b/packages/slate/test/changes/on-selection/focus/basic.js index 9c9d920d8..de85a697b 100644 --- a/packages/slate/test/changes/on-selection/focus/basic.js +++ b/packages/slate/test/changes/on-selection/focus/basic.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.focus() } @@ -17,7 +17,9 @@ export const input = ( export const output = ( - {' '} + ) diff --git a/packages/slate/test/changes/on-selection/move-to/with-object.js b/packages/slate/test/changes/on-selection/move-to/with-object.js index b4e26bf7d..f05120747 100644 --- a/packages/slate/test/changes/on-selection/move-to/with-object.js +++ b/packages/slate/test/changes/on-selection/move-to/with-object.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { const { value } = change const { startText } = value change.select({ diff --git a/packages/slate/test/changes/on-selection/move-to/with-selection.js b/packages/slate/test/changes/on-selection/move-to/with-selection.js index 349b3fbeb..bd3d0e515 100644 --- a/packages/slate/test/changes/on-selection/move-to/with-selection.js +++ b/packages/slate/test/changes/on-selection/move-to/with-selection.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { const { value } = change const { selection, startText } = value const range = selection.merge({ diff --git a/packages/slate/test/changes/on-selection/select-all/basic.js b/packages/slate/test/changes/on-selection/select-all/basic.js index 43ff220d1..9b89fa2aa 100644 --- a/packages/slate/test/changes/on-selection/select-all/basic.js +++ b/packages/slate/test/changes/on-selection/select-all/basic.js @@ -2,7 +2,7 @@ import h from '../../../helpers/h' -export default function (change) { +export default function(change) { change.selectAll() } @@ -12,12 +12,8 @@ export const input = ( - + one + one + - one - two - -- three - +two +three - one - two - +two three diff --git a/packages/slate/test/changes/on-state/set-data/simple.js b/packages/slate/test/changes/on-state/set-data/simple.js index 580e3b0f0..ec07d76cd 100644 --- a/packages/slate/test/changes/on-state/set-data/simple.js +++ b/packages/slate/test/changes/on-state/set-data/simple.js @@ -2,19 +2,15 @@ import h from '../../../helpers/h' -export default function (change) { - change.setValue({ data: { thing: 'value' }}) +export default function(change) { + change.setValue({ data: { thing: 'value' } }) } export const input = () @@ -22,12 +18,8 @@ export const input = ( export const output = ( - - word - -- another - +word +another ) diff --git a/packages/slate/test/helpers/h.js b/packages/slate/test/helpers/h.js index 938dd381d..c6e1b13aa 100644 --- a/packages/slate/test/helpers/h.js +++ b/packages/slate/test/helpers/h.js @@ -1,4 +1,3 @@ - import { createHyperscript } from 'slate-hyperscript' /** @@ -18,7 +17,7 @@ const h = createHyperscript({ image: { type: 'image', isVoid: true, - } + }, }, inlines: { link: 'link', @@ -27,7 +26,7 @@ const h = createHyperscript({ emoji: { type: 'emoji', isVoid: true, - } + }, }, marks: { b: 'bold', diff --git a/packages/slate/test/history/index.js b/packages/slate/test/history/index.js index 9eb9b6056..5b143dcbe 100644 --- a/packages/slate/test/history/index.js +++ b/packages/slate/test/history/index.js @@ -1,4 +1,3 @@ - import assert from 'assert' import fs from 'fs' import { basename, extname, resolve } from 'path' @@ -9,12 +8,17 @@ import { basename, extname, resolve } from 'path' describe('history', async () => { const dir = resolve(__dirname) - const methods = fs.readdirSync(dir).filter(d => d[0] != '.' && d != 'index.js') + const methods = fs + .readdirSync(dir) + .filter(d => d[0] != '.' && d != 'index.js') for (const method of methods) { describe(method, () => { const testDir = resolve(dir, method) - const tests = fs.readdirSync(testDir).filter(f => f[0] != '.' && !!~f.indexOf('.js')).map(f => basename(f, extname(f))) + const tests = fs + .readdirSync(testDir) + .filter(f => f[0] != '.' && !!~f.indexOf('.js')) + .map(f => basename(f, extname(f))) for (const test of tests) { const module = require(resolve(testDir, test)) diff --git a/packages/slate/test/history/undo/add-mark-across-blocks.js b/packages/slate/test/history/undo/add-mark-across-blocks.js index ee08000c5..4a5902394 100644 --- a/packages/slate/test/history/undo/add-mark-across-blocks.js +++ b/packages/slate/test/history/undo/add-mark-across-blocks.js @@ -2,14 +2,12 @@ import h from '../../helpers/h' -export default function (value) { +export default function(value) { return value .change() .addMark('bold') - .value - .change() - .undo() - .value + .value.change() + .undo().value } export const input = ( diff --git a/packages/slate/test/history/undo/add-mark-across-marks.js b/packages/slate/test/history/undo/add-mark-across-marks.js index 459f72dc6..4e029333e 100644 --- a/packages/slate/test/history/undo/add-mark-across-marks.js +++ b/packages/slate/test/history/undo/add-mark-across-marks.js @@ -2,21 +2,21 @@ import h from '../../helpers/h' -export default function (value) { +export default function(value) { return value .change() .addMark('bold') - .value - .change() - .undo() - .value + .value.change() + .undo().value } export const input = ( - - word - -- another - +word +another diff --git a/packages/slate/test/history/undo/add-mark-across-same-mark.js b/packages/slate/test/history/undo/add-mark-across-same-mark.js index 3013aad83..d26b971fb 100644 --- a/packages/slate/test/history/undo/add-mark-across-same-mark.js +++ b/packages/slate/test/history/undo/add-mark-across-same-mark.js @@ -2,21 +2,21 @@ import h from '../../helpers/h' -export default function (value) { +export default function(value) { return value .change() .addMark('bold') - .value - .change() - .undo() - .value + .value.change() + .undo().value } export const input = ( - w or d + + w o + r d diff --git a/packages/slate/test/history/undo/add-mark.js b/packages/slate/test/history/undo/add-mark.js index 4311baca8..a7e4e272c 100644 --- a/packages/slate/test/history/undo/add-mark.js +++ b/packages/slate/test/history/undo/add-mark.js @@ -2,14 +2,12 @@ import h from '../../helpers/h' -export default function (value) { +export default function(value) { return value .change() .addMark('bold') - .value - .change() - .undo() - .value + .value.change() + .undo().value } export const input = ( diff --git a/packages/slate/test/history/undo/delete-across-blocks.js b/packages/slate/test/history/undo/delete-across-blocks.js index 73b2ffedd..46e0c4bbd 100644 --- a/packages/slate/test/history/undo/delete-across-blocks.js +++ b/packages/slate/test/history/undo/delete-across-blocks.js @@ -2,14 +2,12 @@ import h from '../../helpers/h' -export default function (value) { +export default function(value) { return value .change() .delete() - .value - .change() - .undo() - .value + .value.change() + .undo().value } // the paragraph and code blocks have some random data diff --git a/packages/slate/test/history/undo/delete-across-inlines.js b/packages/slate/test/history/undo/delete-across-inlines.js index bd84dae40..d66e375c2 100644 --- a/packages/slate/test/history/undo/delete-across-inlines.js +++ b/packages/slate/test/history/undo/delete-across-inlines.js @@ -2,24 +2,26 @@ import h from '../../helpers/h' -export default function (value) { +export default function(value) { return value .change() .delete() - .value - .change() - .undo() - .value + .value.change() + .undo().value } export const input = ( - w or d + + w o + r d diff --git a/packages/slate/test/history/undo/delete-across-marks.js b/packages/slate/test/history/undo/delete-across-marks.js index f53a6a656..3b66970e6 100644 --- a/packages/slate/test/history/undo/delete-across-marks.js +++ b/packages/slate/test/history/undo/delete-across-marks.js @@ -2,21 +2,24 @@ import h from '../../helpers/h' -export default function (value) { +export default function(value) { return value .change() .delete() - .value - .change() - .undo() - .value + .value.change() + .undo().value } export const input = ( - o ne + + o ne + - tw o + + tw o + diff --git a/packages/slate/test/history/undo/delete.js b/packages/slate/test/history/undo/delete.js index 213208773..d16ac1d01 100644 --- a/packages/slate/test/history/undo/delete.js +++ b/packages/slate/test/history/undo/delete.js @@ -2,14 +2,12 @@ import h from '../../helpers/h' -export default function (value) { +export default function(value) { return value .change() .delete() - .value - .change() - .undo() - .value + .value.change() + .undo().value } export const input = ( diff --git a/packages/slate/test/history/undo/insert-block.js b/packages/slate/test/history/undo/insert-block.js index 40c2bcc4c..5b7eed03a 100644 --- a/packages/slate/test/history/undo/insert-block.js +++ b/packages/slate/test/history/undo/insert-block.js @@ -2,20 +2,20 @@ import h from '../../helpers/h' -export default function (value) { +export default function(value) { return value .change() .insertBlock('quote') - .value - .change() - .undo() - .value + .value.change() + .undo().value } export const input = ( - on etw o + + on e + + + tw o + ) diff --git a/packages/slate/test/history/undo/insert-text-contiguous.js b/packages/slate/test/history/undo/insert-text-contiguous.js index 7b9e2453c..08cf2a857 100644 --- a/packages/slate/test/history/undo/insert-text-contiguous.js +++ b/packages/slate/test/history/undo/insert-text-contiguous.js @@ -2,26 +2,24 @@ import h from '../../helpers/h' -export default function (value) { +export default function(value) { return value .change() .insertText('t') - .value - .change() + .value.change() .insertText('w') - .value - .change() + .value.change() .insertText('o') - .value - .change() - .undo() - .value + .value.change() + .undo().value } export const input = ( - + one + one + ) diff --git a/packages/slate/test/history/undo/insert-text-not-contiguous.js b/packages/slate/test/history/undo/insert-text-not-contiguous.js index bb0c821f6..ca7e2ddbb 100644 --- a/packages/slate/test/history/undo/insert-text-not-contiguous.js +++ b/packages/slate/test/history/undo/insert-text-not-contiguous.js @@ -2,28 +2,26 @@ import h from '../../helpers/h' -export default function (value) { +export default function(value) { return value .change() .insertText('t') - .value - .change() + .value.change() .move(-1) .insertText('w') - .value - .change() + .value.change() .move(-1) .insertText('o') - .value - .change() - .undo() - .value + .value.change() + .undo().value } export const input = ( - one ++ one + ) @@ -31,7 +29,9 @@ export const input = ( export const output = ( - one ++ one + ) diff --git a/packages/slate/test/history/undo/insert-text.js b/packages/slate/test/history/undo/insert-text.js index a6429f5a6..ba45234f6 100644 --- a/packages/slate/test/history/undo/insert-text.js +++ b/packages/slate/test/history/undo/insert-text.js @@ -2,14 +2,12 @@ import h from '../../helpers/h' -export default function (value) { +export default function(value) { return value .change() .insertText('text') - .value - .change() - .undo() - .value + .value.change() + .undo().value } export const input = ( diff --git a/packages/slate/test/history/undo/move-node-affecting-path.js b/packages/slate/test/history/undo/move-node-affecting-path.js index 44abdfdf9..bde344391 100644 --- a/packages/slate/test/history/undo/move-node-affecting-path.js +++ b/packages/slate/test/history/undo/move-node-affecting-path.js @@ -2,33 +2,23 @@ import h from '../../helpers/h' -export default function (value) { +export default function(value) { return value .change() .moveNodeByKey('c', 'd', 1) - .value - .change() - .undo() - .value + .value.change() + .undo().value } export const input = ( - onew +t + onew t + ) diff --git a/packages/slate/test/history/undo/move-node-before-itself.js b/packages/slate/test/history/undo/move-node-before-itself.js index 8d6c64ef6..debe65181 100644 --- a/packages/slate/test/history/undo/move-node-before-itself.js +++ b/packages/slate/test/history/undo/move-node-before-itself.js @@ -2,44 +2,28 @@ import h from '../../helpers/h' -export default function (value) { +export default function(value) { return value .change() .moveNodeByKey('h', 'a', 0) - .value - .change() - .undo() - .value + .value.change() + .undo().value } export const input = ( - - one - -- two - +one +two - -- three - -- four + +three four ) diff --git a/packages/slate/test/history/undo/move-node-by-key.js b/packages/slate/test/history/undo/move-node-by-key.js index f32c2c0b8..543f1b2d9 100644 --- a/packages/slate/test/history/undo/move-node-by-key.js +++ b/packages/slate/test/history/undo/move-node-by-key.js @@ -2,25 +2,19 @@ import h from '../../helpers/h' -export default function (value) { +export default function(value) { return value .change() .moveNodeByKey('b', 'a', 1) - .value - .change() - .undo() - .value + .value.change() + .undo().value } export const input = ( - - one - +one - -- two - +two - - three - -- four - -- five - +three +four +five - six - -- seven - +six +seven ) diff --git a/packages/slate/test/history/undo/remove-mark.js b/packages/slate/test/history/undo/remove-mark.js index 760a1956e..ca05f4cab 100644 --- a/packages/slate/test/history/undo/remove-mark.js +++ b/packages/slate/test/history/undo/remove-mark.js @@ -2,21 +2,21 @@ import h from '../../helpers/h' -export default function (value) { +export default function(value) { return value .change() .removeMark('bold') - .value - .change() - .undo() - .value + .value.change() + .undo().value } export const input = ( - - one - -- two - +one +two diff --git a/packages/slate/test/history/undo/remove-node-by-key.js b/packages/slate/test/history/undo/remove-node-by-key.js index 160f0a51d..56ed73b60 100644 --- a/packages/slate/test/history/undo/remove-node-by-key.js +++ b/packages/slate/test/history/undo/remove-node-by-key.js @@ -2,22 +2,18 @@ import h from '../../helpers/h' -export default function (value) { +export default function(value) { return value .change() .removeNodeByKey('a') - .value - .change() - .undo() - .value + .value.change() + .undo().value } export const input = ( - one + + one + ) diff --git a/packages/slate/test/history/undo/set-node-by-key-with-data.js b/packages/slate/test/history/undo/set-node-by-key-with-data.js index 719161842..fee0f8a99 100644 --- a/packages/slate/test/history/undo/set-node-by-key-with-data.js +++ b/packages/slate/test/history/undo/set-node-by-key-with-data.js @@ -2,24 +2,20 @@ import h from '../../helpers/h' -export default function (value) { +export default function(value) { return value .change() .setNodeByKey('a', { - data: { thing: 'value' } + data: { thing: 'value' }, }) - .value - .change() - .undo() - .value + .value.change() + .undo().value } export const input = ( - - one - +one ) diff --git a/packages/slate/test/history/undo/split-node-by-key-block.js b/packages/slate/test/history/undo/split-node-by-key-block.js index dc5ce92a1..6874a8b50 100644 --- a/packages/slate/test/history/undo/split-node-by-key-block.js +++ b/packages/slate/test/history/undo/split-node-by-key-block.js @@ -2,21 +2,21 @@ import h from '../../helpers/h' -export default function (value) { +export default function(value) { return value .change() .splitNodeByKey('a', 2) - .value - .change() - .undo() - .value + .value.change() + .undo().value } export const input = ( - - one - +one diff --git a/packages/slate/test/history/undo/unwrap-node-by-key.js b/packages/slate/test/history/undo/unwrap-node-by-key.js index 2bb60fb74..a6f01df37 100644 --- a/packages/slate/test/history/undo/unwrap-node-by-key.js +++ b/packages/slate/test/history/undo/unwrap-node-by-key.js @@ -2,14 +2,12 @@ import h from '../../helpers/h' -export default function (value) { +export default function(value) { return value .change() .unwrapNodeByKey('a') - .value - .change() - .undo() - .value + .value.change() + .undo().value } export const input = ( @@ -19,12 +17,8 @@ export const input = ( - one two + one + + two - one - two - -- three - +two +three diff --git a/packages/slate/test/operations/index.js b/packages/slate/test/operations/index.js index 1615d21c6..907e55e03 100644 --- a/packages/slate/test/operations/index.js +++ b/packages/slate/test/operations/index.js @@ -1,4 +1,3 @@ - import assert from 'assert' import fs from 'fs-promise' // eslint-disable-line import/no-extraneous-dependencies import toCamel from 'to-camel-case' // eslint-disable-line import/no-extraneous-dependencies @@ -10,7 +9,9 @@ import { basename, extname, resolve } from 'path' describe('operations', async () => { const dir = resolve(__dirname) - const categories = fs.readdirSync(dir).filter(c => c[0] != '.' && c != 'index.js') + const categories = fs + .readdirSync(dir) + .filter(c => c[0] != '.' && c != 'index.js') for (const category of categories) { describe(category, () => { @@ -20,7 +21,10 @@ describe('operations', async () => { for (const method of methods) { describe(toCamel(method), () => { const testDir = resolve(categoryDir, method) - const tests = fs.readdirSync(testDir).filter(t => t[0] != '.' && !!~t.indexOf('.js')).map(t => basename(t, extname(t))) + const tests = fs + .readdirSync(testDir) + .filter(t => t[0] != '.' && !!~t.indexOf('.js')) + .map(t => basename(t, extname(t))) for (const test of tests) { it(test, async () => { diff --git a/packages/slate/test/schema/core/block-create-text.js b/packages/slate/test/schema/core/block-create-text.js index 58c2d5516..07b02e7e7 100644 --- a/packages/slate/test/schema/core/block-create-text.js +++ b/packages/slate/test/schema/core/block-create-text.js @@ -31,11 +31,11 @@ export const output = { object: 'leaf', text: '', marks: [], - } - ] - } - ] - } - ] - } + }, + ], + }, + ], + }, + ], + }, } diff --git a/packages/slate/test/schema/core/document-no-inline-children.js b/packages/slate/test/schema/core/document-no-inline-children.js index 963d4c4f0..375816409 100644 --- a/packages/slate/test/schema/core/document-no-inline-children.js +++ b/packages/slate/test/schema/core/document-no-inline-children.js @@ -7,12 +7,8 @@ export const schema = {} export const input = ( ) @@ -36,11 +32,11 @@ export const output = { object: 'leaf', text: 'two', marks: [], - } - ] - } - ] - } - ] - } + }, + ], + }, + ], + }, + ], + }, } diff --git a/packages/slate/test/schema/core/document-no-text-children.js b/packages/slate/test/schema/core/document-no-text-children.js index 10c7bc881..05ca0a91b 100644 --- a/packages/slate/test/schema/core/document-no-text-children.js +++ b/packages/slate/test/schema/core/document-no-text-children.js @@ -8,9 +8,7 @@ export const input = ( - - one - - - two - + one +two ) @@ -34,11 +32,11 @@ export const output = { object: 'leaf', text: 'two', marks: [], - } - ] - } - ] - } - ] - } + }, + ], + }, + ], + }, + ], + }, } diff --git a/packages/slate/test/schema/core/inline-no-block-children.js b/packages/slate/test/schema/core/inline-no-block-children.js index 34739953c..fb6d1a5c8 100644 --- a/packages/slate/test/schema/core/inline-no-block-children.js +++ b/packages/slate/test/schema/core/inline-no-block-children.js @@ -9,9 +9,7 @@ export const input = ( one - - two - +two - @@ -38,8 +36,8 @@ export const output = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, { object: 'inline', @@ -54,10 +52,10 @@ export const output = { object: 'leaf', text: 'two', marks: [], - } - ] - } - ] + }, + ], + }, + ], }, { object: 'text', @@ -66,11 +64,11 @@ export const output = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, - ] - } - ] - } + ], + }, + ], + }, } diff --git a/packages/slate/test/schema/core/inline-text-around.js b/packages/slate/test/schema/core/inline-text-around.js index 2d11c0df3..c875a629c 100644 --- a/packages/slate/test/schema/core/inline-text-around.js +++ b/packages/slate/test/schema/core/inline-text-around.js @@ -9,12 +9,8 @@ export const input = (- one - +one two@@ -40,8 +36,8 @@ export const output = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, { object: 'inline', @@ -56,8 +52,8 @@ export const output = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, { object: 'inline', @@ -72,10 +68,10 @@ export const output = { object: 'leaf', text: 'one', marks: [], - } - ] - } - ] + }, + ], + }, + ], }, { object: 'text', @@ -84,8 +80,8 @@ export const output = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, { object: 'inline', @@ -100,10 +96,10 @@ export const output = { object: 'leaf', text: 'two', marks: [], - } - ] - } - ] + }, + ], + }, + ], }, { object: 'text', @@ -112,10 +108,10 @@ export const output = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, - ] + ], }, { object: 'text', @@ -124,11 +120,11 @@ export const output = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, - ] - } - ] - } + ], + }, + ], + }, } diff --git a/packages/slate/test/schema/core/remove-empty-inline.js b/packages/slate/test/schema/core/remove-empty-inline.js index a6e541ac1..b3d1128af 100644 --- a/packages/slate/test/schema/core/remove-empty-inline.js +++ b/packages/slate/test/schema/core/remove-empty-inline.js @@ -33,11 +33,11 @@ export const output = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, - ] - } - ] - } + ], + }, + ], + }, } diff --git a/packages/slate/test/schema/custom/child-kind-invalid-custom-optional-first.js b/packages/slate/test/schema/custom/child-kind-invalid-custom-optional-first.js index 3ae2d7766..de5b93282 100644 --- a/packages/slate/test/schema/custom/child-kind-invalid-custom-optional-first.js +++ b/packages/slate/test/schema/custom/child-kind-invalid-custom-optional-first.js @@ -9,23 +9,21 @@ export const schema = { quote: { nodes: [ { objects: ['block'], types: ['image'], min: 0, max: 1 }, - { objects: ['block'], types: ['paragraph'], min: 1 } + { objects: ['block'], types: ['paragraph'], min: 1 }, ], normalize: (change, reason, { node, child }) => { if (reason == CHILD_OBJECT_INVALID) { change.wrapBlockByKey(child.key, 'paragraph') } - } - } - } + }, + }, + }, } export const input = ( - - one - - - two - + one + two ) @@ -34,9 +32,7 @@ export const output = ( - - text -+textdiff --git a/packages/slate/test/schema/custom/child-kind-invalid-custom.js b/packages/slate/test/schema/custom/child-kind-invalid-custom.js index 38e9d4c40..f6f6f6c13 100644 --- a/packages/slate/test/schema/custom/child-kind-invalid-custom.js +++ b/packages/slate/test/schema/custom/child-kind-invalid-custom.js @@ -7,24 +7,20 @@ export const schema = { blocks: { paragraph: {}, quote: { - nodes: [ - { objects: ['block'] }, - ], + nodes: [{ objects: ['block'] }], normalize: (change, reason, { child }) => { if (reason == CHILD_OBJECT_INVALID) { change.wrapBlockByKey(child.key, 'paragraph') } - } - } - } + }, + }, + }, } export const input = ( -- text - +text ) @@ -33,9 +29,7 @@ export const output = ( - - text -+textdiff --git a/packages/slate/test/schema/custom/child-kind-invalid-default.js b/packages/slate/test/schema/custom/child-kind-invalid-default.js index f6f7186ef..11e0dcf14 100644 --- a/packages/slate/test/schema/custom/child-kind-invalid-default.js +++ b/packages/slate/test/schema/custom/child-kind-invalid-default.js @@ -6,11 +6,9 @@ export const schema = { blocks: { paragraph: {}, quote: { - nodes: [ - { objects: ['text'] }, - ] - } - } + nodes: [{ objects: ['text'] }], + }, + }, } export const input = ( diff --git a/packages/slate/test/schema/custom/child-required-custom.js b/packages/slate/test/schema/custom/child-required-custom.js index c7cf1daeb..05a8731d6 100644 --- a/packages/slate/test/schema/custom/child-required-custom.js +++ b/packages/slate/test/schema/custom/child-required-custom.js @@ -7,16 +7,17 @@ export const schema = { blocks: { paragraph: {}, quote: { - nodes: [ - { types: ['paragraph'], min: 2 }, - ], + nodes: [{ types: ['paragraph'], min: 2 }], normalize: (change, reason, { node, index }) => { if (reason == CHILD_REQUIRED) { - change.insertNodeByKey(node.key, index, { object: 'block', type: 'paragraph' }) + change.insertNodeByKey(node.key, index, { + object: 'block', + type: 'paragraph', + }) } - } - } - } + }, + }, + }, } export const input = ( diff --git a/packages/slate/test/schema/custom/child-required-default.js b/packages/slate/test/schema/custom/child-required-default.js index d63afe74a..c56ca97fd 100644 --- a/packages/slate/test/schema/custom/child-required-default.js +++ b/packages/slate/test/schema/custom/child-required-default.js @@ -6,11 +6,9 @@ export const schema = { blocks: { paragraph: {}, quote: { - nodes: [ - { types: ['paragraph'], min: 1 }, - ] - } - } + nodes: [{ types: ['paragraph'], min: 1 }], + }, + }, } export const input = ( diff --git a/packages/slate/test/schema/custom/child-type-invalid-custom.js b/packages/slate/test/schema/custom/child-type-invalid-custom.js index 9ae2ddaf1..9beedf7bf 100644 --- a/packages/slate/test/schema/custom/child-type-invalid-custom.js +++ b/packages/slate/test/schema/custom/child-type-invalid-custom.js @@ -7,16 +7,14 @@ export const schema = { blocks: { paragraph: {}, quote: { - nodes: [ - { types: ['paragraph'] }, - ], + nodes: [{ types: ['paragraph'] }], normalize: (change, reason, { child }) => { if (reason == CHILD_TYPE_INVALID) { change.wrapBlockByKey(child.key, 'paragraph') } - } - } - } + }, + }, + }, } export const input = ( diff --git a/packages/slate/test/schema/custom/child-type-invalid-default.js b/packages/slate/test/schema/custom/child-type-invalid-default.js index 6176a3c01..6ca98b324 100644 --- a/packages/slate/test/schema/custom/child-type-invalid-default.js +++ b/packages/slate/test/schema/custom/child-type-invalid-default.js @@ -6,11 +6,9 @@ export const schema = { blocks: { paragraph: {}, quote: { - nodes: [ - { types: ['paragraph'] }, - ] - } - } + nodes: [{ types: ['paragraph'] }], + }, + }, } export const input = ( diff --git a/packages/slate/test/schema/custom/child-unknown-custom.js b/packages/slate/test/schema/custom/child-unknown-custom.js index 878845259..d63eaca74 100644 --- a/packages/slate/test/schema/custom/child-unknown-custom.js +++ b/packages/slate/test/schema/custom/child-unknown-custom.js @@ -7,31 +7,29 @@ export const schema = { blocks: { paragraph: {}, quote: { - nodes: [ - { types: ['paragraph'], max: 1 }, - ], + nodes: [{ types: ['paragraph'], max: 1 }], normalize: (change, reason, { node, child, index }) => { if (reason == CHILD_UNKNOWN) { const previous = node.getPreviousSibling(child.key) const offset = previous.nodes.size - child.nodes.forEach((n, i) => change.moveNodeByKey(n.key, previous.key, offset + i, { normalize: false })) + child.nodes.forEach((n, i) => + change.moveNodeByKey(n.key, previous.key, offset + i, { + normalize: false, + }) + ) change.removeNodeByKey(child.key) } - } - } - } + }, + }, + }, } export const input = ( -- text - +text @@ -41,9 +39,7 @@ export const output = ( -- one - -- two - +one +two diff --git a/packages/slate/test/schema/custom/child-unknown-default.js b/packages/slate/test/schema/custom/child-unknown-default.js index d3eae3716..cac9dafbc 100644 --- a/packages/slate/test/schema/custom/child-unknown-default.js +++ b/packages/slate/test/schema/custom/child-unknown-default.js @@ -6,23 +6,17 @@ export const schema = { blocks: { paragraph: {}, quote: { - nodes: [ - { types: ['paragraph'], max: 1 }, - ] - } - } + nodes: [{ types: ['paragraph'], max: 1 }], + }, + }, } export const input = ( -- onetwo - +onetwo @@ -32,9 +26,7 @@ export const output = ( -- one - -- two - +one +two diff --git a/packages/slate/test/schema/custom/first-child-kind-invalid-custom.js b/packages/slate/test/schema/custom/first-child-kind-invalid-custom.js index 56a938a18..d3d3a0738 100644 --- a/packages/slate/test/schema/custom/first-child-kind-invalid-custom.js +++ b/packages/slate/test/schema/custom/first-child-kind-invalid-custom.js @@ -12,17 +12,15 @@ export const schema = { if (reason == FIRST_CHILD_OBJECT_INVALID) { change.wrapBlockByKey(child.key, 'paragraph') } - } - } - } + }, + }, + }, } export const input = ( -- one - +one ) @@ -31,9 +29,7 @@ export const output = ( - - text -+textdiff --git a/packages/slate/test/schema/custom/first-child-kind-invalid-default.js b/packages/slate/test/schema/custom/first-child-kind-invalid-default.js index 2a337a212..024cfaf76 100644 --- a/packages/slate/test/schema/custom/first-child-kind-invalid-default.js +++ b/packages/slate/test/schema/custom/first-child-kind-invalid-default.js @@ -7,8 +7,8 @@ export const schema = { paragraph: {}, quote: { first: { objects: ['text'] }, - } - } + }, + }, } export const input = ( diff --git a/packages/slate/test/schema/custom/first-child-type-invalid-custom.js b/packages/slate/test/schema/custom/first-child-type-invalid-custom.js index 7332d07ba..e45b7dbd5 100644 --- a/packages/slate/test/schema/custom/first-child-type-invalid-custom.js +++ b/packages/slate/test/schema/custom/first-child-type-invalid-custom.js @@ -12,9 +12,9 @@ export const schema = { if (reason == FIRST_CHILD_TYPE_INVALID) { change.wrapBlockByKey(child.key, 'paragraph') } - } - } - } + }, + }, + }, } export const input = ( diff --git a/packages/slate/test/schema/custom/first-child-type-invalid-default.js b/packages/slate/test/schema/custom/first-child-type-invalid-default.js index faff1f4bc..df4f11bc1 100644 --- a/packages/slate/test/schema/custom/first-child-type-invalid-default.js +++ b/packages/slate/test/schema/custom/first-child-type-invalid-default.js @@ -6,9 +6,9 @@ export const schema = { blocks: { paragraph: {}, quote: { - first: { types: ['paragraph'] } - } - } + first: { types: ['paragraph'] }, + }, + }, } export const input = ( diff --git a/packages/slate/test/schema/custom/last-child-kind-invalid-custom.js b/packages/slate/test/schema/custom/last-child-kind-invalid-custom.js index ec0041a80..1120e0ba6 100644 --- a/packages/slate/test/schema/custom/last-child-kind-invalid-custom.js +++ b/packages/slate/test/schema/custom/last-child-kind-invalid-custom.js @@ -12,17 +12,15 @@ export const schema = { if (reason == LAST_CHILD_OBJECT_INVALID) { change.wrapBlockByKey(child.key, 'paragraph') } - } - } - } + }, + }, + }, } export const input = ( -- text - +text ) @@ -31,9 +29,7 @@ export const output = ( - - text -+textdiff --git a/packages/slate/test/schema/custom/last-child-kind-invalid-default.js b/packages/slate/test/schema/custom/last-child-kind-invalid-default.js index eba5fef2d..ff97b76c7 100644 --- a/packages/slate/test/schema/custom/last-child-kind-invalid-default.js +++ b/packages/slate/test/schema/custom/last-child-kind-invalid-default.js @@ -7,8 +7,8 @@ export const schema = { paragraph: {}, quote: { last: { objects: ['text'] }, - } - } + }, + }, } export const input = ( diff --git a/packages/slate/test/schema/custom/last-child-type-invalid-custom.js b/packages/slate/test/schema/custom/last-child-type-invalid-custom.js index 74f73bf4c..aa1e93665 100644 --- a/packages/slate/test/schema/custom/last-child-type-invalid-custom.js +++ b/packages/slate/test/schema/custom/last-child-type-invalid-custom.js @@ -12,9 +12,9 @@ export const schema = { if (reason == LAST_CHILD_TYPE_INVALID) { change.wrapBlockByKey(child.key, 'paragraph') } - } - } - } + }, + }, + }, } export const input = ( diff --git a/packages/slate/test/schema/custom/last-child-type-invalid-default.js b/packages/slate/test/schema/custom/last-child-type-invalid-default.js index 82c0f8111..5b4b063e5 100644 --- a/packages/slate/test/schema/custom/last-child-type-invalid-default.js +++ b/packages/slate/test/schema/custom/last-child-type-invalid-default.js @@ -6,9 +6,9 @@ export const schema = { blocks: { paragraph: {}, quote: { - last: { types: ['paragraph'] } - } - } + last: { types: ['paragraph'] }, + }, + }, } export const input = ( diff --git a/packages/slate/test/schema/custom/node-data-invalid-custom.js b/packages/slate/test/schema/custom/node-data-invalid-custom.js index 2375b4820..380a4ca30 100644 --- a/packages/slate/test/schema/custom/node-data-invalid-custom.js +++ b/packages/slate/test/schema/custom/node-data-invalid-custom.js @@ -7,15 +7,15 @@ export const schema = { blocks: { paragraph: { data: { - thing: v => v == 'value' + thing: v => v == 'value', }, normalize: (change, reason, { node, key }) => { if (reason == NODE_DATA_INVALID) { - change.setNodeByKey(node.key, { data: { thing: 'value' }}) + change.setNodeByKey(node.key, { data: { thing: 'value' } }) } - } - } - } + }, + }, + }, } export const input = ( diff --git a/packages/slate/test/schema/custom/node-data-invalid-default-undefined.js b/packages/slate/test/schema/custom/node-data-invalid-default-undefined.js index fcbd43d28..406e0c9b7 100644 --- a/packages/slate/test/schema/custom/node-data-invalid-default-undefined.js +++ b/packages/slate/test/schema/custom/node-data-invalid-default-undefined.js @@ -6,10 +6,10 @@ export const schema = { blocks: { paragraph: { data: { - thing: v => v == 'value' + thing: v => v == 'value', }, - } - } + }, + }, } export const input = ( diff --git a/packages/slate/test/schema/custom/node-data-invalid-default.js b/packages/slate/test/schema/custom/node-data-invalid-default.js index 3af86f2dd..03fcab0a9 100644 --- a/packages/slate/test/schema/custom/node-data-invalid-default.js +++ b/packages/slate/test/schema/custom/node-data-invalid-default.js @@ -6,10 +6,10 @@ export const schema = { blocks: { paragraph: { data: { - thing: v => v == null || v == 'value' + thing: v => v == null || v == 'value', }, - } - } + }, + }, } export const input = ( diff --git a/packages/slate/test/schema/custom/node-is-void-invalid-custom.js b/packages/slate/test/schema/custom/node-is-void-invalid-custom.js index 6e4e9abd7..18d380ec4 100644 --- a/packages/slate/test/schema/custom/node-is-void-invalid-custom.js +++ b/packages/slate/test/schema/custom/node-is-void-invalid-custom.js @@ -11,9 +11,9 @@ export const schema = { if (reason == NODE_IS_VOID_INVALID) { change.removeNodeByKey(node.key, 'paragraph') } - } - } - } + }, + }, + }, } export const input = ( diff --git a/packages/slate/test/schema/custom/node-is-void-invalid-default.js b/packages/slate/test/schema/custom/node-is-void-invalid-default.js index 05caea513..9b3dff941 100644 --- a/packages/slate/test/schema/custom/node-is-void-invalid-default.js +++ b/packages/slate/test/schema/custom/node-is-void-invalid-default.js @@ -6,8 +6,8 @@ export const schema = { blocks: { paragraph: { isVoid: false, - } - } + }, + }, } export const input = ( @@ -21,9 +21,7 @@ export const input = ( export const output = ( -- text - +text ) diff --git a/packages/slate/test/schema/custom/node-mark-invalid-custom.js b/packages/slate/test/schema/custom/node-mark-invalid-custom.js index b4a115a49..2f858c47f 100644 --- a/packages/slate/test/schema/custom/node-mark-invalid-custom.js +++ b/packages/slate/test/schema/custom/node-mark-invalid-custom.js @@ -11,9 +11,9 @@ export const schema = { if (reason == NODE_MARK_INVALID) { node.nodes.forEach(n => change.removeNodeByKey(n.key)) } - } - } - } + }, + }, + }, } export const input = ( diff --git a/packages/slate/test/schema/custom/node-mark-invalid-default.js b/packages/slate/test/schema/custom/node-mark-invalid-default.js index a15d23865..60ef73c97 100644 --- a/packages/slate/test/schema/custom/node-mark-invalid-default.js +++ b/packages/slate/test/schema/custom/node-mark-invalid-default.js @@ -5,9 +5,9 @@ import h from '../../helpers/h' export const schema = { blocks: { paragraph: { - marks: [{ type: 'bold' }, { type: 'underline' }], - } - } + marks: [{ type: 'bold' }, { type: 'underline' }], + }, + }, } export const input = ( @@ -23,9 +23,7 @@ export const input = ( export const output = ( - - {' '} - +{/* prettier-ignore */ ' '} ) diff --git a/packages/slate/test/schema/custom/node-mark-valid-default.js b/packages/slate/test/schema/custom/node-mark-valid-default.js index 0d681e301..b07cb76a9 100644 --- a/packages/slate/test/schema/custom/node-mark-valid-default.js +++ b/packages/slate/test/schema/custom/node-mark-valid-default.js @@ -5,9 +5,9 @@ import h from '../../helpers/h' export const schema = { blocks: { paragraph: { - marks: [{ type: 'bold' }, { type: 'underline' }], - } - } + marks: [{ type: 'bold' }, { type: 'underline' }], + }, + }, } export const input = ( diff --git a/packages/slate/test/schema/custom/node-text-invalid-custom.js b/packages/slate/test/schema/custom/node-text-invalid-custom.js index 6b37e4636..b1e2b30e9 100644 --- a/packages/slate/test/schema/custom/node-text-invalid-custom.js +++ b/packages/slate/test/schema/custom/node-text-invalid-custom.js @@ -11,17 +11,15 @@ export const schema = { if (reason == NODE_TEXT_INVALID) { node.nodes.forEach(n => change.removeNodeByKey(n.key)) } - } - } - } + }, + }, + }, } export const input = ( - - one two three - +one two three ) diff --git a/packages/slate/test/schema/custom/node-text-invalid-default.js b/packages/slate/test/schema/custom/node-text-invalid-default.js index b2d325ffc..99a2a4ef7 100644 --- a/packages/slate/test/schema/custom/node-text-invalid-default.js +++ b/packages/slate/test/schema/custom/node-text-invalid-default.js @@ -6,16 +6,14 @@ export const schema = { blocks: { paragraph: { text: /^\d*$/, - } - } + }, + }, } export const input = ( - - invalid - +invalid ) diff --git a/packages/slate/test/schema/custom/parent-kind-invalid-custom.js b/packages/slate/test/schema/custom/parent-kind-invalid-custom.js index 50c96d0ab..91ccb85aa 100644 --- a/packages/slate/test/schema/custom/parent-kind-invalid-custom.js +++ b/packages/slate/test/schema/custom/parent-kind-invalid-custom.js @@ -11,16 +11,18 @@ export const schema = { if (reason == PARENT_OBJECT_INVALID) { change.unwrapNodeByKey(node.key) } - } - } - } + }, + }, + }, } export const input = ( - - invalid - +invalid diff --git a/packages/slate/test/schema/custom/parent-kind-invalid-default.js b/packages/slate/test/schema/custom/parent-kind-invalid-default.js index 9c982893d..758d9bfab 100644 --- a/packages/slate/test/schema/custom/parent-kind-invalid-default.js +++ b/packages/slate/test/schema/custom/parent-kind-invalid-default.js @@ -6,15 +6,17 @@ export const schema = { inlines: { link: { parent: { objects: ['block'] }, - } - } + }, + }, } export const input = ( - one + + one + diff --git a/packages/slate/test/schema/custom/parent-type-invalid-custom.js b/packages/slate/test/schema/custom/parent-type-invalid-custom.js index 4ff6f7737..a27a2acd6 100644 --- a/packages/slate/test/schema/custom/parent-type-invalid-custom.js +++ b/packages/slate/test/schema/custom/parent-type-invalid-custom.js @@ -12,9 +12,9 @@ export const schema = { if (reason == PARENT_TYPE_INVALID) { change.wrapBlockByKey(node.key, 'list') } - } - } - } + }, + }, + }, } export const input = ( diff --git a/packages/slate/test/schema/custom/parent-type-invalid-default.js b/packages/slate/test/schema/custom/parent-type-invalid-default.js index 2f1b7b157..7ebd3d3ca 100644 --- a/packages/slate/test/schema/custom/parent-type-invalid-default.js +++ b/packages/slate/test/schema/custom/parent-type-invalid-default.js @@ -7,8 +7,8 @@ export const schema = { list: {}, item: { parent: { types: ['list'] }, - } - } + }, + }, } export const input = ( diff --git a/packages/slate/test/schema/index.js b/packages/slate/test/schema/index.js index 91ff67dd3..d54823525 100644 --- a/packages/slate/test/schema/index.js +++ b/packages/slate/test/schema/index.js @@ -1,4 +1,3 @@ - import assert from 'assert' import fs from 'fs' import { Schema } from '../..' @@ -11,7 +10,10 @@ import { basename, extname, resolve } from 'path' describe('schema', () => { describe('core', () => { const testsDir = resolve(__dirname, 'core') - const tests = fs.readdirSync(testsDir).filter(t => t[0] != '.').map(t => basename(t, extname(t))) + const tests = fs + .readdirSync(testsDir) + .filter(t => t[0] != '.') + .map(t => basename(t, extname(t))) for (const test of tests) { it(test, async () => { @@ -32,7 +34,10 @@ describe('schema', () => { describe('custom', () => { const testsDir = resolve(__dirname, 'custom') - const tests = fs.readdirSync(testsDir).filter(t => t[0] != '.').map(t => basename(t, extname(t))) + const tests = fs + .readdirSync(testsDir) + .filter(t => t[0] != '.') + .map(t => basename(t, extname(t))) for (const test of tests) { it(test, async () => { diff --git a/packages/slate/test/serializers/index.js b/packages/slate/test/serializers/index.js index a9e30e582..461b2a74a 100644 --- a/packages/slate/test/serializers/index.js +++ b/packages/slate/test/serializers/index.js @@ -1,4 +1,3 @@ - import assert from 'assert' import fs from 'fs' import { Value } from '../..' @@ -12,7 +11,10 @@ describe('serializers', () => { describe('raw', () => { describe('deserialize()', () => { const dir = resolve(__dirname, './raw/deserialize') - const tests = fs.readdirSync(dir).filter(t => t[0] != '.').map(t => basename(t, extname(t))) + const tests = fs + .readdirSync(dir) + .filter(t => t[0] != '.') + .map(t => basename(t, extname(t))) for (const test of tests) { it(test, async () => { @@ -27,7 +29,10 @@ describe('serializers', () => { describe('serialize()', () => { const dir = resolve(__dirname, './raw/serialize') - const tests = fs.readdirSync(dir).filter(t => t[0] != '.').map(t => basename(t, extname(t))) + const tests = fs + .readdirSync(dir) + .filter(t => t[0] != '.') + .map(t => basename(t, extname(t))) for (const test of tests) { it(test, async () => { diff --git a/packages/slate/test/serializers/raw/deserialize/block-nested.js b/packages/slate/test/serializers/raw/deserialize/block-nested.js index 1e89cf580..cfe8fdd73 100644 --- a/packages/slate/test/serializers/raw/deserialize/block-nested.js +++ b/packages/slate/test/serializers/raw/deserialize/block-nested.js @@ -26,25 +26,23 @@ export const input = { { text: 'one', object: 'leaf', - marks: [] - } - ] - } - ] - } - ] - } - ] - } + marks: [], + }, + ], + }, + ], + }, + ], + }, + ], + }, } export const output = ( - one + + one + diff --git a/packages/slate/test/serializers/raw/deserialize/block-with-data.js b/packages/slate/test/serializers/raw/deserialize/block-with-data.js index 07470e49c..f609e13bc 100644 --- a/packages/slate/test/serializers/raw/deserialize/block-with-data.js +++ b/packages/slate/test/serializers/raw/deserialize/block-with-data.js @@ -13,7 +13,7 @@ export const input = { type: 'paragraph', isVoid: false, data: { - thing: 'value' + thing: 'value', }, nodes: [ { @@ -22,22 +22,20 @@ export const input = { { object: 'leaf', text: 'one', - marks: [] - } - ] - } - ] - } - ] - } + marks: [], + }, + ], + }, + ], + }, + ], + }, } export const output = ( -- one - +one ) diff --git a/packages/slate/test/serializers/raw/deserialize/block-with-is-void.js b/packages/slate/test/serializers/raw/deserialize/block-with-is-void.js index a7d9c83b8..9cf4589b5 100644 --- a/packages/slate/test/serializers/raw/deserialize/block-with-is-void.js +++ b/packages/slate/test/serializers/raw/deserialize/block-with-is-void.js @@ -21,13 +21,13 @@ export const input = { object: 'leaf', text: ' ', marks: [], - } - ] - } - ] - } - ] - } + }, + ], + }, + ], + }, + ], + }, } export const output = ( diff --git a/packages/slate/test/serializers/raw/deserialize/block.js b/packages/slate/test/serializers/raw/deserialize/block.js index 36901bf01..8c4cf368c 100644 --- a/packages/slate/test/serializers/raw/deserialize/block.js +++ b/packages/slate/test/serializers/raw/deserialize/block.js @@ -21,21 +21,19 @@ export const input = { object: 'leaf', text: 'one', marks: [], - } - ] - } - ] - } - ] - } + }, + ], + }, + ], + }, + ], + }, } export const output = ( - - one - +one ) diff --git a/packages/slate/test/serializers/raw/deserialize/inline-nested.js b/packages/slate/test/serializers/raw/deserialize/inline-nested.js index cb0e59ea2..5bf87f860 100644 --- a/packages/slate/test/serializers/raw/deserialize/inline-nested.js +++ b/packages/slate/test/serializers/raw/deserialize/inline-nested.js @@ -21,8 +21,8 @@ export const input = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, { object: 'inline', @@ -37,8 +37,8 @@ export const input = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, { object: 'inline', @@ -53,10 +53,10 @@ export const input = { object: 'leaf', text: 'one', marks: [], - } - ] - } - ] + }, + ], + }, + ], }, { object: 'text', @@ -65,10 +65,10 @@ export const input = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, - ] + ], }, { object: 'text', @@ -77,13 +77,13 @@ export const input = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, - ] - } - ] - } + ], + }, + ], + }, } export const output = ( @@ -91,9 +91,7 @@ export const output = ( - - one - +one diff --git a/packages/slate/test/serializers/raw/deserialize/inline-with-data.js b/packages/slate/test/serializers/raw/deserialize/inline-with-data.js index 12db01e3b..a3f54949d 100644 --- a/packages/slate/test/serializers/raw/deserialize/inline-with-data.js +++ b/packages/slate/test/serializers/raw/deserialize/inline-with-data.js @@ -21,15 +21,15 @@ export const input = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, { object: 'inline', type: 'link', isVoid: false, data: { - thing: 'value' + thing: 'value', }, nodes: [ { @@ -39,10 +39,10 @@ export const input = { object: 'leaf', text: 'one', marks: [], - } - ] - } - ] + }, + ], + }, + ], }, { object: 'text', @@ -51,22 +51,20 @@ export const input = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, - ] - } - ] - } + ], + }, + ], + }, } export const output = ( - - one - +one diff --git a/packages/slate/test/serializers/raw/deserialize/inline-with-is-void.js b/packages/slate/test/serializers/raw/deserialize/inline-with-is-void.js index 4b6536221..4d9ccc331 100644 --- a/packages/slate/test/serializers/raw/deserialize/inline-with-is-void.js +++ b/packages/slate/test/serializers/raw/deserialize/inline-with-is-void.js @@ -21,8 +21,8 @@ export const input = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, { object: 'inline', @@ -37,10 +37,10 @@ export const input = { object: 'leaf', text: ' ', marks: [], - } - ] - } - ] + }, + ], + }, + ], }, { object: 'text', @@ -49,13 +49,13 @@ export const input = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, - ] - } - ] - } + ], + }, + ], + }, } export const output = ( diff --git a/packages/slate/test/serializers/raw/deserialize/inline.js b/packages/slate/test/serializers/raw/deserialize/inline.js index 067570391..90cd8cfbc 100644 --- a/packages/slate/test/serializers/raw/deserialize/inline.js +++ b/packages/slate/test/serializers/raw/deserialize/inline.js @@ -21,8 +21,8 @@ export const input = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, { object: 'inline', @@ -37,10 +37,10 @@ export const input = { object: 'leaf', text: 'one', marks: [], - } - ] - } - ] + }, + ], + }, + ], }, { object: 'text', @@ -49,22 +49,20 @@ export const input = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, - ] - } - ] - } + ], + }, + ], + }, } export const output = ( - - one - + one diff --git a/packages/slate/test/serializers/raw/deserialize/range-with-mark.js b/packages/slate/test/serializers/raw/deserialize/range-with-mark.js index 5a7562980..384dbc112 100644 --- a/packages/slate/test/serializers/raw/deserialize/range-with-mark.js +++ b/packages/slate/test/serializers/raw/deserialize/range-with-mark.js @@ -30,20 +30,20 @@ export const input = { object: 'mark', type: 'bold', data: {}, - } - ] + }, + ], }, { object: 'leaves', text: 'e', marks: [], - } - ] - } - ] - } - ] - } + }, + ], + }, + ], + }, + ], + }, } export const output = ( diff --git a/packages/slate/test/serializers/raw/serialize/block-nested.js b/packages/slate/test/serializers/raw/serialize/block-nested.js index 5cf9ab30c..09f165cb0 100644 --- a/packages/slate/test/serializers/raw/serialize/block-nested.js +++ b/packages/slate/test/serializers/raw/serialize/block-nested.js @@ -6,9 +6,7 @@ export const input = ( - - one - + one @@ -38,14 +36,14 @@ export const output = { { text: 'one', object: 'leaf', - marks: [] - } - ] - } - ] - } - ] - } - ] - } + marks: [], + }, + ], + }, + ], + }, + ], + }, + ], + }, } diff --git a/packages/slate/test/serializers/raw/serialize/block-with-data.js b/packages/slate/test/serializers/raw/serialize/block-with-data.js index 64d527096..08e798665 100644 --- a/packages/slate/test/serializers/raw/serialize/block-with-data.js +++ b/packages/slate/test/serializers/raw/serialize/block-with-data.js @@ -5,9 +5,7 @@ import h from '../../../helpers/h' export const input = ( -- one - +one ) @@ -23,7 +21,7 @@ export const output = { type: 'paragraph', isVoid: false, data: { - thing: 'value' + thing: 'value', }, nodes: [ { @@ -32,12 +30,12 @@ export const output = { { object: 'leaf', text: 'one', - marks: [] - } - ] - } - ] - } - ] - } + marks: [], + }, + ], + }, + ], + }, + ], + }, } diff --git a/packages/slate/test/serializers/raw/serialize/block-with-is-void.js b/packages/slate/test/serializers/raw/serialize/block-with-is-void.js index 26429cb74..d3c7018bb 100644 --- a/packages/slate/test/serializers/raw/serialize/block-with-is-void.js +++ b/packages/slate/test/serializers/raw/serialize/block-with-is-void.js @@ -29,11 +29,11 @@ export const output = { object: 'leaf', text: ' ', marks: [], - } - ] - } - ] - } - ] - } + }, + ], + }, + ], + }, + ], + }, } diff --git a/packages/slate/test/serializers/raw/serialize/block.js b/packages/slate/test/serializers/raw/serialize/block.js index 1ffd5d5cf..89c5e2f89 100644 --- a/packages/slate/test/serializers/raw/serialize/block.js +++ b/packages/slate/test/serializers/raw/serialize/block.js @@ -5,9 +5,7 @@ import h from '../../../helpers/h' export const input = ( - - one - +one ) @@ -31,11 +29,11 @@ export const output = { object: 'leaf', text: 'one', marks: [], - } - ] - } - ] - } - ] - } + }, + ], + }, + ], + }, + ], + }, } diff --git a/packages/slate/test/serializers/raw/serialize/inline-nested.js b/packages/slate/test/serializers/raw/serialize/inline-nested.js index 6780f9ec6..917f4b00b 100644 --- a/packages/slate/test/serializers/raw/serialize/inline-nested.js +++ b/packages/slate/test/serializers/raw/serialize/inline-nested.js @@ -7,9 +7,7 @@ export const input = ( - - one - +one @@ -35,8 +33,8 @@ export const output = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, { object: 'inline', @@ -51,8 +49,8 @@ export const output = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, { object: 'inline', @@ -67,10 +65,10 @@ export const output = { object: 'leaf', text: 'one', marks: [], - } - ] - } - ] + }, + ], + }, + ], }, { object: 'text', @@ -79,10 +77,10 @@ export const output = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, - ] + ], }, { object: 'text', @@ -91,11 +89,11 @@ export const output = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, - ] - } - ] - } + ], + }, + ], + }, } diff --git a/packages/slate/test/serializers/raw/serialize/inline-with-data.js b/packages/slate/test/serializers/raw/serialize/inline-with-data.js index fd19e377f..be3a9d097 100644 --- a/packages/slate/test/serializers/raw/serialize/inline-with-data.js +++ b/packages/slate/test/serializers/raw/serialize/inline-with-data.js @@ -6,9 +6,7 @@ export const input = ( - - one - +one @@ -33,15 +31,15 @@ export const output = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, { object: 'inline', type: 'link', isVoid: false, data: { - thing: 'value' + thing: 'value', }, nodes: [ { @@ -51,10 +49,10 @@ export const output = { object: 'leaf', text: 'one', marks: [], - } - ] - } - ] + }, + ], + }, + ], }, { object: 'text', @@ -63,11 +61,11 @@ export const output = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, - ] - } - ] - } + ], + }, + ], + }, } diff --git a/packages/slate/test/serializers/raw/serialize/inline-with-is-void.js b/packages/slate/test/serializers/raw/serialize/inline-with-is-void.js index e2eff13bc..7e03ffad4 100644 --- a/packages/slate/test/serializers/raw/serialize/inline-with-is-void.js +++ b/packages/slate/test/serializers/raw/serialize/inline-with-is-void.js @@ -31,8 +31,8 @@ export const output = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, { object: 'inline', @@ -47,10 +47,10 @@ export const output = { object: 'leaf', text: ' ', marks: [], - } - ] - } - ] + }, + ], + }, + ], }, { object: 'text', @@ -59,11 +59,11 @@ export const output = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, - ] - } - ] - } + ], + }, + ], + }, } diff --git a/packages/slate/test/serializers/raw/serialize/inline.js b/packages/slate/test/serializers/raw/serialize/inline.js index 90434af3b..f70a9eab0 100644 --- a/packages/slate/test/serializers/raw/serialize/inline.js +++ b/packages/slate/test/serializers/raw/serialize/inline.js @@ -6,9 +6,7 @@ export const input = ( - - one - + one @@ -33,8 +31,8 @@ export const output = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, { object: 'inline', @@ -49,10 +47,10 @@ export const output = { object: 'leaf', text: 'one', marks: [], - } - ] - } - ] + }, + ], + }, + ], }, { object: 'text', @@ -61,11 +59,11 @@ export const output = { object: 'leaf', text: '', marks: [], - } - ] + }, + ], }, - ] - } - ] - } + ], + }, + ], + }, } diff --git a/packages/slate/test/serializers/raw/serialize/preserve-data.js b/packages/slate/test/serializers/raw/serialize/preserve-data.js index f8890864c..3c699face 100644 --- a/packages/slate/test/serializers/raw/serialize/preserve-data.js +++ b/packages/slate/test/serializers/raw/serialize/preserve-data.js @@ -5,9 +5,7 @@ import h from '../../../helpers/h' export const input = ( - - one - + one ) @@ -31,14 +29,14 @@ export const output = { { text: 'one', object: 'leaf', - marks: [] - } - ] - } - ] - } - ] - } + marks: [], + }, + ], + }, + ], + }, + ], + }, } export const options = { diff --git a/packages/slate/test/serializers/raw/serialize/preserve-keys.js b/packages/slate/test/serializers/raw/serialize/preserve-keys.js index 3fefad9d1..873dd14fa 100644 --- a/packages/slate/test/serializers/raw/serialize/preserve-keys.js +++ b/packages/slate/test/serializers/raw/serialize/preserve-keys.js @@ -5,9 +5,7 @@ import h from '../../../helpers/h' export const input = ( - - one - +one ) @@ -33,14 +31,14 @@ export const output = { { text: 'one', object: 'leaf', - marks: [] - } - ] - } - ] - } - ] - } + marks: [], + }, + ], + }, + ], + }, + ], + }, } export const options = { diff --git a/packages/slate/test/serializers/raw/serialize/preserve-selection-and-keys.js b/packages/slate/test/serializers/raw/serialize/preserve-selection-and-keys.js index b05c7defb..5b7cbd386 100644 --- a/packages/slate/test/serializers/raw/serialize/preserve-selection-and-keys.js +++ b/packages/slate/test/serializers/raw/serialize/preserve-selection-and-keys.js @@ -5,9 +5,7 @@ import h from '../../../helpers/h' export const input = ( - - one - +one ) @@ -33,13 +31,13 @@ export const output = { { text: 'one', object: 'leaf', - marks: [] - } - ] - } - ] - } - ] + marks: [], + }, + ], + }, + ], + }, + ], }, selection: { object: 'range', @@ -50,7 +48,7 @@ export const output = { isBackward: false, isFocused: false, marks: null, - } + }, } export const options = { diff --git a/packages/slate/test/serializers/raw/serialize/preserve-selection.js b/packages/slate/test/serializers/raw/serialize/preserve-selection.js index a20bd54f2..164fb5dce 100644 --- a/packages/slate/test/serializers/raw/serialize/preserve-selection.js +++ b/packages/slate/test/serializers/raw/serialize/preserve-selection.js @@ -5,9 +5,7 @@ import h from '../../../helpers/h' export const input = ( - - one - +one ) @@ -30,13 +28,13 @@ export const output = { { text: 'one', object: 'leaf', - marks: [] - } - ] - } - ] - } - ] + marks: [], + }, + ], + }, + ], + }, + ], }, selection: { object: 'range', @@ -47,7 +45,7 @@ export const output = { isBackward: false, isFocused: false, marks: null, - } + }, } export const options = { diff --git a/packages/slate/test/serializers/raw/serialize/range-with-mark.js b/packages/slate/test/serializers/raw/serialize/range-with-mark.js index f7b18a186..486f7b167 100644 --- a/packages/slate/test/serializers/raw/serialize/range-with-mark.js +++ b/packages/slate/test/serializers/raw/serialize/range-with-mark.js @@ -40,18 +40,18 @@ export const output = { object: 'mark', type: 'bold', data: {}, - } - ] + }, + ], }, { object: 'leaf', text: 'e', marks: [], - } - ] - } - ] - } - ] - } + }, + ], + }, + ], + }, + ], + }, } diff --git a/support/benchmark-compare.js b/support/benchmark-compare.js index 4afd34724..d75285d61 100644 --- a/support/benchmark-compare.js +++ b/support/benchmark-compare.js @@ -27,8 +27,8 @@ baseline.forEach((suite, i) => { const b = base.iterations / base.elapsed * 1000 const c = comp.iterations / comp.elapsed * 1000 const threshold = b * THRESHOLD - const slower = (b - c) > threshold - const faster = (b - c) < (0 - threshold) + const slower = b - c > threshold + const faster = b - c < 0 - threshold const percent = Math.round(Math.abs(b - c) / b * 100) let output = `${b.toFixed(2)} → ${c.toFixed(2)} ops/sec` diff --git a/support/benchmark-reporter.js b/support/benchmark-reporter.js index 55442ffbc..ccfbf43b2 100644 --- a/support/benchmark-reporter.js +++ b/support/benchmark-reporter.js @@ -1,7 +1,6 @@ - const { stdout } = process -module.exports = function (runner, utils) { +module.exports = function(runner, utils) { let hasSuite = false let hasBench = false @@ -13,18 +12,18 @@ module.exports = function (runner, utils) { stdout.write(']') }) - runner.on('suite start', (suite) => { + runner.on('suite start', suite => { if (hasSuite) stdout.write(',') stdout.write(`{"name":"${suite.title}","benchmarks":[`) hasSuite = true }) - runner.on('suite end', (suite) => { + runner.on('suite end', suite => { hasBench = false stdout.write(']}') }) - runner.on('bench end', (bench) => { + runner.on('bench end', bench => { if (hasBench) stdout.write(',') stdout.write(JSON.stringify(bench)) hasBench = true diff --git a/support/rollup/examples.js b/support/rollup/examples.js index 18ddf9b58..20a0e04f8 100644 --- a/support/rollup/examples.js +++ b/support/rollup/examples.js @@ -34,7 +34,10 @@ const umdConfig = { // variant of `react-dom/server` relies on Node.js's Stream. alias({ debug: path.resolve(__dirname, 'node_modules/debug/src/browser'), - 'react-dom/server': path.resolve(__dirname, 'node_modules/react-dom/cjs/react-dom-server.browser.production.min'), + 'react-dom/server': path.resolve( + __dirname, + 'node_modules/react-dom/cjs/react-dom-server.browser.production.min' + ), }), // Allow rollup to resolve modules that are npm dependencies @@ -51,8 +54,16 @@ const umdConfig = { // hint that e.g. `import { List } from 'immutable'` is a reference // to a valid named export. namedExports: { - 'esrever': ['reverse'], - 'immutable': ['List', 'Map', 'Record', 'OrderedSet', 'Set', 'Stack', 'is'], + esrever: ['reverse'], + immutable: [ + 'List', + 'Map', + 'Record', + 'OrderedSet', + 'Set', + 'Stack', + 'is', + ], 'react-dom': ['findDOMNode'], 'react-dom/server': ['renderToStaticMarkup'], }, @@ -65,23 +76,20 @@ const umdConfig = { // some modules like React to use their production variant (and // one place within Slate itself). replace({ - 'process.env.NODE_ENV': JSON.stringify(environment) + 'process.env.NODE_ENV': JSON.stringify(environment), }), // Use babel to transpile the result -- limit to package src // to prevent babel from trying to transpile npm dependencies. babel({ - include: ['examples/**'] + include: ['examples/**'], }), ], // Limit rollup's file watching to example src files and the // built output of packages -- helps keep it from watching // too much and choking. watch: { - include: [ - 'examples/**', - 'packages/*/lib/*.es.js', - ], + include: ['examples/**', 'packages/*/lib/*.es.js'], }, } diff --git a/support/rollup/factory.js b/support/rollup/factory.js index 8fbd5252f..13a0f8498 100644 --- a/support/rollup/factory.js +++ b/support/rollup/factory.js @@ -9,7 +9,7 @@ import uglify from 'rollup-plugin-uglify' const environment = process.env.NODE_ENV || 'development' -export default (pkg) => { +export default pkg => { const pkgName = pkg.name const output = { cjs: pkg.main, @@ -33,7 +33,8 @@ export default (pkg) => { // 2. It is part of a package.json dependency (e.g. `lodash/omit`) // External dependencies are expected to be present at runtime (rather than being bundled into // our built dist). - const isExternalDependency = id => !!dependencies.find(dep => dep === id || id.startsWith(`${dep}/`)) + const isExternalDependency = id => + !!dependencies.find(dep => dep === id || id.startsWith(`${dep}/`)) // UMD build for browsers const umdConfig = { @@ -79,8 +80,16 @@ export default (pkg) => { // hint that e.g. `import { List } from 'immutable'` is a reference // to a valid named export. namedExports: { - 'esrever': ['reverse'], - 'immutable': ['List', 'Map', 'Record', 'OrderedSet', 'Set', 'Stack', 'is'], + esrever: ['reverse'], + immutable: [ + 'List', + 'Map', + 'Record', + 'OrderedSet', + 'Set', + 'Stack', + 'is', + ], 'react-dom': ['findDOMNode'], 'react-dom/server': ['renderToStaticMarkup'], }, @@ -90,15 +99,15 @@ export default (pkg) => { // some modules like React to use their production variant (and // one place within Slate itself). replace({ - 'process.env.NODE_ENV': JSON.stringify('production') + 'process.env.NODE_ENV': JSON.stringify('production'), }), // Use babel to transpile the result -- limit to package src // to prevent babel from trying to transpile npm dependencies. babel({ - include: [`packages/${pkgName}/src/**`] + include: [`packages/${pkgName}/src/**`], }), - ] + ], } // Additional UMD minified build based off of the unminified config @@ -137,15 +146,15 @@ export default (pkg) => { // some modules like React to use their production variant (and // one place within Slate itself). replace({ - 'process.env.NODE_ENV': JSON.stringify(environment) + 'process.env.NODE_ENV': JSON.stringify(environment), }), // Use babel to transpile the result -- limit to package src // to prevent babel from trying to transpile npm dependencies. babel({ - include: [`packages/${pkgName}/src/**`] + include: [`packages/${pkgName}/src/**`], }), - ] + ], } const configurations = [moduleConfig] diff --git a/yarn.lock b/yarn.lock index 0f9aa9273..e19057e32 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1807,6 +1807,12 @@ escodegen@^1.9.0: optionalDependencies: source-map "~0.5.6" +eslint-config-prettier@^2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-2.9.0.tgz#5ecd65174d486c22dff389fe036febf502d468a3" + dependencies: + get-stdin "^5.0.1" + eslint-import-resolver-node@^0.3.1: version "0.3.2" resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.2.tgz#58f15fb839b8d0576ca980413476aab2472db66a" @@ -1836,6 +1842,13 @@ eslint-plugin-import@^2.8.0: minimatch "^3.0.3" read-pkg-up "^2.0.0" +eslint-plugin-prettier@^2.5.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-2.5.0.tgz#39a91dd7528eaf19cd42c0ee3f2c1f684606a05f" + dependencies: + fast-diff "^1.1.1" + jest-docblock "^21.0.0" + eslint-plugin-react@^7.6.0: version "7.6.0" resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.6.0.tgz#351651188c74c5b2fecc2717e3936b7207baa728" @@ -2046,6 +2059,10 @@ fast-deep-equal@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz#96256a3bc975595eb36d82e9929d060d893439ff" +fast-diff@^1.1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.1.2.tgz#4b62c42b8e03de3f848460b639079920695d0154" + fast-json-stable-stringify@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" @@ -2249,6 +2266,10 @@ get-stdin@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" +get-stdin@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-5.0.1.tgz#122e161591e21ff4c52530305693f20e6393a398" + get-stream@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" @@ -2885,6 +2906,10 @@ jade@0.26.3: commander "0.6.1" mkdirp "0.3.0" +jest-docblock@^21.0.0: + version "21.2.0" + resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-21.2.0.tgz#51529c3b30d5fd159da60c27ceedc195faf8d414" + jodid25519@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/jodid25519/-/jodid25519-1.0.2.tgz#06d4912255093419477d425633606e0e90782967" @@ -3708,6 +3733,10 @@ preserve@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" +prettier@^1.10.2: + version "1.10.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.10.2.tgz#1af8356d1842276a99a5b5529c82dd9e9ad3cc93" + prismjs@^1.5.1: version "1.6.0" resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.6.0.tgz#118d95fb7a66dba2272e343b345f5236659db365" - - one - +one