( node, inlineStyle, lastList, inBlock, fragmentBlockTags, depth, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, inEntity )
| 278 | } |
| 279 | |
| 280 | function genFragment( |
| 281 | node, |
| 282 | inlineStyle, |
| 283 | lastList, |
| 284 | inBlock, |
| 285 | fragmentBlockTags, |
| 286 | depth, |
| 287 | processCustomInlineStyles, |
| 288 | checkEntityNode, |
| 289 | checkEntityText, |
| 290 | checkBlockType, |
| 291 | createEntity, |
| 292 | getEntity, |
| 293 | mergeEntityData, |
| 294 | replaceEntityData, |
| 295 | options, |
| 296 | inEntity |
| 297 | ) { |
| 298 | let nodeName = node.nodeName.toLowerCase(); |
| 299 | let newBlock = false; |
| 300 | let nextBlockType = 'unstyled'; |
| 301 | |
| 302 | // Base Case |
| 303 | if (nodeName === '#text') { |
| 304 | let text = node.textContent; |
| 305 | if (text.trim() === '' && inBlock === null) { |
| 306 | return getEmptyChunk(); |
| 307 | } |
| 308 | |
| 309 | if (text.trim() === '' && inBlock !== 'code-block') { |
| 310 | return getWhitespaceChunk(inEntity); |
| 311 | } |
| 312 | if (inBlock !== 'code-block') { |
| 313 | // Can't use empty string because MSWord |
| 314 | text = text.replace(REGEX_LF, SPACE); |
| 315 | } |
| 316 | |
| 317 | const entities = Array(text.length).fill(inEntity); |
| 318 | |
| 319 | let offsetChange = 0; |
| 320 | const textEntities = checkEntityText( |
| 321 | text, |
| 322 | createEntity, |
| 323 | getEntity, |
| 324 | mergeEntityData, |
| 325 | replaceEntityData |
| 326 | ).sort(rangeSort); |
| 327 | |
| 328 | textEntities.forEach(({ entity, offset, length, result }) => { |
| 329 | const adjustedOffset = offset + offsetChange; |
| 330 | |
| 331 | if (result === null || result === undefined) { |
| 332 | result = text.substr(adjustedOffset, length); |
| 333 | } |
| 334 | |
| 335 | const textArray = text.split(''); |
| 336 | textArray.splice |
| 337 | .bind(textArray, adjustedOffset, length) |
no test coverage detected
searching dependent graphs…