Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6474a6c
docs(plans): add margin marker decorations plan
ddfreiling Nov 18, 2026
19baf6e
fix(android): accept decorations without a tint
ddfreiling Nov 19, 2026
cf64e00
feat(platform_interface): add marginMarker decoration style
ddfreiling Nov 19, 2026
3fc63d2
feat(ios): render marginMarker decorations
ddfreiling Nov 19, 2026
b6d6ff4
feat(android): render marginMarker decorations
ddfreiling Nov 19, 2026
44ec57c
feat(web): render marginMarker decorations
ddfreiling Nov 19, 2026
71d5873
feat(example): add page-number and bookmark margin marker recipes
ddfreiling Nov 19, 2026
fb24e1b
docs: add margin markers guide
ddfreiling Nov 19, 2026
c6121ee
docs(flutter_readium): note that marginMarker needs a marker
ddfreiling Nov 19, 2026
e6e046b
fix(platform_interface): parse CSS tint in ReaderDecorationStyle.from…
ddfreiling Nov 19, 2026
8ec34e4
refactor: apply review feedback on margin markers
ddfreiling Nov 19, 2026
5b42b06
feat: add note and star margin marker icons
ddfreiling Nov 19, 2026
1cd4ff6
docs(ios): add changelog entry for skipping invalid decorations
ddfreiling Nov 19, 2026
38909b0
docs(plans): park a plan for app-supplied margin marker icons
ddfreiling Nov 19, 2026
24677c7
feat: draw margin markers without a box
ddfreiling Nov 19, 2026
4ce2cb5
feat: keep margin markers off the screen edge
ddfreiling Nov 19, 2026
72e136b
feat: anchor margin markers to the text column
ddfreiling Nov 23, 2026
1e533a1
feat: anchor margin markers to the text by default
ddfreiling Nov 23, 2026
f5dc0ee
fix(ios): relayout decorations after the viewport resizes
ddfreiling Nov 23, 2026
dca01a4
feat: add makeSpaceForMarginDecoration EPUB preference
ddfreiling Nov 23, 2026
571809b
docs(changelog): fold margin anchor into the margin marker entry
ddfreiling Nov 24, 2026
67fc0df
Merge remote-tracking branch 'origin/main' into docs/margin-marker-de…
ddfreiling Dec 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion docs/api-reference/decorations.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,28 @@ ReaderDecoration(

| Field | Type | Description |
|-------|------|-------------|
| `style` | `DecorationStyle` | `highlight` or `underline` |
| `style` | `DecorationStyle` | `highlight`, `underline` or `marginMarker` |
| `tint` | `Color` | Colour of the decoration |
| `marker` | `MarginMarker?` | Label or icon to show. Required for `marginMarker` |

## DecorationStyle

| Value | Appearance |
|-------|-----------|
| `DecorationStyle.highlight` | Background colour fill over the text range |
| `DecorationStyle.underline` | Underline beneath the text range |
| `DecorationStyle.marginMarker` | Label or icon in the page margin, level with the first line of the range. See [Margin Markers](../guides/margin-markers.md) |

## MarginMarker

| Constructor | Description |
|-------------|-------------|
| `MarginMarker.label(String, {side, anchor})` | Text label, such as a page number |
| `MarginMarker.icon(MarginMarkerIcon, {side, anchor})` | Built-in icon: `MarginMarkerIcon.bookmark`, `.note` or `.star` |

`side` is `MarginSide.start` (default) or `MarginSide.end`, and flips in right-to-left text. Labels are HTML-escaped. Icons are a closed set: the plugin never renders app-supplied markup.

`anchor` is `MarginAnchor.text` (default), which keeps the marker a small gap from the text column however wide the margin is, or `MarginAnchor.page`, which puts it near the page or column edge. See [Margin Markers](../guides/margin-markers.md#anchoring).

## Applying decorations

Expand Down
1 change: 1 addition & 0 deletions docs/api-reference/preferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Controls the visual appearance of the EPUB reader. All fields are optional unles
| `verticalText` | `bool?` | Lay out text vertically (CJK). Auto-derived from `language` if not set. |
| `readingProgression` | `EpubReadingProgression?` | `ltr` or `rtl`. |
| `firstElementTopMargin` | `int?` | Top margin applied to the first element, in pixels — useful to clear a toolbar. Custom plugin setting |
| `makeSpaceForMarginDecoration` | `bool` | Widen the side page margins with the font size so [margin markers](../guides/margin-markers.md#margin-width) never overlap the text. Never narrower than `pageMargins`. Reflowable EPUB only. Defaults to `false`. Custom plugin setting |

### Theme & color

Expand Down
4 changes: 4 additions & 0 deletions docs/guides/highlights-annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ await reader.applyDecorations('highlights', []);

Colours use Flutter `Color` values. The JSON representation uses `rgba(r, g, b, a)` notation.

## Margin markers

To flag a highlight with an icon in the page margin, or to show page numbers, use the `marginMarker` style. See [Margin Markers](margin-markers.md).

## Typical group layout

```dart
Expand Down
125 changes: 125 additions & 0 deletions docs/guides/margin-markers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Margin Markers

A margin marker is a small label or icon in the page margin, level with the first line of a text location. Use it for printed page numbers, bookmarks, or any note-style flag that should not cover the text.

Markers are decorations with the `DecorationStyle.marginMarker` style, so they follow the same group rules as [highlights](highlights-annotations.md): re-applying a group replaces it, and an empty list clears it. They are supported for EPUB on iOS, Android and web. PDF navigators do not support decorations.

## The marker

`ReaderDecorationStyle.marker` is required for `marginMarker` and ignored for other styles. A marker is either a text label or a built-in icon:

```dart
const MarginMarker.label('12', side: MarginSide.end, anchor: MarginAnchor.page)
const MarginMarker.icon(MarginMarkerIcon.bookmark) // side defaults to MarginSide.start, anchor to MarginAnchor.text
```

The fields are described in the [API reference](../api-reference/decorations.md#marginmarker).

`tint` colours the marker's label or icon. Without a tint the marker uses the publication's text colour, so it follows the reader theme. Labels are drawn slightly muted. `isActive` is ignored.

## Anchoring

`anchor` decides where the marker sits inside the margin:

- `MarginAnchor.page` puts the marker near the page edge, or the column edge in two-column layouts. On a wide screen this can be far from the text, which suits printed page numbers.
- `MarginAnchor.text` (default) keeps the marker a small gap (half the body font size) from the text column, however wide the margin is. Use it for markers that belong to a passage, such as bookmarks.

A text-anchored marker follows font size, page margins, scroll mode and publisher CSS. When the margin is narrower than the marker, it overflows toward the text rather than off the page; [`makeSpaceForMarginDecoration`](#margin-width) prevents that. It lines up with the body's text column, so paragraphs that the publisher indents further keep their extra indent.

A `marginMarker` decoration without a label or icon is skipped and logged. In debug builds, `applyDecorations` asserts that the marker is present.

## Recipe: page numbers

Print-equivalent EPUBs carry a `pageList` navigation document. Map each entry to a locator and apply one marker per entry:

```dart
Future<void> showPageNumbers(Publication publication) {
final decorations = <ReaderDecoration>[];
for (final (index, link) in publication.pageList.indexed) {
final title = link.title;
final locator = publication.locatorFromLink(link);
if (title == null || locator == null) continue;
decorations.add(
ReaderDecoration(
id: 'page_$index',
locator: locator,
style: ReaderDecorationStyle(
style: DecorationStyle.marginMarker,
marker: MarginMarker.label(title, side: MarginSide.end, anchor: MarginAnchor.page),
),
),
);
}
return FlutterReadium().applyDecorations('page-list', decorations);
}

Future<void> hidePageNumbers() => FlutterReadium().applyDecorations('page-list', []);
```

Use `pageList`, not `pageListOrGenerated`: generated entries are PDF links. The example app has this behind a toggle in the player app bar.

## Recipe: bookmarked highlights

Apply a second group with one icon marker per highlight, on the same locator as the highlight:

```dart
await reader.applyDecorations('highlights', [
for (final h in highlights)
ReaderDecoration(
id: h.id,
locator: h.locator,
style: ReaderDecorationStyle(style: DecorationStyle.highlight, tint: h.color),
),
]);

await reader.applyDecorations('highlight-markers', [
for (final h in highlights)
ReaderDecoration(
id: '${h.id}_marker',
locator: h.locator,
style: const ReaderDecorationStyle(
style: DecorationStyle.marginMarker,
tint: Color(0xFF2E7D32),
marker: MarginMarker.icon(MarginMarkerIcon.bookmark),
),
),
]);
```

Re-apply both groups together whenever the highlights change, so markers never outlive their highlight.

## Taps

A marker only reacts to taps on the marker itself, not on the row of text beside it, so taps on the highlighted text still reach the highlight. A tap on the marker reports a normal `onDecorationInteraction` event with the marker's group. Ignore groups you do not handle:

```dart
onDecorationInteraction: (event) {
if (event.group != 'highlights') return;
// open the highlight sheet
},
```

Pair a marker with a text decoration if tapping the location should do something. Markers are additive; the plugin has no option to suppress marker taps.

## Margin width

Markers are sized with the font, but Readium's page margin is a fixed number of pixels (scaled by `pageMargins`). At large font sizes, or with small `pageMargins`, a marker can therefore overlap the text. You cannot fix this with `pageMargins` alone, because the publication's base font size is not exposed.

Set `makeSpaceForMarginDecoration` to let the plugin size the margin instead:

```dart
await reader.setEPUBPreferences(prefs.copyWith(makeSpaceForMarginDecoration: true));
```

The side margins then grow with the font size, enough for an icon or a page number of up to three digits with either [anchor](#anchoring). Longer labels can still reach the text. They are never narrower than `pageMargins` would make them. Turning it on shortens the lines, so the text re-paginates like any other layout change. It also applies in scroll mode, and it is ignored for fixed-layout publications.

The margin is reserved on both sides, whether or not any marker is showing. Leave it off if you do not show margin markers.

## Layout notes

- **Two columns.** The `end` margin of the left column and the `start` margin of the right column are the same gap, so markers on both sides can overlap there.
- **Vertical writing modes** are not supported.
- **Fixed layout on iOS.** Decorations are duplicated on both pages of a two-page spread until swift-toolkit 4.0.
- **Volume.** A long book can have hundreds of page-list entries. Apply them in one `applyDecorations` call rather than one call per entry.

See also the [decorations API reference](../api-reference/decorations.md).
2 changes: 2 additions & 0 deletions docs/plans/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ This directory holds implementation plans, parity audits, and retained reference
- **[todo/web-ts-refactor.md](todo/web-ts-refactor.md)** — structural refactor of the web TypeScript.
The `web/src/` rename landed; collapsing `ReadiumReader.ts` into a thin facade has not.
*(Maintainability / L)*
- **[todo/margin-marker-custom-icons.md](todo/margin-marker-custom-icons.md)** — let apps pass their own single-path SVG icon to `marginMarker`; parked until a client asks. *(Feature / S)*
- **[todo/highlight-modes.md](todo/highlight-modes.md)** — `highlight`, `underline` and `spotlight`
decoration styles exist; the `ruler` style does not. *(Feature / M)*

Expand All @@ -47,6 +48,7 @@ This directory holds implementation plans, parity audits, and retained reference
- **[native-media-overlay-toc-context.md](native-media-overlay-toc-context.md)** — native ToC ownership, resource boundaries and anchored seeking, following [ADR 0001](../adr/0001-media-overlay-toc-ownership.md).

- **[web-decorations.md](web-decorations.md)** — web decoration rendering and interaction.
- **[margin-marker-decorations.md](margin-marker-decorations.md)** — built-in `marginMarker` decoration style (label or icon in the page margin).
- **[web-goto-locator-precision.md](web-goto-locator-precision.md)** — full-locator web navigation.
- **[web-error-event.md](web-error-event.md)** — web error event stream.
- **[web-comic-support-plan.md](web-comic-support-plan.md)** — comic helper injection and web panel sync.
Expand Down
Loading
Loading