Skip to content

feat: Notes Editor on a bundled Quill 2 instead of the remote TinyMCE - #1807

Merged
Azgaar merged 12 commits into
v1.152.0from
feat/notes-editor-quill
Sep 8, 2026
Merged

Azgaar merged 12 commits into
v1.152.0from
feat/notes-editor-quill

Conversation

@barrulus

@barrulus barrulus commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator

Closes #1803. Supersedes #1799.

What

The Notes Editor now uses Quill 2, bundled with the app, instead of TinyMCE fetched at runtime from azgaar.github.io. Notes stay plain HTML strings in the .map file; the editor is only a view over them. Version 1.151.3 (patch: the notes format is unchanged).

Why

TinyMCE was loaded with a dynamic import() of a remote URL. When that load fails (Desktop App CSP, offline), Vite reports a missing chunk and the app shows the "New version released" prompt while the editor degrades to a bare contenteditable (#1660). #1799 patched the loader; this replaces the editor as discussed.

Editor Loaded when the editor opens Licence
TinyMCE 7 (before) ~1.5 MB over ~15 requests GPL-2.0-or-later
Quill 2.0.3 (now) 209,500-byte notes-editor chunk (controller + Quill + deps) + 24,367 bytes CSS, bundled BSD-3-Clause (deps MIT/BSD-3/Apache-2.0)

Bundling TinyMCE through npm, the other option, would fold a GPL-2.0-or-later library into the MIT build. Quill's BSD-3 avoids that question.

Behaviour

  • Existing notes render as before until edited, with one exception: table cells now get a border in the hover box. On first edit Quill normalizes the markup: inline styles for alignment, size and font (so the hover box needs no editor CSS), <br> runs become paragraphs, and tables gain Quill's data-row cell attributes and a border style.
  • Notes with markup Quill cannot hold (the dungeon marker's <iframe>, a legacy <hr>) open in a raw HTML textarea automatically; a button below the editor switches any note to HTML mode and back.
  • Toolbar: undo/redo, bold/italic/underline/strike, colours, alignment, size, lists, link, image from a local file, blockquote, clear formatting. Table menu: insert 3×3, add/delete rows and columns. Fullscreen toggle.
  • Dropped from the old toolbar: font family picker, indent/outdent, media embed, horizontal rule, special characters, print, word count, auto-linking of typed URLs.

Notes for review

  • public/libs/tinymce (4.7 MB) is deleted. Every Desktop build already blocks the remote load through its CSP (that is Spurious "New version released" dialog when adding a note in the Electron desktop client #1660), so the desktop is unaffected. Self-hosted copies and forks pinned between 1.123.2 and 1.151.2 load TinyMCE from the deployed copy of that folder at runtime; once this deploys they fall back to the plain editor until they update.
  • Desktop CSP unchanged: the editor is a normal 'self' chunk now.
  • Not run: the Electron app itself. Unit tests (jsdom) cover the HTML round trip and the raw-mode check; the Playwright spec runs against the preview build.
  • The representable check parses into a <template> element rather than a text/html document so a leading <script> or <style> cannot slip past it.
  • src/test-setup.ts gained a guarded jsdom Range.getBoundingClientRect/getClientRects shim because Quill's focus path calls them and jsdom never implements them.

@netlify

netlify Bot commented Sep 5, 2026

Copy link
Copy Markdown

Deploy Preview for afmg ready!

Name Link
🔨 Latest commit 5f095e7
🔍 Latest deploy log https://app.netlify.com/projects/afmg/deploys/6a9c9056bad9e10008a4f1fd
😎 Deploy Preview https://deploy-preview-1807--afmg.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@barrulus
barrulus force-pushed the feat/notes-editor-quill branch from 5f095e7 to 56bf0b2 Compare September 5, 2026 20:35
@Avengium

Avengium commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

The first message says:
Dropped from the old toolbar: font family picker, indent/outdent, media embed, horizontal rule, special characters, print, word count, auto-linking of typed URLs.

Do you know if some people use this?
For example: font family picker and special characters could be useful for places with other alphabets. For example Cyrillic.

I don't know if people with other alphabets are affected.

And, on another topic, sone of the dropped features are interesting.

@barrulus

barrulus commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator Author

Good question, and worth checking rather than assuming, so I did.

The font family and size pickers were not actually reaching anyone. The toolbar config asks for fontselect and fontsizeselect, which are TinyMCE 5 names; TinyMCE 6 renamed them to fontfamily and fontsize. Of the 27 button names in that config, those two are the only ones absent from the bundled TinyMCE build, and the theme's response to an unknown name is console.warn("Ignoring the '<name>' toolbar button"). So they have silently done nothing since the library was upgraded. This PR does add a working size picker, so size control is better than before, not worse.

On other alphabets: typing Cyrillic depends on your keyboard layout, not the editor toolbar, and the note box sets no font family, so notes render in the page font either way. The special characters grid would not have helped there in any case: it holds 288 characters, of which 51 are Greek and none are Cyrillic. It is currency signs, accented Latin, maths, arrows and punctuation.

What is genuinely dropped: the symbol grid, horizontal rule, media embed, print, word count, indent/outdent, and auto-linking of typed URLs. Auto-linking is the one I would expect to be missed most. Anything with markup Quill cannot represent can still be edited through the HTML mode button, and if any of these are wanted back they are small additions on top of Quill: a font picker mainly needs someone to decide the font list, since the underlying format already round-trips any value.

@Azgaar
Azgaar self-requested a review September 5, 2026 22:03
@Azgaar
Azgaar changed the base branch from master to v1.152.0 September 8, 2026 09:30
@Azgaar

Azgaar commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Will update an merge to branch

@Azgaar
Azgaar merged commit e63f61d into v1.152.0 Sep 8, 2026
1 check passed
@Azgaar
Azgaar deleted the feat/notes-editor-quill branch September 8, 2026 14:16
@github-project-automation github-project-automation Bot moved this from Backlog to Done in FMG dev board Sep 8, 2026
@github-actions github-actions Bot added the theme: ui-editors UI / UX & Editors label Sep 8, 2026
Azgaar added a commit that referenced this pull request Sep 9, 2026
* heightmap countour lines (#1813)

* Options full migration (#1666)

* init - migrate main.js

* continue - options.ts

* continue - settings

* migrateSettingsFormat

* refactor: clean up comments and reorganize LOCKS_KEY declaration

* migrateSettingsFormat

* refactor: remove unused properties and update migration functions for legacy settings

* Refactor options usage to capitalize 'Options' throughout the codebase

- Updated references from 'options' to 'Options' in various files including export-json.ts, load.ts, save.ts, stats.ts, url-params.ts, debugUtils.ts, fileUtils.ts, unitUtils.ts, and preferences.ts.
- Introduced new storage migration logic to handle legacy settings and ensure compatibility with the current options structure.
- Added tests for storage migration and deep merging of options to validate the changes.
- Implemented a deepMerge utility function to facilitate merging of nested objects while preserving existing values.

* Refactor global Options to options and update related references

- Changed all instances of globalThis.Options to globalThis.options across multiple files for consistency.
- Updated tests and utility functions to reflect the new options naming convention.
- Ensured that all settings and configurations are correctly accessed through the new options object.
- Introduced options-model and options-store components to better manage application state and options.
- Adjusted local storage keys for options and locks to maintain compatibility with the new structure.

* graph globald remove

* viewport globals gone

* viewport

* mapId and mapHistory global gone

* ocean style fix

* fixes

* fixes

* init shell

* fixes

* architectural rework - non-final

* fixes

* fixes

* legacy options migration

* fixes

* fixes

* meh changes

* still bad

* unufied model

* update

* fixes

* format

* fixes

* fixes

* fixes

* fix

* fixes

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>

* burg-treasury-edit (#1814)

* fixes

* preserve dialog positions

* feat: Notes Editor on a bundled Quill 2 instead of the remote TinyMCE (#1807)

* chore: add quill 2 as a dependency

* feat: rich text helpers for the notes editor on quill

* feat: notes editor on quill instead of the remote tinymce

* chore: drop the bundled tinymce

* fix: guard a leading script or style tag in the rich text check

* test: notes editor e2e on the bundled quill editor

* fix: keep ordinary spaces in saved notes and treat table headers as raw markup

* chore: bump to 1.151.3, changelog entry

* chore: re-pin the npm deps hash for the quill dependency

* fix: let the assistant's answers be selected and copied

* quill tools rework

---------

Co-authored-by: Azgaar <azgaar.fmg@yandex.com>

* Entity notes (#1817)

* docs: PRD for notes on entities

Replace the global notes side table with an optional note field on the
entity, widen note support to 17 entity types, and migrate existing maps
in one version step.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* feat: move notes onto the entities they describe

Replace the global `notes` side table with an optional `note` field on
the entity, and give markers the `name` the note used to carry.

- new components/entity-notes.ts: element id <-> entity resolution, note
  get/set/clear, the aggregate walk the editor and the font scan need
- notes editor lists notes grouped by entity type, exchanges csv
  addressed by entity, and drops the separate note title
- delete the ten lifecycle blocks that kept the array in sync: burg
  renumbering, regiment id rewrite on state merge, marker removal,
  added-label removal, the duplicate-marker-id patch, resample splicing
- auto-update distributes an old map's notes onto entities, collides
  river/route duplicates, folds a divergent note title into the text as
  a heading, and hands back what no entity claims as a csv
- .map field 4 is written empty from this version on

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* feat: notes for every note-bearing entity, and feature note restoration

- note buttons in the states, provinces, cultures, religions, biomes,
  zones, goods and markets tables, and in the journey and market dialogs
- every note button is dimmed until its entity has a note
- Features.captureUserData/restoreUserData match a feature's name and
  note back by grid cell after the graph is rebuilt, so a heightmap edit
  that keeps a lake keeps what the user wrote about it; resample carries
  the note along with the name it already carried
- tests for the resolver, the migration and the feature restore
- data model, glossary and wiki describe notes as an entity field

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* refactor: Notes store, shared button markup, contained legacy migration

- entity-notes exports a NotesStore singleton (Notes.get/set/list/...)
  following the Pins and Layers convention, replacing loose functions
- drop the inactive state on note buttons: having no note is normal
- every note button comes from Notes.getButton(id, subject) or
  Notes.getIcon(subject), so the markup and tip are written once
- the v1.152.0 note migration lives entirely inside its isOlderThan
  block: no module state, and the older blocks that renumber markers and
  added labels record a rename map instead of editing notes; the
  unattached notes come back as the migration's return value

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* refactor: move the Notes store to generators, offer orphans from auto-update

Notes sit next to the data they annotate, and the store has controlling
methods, so components/entity-notes becomes generators/notes.

The unattached-note csv is offered from inside the v1.152.0 block, only
when the migration actually found some, so the loader no longer carries
a result through just to open a dialog.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* refactor: remove outdated notes mapping and auto-update details from data model documentation

* feat: enhance notes functionality and editor interactions for entities

* fix actions column

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>

* docs update

* icons: viewport renderer

* markers - viewport renderer

* markets - viewport rendering

* routes, rivers, goods - viewport rendering

* fixes

* biome upgrade

* fixes

* fixes

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: barrulus <b@rry.im>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

theme: ui-editors UI / UX & Editors

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

TinyMCE replacement

3 participants