Skip to content
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

Feature: user configurable list of allowed html tags in import #601

Merged
merged 10 commits into from
Nov 28, 2024

Conversation

maphew
Copy link

@maphew maphew commented Nov 18, 2024

An implementation of #567 whitelist html tags to keep on import.

Created a new configurable option for HTML import tags that:

  • Lives in the "Other" section of options
  • Help text reads text strings from translations (only EN implemented)
  • Uses a monospace textarea for easy tag editing
  • Can be space, comma, or newline delimited
  • Has a reset to defaults option

Made the necessary backend changes:

  • Added new allowedHtmlTags to default options in options_init.ts
  • Added to ALLOWED_OPTIONS in options.ts
  • sync across devices with isSynced: true

I tested interactively by running Trilium in a devcontainer using the project docker-compose.yml (no changes outside of the code in this PR).

The feature is believed complete and working, with much help from Windsurf Cascade and Claude Sonnet 3.5. This is the first not-a-toy thing I've done in javascript/typescript, so take that into account during review.


Caveat

The whitelisted tags survive import but only last until the note is Edited, at which time the non-standard ones will be changed to <p>. So it's present value is in that the import more faithfully represents the source than before. Keeping them after edit too will mean (i assume) changing CKEditor behaviour. I might try look at that, but I expect it's a harder project than this one. so it might be awhile, if ever. (I really miss not having cite tags though, so who knows.)

Example:

A onenote cite tag after import (with the change in this PR enabled) looks like:

<cite style="margin:0in;font-family:Calibri;font-size:9.0pt;color:#595959">

After being edited the cite changes to:

<p style="margin-left:0in;">

TriliumNext#567

this is the easy method, just add the tags to core, not attempting to
read the list from a user configurable location.
The addition is clearly marked in code.
Bugs remaining:
- extra whitespace under heading
- existing list is filled with `\n` instead of delimiters
- [reset to default] triggers
  "500 PUT options. Option 'allowedHtmlTags' is not allowed to be changed"
Bugs remaining:
- [reset to default] and page exit (e.g. save) triggers:
  "500 PUT options. Option 'allowedHtmlTags' is not allowed to be changed"
  "500 PUT options. Option 'allowedHtmlTags' is not allowed to be changed"

Note: the "allowed to change" list is set on startup. When a new option
is added Trilium must be restarted.
@eliandoran eliandoran merged commit b3b8e60 into TriliumNext:develop Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants