Make data-empty Attribute Optional in toggleEmptyMark to Prevent Unintended DOM Manipulation
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- javascript, typescript
- Área
- frontend
Línea de trabajo
Lee toggleEmptyMark en src/components/dom.ts y toggleInputsEmptyMark en src/components/block/index.ts, especialmente cómo enableLineBreaks y data-mutation-free afectan a los elementos descendientes. Determina el comportamiento apropiado de inclusión o exclusión y verifica que data-empty no se añada cuando el comportamiento está deshabilitado, sin romper el manejo normal de las entradas vacías.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- TypeScript
- Estrellas
- 32k
- Forks
- 2.2k
- Merge medio
- 2 d 1 h
- PR fusionados (30 d)
- 1
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de codex-team/editor.js
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
codex-team/editor.js#3037 ·
-
Floating Promise Anti-Pattern & Premature Caret in Multi-Block PastePosiblemente ocupada @anshurajbisoyi98-ctrl la tomó hace 13 días. Abiertobug good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
codex-team/editor.js#3032 · 1 comentario ·
-
Silent Data Loss & Broken Error Contract in Saver.save()Posiblemente ocupada @Sion612 la tomó hace 22 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
codex-team/editor.js#3030 ·
-
Complete Omission of block.destroy() in Blocks CollectionPosiblemente ocupada @Minhal128 la tomó hace 21 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
codex-team/editor.js#3029 ·
-
Bug: Link cannot be removedPosiblemente ocupada @prathmeshyelne la tomó hace 128 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
codex-team/editor.js#3005 · 1 comentario ·
Todos los issues de codex-team/editor.js
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
aws/agentcore-cli#2606 ·
Los mantenedores suelen responder en 1 día
-
ai-driven-qa bug Cosmetic
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
ai-driven-qa bug claude Minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
linagora/twake-mail-admin#301 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
reproduced
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
anomalyco/opencode#56038 · 1 comentario ·
Los mantenedores suelen responder en 1 día