Skip to content

Mockup: in-editor field protection toggle#1281

Draft
RisingOrange wants to merge 2 commits into
mainfrom
in-editor-field-protection-mockup
Draft

Mockup: in-editor field protection toggle#1281
RisingOrange wants to merge 2 commits into
mainfrom
in-editor-field-protection-mockup

Conversation

@RisingOrange

Copy link
Copy Markdown
Collaborator

Design mockup for moving the "protect fields" UI out of its separate browser-context-menu dialog and into the note editor itself, so users can see each field's protection state at a glance and toggle it in place.

This is intentionally unpolished — it's being put up as a draft so the team can pull the branch, open a note in the editor, take screenshots of variants, and decide on the final direction before we invest in productionizing it.

Related issues

  • Closes #

Proposed changes

  • New module ankihub/gui/field_protection.py injecting a small padlock button into each field header in the note editor.
  • Unprotected fields show a faint outline padlock; protected fields show a filled amber padlock and get a 3px amber inset left border on the field body for at-a-glance visibility.
  • Clicking a padlock toggles the AnkiHub_Protect::<FieldName> tag on the note, persists via col.update_note, and reloads the editor so the UI reflects the new state.
  • AnkiHub_Protect::All is handled: toggling one field off expands it into per-field tags minus the unprotected one; toggling the last missing field back on collapses to ::All.
  • Gated on ankihub_db.is_ankihub_note_type(...) and skips the internal ankihub_id field.
  • Existing browser-context-menu "Protect fields" dialog is untouched — still the right UI for bulk operations across multi-selected notes.

Only per-note (tag-based) protection is surfaced. Per-notetype protection (ProtectedFieldsSet) is a deliberate follow-up, possibly as a second icon or a dropdown on the same control.

How to reproduce

  1. Check out this branch and install/reload the addon in Anki.
  2. Open any note that belongs to an AnkiHub-synced deck (browser → double-click a note, or Add Cards on an AnkiHub note type).
  3. Each field header now has a small padlock to the left of the <> HTML toggle area.
  4. Click a padlock to flip its state — the body picks up an amber left border and the tag is written/removed on the note.

Screenshots and videos

To be added once we pick a variant.

Further comments

Open design questions for team input:

  • Icon placement. Currently the padlock lands in the field's label/header container (near the field name). An alternative is putting it immediately left of the <> toggle to group per-field controls together. Trade-off: state indicator vs. action cluster. Easy to flip either way.
  • Color. Amber (#f59e0b) for "protected". Neutral choice — red reads as danger/error, green reads as "good", blue reads as "info/link". Happy to try alternatives.
  • Body tint. Field body gets a 3px inset amber left shadow when protected. Could also be a background tint, border, or removed entirely if we want the header icon to carry all the visual weight.
  • Anki-version robustness. Header DOM injection uses pickHeader() with fallbacks (.label-container, .field-state, [class*="label"], firstChild). Works on Anki 25.09.2. Older versions may place the icon unexpectedly — needs hardening before ship.

Adds a padlock icon to each field header in the note editor that
reflects the note's current AnkiHub_Protect tags and toggles them on
click. Intended for design review via screenshots before being
promoted to a finished feature.
Shield reads as "protection" naturally, works cleanly at 14px, and
leaves room for AnkiHub branding treatment later if we decide the
origin needs to be more visually explicit.
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.

1 participant