xwikisas / application-task

Task Manager Application
GNU Lesser General Public License v2.1
0 stars 6 forks source link

Updating the task status removes XWiki syntax in the content #81

Open michitux opened 11 months ago

michitux commented 11 months ago

Steps to reproduce:

  1. Add a new task using the task macro, e.g., by typing /task and pressing enter.
  2. As content, write Check [[this website>>https://www.xwiki.com]]. image
  3. Save the document. Confirm that the link is present and works: image
  4. Check the task, marking it as done.
  5. Reload the page.

Expected result:

Nothing changes during reload, the link is still present.

Actual result:

The link is gone. image

image

michitux commented 11 months ago

This seems to happen because of the following sequence of events:

  1. When the task object is created, the name is set to the content of the task macro rendered as plain text: https://github.com/xwikisas/application-task/blob/f07c3113aec5f2f77462b9911b802d4419dbe3ab/application-task-default/src/main/java/com/xwiki/task/internal/TaskXDOMProcessor.java#L185
  2. When the checkbox is clicked, the task object is updated and from this the content of the task is updated: https://github.com/xwikisas/application-task/blob/f07c3113aec5f2f77462b9911b802d4419dbe3ab/application-task-default/src/main/java/com/xwiki/task/internal/TaskXDOMProcessor.java#L213-L217
  3. To generate the content blocks, the task name is parsed as plain text: https://github.com/xwikisas/application-task/blob/999c2709d656c3440a8f99145b4d444f940da47b/application-task-default/src/main/java/com/xwiki/task/internal/TaskBlockProcessor.java#L116-L117

The easiest fix could be to not update the content if nothing that affects the content has been changed, but this is of course not a complete fix. Alternatively, it could be decided that XWiki syntax isn't supported in the content of the task macro, but that contradicts the fact that you can use the mention and date macro there and supporting macros but not other wiki syntax seems difficult as it would need a custom parser and also editing might be non-trivial.

michitux commented 7 months ago

As an idea for a fix, I wondered if it wouldn't be possible to synchronize the content of the task macro with the description of the task instead of the task's name. The task's name could be left empty and computed from the task's description instead, but this might create issues with filtering based on the task's name. Alternatively, an update listener could update the task's name based on changes in the description if the task's name corresponds to the old description.