Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Make data-empty Attribute Optional in toggleEmptyMark to Prevent Unintended DOM Manipulation

Abierto
#2,820 1 comentario 1 reacción 0 asignados Ver en GitHub

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

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de codex-team/editor.js

Todos los issues de codex-team/editor.js

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.