Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

fix build and use correct bold values on copy #3068

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scripts/module-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
module.exports = Object.assign(
{
immutable: 'immutable',
React: 'react',
react: 'react',
ReactDOM: 'react-dom',
ReactDOMComet: 'react-dom',
'object-assign': 'object-assign',
Expand All @@ -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'),
);
28 changes: 14 additions & 14 deletions src/component/contents/__tests__/DraftEditorTextNode-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<DraftEditorTextNode>{''}</DraftEditorTextNode>,
Expand All @@ -66,31 +66,31 @@ 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(
<DraftEditorTextNode>{''}</DraftEditorTextNode>,
);
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(
<DraftEditorTextNode>{TEST_A}</DraftEditorTextNode>,
);
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(
<DraftEditorTextNode>{TEST_A}</DraftEditorTextNode>,
);
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(
<DraftEditorTextNode>{''}</DraftEditorTextNode>,
Expand All @@ -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(
<DraftEditorTextNode>{''}</DraftEditorTextNode>,
Expand All @@ -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(
<DraftEditorTextNode>{TEST_A}</DraftEditorTextNode>,
Expand All @@ -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(
<DraftEditorTextNode>{TEST_A}</DraftEditorTextNode>,
Expand All @@ -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(
<DraftEditorTextNode>{TEST_A}</DraftEditorTextNode>,
Expand All @@ -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(
<DraftEditorTextNode>{TEST_A}</DraftEditorTextNode>,
Expand All @@ -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(
<DraftEditorTextNode>{TEST_A}</DraftEditorTextNode>,
Expand All @@ -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(
<DraftEditorTextNode>{TEST_A}</DraftEditorTextNode>,
Expand All @@ -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(
<div>
Expand All @@ -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(
<DraftEditorTextNode>{TEST_A}</DraftEditorTextNode>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
Expand Down
5 changes: 4 additions & 1 deletion src/component/handlers/edit/commands/keyCommandDeleteWord.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/component/handlers/edit/editOnBlur.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function editOnBlur(editor: DraftEditor, e: SyntheticEvent<HTMLElement>): 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();
Expand Down
2 changes: 1 addition & 1 deletion src/component/selection/getRangeClientRects.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function getRangeClientRectsChrome(range: Range): Array<ClientRect> {
*/
const getRangeClientRects = ((isChrome
? getRangeClientRectsChrome
: function (range: Range): Array<ClientRect> {
: function(range: Range): Array<ClientRect> {
return Array.from(range.getClientRects());
}): (range: Range) => Array<ClientRect>);

Expand Down
2 changes: 1 addition & 1 deletion src/component/selection/setDraftEditorSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
8 changes: 4 additions & 4 deletions src/component/utils/getTextContentFromFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -67,15 +67,15 @@ 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',
'We should be calling "FileReader.readAsText" which returns a string',
);
callback(result);
};
reader.onerror = function () {
reader.onerror = function() {
callback('');
};
reader.readAsText(file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ const toggleExperimentalTreeDataSupport = enabled => {

const assertDraftState = (rawState: RawDraftContentState) => {
expect(
convertFromRawToDraftState(rawState).getBlockMap().toJS(),
convertFromRawToDraftState(rawState)
.getBlockMap()
.toJS(),
).toMatchSnapshot();
};

Expand Down
3 changes: 2 additions & 1 deletion src/model/encoding/convertFromHTMLToContentBlocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const REGEX_CARRIAGE = new RegExp('&#13;?', 'g');
const REGEX_ZWS = new RegExp('&#8203;?', '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',
Expand All @@ -57,6 +57,7 @@ const notBoldValues = [
'200',
'300',
'400',
'500',
];

const anchorAttr = ['className', 'href', 'rel', 'target', 'title'];
Expand Down
2 changes: 1 addition & 1 deletion src/model/immutable/BlockTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const Immutable = require('immutable');

const {List, Repeat, Record} = Immutable;

const returnTrue = function () {
const returnTrue = function() {
return true;
};

Expand Down
3 changes: 1 addition & 2 deletions src/model/immutable/ContentBlockNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
10 changes: 8 additions & 2 deletions src/model/immutable/EditorState.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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);
}

Expand Down
Loading