@manifest-editor/creators 1.3.0 → 1.3.1

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/index.js CHANGED
@@ -1,6 +1,9 @@
1
1
  import {
2
2
  ManifestBrowserCreatorForm
3
- } from "./chunk-7FSKLOVQ.js";
3
+ } from "./chunk-KLSWX2QF.js";
4
+
5
+ // src/Annotation/AudioAnnotation/index.tsx
6
+ import { AudioIcon } from "@manifest-editor/components";
4
7
 
5
8
  // src/Annotation/AudioAnnotation/create-audio-annotation.tsx
6
9
  import { useEffect as useEffect2, useState as useState2 } from "react";
@@ -289,7 +292,13 @@ function MediaControls(props) {
289
292
  // src/Annotation/AudioAnnotation/create-audio-annotation.tsx
290
293
  import { CanvasPanel } from "react-iiif-vault";
291
294
  import { getValue } from "@iiif/helpers";
292
- import { Input, InputContainer, InputLabel, LanguageFieldEditor, FormFieldWrapper } from "@manifest-editor/editors";
295
+ import {
296
+ Input,
297
+ InputContainer,
298
+ InputLabel,
299
+ LanguageFieldEditor,
300
+ FormFieldWrapper
301
+ } from "@manifest-editor/editors";
293
302
 
294
303
  // ../ui/atoms/Button.tsx
295
304
  import styled4 from "styled-components";
@@ -397,12 +406,18 @@ async function createAudioAnnotation(data, ctx) {
397
406
  }
398
407
  if (targetType === "Canvas") {
399
408
  const canvasId = ctx.generateId("canvas");
400
- const pageId = ctx.generateId("annotation-page", { id: canvasId, type: "Canvas" });
409
+ const pageId = ctx.generateId("annotation-page", {
410
+ id: canvasId,
411
+ type: "Canvas"
412
+ });
401
413
  const annotationResource = ctx.embed({
402
414
  ...annotation,
403
415
  motivation: "painting",
404
416
  body,
405
- target: { type: "SpecificResource", source: { id: canvasId, type: "Canvas" } }
417
+ target: {
418
+ type: "SpecificResource",
419
+ source: { id: canvasId, type: "Canvas" }
420
+ }
406
421
  });
407
422
  const page = ctx.embed({
408
423
  id: pageId,
@@ -442,7 +457,15 @@ function CreateAudioAnnotationForm(props) {
442
457
  error ? /* @__PURE__ */ jsx4(ErrorMessage, { children: error }) : null,
443
458
  /* @__PURE__ */ jsxs4(InputContainer, { children: [
444
459
  /* @__PURE__ */ jsx4(InputLabel, { htmlFor: "audio-url", children: "URL" }),
445
- /* @__PURE__ */ jsx4(Input, { type: "text", id: "audio-url", value: url, onChange: (e) => setUrl(e.target.value) })
460
+ /* @__PURE__ */ jsx4(
461
+ Input,
462
+ {
463
+ type: "text",
464
+ id: "audio-url",
465
+ value: url,
466
+ onChange: (e) => setUrl(e.target.value)
467
+ }
468
+ )
446
469
  ] }),
447
470
  url && !error ? /* @__PURE__ */ jsx4("div", { children: /* @__PURE__ */ jsx4(
448
471
  LanguageFieldEditor,
@@ -455,24 +478,38 @@ function CreateAudioAnnotationForm(props) {
455
478
  },
456
479
  url + "__" + duration
457
480
  ) }) : null,
458
- url && !error ? /* @__PURE__ */ jsx4(CanvasPanel.AudioHTML, { media: { url, duration, type: "Sound" }, children: /* @__PURE__ */ jsx4(
459
- MediaControls,
481
+ url && !error ? /* @__PURE__ */ jsx4(
482
+ CanvasPanel.AudioHTML,
460
483
  {
461
- onError: (error2) => setError(error2),
462
- onDuration: (duration2) => setDuration(duration2)
484
+ media: { url, duration, type: "Sound" },
485
+ children: /* @__PURE__ */ jsx4(
486
+ MediaControls,
487
+ {
488
+ onError: (error2) => setError(error2),
489
+ onDuration: (duration2) => setDuration(duration2)
490
+ },
491
+ url + "__" + duration
492
+ )
463
493
  },
464
494
  url + "__" + duration
465
- ) }, url + "__" + duration) : null,
495
+ ) : null,
466
496
  duration && !error ? /* @__PURE__ */ jsxs4(FormFieldWrapper, { children: [
467
497
  /* @__PURE__ */ jsx4(InputLabel, { htmlFor: "duration", children: "Duration" }),
468
- /* @__PURE__ */ jsx4(Input, { type: "number", id: "duration", value: duration, onChange: (e) => setDuration(e.target.valueAsNumber) })
498
+ /* @__PURE__ */ jsx4(
499
+ Input,
500
+ {
501
+ type: "number",
502
+ id: "duration",
503
+ value: duration,
504
+ onChange: (e) => setDuration(e.target.valueAsNumber)
505
+ }
506
+ )
469
507
  ] }) : null,
470
508
  url && !error && /* @__PURE__ */ jsx4(Button, { onClick: onSubmit, children: "Add audio" })
471
509
  ] });
472
510
  }
473
511
 
474
512
  // src/Annotation/AudioAnnotation/index.tsx
475
- import { AudioIcon } from "@manifest-editor/components";
476
513
  import { jsx as jsx5 } from "react/jsx-runtime";
477
514
  var audioAnnotation = {
478
515
  id: "@manifest-editor/audio-annotation",
@@ -500,7 +537,12 @@ var audioAnnotation = {
500
537
  import { AddImageIcon } from "@manifest-editor/components";
501
538
 
502
539
  // src/Annotation/CaptionedImageAnnotation/create-captioned-image-annotation.tsx
503
- import { Input as Input2, InputContainer as InputContainer2, InputLabel as InputLabel2, LanguageFieldEditor as LanguageFieldEditor2 } from "@manifest-editor/editors";
540
+ import {
541
+ Input as Input2,
542
+ InputContainer as InputContainer2,
543
+ InputLabel as InputLabel2,
544
+ LanguageFieldEditor as LanguageFieldEditor2
545
+ } from "@manifest-editor/editors";
504
546
  import { useState as useState3 } from "react";
505
547
  import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
506
548
  async function createCaptionedImageAnnotation(data, ctx) {
@@ -630,6 +672,9 @@ var captionedImageAnnotation = {
630
672
  }
631
673
  };
632
674
 
675
+ // src/Annotation/HTMLAnnotation/index.tsx
676
+ import { HTMLIcon as HTMLIcon2 } from "@manifest-editor/components";
677
+
633
678
  // src/Annotation/HTMLAnnotation/create-html-annotation.tsx
634
679
  import { useState as useState4 } from "react";
635
680
  import {
@@ -724,7 +769,6 @@ function CreateHTMLAnnotation(props) {
724
769
  }
725
770
 
726
771
  // src/Annotation/HTMLAnnotation/index.tsx
727
- import { HTMLIcon as HTMLIcon2 } from "@manifest-editor/components";
728
772
  import { jsx as jsx9 } from "react/jsx-runtime";
729
773
  var htmlAnnotation = {
730
774
  id: "@manifest-editor/html-annotation",
@@ -748,6 +792,9 @@ var htmlAnnotation = {
748
792
  }
749
793
  };
750
794
 
795
+ // src/Annotation/ImageServiceAnnotation/index.tsx
796
+ import { IIIFLogo } from "@manifest-editor/components";
797
+
751
798
  // src/side-effects/reposition-multiple-images.ts
752
799
  import { isImageService } from "@iiif/parser/image-3";
753
800
  import { EditorInstance } from "@manifest-editor/editor-api";
@@ -771,7 +818,7 @@ var repositionMultipleImages = {
771
818
  if (!annoPage) {
772
819
  return;
773
820
  }
774
- if (annoPage.items.length < 2) {
821
+ if (annoPage.items.length < 2 && !canvas.behavior.includes("multi-image")) {
775
822
  return;
776
823
  }
777
824
  const bodies = vault.get(fullAnno.body);
@@ -782,10 +829,18 @@ var repositionMultipleImages = {
782
829
  if (imageService) {
783
830
  if (imageService.width && imageService.height) {
784
831
  if (imageService.width !== body.width) {
785
- vault.modifyEntityField({ id: body.id, type: "ContentResource" }, "width", imageService.width);
832
+ vault.modifyEntityField(
833
+ { id: body.id, type: "ContentResource" },
834
+ "width",
835
+ imageService.width
836
+ );
786
837
  }
787
838
  if (imageService.height !== body.height) {
788
- vault.modifyEntityField({ id: body.id, type: "ContentResource" }, "height", imageService.height);
839
+ vault.modifyEntityField(
840
+ { id: body.id, type: "ContentResource" },
841
+ "height",
842
+ imageService.height
843
+ );
789
844
  }
790
845
  }
791
846
  }
@@ -829,6 +884,9 @@ var resizeResourceToEmptyCanvas = {
829
884
  if (!canvas.items) {
830
885
  return;
831
886
  }
887
+ if (canvas.behavior.includes("multi-image")) {
888
+ return;
889
+ }
832
890
  const annoPage = vault.get(canvas.items[0]);
833
891
  if (!annoPage) {
834
892
  return;
@@ -886,6 +944,9 @@ var resizeToFitService = {
886
944
  if (!canvas.items) {
887
945
  return;
888
946
  }
947
+ if (canvas.behavior.includes("multi-image")) {
948
+ return;
949
+ }
889
950
  const annoPage = vault.get(canvas.items[0]);
890
951
  if (!annoPage) {
891
952
  return;
@@ -901,10 +962,18 @@ var resizeToFitService = {
901
962
  if (imageService) {
902
963
  if (imageService.width && imageService.height) {
903
964
  if (imageService.width !== body.width) {
904
- vault.modifyEntityField({ id: body.id, type: "ContentResource" }, "width", imageService.width);
965
+ vault.modifyEntityField(
966
+ { id: body.id, type: "ContentResource" },
967
+ "width",
968
+ imageService.width
969
+ );
905
970
  }
906
971
  if (imageService.height !== body.height) {
907
- vault.modifyEntityField({ id: body.id, type: "ContentResource" }, "height", imageService.height);
972
+ vault.modifyEntityField(
973
+ { id: body.id, type: "ContentResource" },
974
+ "height",
975
+ imageService.height
976
+ );
908
977
  }
909
978
  }
910
979
  }
@@ -988,9 +1057,13 @@ async function createImageServiceAnnotation(data, ctx) {
988
1057
  type: "Annotation"
989
1058
  };
990
1059
  const targetType = ctx.options.targetType;
991
- const resource = await ctx.create("@manifest-editor/image-service-creator", data, {
992
- parent: { resource: annotation, property: "body" }
993
- });
1060
+ const resource = await ctx.create(
1061
+ "@manifest-editor/image-service-creator",
1062
+ data,
1063
+ {
1064
+ parent: { resource: annotation, property: "body" }
1065
+ }
1066
+ );
994
1067
  if (targetType === "Annotation") {
995
1068
  return {
996
1069
  ...annotation,
@@ -1001,12 +1074,18 @@ async function createImageServiceAnnotation(data, ctx) {
1001
1074
  }
1002
1075
  if (targetType === "Canvas") {
1003
1076
  const canvasId = ctx.generateId("canvas");
1004
- const pageId = ctx.generateId("annotation-page", { id: canvasId, type: "Canvas" });
1077
+ const pageId = ctx.generateId("annotation-page", {
1078
+ id: canvasId,
1079
+ type: "Canvas"
1080
+ });
1005
1081
  const annotationResource = ctx.embed({
1006
1082
  ...annotation,
1007
1083
  motivation: "painting",
1008
1084
  body: [resource],
1009
- target: { type: "SpecificResource", source: { id: canvasId, type: "Canvas" } }
1085
+ target: {
1086
+ type: "SpecificResource",
1087
+ source: { id: canvasId, type: "Canvas" }
1088
+ }
1010
1089
  });
1011
1090
  const page = ctx.embed({
1012
1091
  id: pageId,
@@ -1028,7 +1107,6 @@ function CreateImageServiceAnnotationForm(props) {
1028
1107
  }
1029
1108
 
1030
1109
  // src/Annotation/ImageServiceAnnotation/index.tsx
1031
- import { IIIFLogo } from "@manifest-editor/components";
1032
1110
  import { jsx as jsx12 } from "react/jsx-runtime";
1033
1111
  var imageServiceAnnotation = {
1034
1112
  id: "@manifest-editor/image-service-annotation",
@@ -1048,12 +1126,19 @@ var imageServiceAnnotation = {
1048
1126
  parentTypes: ["AnnotationPage", "Manifest"],
1049
1127
  parentFields: ["items"]
1050
1128
  },
1051
- sideEffects: [resizeToFitService, resizeResourceToEmptyCanvas, repositionMultipleImages],
1129
+ sideEffects: [
1130
+ resizeToFitService,
1131
+ resizeResourceToEmptyCanvas,
1132
+ repositionMultipleImages
1133
+ ],
1052
1134
  staticFields: {
1053
1135
  type: "Annotation"
1054
1136
  }
1055
1137
  };
1056
1138
 
1139
+ // src/Annotation/ImageUrlAnnotation/index.tsx
1140
+ import { AddImageIcon as AddImageIcon2 } from "@manifest-editor/components";
1141
+
1057
1142
  // src/ContentResource/ImageUrlCreator/create-image-url.tsx
1058
1143
  import { InputContainer as InputContainer5, InputLabel as InputLabel5, Input as Input4 } from "@manifest-editor/editors";
1059
1144
  import { getImageDimensions, getFormat } from "@manifest-editor/shell";
@@ -1101,9 +1186,13 @@ async function createImageUrlAnnotation(data, ctx) {
1101
1186
  type: "Annotation"
1102
1187
  };
1103
1188
  const targetType = ctx.options.targetType;
1104
- const resource = await ctx.create("@manifest-editor/image-url-creator", data, {
1105
- parent: { resource: annotation, property: "body" }
1106
- });
1189
+ const resource = await ctx.create(
1190
+ "@manifest-editor/image-url-creator",
1191
+ data,
1192
+ {
1193
+ parent: { resource: annotation, property: "body" }
1194
+ }
1195
+ );
1107
1196
  if (targetType === "Annotation") {
1108
1197
  return {
1109
1198
  ...annotation,
@@ -1114,12 +1203,18 @@ async function createImageUrlAnnotation(data, ctx) {
1114
1203
  }
1115
1204
  if (targetType === "Canvas") {
1116
1205
  const canvasId = ctx.generateId("canvas");
1117
- const pageId = ctx.generateId("annotation-page", { id: canvasId, type: "Canvas" });
1206
+ const pageId = ctx.generateId("annotation-page", {
1207
+ id: canvasId,
1208
+ type: "Canvas"
1209
+ });
1118
1210
  const annotationResource = ctx.embed({
1119
1211
  ...annotation,
1120
1212
  motivation: "painting",
1121
1213
  body: [resource],
1122
- target: { type: "SpecificResource", source: { id: canvasId, type: "Canvas" } }
1214
+ target: {
1215
+ type: "SpecificResource",
1216
+ source: { id: canvasId, type: "Canvas" }
1217
+ }
1123
1218
  });
1124
1219
  const page = ctx.embed({
1125
1220
  id: pageId,
@@ -1141,7 +1236,6 @@ function CreateImageUrlAnnotationForm(props) {
1141
1236
  }
1142
1237
 
1143
1238
  // src/Annotation/ImageUrlAnnotation/index.tsx
1144
- import { AddImageIcon as AddImageIcon2 } from "@manifest-editor/components";
1145
1239
  import { jsx as jsx15 } from "react/jsx-runtime";
1146
1240
  var imageUrlAnnotation = {
1147
1241
  id: "@manifest-editor/image-url-annotation",
@@ -1161,7 +1255,11 @@ var imageUrlAnnotation = {
1161
1255
  parentTypes: ["AnnotationPage", "Manifest"],
1162
1256
  parentFields: ["items"]
1163
1257
  },
1164
- sideEffects: [resizeToFitService, resizeResourceToEmptyCanvas, repositionMultipleImages],
1258
+ sideEffects: [
1259
+ resizeToFitService,
1260
+ resizeResourceToEmptyCanvas,
1261
+ repositionMultipleImages
1262
+ ],
1165
1263
  staticFields: {
1166
1264
  type: "Annotation"
1167
1265
  }
@@ -1199,11 +1297,19 @@ function createNoBodyAnnotation(data, ctx) {
1199
1297
  });
1200
1298
  }
1201
1299
 
1300
+ // src/Annotation/VideoAnnotation/index.tsx
1301
+ import { VideoIcon } from "@manifest-editor/components";
1302
+
1202
1303
  // src/Annotation/VideoAnnotation/create-video-annotation.tsx
1203
1304
  import { getValue as getValue2 } from "@iiif/helpers";
1204
- import { InputContainer as InputContainer6, InputLabel as InputLabel6, Input as Input5, LanguageFieldEditor as LanguageFieldEditor4, DimensionsTriplet } from "@manifest-editor/editors";
1205
1305
  import { ErrorMessage as ErrorMessage2 } from "@manifest-editor/components";
1206
- import { useState as useState5, useEffect as useEffect3 } from "react";
1306
+ import {
1307
+ DimensionsTriplet,
1308
+ Input as Input5,
1309
+ InputContainer as InputContainer6,
1310
+ InputLabel as InputLabel6,
1311
+ LanguageFieldEditor as LanguageFieldEditor4
1312
+ } from "@manifest-editor/editors";
1207
1313
 
1208
1314
  // ../ui/ui/VideoPlayer/VideoPlayer.tsx
1209
1315
  import { CanvasPanel as CanvasPanel2, MediaPlayerProvider, useSimpleMediaPlayer } from "react-iiif-vault";
@@ -1243,6 +1349,7 @@ function VideoPlayer({
1243
1349
  }
1244
1350
 
1245
1351
  // src/Annotation/VideoAnnotation/create-video-annotation.tsx
1352
+ import { useEffect as useEffect3, useState as useState5 } from "react";
1246
1353
  import { jsx as jsx18, jsxs as jsxs10 } from "react/jsx-runtime";
1247
1354
  async function createVideoAnnotation(data, ctx) {
1248
1355
  const annotation = {
@@ -1250,7 +1357,7 @@ async function createVideoAnnotation(data, ctx) {
1250
1357
  type: "Annotation"
1251
1358
  };
1252
1359
  const targetType = ctx.options.targetType;
1253
- const body = await ctx.embed({
1360
+ const body = ctx.embed({
1254
1361
  id: data.url,
1255
1362
  type: "Video",
1256
1363
  format: "video/mp4",
@@ -1269,12 +1376,18 @@ async function createVideoAnnotation(data, ctx) {
1269
1376
  }
1270
1377
  if (targetType === "Canvas") {
1271
1378
  const canvasId = ctx.generateId("canvas");
1272
- const pageId = ctx.generateId("annotation-page", { id: canvasId, type: "Canvas" });
1379
+ const pageId = ctx.generateId("annotation-page", {
1380
+ id: canvasId,
1381
+ type: "Canvas"
1382
+ });
1273
1383
  const annotationResource = ctx.embed({
1274
1384
  ...annotation,
1275
1385
  motivation: "painting",
1276
1386
  body,
1277
- target: { type: "SpecificResource", source: { id: canvasId, type: "Canvas" } }
1387
+ target: {
1388
+ type: "SpecificResource",
1389
+ source: { id: canvasId, type: "Canvas" }
1390
+ }
1278
1391
  });
1279
1392
  const page = ctx.embed({
1280
1393
  id: pageId,
@@ -1320,7 +1433,15 @@ function CreateVideoAnnotationForm(props) {
1320
1433
  error ? /* @__PURE__ */ jsx18(ErrorMessage2, { children: error }) : null,
1321
1434
  /* @__PURE__ */ jsxs10(InputContainer6, { children: [
1322
1435
  /* @__PURE__ */ jsx18(InputLabel6, { htmlFor: "video-url", children: "URL" }),
1323
- /* @__PURE__ */ jsx18(Input5, { type: "text", id: "video-url", value: url, onChange: (e) => setUrl(e.target.value) })
1436
+ /* @__PURE__ */ jsx18(
1437
+ Input5,
1438
+ {
1439
+ type: "text",
1440
+ id: "video-url",
1441
+ value: url,
1442
+ onChange: (e) => setUrl(e.target.value)
1443
+ }
1444
+ )
1324
1445
  ] }),
1325
1446
  url && !error ? /* @__PURE__ */ jsx18("div", { children: /* @__PURE__ */ jsx18(
1326
1447
  LanguageFieldEditor4,
@@ -1371,7 +1492,6 @@ function CreateVideoAnnotationForm(props) {
1371
1492
  }
1372
1493
 
1373
1494
  // src/Annotation/VideoAnnotation/index.tsx
1374
- import { VideoIcon } from "@manifest-editor/components";
1375
1495
  import { jsx as jsx19 } from "react/jsx-runtime";
1376
1496
  var videoAnnotation = {
1377
1497
  id: "@manifest-editor/video-annotation",
@@ -1417,7 +1537,14 @@ var ThumbnailStripIcon = () => /* @__PURE__ */ jsx20(
1417
1537
  import { jsx as jsx21 } from "react/jsx-runtime";
1418
1538
  var emptyAnnotationPage = {
1419
1539
  id: "@manifest-editor/empty-annotation-page",
1420
- create: createEmptyAnnotationPage,
1540
+ create: (data, ctx) => {
1541
+ return ctx.embed({
1542
+ id: ctx.generateId("annotations"),
1543
+ label: data.label,
1544
+ type: "AnnotationPage",
1545
+ items: []
1546
+ });
1547
+ },
1421
1548
  label: "Empty annotation page",
1422
1549
  summary: "AnnotationPage with nothing",
1423
1550
  icon: /* @__PURE__ */ jsx21(ThumbnailStripIcon, {}),
@@ -1432,21 +1559,28 @@ var emptyAnnotationPage = {
1432
1559
  }
1433
1560
  }
1434
1561
  };
1435
- async function createEmptyAnnotationPage(data, ctx) {
1436
- return ctx.embed({
1437
- id: ctx.generateId("annotations"),
1438
- label: data.label,
1439
- type: "AnnotationPage",
1440
- items: []
1441
- });
1442
- }
1443
1562
 
1444
1563
  // src/Canvas/EmptyCanvas/index.tsx
1445
1564
  import { EmptyCanvasIcon as EmptyCanvasIcon2 } from "@manifest-editor/components";
1446
1565
  import { jsx as jsx22 } from "react/jsx-runtime";
1447
1566
  var emptyCanvas = {
1448
1567
  id: "@manifest-editor/empty-canvas",
1449
- create: createEmptyCanvas,
1568
+ create: (data, ctx) => {
1569
+ const canvasId = ctx.generateId("canvas");
1570
+ const page = ctx.embed({
1571
+ id: ctx.generateId("annotation-page", { id: canvasId, type: "Canvas" }),
1572
+ type: "AnnotationPage",
1573
+ items: []
1574
+ });
1575
+ return {
1576
+ id: canvasId,
1577
+ type: "Canvas",
1578
+ label: data.label || { en: [""] },
1579
+ height: data.height || 1e3,
1580
+ width: data.width || 1e3,
1581
+ items: [page]
1582
+ };
1583
+ },
1450
1584
  label: "Empty canvas",
1451
1585
  summary: "No content",
1452
1586
  icon: /* @__PURE__ */ jsx22(EmptyCanvasIcon2, {}),
@@ -1457,24 +1591,9 @@ var emptyCanvas = {
1457
1591
  parentFields: ["items"]
1458
1592
  }
1459
1593
  };
1460
- async function createEmptyCanvas(data, ctx) {
1461
- const canvasId = ctx.generateId("canvas");
1462
- const page = ctx.embed({
1463
- id: ctx.generateId("annotation-page", { id: canvasId, type: "Canvas" }),
1464
- type: "AnnotationPage",
1465
- items: []
1466
- });
1467
- return {
1468
- id: canvasId,
1469
- type: "Canvas",
1470
- label: data.label || { en: [""] },
1471
- height: data.height || 1e3,
1472
- width: data.width || 1e3,
1473
- items: [page]
1474
- };
1475
- }
1476
1594
 
1477
1595
  // src/Canvas/InternalCanvas/index.tsx
1596
+ import { IIIFExplorer } from "@manifest-editor/iiif-browser";
1478
1597
  import { useManifest, useVault } from "react-iiif-vault";
1479
1598
 
1480
1599
  // ../../node_modules/.pnpm/tiny-invariant@1.3.3/node_modules/tiny-invariant/dist/esm/tiny-invariant.js
@@ -1493,7 +1612,6 @@ function invariant(condition, message) {
1493
1612
  }
1494
1613
 
1495
1614
  // src/Canvas/InternalCanvas/index.tsx
1496
- import { IIIFExplorer } from "@manifest-editor/iiif-browser";
1497
1615
  import { jsx as jsx23 } from "react/jsx-runtime";
1498
1616
  var internalCanvas = {
1499
1617
  id: "@manifest-editor/internal-canvas",
@@ -1539,11 +1657,22 @@ async function createInternalCanvas(data, ctx) {
1539
1657
  return ctx.embed({ id: data.id, type: "Canvas" });
1540
1658
  }
1541
1659
 
1660
+ // ../ui/icons/TextFormatIcon.tsx
1661
+ import { jsx as jsx24, jsxs as jsxs12 } from "react/jsx-runtime";
1662
+ var TextFormatIcon = (props) => /* @__PURE__ */ jsxs12("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", height: "1em", width: "1em", ...props, children: [
1663
+ /* @__PURE__ */ jsx24("path", { d: "M0 0h24v24H0z", fill: "none" }),
1664
+ /* @__PURE__ */ jsx24("path", { d: "M5 17v2h14v-2H5zm4.5-4.2h5l.9 2.2h2.1L12.75 4h-1.5L6.5 15h2.1l.9-2.2zM12 5.98 13.87 11h-3.74L12 5.98z" })
1665
+ ] });
1666
+
1542
1667
  // src/ContentResource/HTMLBodyCreator/create-html-body.tsx
1543
- import { InputContainer as InputContainer7, InputLabel as InputLabel7, RichTextLanguageField } from "@manifest-editor/editors";
1668
+ import {
1669
+ InputContainer as InputContainer7,
1670
+ InputLabel as InputLabel7,
1671
+ RichTextLanguageField
1672
+ } from "@manifest-editor/editors";
1544
1673
  import { useConfig } from "@manifest-editor/shell";
1545
1674
  import { useState as useState6 } from "react";
1546
- import { jsx as jsx24, jsxs as jsxs12 } from "react/jsx-runtime";
1675
+ import { jsx as jsx25, jsxs as jsxs13 } from "react/jsx-runtime";
1547
1676
  async function createHtmlBody(data, ctx) {
1548
1677
  return ctx.embed({
1549
1678
  id: ctx.generateId(`html/${data.language}`),
@@ -1563,10 +1692,10 @@ function CreateHTMLBodyForm(props) {
1563
1692
  body
1564
1693
  });
1565
1694
  };
1566
- return /* @__PURE__ */ jsxs12(PaddedSidebarContainer, { children: [
1567
- /* @__PURE__ */ jsxs12(InputContainer7, { children: [
1568
- /* @__PURE__ */ jsx24(InputLabel7, { children: "HTML Body" }),
1569
- /* @__PURE__ */ jsx24(
1695
+ return /* @__PURE__ */ jsxs13(PaddedSidebarContainer, { children: [
1696
+ /* @__PURE__ */ jsxs13(InputContainer7, { children: [
1697
+ /* @__PURE__ */ jsx25(InputLabel7, { children: "HTML Body" }),
1698
+ /* @__PURE__ */ jsx25(
1570
1699
  RichTextLanguageField,
1571
1700
  {
1572
1701
  value: body,
@@ -1577,17 +1706,10 @@ function CreateHTMLBodyForm(props) {
1577
1706
  }
1578
1707
  )
1579
1708
  ] }),
1580
- /* @__PURE__ */ jsx24(Button, { onClick: () => onSubmit(), children: "Create" })
1709
+ /* @__PURE__ */ jsx25(Button, { onClick: () => onSubmit(), children: "Create" })
1581
1710
  ] });
1582
1711
  }
1583
1712
 
1584
- // ../ui/icons/TextFormatIcon.tsx
1585
- import { jsx as jsx25, jsxs as jsxs13 } from "react/jsx-runtime";
1586
- var TextFormatIcon = (props) => /* @__PURE__ */ jsxs13("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", height: "1em", width: "1em", ...props, children: [
1587
- /* @__PURE__ */ jsx25("path", { d: "M0 0h24v24H0z", fill: "none" }),
1588
- /* @__PURE__ */ jsx25("path", { d: "M5 17v2h14v-2H5zm4.5-4.2h5l.9 2.2h2.1L12.75 4h-1.5L6.5 15h2.1l.9-2.2zM12 5.98 13.87 11h-3.74L12 5.98z" })
1589
- ] });
1590
-
1591
1713
  // src/ContentResource/HTMLBodyCreator/index.tsx
1592
1714
  import { jsx as jsx26 } from "react/jsx-runtime";
1593
1715
  var htmlBodyCreator = {
@@ -1616,10 +1738,17 @@ import { IIIFBrowserIcon } from "@manifest-editor/components";
1616
1738
 
1617
1739
  // src/ContentResource/IIIFBrowserCreator/iiif-browser-creator.tsx
1618
1740
  import {
1741
+ Vault,
1619
1742
  normaliseContentState,
1620
1743
  parseContentState
1621
1744
  } from "@iiif/helpers";
1745
+ import { getImageServices } from "@iiif/parser/image-3";
1622
1746
  import { lazy } from "react";
1747
+ function croppedRegion(imageServiceId, region, size) {
1748
+ return `${imageServiceId}/${Math.floor(region.x)},${Math.floor(region.y)},${Math.floor(region.width)},${Math.floor(
1749
+ region.height
1750
+ )}/${size}/0/default.jpg`;
1751
+ }
1623
1752
  async function createFromIIIFBrowserOutput(data, ctx) {
1624
1753
  const targetType = ctx.options.targetType;
1625
1754
  if (Array.isArray(data.output)) {
@@ -1633,8 +1762,8 @@ async function createFromIIIFBrowserOutput(data, ctx) {
1633
1762
  }
1634
1763
  const target = contentState.target[0];
1635
1764
  const type = target.source.type;
1636
- const previewVault = ctx.getPreviewVault();
1637
- if (targetType === "Canvas" || targetType === "Annotation") {
1765
+ const previewVault = new Vault();
1766
+ if (targetType === "Canvas" || targetType === "Annotation" || targetType === "ContentResource") {
1638
1767
  if (type === "Canvas") {
1639
1768
  const canvasId = target.source.id;
1640
1769
  const manifestId = target.source.partOf?.find(
@@ -1651,16 +1780,24 @@ async function createFromIIIFBrowserOutput(data, ctx) {
1651
1780
  }
1652
1781
  const annotationPage = previewVault.get(canvas.items[0]);
1653
1782
  const annotation = previewVault.get(annotationPage.items[0]);
1654
- if (targetType === "Annotation" || targetType === "Canvas") {
1783
+ if (targetType === "Annotation" || targetType === "Canvas" || targetType === "ContentResource") {
1655
1784
  const fullAnnotation = previewVault.toPresentation3(annotation);
1785
+ fullAnnotation.id = ctx.generateId("Annotation");
1786
+ let service = null;
1787
+ const dimensions = { width: 0, height: 0 };
1656
1788
  if (fullAnnotation?.body?.service) {
1657
1789
  const width = fullAnnotation?.body.width;
1658
1790
  const height = fullAnnotation?.body.height;
1659
- const service = Array.isArray(fullAnnotation?.body?.service) ? fullAnnotation?.body?.service[0] : fullAnnotation?.body?.service;
1660
- if (!service.width || !service.height) {
1791
+ service = getImageServices(fullAnnotation?.body)[0];
1792
+ if (service && (!service.width || !service.height)) {
1661
1793
  service.width = width;
1662
1794
  service.height = height;
1663
1795
  }
1796
+ dimensions.width = width;
1797
+ dimensions.height = height;
1798
+ if (data.trackSize) {
1799
+ data.trackSize(dimensions);
1800
+ }
1664
1801
  }
1665
1802
  if (target.selector && target.selector.type === "BoxSelector") {
1666
1803
  const selector = {
@@ -1673,12 +1810,30 @@ async function createFromIIIFBrowserOutput(data, ctx) {
1673
1810
  ~~target.selector.spatial.height
1674
1811
  ].join(",")
1675
1812
  };
1813
+ const newBody = { ...fullAnnotation.body };
1814
+ let thumbnailId = "";
1815
+ if (service) {
1816
+ const id = service.id || service["@id"] || "";
1817
+ if (id) {
1818
+ newBody.id = croppedRegion(id, target.selector.spatial, "max");
1819
+ thumbnailId = croppedRegion(id, target.selector.spatial, "512,");
1820
+ }
1821
+ }
1676
1822
  fullAnnotation.body = {
1677
1823
  id: ctx.generateId("SpecificResource", annotation),
1678
1824
  type: "SpecificResource",
1679
- source: fullAnnotation.body,
1825
+ source: newBody,
1680
1826
  selector
1681
1827
  };
1828
+ if (data.trackSize) {
1829
+ data.trackSize({
1830
+ width: ~~target.selector.spatial.width,
1831
+ height: ~~target.selector.spatial.height
1832
+ });
1833
+ }
1834
+ if (targetType === "ContentResource") {
1835
+ return fullAnnotation.body;
1836
+ }
1682
1837
  if (targetType === "Canvas") {
1683
1838
  const canvasId2 = ctx.generateId("Canvas", annotation);
1684
1839
  fullAnnotation.target = canvasId2;
@@ -1693,6 +1848,17 @@ async function createFromIIIFBrowserOutput(data, ctx) {
1693
1848
  type: "Canvas",
1694
1849
  width: ~~target.selector.spatial.width,
1695
1850
  height: ~~target.selector.spatial.height,
1851
+ thumbnail: thumbnailId ? [
1852
+ ctx.embed({
1853
+ id: thumbnailId,
1854
+ type: "Image",
1855
+ format: "image/jpeg",
1856
+ width: 512,
1857
+ height: Math.round(
1858
+ target.selector.spatial.height / target.selector.spatial.width * 512
1859
+ )
1860
+ })
1861
+ ] : void 0,
1696
1862
  items: [annotationPage2]
1697
1863
  });
1698
1864
  }
@@ -1711,7 +1877,7 @@ async function createFromIIIFBrowserOutput(data, ctx) {
1711
1877
  throw new Error("Not yet supported.");
1712
1878
  }
1713
1879
  var IIIFBrowserCreatorForm = lazy(
1714
- () => import("./iiif-browser-form.lazy-W42LJ6X2.js")
1880
+ () => import("./iiif-browser-form.lazy-HZ3M2DXT.js")
1715
1881
  );
1716
1882
 
1717
1883
  // src/ContentResource/IIIFBrowserCreator/index.tsx
@@ -1761,9 +1927,6 @@ var imageServiceCreator = {
1761
1927
  resourceFields: ["id", "type", "height", "width", "format", "service"],
1762
1928
  supports: {
1763
1929
  parentFields: ["logo", "body", "thumbnail"]
1764
- },
1765
- staticFields: {
1766
- type: "Image"
1767
1930
  }
1768
1931
  };
1769
1932
 
@@ -1790,7 +1953,12 @@ var imageUrlCreator = {
1790
1953
  };
1791
1954
 
1792
1955
  // src/ContentResource/PlaintextCreator/create-plaintext.tsx
1793
- import { LanguageFieldEditor as LanguageFieldEditor5, InputContainer as InputContainer8, InputLabel as InputLabel8, Input as Input6 } from "@manifest-editor/editors";
1956
+ import {
1957
+ LanguageFieldEditor as LanguageFieldEditor5,
1958
+ InputContainer as InputContainer8,
1959
+ InputLabel as InputLabel8,
1960
+ Input as Input6
1961
+ } from "@manifest-editor/editors";
1794
1962
  import { useState as useState7 } from "react";
1795
1963
  import { jsx as jsx30, jsxs as jsxs14 } from "react/jsx-runtime";
1796
1964
  async function createPlaintext(data, ctx) {
@@ -1802,7 +1970,9 @@ async function createPlaintext(data, ctx) {
1802
1970
  });
1803
1971
  }
1804
1972
  function CreatePlaintextForm(props) {
1805
- const [label, setLabel] = useState7({ en: ["View as text"] });
1973
+ const [label, setLabel] = useState7({
1974
+ en: ["View as text"]
1975
+ });
1806
1976
  const onSubmit = (e) => {
1807
1977
  e.preventDefault();
1808
1978
  const data = new FormData(e.target);
@@ -1850,10 +2020,24 @@ var plaintextCreator = {
1850
2020
  }
1851
2021
  };
1852
2022
 
2023
+ // ../ui/icons/LinkIcon.tsx
2024
+ import { jsx as jsx32, jsxs as jsxs15 } from "react/jsx-runtime";
2025
+ function LinkIcon() {
2026
+ return /* @__PURE__ */ jsxs15("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000", children: [
2027
+ /* @__PURE__ */ jsx32("path", { d: "M0 0h24v24H0z", fill: "none" }),
2028
+ /* @__PURE__ */ jsx32("path", { d: "M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z" })
2029
+ ] });
2030
+ }
2031
+
1853
2032
  // src/ContentResource/WebPageCreator/create-web-page.tsx
1854
- import { LanguageFieldEditor as LanguageFieldEditor6, InputContainer as InputContainer9, InputLabel as InputLabel9, Input as Input7 } from "@manifest-editor/editors";
2033
+ import {
2034
+ LanguageFieldEditor as LanguageFieldEditor6,
2035
+ InputContainer as InputContainer9,
2036
+ InputLabel as InputLabel9,
2037
+ Input as Input7
2038
+ } from "@manifest-editor/editors";
1855
2039
  import { useState as useState8 } from "react";
1856
- import { jsx as jsx32, jsxs as jsxs15 } from "react/jsx-runtime";
2040
+ import { jsx as jsx33, jsxs as jsxs16 } from "react/jsx-runtime";
1857
2041
  async function createWebPage(data, ctx) {
1858
2042
  return ctx.embed({
1859
2043
  id: data.url,
@@ -1872,8 +2056,8 @@ function CreateWebPageForm(props) {
1872
2056
  props.runCreate({ url: formData.url, label });
1873
2057
  }
1874
2058
  };
1875
- return /* @__PURE__ */ jsx32(PaddedSidebarContainer, { children: /* @__PURE__ */ jsxs15("form", { onSubmit, children: [
1876
- /* @__PURE__ */ jsx32(
2059
+ return /* @__PURE__ */ jsx33(PaddedSidebarContainer, { children: /* @__PURE__ */ jsxs16("form", { onSubmit, children: [
2060
+ /* @__PURE__ */ jsx33(
1877
2061
  LanguageFieldEditor6,
1878
2062
  {
1879
2063
  focusId: "label",
@@ -1882,23 +2066,14 @@ function CreateWebPageForm(props) {
1882
2066
  onSave: (e) => setLabel(e.toInternationalString())
1883
2067
  }
1884
2068
  ),
1885
- /* @__PURE__ */ jsxs15(InputContainer9, { $wide: true, children: [
1886
- /* @__PURE__ */ jsx32(InputLabel9, { htmlFor: "id", children: "Link" }),
1887
- /* @__PURE__ */ jsx32(Input7, { id: "url", name: "url", defaultValue: "" })
2069
+ /* @__PURE__ */ jsxs16(InputContainer9, { $wide: true, children: [
2070
+ /* @__PURE__ */ jsx33(InputLabel9, { htmlFor: "id", children: "Link" }),
2071
+ /* @__PURE__ */ jsx33(Input7, { id: "url", name: "url", defaultValue: "" })
1888
2072
  ] }),
1889
- /* @__PURE__ */ jsx32(Button, { type: "submit", children: "Create link" })
2073
+ /* @__PURE__ */ jsx33(Button, { type: "submit", children: "Create link" })
1890
2074
  ] }) });
1891
2075
  }
1892
2076
 
1893
- // ../ui/icons/LinkIcon.tsx
1894
- import { jsx as jsx33, jsxs as jsxs16 } from "react/jsx-runtime";
1895
- function LinkIcon() {
1896
- return /* @__PURE__ */ jsxs16("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000", children: [
1897
- /* @__PURE__ */ jsx33("path", { d: "M0 0h24v24H0z", fill: "none" }),
1898
- /* @__PURE__ */ jsx33("path", { d: "M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z" })
1899
- ] });
1900
- }
1901
-
1902
2077
  // src/ContentResource/WebPageCreator/index.tsx
1903
2078
  import { jsx as jsx34 } from "react/jsx-runtime";
1904
2079
  var webPageCreator = {
@@ -1928,6 +2103,9 @@ function getYouTubeId(url) {
1928
2103
  const id = (url || "").match(ytRegex);
1929
2104
  return id ? id[1] : null;
1930
2105
  }
2106
+ function validateYouTube(data) {
2107
+ return !!getYouTubeId(data.youtubeUrl);
2108
+ }
1931
2109
  async function createYoutubeBody(data, ctx) {
1932
2110
  const id = getYouTubeId(data.youtubeUrl);
1933
2111
  const body = ctx.embed({
@@ -2031,8 +2209,14 @@ var youTubeBodyCreator = {
2031
2209
  }
2032
2210
  };
2033
2211
 
2212
+ // src/Manifest/ManifestBrowserCreator/index.tsx
2213
+ import { IIIFBrowserIcon as IIIFBrowserIcon2 } from "@manifest-editor/components";
2214
+
2034
2215
  // src/Manifest/ManifestBrowserCreator/manifest-browser-creator.tsx
2035
- import { normaliseContentState as normaliseContentState2, parseContentState as parseContentState2 } from "@iiif/helpers";
2216
+ import {
2217
+ normaliseContentState as normaliseContentState2,
2218
+ parseContentState as parseContentState2
2219
+ } from "@iiif/helpers";
2036
2220
  import { lazy as lazy2 } from "react";
2037
2221
  async function createFromManifestBrowserOutput(data, ctx) {
2038
2222
  const targetType = ctx.options.targetType;
@@ -2069,10 +2253,11 @@ async function createFromManifestBrowserOutput(data, ctx) {
2069
2253
  }
2070
2254
  throw new Error("Not yet supported.");
2071
2255
  }
2072
- var ManifestBrowserCreatorForm2 = lazy2(() => import("./manifest-browser-form.lazy-WRWZPVRC.js"));
2256
+ var ManifestBrowserCreatorForm2 = lazy2(
2257
+ () => import("./manifest-browser-form.lazy-MYI26AX4.js")
2258
+ );
2073
2259
 
2074
2260
  // src/Manifest/ManifestBrowserCreator/index.tsx
2075
- import { IIIFBrowserIcon as IIIFBrowserIcon2 } from "@manifest-editor/components";
2076
2261
  import { jsx as jsx37 } from "react/jsx-runtime";
2077
2262
  var manifestBrowserCreator = {
2078
2263
  id: "@manifest-editor/manifest-browser-creator",
@@ -2118,11 +2303,39 @@ var allCreators = [
2118
2303
  captionedImageAnnotation
2119
2304
  ];
2120
2305
  export {
2306
+ CreateAudioAnnotationForm,
2307
+ CreateCaptionedImageAnnotation,
2308
+ CreateHTMLAnnotation,
2309
+ CreateHTMLBodyForm,
2310
+ CreateImageServerForm,
2311
+ CreateImageServiceAnnotationForm,
2312
+ CreateImageUrlAnnotationForm,
2313
+ CreateImageUrlForm,
2314
+ CreatePlaintextForm,
2315
+ CreateVideoAnnotationForm,
2316
+ CreateWebPageForm,
2317
+ IIIFBrowserCreatorForm,
2318
+ YouTubeForm,
2121
2319
  allCreators,
2122
2320
  audioAnnotation,
2123
2321
  captionedImageAnnotation,
2322
+ createAudioAnnotation,
2323
+ createCaptionedImageAnnotation,
2324
+ createFromIIIFBrowserOutput,
2325
+ createHtmlAnnotation,
2326
+ createHtmlBody,
2327
+ createImageServer,
2328
+ createImageServiceAnnotation,
2329
+ createImageUrl,
2330
+ createImageUrlAnnotation,
2331
+ createNoBodyAnnotation,
2332
+ createPlaintext,
2333
+ createVideoAnnotation,
2334
+ createWebPage,
2335
+ createYoutubeBody,
2124
2336
  emptyAnnotationPage,
2125
2337
  emptyCanvas,
2338
+ getYouTubeId,
2126
2339
  htmlAnnotation,
2127
2340
  htmlBodyCreator,
2128
2341
  iiifBrowserCreator,
@@ -2134,6 +2347,7 @@ export {
2134
2347
  manifestBrowserCreator,
2135
2348
  noBodyAnnotation,
2136
2349
  plaintextCreator,
2350
+ validateYouTube,
2137
2351
  videoAnnotation,
2138
2352
  webPageCreator,
2139
2353
  youTubeBodyCreator