@@ -370,100 +370,19 @@ const methods = state => ({
370370 const range = selection . getRangeAt ( 0 )
371371 rerenderNeeded = (
372372 ( range . startContainer . nodeType === Node . TEXT_NODE && range . startOffset <= 1 ) ||
373- // TODO: Add data-codex-rerender?
374373 ascendToElement ( range . startContainer ) . getAttribute ( "data-codex-markdown" ) ||
375- ascendToElement ( range . startContainer ) . getAttribute ( "aria-label" )
374+ ( range . startContainer . nodeType === Node . TEXT_NODE && emojiTrie . atEnd ( range . startContainer . nodeValue ) )
376375 )
377376 const root = ascendToElement ( range . startContainer ) . closest ( "[data-codex-editor] > *" )
378377 id = root . id || root . querySelector ( "[id]" ) . id
379378 }
380-
381- // if (rerenderNeeded) {
379+ if ( rerenderNeeded ) {
382380 const nextElement = nextElements . find ( each => each . id === id )
383381 if ( nextElement ) {
384382 nextElement . reactKey = uuidv4 ( ) . slice ( 0 , 8 )
385383 }
386- // }
387-
388- // const elements = parseInlineElements(state.nodes[state.pos1.y].data)
389- // console.log(elements)
384+ }
390385
391- // // Compares whether two children are equal. Character
392- // // data is not compared in order to preserve
393- // // spellcheck highlighting.
394- // const isString = value => {
395- // return typeof value === "string"
396- // }
397- // const isObject = value => {
398- // const ok = (
399- // typeof value === "object" &&
400- // !Array.isArray(value)
401- // )
402- // return ok
403- // }
404- // const isArray = value => {
405- // const ok = (
406- // typeof value === "object" &&
407- // Array.isArray(value)
408- // )
409- // return ok
410- // }
411- // const areEqualChildren = (childrenA, childrenB) => {
412- // if (childrenA === null || childrenB === null) {
413- // return childrenA === childrenB
414- // }
415- // if (isString(childrenA) && isString(childrenB)) {
416- // return true
417- // } else if (isObject(childrenA) && isObject(childrenB)) {
418- // const ok = (
419- // childrenA.type === childrenB.type &&
420- // JSON.stringify(childrenA.syntax) === JSON.stringify(childrenB.syntax) &&
421- // areEqualChildren(childrenA.children, childrenB.children)
422- // )
423- // return ok
424- // }
425- // if (!isArray(childrenA) || !isArray(childrenB) || childrenA.length !== childrenB.length) {
426- // return false
427- // }
428- // for (let x = 0; x < childrenA.length; x++) {
429- // if (!areEqualChildren(childrenA[x], childrenB[x])) {
430- // return false
431- // }
432- // }
433- // return true
434- // }
435- // // Compares whether two elements are equal. Elements
436- // // are considered to be equal if their types, ID, and
437- // // children are equal.
438- // const areEqualElements = (elementA, elementB) => {
439- // const ok = (
440- // elementA.type === elementB.type &&
441- // elementA.id === elementB.id &&
442- // JSON.stringify(elementA.syntax) === JSON.stringify(elementB.syntax) &&
443- // areEqualChildren(elementA.children, elementB.children)
444- // )
445- // return ok
446- // }
447- // let id = ""
448- // const selection = document.getSelection()
449- // if (selection.rangeCount) {
450- // const range = selection.getRangeAt(0)
451- // const root = ascendToElement(range.startContainer).closest("[data-codex-editor] > *")
452- // id = root.id || root.querySelector("[id]").id
453- // }
454- // const substr = state.nodes[state.pos1.y].data.slice(state.pos1.x - 2, state.pos1.x + 1)
455- // const mustRerender = false // substr
456- // // .split("")
457- // // .some(each => ascii.isPunctuation(each))
458- // const prevElement = state.elements.find(each => each.id === id)
459- // const nextElement = nextElements.find(each => each.id === id)
460- // if (prevElement && nextElement) {
461- // if (areEqualElements(prevElement, nextElement)) {
462- // // No-op
463- // return
464- // }
465- // nextElement.reactKey = uuidv4().slice(0, 8)
466- // }
467386 }
468387
469388 Object . assign ( state , {
0 commit comments