mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Fix underline in vertical writing mode
Or rather, add the option to fix it. The actual fix is in the reader.
This commit is contained in:
+11
-3
@@ -50,11 +50,19 @@ export class Overlayer {
|
||||
return []
|
||||
}
|
||||
static underline(rects, options = {}) {
|
||||
// TODO: in vertical-rl, the bōsen (sideline) should be on the right
|
||||
const { color = 'red', width: strokeWidth = 2 } = options
|
||||
const { color = 'red', width: strokeWidth = 2, writingMode } = options
|
||||
const g = createSVGElement('g')
|
||||
g.setAttribute('fill', color)
|
||||
for (const { left, bottom, width } of rects) {
|
||||
if (writingMode === 'vertical-rl' || writingMode === 'vertical-lr')
|
||||
for (const { right, top, height } of rects) {
|
||||
const el = createSVGElement('rect')
|
||||
el.setAttribute('x', right - strokeWidth)
|
||||
el.setAttribute('y', top)
|
||||
el.setAttribute('height', height)
|
||||
el.setAttribute('width', strokeWidth)
|
||||
g.append(el)
|
||||
}
|
||||
else for (const { left, bottom, width } of rects) {
|
||||
const el = createSVGElement('rect')
|
||||
el.setAttribute('x', left)
|
||||
el.setAttribute('y', bottom - strokeWidth)
|
||||
|
||||
@@ -188,7 +188,8 @@ export class View {
|
||||
overlayer.remove(value)
|
||||
if (!remove) {
|
||||
const range = doc ? anchor(doc) : anchor
|
||||
const [func, opts] = this.emit({ type: 'draw-annotation', annotation })
|
||||
const [func, opts] = this
|
||||
.emit({ type: 'draw-annotation', annotation, doc, range })
|
||||
overlayer.add(value, range, func, opts)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user