-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(Bug report) redundent new line on long check-box item #4402
Comments
I've checked the ckeditor5's online demo. That works fine. So I assume this is a trilium issue. https://ckeditor.com/docs/ckeditor5/latest/features/lists/todo-lists.html |
0.60.4 The source code of todo item is like this.
0.61.13 The current state of the todo item includes an unwanted cascaded
|
Wrote a widget that fixes the HTML when a note is opened. This loops over each todo item and removes the extra class FixTodoListWidget extends api.NoteContextAwareWidget {
get parentWidget() { return "left-pane"; }
doRender() {
this.$widget = $("");
this.editorIntervalId = null;
this.initializedEditorIds = [];
}
refreshWithNote() {
if (this.note.type === "text") {
this.initializeEditor();
}
}
initializeEditor() {
this.editorIntervalId = setInterval(async () => {
const editor = await api.getActiveContextTextEditor();
clearInterval(this.editorIntervalId);
if (this.initializedEditorIds.includes(editor.id)) {
return;
}
this.initializedEditorIds.push(editor.id);
editor.data.on('set', () => this.fixTodoLists(editor));
this.fixTodoLists(editor);
}, 100);
}
fixTodoLists(editor) {
let brokenElements = [];
this.findBrokenElements(editor.model.document.getRoot(), brokenElements);
if (!brokenElements.length) {
return;
}
editor.model.change((writer) => {
for (const element of brokenElements) {
this.fixElement(writer, element);
}
});
}
findBrokenElements(node, brokenElements) {
if (!node.is("element")) {
return;
}
const isTodoItem = node.getAttribute("listType") === "todo";
for (const child of node.getChildren()) {
if (isTodoItem && (child.hasAttribute("htmlLabel") || child.hasAttribute("htmlSpan"))) {
brokenElements.push(child);
}
this.findBrokenElements(child, brokenElements);
}
}
fixElement(writer, element) {
for (const key of ["htmlLabel", "htmlSpan"]) {
if (element.hasAttribute(key)) {
writer.removeAttribute(key, element);
}
}
}
}
module.exports = new FixTodoListWidget(); |
Hmm, Trilium itself does nothing with such HTML content and has no transformation like that. 0.61 contains CKEditor upgrade (from 36.4.0 to 40.0.0) which could be doing this. I have a suspicion this might be connected to the fact that CKEditor is currently undergoing some major lists refactoring. CKEditor in Trilium should still be using the old list/todo plugin, though ... |
Just for memo: set |
Closing this as it is fixed in the latest version. |
Trilium Version
0.61.13
What operating system are you using?
Windows
What is your setup?
Local + server sync
Operating System Version
Win 10
Description
If the todo item is longer than one line, the text is pushed to a new line.
Error logs
No response
The text was updated successfully, but these errors were encountered: