diff --git a/.eslintrc b/.eslintrc index afcd1f46a..890fee220 100644 --- a/.eslintrc +++ b/.eslintrc @@ -38,6 +38,7 @@ "import/no-named-as-default": "error", "import/no-named-as-default-member": "error", "import/no-unresolved": "error", + "indent": ["error", 2], "key-spacing": ["error", { "beforeColon": false, "afterColon": true }], "lines-around-comment": ["error", { "beforeBlockComment": true, "afterBlockComment": true }], "new-parens": "error", diff --git a/examples/auto-markdown/index.js b/examples/auto-markdown/index.js index c2c3f8c36..602f898b6 100644 --- a/examples/auto-markdown/index.js +++ b/examples/auto-markdown/index.js @@ -50,17 +50,17 @@ class AutoMarkdown extends React.Component { getType = (chars) => { switch (chars) { - case '*': - case '-': - case '+': return 'list-item' - case '>': return 'block-quote' - case '#': return 'heading-one' - case '##': return 'heading-two' - case '###': return 'heading-three' - case '####': return 'heading-four' - case '#####': return 'heading-five' - case '######': return 'heading-six' - default: return null + case '*': + case '-': + case '+': return 'list-item' + case '>': return 'block-quote' + case '#': return 'heading-one' + case '##': return 'heading-two' + case '###': return 'heading-three' + case '####': return 'heading-four' + case '#####': return 'heading-five' + case '######': return 'heading-six' + default: return null } } @@ -105,9 +105,9 @@ class AutoMarkdown extends React.Component { onKeyDown = (e, data, state) => { switch (data.key) { - case 'space': return this.onSpace(e, state) - case 'backspace': return this.onBackspace(e, state) - case 'enter': return this.onEnter(e, state) + case 'space': return this.onSpace(e, state) + case 'backspace': return this.onBackspace(e, state) + case 'enter': return this.onEnter(e, state) } } diff --git a/examples/development/performance-rich/index.js b/examples/development/performance-rich/index.js index cb0da62d0..02b6356ed 100644 --- a/examples/development/performance-rich/index.js +++ b/examples/development/performance-rich/index.js @@ -109,20 +109,20 @@ class RichText extends React.Component { let mark switch (data.key) { - case 'b': - mark = 'bold' - break - case 'i': - mark = 'italic' - break - case 'u': - mark = 'underlined' - break - case '`': - mark = 'code' - break - default: - return + case 'b': + mark = 'bold' + break + case 'i': + mark = 'italic' + break + case 'u': + mark = 'underlined' + break + case '`': + mark = 'code' + break + default: + return } state = state diff --git a/examples/iframes/index.js b/examples/iframes/index.js index d50d050a3..6a9bb8629 100644 --- a/examples/iframes/index.js +++ b/examples/iframes/index.js @@ -104,14 +104,14 @@ class Iframes extends React.Component { let mark switch (data.key) { - case 'b': - mark = 'bold' - break - case 'i': - mark = 'italic' - break - default: - return + case 'b': + mark = 'bold' + break + case 'i': + mark = 'italic' + break + default: + return } state = state diff --git a/examples/images/index.js b/examples/images/index.js index b83e80da0..6ecf90bce 100644 --- a/examples/images/index.js +++ b/examples/images/index.js @@ -160,8 +160,8 @@ class Images extends React.Component { onDrop = (e, data, state, editor) => { switch (data.type) { - case 'files': return this.onDropOrPasteFiles(e, data, state, editor) - case 'node': return this.onDropNode(e, data, state) + case 'files': return this.onDropOrPasteFiles(e, data, state, editor) + case 'node': return this.onDropNode(e, data, state) } } @@ -222,8 +222,8 @@ class Images extends React.Component { onPaste = (e, data, state, editor) => { switch (data.type) { - case 'files': return this.onDropOrPasteFiles(e, data, state, editor) - case 'text': return this.onPasteText(e, data, state) + case 'files': return this.onDropOrPasteFiles(e, data, state, editor) + case 'text': return this.onPasteText(e, data, state) } } diff --git a/examples/rich-text/index.js b/examples/rich-text/index.js index 8cb50327c..0a936629d 100644 --- a/examples/rich-text/index.js +++ b/examples/rich-text/index.js @@ -109,20 +109,20 @@ class RichText extends React.Component { let mark switch (data.key) { - case 'b': - mark = 'bold' - break - case 'i': - mark = 'italic' - break - case 'u': - mark = 'underlined' - break - case '`': - mark = 'code' - break - default: - return + case 'b': + mark = 'bold' + break + case 'i': + mark = 'italic' + break + case 'u': + mark = 'underlined' + break + case '`': + mark = 'code' + break + default: + return } state = state diff --git a/examples/tables/index.js b/examples/tables/index.js index bc006c5dc..44399cc26 100644 --- a/examples/tables/index.js +++ b/examples/tables/index.js @@ -115,9 +115,9 @@ class Tables extends React.Component { if (state.startBlock.type != 'table-cell') return switch (data.key) { - case 'backspace': return this.onBackspace(e, state) - case 'delete': return this.onDelete(e, state) - case 'enter': return this.onEnter(e, state) + case 'backspace': return this.onBackspace(e, state) + case 'delete': return this.onDelete(e, state) + case 'enter': return this.onEnter(e, state) } } diff --git a/src/components/void.js b/src/components/void.js index 0f51d0a17..d752761f0 100644 --- a/src/components/void.js +++ b/src/components/void.js @@ -94,18 +94,18 @@ class Void extends React.Component { if (node.kind == 'block') { style = IS_FIREFOX ? { - pointerEvents: 'none', - width: '0px', - height: '0px', - lineHeight: '0px', - visibility: 'hidden' - } + pointerEvents: 'none', + width: '0px', + height: '0px', + lineHeight: '0px', + visibility: 'hidden' + } : { - position: 'absolute', - top: '0px', - left: '-9999px', - textIndent: '-9999px' - } + position: 'absolute', + top: '0px', + left: '-9999px', + textIndent: '-9999px' + } } else { style = { position: 'relative', diff --git a/src/models/schema.js b/src/models/schema.js index 2198aa371..c925ab413 100644 --- a/src/models/schema.js +++ b/src/models/schema.js @@ -226,12 +226,12 @@ function normalizeMarkComponent(render) { if (isReactComponent(render)) return render switch (typeOf(render)) { - case 'function': - return render - case 'object': - return props => {props.children} - case 'string': - return props => {props.children} + case 'function': + return render + case 'object': + return props => {props.children} + case 'string': + return props => {props.children} } } diff --git a/src/models/selection.js b/src/models/selection.js index 4065e00c6..e6d451a81 100644 --- a/src/models/selection.js +++ b/src/models/selection.js @@ -594,9 +594,9 @@ class Selection extends new Record(DEFAULTS) { */ moveEndOffset(n = 1) { - return this.isBackward - ? this.merge({ anchorOffset: this.anchorOffset + n }) - : this.merge({ focusOffset: this.focusOffset + n }) + return this.isBackward + ? this.merge({ anchorOffset: this.anchorOffset + n }) + : this.merge({ focusOffset: this.focusOffset + n }) } /** diff --git a/src/models/state.js b/src/models/state.js index b677e2b0f..9b2889ac9 100644 --- a/src/models/state.js +++ b/src/models/state.js @@ -425,8 +425,8 @@ class State extends new Record(DEFAULTS) { transform(properties = {}) { const state = this return new Transform({ - ...properties, - state + ...properties, + state }) } diff --git a/src/models/text.js b/src/models/text.js index f9711d7e9..f09dbcbc8 100644 --- a/src/models/text.js +++ b/src/models/text.js @@ -44,9 +44,9 @@ class Text extends new Record(DEFAULTS) { */ static createFromString(text, marks = Set()) { - return Text.createFromRanges([ - Range.create({ text, marks }) - ]) + return Text.createFromRanges([ + Range.create({ text, marks }) + ]) } /** @@ -57,12 +57,12 @@ class Text extends new Record(DEFAULTS) { */ static createFromRanges(ranges) { - return Text.create({ - characters: ranges.reduce((characters, range) => { - range = Range.create(range) - return characters.concat(range.getCharacters()) - }, Character.createList()) - }) + return Text.create({ + characters: ranges.reduce((characters, range) => { + range = Range.create(range) + return characters.concat(range.getCharacters()) + }, Character.createList()) + }) } /** diff --git a/src/plugins/core.js b/src/plugins/core.js index fd8ab42b3..96e75990a 100644 --- a/src/plugins/core.js +++ b/src/plugins/core.js @@ -261,11 +261,11 @@ function Plugin(options = {}) { debug('onDrop', { data }) switch (data.type) { - case 'text': - case 'html': - return onDropText(e, data, state) - case 'fragment': - return onDropFragment(e, data, state) + case 'text': + case 'html': + return onDropText(e, data, state) + case 'fragment': + return onDropFragment(e, data, state) } } @@ -346,14 +346,14 @@ function Plugin(options = {}) { debug('onKeyDown', { data }) switch (data.key) { - case 'enter': return onKeyDownEnter(e, data, state) - case 'backspace': return onKeyDownBackspace(e, data, state) - case 'delete': return onKeyDownDelete(e, data, state) - case 'left': return onKeyDownLeft(e, data, state) - case 'right': return onKeyDownRight(e, data, state) - case 'y': return onKeyDownY(e, data, state) - case 'z': return onKeyDownZ(e, data, state) - case 'k': return onKeyDownK(e, data, state) + case 'enter': return onKeyDownEnter(e, data, state) + case 'backspace': return onKeyDownBackspace(e, data, state) + case 'delete': return onKeyDownDelete(e, data, state) + case 'left': return onKeyDownLeft(e, data, state) + case 'right': return onKeyDownRight(e, data, state) + case 'y': return onKeyDownY(e, data, state) + case 'z': return onKeyDownZ(e, data, state) + case 'k': return onKeyDownK(e, data, state) } } @@ -625,11 +625,11 @@ function Plugin(options = {}) { debug('onPaste', { data }) switch (data.type) { - case 'fragment': - return onPasteFragment(e, data, state) - case 'text': - case 'html': - return onPasteText(e, data, state) + case 'fragment': + return onPasteFragment(e, data, state) + case 'text': + case 'html': + return onPasteText(e, data, state) } } @@ -701,60 +701,60 @@ function Plugin(options = {}) { * Extend core schema with rendering */ - /** - * A default schema rule to render block nodes. - * - * @type {Object} - */ + /** + * A default schema rule to render block nodes. + * + * @type {Object} + */ - const BLOCK_RENDER_RULE = { - match: (node) => { - return node.kind == 'block' - }, - render: (props) => { - return ( -
- {props.children} - {placeholder - ? - {placeholder} - - : null} -
- ) - } - } + const BLOCK_RENDER_RULE = { + match: (node) => { + return node.kind == 'block' + }, + render: (props) => { + return ( +
+ {props.children} + {placeholder + ? + {placeholder} + + : null} +
+ ) + } + } - /** - * A default schema rule to render inline nodes. - * - * @type {Object} - */ + /** + * A default schema rule to render inline nodes. + * + * @type {Object} + */ - const INLINE_RENDER_RULE = { - match: (node) => { - return node.kind == 'inline' - }, - render: (props) => { - return ( - - {props.children} - - ) - } - } + const INLINE_RENDER_RULE = { + match: (node) => { + return node.kind == 'inline' + }, + render: (props) => { + return ( + + {props.children} + + ) + } + } const schema = { - rules: [ - BLOCK_RENDER_RULE, - INLINE_RENDER_RULE - ] + rules: [ + BLOCK_RENDER_RULE, + INLINE_RENDER_RULE + ] } /** diff --git a/src/plugins/schema.js b/src/plugins/schema.js index f1190e9ac..46f8ea54b 100644 --- a/src/plugins/schema.js +++ b/src/plugins/schema.js @@ -57,16 +57,16 @@ const BLOCK_CHILDREN_RULE = { */ const MIN_TEXT_RULE = { - match: (object) => { - return object.kind == 'block' || object.kind == 'inline' - }, - validate: (node) => { - const { nodes } = node - return nodes.size === 0 ? true : null - }, - normalize: (transform, node) => { - return transform.insertNodeByKey(node.key, 0, Text.create(), { normalize: false }) - } + match: (object) => { + return object.kind == 'block' || object.kind == 'inline' + }, + validate: (node) => { + const { nodes } = node + return nodes.size === 0 ? true : null + }, + normalize: (transform, node) => { + return transform.insertNodeByKey(node.key, 0, Text.create(), { normalize: false }) + } } /** @@ -83,7 +83,7 @@ const INLINE_CHILDREN_RULE = { const { nodes } = inline const invalids = nodes.filter(n => n.kind != 'inline' && n.kind != 'text') return invalids.size ? invalids : null -}, + }, normalize: (transform, inline, invalids) => { return invalids.reduce((t, n) => t.removeNodeByKey(n.key, { normalize: false }), transform) } @@ -131,11 +131,11 @@ const INLINE_VOID_TEXT_RULE = { return node.text !== ' ' || node.nodes.size !== 1 }, normalize: (transform, node, result) => { - transform = node.nodes.reduce((t, child) => { - return t.removeNodeByKey(child.key, { normalize: false }) - }, transform) + transform = node.nodes.reduce((t, child) => { + return t.removeNodeByKey(child.key, { normalize: false }) + }, transform) - return transform.insertNodeByKey(node.key, 0, Text.createFromString(' '), { normalize: false }) + return transform.insertNodeByKey(node.key, 0, Text.createFromString(' '), { normalize: false }) } } @@ -240,43 +240,43 @@ const NO_EMPTY_TEXT_RULE = { const { nodes } = node if (nodes.size <= 1) { - return + return } const invalids = nodes - .filter((desc, i) => { - if (desc.kind != 'text' || desc.length > 0) { - return - } + .filter((desc, i) => { + if (desc.kind != 'text' || desc.length > 0) { + return + } - // Empty text nodes are only allowed near inline void node - const next = nodes.get(i + 1) - const prev = i > 0 ? nodes.get(i - 1) : null + // Empty text nodes are only allowed near inline void node + const next = nodes.get(i + 1) + const prev = i > 0 ? nodes.get(i - 1) : null - // If last one and previous is an inline void, we need to preserve it - if (!next && isInlineVoid(prev)) { - return - } + // If last one and previous is an inline void, we need to preserve it + if (!next && isInlineVoid(prev)) { + return + } - // If first one and next one is an inline, we preserve it - if (!prev && isInlineVoid(next)) { - return - } + // If first one and next one is an inline, we preserve it + if (!prev && isInlineVoid(next)) { + return + } - // If surrounded by inline void, we preserve it - if (next && prev && isInlineVoid(next) && isInlineVoid(prev)) { - return - } + // If surrounded by inline void, we preserve it + if (next && prev && isInlineVoid(next) && isInlineVoid(prev)) { + return + } - // Otherwise we remove it - return true - }) + // Otherwise we remove it + return true + }) return invalids.size ? invalids : null }, normalize: (transform, node, invalids) => { return invalids.reduce((t, text) => { - return t.removeNodeByKey(text.key, { normalize: false }) + return t.removeNodeByKey(text.key, { normalize: false }) }, transform) } } diff --git a/src/serializers/html.js b/src/serializers/html.js index 41e8d79a6..b76e09790 100644 --- a/src/serializers/html.js +++ b/src/serializers/html.js @@ -129,17 +129,17 @@ class Html { elements.forEach((element) => { const node = this.deserializeElement(element) switch (typeOf(node)) { - case 'array': - nodes = nodes.concat(node) - break - case 'object': - nodes.push(node) - break - case 'null': - case 'undefined': - return - default: - throw new Error(`A rule returned an invalid deserialized representation: "${node}".`) + case 'array': + nodes = nodes.concat(node) + break + case 'object': + nodes.push(node) + break + case 'null': + case 'undefined': + return + default: + throw new Error(`A rule returned an invalid deserialized representation: "${node}".`) } }) @@ -158,15 +158,15 @@ class Html { const next = (elements) => { switch (typeOf(elements)) { - case 'array': - return this.deserializeElements(elements) - case 'object': - return this.deserializeElement(elements) - case 'null': - case 'undefined': - return - default: - throw new Error(`The \`next\` argument was called with invalid children: "${elements}".`) + case 'array': + return this.deserializeElements(elements) + case 'object': + return this.deserializeElement(elements) + case 'null': + case 'undefined': + return + default: + throw new Error(`The \`next\` argument was called with invalid children: "${elements}".`) } } diff --git a/src/serializers/raw.js b/src/serializers/raw.js index 1b53861d7..7a4a5ad8e 100644 --- a/src/serializers/raw.js +++ b/src/serializers/raw.js @@ -110,13 +110,13 @@ const Raw = { deserializeNode(object, options) { switch (object.kind) { - case 'block': return Raw.deserializeBlock(object, options) - case 'document': return Raw.deserializeDocument(object, options) - case 'inline': return Raw.deserializeInline(object, options) - case 'text': return Raw.deserializeText(object, options) - default: { - throw new Error(`Unrecognized node kind "${object.kind}".`) - } + case 'block': return Raw.deserializeBlock(object, options) + case 'document': return Raw.deserializeDocument(object, options) + case 'inline': return Raw.deserializeInline(object, options) + case 'text': return Raw.deserializeText(object, options) + default: { + throw new Error(`Unrecognized node kind "${object.kind}".`) + } } }, @@ -291,13 +291,13 @@ const Raw = { serializeNode(node, options) { switch (node.kind) { - case 'block': return Raw.serializeBlock(node, options) - case 'document': return Raw.serializeDocument(node, options) - case 'inline': return Raw.serializeInline(node, options) - case 'text': return Raw.serializeText(node, options) - default: { - throw new Error(`Unrecognized node kind "${node.kind}".`) - } + case 'block': return Raw.serializeBlock(node, options) + case 'document': return Raw.serializeDocument(node, options) + case 'inline': return Raw.serializeInline(node, options) + case 'text': return Raw.serializeText(node, options) + default: { + throw new Error(`Unrecognized node kind "${node.kind}".`) + } } }, diff --git a/src/transforms/normalize.js b/src/transforms/normalize.js index f089347f8..0969bf86c 100644 --- a/src/transforms/normalize.js +++ b/src/transforms/normalize.js @@ -193,10 +193,10 @@ export function normalizeWith(transform, schema, prevDocument) { */ export function normalize(transform) { - transform = transform - .normalizeDocument() - .normalizeSelection() - return transform + transform = transform + .normalizeDocument() + .normalizeSelection() + return transform } /** @@ -272,15 +272,15 @@ export function normalizeSelection(transform) { !document.hasDescendant(selection.anchorKey) || !document.hasDescendant(selection.focusKey) ) { - warning('Selection was invalid and reset to start of the document') - const firstText = document.getTexts().first() - selection = selection.merge({ - anchorKey: firstText.key, - anchorOffset: 0, - focusKey: firstText.key, - focusOffset: 0, - isBackward: false - }) + warning('Selection was invalid and reset to start of the document') + const firstText = document.getTexts().first() + selection = selection.merge({ + anchorKey: firstText.key, + anchorOffset: 0, + focusKey: firstText.key, + focusOffset: 0, + isBackward: false + }) } state = state.merge({ selection }) diff --git a/src/transforms/operations.js b/src/transforms/operations.js index 0367deb81..98c9223c3 100644 --- a/src/transforms/operations.js +++ b/src/transforms/operations.js @@ -380,10 +380,10 @@ export function setSelectionOperation(transform, properties) { // If the selection moves, clear any marks, unless the new selection // does change the marks in some way const moved = [ - 'anchorKey', - 'anchorOffset', - 'focusKey', - 'focusOffset', + 'anchorKey', + 'anchorOffset', + 'focusKey', + 'focusOffset', ].some(p => props.hasOwnProperty(p)) if (selection.marks diff --git a/src/utils/normalize.js b/src/utils/normalize.js index 883043a5f..aabbb1ea3 100644 --- a/src/utils/normalize.js +++ b/src/utils/normalize.js @@ -20,13 +20,12 @@ function block(value) { if (value instanceof Block) return value switch (typeOf(value)) { - case 'string': - case 'object': { - return Block.create(nodeProperties(value)) - } - default: { - throw new Error(`Invalid \`block\` argument! It must be a block, an object, or a string. You passed: "${value}".`) - } + case 'string': + case 'object': + return Block.create(nodeProperties(value)) + + default: + throw new Error(`Invalid \`block\` argument! It must be a block, an object, or a string. You passed: "${value}".`) } } @@ -41,13 +40,12 @@ function inline(value) { if (value instanceof Inline) return value switch (typeOf(value)) { - case 'string': - case 'object': { - return Inline.create(nodeProperties(value)) - } - default: { - throw new Error(`Invalid \`inline\` argument! It must be an inline, an object, or a string. You passed: "${value}".`) - } + case 'string': + case 'object': + return Inline.create(nodeProperties(value)) + + default: + throw new Error(`Invalid \`inline\` argument! It must be an inline, an object, or a string. You passed: "${value}".`) } } @@ -81,13 +79,12 @@ function mark(value) { if (value instanceof Mark) return value switch (typeOf(value)) { - case 'string': - case 'object': { - return Mark.create(markProperties(value)) - } - default: { - throw new Error(`Invalid \`mark\` argument! It must be a mark, an object, or a string. You passed: "${value}".`) - } + case 'string': + case 'object': + return Mark.create(markProperties(value)) + + default: + throw new Error(`Invalid \`mark\` argument! It must be a mark, an object, or a string. You passed: "${value}".`) } } @@ -102,23 +99,22 @@ function markProperties(value = {}) { const ret = {} switch (typeOf(value)) { - case 'string': { - ret.type = value - break - } - case 'object': { - for (const k in value) { - if (k == 'data') { - if (value[k] !== undefined) ret[k] = Data.create(value[k]) - } else { - ret[k] = value[k] - } + case 'string': + ret.type = value + break + + case 'object': + for (const k in value) { + if (k == 'data') { + if (value[k] !== undefined) ret[k] = Data.create(value[k]) + } else { + ret[k] = value[k] } - break - } - default: { - throw new Error(`Invalid mark \`properties\` argument! It must be an object, a string or a mark. You passed: "${value}".`) } + break + + default: + throw new Error(`Invalid mark \`properties\` argument! It must be an object, a string or a mark. You passed: "${value}".`) } return ret @@ -135,24 +131,23 @@ function nodeProperties(value = {}) { const ret = {} switch (typeOf(value)) { - case 'string': { - ret.type = value - break - } - case 'object': { - if (value.isVoid !== undefined) ret.isVoid = !!value.isVoid - for (const k in value) { - if (k == 'data') { - if (value[k] !== undefined) ret[k] = Data.create(value[k]) - } else { - ret[k] = value[k] - } + case 'string': + ret.type = value + break + + case 'object': + if (value.isVoid !== undefined) ret.isVoid = !!value.isVoid + for (const k in value) { + if (k == 'data') { + if (value[k] !== undefined) ret[k] = Data.create(value[k]) + } else { + ret[k] = value[k] } - break - } - default: { - throw new Error(`Invalid node \`properties\` argument! It must be an object, a string or a node. You passed: "${value}".`) } + break + + default: + throw new Error(`Invalid node \`properties\` argument! It must be an object, a string or a node. You passed: "${value}".`) } return ret @@ -169,12 +164,11 @@ function selection(value) { if (value instanceof Selection) return value switch (typeOf(value)) { - case 'object': { - return Selection.create(value) - } - default: { - throw new Error(`Invalid \`selection\` argument! It must be a selection or an object. You passed: "${value}".`) - } + case 'object': + return Selection.create(value) + + default: + throw new Error(`Invalid \`selection\` argument! It must be a selection or an object. You passed: "${value}".`) } } @@ -189,19 +183,18 @@ function selectionProperties(value = {}) { const ret = {} switch (typeOf(value)) { - case 'object': { - if (value.anchorKey !== undefined) ret.anchorKey = value.anchorKey - if (value.anchorOffset !== undefined) ret.anchorOffset = value.anchorOffset - if (value.focusKey !== undefined) ret.focusKey = value.focusKey - if (value.focusOffset !== undefined) ret.focusOffset = value.focusOffset - if (value.isBackward !== undefined) ret.isBackward = !!value.isBackward - if (value.isFocused !== undefined) ret.isFocused = !!value.isFocused - if (value.marks !== undefined) ret.marks = value.marks - break - } - default: { - throw new Error(`Invalid selection \`properties\` argument! It must be an object or a selection. You passed: "${value}".`) - } + case 'object': + if (value.anchorKey !== undefined) ret.anchorKey = value.anchorKey + if (value.anchorOffset !== undefined) ret.anchorOffset = value.anchorOffset + if (value.focusKey !== undefined) ret.focusKey = value.focusKey + if (value.focusOffset !== undefined) ret.focusOffset = value.focusOffset + if (value.isBackward !== undefined) ret.isBackward = !!value.isBackward + if (value.isFocused !== undefined) ret.isFocused = !!value.isFocused + if (value.marks !== undefined) ret.marks = value.marks + break + + default: + throw new Error(`Invalid selection \`properties\` argument! It must be an object or a selection. You passed: "${value}".`) } return ret diff --git a/src/utils/transfer.js b/src/utils/transfer.js index bf1f5c45e..14817fa6e 100644 --- a/src/utils/transfer.js +++ b/src/utils/transfer.js @@ -41,22 +41,22 @@ class Transfer { data.type = type switch (type) { - case 'files': - data.files = this.getFiles() - break - case 'fragment': - data.fragment = this.getFragment() - break - case 'html': - data.html = this.getHtml() - data.text = this.getText() - break - case 'node': - data.node = this.getNode() - break - case 'text': - data.text = this.getText() - break + case 'files': + data.files = this.getFiles() + break + case 'fragment': + data.fragment = this.getFragment() + break + case 'html': + data.html = this.getHtml() + data.text = this.getText() + break + case 'node': + data.node = this.getNode() + break + case 'text': + data.text = this.getText() + break } return data @@ -76,8 +76,8 @@ class Transfer { if (data.items && data.items.length) { const fileItems = Array.from(data.items) - .map(item => item.kind == 'file' ? item.getAsFile() : null) - .filter(exists => exists) + .map(item => item.kind == 'file' ? item.getAsFile() : null) + .filter(exists => exists) if (fileItems.length) files = fileItems }