1010 * of patent rights can be found in the PATENTS file in the same directory.
1111 */
1212
13- // immutable is CJS-only; default import maps to module.exports for Node ESM interop.
14- // eslint-disable-next-line import/default
15- import Immutable from 'immutable'
1613import DraftJS from 'draft-js'
14+ import Immutable from 'immutable'
1715import getSafeBodyFromHTML from './util/parseHTML.js'
1816import rangeSort from './util/rangeSort.js'
1917
20- // eslint-disable-next-line import/no-named-as-default-member
21- const { List, Map, OrderedSet } = Immutable
2218const {
2319 BlockMapBuilder,
2420 CharacterMetadata,
@@ -63,13 +59,13 @@ const handleMiddleware = (maybeMiddleware, base) => {
6359 return maybeMiddleware
6460}
6561
66- const defaultHTMLToBlock = ( nodeName , node , lastList ) => undefined
62+ const defaultHTMLToBlock = ( _nodeName , _node , _lastList ) => undefined
6763
68- const defaultHTMLToStyle = ( nodeName , node , currentStyle ) => currentStyle
64+ const defaultHTMLToStyle = ( _nodeName , _node , currentStyle ) => currentStyle
6965
70- const defaultHTMLToEntity = ( nodeName , node ) => undefined
66+ const defaultHTMLToEntity = ( _nodeName , _node ) => undefined
7167
72- const defaultTextToEntity = ( text ) => [ ]
68+ const defaultTextToEntity = ( _text ) => [ ]
7369
7470const nullthrows = ( x ) => {
7571 if ( x != null ) {
@@ -97,17 +93,17 @@ function getWhitespaceChunk(inEntity) {
9793
9894 return {
9995 text : SPACE ,
100- inlines : [ OrderedSet ( ) ] ,
96+ inlines : [ Immutable . OrderedSet ( ) ] ,
10197 entities,
10298 blocks : [ ] ,
10399 }
104100}
105101
106- function getSoftNewlineChunk ( block , depth , flat = false , data = Map ( ) ) {
102+ function getSoftNewlineChunk ( block , depth , flat = false , data = Immutable . Map ( ) ) {
107103 if ( flat === true ) {
108104 return {
109105 text : '\r' ,
110- inlines : [ OrderedSet ( ) ] ,
106+ inlines : [ Immutable . OrderedSet ( ) ] ,
111107 entities : new Array ( 1 ) ,
112108 blocks : [
113109 {
@@ -122,16 +118,16 @@ function getSoftNewlineChunk(block, depth, flat = false, data = Map()) {
122118
123119 return {
124120 text : '\n' ,
125- inlines : [ OrderedSet ( ) ] ,
121+ inlines : [ Immutable . OrderedSet ( ) ] ,
126122 entities : new Array ( 1 ) ,
127123 blocks : [ ] ,
128124 }
129125}
130126
131- function getBlockDividerChunk ( block , depth , data = Map ( ) ) {
127+ function getBlockDividerChunk ( block , depth , data = Immutable . Map ( ) ) {
132128 return {
133129 text : '\r' ,
134- inlines : [ OrderedSet ( ) ] ,
130+ inlines : [ Immutable . OrderedSet ( ) ] ,
135131 entities : new Array ( 1 ) ,
136132 blocks : [
137133 {
@@ -175,7 +171,7 @@ function getBlockTypeForTag(tag, lastList) {
175171 }
176172}
177173
178- function baseCheckBlockType ( nodeName , node , lastList ) {
174+ function baseCheckBlockType ( nodeName , _node , lastList ) {
179175 return getBlockTypeForTag ( nodeName , lastList )
180176}
181177
@@ -209,7 +205,7 @@ function processInlineTag(tag, node, currentStyle) {
209205 return currentStyle
210206}
211207
212- function baseProcessInlineTag ( tag , node , inlineStyles = OrderedSet ( ) ) {
208+ function baseProcessInlineTag ( tag , node , inlineStyles = Immutable . OrderedSet ( ) ) {
213209 return processInlineTag ( tag , node , inlineStyles )
214210}
215211
@@ -376,10 +372,10 @@ function genFragment(
376372
377373 if ( typeof blockInfo === 'string' ) {
378374 blockType = blockInfo
379- blockDataMap = Map ( )
375+ blockDataMap = Immutable . Map ( )
380376 } else {
381377 blockType = typeof blockInfo === 'string' ? blockInfo : blockInfo . type
382- blockDataMap = blockInfo . data ? Map ( blockInfo . data ) : Map ( )
378+ blockDataMap = blockInfo . data ? Immutable . Map ( blockInfo . data ) : Immutable . Map ( )
383379 }
384380 if ( ! inBlock && ( fragmentBlockTags . indexOf ( nodeName ) !== - 1 || blockType ) ) {
385381 chunk = getBlockDividerChunk (
@@ -472,10 +468,10 @@ function genFragment(
472468
473469 if ( typeof newBlockInfo === 'string' ) {
474470 newBlockType = newBlockInfo
475- newBlockData = Map ( )
471+ newBlockData = Immutable . Map ( )
476472 } else {
477473 newBlockType = newBlockInfo . type || getBlockTypeForTag ( nodeName , lastList )
478- newBlockData = newBlockInfo . data ? Map ( newBlockInfo . data ) : Map ( )
474+ newBlockData = newBlockInfo . data ? Immutable . Map ( newBlockInfo . data ) : Immutable . Map ( )
479475 }
480476
481477 chunk = joinChunks (
@@ -492,7 +488,11 @@ function genFragment(
492488 }
493489
494490 if ( newBlock ) {
495- chunk = joinChunks ( chunk , getBlockDividerChunk ( nextBlockType , depth , Map ( ) ) , options . flat )
491+ chunk = joinChunks (
492+ chunk ,
493+ getBlockDividerChunk ( nextBlockType , depth , Immutable . Map ( ) ) ,
494+ options . flat
495+ )
496496 }
497497
498498 return chunk
@@ -527,7 +527,7 @@ function getChunkForHTML(
527527 // UL block to sta rt with.
528528 let chunk = genFragment (
529529 safeBody ,
530- OrderedSet ( ) ,
530+ Immutable . OrderedSet ( ) ,
531531 'ul' ,
532532 null ,
533533 workingBlocks ,
@@ -563,14 +563,14 @@ function getChunkForHTML(
563563
564564 // If we saw no block tags, put an unstyled one in
565565 if ( chunk . blocks . length === 0 ) {
566- chunk . blocks . push ( { type : 'unstyled' , data : Map ( ) , depth : 0 } )
566+ chunk . blocks . push ( { type : 'unstyled' , data : Immutable . Map ( ) , depth : 0 } )
567567 }
568568
569569 // Sometimes we start with text that isn't in a block, which is then
570570 // followed by blocks. Need to fix up the blocks to add in
571571 // an unstyled block for this content
572572 if ( chunk . text . split ( '\r' ) . length === chunk . blocks . length + 1 ) {
573- chunk . blocks . unshift ( { type : 'unstyled' , data : Map ( ) , depth : 0 } )
573+ chunk . blocks . unshift ( { type : 'unstyled' , data : Immutable . Map ( ) , depth : 0 } )
574574 }
575575
576576 return chunk
@@ -619,7 +619,7 @@ function convertFromHTMLtoContentBlocks(
619619 const end = start + textBlock . length
620620 const inlines = nullthrows ( chunk ) . inlines . slice ( start , end )
621621 const entities = nullthrows ( chunk ) . entities . slice ( start , end )
622- const characterList = List (
622+ const characterList = Immutable . List (
623623 inlines . map ( ( style , entityIndex ) => {
624624 const data = { style, entity : null }
625625 if ( entities [ entityIndex ] ) {
0 commit comments