@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.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_contract = require("./contract-
|
|
3
|
-
const require_host_contract = require("./host-contract-
|
|
2
|
+
const require_contract = require("./contract-BtAl3Yo2.cjs");
|
|
3
|
+
const require_host_contract = require("./host-contract-BzM2upsA.cjs");
|
|
4
4
|
require("./authoring.cjs");
|
|
5
5
|
let _embedpdf_core = require("@embedpdf/core");
|
|
6
6
|
let _embedpdf_plugin_actions_contract = require("@embedpdf/plugin-actions/contract");
|
|
@@ -121,9 +121,9 @@ function createComments(ctx, { store, authority, events }, threads, crud) {
|
|
|
121
121
|
const record = store.model().byId[(0, _embedpdf_engine_core_runtime.annotationKey)(ref)];
|
|
122
122
|
return !!record && !(0, _embedpdf_engine_core_runtime.isDimension)(record.annotation) && (0, _embedpdf_core_annotation.annotContentsEditable)(record);
|
|
123
123
|
};
|
|
124
|
-
const announce = (root,
|
|
124
|
+
const announce = (root, type) => events.threadChanged.emit({
|
|
125
125
|
rootRef: root,
|
|
126
|
-
|
|
126
|
+
type
|
|
127
127
|
});
|
|
128
128
|
return { api: { comments: {
|
|
129
129
|
listThreads: () => threads.index().threads,
|
|
@@ -364,12 +364,12 @@ function createPlaceHandler(anno, interaction) {
|
|
|
364
364
|
id: "annotation-place",
|
|
365
365
|
priority: 95,
|
|
366
366
|
enabledFor: (tool) => tool.enables.has("annotation-place") || tool.enables.has("annotation-stamp"),
|
|
367
|
-
|
|
367
|
+
onPointerDown: (sample) => {
|
|
368
368
|
if (!sample.page) return false;
|
|
369
369
|
return anno.placeAt(sample.page.ref, sample.page.point, sample.page.rotation, sample.page.zoom);
|
|
370
370
|
},
|
|
371
|
-
|
|
372
|
-
|
|
371
|
+
onPointerUp: () => anno.clearGhost(),
|
|
372
|
+
onPointerCancel: () => anno.clearGhost(),
|
|
373
373
|
onHover: (sample) => followGhost(anno, interaction, sample)
|
|
374
374
|
};
|
|
375
375
|
}
|
|
@@ -387,9 +387,9 @@ function createEditHandler(anno, interaction) {
|
|
|
387
387
|
priority: 100,
|
|
388
388
|
enabledFor: (tool) => tool.enables.has("annotation-edit"),
|
|
389
389
|
claimsTouch: (sample) => !!sample.page && anno.claimsTouchAt(sample.page.ref, sample.page.point, sample.page.scale, sample.page.rotation, sample.page.zoom),
|
|
390
|
-
|
|
390
|
+
onPointerDown: (sample) => {
|
|
391
391
|
if (!sample.page) return false;
|
|
392
|
-
if (anno.
|
|
392
|
+
if (anno.getDistanceCreationPage?.() != null) return false;
|
|
393
393
|
const touch = sample.pointerType === "touch";
|
|
394
394
|
const wasEditing = anno.getEditingId() != null;
|
|
395
395
|
if (wasEditing) anno.text.end();
|
|
@@ -409,19 +409,19 @@ function createEditHandler(anno, interaction) {
|
|
|
409
409
|
};
|
|
410
410
|
return true;
|
|
411
411
|
},
|
|
412
|
-
|
|
412
|
+
onPointerMove: (sample) => {
|
|
413
413
|
if (!origin) return;
|
|
414
414
|
const point = pointOn(sample, origin.page);
|
|
415
415
|
if (!point) return;
|
|
416
416
|
origin.point = point;
|
|
417
417
|
anno.editPointer("move", origin.page, point, sample.modifiers.shift, sample.page?.scale, sample.page?.rotation, sample.page?.zoom, origin.touch);
|
|
418
418
|
},
|
|
419
|
-
|
|
419
|
+
onPointerUp: (sample) => {
|
|
420
420
|
if (!origin) return;
|
|
421
421
|
anno.editPointer("up", origin.page, pointOn(sample, origin.page) ?? origin.point, false, void 0, void 0, void 0, origin.touch);
|
|
422
422
|
origin = null;
|
|
423
423
|
},
|
|
424
|
-
|
|
424
|
+
onPointerCancel: () => {
|
|
425
425
|
if (!origin) return;
|
|
426
426
|
const { page, downPoint, touch } = origin;
|
|
427
427
|
origin = null;
|
|
@@ -453,7 +453,7 @@ function createMarqueeHandler(anno) {
|
|
|
453
453
|
id: "annotation-marquee",
|
|
454
454
|
priority: 50,
|
|
455
455
|
enabledFor: (tool) => tool.enables.has("annotation-marquee"),
|
|
456
|
-
|
|
456
|
+
onPointerDown: (sample) => {
|
|
457
457
|
if (!sample.page) return false;
|
|
458
458
|
anchor = {
|
|
459
459
|
page: sample.page.ref,
|
|
@@ -474,7 +474,7 @@ function createMarqueeHandler(anno) {
|
|
|
474
474
|
dragging = false;
|
|
475
475
|
return true;
|
|
476
476
|
},
|
|
477
|
-
|
|
477
|
+
onPointerMove: (sample) => {
|
|
478
478
|
if (!anchor) return;
|
|
479
479
|
const point = pointOn(sample, anchor.page);
|
|
480
480
|
if (!point) return;
|
|
@@ -489,13 +489,13 @@ function createMarqueeHandler(anno) {
|
|
|
489
489
|
}
|
|
490
490
|
anno.marqueePointer("move", anchor.page, point, anchor.shift, view.scale, view.rotation, view.zoom);
|
|
491
491
|
},
|
|
492
|
-
|
|
492
|
+
onPointerUp: () => {
|
|
493
493
|
if (dragging && anchor && last) anno.marqueePointer("up", anchor.page, last.point, anchor.shift, view.scale, view.rotation, view.zoom);
|
|
494
494
|
anchor = null;
|
|
495
495
|
last = null;
|
|
496
496
|
dragging = false;
|
|
497
497
|
},
|
|
498
|
-
|
|
498
|
+
onPointerCancel: () => {
|
|
499
499
|
anchor = null;
|
|
500
500
|
last = null;
|
|
501
501
|
dragging = false;
|
|
@@ -534,10 +534,10 @@ function createDrawHandler(anno, interaction, clock, onSettle) {
|
|
|
534
534
|
id: "annotation-draw",
|
|
535
535
|
priority: 55,
|
|
536
536
|
enabledFor: (tool) => tool.enables.has("annotation-draw"),
|
|
537
|
-
|
|
537
|
+
onPointerDown: (sample) => {
|
|
538
538
|
const tool = toolId();
|
|
539
539
|
const st = subtypeOf(tool);
|
|
540
|
-
const distancePage = anno.
|
|
540
|
+
const distancePage = anno.getDistanceCreationPage?.();
|
|
541
541
|
if (distancePage != null) {
|
|
542
542
|
const point = pointOn(sample, distancePage);
|
|
543
543
|
if (point) anno.createPointer(tool, "down", distancePage, point);
|
|
@@ -568,7 +568,7 @@ function createDrawHandler(anno, interaction, clock, onSettle) {
|
|
|
568
568
|
anno.createPointer(tool, "down", sample.page.ref, sample.page.point, false, sample.page.rotation);
|
|
569
569
|
return true;
|
|
570
570
|
},
|
|
571
|
-
|
|
571
|
+
onPointerMove: (sample) => {
|
|
572
572
|
const tool = toolId();
|
|
573
573
|
const st = subtypeOf(tool);
|
|
574
574
|
if (!origin || isPolyTool(st) && !drawingPoly) return;
|
|
@@ -577,7 +577,7 @@ function createDrawHandler(anno, interaction, clock, onSettle) {
|
|
|
577
577
|
origin.point = point;
|
|
578
578
|
anno.createPointer(tool, "move", origin.page, point);
|
|
579
579
|
},
|
|
580
|
-
|
|
580
|
+
onPointerUp: (sample) => {
|
|
581
581
|
const tool = toolId();
|
|
582
582
|
const st = subtypeOf(tool);
|
|
583
583
|
if (origin && !isPolyTool(st)) {
|
|
@@ -597,7 +597,7 @@ function createDrawHandler(anno, interaction, clock, onSettle) {
|
|
|
597
597
|
origin = null;
|
|
598
598
|
anno.clearGhost();
|
|
599
599
|
},
|
|
600
|
-
|
|
600
|
+
onPointerCancel: () => {
|
|
601
601
|
if (pendingInk) {
|
|
602
602
|
pendingInk.cancelWait();
|
|
603
603
|
pendingInk = null;
|
|
@@ -613,7 +613,7 @@ function createDrawHandler(anno, interaction, clock, onSettle) {
|
|
|
613
613
|
followGhost(anno, interaction, sample);
|
|
614
614
|
const tool = toolId();
|
|
615
615
|
const st = subtypeOf(tool);
|
|
616
|
-
const distancePage = anno.
|
|
616
|
+
const distancePage = anno.getDistanceCreationPage?.();
|
|
617
617
|
if (distancePage != null) {
|
|
618
618
|
const point = pointOn(sample, distancePage);
|
|
619
619
|
if (point) anno.createPointer(tool, "move", distancePage, point);
|
|
@@ -1138,7 +1138,8 @@ function createChromeReads(ctx, { store, geometry, behaviors, settings }) {
|
|
|
1138
1138
|
*
|
|
1139
1139
|
* • a flat props patch → the run delta it means for a text range (font,
|
|
1140
1140
|
* size, colour, bold/italic/underline) and the keys left for the body
|
|
1141
|
-
* • what a range reads back for those keys (agree → the value, else mixed)
|
|
1141
|
+
* • what a range reads back for those keys (agree → the value, else mixed),
|
|
1142
|
+
* and a caret: the text typed there next
|
|
1142
1143
|
* • faces: the DTO font a face names
|
|
1143
1144
|
* • the commit rule: a document nothing overrides on a plain annotation
|
|
1144
1145
|
* commits as `contents`; anything else as `richText`
|
|
@@ -1266,11 +1267,24 @@ function runsInRange(doc, range) {
|
|
|
1266
1267
|
}
|
|
1267
1268
|
return out;
|
|
1268
1269
|
}
|
|
1269
|
-
/** The values a range reads back for the range keys
|
|
1270
|
-
* body, one value where every run agrees, `mixed` where they don't. */
|
|
1270
|
+
/** The values a range reads back for the range keys: the runs it covers (`runProps`). */
|
|
1271
1271
|
function rangeProps(doc, range, fonts) {
|
|
1272
|
-
|
|
1273
|
-
|
|
1272
|
+
return runProps(doc.body, runsInRange(doc, range), fonts);
|
|
1273
|
+
}
|
|
1274
|
+
/**
|
|
1275
|
+
* The values a caret reads back for the range keys: the text typed there
|
|
1276
|
+
* next, in the style of the text before it (`styleAt`) with the style chosen
|
|
1277
|
+
* at the caret over it.
|
|
1278
|
+
*/
|
|
1279
|
+
function caretProps(doc, at, typing, fonts) {
|
|
1280
|
+
return runProps(doc.body, [{
|
|
1281
|
+
...(0, _embedpdf_core_annotation.styleAt)(doc, at),
|
|
1282
|
+
...typing
|
|
1283
|
+
}], fonts);
|
|
1284
|
+
}
|
|
1285
|
+
/** The values runs read back for the range keys: resolved against the
|
|
1286
|
+
* body, one value where every run agrees, `mixed` where they don't. */
|
|
1287
|
+
function runProps(body, runs, fonts) {
|
|
1274
1288
|
const resolve = (delta) => ({
|
|
1275
1289
|
family: delta.family ?? body.family,
|
|
1276
1290
|
weight: delta.weight ?? body.weight,
|
|
@@ -1349,12 +1363,24 @@ function propertyValues(properties, sources) {
|
|
|
1349
1363
|
* selection of frozen annotations has nothing to restyle.
|
|
1350
1364
|
*/
|
|
1351
1365
|
function createPropertyReads(ctx, { store, fonts }) {
|
|
1366
|
+
/** The editor's selection inside the annotation being edited, or null (no
|
|
1367
|
+
* editor selection, or one left behind by a previous edit). */
|
|
1368
|
+
const editorSelection = (model) => {
|
|
1369
|
+
const ts = ctx.state.get().textSelection;
|
|
1370
|
+
return ts && model.editing === ts.id && model.byId[ts.id] ? ts : null;
|
|
1371
|
+
};
|
|
1352
1372
|
/** The editor's text range inside the annotation being edited, or null
|
|
1353
|
-
* (no editor selection, a bare caret
|
|
1354
|
-
*
|
|
1373
|
+
* (no editor selection, or a bare caret). The one condition that routes
|
|
1374
|
+
* the range properties to runs. */
|
|
1355
1375
|
const activeTextRange = (model) => {
|
|
1356
|
-
const ts =
|
|
1357
|
-
return ts &&
|
|
1376
|
+
const ts = editorSelection(model);
|
|
1377
|
+
return ts && ts.end > ts.start ? ts : null;
|
|
1378
|
+
};
|
|
1379
|
+
/** The editor's caret inside the annotation being edited, or null. The
|
|
1380
|
+
* range properties there are the text typed next. */
|
|
1381
|
+
const activeCaret = (model) => {
|
|
1382
|
+
const ts = editorSelection(model);
|
|
1383
|
+
return ts && ts.end === ts.start ? ts : null;
|
|
1358
1384
|
};
|
|
1359
1385
|
/** What a panel reads of one member: its fields, its text as shown, and its link. */
|
|
1360
1386
|
const sourcesOf = (model, record) => {
|
|
@@ -1366,29 +1392,42 @@ function createPropertyReads(ctx, { store, fonts }) {
|
|
|
1366
1392
|
link: annotation.subtype === "link" ? annotation.target ?? null : (0, _embedpdf_core_annotation.linkOf)(model, record.id)
|
|
1367
1393
|
};
|
|
1368
1394
|
};
|
|
1395
|
+
/**
|
|
1396
|
+
* What a free text's range properties read: the text the next change
|
|
1397
|
+
* styles. The editor's range, the text typed next at its caret, else all of
|
|
1398
|
+
* the box's text. `null` for any other kind.
|
|
1399
|
+
*/
|
|
1400
|
+
const textPropsOf = (model, record) => {
|
|
1401
|
+
if (record.annotation.subtype !== "free-text") return null;
|
|
1402
|
+
const doc = (0, _embedpdf_core_annotation.richDocOf)(record.annotation, fonts);
|
|
1403
|
+
const ts = editorSelection(model);
|
|
1404
|
+
if (ts?.id !== record.id) return rangeProps(doc, {
|
|
1405
|
+
start: 0,
|
|
1406
|
+
end: (0, _embedpdf_core_annotation.richTextLength)(doc)
|
|
1407
|
+
}, fonts);
|
|
1408
|
+
if (ts.end > ts.start) return rangeProps(doc, ts, fonts);
|
|
1409
|
+
return caretProps(doc, ts.start, ts.typing, fonts);
|
|
1410
|
+
};
|
|
1369
1411
|
let cache = null;
|
|
1370
1412
|
const selectionPropertiesOf = () => {
|
|
1371
1413
|
const model = store.model();
|
|
1372
|
-
const
|
|
1373
|
-
if (cache && cache.model === model && cache.
|
|
1414
|
+
const selection = editorSelection(model);
|
|
1415
|
+
if (cache && cache.model === model && cache.selection === selection) return cache.v;
|
|
1374
1416
|
const members = model.selected.map((id) => model.byId[id]).filter((record) => !!record && (0, _embedpdf_core_annotation.isEditableByHand)(model, record.annotation));
|
|
1375
|
-
const properties = (0, _embedpdf_core_annotation.
|
|
1417
|
+
const properties = (0, _embedpdf_core_annotation.selectionProperties)(model, members.map((record) => record.annotation));
|
|
1376
1418
|
const sources = members.map((record) => sourcesOf(model, record));
|
|
1419
|
+
const texts = members.map((record) => textPropsOf(model, record));
|
|
1420
|
+
const valueOf = (spec, index) => {
|
|
1421
|
+
const text = texts[index];
|
|
1422
|
+
return text && RANGE_KEYS.includes(spec.key) ? text.values[spec.key] : propertyValue(spec, sources[index]);
|
|
1423
|
+
};
|
|
1377
1424
|
const values = sources.length ? propertyValues(properties, sources[0]) : {};
|
|
1378
1425
|
const mixed = [];
|
|
1379
1426
|
for (const spec of properties) {
|
|
1380
|
-
const
|
|
1381
|
-
if (
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
const rp = rangeProps((0, _embedpdf_core_annotation.richDocOf)(members[0].annotation, fonts), range, fonts);
|
|
1385
|
-
for (const spec of properties) {
|
|
1386
|
-
if (!RANGE_KEYS.includes(spec.key)) continue;
|
|
1387
|
-
values[spec.key] = rp.values[spec.key];
|
|
1388
|
-
const index = mixed.indexOf(spec.key);
|
|
1389
|
-
if (index >= 0) mixed.splice(index, 1);
|
|
1390
|
-
if (rp.mixed.includes(spec.key)) mixed.push(spec.key);
|
|
1391
|
-
}
|
|
1427
|
+
const ofText = RANGE_KEYS.includes(spec.key);
|
|
1428
|
+
if (ofText && texts[0]) values[spec.key] = texts[0].values[spec.key];
|
|
1429
|
+
const first = JSON.stringify(valueOf(spec, 0));
|
|
1430
|
+
if (sources.some((_, index) => JSON.stringify(valueOf(spec, index)) !== first) || ofText && texts.some((text) => text?.mixed.includes(spec.key))) mixed.push(spec.key);
|
|
1392
1431
|
}
|
|
1393
1432
|
const result = {
|
|
1394
1433
|
properties,
|
|
@@ -1397,13 +1436,14 @@ function createPropertyReads(ctx, { store, fonts }) {
|
|
|
1397
1436
|
};
|
|
1398
1437
|
cache = {
|
|
1399
1438
|
model,
|
|
1400
|
-
|
|
1439
|
+
selection,
|
|
1401
1440
|
v: result
|
|
1402
1441
|
};
|
|
1403
1442
|
return result;
|
|
1404
1443
|
};
|
|
1405
1444
|
return {
|
|
1406
1445
|
activeTextRange,
|
|
1446
|
+
activeCaret,
|
|
1407
1447
|
selectionPropertiesOf
|
|
1408
1448
|
};
|
|
1409
1449
|
}
|
|
@@ -1672,7 +1712,7 @@ function createRenderReads(ctx, { view: { pageModel }, lending, fonts: fontLooku
|
|
|
1672
1712
|
return {
|
|
1673
1713
|
engine,
|
|
1674
1714
|
placed: placed.sort().join("|"),
|
|
1675
|
-
lent: lentShown && lender ? `lent:${lender.
|
|
1715
|
+
lent: lentShown && lender ? `lent:${lender.getPictureEpoch(page)}` : ""
|
|
1676
1716
|
};
|
|
1677
1717
|
};
|
|
1678
1718
|
/** The lender's pictures of its records on `page`, in every state, at their picture versions. */
|
|
@@ -1697,7 +1737,7 @@ function createRenderReads(ctx, { view: { pageModel }, lending, fonts: fontLooku
|
|
|
1697
1737
|
/** The family whose pictures a record's are: the lender's widgets, or annotations. */
|
|
1698
1738
|
const familyOf = (id) => lending.owns(id) ? "widgets" : "annotations";
|
|
1699
1739
|
/** The engine's last pictures of a record, kept a while after it left its page. */
|
|
1700
|
-
const keptOf = (id, ref) => ctx.tryGet(_embedpdf_plugin_render_contract_host.RenderToken)?.
|
|
1740
|
+
const keptOf = (id, ref) => ctx.tryGet(_embedpdf_plugin_render_contract_host.RenderToken)?.getKeptAppearances(familyOf(id), ref) ?? [];
|
|
1701
1741
|
/**
|
|
1702
1742
|
* The pictures of what shows on `page` that the engine hasn't written yet:
|
|
1703
1743
|
* a stamp this session placed shows its preview, at the size the page shows
|
|
@@ -1898,16 +1938,16 @@ function createView(ctx, records, lending) {
|
|
|
1898
1938
|
...(0, _embedpdf_core_annotation.fromDTO)(shown),
|
|
1899
1939
|
unconfirmed: true,
|
|
1900
1940
|
source: confirmedOnce.has((0, _embedpdf_engine_core_runtime.annotationKey)(shown.ref)) ? "baked" : "vector",
|
|
1901
|
-
pictureVersion: lender.
|
|
1902
|
-
authority: lender.
|
|
1941
|
+
pictureVersion: lender.getPictureVersion(shown.ref),
|
|
1942
|
+
authority: lender.getAuthority(shown),
|
|
1903
1943
|
...painterOf(shown, lender)
|
|
1904
1944
|
};
|
|
1905
1945
|
else {
|
|
1906
1946
|
const base = {
|
|
1907
1947
|
...(0, _embedpdf_core_annotation.fromDTO)(truth),
|
|
1908
1948
|
source: (0, _embedpdf_core_annotation.sourceOfConfirmed)(truth, false),
|
|
1909
|
-
pictureVersion: lender.
|
|
1910
|
-
authority: lender.
|
|
1949
|
+
pictureVersion: lender.getPictureVersion(truth.ref),
|
|
1950
|
+
authority: lender.getAuthority(truth),
|
|
1911
1951
|
...painterOf(shown, lender)
|
|
1912
1952
|
};
|
|
1913
1953
|
const patch = {
|
|
@@ -1919,7 +1959,7 @@ function createView(ctx, records, lending) {
|
|
|
1919
1959
|
annotation: shown,
|
|
1920
1960
|
...(0, _embedpdf_core_annotation.drawnAfter)(base, patch)
|
|
1921
1961
|
};
|
|
1922
|
-
if (lender.
|
|
1962
|
+
if (lender.isPending(shown.ref) && (0, _embedpdf_core_annotation.drawsLive)(record)) record = {
|
|
1923
1963
|
...record,
|
|
1924
1964
|
source: "vector"
|
|
1925
1965
|
};
|
|
@@ -2593,7 +2633,7 @@ function createRecordsMirror(ctx, events) {
|
|
|
2593
2633
|
const list = await doc.annotations.list();
|
|
2594
2634
|
return {
|
|
2595
2635
|
value: fromSnapshot(records.get(), list.annotations),
|
|
2596
|
-
cursor: list.auditHead
|
|
2636
|
+
cursor: list.auditHead
|
|
2597
2637
|
};
|
|
2598
2638
|
},
|
|
2599
2639
|
fold: foldRecords,
|
|
@@ -2604,7 +2644,7 @@ function createRecordsMirror(ctx, events) {
|
|
|
2604
2644
|
const { annotations } = reading.length ? await doc.annotations.list({ pages: reading }) : { annotations: [] };
|
|
2605
2645
|
return (current) => withPages(current, pages, annotations);
|
|
2606
2646
|
},
|
|
2607
|
-
|
|
2647
|
+
onChanged: (change) => events.recordsChanged.emit(change)
|
|
2608
2648
|
});
|
|
2609
2649
|
return records;
|
|
2610
2650
|
}
|
|
@@ -3084,8 +3124,10 @@ function createStore(ctx, view, records, events, lending) {
|
|
|
3084
3124
|
* program the engine writes with. A box someone types in is resolved the way
|
|
3085
3125
|
* its write will be (the fonts plugin's `resolve`, with the box, so its own
|
|
3086
3126
|
* font counts): when the edit starts, and again after a pause in typing once
|
|
3087
|
-
* the text has a character it wasn't resolved with.
|
|
3088
|
-
*
|
|
3127
|
+
* the text has a character it wasn't resolved with. An answer holds for the
|
|
3128
|
+
* faces it was asked about: a box restyled since (another font, a bold word)
|
|
3129
|
+
* is asked again, and drawn in the fonts its names say until it is answered.
|
|
3130
|
+
* Any other box is drawn in the fonts its names say. Without the fonts plugin, a box is drawn in the
|
|
3089
3131
|
* standard font the engine falls back to for its font or face, in that
|
|
3090
3132
|
* font's built-in program (`@embedpdf/core-fonts`).
|
|
3091
3133
|
*/
|
|
@@ -3099,13 +3141,16 @@ const codePointsOf = (text) => Array.from(text, (char) => char.codePointAt(0));
|
|
|
3099
3141
|
function createTextFonts(ctx, store, lookup) {
|
|
3100
3142
|
const fonts = () => ctx.tryGet(_embedpdf_plugin_fonts_contract.FontsToken);
|
|
3101
3143
|
/**
|
|
3102
|
-
* What the engine answered per box: the
|
|
3103
|
-
*
|
|
3144
|
+
* What the engine answered per box: the faces it was asked about, the record it was asked for
|
|
3145
|
+
* (a newer one with the same faces keeps the answer), and the run each face drew in, its CSS
|
|
3146
|
+
* asked for on each read (it changes as the programs reach the browser).
|
|
3104
3147
|
*/
|
|
3105
3148
|
const answers = /* @__PURE__ */ new Map();
|
|
3106
3149
|
/** The box being typed in, and the characters its last resolve asked about. */
|
|
3150
|
+
let editing = null;
|
|
3107
3151
|
let asked = null;
|
|
3108
|
-
|
|
3152
|
+
/** Each box's resolve in flight: a newer one for the same box replaces it. */
|
|
3153
|
+
const resolving = /* @__PURE__ */ new Map();
|
|
3109
3154
|
let cancelPause = () => {};
|
|
3110
3155
|
let answered = 0;
|
|
3111
3156
|
let token = {
|
|
@@ -3118,13 +3163,13 @@ function createTextFonts(ctx, store, lookup) {
|
|
|
3118
3163
|
const face = (0, _embedpdf_engine_core_runtime.faceForFontName)(style.fontFamily, (key) => lookup().find((font) => font.key === key));
|
|
3119
3164
|
return (face.weight ?? 400) === body.weight && (face.italic ?? false) === body.italic;
|
|
3120
3165
|
};
|
|
3121
|
-
/**
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3166
|
+
/**
|
|
3167
|
+
* What the engine is asked about a box's text: the body first, then every run, unstyled ones by
|
|
3168
|
+
* the box's font, the rest by face; `faces` names the faces asked, whatever the text.
|
|
3169
|
+
*/
|
|
3170
|
+
const questionOf = (record) => {
|
|
3171
|
+
const style = (0, _embedpdf_core_annotation.textOf)(record.annotation);
|
|
3172
|
+
if (!style || record.annotation.subtype !== "free-text") return null;
|
|
3128
3173
|
const doc = (0, _embedpdf_core_annotation.richDocOf)(record.annotation, lookup);
|
|
3129
3174
|
const body = doc.body;
|
|
3130
3175
|
const faces = [BODY];
|
|
@@ -3152,32 +3197,85 @@ function createTextFonts(ctx, store, lookup) {
|
|
|
3152
3197
|
...face
|
|
3153
3198
|
});
|
|
3154
3199
|
}
|
|
3155
|
-
|
|
3200
|
+
const key = JSON.stringify({
|
|
3201
|
+
body: runs[0],
|
|
3202
|
+
faces: [...new Set(faces)].sort()
|
|
3203
|
+
});
|
|
3204
|
+
return {
|
|
3205
|
+
body,
|
|
3206
|
+
runs,
|
|
3207
|
+
faces,
|
|
3208
|
+
text,
|
|
3209
|
+
key
|
|
3210
|
+
};
|
|
3211
|
+
};
|
|
3212
|
+
/** Ask the engine what the box's text will be drawn in, and keep the answer. */
|
|
3213
|
+
const resolveBox = async (id) => {
|
|
3214
|
+
const api = fonts();
|
|
3215
|
+
const record = store.model().byId[id];
|
|
3216
|
+
const question = api && record && questionOf(record);
|
|
3217
|
+
if (!api || !record || !question) return;
|
|
3218
|
+
const { body, runs, faces, text, key } = question;
|
|
3219
|
+
const ref = (0, _embedpdf_core_annotation.refOf)(record) ?? void 0;
|
|
3220
|
+
if (id === editing) asked = {
|
|
3156
3221
|
id,
|
|
3157
3222
|
codePoints: new Set(codePointsOf(text))
|
|
3158
3223
|
};
|
|
3159
|
-
resolving?.abort();
|
|
3224
|
+
resolving.get(id)?.abort();
|
|
3160
3225
|
const request = new AbortController();
|
|
3161
|
-
resolving
|
|
3226
|
+
resolving.set(id, request);
|
|
3162
3227
|
try {
|
|
3163
3228
|
await api.ensureLoaded();
|
|
3164
3229
|
const answer = await api.resolve({
|
|
3165
3230
|
...ref ? { annotation: ref } : {},
|
|
3166
3231
|
runs
|
|
3167
3232
|
}, { signal: request.signal });
|
|
3168
|
-
if (resolving !== request) return;
|
|
3233
|
+
if (resolving.get(id) !== request) return;
|
|
3234
|
+
resolving.delete(id);
|
|
3169
3235
|
const byFace = /* @__PURE__ */ new Map();
|
|
3170
3236
|
answer.runs.forEach((run, index) => {
|
|
3171
3237
|
const face = faces[index];
|
|
3172
3238
|
if (!byFace.has(face)) byFace.set(face, run);
|
|
3173
3239
|
});
|
|
3174
3240
|
if (!byFace.has(faceKey(body))) byFace.set(faceKey(body), byFace.get(BODY));
|
|
3175
|
-
answers.set(id,
|
|
3241
|
+
answers.set(id, {
|
|
3242
|
+
faces: key,
|
|
3243
|
+
record,
|
|
3244
|
+
byFace
|
|
3245
|
+
});
|
|
3176
3246
|
answered++;
|
|
3177
3247
|
ctx.notify();
|
|
3178
3248
|
} catch {}
|
|
3179
3249
|
};
|
|
3180
|
-
|
|
3250
|
+
/**
|
|
3251
|
+
* Drop the answers the model moved on from: a box deleted, or restyled so its faces aren't the
|
|
3252
|
+
* ones asked about, which is asked again (typing keeps the faces, and the answer). The model is
|
|
3253
|
+
* watched, not this plugin's state: a change that shows before the engine answers it, as a
|
|
3254
|
+
* format on a whole box does, changes the view alone.
|
|
3255
|
+
*/
|
|
3256
|
+
const dropStaleAnswers = (model) => {
|
|
3257
|
+
let dropped = false;
|
|
3258
|
+
for (const [id, answer] of answers) {
|
|
3259
|
+
const record = model.byId[id];
|
|
3260
|
+
if (record === answer.record) continue;
|
|
3261
|
+
const question = record && questionOf(record);
|
|
3262
|
+
if (question && question.key === answer.faces) {
|
|
3263
|
+
answers.set(id, {
|
|
3264
|
+
...answer,
|
|
3265
|
+
record
|
|
3266
|
+
});
|
|
3267
|
+
continue;
|
|
3268
|
+
}
|
|
3269
|
+
answers.delete(id);
|
|
3270
|
+
dropped = true;
|
|
3271
|
+
if (question) resolveBox(id);
|
|
3272
|
+
}
|
|
3273
|
+
if (dropped) {
|
|
3274
|
+
answered++;
|
|
3275
|
+
ctx.notify();
|
|
3276
|
+
}
|
|
3277
|
+
};
|
|
3278
|
+
ctx.watch(store.model, dropStaleAnswers);
|
|
3181
3279
|
ctx.state.onChange(() => {
|
|
3182
3280
|
const next = store.model().editing;
|
|
3183
3281
|
if (next === editing) return;
|
|
@@ -3190,15 +3288,15 @@ function createTextFonts(ctx, store, lookup) {
|
|
|
3190
3288
|
bodyCss: (id, style, body) => {
|
|
3191
3289
|
const api = fonts();
|
|
3192
3290
|
const byFont = bodyIsItsFont(style, body);
|
|
3193
|
-
if (!api) return (0, _embedpdf_core_fonts.standardFontCss)(byFont ? (0, _embedpdf_core_fonts.standardFontOf)(style.fontFamily) : (0,
|
|
3194
|
-
const run = answers.get(id)?.get(BODY);
|
|
3291
|
+
if (!api) return (0, _embedpdf_core_fonts.standardFontCss)(byFont ? (0, _embedpdf_core_fonts.standardFontOf)(style.fontFamily) : (0, _embedpdf_engine_core_runtime.standardFontForFace)(body));
|
|
3292
|
+
const run = answers.get(id)?.byFace.get(BODY);
|
|
3195
3293
|
if (run) return api.getRunCss(run);
|
|
3196
3294
|
return byFont ? api.getFontCss(style.fontFamily) : api.getFaceCss(body);
|
|
3197
3295
|
},
|
|
3198
3296
|
faceCss: (id, face) => {
|
|
3199
3297
|
const api = fonts();
|
|
3200
|
-
if (!api) return (0, _embedpdf_core_fonts.standardFontCss)((0,
|
|
3201
|
-
const run = id !== null ? answers.get(id)?.get(faceKey(face)) : void 0;
|
|
3298
|
+
if (!api) return (0, _embedpdf_core_fonts.standardFontCss)((0, _embedpdf_engine_core_runtime.standardFontForFace)(face));
|
|
3299
|
+
const run = id !== null ? answers.get(id)?.byFace.get(faceKey(face)) : void 0;
|
|
3202
3300
|
return run ? api.getRunCss(run) : api.getFaceCss(face);
|
|
3203
3301
|
},
|
|
3204
3302
|
familyOfCss: (cssFamily) => {
|
|
@@ -3633,13 +3731,13 @@ const annotationOfTool = (model, tool) => ({
|
|
|
3633
3731
|
* size, hanging from its rect's upper-left corner. So the placement starts
|
|
3634
3732
|
* from how it shows, the icon centred on the pointer and kept on the page
|
|
3635
3733
|
* (`shown`, what the ghost draws), and stores the rect whose own display is
|
|
3636
|
-
* exactly that (`rect`, through `
|
|
3734
|
+
* exactly that (`rect`, through `unanchoredGeometry`, the inverse gestures use).
|
|
3637
3735
|
* `annotation` is what the tool creates, read for its flags. Without a view
|
|
3638
3736
|
* the two are the same box.
|
|
3639
3737
|
*/
|
|
3640
3738
|
function iconPlaceAt(annotation, point, page, view) {
|
|
3641
3739
|
const mode = (0, _embedpdf_core_annotation.anchorModeOf)({ annotation });
|
|
3642
|
-
const { box: size, rotation } = (0, _embedpdf_core_annotation.
|
|
3740
|
+
const { box: size, rotation } = (0, _embedpdf_core_annotation.anchoredGeometry)({
|
|
3643
3741
|
kind: "box",
|
|
3644
3742
|
box: {
|
|
3645
3743
|
x: 0,
|
|
@@ -3660,7 +3758,7 @@ function iconPlaceAt(annotation, point, page, view) {
|
|
|
3660
3758
|
};
|
|
3661
3759
|
return {
|
|
3662
3760
|
shown,
|
|
3663
|
-
rect: (0, _embedpdf_core_annotation.
|
|
3761
|
+
rect: (0, _embedpdf_core_annotation.unanchoredGeometry)(shown, mode, view).box
|
|
3664
3762
|
};
|
|
3665
3763
|
}
|
|
3666
3764
|
/**
|
|
@@ -4049,7 +4147,7 @@ function createDrafts(ctx, { store, events, tools, afterCreate }, annotations) {
|
|
|
4049
4147
|
cancel: () => {
|
|
4050
4148
|
store.commit({ type: "cancel" });
|
|
4051
4149
|
},
|
|
4052
|
-
|
|
4150
|
+
getDistanceCreationPage: () => {
|
|
4053
4151
|
const draft = store.model().draft;
|
|
4054
4152
|
return draft?.kind === "create-distance" && draft.step === "offset" ? draft.page : null;
|
|
4055
4153
|
},
|
|
@@ -4762,26 +4860,28 @@ function createSelectionWrites(ctx, { store, authority, fonts, behaviors, lendin
|
|
|
4762
4860
|
* member takes the fields its kind has, and the change shows at once, as
|
|
4763
4861
|
* one change. While the text editor holds a range, the font, size, colour
|
|
4764
4862
|
* and formats restyle the runs it covers (a delta over the body, through
|
|
4765
|
-
* the pure run algebra) as part of the typing
|
|
4766
|
-
*
|
|
4767
|
-
* the
|
|
4863
|
+
* the pure run algebra) as part of the typing; at its caret they are the
|
|
4864
|
+
* style of the text typed next, and nothing is written. The rest goes to
|
|
4865
|
+
* the annotation: its change sends the typing first, so the body it writes
|
|
4866
|
+
* is the latest.
|
|
4768
4867
|
*/
|
|
4769
4868
|
const restyle = (patch) => {
|
|
4770
4869
|
const model = store.model();
|
|
4771
|
-
const
|
|
4870
|
+
const editor = properties.activeTextRange(model) ?? properties.activeCaret(model);
|
|
4772
4871
|
const commits = [];
|
|
4773
4872
|
const patches = {};
|
|
4774
4873
|
for (const id of model.selected) {
|
|
4775
4874
|
const record = model.byId[id];
|
|
4776
4875
|
if (!record) continue;
|
|
4777
4876
|
const own = typeof patch === "function" ? patch(record.annotation) : patch;
|
|
4778
|
-
if (
|
|
4877
|
+
if (editor?.id !== id) {
|
|
4779
4878
|
patches[id] = own;
|
|
4780
4879
|
continue;
|
|
4781
4880
|
}
|
|
4782
4881
|
const { delta, rest } = runDeltaForFields(own, fonts);
|
|
4783
|
-
if (Object.keys(delta).length)
|
|
4784
|
-
|
|
4882
|
+
if (Object.keys(delta).length && editor.start === editor.end) text.styleTyping(id, delta);
|
|
4883
|
+
else if (Object.keys(delta).length) {
|
|
4884
|
+
const next = (0, _embedpdf_core_annotation.applyStyleToRange)({ paragraphs: (0, _embedpdf_core_annotation.richDocOf)(record.annotation, fonts).paragraphs }, editor, delta);
|
|
4785
4885
|
commits.push(text.type(id, {
|
|
4786
4886
|
type: "setRichText",
|
|
4787
4887
|
id,
|
|
@@ -4805,12 +4905,15 @@ function createSelectionWrites(ctx, { store, authority, fonts, behaviors, lendin
|
|
|
4805
4905
|
});
|
|
4806
4906
|
};
|
|
4807
4907
|
/**
|
|
4808
|
-
* Bold, italic or underline on or off: the words selected while typing,
|
|
4809
|
-
*
|
|
4908
|
+
* Bold, italic or underline on or off: the words selected while typing, the
|
|
4909
|
+
* text typed next at the caret, or all the text of each selected box once
|
|
4910
|
+
* the text being typed has landed. On, unless all of it already has it.
|
|
4810
4911
|
*/
|
|
4811
4912
|
const toggleFormat = async (format, options = {}) => {
|
|
4812
|
-
const
|
|
4813
|
-
const
|
|
4913
|
+
const { values, mixed } = properties.selectionPropertiesOf();
|
|
4914
|
+
const on = values[format] !== true || mixed.includes(format);
|
|
4915
|
+
const model = store.model();
|
|
4916
|
+
const commits = properties.activeTextRange(model) ?? properties.activeCaret(model) ? restyle({ [format]: on }) : [store.commit({
|
|
4814
4917
|
type: "setTextFormat",
|
|
4815
4918
|
format,
|
|
4816
4919
|
on
|
|
@@ -4819,7 +4922,7 @@ function createSelectionWrites(ctx, { store, authority, fonts, behaviors, lendin
|
|
|
4819
4922
|
};
|
|
4820
4923
|
/** The `selection` noun (its reads come from the property and chrome reads). */
|
|
4821
4924
|
const selection = {
|
|
4822
|
-
|
|
4925
|
+
select: (refs) => refs.length ? select(refs, false) : void store.commit({ type: "deselect" }),
|
|
4823
4926
|
add: (refs) => select(refs, true),
|
|
4824
4927
|
selectAll: (page) => {
|
|
4825
4928
|
const only = page === void 0 ? null : ctx.getPage(page);
|
|
@@ -4848,7 +4951,7 @@ function createSelectionWrites(ctx, { store, authority, fonts, behaviors, lendin
|
|
|
4848
4951
|
clear: () => {
|
|
4849
4952
|
store.commit({ type: "deselect" });
|
|
4850
4953
|
},
|
|
4851
|
-
|
|
4954
|
+
getSelected: () => annotations.listSelected(),
|
|
4852
4955
|
update: (changes, options = {}) => commitOverSelection(() => restyle(changes), options.signal),
|
|
4853
4956
|
updateLink: (target, options = {}) => commitOverSelection(() => [store.commit({
|
|
4854
4957
|
type: "setLink",
|
|
@@ -5186,7 +5289,8 @@ function createStamps(ctx, { store, geometry, tools, filePicker, afterCreate })
|
|
|
5186
5289
|
* hold): the view shows the text at once, and the change keeps its place in
|
|
5187
5290
|
* line holding the latest text. It is sent after a pause in typing, when
|
|
5188
5291
|
* editing ends, when anything else is staged, and before a download; what is
|
|
5189
|
-
* typed after that goes into a new one.
|
|
5292
|
+
* typed after that goes into a new one. A style chosen at the caret waits in
|
|
5293
|
+
* the editor's selection for the text typed there next.
|
|
5190
5294
|
*/
|
|
5191
5295
|
const TEXT_WRITE_DELAY_MS = 250;
|
|
5192
5296
|
function createTextEditing(ctx, { store, fonts, textFonts }, chrome) {
|
|
@@ -5223,6 +5327,44 @@ function createTextEditing(ctx, { store, fonts, textFonts }, chrome) {
|
|
|
5223
5327
|
});
|
|
5224
5328
|
return commit;
|
|
5225
5329
|
};
|
|
5330
|
+
/**
|
|
5331
|
+
* The style the text typed next at the caret in box `id` takes, over what
|
|
5332
|
+
* was chosen there already. Nothing is written until it is typed.
|
|
5333
|
+
*/
|
|
5334
|
+
const styleTyping = (id, style) => {
|
|
5335
|
+
const selection = ctx.state.get().textSelection;
|
|
5336
|
+
if (selection?.id !== id || selection.start !== selection.end) return;
|
|
5337
|
+
ctx.state.update(setTextSelection, {
|
|
5338
|
+
...selection,
|
|
5339
|
+
typing: {
|
|
5340
|
+
...selection.typing,
|
|
5341
|
+
...style
|
|
5342
|
+
}
|
|
5343
|
+
});
|
|
5344
|
+
};
|
|
5345
|
+
/**
|
|
5346
|
+
* The paragraphs typed into box `id`, the text typed at the caret in the
|
|
5347
|
+
* style chosen there (`typeWithStyle`), and the caret where the typing
|
|
5348
|
+
* leaves it. Any other edit drops the style.
|
|
5349
|
+
*/
|
|
5350
|
+
const typedInStyle = (id, paragraphs) => {
|
|
5351
|
+
const selection = ctx.state.get().textSelection;
|
|
5352
|
+
const record = store.model().byId[id];
|
|
5353
|
+
if (!selection?.typing || selection.id !== id || !record) return paragraphs;
|
|
5354
|
+
const typed = (0, _embedpdf_core_annotation.typeWithStyle)((0, _embedpdf_core_annotation.richDocOf)(record.annotation, fonts), { paragraphs }, selection.start, selection.typing);
|
|
5355
|
+
const caret = typed ? {
|
|
5356
|
+
id,
|
|
5357
|
+
start: typed.caret,
|
|
5358
|
+
end: typed.caret,
|
|
5359
|
+
...typed.style && { typing: typed.style }
|
|
5360
|
+
} : {
|
|
5361
|
+
id,
|
|
5362
|
+
start: selection.start,
|
|
5363
|
+
end: selection.end
|
|
5364
|
+
};
|
|
5365
|
+
ctx.state.update(setTextSelection, caret);
|
|
5366
|
+
return typed?.doc.paragraphs ?? paragraphs;
|
|
5367
|
+
};
|
|
5226
5368
|
store.onEffect("text", (effect, model) => {
|
|
5227
5369
|
const record = model.byId[effect.id];
|
|
5228
5370
|
const ref = (0, _embedpdf_core_annotation.refOf)(record);
|
|
@@ -5238,6 +5380,7 @@ function createTextEditing(ctx, { store, fonts, textFonts }, chrome) {
|
|
|
5238
5380
|
});
|
|
5239
5381
|
return {
|
|
5240
5382
|
type,
|
|
5383
|
+
styleTyping,
|
|
5241
5384
|
sendTyping,
|
|
5242
5385
|
text: {
|
|
5243
5386
|
begin: (ref) => {
|
|
@@ -5280,11 +5423,13 @@ function createTextEditing(ctx, { store, fonts, textFonts }, chrome) {
|
|
|
5280
5423
|
},
|
|
5281
5424
|
draftRichText: (ref, doc) => {
|
|
5282
5425
|
const id = (0, _embedpdf_engine_core_runtime.annotationKey)(ref);
|
|
5426
|
+
const kept = { paragraphs: typedInStyle(id, doc.paragraphs) };
|
|
5283
5427
|
type(id, {
|
|
5284
5428
|
type: "setRichText",
|
|
5285
5429
|
id,
|
|
5286
|
-
doc:
|
|
5430
|
+
doc: kept
|
|
5287
5431
|
});
|
|
5432
|
+
return kept;
|
|
5288
5433
|
},
|
|
5289
5434
|
setTextSelection: (ref, range) => {
|
|
5290
5435
|
const id = (0, _embedpdf_engine_core_runtime.annotationKey)(ref);
|
|
@@ -5316,9 +5461,9 @@ function createAnnotationController(ctx) {
|
|
|
5316
5461
|
const { events, records, view, authority, tools, behaviors, settings } = services;
|
|
5317
5462
|
ctx.state.update(withSnap, settings.get().snap);
|
|
5318
5463
|
ctx.state.update(withEditable, settings.get().editable);
|
|
5319
|
-
settings.api.onSettingsChanged(({ settings: next,
|
|
5320
|
-
if (
|
|
5321
|
-
if (
|
|
5464
|
+
settings.api.onSettingsChanged(({ settings: next, changedKeys }) => {
|
|
5465
|
+
if (changedKeys.includes("snap")) ctx.state.update(withSnap, next.snap);
|
|
5466
|
+
if (changedKeys.includes("editable")) ctx.state.update(withEditable, next.editable);
|
|
5322
5467
|
});
|
|
5323
5468
|
const annotations = createAnnotationReads(ctx, services);
|
|
5324
5469
|
const chrome = createChromeReads(ctx, services);
|
|
@@ -5329,8 +5474,8 @@ function createAnnotationController(ctx) {
|
|
|
5329
5474
|
await text.sendTyping();
|
|
5330
5475
|
await services.store.whenWritten();
|
|
5331
5476
|
};
|
|
5332
|
-
settings.api.onSettingsChanged(({
|
|
5333
|
-
if (!
|
|
5477
|
+
settings.api.onSettingsChanged(({ changedKeys }) => {
|
|
5478
|
+
if (!changedKeys.includes("editable")) return;
|
|
5334
5479
|
const model = services.store.model();
|
|
5335
5480
|
const editing = model.editing === null ? void 0 : model.byId[model.editing];
|
|
5336
5481
|
if (editing && !(0, _embedpdf_core_annotation.isContentsEditableByHand)(model, editing)) text.text.end();
|
|
@@ -5437,7 +5582,8 @@ const annotationPlugin = (config) => (0, _embedpdf_core.definePlugin)({
|
|
|
5437
5582
|
state: initialAnnotationModel,
|
|
5438
5583
|
settings: {
|
|
5439
5584
|
defaults: require_contract.ANNOTATION_DEFAULTS,
|
|
5440
|
-
registered: config
|
|
5585
|
+
registered: config,
|
|
5586
|
+
whole: ["chrome.marquee"]
|
|
5441
5587
|
},
|
|
5442
5588
|
create: createAnnotationController
|
|
5443
5589
|
});
|