-
Notifications
You must be signed in to change notification settings - Fork 147
SD-2524 - feat: implement context menu for lists #2918
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
Changes from 16 commits
5af3ec9
58bffc3
499762a
ba2bc6f
ed61181
641b1f2
b170c88
ebe3f67
bcd5de5
fae4a96
16eb3a1
9518489
c352203
2cce922
e870e62
6d8c9c9
c29f393
d33d978
ef93e57
260042b
63fdda6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| import { DOM_CLASS_NAMES } from '@superdoc/dom-contract'; | ||
| import { toCssFontFamily } from '@superdoc/font-utils'; | ||
| import { | ||
| resolveListMarkerGeometry, | ||
| resolveListTextStartPx, | ||
|
|
@@ -6,6 +8,8 @@ import { | |
| type MinimalWordLayout, | ||
| type ResolvedListMarkerGeometry, | ||
| } from '@superdoc/common/list-marker-utils'; | ||
| import { applySourceAnchorDataset } from '../renderer'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this file and renderer.ts import each other (helper pulls |
||
| import { SourceAnchor } from '@superdoc/contracts'; | ||
|
|
||
| type PainterListTextStartParams = { | ||
| wordLayout: MinimalWordLayout | undefined; | ||
|
|
@@ -74,3 +78,54 @@ export const resolvePainterListTextStartPx = ({ | |
|
|
||
| // Re-export computeTabWidth from shared module | ||
| export { computeTabWidth }; | ||
|
|
||
| type MarkerRunStyle = { | ||
| fontFamily?: string | null; | ||
| fontSize?: number | null; | ||
| bold?: boolean | null; | ||
| italic?: boolean | null; | ||
| color?: string | null; | ||
| letterSpacing?: number | null; | ||
| }; | ||
|
|
||
| /** | ||
| * Build the marker container `<span class="superdoc-list-marker">` with the inner | ||
| * `<span class="superdoc-paragraph-marker">` already appended and styled from the | ||
| * given run. Callers handle positioning, suffix separators, and the final prepend. | ||
| */ | ||
| export const createListMarkerElement = ( | ||
| doc: Document, | ||
| markerText: string, | ||
| run: MarkerRunStyle, | ||
| sourceAnchor?: SourceAnchor, | ||
| ): HTMLElement => { | ||
| const markerContainer = doc.createElement('span'); | ||
| markerContainer.classList.add(DOM_CLASS_NAMES.LIST_MARKER); | ||
| markerContainer.style.display = 'inline-block'; | ||
| markerContainer.style.wordSpacing = '0px'; | ||
|
|
||
| const markerEl = doc.createElement('span'); | ||
| markerEl.classList.add('superdoc-paragraph-marker'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since this PR is moving list-marker classes into |
||
| markerEl.textContent = markerText; | ||
| markerEl.style.pointerEvents = 'none'; | ||
| markerEl.style.fontFamily = toCssFontFamily(run.fontFamily) ?? run.fontFamily ?? ''; | ||
|
|
||
| if (run.fontSize != null) { | ||
| markerEl.style.fontSize = `${run.fontSize}px`; | ||
| } | ||
| markerEl.style.fontWeight = run.bold ? 'bold' : ''; | ||
| markerEl.style.fontStyle = run.italic ? 'italic' : ''; | ||
|
|
||
| if (run.color) { | ||
| markerEl.style.color = run.color; | ||
| } | ||
| if (run.letterSpacing != null) { | ||
| markerEl.style.letterSpacing = `${run.letterSpacing}px`; | ||
| } | ||
|
|
||
| markerContainer.appendChild(markerEl); | ||
| if (sourceAnchor) { | ||
| applySourceAnchorDataset(markerEl, sourceAnchor); | ||
| } | ||
| return markerContainer; | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flow markers carry source anchors via the helper now, but this call passes 3 args so table markers don't. snapshot consumers walking markers will skip them. any reason not to pass
markerLayout?.sourceAnchorhere, like the renderer.ts call at 3231?