forked from facebookarchive/draft-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix line breaks when pasting from word to draft (facebookarchive#828)
* Making sure that pasted paragraphs are not converged when pasting * Adding documentation for introducing alias * Simplifying the logic * Adding flow types * Updaing docs
- Loading branch information
1 parent
6c6946b
commit b298df2
Showing
5 changed files
with
87 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/model/encoding/__tests__/convertFromHTMLToContentBlocks-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* @emails oncall+ui_infra | ||
*/ | ||
|
||
'use strict'; | ||
|
||
jest.disableAutomock(); | ||
|
||
const convertFromHTMLToContentBlocks = require('convertFromHTMLToContentBlocks'); | ||
|
||
function testConvertingAdjacentHtmlElementsToContentBlocks( | ||
tag: string | ||
) { | ||
it(`must not merge tags when converting adjacent <${tag} />`, () => { | ||
const html_string = ` | ||
<${tag}>a</${tag}> | ||
<${tag}>b</${tag}> | ||
`; | ||
|
||
const blocks = convertFromHTMLToContentBlocks(html_string); | ||
|
||
expect(blocks.contentBlocks.length).toBe(2); | ||
}); | ||
} | ||
|
||
describe('convertFromHTMLToContentBlocks', () => { | ||
[ | ||
'blockquote', | ||
'div', | ||
'figure', | ||
'h1', | ||
'h2', | ||
'h3', | ||
'h4', | ||
'h5', | ||
'h6', | ||
'li', | ||
'p', | ||
'pre', | ||
].forEach(tag => testConvertingAdjacentHtmlElementsToContentBlocks(tag)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,5 +60,6 @@ module.exports = Map({ | |
}, | ||
'unstyled': { | ||
element: 'div', | ||
aliasedElements: ['p'], | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters