@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.cjs CHANGED
@@ -36,7 +36,7 @@ __export(iiif_browser_form_lazy_exports, {
36
36
  default: () => IIIFBrowserCreatorForm
37
37
  });
38
38
  function IIIFBrowserCreatorForm(props) {
39
- const vault = (0, import_shell3.usePreviewVault)();
39
+ const vault = (0, import_react7.useMemo)(() => new import_helpers3.Vault(), []);
40
40
  const output = (0, import_react7.useMemo)(() => {
41
41
  return [
42
42
  {
@@ -54,27 +54,38 @@ function IIIFBrowserCreatorForm(props) {
54
54
  }
55
55
  ];
56
56
  }, [props.runCreate]);
57
+ const navigationOptions = (0, import_react7.useMemo)(() => {
58
+ return {
59
+ canCropImage: true,
60
+ canSelectCanvas: true,
61
+ canSelectManifest: false,
62
+ canSelectCollection: false,
63
+ // @todo fix the output so this one works.
64
+ multiSelect: false
65
+ };
66
+ }, []);
67
+ const uiOptions = (0, import_react7.useMemo)(() => {
68
+ return {
69
+ buttonClassName: "bg-me-primary-500 text-white hover:bg-me-primary-600"
70
+ };
71
+ }, []);
57
72
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_shell3.PreviewVaultBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
58
73
  import_iiif_browser2.IIIFBrowser,
59
74
  {
75
+ debug: true,
76
+ ui: uiOptions,
60
77
  vault,
61
78
  className: "iiif-browser border-none border-t rounded-none h-[70vh] min-h-[60vh] max-h-full max-w-full",
62
79
  output,
63
- navigation: {
64
- canCropImage: true,
65
- canSelectCanvas: true,
66
- canSelectManifest: false,
67
- canSelectCollection: false,
68
- // @todo fix the output so this one works.
69
- multiSelect: false
70
- }
80
+ navigation: navigationOptions
71
81
  }
72
82
  ) });
73
83
  }
74
- var import_shell3, import_iiif_browser2, import_react7, import_jsx_runtime27;
84
+ var import_helpers3, import_shell3, import_iiif_browser2, import_react7, import_jsx_runtime27;
75
85
  var init_iiif_browser_form_lazy = __esm({
76
86
  "src/ContentResource/IIIFBrowserCreator/iiif-browser-form.lazy.tsx"() {
77
87
  "use strict";
88
+ import_helpers3 = require("@iiif/helpers");
78
89
  import_shell3 = require("@manifest-editor/shell");
79
90
  import_iiif_browser2 = require("iiif-browser");
80
91
  import_react7 = require("react");
@@ -125,11 +136,39 @@ var init_manifest_browser_form_lazy = __esm({
125
136
  // src/index.ts
126
137
  var src_exports = {};
127
138
  __export(src_exports, {
139
+ CreateAudioAnnotationForm: () => CreateAudioAnnotationForm,
140
+ CreateCaptionedImageAnnotation: () => CreateCaptionedImageAnnotation,
141
+ CreateHTMLAnnotation: () => CreateHTMLAnnotation,
142
+ CreateHTMLBodyForm: () => CreateHTMLBodyForm,
143
+ CreateImageServerForm: () => CreateImageServerForm,
144
+ CreateImageServiceAnnotationForm: () => CreateImageServiceAnnotationForm,
145
+ CreateImageUrlAnnotationForm: () => CreateImageUrlAnnotationForm,
146
+ CreateImageUrlForm: () => CreateImageUrlForm,
147
+ CreatePlaintextForm: () => CreatePlaintextForm,
148
+ CreateVideoAnnotationForm: () => CreateVideoAnnotationForm,
149
+ CreateWebPageForm: () => CreateWebPageForm,
150
+ IIIFBrowserCreatorForm: () => IIIFBrowserCreatorForm2,
151
+ YouTubeForm: () => YouTubeForm,
128
152
  allCreators: () => allCreators,
129
153
  audioAnnotation: () => audioAnnotation,
130
154
  captionedImageAnnotation: () => captionedImageAnnotation,
155
+ createAudioAnnotation: () => createAudioAnnotation,
156
+ createCaptionedImageAnnotation: () => createCaptionedImageAnnotation,
157
+ createFromIIIFBrowserOutput: () => createFromIIIFBrowserOutput,
158
+ createHtmlAnnotation: () => createHtmlAnnotation,
159
+ createHtmlBody: () => createHtmlBody,
160
+ createImageServer: () => createImageServer,
161
+ createImageServiceAnnotation: () => createImageServiceAnnotation,
162
+ createImageUrl: () => createImageUrl,
163
+ createImageUrlAnnotation: () => createImageUrlAnnotation,
164
+ createNoBodyAnnotation: () => createNoBodyAnnotation,
165
+ createPlaintext: () => createPlaintext,
166
+ createVideoAnnotation: () => createVideoAnnotation,
167
+ createWebPage: () => createWebPage,
168
+ createYoutubeBody: () => createYoutubeBody,
131
169
  emptyAnnotationPage: () => emptyAnnotationPage,
132
170
  emptyCanvas: () => emptyCanvas,
171
+ getYouTubeId: () => getYouTubeId,
133
172
  htmlAnnotation: () => htmlAnnotation,
134
173
  htmlBodyCreator: () => htmlBodyCreator,
135
174
  iiifBrowserCreator: () => iiifBrowserCreator,
@@ -141,12 +180,16 @@ __export(src_exports, {
141
180
  manifestBrowserCreator: () => manifestBrowserCreator,
142
181
  noBodyAnnotation: () => noBodyAnnotation,
143
182
  plaintextCreator: () => plaintextCreator,
183
+ validateYouTube: () => validateYouTube,
144
184
  videoAnnotation: () => videoAnnotation,
145
185
  webPageCreator: () => webPageCreator,
146
186
  youTubeBodyCreator: () => youTubeBodyCreator
147
187
  });
148
188
  module.exports = __toCommonJS(src_exports);
149
189
 
190
+ // src/Annotation/AudioAnnotation/index.tsx
191
+ var import_components2 = require("@manifest-editor/components");
192
+
150
193
  // src/Annotation/AudioAnnotation/create-audio-annotation.tsx
151
194
  var import_react2 = require("react");
152
195
 
@@ -542,12 +585,18 @@ async function createAudioAnnotation(data, ctx) {
542
585
  }
543
586
  if (targetType === "Canvas") {
544
587
  const canvasId = ctx.generateId("canvas");
545
- const pageId = ctx.generateId("annotation-page", { id: canvasId, type: "Canvas" });
588
+ const pageId = ctx.generateId("annotation-page", {
589
+ id: canvasId,
590
+ type: "Canvas"
591
+ });
546
592
  const annotationResource = ctx.embed({
547
593
  ...annotation,
548
594
  motivation: "painting",
549
595
  body,
550
- target: { type: "SpecificResource", source: { id: canvasId, type: "Canvas" } }
596
+ target: {
597
+ type: "SpecificResource",
598
+ source: { id: canvasId, type: "Canvas" }
599
+ }
551
600
  });
552
601
  const page = ctx.embed({
553
602
  id: pageId,
@@ -587,7 +636,15 @@ function CreateAudioAnnotationForm(props) {
587
636
  error ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_components.ErrorMessage, { children: error }) : null,
588
637
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_editors.InputContainer, { children: [
589
638
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_editors.InputLabel, { htmlFor: "audio-url", children: "URL" }),
590
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_editors.Input, { type: "text", id: "audio-url", value: url, onChange: (e) => setUrl(e.target.value) })
639
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
640
+ import_editors.Input,
641
+ {
642
+ type: "text",
643
+ id: "audio-url",
644
+ value: url,
645
+ onChange: (e) => setUrl(e.target.value)
646
+ }
647
+ )
591
648
  ] }),
592
649
  url && !error ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
593
650
  import_editors.LanguageFieldEditor,
@@ -600,24 +657,38 @@ function CreateAudioAnnotationForm(props) {
600
657
  },
601
658
  url + "__" + duration
602
659
  ) }) : null,
603
- url && !error ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_iiif_vault2.CanvasPanel.AudioHTML, { media: { url, duration, type: "Sound" }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
604
- MediaControls,
660
+ url && !error ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
661
+ import_react_iiif_vault2.CanvasPanel.AudioHTML,
605
662
  {
606
- onError: (error2) => setError(error2),
607
- onDuration: (duration2) => setDuration(duration2)
663
+ media: { url, duration, type: "Sound" },
664
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
665
+ MediaControls,
666
+ {
667
+ onError: (error2) => setError(error2),
668
+ onDuration: (duration2) => setDuration(duration2)
669
+ },
670
+ url + "__" + duration
671
+ )
608
672
  },
609
673
  url + "__" + duration
610
- ) }, url + "__" + duration) : null,
674
+ ) : null,
611
675
  duration && !error ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_editors.FormFieldWrapper, { children: [
612
676
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_editors.InputLabel, { htmlFor: "duration", children: "Duration" }),
613
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_editors.Input, { type: "number", id: "duration", value: duration, onChange: (e) => setDuration(e.target.valueAsNumber) })
677
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
678
+ import_editors.Input,
679
+ {
680
+ type: "number",
681
+ id: "duration",
682
+ value: duration,
683
+ onChange: (e) => setDuration(e.target.valueAsNumber)
684
+ }
685
+ )
614
686
  ] }) : null,
615
687
  url && !error && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Button, { onClick: onSubmit, children: "Add audio" })
616
688
  ] });
617
689
  }
618
690
 
619
691
  // src/Annotation/AudioAnnotation/index.tsx
620
- var import_components2 = require("@manifest-editor/components");
621
692
  var import_jsx_runtime5 = require("react/jsx-runtime");
622
693
  var audioAnnotation = {
623
694
  id: "@manifest-editor/audio-annotation",
@@ -775,6 +846,9 @@ var captionedImageAnnotation = {
775
846
  }
776
847
  };
777
848
 
849
+ // src/Annotation/HTMLAnnotation/index.tsx
850
+ var import_components4 = require("@manifest-editor/components");
851
+
778
852
  // src/Annotation/HTMLAnnotation/create-html-annotation.tsx
779
853
  var import_react4 = require("react");
780
854
  var import_editors3 = require("@manifest-editor/editors");
@@ -865,7 +939,6 @@ function CreateHTMLAnnotation(props) {
865
939
  }
866
940
 
867
941
  // src/Annotation/HTMLAnnotation/index.tsx
868
- var import_components4 = require("@manifest-editor/components");
869
942
  var import_jsx_runtime9 = require("react/jsx-runtime");
870
943
  var htmlAnnotation = {
871
944
  id: "@manifest-editor/html-annotation",
@@ -889,6 +962,9 @@ var htmlAnnotation = {
889
962
  }
890
963
  };
891
964
 
965
+ // src/Annotation/ImageServiceAnnotation/index.tsx
966
+ var import_components5 = require("@manifest-editor/components");
967
+
892
968
  // src/side-effects/reposition-multiple-images.ts
893
969
  var import_image_3 = require("@iiif/parser/image-3");
894
970
  var import_editor_api = require("@manifest-editor/editor-api");
@@ -912,7 +988,7 @@ var repositionMultipleImages = {
912
988
  if (!annoPage) {
913
989
  return;
914
990
  }
915
- if (annoPage.items.length < 2) {
991
+ if (annoPage.items.length < 2 && !canvas.behavior.includes("multi-image")) {
916
992
  return;
917
993
  }
918
994
  const bodies = vault.get(fullAnno.body);
@@ -923,10 +999,18 @@ var repositionMultipleImages = {
923
999
  if (imageService) {
924
1000
  if (imageService.width && imageService.height) {
925
1001
  if (imageService.width !== body.width) {
926
- vault.modifyEntityField({ id: body.id, type: "ContentResource" }, "width", imageService.width);
1002
+ vault.modifyEntityField(
1003
+ { id: body.id, type: "ContentResource" },
1004
+ "width",
1005
+ imageService.width
1006
+ );
927
1007
  }
928
1008
  if (imageService.height !== body.height) {
929
- vault.modifyEntityField({ id: body.id, type: "ContentResource" }, "height", imageService.height);
1009
+ vault.modifyEntityField(
1010
+ { id: body.id, type: "ContentResource" },
1011
+ "height",
1012
+ imageService.height
1013
+ );
930
1014
  }
931
1015
  }
932
1016
  }
@@ -970,6 +1054,9 @@ var resizeResourceToEmptyCanvas = {
970
1054
  if (!canvas.items) {
971
1055
  return;
972
1056
  }
1057
+ if (canvas.behavior.includes("multi-image")) {
1058
+ return;
1059
+ }
973
1060
  const annoPage = vault.get(canvas.items[0]);
974
1061
  if (!annoPage) {
975
1062
  return;
@@ -1027,6 +1114,9 @@ var resizeToFitService = {
1027
1114
  if (!canvas.items) {
1028
1115
  return;
1029
1116
  }
1117
+ if (canvas.behavior.includes("multi-image")) {
1118
+ return;
1119
+ }
1030
1120
  const annoPage = vault.get(canvas.items[0]);
1031
1121
  if (!annoPage) {
1032
1122
  return;
@@ -1042,10 +1132,18 @@ var resizeToFitService = {
1042
1132
  if (imageService) {
1043
1133
  if (imageService.width && imageService.height) {
1044
1134
  if (imageService.width !== body.width) {
1045
- vault.modifyEntityField({ id: body.id, type: "ContentResource" }, "width", imageService.width);
1135
+ vault.modifyEntityField(
1136
+ { id: body.id, type: "ContentResource" },
1137
+ "width",
1138
+ imageService.width
1139
+ );
1046
1140
  }
1047
1141
  if (imageService.height !== body.height) {
1048
- vault.modifyEntityField({ id: body.id, type: "ContentResource" }, "height", imageService.height);
1142
+ vault.modifyEntityField(
1143
+ { id: body.id, type: "ContentResource" },
1144
+ "height",
1145
+ imageService.height
1146
+ );
1049
1147
  }
1050
1148
  }
1051
1149
  }
@@ -1125,9 +1223,13 @@ async function createImageServiceAnnotation(data, ctx) {
1125
1223
  type: "Annotation"
1126
1224
  };
1127
1225
  const targetType = ctx.options.targetType;
1128
- const resource = await ctx.create("@manifest-editor/image-service-creator", data, {
1129
- parent: { resource: annotation, property: "body" }
1130
- });
1226
+ const resource = await ctx.create(
1227
+ "@manifest-editor/image-service-creator",
1228
+ data,
1229
+ {
1230
+ parent: { resource: annotation, property: "body" }
1231
+ }
1232
+ );
1131
1233
  if (targetType === "Annotation") {
1132
1234
  return {
1133
1235
  ...annotation,
@@ -1138,12 +1240,18 @@ async function createImageServiceAnnotation(data, ctx) {
1138
1240
  }
1139
1241
  if (targetType === "Canvas") {
1140
1242
  const canvasId = ctx.generateId("canvas");
1141
- const pageId = ctx.generateId("annotation-page", { id: canvasId, type: "Canvas" });
1243
+ const pageId = ctx.generateId("annotation-page", {
1244
+ id: canvasId,
1245
+ type: "Canvas"
1246
+ });
1142
1247
  const annotationResource = ctx.embed({
1143
1248
  ...annotation,
1144
1249
  motivation: "painting",
1145
1250
  body: [resource],
1146
- target: { type: "SpecificResource", source: { id: canvasId, type: "Canvas" } }
1251
+ target: {
1252
+ type: "SpecificResource",
1253
+ source: { id: canvasId, type: "Canvas" }
1254
+ }
1147
1255
  });
1148
1256
  const page = ctx.embed({
1149
1257
  id: pageId,
@@ -1165,7 +1273,6 @@ function CreateImageServiceAnnotationForm(props) {
1165
1273
  }
1166
1274
 
1167
1275
  // src/Annotation/ImageServiceAnnotation/index.tsx
1168
- var import_components5 = require("@manifest-editor/components");
1169
1276
  var import_jsx_runtime12 = require("react/jsx-runtime");
1170
1277
  var imageServiceAnnotation = {
1171
1278
  id: "@manifest-editor/image-service-annotation",
@@ -1185,12 +1292,19 @@ var imageServiceAnnotation = {
1185
1292
  parentTypes: ["AnnotationPage", "Manifest"],
1186
1293
  parentFields: ["items"]
1187
1294
  },
1188
- sideEffects: [resizeToFitService, resizeResourceToEmptyCanvas, repositionMultipleImages],
1295
+ sideEffects: [
1296
+ resizeToFitService,
1297
+ resizeResourceToEmptyCanvas,
1298
+ repositionMultipleImages
1299
+ ],
1189
1300
  staticFields: {
1190
1301
  type: "Annotation"
1191
1302
  }
1192
1303
  };
1193
1304
 
1305
+ // src/Annotation/ImageUrlAnnotation/index.tsx
1306
+ var import_components6 = require("@manifest-editor/components");
1307
+
1194
1308
  // src/ContentResource/ImageUrlCreator/create-image-url.tsx
1195
1309
  var import_editors6 = require("@manifest-editor/editors");
1196
1310
  var import_shell = require("@manifest-editor/shell");
@@ -1238,9 +1352,13 @@ async function createImageUrlAnnotation(data, ctx) {
1238
1352
  type: "Annotation"
1239
1353
  };
1240
1354
  const targetType = ctx.options.targetType;
1241
- const resource = await ctx.create("@manifest-editor/image-url-creator", data, {
1242
- parent: { resource: annotation, property: "body" }
1243
- });
1355
+ const resource = await ctx.create(
1356
+ "@manifest-editor/image-url-creator",
1357
+ data,
1358
+ {
1359
+ parent: { resource: annotation, property: "body" }
1360
+ }
1361
+ );
1244
1362
  if (targetType === "Annotation") {
1245
1363
  return {
1246
1364
  ...annotation,
@@ -1251,12 +1369,18 @@ async function createImageUrlAnnotation(data, ctx) {
1251
1369
  }
1252
1370
  if (targetType === "Canvas") {
1253
1371
  const canvasId = ctx.generateId("canvas");
1254
- const pageId = ctx.generateId("annotation-page", { id: canvasId, type: "Canvas" });
1372
+ const pageId = ctx.generateId("annotation-page", {
1373
+ id: canvasId,
1374
+ type: "Canvas"
1375
+ });
1255
1376
  const annotationResource = ctx.embed({
1256
1377
  ...annotation,
1257
1378
  motivation: "painting",
1258
1379
  body: [resource],
1259
- target: { type: "SpecificResource", source: { id: canvasId, type: "Canvas" } }
1380
+ target: {
1381
+ type: "SpecificResource",
1382
+ source: { id: canvasId, type: "Canvas" }
1383
+ }
1260
1384
  });
1261
1385
  const page = ctx.embed({
1262
1386
  id: pageId,
@@ -1278,7 +1402,6 @@ function CreateImageUrlAnnotationForm(props) {
1278
1402
  }
1279
1403
 
1280
1404
  // src/Annotation/ImageUrlAnnotation/index.tsx
1281
- var import_components6 = require("@manifest-editor/components");
1282
1405
  var import_jsx_runtime15 = require("react/jsx-runtime");
1283
1406
  var imageUrlAnnotation = {
1284
1407
  id: "@manifest-editor/image-url-annotation",
@@ -1298,7 +1421,11 @@ var imageUrlAnnotation = {
1298
1421
  parentTypes: ["AnnotationPage", "Manifest"],
1299
1422
  parentFields: ["items"]
1300
1423
  },
1301
- sideEffects: [resizeToFitService, resizeResourceToEmptyCanvas, repositionMultipleImages],
1424
+ sideEffects: [
1425
+ resizeToFitService,
1426
+ resizeResourceToEmptyCanvas,
1427
+ repositionMultipleImages
1428
+ ],
1302
1429
  staticFields: {
1303
1430
  type: "Annotation"
1304
1431
  }
@@ -1336,11 +1463,13 @@ function createNoBodyAnnotation(data, ctx) {
1336
1463
  });
1337
1464
  }
1338
1465
 
1466
+ // src/Annotation/VideoAnnotation/index.tsx
1467
+ var import_components9 = require("@manifest-editor/components");
1468
+
1339
1469
  // src/Annotation/VideoAnnotation/create-video-annotation.tsx
1340
1470
  var import_helpers2 = require("@iiif/helpers");
1341
- var import_editors7 = require("@manifest-editor/editors");
1342
1471
  var import_components8 = require("@manifest-editor/components");
1343
- var import_react5 = require("react");
1472
+ var import_editors7 = require("@manifest-editor/editors");
1344
1473
 
1345
1474
  // ../ui/ui/VideoPlayer/VideoPlayer.tsx
1346
1475
  var import_react_iiif_vault3 = require("react-iiif-vault");
@@ -1380,6 +1509,7 @@ function VideoPlayer({
1380
1509
  }
1381
1510
 
1382
1511
  // src/Annotation/VideoAnnotation/create-video-annotation.tsx
1512
+ var import_react5 = require("react");
1383
1513
  var import_jsx_runtime18 = require("react/jsx-runtime");
1384
1514
  async function createVideoAnnotation(data, ctx) {
1385
1515
  const annotation = {
@@ -1387,7 +1517,7 @@ async function createVideoAnnotation(data, ctx) {
1387
1517
  type: "Annotation"
1388
1518
  };
1389
1519
  const targetType = ctx.options.targetType;
1390
- const body = await ctx.embed({
1520
+ const body = ctx.embed({
1391
1521
  id: data.url,
1392
1522
  type: "Video",
1393
1523
  format: "video/mp4",
@@ -1406,12 +1536,18 @@ async function createVideoAnnotation(data, ctx) {
1406
1536
  }
1407
1537
  if (targetType === "Canvas") {
1408
1538
  const canvasId = ctx.generateId("canvas");
1409
- const pageId = ctx.generateId("annotation-page", { id: canvasId, type: "Canvas" });
1539
+ const pageId = ctx.generateId("annotation-page", {
1540
+ id: canvasId,
1541
+ type: "Canvas"
1542
+ });
1410
1543
  const annotationResource = ctx.embed({
1411
1544
  ...annotation,
1412
1545
  motivation: "painting",
1413
1546
  body,
1414
- target: { type: "SpecificResource", source: { id: canvasId, type: "Canvas" } }
1547
+ target: {
1548
+ type: "SpecificResource",
1549
+ source: { id: canvasId, type: "Canvas" }
1550
+ }
1415
1551
  });
1416
1552
  const page = ctx.embed({
1417
1553
  id: pageId,
@@ -1457,7 +1593,15 @@ function CreateVideoAnnotationForm(props) {
1457
1593
  error ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_components8.ErrorMessage, { children: error }) : null,
1458
1594
  /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_editors7.InputContainer, { children: [
1459
1595
  /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_editors7.InputLabel, { htmlFor: "video-url", children: "URL" }),
1460
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_editors7.Input, { type: "text", id: "video-url", value: url, onChange: (e) => setUrl(e.target.value) })
1596
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1597
+ import_editors7.Input,
1598
+ {
1599
+ type: "text",
1600
+ id: "video-url",
1601
+ value: url,
1602
+ onChange: (e) => setUrl(e.target.value)
1603
+ }
1604
+ )
1461
1605
  ] }),
1462
1606
  url && !error ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1463
1607
  import_editors7.LanguageFieldEditor,
@@ -1508,7 +1652,6 @@ function CreateVideoAnnotationForm(props) {
1508
1652
  }
1509
1653
 
1510
1654
  // src/Annotation/VideoAnnotation/index.tsx
1511
- var import_components9 = require("@manifest-editor/components");
1512
1655
  var import_jsx_runtime19 = require("react/jsx-runtime");
1513
1656
  var videoAnnotation = {
1514
1657
  id: "@manifest-editor/video-annotation",
@@ -1554,7 +1697,14 @@ var ThumbnailStripIcon = () => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
1554
1697
  var import_jsx_runtime21 = require("react/jsx-runtime");
1555
1698
  var emptyAnnotationPage = {
1556
1699
  id: "@manifest-editor/empty-annotation-page",
1557
- create: createEmptyAnnotationPage,
1700
+ create: (data, ctx) => {
1701
+ return ctx.embed({
1702
+ id: ctx.generateId("annotations"),
1703
+ label: data.label,
1704
+ type: "AnnotationPage",
1705
+ items: []
1706
+ });
1707
+ },
1558
1708
  label: "Empty annotation page",
1559
1709
  summary: "AnnotationPage with nothing",
1560
1710
  icon: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ThumbnailStripIcon, {}),
@@ -1569,21 +1719,28 @@ var emptyAnnotationPage = {
1569
1719
  }
1570
1720
  }
1571
1721
  };
1572
- async function createEmptyAnnotationPage(data, ctx) {
1573
- return ctx.embed({
1574
- id: ctx.generateId("annotations"),
1575
- label: data.label,
1576
- type: "AnnotationPage",
1577
- items: []
1578
- });
1579
- }
1580
1722
 
1581
1723
  // src/Canvas/EmptyCanvas/index.tsx
1582
1724
  var import_components10 = require("@manifest-editor/components");
1583
1725
  var import_jsx_runtime22 = require("react/jsx-runtime");
1584
1726
  var emptyCanvas = {
1585
1727
  id: "@manifest-editor/empty-canvas",
1586
- create: createEmptyCanvas,
1728
+ create: (data, ctx) => {
1729
+ const canvasId = ctx.generateId("canvas");
1730
+ const page = ctx.embed({
1731
+ id: ctx.generateId("annotation-page", { id: canvasId, type: "Canvas" }),
1732
+ type: "AnnotationPage",
1733
+ items: []
1734
+ });
1735
+ return {
1736
+ id: canvasId,
1737
+ type: "Canvas",
1738
+ label: data.label || { en: [""] },
1739
+ height: data.height || 1e3,
1740
+ width: data.width || 1e3,
1741
+ items: [page]
1742
+ };
1743
+ },
1587
1744
  label: "Empty canvas",
1588
1745
  summary: "No content",
1589
1746
  icon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_components10.EmptyCanvasIcon, {}),
@@ -1594,24 +1751,9 @@ var emptyCanvas = {
1594
1751
  parentFields: ["items"]
1595
1752
  }
1596
1753
  };
1597
- async function createEmptyCanvas(data, ctx) {
1598
- const canvasId = ctx.generateId("canvas");
1599
- const page = ctx.embed({
1600
- id: ctx.generateId("annotation-page", { id: canvasId, type: "Canvas" }),
1601
- type: "AnnotationPage",
1602
- items: []
1603
- });
1604
- return {
1605
- id: canvasId,
1606
- type: "Canvas",
1607
- label: data.label || { en: [""] },
1608
- height: data.height || 1e3,
1609
- width: data.width || 1e3,
1610
- items: [page]
1611
- };
1612
- }
1613
1754
 
1614
1755
  // src/Canvas/InternalCanvas/index.tsx
1756
+ var import_iiif_browser = require("@manifest-editor/iiif-browser");
1615
1757
  var import_react_iiif_vault4 = require("react-iiif-vault");
1616
1758
 
1617
1759
  // ../../node_modules/.pnpm/tiny-invariant@1.3.3/node_modules/tiny-invariant/dist/esm/tiny-invariant.js
@@ -1630,7 +1772,6 @@ function invariant(condition, message) {
1630
1772
  }
1631
1773
 
1632
1774
  // src/Canvas/InternalCanvas/index.tsx
1633
- var import_iiif_browser = require("@manifest-editor/iiif-browser");
1634
1775
  var import_jsx_runtime23 = require("react/jsx-runtime");
1635
1776
  var internalCanvas = {
1636
1777
  id: "@manifest-editor/internal-canvas",
@@ -1676,11 +1817,18 @@ async function createInternalCanvas(data, ctx) {
1676
1817
  return ctx.embed({ id: data.id, type: "Canvas" });
1677
1818
  }
1678
1819
 
1820
+ // ../ui/icons/TextFormatIcon.tsx
1821
+ var import_jsx_runtime24 = require("react/jsx-runtime");
1822
+ var TextFormatIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", height: "1em", width: "1em", ...props, children: [
1823
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("path", { d: "M0 0h24v24H0z", fill: "none" }),
1824
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("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" })
1825
+ ] });
1826
+
1679
1827
  // src/ContentResource/HTMLBodyCreator/create-html-body.tsx
1680
1828
  var import_editors8 = require("@manifest-editor/editors");
1681
1829
  var import_shell2 = require("@manifest-editor/shell");
1682
1830
  var import_react6 = require("react");
1683
- var import_jsx_runtime24 = require("react/jsx-runtime");
1831
+ var import_jsx_runtime25 = require("react/jsx-runtime");
1684
1832
  async function createHtmlBody(data, ctx) {
1685
1833
  return ctx.embed({
1686
1834
  id: ctx.generateId(`html/${data.language}`),
@@ -1700,10 +1848,10 @@ function CreateHTMLBodyForm(props) {
1700
1848
  body
1701
1849
  });
1702
1850
  };
1703
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(PaddedSidebarContainer, { children: [
1704
- /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_editors8.InputContainer, { children: [
1705
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_editors8.InputLabel, { children: "HTML Body" }),
1706
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
1851
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(PaddedSidebarContainer, { children: [
1852
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_editors8.InputContainer, { children: [
1853
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_editors8.InputLabel, { children: "HTML Body" }),
1854
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
1707
1855
  import_editors8.RichTextLanguageField,
1708
1856
  {
1709
1857
  value: body,
@@ -1714,17 +1862,10 @@ function CreateHTMLBodyForm(props) {
1714
1862
  }
1715
1863
  )
1716
1864
  ] }),
1717
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Button, { onClick: () => onSubmit(), children: "Create" })
1865
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Button, { onClick: () => onSubmit(), children: "Create" })
1718
1866
  ] });
1719
1867
  }
1720
1868
 
1721
- // ../ui/icons/TextFormatIcon.tsx
1722
- var import_jsx_runtime25 = require("react/jsx-runtime");
1723
- var TextFormatIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", height: "1em", width: "1em", ...props, children: [
1724
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("path", { d: "M0 0h24v24H0z", fill: "none" }),
1725
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("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" })
1726
- ] });
1727
-
1728
1869
  // src/ContentResource/HTMLBodyCreator/index.tsx
1729
1870
  var import_jsx_runtime26 = require("react/jsx-runtime");
1730
1871
  var htmlBodyCreator = {
@@ -1752,23 +1893,29 @@ var htmlBodyCreator = {
1752
1893
  var import_components11 = require("@manifest-editor/components");
1753
1894
 
1754
1895
  // src/ContentResource/IIIFBrowserCreator/iiif-browser-creator.tsx
1755
- var import_helpers3 = require("@iiif/helpers");
1896
+ var import_helpers4 = require("@iiif/helpers");
1897
+ var import_image_33 = require("@iiif/parser/image-3");
1756
1898
  var import_react8 = require("react");
1899
+ function croppedRegion(imageServiceId, region, size) {
1900
+ return `${imageServiceId}/${Math.floor(region.x)},${Math.floor(region.y)},${Math.floor(region.width)},${Math.floor(
1901
+ region.height
1902
+ )}/${size}/0/default.jpg`;
1903
+ }
1757
1904
  async function createFromIIIFBrowserOutput(data, ctx) {
1758
1905
  const targetType = ctx.options.targetType;
1759
1906
  if (Array.isArray(data.output)) {
1760
1907
  throw new Error("Multiple items not yet supported");
1761
1908
  }
1762
- const contentState = (0, import_helpers3.normaliseContentState)(
1763
- typeof data.output === "string" ? (0, import_helpers3.parseContentState)(data.output) : data.output
1909
+ const contentState = (0, import_helpers4.normaliseContentState)(
1910
+ typeof data.output === "string" ? (0, import_helpers4.parseContentState)(data.output) : data.output
1764
1911
  );
1765
1912
  if (!contentState.target || contentState.target.length === 0) {
1766
1913
  throw new Error("No target found in content state");
1767
1914
  }
1768
1915
  const target = contentState.target[0];
1769
1916
  const type = target.source.type;
1770
- const previewVault = ctx.getPreviewVault();
1771
- if (targetType === "Canvas" || targetType === "Annotation") {
1917
+ const previewVault = new import_helpers4.Vault();
1918
+ if (targetType === "Canvas" || targetType === "Annotation" || targetType === "ContentResource") {
1772
1919
  if (type === "Canvas") {
1773
1920
  const canvasId = target.source.id;
1774
1921
  const manifestId = target.source.partOf?.find(
@@ -1785,16 +1932,24 @@ async function createFromIIIFBrowserOutput(data, ctx) {
1785
1932
  }
1786
1933
  const annotationPage = previewVault.get(canvas.items[0]);
1787
1934
  const annotation = previewVault.get(annotationPage.items[0]);
1788
- if (targetType === "Annotation" || targetType === "Canvas") {
1935
+ if (targetType === "Annotation" || targetType === "Canvas" || targetType === "ContentResource") {
1789
1936
  const fullAnnotation = previewVault.toPresentation3(annotation);
1937
+ fullAnnotation.id = ctx.generateId("Annotation");
1938
+ let service = null;
1939
+ const dimensions = { width: 0, height: 0 };
1790
1940
  if (fullAnnotation?.body?.service) {
1791
1941
  const width = fullAnnotation?.body.width;
1792
1942
  const height = fullAnnotation?.body.height;
1793
- const service = Array.isArray(fullAnnotation?.body?.service) ? fullAnnotation?.body?.service[0] : fullAnnotation?.body?.service;
1794
- if (!service.width || !service.height) {
1943
+ service = (0, import_image_33.getImageServices)(fullAnnotation?.body)[0];
1944
+ if (service && (!service.width || !service.height)) {
1795
1945
  service.width = width;
1796
1946
  service.height = height;
1797
1947
  }
1948
+ dimensions.width = width;
1949
+ dimensions.height = height;
1950
+ if (data.trackSize) {
1951
+ data.trackSize(dimensions);
1952
+ }
1798
1953
  }
1799
1954
  if (target.selector && target.selector.type === "BoxSelector") {
1800
1955
  const selector = {
@@ -1807,12 +1962,30 @@ async function createFromIIIFBrowserOutput(data, ctx) {
1807
1962
  ~~target.selector.spatial.height
1808
1963
  ].join(",")
1809
1964
  };
1965
+ const newBody = { ...fullAnnotation.body };
1966
+ let thumbnailId = "";
1967
+ if (service) {
1968
+ const id = service.id || service["@id"] || "";
1969
+ if (id) {
1970
+ newBody.id = croppedRegion(id, target.selector.spatial, "max");
1971
+ thumbnailId = croppedRegion(id, target.selector.spatial, "512,");
1972
+ }
1973
+ }
1810
1974
  fullAnnotation.body = {
1811
1975
  id: ctx.generateId("SpecificResource", annotation),
1812
1976
  type: "SpecificResource",
1813
- source: fullAnnotation.body,
1977
+ source: newBody,
1814
1978
  selector
1815
1979
  };
1980
+ if (data.trackSize) {
1981
+ data.trackSize({
1982
+ width: ~~target.selector.spatial.width,
1983
+ height: ~~target.selector.spatial.height
1984
+ });
1985
+ }
1986
+ if (targetType === "ContentResource") {
1987
+ return fullAnnotation.body;
1988
+ }
1816
1989
  if (targetType === "Canvas") {
1817
1990
  const canvasId2 = ctx.generateId("Canvas", annotation);
1818
1991
  fullAnnotation.target = canvasId2;
@@ -1827,6 +2000,17 @@ async function createFromIIIFBrowserOutput(data, ctx) {
1827
2000
  type: "Canvas",
1828
2001
  width: ~~target.selector.spatial.width,
1829
2002
  height: ~~target.selector.spatial.height,
2003
+ thumbnail: thumbnailId ? [
2004
+ ctx.embed({
2005
+ id: thumbnailId,
2006
+ type: "Image",
2007
+ format: "image/jpeg",
2008
+ width: 512,
2009
+ height: Math.round(
2010
+ target.selector.spatial.height / target.selector.spatial.width * 512
2011
+ )
2012
+ })
2013
+ ] : void 0,
1830
2014
  items: [annotationPage2]
1831
2015
  });
1832
2016
  }
@@ -1895,9 +2079,6 @@ var imageServiceCreator = {
1895
2079
  resourceFields: ["id", "type", "height", "width", "format", "service"],
1896
2080
  supports: {
1897
2081
  parentFields: ["logo", "body", "thumbnail"]
1898
- },
1899
- staticFields: {
1900
- type: "Image"
1901
2082
  }
1902
2083
  };
1903
2084
 
@@ -1936,7 +2117,9 @@ async function createPlaintext(data, ctx) {
1936
2117
  });
1937
2118
  }
1938
2119
  function CreatePlaintextForm(props) {
1939
- const [label, setLabel] = (0, import_react9.useState)({ en: ["View as text"] });
2120
+ const [label, setLabel] = (0, import_react9.useState)({
2121
+ en: ["View as text"]
2122
+ });
1940
2123
  const onSubmit = (e) => {
1941
2124
  e.preventDefault();
1942
2125
  const data = new FormData(e.target);
@@ -1984,10 +2167,19 @@ var plaintextCreator = {
1984
2167
  }
1985
2168
  };
1986
2169
 
2170
+ // ../ui/icons/LinkIcon.tsx
2171
+ var import_jsx_runtime33 = require("react/jsx-runtime");
2172
+ function LinkIcon() {
2173
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000", children: [
2174
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("path", { d: "M0 0h24v24H0z", fill: "none" }),
2175
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("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" })
2176
+ ] });
2177
+ }
2178
+
1987
2179
  // src/ContentResource/WebPageCreator/create-web-page.tsx
1988
2180
  var import_editors10 = require("@manifest-editor/editors");
1989
2181
  var import_react10 = require("react");
1990
- var import_jsx_runtime33 = require("react/jsx-runtime");
2182
+ var import_jsx_runtime34 = require("react/jsx-runtime");
1991
2183
  async function createWebPage(data, ctx) {
1992
2184
  return ctx.embed({
1993
2185
  id: data.url,
@@ -2006,8 +2198,8 @@ function CreateWebPageForm(props) {
2006
2198
  props.runCreate({ url: formData.url, label });
2007
2199
  }
2008
2200
  };
2009
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(PaddedSidebarContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("form", { onSubmit, children: [
2010
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2201
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(PaddedSidebarContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("form", { onSubmit, children: [
2202
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
2011
2203
  import_editors10.LanguageFieldEditor,
2012
2204
  {
2013
2205
  focusId: "label",
@@ -2016,23 +2208,14 @@ function CreateWebPageForm(props) {
2016
2208
  onSave: (e) => setLabel(e.toInternationalString())
2017
2209
  }
2018
2210
  ),
2019
- /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_editors10.InputContainer, { $wide: true, children: [
2020
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_editors10.InputLabel, { htmlFor: "id", children: "Link" }),
2021
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_editors10.Input, { id: "url", name: "url", defaultValue: "" })
2211
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_editors10.InputContainer, { $wide: true, children: [
2212
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_editors10.InputLabel, { htmlFor: "id", children: "Link" }),
2213
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_editors10.Input, { id: "url", name: "url", defaultValue: "" })
2022
2214
  ] }),
2023
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Button, { type: "submit", children: "Create link" })
2215
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Button, { type: "submit", children: "Create link" })
2024
2216
  ] }) });
2025
2217
  }
2026
2218
 
2027
- // ../ui/icons/LinkIcon.tsx
2028
- var import_jsx_runtime34 = require("react/jsx-runtime");
2029
- function LinkIcon() {
2030
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000", children: [
2031
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("path", { d: "M0 0h24v24H0z", fill: "none" }),
2032
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("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" })
2033
- ] });
2034
- }
2035
-
2036
2219
  // src/ContentResource/WebPageCreator/index.tsx
2037
2220
  var import_jsx_runtime35 = require("react/jsx-runtime");
2038
2221
  var webPageCreator = {
@@ -2062,6 +2245,9 @@ function getYouTubeId(url) {
2062
2245
  const id = (url || "").match(ytRegex);
2063
2246
  return id ? id[1] : null;
2064
2247
  }
2248
+ function validateYouTube(data) {
2249
+ return !!getYouTubeId(data.youtubeUrl);
2250
+ }
2065
2251
  async function createYoutubeBody(data, ctx) {
2066
2252
  const id = getYouTubeId(data.youtubeUrl);
2067
2253
  const body = ctx.embed({
@@ -2165,16 +2351,19 @@ var youTubeBodyCreator = {
2165
2351
  }
2166
2352
  };
2167
2353
 
2354
+ // src/Manifest/ManifestBrowserCreator/index.tsx
2355
+ var import_components14 = require("@manifest-editor/components");
2356
+
2168
2357
  // src/Manifest/ManifestBrowserCreator/manifest-browser-creator.tsx
2169
- var import_helpers4 = require("@iiif/helpers");
2358
+ var import_helpers5 = require("@iiif/helpers");
2170
2359
  var import_react11 = require("react");
2171
2360
  async function createFromManifestBrowserOutput(data, ctx) {
2172
2361
  const targetType = ctx.options.targetType;
2173
2362
  if (Array.isArray(data.output)) {
2174
2363
  throw new Error("Multiple items not yet supported");
2175
2364
  }
2176
- const contentState = (0, import_helpers4.normaliseContentState)(
2177
- typeof data.output === "string" ? (0, import_helpers4.parseContentState)(data.output) : data.output
2365
+ const contentState = (0, import_helpers5.normaliseContentState)(
2366
+ typeof data.output === "string" ? (0, import_helpers5.parseContentState)(data.output) : data.output
2178
2367
  );
2179
2368
  const target = contentState.target[0];
2180
2369
  const previewVault = ctx.getPreviewVault();
@@ -2203,11 +2392,12 @@ async function createFromManifestBrowserOutput(data, ctx) {
2203
2392
  }
2204
2393
  throw new Error("Not yet supported.");
2205
2394
  }
2206
- var ManifestBrowserCreatorForm2 = (0, import_react11.lazy)(() => Promise.resolve().then(() => (init_manifest_browser_form_lazy(), manifest_browser_form_lazy_exports)));
2395
+ var ManifestBrowserCreatorForm2 = (0, import_react11.lazy)(
2396
+ () => Promise.resolve().then(() => (init_manifest_browser_form_lazy(), manifest_browser_form_lazy_exports))
2397
+ );
2207
2398
 
2208
2399
  // src/Manifest/ManifestBrowserCreator/index.tsx
2209
2400
  init_manifest_browser_form_lazy();
2210
- var import_components14 = require("@manifest-editor/components");
2211
2401
  var import_jsx_runtime39 = require("react/jsx-runtime");
2212
2402
  var manifestBrowserCreator = {
2213
2403
  id: "@manifest-editor/manifest-browser-creator",