@embedpdf/plugin-annotation 3.0.0-next.21 → 3.0.0-next.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/contract/host.cjs +2 -2
- package/dist/contract/host.d.cts +3 -3
- package/dist/contract/host.d.ts +3 -3
- package/dist/contract/host.js +2 -2
- package/dist/{contract-Cm0cfAzG.d.cts → contract-BK2g1Rem.d.ts} +85 -68
- package/dist/{contract-CPzpRG3h.cjs → contract-BtAl3Yo2.cjs} +4 -4
- package/dist/contract-BtAl3Yo2.cjs.map +1 -0
- package/dist/{contract-QAvnfm2b.d.ts → contract-CBYEqnev.d.cts} +85 -68
- package/dist/{contract-b2e_LZvu.js → contract-OwgW3JE8.js} +4 -4
- package/dist/contract-OwgW3JE8.js.map +1 -0
- package/dist/contract.cjs +1 -1
- package/dist/contract.d.cts +2 -2
- package/dist/contract.d.ts +2 -2
- package/dist/contract.js +1 -1
- package/dist/{host-contract-DY9jFPPF.cjs → host-contract-BzM2upsA.cjs} +2 -2
- package/dist/host-contract-BzM2upsA.cjs.map +1 -0
- package/dist/{host-contract-BDwyBNrs.d.cts → host-contract-COF2Prd-.d.ts} +33 -29
- package/dist/{host-contract-CxrQPcPj.js → host-contract-CSKiuu3g.js} +2 -2
- package/dist/host-contract-CSKiuu3g.js.map +1 -0
- package/dist/{host-contract-BUub1Un-.d.ts → host-contract-CxOrR_pp.d.cts} +33 -29
- package/dist/index.cjs +249 -103
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +250 -104
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
- package/dist/contract-CPzpRG3h.cjs.map +0 -1
- package/dist/contract-b2e_LZvu.js.map +0 -1
- package/dist/host-contract-CxrQPcPj.js.map +0 -1
- package/dist/host-contract-DY9jFPPF.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as buildToolRegistry, c as AnnotationToken, i as DEFAULT_TOOLS, n as AnnotationTransfer, o as toolTouchOf, r as ARMED_STAMP_TOOL_ID, s as annotationState, t as ANNOTATION_DEFAULTS } from "./contract-
|
|
2
|
-
import { n as previewBucket, t as AnnotationToken$1 } from "./host-contract-
|
|
1
|
+
import { a as buildToolRegistry, c as AnnotationToken, i as DEFAULT_TOOLS, n as AnnotationTransfer, o as toolTouchOf, r as ARMED_STAMP_TOOL_ID, s as annotationState, t as ANNOTATION_DEFAULTS } from "./contract-OwgW3JE8.js";
|
|
2
|
+
import { n as previewBucket, t as AnnotationToken$1 } from "./host-contract-CSKiuu3g.js";
|
|
3
3
|
import { widgetAppearanceOf } from "./authoring.js";
|
|
4
4
|
import { PluginError, annotationKey, composeApi, definePlugin, memo, pageRefsEqual, reload, toPluginError, toPluginErrorInfo } from "@embedpdf/core";
|
|
5
5
|
import { ActionsToken, createHoverPump } from "@embedpdf/plugin-actions/contract";
|
|
@@ -7,11 +7,11 @@ import { FontsToken } from "@embedpdf/plugin-fonts/contract";
|
|
|
7
7
|
import { InteractionToken } from "@embedpdf/plugin-interaction/contract/host";
|
|
8
8
|
import { RenderToken } from "@embedpdf/plugin-render/contract";
|
|
9
9
|
import { SelectionToken } from "@embedpdf/plugin-selection/contract/host";
|
|
10
|
-
import { ANNOTATION_FIELD_NAMES, STANDARD_FACES, anchorOf, annotationKey as annotationKey$1, annotationPatchBetween, buildCommentThreads, colorOf, compareIsoDateTime, deletedWith, faceForFontName, familyKey, fontNameForFace, imageSourceOfBytes, isDimension, isLocalEngine, isReadout, measurementReadout, pageBoxOf, reorderPart, reorderedList, resolveAnnotationPatch, resolveBinarySource, serializeError, sniffBinaryMetadata, toPageRef, viewportForPoint } from "@embedpdf/engine-core/runtime";
|
|
11
|
-
import { MIN_DRAG, anchorModeOf,
|
|
10
|
+
import { ANNOTATION_FIELD_NAMES, STANDARD_FACES, anchorOf, annotationKey as annotationKey$1, annotationPatchBetween, buildCommentThreads, colorOf, compareIsoDateTime, deletedWith, faceForFontName, familyKey, fontNameForFace, imageSourceOfBytes, isDimension, isLocalEngine, isReadout, measurementReadout, pageBoxOf, reorderPart, reorderedList, resolveAnnotationPatch, resolveBinarySource, serializeError, sniffBinaryMetadata, standardFontForFace, toPageRef, viewportForPoint } from "@embedpdf/engine-core/runtime";
|
|
11
|
+
import { MIN_DRAG, anchorModeOf, anchoredGeometry, annotContentsEditable, annotDeletable, annotTransformable, annotationAfter, annotationAnchor, annotationOfNew, applyStyleToRange, canMove, chrome, creationDraftAnchor, cursorAt, defaultsFor, drawnAfter, drawsLive, expandGroups, faceForFont, fitStampBox, fromDTO, gesturePlacement, gesturePlacement as gesturePlacement$1, groupKeyOf, groupOf, hitTest, initialSession, initialTextStyle, isContentsEditableByHand, isDrag, isEditableByHand, isOnTextBox, isSelectable, isSubstrateOnly, isTransformableByHand, kindNamed, kindNamed as kindNamed$1, kindOf, linkChildRects, linkChildrenOf, linkOf, locateOffset, newRecordsAtMost, pageItems, placedShape, propertiesOf, propertiesOf as propertiesOf$1, readOfDefaults, refOf, resolveClickPlacement, resolveClickPlacement as resolveClickPlacement$1, richDocOf, richTextLength, rotationAnchor, sameSession, selectionAnchor, selectionInBox, selectionProperties, shapeOf, sourceOfConfirmed, sourceOfNew, styleAt, styleOf, textBoxOf, textBoxes, textOf, textPlateInset, toolAnnotation, typeWithStyle, unanchoredGeometry, unmadeItem, update, uprightRotation, viewable, writableTarget } from "@embedpdf/core-annotation";
|
|
12
12
|
import { ActionsToken as ActionsToken$1 } from "@embedpdf/plugin-actions/contract/host";
|
|
13
13
|
import { RenderToken as RenderToken$1 } from "@embedpdf/plugin-render/contract/host";
|
|
14
|
-
import { standardFontCss,
|
|
14
|
+
import { standardFontCss, standardFontOf, standardFontOfProgramFamily } from "@embedpdf/core-fonts";
|
|
15
15
|
import { InteractionToken as InteractionToken$1 } from "@embedpdf/plugin-interaction/contract";
|
|
16
16
|
import { SelectionToken as SelectionToken$1 } from "@embedpdf/plugin-selection/contract";
|
|
17
17
|
import { scriptColorToRgb } from "@embedpdf/core-acrojs";
|
|
@@ -119,9 +119,9 @@ function createComments(ctx, { store, authority, events }, threads, crud) {
|
|
|
119
119
|
const record = store.model().byId[annotationKey$1(ref)];
|
|
120
120
|
return !!record && !isDimension(record.annotation) && annotContentsEditable(record);
|
|
121
121
|
};
|
|
122
|
-
const announce = (root,
|
|
122
|
+
const announce = (root, type) => events.threadChanged.emit({
|
|
123
123
|
rootRef: root,
|
|
124
|
-
|
|
124
|
+
type
|
|
125
125
|
});
|
|
126
126
|
return { api: { comments: {
|
|
127
127
|
listThreads: () => threads.index().threads,
|
|
@@ -362,12 +362,12 @@ function createPlaceHandler(anno, interaction) {
|
|
|
362
362
|
id: "annotation-place",
|
|
363
363
|
priority: 95,
|
|
364
364
|
enabledFor: (tool) => tool.enables.has("annotation-place") || tool.enables.has("annotation-stamp"),
|
|
365
|
-
|
|
365
|
+
onPointerDown: (sample) => {
|
|
366
366
|
if (!sample.page) return false;
|
|
367
367
|
return anno.placeAt(sample.page.ref, sample.page.point, sample.page.rotation, sample.page.zoom);
|
|
368
368
|
},
|
|
369
|
-
|
|
370
|
-
|
|
369
|
+
onPointerUp: () => anno.clearGhost(),
|
|
370
|
+
onPointerCancel: () => anno.clearGhost(),
|
|
371
371
|
onHover: (sample) => followGhost(anno, interaction, sample)
|
|
372
372
|
};
|
|
373
373
|
}
|
|
@@ -385,9 +385,9 @@ function createEditHandler(anno, interaction) {
|
|
|
385
385
|
priority: 100,
|
|
386
386
|
enabledFor: (tool) => tool.enables.has("annotation-edit"),
|
|
387
387
|
claimsTouch: (sample) => !!sample.page && anno.claimsTouchAt(sample.page.ref, sample.page.point, sample.page.scale, sample.page.rotation, sample.page.zoom),
|
|
388
|
-
|
|
388
|
+
onPointerDown: (sample) => {
|
|
389
389
|
if (!sample.page) return false;
|
|
390
|
-
if (anno.
|
|
390
|
+
if (anno.getDistanceCreationPage?.() != null) return false;
|
|
391
391
|
const touch = sample.pointerType === "touch";
|
|
392
392
|
const wasEditing = anno.getEditingId() != null;
|
|
393
393
|
if (wasEditing) anno.text.end();
|
|
@@ -407,19 +407,19 @@ function createEditHandler(anno, interaction) {
|
|
|
407
407
|
};
|
|
408
408
|
return true;
|
|
409
409
|
},
|
|
410
|
-
|
|
410
|
+
onPointerMove: (sample) => {
|
|
411
411
|
if (!origin) return;
|
|
412
412
|
const point = pointOn(sample, origin.page);
|
|
413
413
|
if (!point) return;
|
|
414
414
|
origin.point = point;
|
|
415
415
|
anno.editPointer("move", origin.page, point, sample.modifiers.shift, sample.page?.scale, sample.page?.rotation, sample.page?.zoom, origin.touch);
|
|
416
416
|
},
|
|
417
|
-
|
|
417
|
+
onPointerUp: (sample) => {
|
|
418
418
|
if (!origin) return;
|
|
419
419
|
anno.editPointer("up", origin.page, pointOn(sample, origin.page) ?? origin.point, false, void 0, void 0, void 0, origin.touch);
|
|
420
420
|
origin = null;
|
|
421
421
|
},
|
|
422
|
-
|
|
422
|
+
onPointerCancel: () => {
|
|
423
423
|
if (!origin) return;
|
|
424
424
|
const { page, downPoint, touch } = origin;
|
|
425
425
|
origin = null;
|
|
@@ -451,7 +451,7 @@ function createMarqueeHandler(anno) {
|
|
|
451
451
|
id: "annotation-marquee",
|
|
452
452
|
priority: 50,
|
|
453
453
|
enabledFor: (tool) => tool.enables.has("annotation-marquee"),
|
|
454
|
-
|
|
454
|
+
onPointerDown: (sample) => {
|
|
455
455
|
if (!sample.page) return false;
|
|
456
456
|
anchor = {
|
|
457
457
|
page: sample.page.ref,
|
|
@@ -472,7 +472,7 @@ function createMarqueeHandler(anno) {
|
|
|
472
472
|
dragging = false;
|
|
473
473
|
return true;
|
|
474
474
|
},
|
|
475
|
-
|
|
475
|
+
onPointerMove: (sample) => {
|
|
476
476
|
if (!anchor) return;
|
|
477
477
|
const point = pointOn(sample, anchor.page);
|
|
478
478
|
if (!point) return;
|
|
@@ -487,13 +487,13 @@ function createMarqueeHandler(anno) {
|
|
|
487
487
|
}
|
|
488
488
|
anno.marqueePointer("move", anchor.page, point, anchor.shift, view.scale, view.rotation, view.zoom);
|
|
489
489
|
},
|
|
490
|
-
|
|
490
|
+
onPointerUp: () => {
|
|
491
491
|
if (dragging && anchor && last) anno.marqueePointer("up", anchor.page, last.point, anchor.shift, view.scale, view.rotation, view.zoom);
|
|
492
492
|
anchor = null;
|
|
493
493
|
last = null;
|
|
494
494
|
dragging = false;
|
|
495
495
|
},
|
|
496
|
-
|
|
496
|
+
onPointerCancel: () => {
|
|
497
497
|
anchor = null;
|
|
498
498
|
last = null;
|
|
499
499
|
dragging = false;
|
|
@@ -532,10 +532,10 @@ function createDrawHandler(anno, interaction, clock, onSettle) {
|
|
|
532
532
|
id: "annotation-draw",
|
|
533
533
|
priority: 55,
|
|
534
534
|
enabledFor: (tool) => tool.enables.has("annotation-draw"),
|
|
535
|
-
|
|
535
|
+
onPointerDown: (sample) => {
|
|
536
536
|
const tool = toolId();
|
|
537
537
|
const st = subtypeOf(tool);
|
|
538
|
-
const distancePage = anno.
|
|
538
|
+
const distancePage = anno.getDistanceCreationPage?.();
|
|
539
539
|
if (distancePage != null) {
|
|
540
540
|
const point = pointOn(sample, distancePage);
|
|
541
541
|
if (point) anno.createPointer(tool, "down", distancePage, point);
|
|
@@ -566,7 +566,7 @@ function createDrawHandler(anno, interaction, clock, onSettle) {
|
|
|
566
566
|
anno.createPointer(tool, "down", sample.page.ref, sample.page.point, false, sample.page.rotation);
|
|
567
567
|
return true;
|
|
568
568
|
},
|
|
569
|
-
|
|
569
|
+
onPointerMove: (sample) => {
|
|
570
570
|
const tool = toolId();
|
|
571
571
|
const st = subtypeOf(tool);
|
|
572
572
|
if (!origin || isPolyTool(st) && !drawingPoly) return;
|
|
@@ -575,7 +575,7 @@ function createDrawHandler(anno, interaction, clock, onSettle) {
|
|
|
575
575
|
origin.point = point;
|
|
576
576
|
anno.createPointer(tool, "move", origin.page, point);
|
|
577
577
|
},
|
|
578
|
-
|
|
578
|
+
onPointerUp: (sample) => {
|
|
579
579
|
const tool = toolId();
|
|
580
580
|
const st = subtypeOf(tool);
|
|
581
581
|
if (origin && !isPolyTool(st)) {
|
|
@@ -595,7 +595,7 @@ function createDrawHandler(anno, interaction, clock, onSettle) {
|
|
|
595
595
|
origin = null;
|
|
596
596
|
anno.clearGhost();
|
|
597
597
|
},
|
|
598
|
-
|
|
598
|
+
onPointerCancel: () => {
|
|
599
599
|
if (pendingInk) {
|
|
600
600
|
pendingInk.cancelWait();
|
|
601
601
|
pendingInk = null;
|
|
@@ -611,7 +611,7 @@ function createDrawHandler(anno, interaction, clock, onSettle) {
|
|
|
611
611
|
followGhost(anno, interaction, sample);
|
|
612
612
|
const tool = toolId();
|
|
613
613
|
const st = subtypeOf(tool);
|
|
614
|
-
const distancePage = anno.
|
|
614
|
+
const distancePage = anno.getDistanceCreationPage?.();
|
|
615
615
|
if (distancePage != null) {
|
|
616
616
|
const point = pointOn(sample, distancePage);
|
|
617
617
|
if (point) anno.createPointer(tool, "move", distancePage, point);
|
|
@@ -1136,7 +1136,8 @@ function createChromeReads(ctx, { store, geometry, behaviors, settings }) {
|
|
|
1136
1136
|
*
|
|
1137
1137
|
* • a flat props patch → the run delta it means for a text range (font,
|
|
1138
1138
|
* size, colour, bold/italic/underline) and the keys left for the body
|
|
1139
|
-
* • what a range reads back for those keys (agree → the value, else mixed)
|
|
1139
|
+
* • what a range reads back for those keys (agree → the value, else mixed),
|
|
1140
|
+
* and a caret: the text typed there next
|
|
1140
1141
|
* • faces: the DTO font a face names
|
|
1141
1142
|
* • the commit rule: a document nothing overrides on a plain annotation
|
|
1142
1143
|
* commits as `contents`; anything else as `richText`
|
|
@@ -1264,11 +1265,24 @@ function runsInRange(doc, range) {
|
|
|
1264
1265
|
}
|
|
1265
1266
|
return out;
|
|
1266
1267
|
}
|
|
1267
|
-
/** The values a range reads back for the range keys
|
|
1268
|
-
* body, one value where every run agrees, `mixed` where they don't. */
|
|
1268
|
+
/** The values a range reads back for the range keys: the runs it covers (`runProps`). */
|
|
1269
1269
|
function rangeProps(doc, range, fonts) {
|
|
1270
|
-
|
|
1271
|
-
|
|
1270
|
+
return runProps(doc.body, runsInRange(doc, range), fonts);
|
|
1271
|
+
}
|
|
1272
|
+
/**
|
|
1273
|
+
* The values a caret reads back for the range keys: the text typed there
|
|
1274
|
+
* next, in the style of the text before it (`styleAt`) with the style chosen
|
|
1275
|
+
* at the caret over it.
|
|
1276
|
+
*/
|
|
1277
|
+
function caretProps(doc, at, typing, fonts) {
|
|
1278
|
+
return runProps(doc.body, [{
|
|
1279
|
+
...styleAt(doc, at),
|
|
1280
|
+
...typing
|
|
1281
|
+
}], fonts);
|
|
1282
|
+
}
|
|
1283
|
+
/** The values runs read back for the range keys: resolved against the
|
|
1284
|
+
* body, one value where every run agrees, `mixed` where they don't. */
|
|
1285
|
+
function runProps(body, runs, fonts) {
|
|
1272
1286
|
const resolve = (delta) => ({
|
|
1273
1287
|
family: delta.family ?? body.family,
|
|
1274
1288
|
weight: delta.weight ?? body.weight,
|
|
@@ -1347,12 +1361,24 @@ function propertyValues(properties, sources) {
|
|
|
1347
1361
|
* selection of frozen annotations has nothing to restyle.
|
|
1348
1362
|
*/
|
|
1349
1363
|
function createPropertyReads(ctx, { store, fonts }) {
|
|
1364
|
+
/** The editor's selection inside the annotation being edited, or null (no
|
|
1365
|
+
* editor selection, or one left behind by a previous edit). */
|
|
1366
|
+
const editorSelection = (model) => {
|
|
1367
|
+
const ts = ctx.state.get().textSelection;
|
|
1368
|
+
return ts && model.editing === ts.id && model.byId[ts.id] ? ts : null;
|
|
1369
|
+
};
|
|
1350
1370
|
/** The editor's text range inside the annotation being edited, or null
|
|
1351
|
-
* (no editor selection, a bare caret
|
|
1352
|
-
*
|
|
1371
|
+
* (no editor selection, or a bare caret). The one condition that routes
|
|
1372
|
+
* the range properties to runs. */
|
|
1353
1373
|
const activeTextRange = (model) => {
|
|
1354
|
-
const ts =
|
|
1355
|
-
return ts &&
|
|
1374
|
+
const ts = editorSelection(model);
|
|
1375
|
+
return ts && ts.end > ts.start ? ts : null;
|
|
1376
|
+
};
|
|
1377
|
+
/** The editor's caret inside the annotation being edited, or null. The
|
|
1378
|
+
* range properties there are the text typed next. */
|
|
1379
|
+
const activeCaret = (model) => {
|
|
1380
|
+
const ts = editorSelection(model);
|
|
1381
|
+
return ts && ts.end === ts.start ? ts : null;
|
|
1356
1382
|
};
|
|
1357
1383
|
/** What a panel reads of one member: its fields, its text as shown, and its link. */
|
|
1358
1384
|
const sourcesOf = (model, record) => {
|
|
@@ -1364,29 +1390,42 @@ function createPropertyReads(ctx, { store, fonts }) {
|
|
|
1364
1390
|
link: annotation.subtype === "link" ? annotation.target ?? null : linkOf(model, record.id)
|
|
1365
1391
|
};
|
|
1366
1392
|
};
|
|
1393
|
+
/**
|
|
1394
|
+
* What a free text's range properties read: the text the next change
|
|
1395
|
+
* styles. The editor's range, the text typed next at its caret, else all of
|
|
1396
|
+
* the box's text. `null` for any other kind.
|
|
1397
|
+
*/
|
|
1398
|
+
const textPropsOf = (model, record) => {
|
|
1399
|
+
if (record.annotation.subtype !== "free-text") return null;
|
|
1400
|
+
const doc = richDocOf(record.annotation, fonts);
|
|
1401
|
+
const ts = editorSelection(model);
|
|
1402
|
+
if (ts?.id !== record.id) return rangeProps(doc, {
|
|
1403
|
+
start: 0,
|
|
1404
|
+
end: richTextLength(doc)
|
|
1405
|
+
}, fonts);
|
|
1406
|
+
if (ts.end > ts.start) return rangeProps(doc, ts, fonts);
|
|
1407
|
+
return caretProps(doc, ts.start, ts.typing, fonts);
|
|
1408
|
+
};
|
|
1367
1409
|
let cache = null;
|
|
1368
1410
|
const selectionPropertiesOf = () => {
|
|
1369
1411
|
const model = store.model();
|
|
1370
|
-
const
|
|
1371
|
-
if (cache && cache.model === model && cache.
|
|
1412
|
+
const selection = editorSelection(model);
|
|
1413
|
+
if (cache && cache.model === model && cache.selection === selection) return cache.v;
|
|
1372
1414
|
const members = model.selected.map((id) => model.byId[id]).filter((record) => !!record && isEditableByHand(model, record.annotation));
|
|
1373
|
-
const properties =
|
|
1415
|
+
const properties = selectionProperties(model, members.map((record) => record.annotation));
|
|
1374
1416
|
const sources = members.map((record) => sourcesOf(model, record));
|
|
1417
|
+
const texts = members.map((record) => textPropsOf(model, record));
|
|
1418
|
+
const valueOf = (spec, index) => {
|
|
1419
|
+
const text = texts[index];
|
|
1420
|
+
return text && RANGE_KEYS.includes(spec.key) ? text.values[spec.key] : propertyValue(spec, sources[index]);
|
|
1421
|
+
};
|
|
1375
1422
|
const values = sources.length ? propertyValues(properties, sources[0]) : {};
|
|
1376
1423
|
const mixed = [];
|
|
1377
1424
|
for (const spec of properties) {
|
|
1378
|
-
const
|
|
1379
|
-
if (
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
const rp = rangeProps(richDocOf(members[0].annotation, fonts), range, fonts);
|
|
1383
|
-
for (const spec of properties) {
|
|
1384
|
-
if (!RANGE_KEYS.includes(spec.key)) continue;
|
|
1385
|
-
values[spec.key] = rp.values[spec.key];
|
|
1386
|
-
const index = mixed.indexOf(spec.key);
|
|
1387
|
-
if (index >= 0) mixed.splice(index, 1);
|
|
1388
|
-
if (rp.mixed.includes(spec.key)) mixed.push(spec.key);
|
|
1389
|
-
}
|
|
1425
|
+
const ofText = RANGE_KEYS.includes(spec.key);
|
|
1426
|
+
if (ofText && texts[0]) values[spec.key] = texts[0].values[spec.key];
|
|
1427
|
+
const first = JSON.stringify(valueOf(spec, 0));
|
|
1428
|
+
if (sources.some((_, index) => JSON.stringify(valueOf(spec, index)) !== first) || ofText && texts.some((text) => text?.mixed.includes(spec.key))) mixed.push(spec.key);
|
|
1390
1429
|
}
|
|
1391
1430
|
const result = {
|
|
1392
1431
|
properties,
|
|
@@ -1395,13 +1434,14 @@ function createPropertyReads(ctx, { store, fonts }) {
|
|
|
1395
1434
|
};
|
|
1396
1435
|
cache = {
|
|
1397
1436
|
model,
|
|
1398
|
-
|
|
1437
|
+
selection,
|
|
1399
1438
|
v: result
|
|
1400
1439
|
};
|
|
1401
1440
|
return result;
|
|
1402
1441
|
};
|
|
1403
1442
|
return {
|
|
1404
1443
|
activeTextRange,
|
|
1444
|
+
activeCaret,
|
|
1405
1445
|
selectionPropertiesOf
|
|
1406
1446
|
};
|
|
1407
1447
|
}
|
|
@@ -1670,7 +1710,7 @@ function createRenderReads(ctx, { view: { pageModel }, lending, fonts: fontLooku
|
|
|
1670
1710
|
return {
|
|
1671
1711
|
engine,
|
|
1672
1712
|
placed: placed.sort().join("|"),
|
|
1673
|
-
lent: lentShown && lender ? `lent:${lender.
|
|
1713
|
+
lent: lentShown && lender ? `lent:${lender.getPictureEpoch(page)}` : ""
|
|
1674
1714
|
};
|
|
1675
1715
|
};
|
|
1676
1716
|
/** The lender's pictures of its records on `page`, in every state, at their picture versions. */
|
|
@@ -1695,7 +1735,7 @@ function createRenderReads(ctx, { view: { pageModel }, lending, fonts: fontLooku
|
|
|
1695
1735
|
/** The family whose pictures a record's are: the lender's widgets, or annotations. */
|
|
1696
1736
|
const familyOf = (id) => lending.owns(id) ? "widgets" : "annotations";
|
|
1697
1737
|
/** The engine's last pictures of a record, kept a while after it left its page. */
|
|
1698
|
-
const keptOf = (id, ref) => ctx.tryGet(RenderToken$1)?.
|
|
1738
|
+
const keptOf = (id, ref) => ctx.tryGet(RenderToken$1)?.getKeptAppearances(familyOf(id), ref) ?? [];
|
|
1699
1739
|
/**
|
|
1700
1740
|
* The pictures of what shows on `page` that the engine hasn't written yet:
|
|
1701
1741
|
* a stamp this session placed shows its preview, at the size the page shows
|
|
@@ -1896,16 +1936,16 @@ function createView(ctx, records, lending) {
|
|
|
1896
1936
|
...fromDTO(shown),
|
|
1897
1937
|
unconfirmed: true,
|
|
1898
1938
|
source: confirmedOnce.has(annotationKey$1(shown.ref)) ? "baked" : "vector",
|
|
1899
|
-
pictureVersion: lender.
|
|
1900
|
-
authority: lender.
|
|
1939
|
+
pictureVersion: lender.getPictureVersion(shown.ref),
|
|
1940
|
+
authority: lender.getAuthority(shown),
|
|
1901
1941
|
...painterOf(shown, lender)
|
|
1902
1942
|
};
|
|
1903
1943
|
else {
|
|
1904
1944
|
const base = {
|
|
1905
1945
|
...fromDTO(truth),
|
|
1906
1946
|
source: sourceOfConfirmed(truth, false),
|
|
1907
|
-
pictureVersion: lender.
|
|
1908
|
-
authority: lender.
|
|
1947
|
+
pictureVersion: lender.getPictureVersion(truth.ref),
|
|
1948
|
+
authority: lender.getAuthority(truth),
|
|
1909
1949
|
...painterOf(shown, lender)
|
|
1910
1950
|
};
|
|
1911
1951
|
const patch = {
|
|
@@ -1917,7 +1957,7 @@ function createView(ctx, records, lending) {
|
|
|
1917
1957
|
annotation: shown,
|
|
1918
1958
|
...drawnAfter(base, patch)
|
|
1919
1959
|
};
|
|
1920
|
-
if (lender.
|
|
1960
|
+
if (lender.isPending(shown.ref) && drawsLive(record)) record = {
|
|
1921
1961
|
...record,
|
|
1922
1962
|
source: "vector"
|
|
1923
1963
|
};
|
|
@@ -2591,7 +2631,7 @@ function createRecordsMirror(ctx, events) {
|
|
|
2591
2631
|
const list = await doc.annotations.list();
|
|
2592
2632
|
return {
|
|
2593
2633
|
value: fromSnapshot(records.get(), list.annotations),
|
|
2594
|
-
cursor: list.auditHead
|
|
2634
|
+
cursor: list.auditHead
|
|
2595
2635
|
};
|
|
2596
2636
|
},
|
|
2597
2637
|
fold: foldRecords,
|
|
@@ -2602,7 +2642,7 @@ function createRecordsMirror(ctx, events) {
|
|
|
2602
2642
|
const { annotations } = reading.length ? await doc.annotations.list({ pages: reading }) : { annotations: [] };
|
|
2603
2643
|
return (current) => withPages(current, pages, annotations);
|
|
2604
2644
|
},
|
|
2605
|
-
|
|
2645
|
+
onChanged: (change) => events.recordsChanged.emit(change)
|
|
2606
2646
|
});
|
|
2607
2647
|
return records;
|
|
2608
2648
|
}
|
|
@@ -3082,8 +3122,10 @@ function createStore(ctx, view, records, events, lending) {
|
|
|
3082
3122
|
* program the engine writes with. A box someone types in is resolved the way
|
|
3083
3123
|
* its write will be (the fonts plugin's `resolve`, with the box, so its own
|
|
3084
3124
|
* font counts): when the edit starts, and again after a pause in typing once
|
|
3085
|
-
* the text has a character it wasn't resolved with.
|
|
3086
|
-
*
|
|
3125
|
+
* the text has a character it wasn't resolved with. An answer holds for the
|
|
3126
|
+
* faces it was asked about: a box restyled since (another font, a bold word)
|
|
3127
|
+
* is asked again, and drawn in the fonts its names say until it is answered.
|
|
3128
|
+
* Any other box is drawn in the fonts its names say. Without the fonts plugin, a box is drawn in the
|
|
3087
3129
|
* standard font the engine falls back to for its font or face, in that
|
|
3088
3130
|
* font's built-in program (`@embedpdf/core-fonts`).
|
|
3089
3131
|
*/
|
|
@@ -3097,13 +3139,16 @@ const codePointsOf = (text) => Array.from(text, (char) => char.codePointAt(0));
|
|
|
3097
3139
|
function createTextFonts(ctx, store, lookup) {
|
|
3098
3140
|
const fonts = () => ctx.tryGet(FontsToken);
|
|
3099
3141
|
/**
|
|
3100
|
-
* What the engine answered per box: the
|
|
3101
|
-
*
|
|
3142
|
+
* What the engine answered per box: the faces it was asked about, the record it was asked for
|
|
3143
|
+
* (a newer one with the same faces keeps the answer), and the run each face drew in, its CSS
|
|
3144
|
+
* asked for on each read (it changes as the programs reach the browser).
|
|
3102
3145
|
*/
|
|
3103
3146
|
const answers = /* @__PURE__ */ new Map();
|
|
3104
3147
|
/** The box being typed in, and the characters its last resolve asked about. */
|
|
3148
|
+
let editing = null;
|
|
3105
3149
|
let asked = null;
|
|
3106
|
-
|
|
3150
|
+
/** Each box's resolve in flight: a newer one for the same box replaces it. */
|
|
3151
|
+
const resolving = /* @__PURE__ */ new Map();
|
|
3107
3152
|
let cancelPause = () => {};
|
|
3108
3153
|
let answered = 0;
|
|
3109
3154
|
let token = {
|
|
@@ -3116,13 +3161,13 @@ function createTextFonts(ctx, store, lookup) {
|
|
|
3116
3161
|
const face = faceForFontName(style.fontFamily, (key) => lookup().find((font) => font.key === key));
|
|
3117
3162
|
return (face.weight ?? 400) === body.weight && (face.italic ?? false) === body.italic;
|
|
3118
3163
|
};
|
|
3119
|
-
/**
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3164
|
+
/**
|
|
3165
|
+
* What the engine is asked about a box's text: the body first, then every run, unstyled ones by
|
|
3166
|
+
* the box's font, the rest by face; `faces` names the faces asked, whatever the text.
|
|
3167
|
+
*/
|
|
3168
|
+
const questionOf = (record) => {
|
|
3169
|
+
const style = textOf(record.annotation);
|
|
3170
|
+
if (!style || record.annotation.subtype !== "free-text") return null;
|
|
3126
3171
|
const doc = richDocOf(record.annotation, lookup);
|
|
3127
3172
|
const body = doc.body;
|
|
3128
3173
|
const faces = [BODY];
|
|
@@ -3150,32 +3195,85 @@ function createTextFonts(ctx, store, lookup) {
|
|
|
3150
3195
|
...face
|
|
3151
3196
|
});
|
|
3152
3197
|
}
|
|
3153
|
-
|
|
3198
|
+
const key = JSON.stringify({
|
|
3199
|
+
body: runs[0],
|
|
3200
|
+
faces: [...new Set(faces)].sort()
|
|
3201
|
+
});
|
|
3202
|
+
return {
|
|
3203
|
+
body,
|
|
3204
|
+
runs,
|
|
3205
|
+
faces,
|
|
3206
|
+
text,
|
|
3207
|
+
key
|
|
3208
|
+
};
|
|
3209
|
+
};
|
|
3210
|
+
/** Ask the engine what the box's text will be drawn in, and keep the answer. */
|
|
3211
|
+
const resolveBox = async (id) => {
|
|
3212
|
+
const api = fonts();
|
|
3213
|
+
const record = store.model().byId[id];
|
|
3214
|
+
const question = api && record && questionOf(record);
|
|
3215
|
+
if (!api || !record || !question) return;
|
|
3216
|
+
const { body, runs, faces, text, key } = question;
|
|
3217
|
+
const ref = refOf(record) ?? void 0;
|
|
3218
|
+
if (id === editing) asked = {
|
|
3154
3219
|
id,
|
|
3155
3220
|
codePoints: new Set(codePointsOf(text))
|
|
3156
3221
|
};
|
|
3157
|
-
resolving?.abort();
|
|
3222
|
+
resolving.get(id)?.abort();
|
|
3158
3223
|
const request = new AbortController();
|
|
3159
|
-
resolving
|
|
3224
|
+
resolving.set(id, request);
|
|
3160
3225
|
try {
|
|
3161
3226
|
await api.ensureLoaded();
|
|
3162
3227
|
const answer = await api.resolve({
|
|
3163
3228
|
...ref ? { annotation: ref } : {},
|
|
3164
3229
|
runs
|
|
3165
3230
|
}, { signal: request.signal });
|
|
3166
|
-
if (resolving !== request) return;
|
|
3231
|
+
if (resolving.get(id) !== request) return;
|
|
3232
|
+
resolving.delete(id);
|
|
3167
3233
|
const byFace = /* @__PURE__ */ new Map();
|
|
3168
3234
|
answer.runs.forEach((run, index) => {
|
|
3169
3235
|
const face = faces[index];
|
|
3170
3236
|
if (!byFace.has(face)) byFace.set(face, run);
|
|
3171
3237
|
});
|
|
3172
3238
|
if (!byFace.has(faceKey(body))) byFace.set(faceKey(body), byFace.get(BODY));
|
|
3173
|
-
answers.set(id,
|
|
3239
|
+
answers.set(id, {
|
|
3240
|
+
faces: key,
|
|
3241
|
+
record,
|
|
3242
|
+
byFace
|
|
3243
|
+
});
|
|
3174
3244
|
answered++;
|
|
3175
3245
|
ctx.notify();
|
|
3176
3246
|
} catch {}
|
|
3177
3247
|
};
|
|
3178
|
-
|
|
3248
|
+
/**
|
|
3249
|
+
* Drop the answers the model moved on from: a box deleted, or restyled so its faces aren't the
|
|
3250
|
+
* ones asked about, which is asked again (typing keeps the faces, and the answer). The model is
|
|
3251
|
+
* watched, not this plugin's state: a change that shows before the engine answers it, as a
|
|
3252
|
+
* format on a whole box does, changes the view alone.
|
|
3253
|
+
*/
|
|
3254
|
+
const dropStaleAnswers = (model) => {
|
|
3255
|
+
let dropped = false;
|
|
3256
|
+
for (const [id, answer] of answers) {
|
|
3257
|
+
const record = model.byId[id];
|
|
3258
|
+
if (record === answer.record) continue;
|
|
3259
|
+
const question = record && questionOf(record);
|
|
3260
|
+
if (question && question.key === answer.faces) {
|
|
3261
|
+
answers.set(id, {
|
|
3262
|
+
...answer,
|
|
3263
|
+
record
|
|
3264
|
+
});
|
|
3265
|
+
continue;
|
|
3266
|
+
}
|
|
3267
|
+
answers.delete(id);
|
|
3268
|
+
dropped = true;
|
|
3269
|
+
if (question) resolveBox(id);
|
|
3270
|
+
}
|
|
3271
|
+
if (dropped) {
|
|
3272
|
+
answered++;
|
|
3273
|
+
ctx.notify();
|
|
3274
|
+
}
|
|
3275
|
+
};
|
|
3276
|
+
ctx.watch(store.model, dropStaleAnswers);
|
|
3179
3277
|
ctx.state.onChange(() => {
|
|
3180
3278
|
const next = store.model().editing;
|
|
3181
3279
|
if (next === editing) return;
|
|
@@ -3189,14 +3287,14 @@ function createTextFonts(ctx, store, lookup) {
|
|
|
3189
3287
|
const api = fonts();
|
|
3190
3288
|
const byFont = bodyIsItsFont(style, body);
|
|
3191
3289
|
if (!api) return standardFontCss(byFont ? standardFontOf(style.fontFamily) : standardFontForFace(body));
|
|
3192
|
-
const run = answers.get(id)?.get(BODY);
|
|
3290
|
+
const run = answers.get(id)?.byFace.get(BODY);
|
|
3193
3291
|
if (run) return api.getRunCss(run);
|
|
3194
3292
|
return byFont ? api.getFontCss(style.fontFamily) : api.getFaceCss(body);
|
|
3195
3293
|
},
|
|
3196
3294
|
faceCss: (id, face) => {
|
|
3197
3295
|
const api = fonts();
|
|
3198
3296
|
if (!api) return standardFontCss(standardFontForFace(face));
|
|
3199
|
-
const run = id !== null ? answers.get(id)?.get(faceKey(face)) : void 0;
|
|
3297
|
+
const run = id !== null ? answers.get(id)?.byFace.get(faceKey(face)) : void 0;
|
|
3200
3298
|
return run ? api.getRunCss(run) : api.getFaceCss(face);
|
|
3201
3299
|
},
|
|
3202
3300
|
familyOfCss: (cssFamily) => {
|
|
@@ -3631,13 +3729,13 @@ const annotationOfTool = (model, tool) => ({
|
|
|
3631
3729
|
* size, hanging from its rect's upper-left corner. So the placement starts
|
|
3632
3730
|
* from how it shows, the icon centred on the pointer and kept on the page
|
|
3633
3731
|
* (`shown`, what the ghost draws), and stores the rect whose own display is
|
|
3634
|
-
* exactly that (`rect`, through `
|
|
3732
|
+
* exactly that (`rect`, through `unanchoredGeometry`, the inverse gestures use).
|
|
3635
3733
|
* `annotation` is what the tool creates, read for its flags. Without a view
|
|
3636
3734
|
* the two are the same box.
|
|
3637
3735
|
*/
|
|
3638
3736
|
function iconPlaceAt(annotation, point, page, view) {
|
|
3639
3737
|
const mode = anchorModeOf({ annotation });
|
|
3640
|
-
const { box: size, rotation } =
|
|
3738
|
+
const { box: size, rotation } = anchoredGeometry({
|
|
3641
3739
|
kind: "box",
|
|
3642
3740
|
box: {
|
|
3643
3741
|
x: 0,
|
|
@@ -3658,7 +3756,7 @@ function iconPlaceAt(annotation, point, page, view) {
|
|
|
3658
3756
|
};
|
|
3659
3757
|
return {
|
|
3660
3758
|
shown,
|
|
3661
|
-
rect:
|
|
3759
|
+
rect: unanchoredGeometry(shown, mode, view).box
|
|
3662
3760
|
};
|
|
3663
3761
|
}
|
|
3664
3762
|
/**
|
|
@@ -4047,7 +4145,7 @@ function createDrafts(ctx, { store, events, tools, afterCreate }, annotations) {
|
|
|
4047
4145
|
cancel: () => {
|
|
4048
4146
|
store.commit({ type: "cancel" });
|
|
4049
4147
|
},
|
|
4050
|
-
|
|
4148
|
+
getDistanceCreationPage: () => {
|
|
4051
4149
|
const draft = store.model().draft;
|
|
4052
4150
|
return draft?.kind === "create-distance" && draft.step === "offset" ? draft.page : null;
|
|
4053
4151
|
},
|
|
@@ -4760,26 +4858,28 @@ function createSelectionWrites(ctx, { store, authority, fonts, behaviors, lendin
|
|
|
4760
4858
|
* member takes the fields its kind has, and the change shows at once, as
|
|
4761
4859
|
* one change. While the text editor holds a range, the font, size, colour
|
|
4762
4860
|
* and formats restyle the runs it covers (a delta over the body, through
|
|
4763
|
-
* the pure run algebra) as part of the typing
|
|
4764
|
-
*
|
|
4765
|
-
* the
|
|
4861
|
+
* the pure run algebra) as part of the typing; at its caret they are the
|
|
4862
|
+
* style of the text typed next, and nothing is written. The rest goes to
|
|
4863
|
+
* the annotation: its change sends the typing first, so the body it writes
|
|
4864
|
+
* is the latest.
|
|
4766
4865
|
*/
|
|
4767
4866
|
const restyle = (patch) => {
|
|
4768
4867
|
const model = store.model();
|
|
4769
|
-
const
|
|
4868
|
+
const editor = properties.activeTextRange(model) ?? properties.activeCaret(model);
|
|
4770
4869
|
const commits = [];
|
|
4771
4870
|
const patches = {};
|
|
4772
4871
|
for (const id of model.selected) {
|
|
4773
4872
|
const record = model.byId[id];
|
|
4774
4873
|
if (!record) continue;
|
|
4775
4874
|
const own = typeof patch === "function" ? patch(record.annotation) : patch;
|
|
4776
|
-
if (
|
|
4875
|
+
if (editor?.id !== id) {
|
|
4777
4876
|
patches[id] = own;
|
|
4778
4877
|
continue;
|
|
4779
4878
|
}
|
|
4780
4879
|
const { delta, rest } = runDeltaForFields(own, fonts);
|
|
4781
|
-
if (Object.keys(delta).length)
|
|
4782
|
-
|
|
4880
|
+
if (Object.keys(delta).length && editor.start === editor.end) text.styleTyping(id, delta);
|
|
4881
|
+
else if (Object.keys(delta).length) {
|
|
4882
|
+
const next = applyStyleToRange({ paragraphs: richDocOf(record.annotation, fonts).paragraphs }, editor, delta);
|
|
4783
4883
|
commits.push(text.type(id, {
|
|
4784
4884
|
type: "setRichText",
|
|
4785
4885
|
id,
|
|
@@ -4803,12 +4903,15 @@ function createSelectionWrites(ctx, { store, authority, fonts, behaviors, lendin
|
|
|
4803
4903
|
});
|
|
4804
4904
|
};
|
|
4805
4905
|
/**
|
|
4806
|
-
* Bold, italic or underline on or off: the words selected while typing,
|
|
4807
|
-
*
|
|
4906
|
+
* Bold, italic or underline on or off: the words selected while typing, the
|
|
4907
|
+
* text typed next at the caret, or all the text of each selected box once
|
|
4908
|
+
* the text being typed has landed. On, unless all of it already has it.
|
|
4808
4909
|
*/
|
|
4809
4910
|
const toggleFormat = async (format, options = {}) => {
|
|
4810
|
-
const
|
|
4811
|
-
const
|
|
4911
|
+
const { values, mixed } = properties.selectionPropertiesOf();
|
|
4912
|
+
const on = values[format] !== true || mixed.includes(format);
|
|
4913
|
+
const model = store.model();
|
|
4914
|
+
const commits = properties.activeTextRange(model) ?? properties.activeCaret(model) ? restyle({ [format]: on }) : [store.commit({
|
|
4812
4915
|
type: "setTextFormat",
|
|
4813
4916
|
format,
|
|
4814
4917
|
on
|
|
@@ -4817,7 +4920,7 @@ function createSelectionWrites(ctx, { store, authority, fonts, behaviors, lendin
|
|
|
4817
4920
|
};
|
|
4818
4921
|
/** The `selection` noun (its reads come from the property and chrome reads). */
|
|
4819
4922
|
const selection = {
|
|
4820
|
-
|
|
4923
|
+
select: (refs) => refs.length ? select(refs, false) : void store.commit({ type: "deselect" }),
|
|
4821
4924
|
add: (refs) => select(refs, true),
|
|
4822
4925
|
selectAll: (page) => {
|
|
4823
4926
|
const only = page === void 0 ? null : ctx.getPage(page);
|
|
@@ -4846,7 +4949,7 @@ function createSelectionWrites(ctx, { store, authority, fonts, behaviors, lendin
|
|
|
4846
4949
|
clear: () => {
|
|
4847
4950
|
store.commit({ type: "deselect" });
|
|
4848
4951
|
},
|
|
4849
|
-
|
|
4952
|
+
getSelected: () => annotations.listSelected(),
|
|
4850
4953
|
update: (changes, options = {}) => commitOverSelection(() => restyle(changes), options.signal),
|
|
4851
4954
|
updateLink: (target, options = {}) => commitOverSelection(() => [store.commit({
|
|
4852
4955
|
type: "setLink",
|
|
@@ -5184,7 +5287,8 @@ function createStamps(ctx, { store, geometry, tools, filePicker, afterCreate })
|
|
|
5184
5287
|
* hold): the view shows the text at once, and the change keeps its place in
|
|
5185
5288
|
* line holding the latest text. It is sent after a pause in typing, when
|
|
5186
5289
|
* editing ends, when anything else is staged, and before a download; what is
|
|
5187
|
-
* typed after that goes into a new one.
|
|
5290
|
+
* typed after that goes into a new one. A style chosen at the caret waits in
|
|
5291
|
+
* the editor's selection for the text typed there next.
|
|
5188
5292
|
*/
|
|
5189
5293
|
const TEXT_WRITE_DELAY_MS = 250;
|
|
5190
5294
|
function createTextEditing(ctx, { store, fonts, textFonts }, chrome) {
|
|
@@ -5221,6 +5325,44 @@ function createTextEditing(ctx, { store, fonts, textFonts }, chrome) {
|
|
|
5221
5325
|
});
|
|
5222
5326
|
return commit;
|
|
5223
5327
|
};
|
|
5328
|
+
/**
|
|
5329
|
+
* The style the text typed next at the caret in box `id` takes, over what
|
|
5330
|
+
* was chosen there already. Nothing is written until it is typed.
|
|
5331
|
+
*/
|
|
5332
|
+
const styleTyping = (id, style) => {
|
|
5333
|
+
const selection = ctx.state.get().textSelection;
|
|
5334
|
+
if (selection?.id !== id || selection.start !== selection.end) return;
|
|
5335
|
+
ctx.state.update(setTextSelection, {
|
|
5336
|
+
...selection,
|
|
5337
|
+
typing: {
|
|
5338
|
+
...selection.typing,
|
|
5339
|
+
...style
|
|
5340
|
+
}
|
|
5341
|
+
});
|
|
5342
|
+
};
|
|
5343
|
+
/**
|
|
5344
|
+
* The paragraphs typed into box `id`, the text typed at the caret in the
|
|
5345
|
+
* style chosen there (`typeWithStyle`), and the caret where the typing
|
|
5346
|
+
* leaves it. Any other edit drops the style.
|
|
5347
|
+
*/
|
|
5348
|
+
const typedInStyle = (id, paragraphs) => {
|
|
5349
|
+
const selection = ctx.state.get().textSelection;
|
|
5350
|
+
const record = store.model().byId[id];
|
|
5351
|
+
if (!selection?.typing || selection.id !== id || !record) return paragraphs;
|
|
5352
|
+
const typed = typeWithStyle(richDocOf(record.annotation, fonts), { paragraphs }, selection.start, selection.typing);
|
|
5353
|
+
const caret = typed ? {
|
|
5354
|
+
id,
|
|
5355
|
+
start: typed.caret,
|
|
5356
|
+
end: typed.caret,
|
|
5357
|
+
...typed.style && { typing: typed.style }
|
|
5358
|
+
} : {
|
|
5359
|
+
id,
|
|
5360
|
+
start: selection.start,
|
|
5361
|
+
end: selection.end
|
|
5362
|
+
};
|
|
5363
|
+
ctx.state.update(setTextSelection, caret);
|
|
5364
|
+
return typed?.doc.paragraphs ?? paragraphs;
|
|
5365
|
+
};
|
|
5224
5366
|
store.onEffect("text", (effect, model) => {
|
|
5225
5367
|
const record = model.byId[effect.id];
|
|
5226
5368
|
const ref = refOf(record);
|
|
@@ -5236,6 +5378,7 @@ function createTextEditing(ctx, { store, fonts, textFonts }, chrome) {
|
|
|
5236
5378
|
});
|
|
5237
5379
|
return {
|
|
5238
5380
|
type,
|
|
5381
|
+
styleTyping,
|
|
5239
5382
|
sendTyping,
|
|
5240
5383
|
text: {
|
|
5241
5384
|
begin: (ref) => {
|
|
@@ -5278,11 +5421,13 @@ function createTextEditing(ctx, { store, fonts, textFonts }, chrome) {
|
|
|
5278
5421
|
},
|
|
5279
5422
|
draftRichText: (ref, doc) => {
|
|
5280
5423
|
const id = annotationKey$1(ref);
|
|
5424
|
+
const kept = { paragraphs: typedInStyle(id, doc.paragraphs) };
|
|
5281
5425
|
type(id, {
|
|
5282
5426
|
type: "setRichText",
|
|
5283
5427
|
id,
|
|
5284
|
-
doc:
|
|
5428
|
+
doc: kept
|
|
5285
5429
|
});
|
|
5430
|
+
return kept;
|
|
5286
5431
|
},
|
|
5287
5432
|
setTextSelection: (ref, range) => {
|
|
5288
5433
|
const id = annotationKey$1(ref);
|
|
@@ -5314,9 +5459,9 @@ function createAnnotationController(ctx) {
|
|
|
5314
5459
|
const { events, records, view, authority, tools, behaviors, settings } = services;
|
|
5315
5460
|
ctx.state.update(withSnap, settings.get().snap);
|
|
5316
5461
|
ctx.state.update(withEditable, settings.get().editable);
|
|
5317
|
-
settings.api.onSettingsChanged(({ settings: next,
|
|
5318
|
-
if (
|
|
5319
|
-
if (
|
|
5462
|
+
settings.api.onSettingsChanged(({ settings: next, changedKeys }) => {
|
|
5463
|
+
if (changedKeys.includes("snap")) ctx.state.update(withSnap, next.snap);
|
|
5464
|
+
if (changedKeys.includes("editable")) ctx.state.update(withEditable, next.editable);
|
|
5320
5465
|
});
|
|
5321
5466
|
const annotations = createAnnotationReads(ctx, services);
|
|
5322
5467
|
const chrome = createChromeReads(ctx, services);
|
|
@@ -5327,8 +5472,8 @@ function createAnnotationController(ctx) {
|
|
|
5327
5472
|
await text.sendTyping();
|
|
5328
5473
|
await services.store.whenWritten();
|
|
5329
5474
|
};
|
|
5330
|
-
settings.api.onSettingsChanged(({
|
|
5331
|
-
if (!
|
|
5475
|
+
settings.api.onSettingsChanged(({ changedKeys }) => {
|
|
5476
|
+
if (!changedKeys.includes("editable")) return;
|
|
5332
5477
|
const model = services.store.model();
|
|
5333
5478
|
const editing = model.editing === null ? void 0 : model.byId[model.editing];
|
|
5334
5479
|
if (editing && !isContentsEditableByHand(model, editing)) text.text.end();
|
|
@@ -5435,7 +5580,8 @@ const annotationPlugin = (config) => definePlugin({
|
|
|
5435
5580
|
state: initialAnnotationModel,
|
|
5436
5581
|
settings: {
|
|
5437
5582
|
defaults: ANNOTATION_DEFAULTS,
|
|
5438
|
-
registered: config
|
|
5583
|
+
registered: config,
|
|
5584
|
+
whole: ["chrome.marquee"]
|
|
5439
5585
|
},
|
|
5440
5586
|
create: createAnnotationController
|
|
5441
5587
|
});
|