Make data-empty Attribute Optional in toggleEmptyMark to Prevent Unintended DOM Manipulation
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, typescript
- Ambito
- frontend
Direzione di ricerca
Leggi toggleEmptyMark in src/components/dom.ts e toggleInputsEmptyMark in src/components/block/index.ts, in particolare il modo in cui enableLineBreaks e data-mutation-free influiscono sugli elementi discendenti. Determina il comportamento appropriato di opt-in o esclusione, quindi verifica che data-empty non venga aggiunto quando il comportamento è disabilitato, senza compromettere la normale gestione degli input vuoti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The toggleEmptyMark() function (relevant code here: toggleEmptyMark Function) is causing significant issues. As it modifies the editor's DOM, it can trigger reactivity within Editor.js plugins developed using JavaScript frameworks like Svelte.
For example, when using a Svelte component with a contenteditable div bound to innerHTML (e.g., bind:innerHTML={html}), the DOM changes triggered by toggleEmptyMark can have disastrous effects, such as loss of the current selection and cursor position.
To avoid these issues, the automatic addition of the data-empty attribute to inputs should be made optional. This change would prevent unnecessary DOM manipulation and improve compatibility with reactive frameworks.
Editor version: 2.30.5
Clarification:
The root cause actually lies within the toggleInputsEmptyMark function (relevant code here: toggleInputsEmptyMark Function).
The problem becomes evident when enableLineBreaks is set to true to allow line breaks in a plugin via the "Enter" key. In this scenario, the data-empty attribute can incorrectly be added to <div> elements within contenteditable areas, which then triggers reactivity and potentially causes issues like losing the cursor position or disrupting the user experience.
Of course i tried setting the data-mutation-free attribute to true on the parent element, but the data-empty attribute is still added to its childs and so the issue remains.
I guess that ensuring the data-empty attribute is not added to all children of an element possessing the data-mutation-free="true" attribute would fix the issue...
As a sidenote:
Implementing placeholder logic through DOM manipulation in a WYSIWYG editor that allows custom plugins is a highly questionable decision, as it has the potential to break everything users have created. At the very least, this feature should have been made opt-in rather than mandatory.
- Lingua principale
- TypeScript
- Stelle
- 32k
- Fork
- 2.2k
- Merge medio
- 2g 1h
- PR unite (30g)
- 1
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di codex-team/editor.js
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
codex-team/editor.js#3037 ·
-
Floating Promise Anti-Pattern & Premature Caret in Multi-Block PasteForse già presa @anshurajbisoyi98-ctrl l’ha presa 16 giorni fa. Apertabug good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
codex-team/editor.js#3032 · 1 commento ·
-
Silent Data Loss & Broken Error Contract in Saver.save()Forse già presa @Sion612 l’ha presa 26 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
codex-team/editor.js#3030 ·
-
Complete Omission of block.destroy() in Blocks CollectionForse già presa @Minhal128 l’ha presa 25 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
codex-team/editor.js#3029 ·
-
Bug: Link cannot be removedForse già presa @prathmeshyelne l’ha presa 132 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
codex-team/editor.js#3005 · 1 commento ·
Tutte le issue di codex-team/editor.js
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
simkimsia/netlify-axi#19 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
subhranshudash13-dotcom/Contribo#74 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement frontend good first issue Stellar Wave trivial
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
Godgift-care/sci-healthcare-frontend#166 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
backend good first issue security Stellar Wave trivial
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
Godgift-care/sci-healthcare-backend#171 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno