From 4ce5126643b38b8ed7be35660b5cac3e972437c5 Mon Sep 17 00:00:00 2001 From: Christoffer Jahren Date: Thu, 30 Sep 2021 09:53:55 +0200 Subject: [PATCH 1/3] fix: make sure font-weight 500 is considered non bold --- src/model/encoding/convertFromHTMLToContentBlocks.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/model/encoding/convertFromHTMLToContentBlocks.js b/src/model/encoding/convertFromHTMLToContentBlocks.js index b8fe3518fe..0f850d31e4 100644 --- a/src/model/encoding/convertFromHTMLToContentBlocks.js +++ b/src/model/encoding/convertFromHTMLToContentBlocks.js @@ -48,7 +48,7 @@ const REGEX_CARRIAGE = new RegExp(' ?', 'g'); const REGEX_ZWS = new RegExp('​?', 'g'); // https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight -const boldValues = ['bold', 'bolder', '500', '600', '700', '800', '900']; +const boldValues = ['bold', 'bolder', '600', '700', '800', '900']; const notBoldValues = [ 'light', 'lighter', @@ -57,6 +57,7 @@ const notBoldValues = [ '200', '300', '400', + '500', ]; const anchorAttr = ['className', 'href', 'rel', 'target', 'title']; From d126bc53359f7ba2ce0790629c5192e8ddc776a3 Mon Sep 17 00:00:00 2001 From: Christoffer Jahren Date: Thu, 30 Sep 2021 10:18:42 +0200 Subject: [PATCH 2/3] fix: make sure install and build works --- scripts/module-map.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/module-map.js b/scripts/module-map.js index 6896a2f3ac..de34302c6f 100644 --- a/scripts/module-map.js +++ b/scripts/module-map.js @@ -8,7 +8,7 @@ module.exports = Object.assign( { immutable: 'immutable', - React: 'react', + react: 'react', ReactDOM: 'react-dom', ReactDOMComet: 'react-dom', 'object-assign': 'object-assign', @@ -17,5 +17,5 @@ module.exports = Object.assign( reactComponentExpect: 'react-dom/lib/reactComponentExpect', }, require('fbjs/module-map'), - require('fbjs-scripts/third-party-module-map') + require('fbjs-scripts/third-party-module-map'), ); From c7d60f8d3857455b5c485063613e29a740a2bc87 Mon Sep 17 00:00:00 2001 From: Christoffer Jahren Date: Thu, 30 Sep 2021 10:19:24 +0200 Subject: [PATCH 3/3] fix: run eslint fix --- .../__tests__/DraftEditorTextNode-test.js | 28 +++--- .../__tests__/SecondaryClipboard-test.js | 5 +- .../edit/commands/keyCommandBackspaceWord.js | 5 +- .../edit/commands/keyCommandDeleteWord.js | 5 +- src/component/handlers/edit/editOnBlur.js | 2 +- .../selection/getRangeClientRects.js | 2 +- .../selection/setDraftEditorSelection.js | 2 +- .../utils/getTextContentFromFiles.js | 8 +- .../convertFromRawToDraftState-test.js | 4 +- src/model/immutable/BlockTree.js | 2 +- src/model/immutable/ContentBlockNode.js | 3 +- src/model/immutable/EditorState.js | 10 +- .../__tests__/AtomicBlockUtils-test.js | 96 +++++++++++++++---- .../__tests__/RichTextEditorUtil-test.js | 5 +- .../exploration/NestedRichTextEditorUtil.js | 6 +- .../NestedRichTextEditorUtil-test.js | 5 +- .../__tests__/removeEntitiesAtEdges-test.js | 4 +- .../removeRangeFromContentState-test.js | 14 ++- .../splitBlockInContentState-test.js | 5 +- src/stubs/gkx.js | 2 +- src/util/getOwnObjectValues.js | 4 +- src/util/uuid.js | 2 +- 22 files changed, 157 insertions(+), 62 deletions(-) diff --git a/src/component/contents/__tests__/DraftEditorTextNode-test.js b/src/component/contents/__tests__/DraftEditorTextNode-test.js index 9c4cacc1f8..465dfc8b42 100644 --- a/src/component/contents/__tests__/DraftEditorTextNode-test.js +++ b/src/component/contents/__tests__/DraftEditorTextNode-test.js @@ -56,7 +56,7 @@ const expectPopulatedSpan = (stub, testString) => { expect(node.firstChild && node.firstChild.textContent).toBe(testString); }; -test('must initialize correctly with an empty string, non-IE', function () { +test('must initialize correctly with an empty string, non-IE', function() { initializeAsNonIE(); const stub = renderIntoContainer( {''}, @@ -66,7 +66,7 @@ test('must initialize correctly with an empty string, non-IE', function () { expect(ReactDOM.findDOMNode(stub).tagName).toBe('BR'); }); -test('must initialize correctly with an empty string, IE', function () { +test('must initialize correctly with an empty string, IE', function() { initializeAsIE(); const stub = renderIntoContainer( {''}, @@ -74,7 +74,7 @@ test('must initialize correctly with an empty string, IE', function () { expectPopulatedSpan(stub, BLOCK_DELIMITER_CHAR); }); -test('must initialize correctly with a string, non-IE', function () { +test('must initialize correctly with a string, non-IE', function() { initializeAsNonIE(); const stub = renderIntoContainer( {TEST_A}, @@ -82,7 +82,7 @@ test('must initialize correctly with a string, non-IE', function () { expectPopulatedSpan(stub, TEST_A); }); -test('must initialize correctly with a string, IE', function () { +test('must initialize correctly with a string, IE', function() { initializeAsIE(); const stub = renderIntoContainer( {TEST_A}, @@ -90,7 +90,7 @@ test('must initialize correctly with a string, IE', function () { expectPopulatedSpan(stub, TEST_A); }); -test('must update from empty to non-empty, non-IE', function () { +test('must update from empty to non-empty, non-IE', function() { initializeAsNonIE(); const stub = renderIntoContainer( {''}, @@ -100,7 +100,7 @@ test('must update from empty to non-empty, non-IE', function () { expectPopulatedSpan(stub, TEST_A); }); -test('must update from empty to non-empty, IE', function () { +test('must update from empty to non-empty, IE', function() { initializeAsIE(); const stub = renderIntoContainer( {''}, @@ -110,7 +110,7 @@ test('must update from empty to non-empty, IE', function () { expectPopulatedSpan(stub, TEST_A); }); -test('must update from non-empty to non-empty, non-IE', function () { +test('must update from non-empty to non-empty, non-IE', function() { initializeAsNonIE(); const stub = renderIntoContainer( {TEST_A}, @@ -126,7 +126,7 @@ test('must update from non-empty to non-empty, non-IE', function () { expectPopulatedSpan(stub, TEST_B); }); -test('must update from non-empty to non-empty, non-IE', function () { +test('must update from non-empty to non-empty, non-IE', function() { initializeAsIE(); const stub = renderIntoContainer( {TEST_A}, @@ -141,7 +141,7 @@ test('must update from non-empty to non-empty, non-IE', function () { expectPopulatedSpan(stub, TEST_B); }); -test('must skip updates if text already matches DOM, non-IE', function () { +test('must skip updates if text already matches DOM, non-IE', function() { initializeAsNonIE(); const stub = renderIntoContainer( {TEST_A}, @@ -163,7 +163,7 @@ test('must skip updates if text already matches DOM, non-IE', function () { expect(stub.render.mock.calls.length).toBe(1); }); -test('must skip updates if text already matches DOM, IE', function () { +test('must skip updates if text already matches DOM, IE', function() { initializeAsIE(); const stub = renderIntoContainer( {TEST_A}, @@ -185,7 +185,7 @@ test('must skip updates if text already matches DOM, IE', function () { expect(stub.render.mock.calls.length).toBe(1); }); -test('must update from non-empty to empty, non-IE', function () { +test('must update from non-empty to empty, non-IE', function() { initializeAsNonIE(); const stub = renderIntoContainer( {TEST_A}, @@ -198,7 +198,7 @@ test('must update from non-empty to empty, non-IE', function () { expect(ReactDOM.findDOMNode(stub).tagName).toBe('BR'); }); -test('must update from non-empty to empty, IE', function () { +test('must update from non-empty to empty, IE', function() { initializeAsIE(); const stub = renderIntoContainer( {TEST_A}, @@ -209,7 +209,7 @@ test('must update from non-empty to empty, IE', function () { expectPopulatedSpan(stub, BLOCK_DELIMITER_CHAR); }); -test('must render properly into a parent DOM node', function () { +test('must render properly into a parent DOM node', function() { initializeAsNonIE(); renderIntoContainer(
@@ -218,7 +218,7 @@ test('must render properly into a parent DOM node', function () { ); }); -test('must force unchanged text back into the DOM', function () { +test('must force unchanged text back into the DOM', function() { initializeAsNonIE(); const stub = renderIntoContainer( {TEST_A}, diff --git a/src/component/handlers/edit/commands/__tests__/SecondaryClipboard-test.js b/src/component/handlers/edit/commands/__tests__/SecondaryClipboard-test.js index 4652f23e3a..a194422b40 100644 --- a/src/component/handlers/edit/commands/__tests__/SecondaryClipboard-test.js +++ b/src/component/handlers/edit/commands/__tests__/SecondaryClipboard-test.js @@ -112,7 +112,10 @@ const assertCutOperation = ( SelectionState.createEmpty(content[0].key).merge(selection), ), ); - const expected = result.getCurrentContent().getBlockMap().toJS(); + const expected = result + .getCurrentContent() + .getBlockMap() + .toJS(); expect(expected).toMatchSnapshot(); }; diff --git a/src/component/handlers/edit/commands/keyCommandBackspaceWord.js b/src/component/handlers/edit/commands/keyCommandBackspaceWord.js index 72ce923496..473af9cdc7 100644 --- a/src/component/handlers/edit/commands/keyCommandBackspaceWord.js +++ b/src/component/handlers/edit/commands/keyCommandBackspaceWord.js @@ -33,7 +33,10 @@ function keyCommandBackspaceWord(editorState: EditorState): EditorState { } const key = selection.getStartKey(); const content = strategyState.getCurrentContent(); - const text = content.getBlockForKey(key).getText().slice(0, offset); + const text = content + .getBlockForKey(key) + .getText() + .slice(0, offset); const toRemove = DraftRemovableWord.getBackward(text); return moveSelectionBackward(strategyState, toRemove.length || 1); }, diff --git a/src/component/handlers/edit/commands/keyCommandDeleteWord.js b/src/component/handlers/edit/commands/keyCommandDeleteWord.js index b9a07194ba..781881a19e 100644 --- a/src/component/handlers/edit/commands/keyCommandDeleteWord.js +++ b/src/component/handlers/edit/commands/keyCommandDeleteWord.js @@ -29,7 +29,10 @@ function keyCommandDeleteWord(editorState: EditorState): EditorState { const offset = selection.getStartOffset(); const key = selection.getStartKey(); const content = strategyState.getCurrentContent(); - const text = content.getBlockForKey(key).getText().slice(offset); + const text = content + .getBlockForKey(key) + .getText() + .slice(offset); const toRemove = DraftRemovableWord.getForward(text); // If there are no words in front of the cursor, remove the newline. diff --git a/src/component/handlers/edit/editOnBlur.js b/src/component/handlers/edit/editOnBlur.js index 04135e21c6..aee69e5068 100644 --- a/src/component/handlers/edit/editOnBlur.js +++ b/src/component/handlers/edit/editOnBlur.js @@ -30,7 +30,7 @@ function editOnBlur(editor: DraftEditor, e: SyntheticEvent): void { // opposed to clicking to another tab or window). const {ownerDocument} = e.currentTarget; if ( - !Boolean(editor.props.preserveSelectionOnBlur) && + !editor.props.preserveSelectionOnBlur && getActiveElement(ownerDocument) === ownerDocument.body ) { const selection: SelectionObject = ownerDocument.defaultView.getSelection(); diff --git a/src/component/selection/getRangeClientRects.js b/src/component/selection/getRangeClientRects.js index da9e94b84d..46b4f62d6f 100644 --- a/src/component/selection/getRangeClientRects.js +++ b/src/component/selection/getRangeClientRects.js @@ -60,7 +60,7 @@ function getRangeClientRectsChrome(range: Range): Array { */ const getRangeClientRects = ((isChrome ? getRangeClientRectsChrome - : function (range: Range): Array { + : function(range: Range): Array { return Array.from(range.getClientRects()); }): (range: Range) => Array); diff --git a/src/component/selection/setDraftEditorSelection.js b/src/component/selection/setDraftEditorSelection.js index 68f8ac52f6..cc08cafbad 100644 --- a/src/component/selection/setDraftEditorSelection.js +++ b/src/component/selection/setDraftEditorSelection.js @@ -273,7 +273,7 @@ function addFocusToSelection( } } catch (e) { DraftJsDebugLogging.logSelectionStateFailure({ - anonymizedDom: getAnonymizedEditorDOM(node, function (n) { + anonymizedDom: getAnonymizedEditorDOM(node, function(n) { const labels = []; if (n === activeElement) { labels.push('active element'); diff --git a/src/component/utils/getTextContentFromFiles.js b/src/component/utils/getTextContentFromFiles.js index 176ce9a429..216843ab24 100644 --- a/src/component/utils/getTextContentFromFiles.js +++ b/src/component/utils/getTextContentFromFiles.js @@ -33,8 +33,8 @@ function getTextContentFromFiles( ): void { let readCount = 0; const results = []; - files.forEach(function (/*blob*/ file) { - readFile(file, function (/*string*/ text) { + files.forEach(function(/*blob*/ file) { + readFile(file, function(/*string*/ text) { readCount++; text && results.push(text.slice(0, TEXT_SIZE_UPPER_BOUND)); if (readCount == files.length) { @@ -67,7 +67,7 @@ function readFile(file: File, callback: (contents: string) => void): void { } const reader = new FileReader(); - reader.onload = function () { + reader.onload = function() { const result = reader.result; invariant( typeof result === 'string', @@ -75,7 +75,7 @@ function readFile(file: File, callback: (contents: string) => void): void { ); callback(result); }; - reader.onerror = function () { + reader.onerror = function() { callback(''); }; reader.readAsText(file); diff --git a/src/model/encoding/__tests__/convertFromRawToDraftState-test.js b/src/model/encoding/__tests__/convertFromRawToDraftState-test.js index f9b9e949dd..7b01286054 100644 --- a/src/model/encoding/__tests__/convertFromRawToDraftState-test.js +++ b/src/model/encoding/__tests__/convertFromRawToDraftState-test.js @@ -26,7 +26,9 @@ const toggleExperimentalTreeDataSupport = enabled => { const assertDraftState = (rawState: RawDraftContentState) => { expect( - convertFromRawToDraftState(rawState).getBlockMap().toJS(), + convertFromRawToDraftState(rawState) + .getBlockMap() + .toJS(), ).toMatchSnapshot(); }; diff --git a/src/model/immutable/BlockTree.js b/src/model/immutable/BlockTree.js index 12f92c9457..69327bfa75 100644 --- a/src/model/immutable/BlockTree.js +++ b/src/model/immutable/BlockTree.js @@ -22,7 +22,7 @@ const Immutable = require('immutable'); const {List, Repeat, Record} = Immutable; -const returnTrue = function () { +const returnTrue = function() { return true; }; diff --git a/src/model/immutable/ContentBlockNode.js b/src/model/immutable/ContentBlockNode.js index 45b40365c7..9de9236a52 100644 --- a/src/model/immutable/ContentBlockNode.js +++ b/src/model/immutable/ContentBlockNode.js @@ -77,8 +77,7 @@ const decorateCharacterList = ( return config; }; -class ContentBlockNode - extends (Record(defaultRecord): any) +class ContentBlockNode extends (Record(defaultRecord): any) implements BlockNode { constructor(props: ContentBlockNodeConfig = defaultRecord) { /* eslint-disable-next-line constructor-super */ diff --git a/src/model/immutable/EditorState.js b/src/model/immutable/EditorState.js index 428d4c525b..5ce1e96671 100644 --- a/src/model/immutable/EditorState.js +++ b/src/model/immutable/EditorState.js @@ -138,7 +138,10 @@ class EditorState { if (contentState.getBlockMap().count() === 0) { return EditorState.createEmpty(decorator); } - const firstKey = contentState.getBlockMap().first().getKey(); + const firstKey = contentState + .getBlockMap() + .first() + .getKey(); return EditorState.create({ currentContent: contentState, undoStack: Stack(), @@ -343,7 +346,10 @@ class EditorState { } isSelectionAtStartOfContent(): boolean { - const firstKey = this.getCurrentContent().getBlockMap().first().getKey(); + const firstKey = this.getCurrentContent() + .getBlockMap() + .first() + .getKey(); return this.getSelection().hasEdgeWithin(firstKey, 0, 0); } diff --git a/src/model/modifier/__tests__/AtomicBlockUtils-test.js b/src/model/modifier/__tests__/AtomicBlockUtils-test.js index 202d5ee2ca..f56f2b7540 100644 --- a/src/model/modifier/__tests__/AtomicBlockUtils-test.js +++ b/src/model/modifier/__tests__/AtomicBlockUtils-test.js @@ -50,7 +50,11 @@ const toggleExperimentalTreeDataSupport = enabled => { const assertAtomic = state => { expect( - state.getCurrentContent().getBlockMap().toIndexedSeq().toJS(), + state + .getCurrentContent() + .getBlockMap() + .toIndexedSeq() + .toJS(), ).toMatchSnapshot(); }; @@ -120,7 +124,10 @@ test('must move atomic at start of block with collapsed selection', () => { const resultEditor = assertInsertAtomicBlock(); const resultContent = resultEditor.getCurrentContent(); const firstBlock = resultContent.getBlockMap().first(); - const atomicBlock = resultContent.getBlockMap().skip(1).first(); + const atomicBlock = resultContent + .getBlockMap() + .skip(1) + .first(); assertMoveAtomicBlock( atomicBlock, @@ -137,7 +144,10 @@ test('must move atomic at end of block with collapsed selection', () => { const resultEditor = assertInsertAtomicBlock(); const resultContent = resultEditor.getCurrentContent(); const lastBlock = resultContent.getBlockMap().last(); - const atomicBlock = resultContent.getBlockMap().skip(1).first(); + const atomicBlock = resultContent + .getBlockMap() + .skip(1) + .first(); // Move atomic block at end of the last block assertMoveAtomicBlock( @@ -156,8 +166,14 @@ test('must move atomic inbetween block with collapsed selection', () => { // Insert atomic block at the first position const resultEditor = assertInsertAtomicBlock(); const resultContent = resultEditor.getCurrentContent(); - const atomicBlock = resultContent.getBlockMap().skip(1).first(); - const thirdBlock = resultContent.getBlockMap().skip(2).first(); + const atomicBlock = resultContent + .getBlockMap() + .skip(1) + .first(); + const thirdBlock = resultContent + .getBlockMap() + .skip(2) + .first(); // Move atomic block inbetween the split parts of the third block assertMoveAtomicBlock( @@ -177,7 +193,10 @@ test('must move atomic before block with collapsed selection', () => { const resultEditor = assertInsertAtomicBlock(); const resultContent = resultEditor.getCurrentContent(); const firstBlock = resultContent.getBlockMap().first(); - const atomicBlock = resultContent.getBlockMap().skip(1).first(); + const atomicBlock = resultContent + .getBlockMap() + .skip(1) + .first(); // Move atomic block before the first block assertMoveAtomicBlock( @@ -194,7 +213,10 @@ test('must move atomic after block with collapsed selection', () => { // Insert atomic block at the first position const resultEditor = assertInsertAtomicBlock(); const resultContent = resultEditor.getCurrentContent(); - const atomicBlock = resultContent.getBlockMap().skip(1).first(); + const atomicBlock = resultContent + .getBlockMap() + .skip(1) + .first(); const lastBlock = resultContent.getBlockMap().last(); // Move atomic block after the last block @@ -221,8 +243,14 @@ test("mustn't move atomic next to itself with collapsed selection", () => { ); const resultContent = resultEditor.getCurrentContent(); const beforeAtomicBlock = resultContent.getBlockMap().first(); - const atomicBlock = resultContent.getBlockMap().skip(1).first(); - const afterAtomicBlock = resultContent.getBlockMap().skip(2).first(); + const atomicBlock = resultContent + .getBlockMap() + .skip(1) + .first(); + const afterAtomicBlock = resultContent + .getBlockMap() + .skip(2) + .first(); // Move atomic block above itself by moving it after preceding block by // replacement @@ -371,7 +399,10 @@ test('must insert atomic at end of block', () => { }); test('must insert atomic for cross-block selection', () => { - const originalThirdBlock = contentState.getBlockMap().skip(2).first(); + const originalThirdBlock = contentState + .getBlockMap() + .skip(2) + .first(); assertInsertAtomicBlock( EditorState.forceSelection( editorState, @@ -388,7 +419,10 @@ test('must move atomic at start of block', () => { // Insert atomic block at the first position const resultEditor = assertInsertAtomicBlock(); const resultContent = resultEditor.getCurrentContent(); - const atomicBlock = resultContent.getBlockMap().skip(1).first(); + const atomicBlock = resultContent + .getBlockMap() + .skip(1) + .first(); const lastBlock = resultContent.getBlockMap().last(); // Move atomic block at start of the last block @@ -408,7 +442,10 @@ test('must move atomic at end of block', () => { // Insert atomic block at the first position const resultEditor = assertInsertAtomicBlock(); const resultContent = resultEditor.getCurrentContent(); - const atomicBlock = resultContent.getBlockMap().skip(1).first(); + const atomicBlock = resultContent + .getBlockMap() + .skip(1) + .first(); const lastBlock = resultContent.getBlockMap().last(); // Move atomic block at end of the last block @@ -428,8 +465,14 @@ test('must move atomic inbetween block', () => { // Insert atomic block at the first position const resultEditor = assertInsertAtomicBlock(); const resultContent = resultEditor.getCurrentContent(); - const atomicBlock = resultContent.getBlockMap().skip(1).first(); - const thirdBlock = resultContent.getBlockMap().skip(2).first(); + const atomicBlock = resultContent + .getBlockMap() + .skip(1) + .first(); + const thirdBlock = resultContent + .getBlockMap() + .skip(2) + .first(); // Move atomic block inbetween the split parts of the third block assertMoveAtomicBlock( @@ -449,7 +492,10 @@ test('must move atomic before block', () => { const resultEditor = assertInsertAtomicBlock(); const resultContent = resultEditor.getCurrentContent(); const firstBlock = resultContent.getBlockMap().first(); - const atomicBlock = resultContent.getBlockMap().skip(1).first(); + const atomicBlock = resultContent + .getBlockMap() + .skip(1) + .first(); const lastBlock = resultContent.getBlockMap().last(); // Move atomic block before the first block @@ -471,7 +517,10 @@ test('must move atomic after block', () => { const resultEditor = assertInsertAtomicBlock(); const resultContent = resultEditor.getCurrentContent(); const firstBlock = resultContent.getBlockMap().first(); - const atomicBlock = resultContent.getBlockMap().skip(1).first(); + const atomicBlock = resultContent + .getBlockMap() + .skip(1) + .first(); const lastBlock = resultContent.getBlockMap().last(); // Move atomic block after the last block @@ -501,8 +550,14 @@ test("mustn't move atomic next to itself", () => { ); const resultContent = resultEditor.getCurrentContent(); const beforeAtomicBlock = resultContent.getBlockMap().first(); - const atomicBlock = resultContent.getBlockMap().skip(1).first(); - const afterAtomicBlock = resultContent.getBlockMap().skip(2).first(); + const atomicBlock = resultContent + .getBlockMap() + .skip(1) + .first(); + const afterAtomicBlock = resultContent + .getBlockMap() + .skip(2) + .first(); // Move atomic block above itself by moving it after preceding block by // replacement @@ -580,7 +635,10 @@ test('must be able to move atomic block when experimentalTreeDataSupport is enab const resultContent = resultEditor.getCurrentContent(); const lastBlock = resultContent.getBlockMap().last(); - const atomicBlock = resultContent.getBlockMap().skip(1).first(); + const atomicBlock = resultContent + .getBlockMap() + .skip(1) + .first(); // Move atomic block at end of the last block assertMoveAtomicBlock( diff --git a/src/model/modifier/__tests__/RichTextEditorUtil-test.js b/src/model/modifier/__tests__/RichTextEditorUtil-test.js index bed5c610c5..b531effcd3 100644 --- a/src/model/modifier/__tests__/RichTextEditorUtil-test.js +++ b/src/model/modifier/__tests__/RichTextEditorUtil-test.js @@ -177,7 +177,10 @@ describe('onTab on list block', () => { const changeBlockType = setListItem => EditorState.push(editorState, setListItem, 'change-block-type'); const getFirstBlockDepth = contentState => - contentState.getCurrentContent().getFirstBlock().getDepth(); + contentState + .getCurrentContent() + .getFirstBlock() + .getDepth(); const addTab = contentState => onTab({preventDefault: () => {}}, contentState); diff --git a/src/model/modifier/exploration/NestedRichTextEditorUtil.js b/src/model/modifier/exploration/NestedRichTextEditorUtil.js index 1008369a37..1b062685d0 100644 --- a/src/model/modifier/exploration/NestedRichTextEditorUtil.js +++ b/src/model/modifier/exploration/NestedRichTextEditorUtil.js @@ -171,8 +171,10 @@ const NestedRichTextEditorUtil: RichTextUtils = { return EditorState.push( editorState, withoutBlockStyle, - withoutBlockStyle.getBlockMap().get(currentBlock.getKey()).getType() === - 'unstyled' + withoutBlockStyle + .getBlockMap() + .get(currentBlock.getKey()) + .getType() === 'unstyled' ? 'change-block-type' : 'adjust-depth', ); diff --git a/src/model/modifier/exploration/__tests__/NestedRichTextEditorUtil-test.js b/src/model/modifier/exploration/__tests__/NestedRichTextEditorUtil-test.js index c5b5353a54..081113603c 100644 --- a/src/model/modifier/exploration/__tests__/NestedRichTextEditorUtil-test.js +++ b/src/model/modifier/exploration/__tests__/NestedRichTextEditorUtil-test.js @@ -125,7 +125,10 @@ const assertNestedUtilOperation = ( const expected = result instanceof EditorState - ? result.getCurrentContent().getBlockMap().toJS() + ? result + .getCurrentContent() + .getBlockMap() + .toJS() : result; expect(expected).toMatchSnapshot(); diff --git a/src/model/transaction/__tests__/removeEntitiesAtEdges-test.js b/src/model/transaction/__tests__/removeEntitiesAtEdges-test.js index 0a92d36cd6..7268a3c917 100644 --- a/src/model/transaction/__tests__/removeEntitiesAtEdges-test.js +++ b/src/model/transaction/__tests__/removeEntitiesAtEdges-test.js @@ -48,7 +48,9 @@ const assertRemoveEntitiesAtEdges = ( ) => { const contentState = ensureEntityWithMutability(content, '2', mutability); expect( - removeEntitiesAtEdges(contentState, selection).getBlockMap().toJS(), + removeEntitiesAtEdges(contentState, selection) + .getBlockMap() + .toJS(), ).toMatchSnapshot(); }; diff --git a/src/model/transaction/__tests__/removeRangeFromContentState-test.js b/src/model/transaction/__tests__/removeRangeFromContentState-test.js index 3c01dddf8c..898b27fc87 100644 --- a/src/model/transaction/__tests__/removeRangeFromContentState-test.js +++ b/src/model/transaction/__tests__/removeRangeFromContentState-test.js @@ -75,12 +75,17 @@ const assertRemoveRangeFromContentState = ( content = contentState, ) => { expect( - removeRangeFromContentState(content, selection).getBlockMap().toJS(), + removeRangeFromContentState(content, selection) + .getBlockMap() + .toJS(), ).toMatchSnapshot(); }; const initialBlock = contentState.getBlockMap().first(); -const secondBlock = contentState.getBlockMap().skip(1).first(); +const secondBlock = contentState + .getBlockMap() + .skip(1) + .first(); const selectionWithinA = selectionState.set('anchorOffset', 3); const selectionFromEndOfA = selectionState.merge({ anchorOffset: initialBlock.getLength(), @@ -111,7 +116,10 @@ test('must remove to the end of the block', () => { assertRemoveRangeFromContentState( selectionState.merge({ anchorOffset: 3, - focusOffset: contentState.getBlockMap().first().getLength(), + focusOffset: contentState + .getBlockMap() + .first() + .getLength(), }), ); }); diff --git a/src/model/transaction/__tests__/splitBlockInContentState-test.js b/src/model/transaction/__tests__/splitBlockInContentState-test.js index cd1abbb934..79cd027c5e 100644 --- a/src/model/transaction/__tests__/splitBlockInContentState-test.js +++ b/src/model/transaction/__tests__/splitBlockInContentState-test.js @@ -114,7 +114,10 @@ test('must split within a block', () => { }); test('must split at the end of a block', () => { - const SPLIT_OFFSET = contentState.getBlockMap().first().getLength(); + const SPLIT_OFFSET = contentState + .getBlockMap() + .first() + .getLength(); assertSplitBlockInContentState( selectionState.merge({ diff --git a/src/stubs/gkx.js b/src/stubs/gkx.js index bdae8998ab..065dd37c7d 100644 --- a/src/stubs/gkx.js +++ b/src/stubs/gkx.js @@ -10,7 +10,7 @@ 'use strict'; -module.exports = function (name: string) { +module.exports = function(name: string) { if (typeof window !== 'undefined' && window.__DRAFT_GKX) { return !!window.__DRAFT_GKX[name]; } diff --git a/src/util/getOwnObjectValues.js b/src/util/getOwnObjectValues.js index 8a43bce027..aa6ef555fb 100644 --- a/src/util/getOwnObjectValues.js +++ b/src/util/getOwnObjectValues.js @@ -18,9 +18,9 @@ */ function getOwnObjectValues(obj: { +[key: string]: TValue, - ... + ..., }): Array { - return Object.keys(obj).map((key) => obj[key]); + return Object.keys(obj).map(key => obj[key]); } module.exports = getOwnObjectValues; diff --git a/src/util/uuid.js b/src/util/uuid.js index d4ec9091bd..942cacd299 100644 --- a/src/util/uuid.js +++ b/src/util/uuid.js @@ -13,7 +13,7 @@ * http://stackoverflow.com/questions/105034 */ function uuid(): string { - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => { const r = (Math.random() * 16) | 0; const v = c == 'x' ? r : (r & 0x3) | 0x8; return v.toString(16);