@drghaliasri/butex 6.0.1 → 6.1.2

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.
@@ -33,6 +33,26 @@ __export(react_document2_entry_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(react_document2_entry_exports);
35
35
 
36
+ // src/react/matrixPickerCss.ts
37
+ var MATRIX_PICKER_CSS = `
38
+ .butex-widget .matrix-grid-picker,
39
+ .butex-widget .matrix-grid-cell {
40
+ box-sizing: border-box;
41
+ }
42
+ `.trim();
43
+ var MATRIX_PICKER_STYLE_ID = "butex-matrix-picker-css";
44
+ function injectMatrixPickerCss(doc) {
45
+ const d = doc ?? (typeof document !== "undefined" ? document : void 0);
46
+ if (!d || d.getElementById(MATRIX_PICKER_STYLE_ID)) {
47
+ return;
48
+ }
49
+ const style = d.createElement("style");
50
+ style.id = MATRIX_PICKER_STYLE_ID;
51
+ style.textContent = MATRIX_PICKER_CSS;
52
+ d.head.appendChild(style);
53
+ }
54
+ injectMatrixPickerCss();
55
+
36
56
  // src/react-document2/ArticleMetaPanel.tsx
37
57
  var import_react = require("react");
38
58
 
@@ -1005,6 +1025,76 @@ function applyFloatMetaPatch(block, patch) {
1005
1025
  }
1006
1026
  }
1007
1027
 
1028
+ // src/document2/inlineIdentity.ts
1029
+ function createDocument2IdentityState() {
1030
+ return {
1031
+ blockIds: /* @__PURE__ */ new Set(),
1032
+ itemIds: /* @__PURE__ */ new Set(),
1033
+ fieldIds: /* @__PURE__ */ new Set(),
1034
+ tokenIds: /* @__PURE__ */ new Set()
1035
+ };
1036
+ }
1037
+ function importedOrGeneratedId(value, prefix, used) {
1038
+ const imported = typeof value === "string" ? value.trim() : "";
1039
+ if (imported.length > 0 && !used.has(imported)) {
1040
+ used.add(imported);
1041
+ return imported;
1042
+ }
1043
+ let generated = document2Id(prefix);
1044
+ while (used.has(generated)) {
1045
+ generated = document2Id(prefix);
1046
+ }
1047
+ used.add(generated);
1048
+ return generated;
1049
+ }
1050
+ function inlineTokenSource(token) {
1051
+ if (token.kind === "text") {
1052
+ return token.text;
1053
+ }
1054
+ if (token.kind === "math") {
1055
+ return token.source;
1056
+ }
1057
+ if (token.kind === "cite") {
1058
+ return citeTokenLatex(token.keys);
1059
+ }
1060
+ return refTokenLatex(token.keys, token.refCommand);
1061
+ }
1062
+ function inlineIdsFromField(field) {
1063
+ let offset = 0;
1064
+ const tokens = field.tokens.map((token) => {
1065
+ const start = offset;
1066
+ offset += inlineTokenSource(token).length;
1067
+ return { id: token.id, kind: token.kind, start, end: offset };
1068
+ });
1069
+ return { field_id: field.id, tokens };
1070
+ }
1071
+ function isAlignedSidecar(value, field) {
1072
+ if (typeof value !== "object" || value === null || !Array.isArray(value.tokens)) {
1073
+ return false;
1074
+ }
1075
+ const tokens = value.tokens;
1076
+ const expected = inlineIdsFromField(field).tokens;
1077
+ if (tokens.length !== expected.length) {
1078
+ return false;
1079
+ }
1080
+ return tokens.every((token, index) => {
1081
+ const expectedToken = expected[index];
1082
+ return typeof token === "object" && token !== null && expectedToken !== void 0 && token.kind === expectedToken.kind && token.start === expectedToken.start && token.end === expectedToken.end;
1083
+ });
1084
+ }
1085
+ function applyImportedInlineIds(field, sidecar, state) {
1086
+ field.id = importedOrGeneratedId(
1087
+ typeof sidecar === "object" && sidecar !== null ? sidecar.field_id : void 0,
1088
+ "field",
1089
+ state.fieldIds
1090
+ );
1091
+ const aligned = isAlignedSidecar(sidecar, field);
1092
+ field.tokens.forEach((token, index) => {
1093
+ token.id = importedOrGeneratedId(aligned ? sidecar.tokens[index]?.id : void 0, token.kind, state.tokenIds);
1094
+ });
1095
+ return field;
1096
+ }
1097
+
1008
1098
  // src/document2/inlineScanner.ts
1009
1099
  var MATH_ENVIRONMENTS = /* @__PURE__ */ new Set([
1010
1100
  "equation",
@@ -1083,17 +1173,13 @@ function citeSpan(value, start) {
1083
1173
  function refSpan(value, start) {
1084
1174
  const eqrefPrefix = "\\eqref{";
1085
1175
  const refPrefix = "\\ref{";
1086
- let refCommand = "ref";
1087
- let prefix = refPrefix;
1088
- if (value.startsWith(eqrefPrefix, start) && !isEscaped(value, start)) {
1089
- refCommand = "eqref";
1090
- prefix = eqrefPrefix;
1091
- } else if (value.startsWith(refPrefix, start) && !isEscaped(value, start)) {
1092
- refCommand = "ref";
1093
- prefix = refPrefix;
1094
- } else {
1176
+ const isEqref = value.startsWith(eqrefPrefix, start) && !isEscaped(value, start);
1177
+ const isRef = value.startsWith(refPrefix, start) && !isEscaped(value, start);
1178
+ if (!isEqref && !isRef) {
1095
1179
  return null;
1096
1180
  }
1181
+ const refCommand = isEqref ? "eqref" : "ref";
1182
+ const prefix = isEqref ? eqrefPrefix : refPrefix;
1097
1183
  const openBrace = start + prefix.length - 1;
1098
1184
  if (value[openBrace] !== "{") {
1099
1185
  return null;
@@ -1152,7 +1238,14 @@ function mathSpanAt(value, i) {
1152
1238
  return null;
1153
1239
  }
1154
1240
  function detectMathSpans2(value) {
1155
- return detectInlineSpans2(value).filter((span) => span.kind === "math").map(({ kind: _kind, ...span }) => span);
1241
+ return detectInlineSpans2(value).filter((span) => span.kind === "math").map((span) => ({
1242
+ start: span.start,
1243
+ end: span.end,
1244
+ source: span.source,
1245
+ opening: span.opening,
1246
+ closing: span.closing,
1247
+ display: span.display
1248
+ }));
1156
1249
  }
1157
1250
  function detectInlineSpans2(value) {
1158
1251
  const spans = [];
@@ -1206,17 +1299,13 @@ function asBlockJson(value) {
1206
1299
  return value;
1207
1300
  }
1208
1301
  function blockIdFromJson(json, state) {
1209
- const imported = typeof json.id === "string" ? json.id.trim() : "";
1210
- if (imported.length > 0 && !state.used.has(imported)) {
1211
- state.used.add(imported);
1212
- return imported;
1213
- }
1214
- let generated = document2Id("block");
1215
- while (state.used.has(generated)) {
1216
- generated = document2Id("block");
1302
+ return importedOrGeneratedId(json.id, "block", state.blockIds);
1303
+ }
1304
+ function metadataFromJson(value) {
1305
+ if (!isObject2(value) || value.source !== "agent" && value.source !== "user") {
1306
+ return {};
1217
1307
  }
1218
- state.used.add(generated);
1219
- return generated;
1308
+ return { metadata: { source: value.source } };
1220
1309
  }
1221
1310
  function pushDiagnostic(diagnostics, options, path, message) {
1222
1311
  if (options.strict) {
@@ -1399,44 +1488,54 @@ function pushFormattedTextTokens(tokens, text, sourceStart, formats) {
1399
1488
  function closingForList(command) {
1400
1489
  return command === "\\begin{itemize}" ? "\\end{itemize}" : "\\end{enumerate}";
1401
1490
  }
1402
- function parseTextBlock(json, options, path, diagnostics, blockIds) {
1491
+ function parseTextBlock(json, options, path, diagnostics, identities) {
1403
1492
  const value = requireString(json.value, `${json.command} requires string value`);
1404
1493
  return {
1405
- id: blockIdFromJson(json, blockIds),
1494
+ id: blockIdFromJson(json, identities),
1406
1495
  kind: "textBlock",
1407
1496
  command: json.command,
1408
- field: createInlineField2(value, json.math_objects ?? [], options, `${path}.value`, diagnostics, json.command === "\\paragraph" ? json.formats ?? [] : []),
1497
+ field: applyImportedInlineIds(
1498
+ createInlineField2(value, json.math_objects ?? [], options, `${path}.value`, diagnostics, json.command === "\\paragraph" ? json.formats ?? [] : []),
1499
+ json.inline_ids,
1500
+ identities
1501
+ ),
1502
+ ...metadataFromJson(json.metadata),
1409
1503
  ...json.centered === true ? { centered: true } : {}
1410
1504
  };
1411
1505
  }
1412
- function parseListItem(json, options, path, diagnostics, blockIds) {
1506
+ function parseListItem(json, options, path, diagnostics, identities) {
1413
1507
  const value = requireString(json.value, "Document list item requires string value");
1414
1508
  const blocksJson = Array.isArray(json.blocks) ? json.blocks : [];
1415
1509
  return {
1416
- id: document2Id("item"),
1417
- field: createInlineField2(value, json.math_objects ?? [], options, `${path}.value`, diagnostics, json.formats ?? []),
1510
+ id: importedOrGeneratedId(json.id, "item", identities.itemIds),
1511
+ field: applyImportedInlineIds(
1512
+ createInlineField2(value, json.math_objects ?? [], options, `${path}.value`, diagnostics, json.formats ?? []),
1513
+ json.inline_ids,
1514
+ identities
1515
+ ),
1418
1516
  blocks: blocksJson.map(
1419
- (block, index) => parseBlock(asBlockJson(block), options, `${path}.blocks[${String(index)}]`, diagnostics, blockIds)
1517
+ (block, index) => parseBlock(asBlockJson(block), options, `${path}.blocks[${String(index)}]`, diagnostics, identities)
1420
1518
  )
1421
1519
  };
1422
1520
  }
1423
- function parseListBlock(json, options, path, diagnostics, blockIds) {
1521
+ function parseListBlock(json, options, path, diagnostics, identities) {
1424
1522
  if (!Array.isArray(json.items)) {
1425
1523
  throw new Error(`${json.command} requires items array`);
1426
1524
  }
1427
1525
  const command = json.command;
1428
1526
  const closing = closingForList(command);
1429
1527
  return {
1430
- id: blockIdFromJson(json, blockIds),
1528
+ id: blockIdFromJson(json, identities),
1431
1529
  kind: "list",
1432
1530
  command,
1433
1531
  closing,
1434
1532
  items: json.items.map(
1435
- (item, index) => parseListItem(item, options, `${path}.items[${String(index)}]`, diagnostics, blockIds)
1436
- )
1533
+ (item, index) => parseListItem(item, options, `${path}.items[${String(index)}]`, diagnostics, identities)
1534
+ ),
1535
+ ...metadataFromJson(json.metadata)
1437
1536
  };
1438
1537
  }
1439
- function parseTableBlock(json, options, path, diagnostics, blockIds) {
1538
+ function parseTableBlock(json, options, path, diagnostics, identities) {
1440
1539
  if (!Array.isArray(json.rows)) {
1441
1540
  throw new Error("\\begin{tabular} requires rows array");
1442
1541
  }
@@ -1452,75 +1551,84 @@ function parseTableBlock(json, options, path, diagnostics, blockIds) {
1452
1551
  const cellMathObjects = mathObjects.slice(mathObjectIndex, mathObjectIndex + spanCount);
1453
1552
  mathObjectIndex += spanCount;
1454
1553
  const cellFormats = json.cell_formats?.[rowIndex]?.[columnIndex] ?? [];
1455
- return createInlineField2(value, cellMathObjects, options, `${path}.rows[${String(rowIndex)}][${String(columnIndex)}]`, diagnostics, cellFormats);
1554
+ return applyImportedInlineIds(
1555
+ createInlineField2(value, cellMathObjects, options, `${path}.rows[${String(rowIndex)}][${String(columnIndex)}]`, diagnostics, cellFormats),
1556
+ json.cell_inline_ids?.[rowIndex]?.[columnIndex],
1557
+ identities
1558
+ );
1456
1559
  });
1457
1560
  });
1458
1561
  if (mathObjects.length > 0 && mathObjects.length !== mathObjectIndex) {
1459
1562
  pushDiagnostic(diagnostics, options, path, `math_objects count mismatch: detected ${String(mathObjectIndex)}, got ${String(mathObjects.length)}`);
1460
1563
  }
1461
1564
  return {
1462
- id: blockIdFromJson(json, blockIds),
1565
+ id: blockIdFromJson(json, identities),
1463
1566
  kind: "table",
1464
1567
  command: "\\begin{tabular}",
1465
1568
  closing: "\\end{tabular}",
1466
1569
  columns: typeof json.columns === "string" ? json.columns : "",
1467
1570
  rows,
1468
- ...parseFloatMetaFromJson(json)
1571
+ ...parseFloatMetaFromJson(json),
1572
+ ...metadataFromJson(json.metadata)
1469
1573
  };
1470
1574
  }
1471
- function parseImageBlock(json, blockIds) {
1575
+ function parseImageBlock(json, identities) {
1472
1576
  const assetId = typeof json.asset_id === "string" && json.asset_id.length > 0 ? json.asset_id : void 0;
1473
1577
  const value = assetId !== void 0 ? typeof json.value === "string" ? json.value : "" : requireString(json.value, "\\includegraphics requires string value");
1474
1578
  return {
1475
- id: blockIdFromJson(json, blockIds),
1579
+ id: blockIdFromJson(json, identities),
1476
1580
  kind: "image",
1477
1581
  command: "\\includegraphics",
1478
1582
  value,
1479
1583
  ...assetId !== void 0 ? { assetId } : {},
1480
1584
  options: isRecordOfStrings(json.options) ? json.options : {},
1481
- ...parseFloatMetaFromJson(json)
1585
+ ...parseFloatMetaFromJson(json),
1586
+ ...metadataFromJson(json.metadata)
1482
1587
  };
1483
1588
  }
1484
- function parseRawBlock(json, blockIds) {
1589
+ function parseRawBlock(json, identities) {
1485
1590
  return {
1486
- id: blockIdFromJson(json, blockIds),
1591
+ id: blockIdFromJson(json, identities),
1487
1592
  kind: "raw",
1488
1593
  command: "\\raw",
1489
- value: typeof json.value === "string" ? json.value : ""
1594
+ value: typeof json.value === "string" ? json.value : "",
1595
+ ...metadataFromJson(json.metadata)
1490
1596
  };
1491
1597
  }
1492
- function parseBibliographyBlock(json, blockIds) {
1598
+ function parseBibliographyBlock(json, identities) {
1493
1599
  return {
1494
- id: blockIdFromJson(json, blockIds),
1600
+ id: blockIdFromJson(json, identities),
1495
1601
  kind: "bibliography",
1496
1602
  command: "\\begin{thebibliography}",
1497
- closing: "\\end{thebibliography}"
1603
+ closing: "\\end{thebibliography}",
1604
+ ...metadataFromJson(json.metadata)
1498
1605
  };
1499
1606
  }
1500
- function parseBlock(json, options, path, diagnostics, blockIds) {
1607
+ function parseBlock(json, options, path, diagnostics, identities) {
1501
1608
  if (TEXT_COMMANDS.has(json.command)) {
1502
- return parseTextBlock(json, options, path, diagnostics, blockIds);
1609
+ return parseTextBlock(json, options, path, diagnostics, identities);
1503
1610
  }
1504
1611
  if (LIST_COMMANDS.has(json.command)) {
1505
- return parseListBlock(json, options, path, diagnostics, blockIds);
1612
+ return parseListBlock(json, options, path, diagnostics, identities);
1506
1613
  }
1507
1614
  if (json.command === "\\begin{tabular}") {
1508
- return parseTableBlock(json, options, path, diagnostics, blockIds);
1615
+ return parseTableBlock(json, options, path, diagnostics, identities);
1509
1616
  }
1510
1617
  if (json.command === "\\includegraphics") {
1511
- return parseImageBlock(json, blockIds);
1618
+ return parseImageBlock(json, identities);
1512
1619
  }
1513
1620
  if (json.command === "\\begin{thebibliography}" || json.command === "\\bibliography") {
1514
- return parseBibliographyBlock(json, blockIds);
1621
+ return parseBibliographyBlock(json, identities);
1515
1622
  }
1516
1623
  if (json.command === "\\raw") {
1517
- return parseRawBlock(json, blockIds);
1624
+ return parseRawBlock(json, identities);
1518
1625
  }
1519
1626
  return {
1520
- id: blockIdFromJson(json, blockIds),
1627
+ id: blockIdFromJson(json, identities),
1521
1628
  kind: "raw",
1522
1629
  command: "\\raw",
1523
- value: typeof json.value === "string" ? json.value : json.command
1630
+ value: typeof json.value === "string" ? json.value : json.command,
1631
+ ...metadataFromJson(json.metadata)
1524
1632
  };
1525
1633
  }
1526
1634
  function fromDocumentJson2(json, options = {}) {
@@ -1531,13 +1639,13 @@ function fromDocumentJson2(json, options = {}) {
1531
1639
  throw new Error("DocumentObject requires blocks array");
1532
1640
  }
1533
1641
  const diagnostics = [];
1534
- const blockIds = { used: /* @__PURE__ */ new Set() };
1642
+ const identities = createDocument2IdentityState();
1535
1643
  return {
1536
1644
  nodeType: "DocumentObject",
1537
1645
  meta: normalizeDocument2Meta(json.meta),
1538
1646
  references: parseReferences(json.references),
1539
1647
  blocks: json.blocks.map(
1540
- (block, index) => parseBlock(asBlockJson(block), options, `$.blocks[${String(index)}]`, diagnostics, blockIds)
1648
+ (block, index) => parseBlock(asBlockJson(block), options, `$.blocks[${String(index)}]`, diagnostics, identities)
1541
1649
  ),
1542
1650
  diagnostics
1543
1651
  };
@@ -8358,12 +8466,14 @@ function cloneField(field) {
8358
8466
  return { id: field.id, tokens: field.tokens.map(cloneToken) };
8359
8467
  }
8360
8468
  function cloneBlock(block) {
8469
+ const metadata = block.metadata ? { metadata: { ...block.metadata } } : {};
8361
8470
  if (block.kind === "textBlock") {
8362
- return { ...block, field: cloneField(block.field) };
8471
+ return { ...block, ...metadata, field: cloneField(block.field) };
8363
8472
  }
8364
8473
  if (block.kind === "list") {
8365
8474
  return {
8366
8475
  ...block,
8476
+ ...metadata,
8367
8477
  items: block.items.map((item) => ({
8368
8478
  ...item,
8369
8479
  field: cloneField(item.field),
@@ -8372,12 +8482,12 @@ function cloneBlock(block) {
8372
8482
  };
8373
8483
  }
8374
8484
  if (block.kind === "table") {
8375
- return { ...block, rows: block.rows.map((row) => row.map(cloneField)) };
8485
+ return { ...block, ...metadata, rows: block.rows.map((row) => row.map(cloneField)) };
8376
8486
  }
8377
8487
  if (block.kind === "image") {
8378
- return { ...block, options: { ...block.options } };
8488
+ return { ...block, ...metadata, options: { ...block.options } };
8379
8489
  }
8380
- return { ...block };
8490
+ return { ...block, ...metadata };
8381
8491
  }
8382
8492
  function cloneDocument(document2) {
8383
8493
  return {
@@ -9150,12 +9260,13 @@ function serializeField(field) {
9150
9260
  ...token.label !== void 0 ? { label: token.label } : {}
9151
9261
  });
9152
9262
  }
9153
- return { value, formats, mathObjects, hasPersistedMath };
9263
+ return { value, formats, mathObjects, hasPersistedMath, inlineIds: inlineIdsFromField(field) };
9154
9264
  }
9155
9265
  function fieldJson(field) {
9156
9266
  const serialized = serializeField(field);
9157
9267
  return {
9158
9268
  value: serialized.value,
9269
+ inline_ids: serialized.inlineIds,
9159
9270
  ...serialized.formats.length > 0 ? { formats: serialized.formats } : {},
9160
9271
  ...serialized.hasPersistedMath ? { math_objects: serialized.mathObjects } : {}
9161
9272
  };
@@ -9163,7 +9274,9 @@ function fieldJson(field) {
9163
9274
  function listItemJson(item) {
9164
9275
  const field = fieldJson(item.field);
9165
9276
  return {
9277
+ id: item.id,
9166
9278
  value: field.value ?? "",
9279
+ inline_ids: field.inline_ids,
9167
9280
  ...field.formats ? { formats: field.formats } : {},
9168
9281
  ...field.math_objects ? { math_objects: field.math_objects } : {},
9169
9282
  ...item.blocks.length > 0 ? { blocks: item.blocks.map(blockJson) } : {}
@@ -9175,6 +9288,7 @@ function blockJson(block) {
9175
9288
  id: block.id,
9176
9289
  command: block.command,
9177
9290
  ...fieldJson(block.field),
9291
+ ...block.metadata ? { metadata: { ...block.metadata } } : {},
9178
9292
  ...block.command === "\\paragraph" ? { centered: block.centered === true } : {}
9179
9293
  };
9180
9294
  }
@@ -9183,7 +9297,8 @@ function blockJson(block) {
9183
9297
  id: block.id,
9184
9298
  command: block.command,
9185
9299
  closing: block.closing,
9186
- items: block.items.map(listItemJson)
9300
+ items: block.items.map(listItemJson),
9301
+ ...block.metadata ? { metadata: { ...block.metadata } } : {}
9187
9302
  };
9188
9303
  }
9189
9304
  if (block.kind === "table") {
@@ -9195,13 +9310,15 @@ function blockJson(block) {
9195
9310
  closing: block.closing,
9196
9311
  columns: block.columns,
9197
9312
  rows: fields.map((row) => row.map((field) => field.value)),
9313
+ cell_inline_ids: fields.map((row) => row.map((field) => field.inlineIds)),
9198
9314
  ...fields.some((row) => row.some((field) => field.formats.length > 0)) ? { cell_formats: fields.map((row) => row.map((field) => field.formats)) } : {},
9199
9315
  ...hasPersistedMath ? { math_objects: fields.flatMap((row) => row.flatMap((field) => field.mathObjects)) } : {},
9200
9316
  centered: block.centered,
9201
9317
  caption_enabled: block.captionEnabled,
9202
9318
  caption: block.caption,
9203
9319
  label_enabled: block.labelEnabled,
9204
- label: block.label
9320
+ label: block.label,
9321
+ ...block.metadata ? { metadata: { ...block.metadata } } : {}
9205
9322
  };
9206
9323
  }
9207
9324
  if (block.kind === "image") {
@@ -9215,13 +9332,24 @@ function blockJson(block) {
9215
9332
  caption_enabled: block.captionEnabled,
9216
9333
  caption: block.caption,
9217
9334
  label_enabled: block.labelEnabled,
9218
- label: block.label
9335
+ label: block.label,
9336
+ ...block.metadata ? { metadata: { ...block.metadata } } : {}
9219
9337
  };
9220
9338
  }
9221
9339
  if (block.kind === "bibliography") {
9222
- return { id: block.id, command: block.command, closing: block.closing };
9340
+ return {
9341
+ id: block.id,
9342
+ command: block.command,
9343
+ closing: block.closing,
9344
+ ...block.metadata ? { metadata: { ...block.metadata } } : {}
9345
+ };
9223
9346
  }
9224
- return { id: block.id, command: block.command, value: block.value };
9347
+ return {
9348
+ id: block.id,
9349
+ command: block.command,
9350
+ value: block.value,
9351
+ ...block.metadata ? { metadata: { ...block.metadata } } : {}
9352
+ };
9225
9353
  }
9226
9354
  function referenceJson(reference) {
9227
9355
  return {
@@ -9252,7 +9380,7 @@ function toDocumentJson2(document2) {
9252
9380
  }
9253
9381
 
9254
9382
  // src/document2/keys.ts
9255
- var DOCUMENT2_KEY_PATTERN = /^[\p{L}\p{M}0-9:._-]+$/u;
9383
+ var DOCUMENT2_KEY_PATTERN = /^[\p{L}\p{M}\p{Nd}:._-]+$/u;
9256
9384
  function normalizeDocument2Key(key) {
9257
9385
  return key.normalize("NFC").trim();
9258
9386
  }
@@ -9870,19 +9998,21 @@ function previewInlines(field, islands, output, equationSide, document2, preview
9870
9998
  }
9871
9999
  function textBlockPreview(block, islands, output, equationSide, document2, previewOptions) {
9872
10000
  const inlines = previewInlines(block.field, islands, output, equationSide, document2, previewOptions);
10001
+ const metadata = block.metadata ? { metadata: { ...block.metadata } } : {};
9873
10002
  if (block.command === "\\section") {
9874
- return { kind: "heading", id: block.id, level: 1, inlines };
10003
+ return { kind: "heading", id: block.id, level: 1, inlines, ...metadata };
9875
10004
  }
9876
10005
  if (block.command === "\\subsection") {
9877
- return { kind: "heading", id: block.id, level: 2, inlines };
10006
+ return { kind: "heading", id: block.id, level: 2, inlines, ...metadata };
9878
10007
  }
9879
10008
  if (block.command === "\\subsubsection") {
9880
- return { kind: "heading", id: block.id, level: 3, inlines };
10009
+ return { kind: "heading", id: block.id, level: 3, inlines, ...metadata };
9881
10010
  }
9882
10011
  return {
9883
10012
  kind: "paragraph",
9884
10013
  id: block.id,
9885
10014
  inlines,
10015
+ ...metadata,
9886
10016
  ...block.centered ? { centered: true } : {}
9887
10017
  };
9888
10018
  }
@@ -9913,7 +10043,8 @@ function blockPreview(block, islands, output, equationSide, document2, previewOp
9913
10043
  id: item.id,
9914
10044
  inlines: previewInlines(item.field, islands, output, equationSide, document2, previewOptions),
9915
10045
  blocks: item.blocks.map((child) => blockPreview(child, islands, output, equationSide, document2, previewOptions))
9916
- }))
10046
+ })),
10047
+ ...block.metadata ? { metadata: { ...block.metadata } } : {}
9917
10048
  };
9918
10049
  }
9919
10050
  if (block.kind === "table") {
@@ -9923,7 +10054,8 @@ function blockPreview(block, islands, output, equationSide, document2, previewOp
9923
10054
  id: block.id,
9924
10055
  rows: block.rows.map((row) => row.map((cell) => previewInlines(cell, islands, output, equationSide, document2, previewOptions))),
9925
10056
  ...block.captionEnabled && block.caption.trim().length > 0 ? { caption: block.caption.trim() } : {},
9926
- ...label.length > 0 ? { label, numberLabel: floatNumberLabel(document2, label, previewOptions) } : {}
10057
+ ...label.length > 0 ? { label, numberLabel: floatNumberLabel(document2, label, previewOptions) } : {},
10058
+ ...block.metadata ? { metadata: { ...block.metadata } } : {}
9927
10059
  };
9928
10060
  }
9929
10061
  if (block.kind === "image") {
@@ -9935,7 +10067,8 @@ function blockPreview(block, islands, output, equationSide, document2, previewOp
9935
10067
  ...block.assetId !== void 0 ? { assetId: block.assetId } : {},
9936
10068
  options: block.options,
9937
10069
  ...block.captionEnabled && block.caption.trim().length > 0 ? { caption: block.caption.trim() } : {},
9938
- ...label.length > 0 ? { label, numberLabel: floatNumberLabel(document2, label, previewOptions) } : {}
10070
+ ...label.length > 0 ? { label, numberLabel: floatNumberLabel(document2, label, previewOptions) } : {},
10071
+ ...block.metadata ? { metadata: { ...block.metadata } } : {}
9939
10072
  };
9940
10073
  }
9941
10074
  if (block.kind === "bibliography") {
@@ -9955,10 +10088,11 @@ function blockPreview(block, islands, output, equationSide, document2, previewOp
9955
10088
  url: reference.url,
9956
10089
  venue: reference.venue,
9957
10090
  fieldSeparator: reference.fieldSeparator
9958
- }))
10091
+ })),
10092
+ ...block.metadata ? { metadata: { ...block.metadata } } : {}
9959
10093
  };
9960
10094
  }
9961
- return { kind: "omit", id: block.id };
10095
+ return { kind: "omit", id: block.id, ...block.metadata ? { metadata: { ...block.metadata } } : {} };
9962
10096
  }
9963
10097
  function articleChromePreview(document2, uiLocale, previewOptions) {
9964
10098
  const meta = document2.meta ?? emptyDocument2Meta();
@@ -10106,7 +10240,7 @@ var DOCUMENT2_MESSAGES = {
10106
10240
  editInternalRef: "\u062A\u062D\u0631\u064A\u0631 \u0627\u0644\u0645\u0631\u062C\u0639 \u0627\u0644\u062F\u0627\u062E\u0644\u064A",
10107
10241
  deleteInternalRef: "\u062D\u0630\u0641 \u0627\u0644\u0645\u0631\u062C\u0639 \u0627\u0644\u062F\u0627\u062E\u0644\u064A",
10108
10242
  labelsTitle: "\u0627\u0644\u062A\u0633\u0645\u064A\u0627\u062A \u0648\u0627\u0644\u0645\u0631\u0627\u062C\u0639 \u0627\u0644\u062F\u0627\u062E\u0644\u064A\u0629",
10109
- labelsHelp: "\u0627\u0644\u062A\u0633\u0645\u064A\u0627\u062A \u0644\u0644\u0645\u0631\u0627\u062C\u0639 \u062F\u0627\u062E\u0644 \u0627\u0644\u0645\u0633\u062A\u0646\u062F\u061B \u0627\u0644\u0645\u0631\u0627\u062C\u0639 \u0627\u0644\u0628\u0628\u0644\u064A\u0648\u063A\u0631\u0627\u0641\u064A\u0629 \u0644\u0644\u0627\u0642\u062A\u0628\u0627\u0633\u0627\u062A \u0645\u0646 \u0642\u0627\u0626\u0645\u0629 \u0627\u0644\u0645\u0631\u0627\u062C\u0639.",
10243
+ labelsHelp: "\u0627\u0644\u062A\u0633\u0645\u064A\u0627\u062A \u0644\u0644\u0645\u0631\u0627\u062C\u0639 \u062F\u0627\u062E\u0644 \u0627\u0644\u0645\u0633\u062A\u0646\u062F\u061B \u0648\u0627\u0644\u0627\u0642\u062A\u0628\u0627\u0633\u0627\u062A \u062A\u0633\u062A\u0646\u062F \u0625\u0644\u0649 \u0642\u0627\u0626\u0645\u0629 \u0627\u0644\u0645\u0631\u0627\u062C\u0639.",
10110
10244
  captionToggle: "\u062A\u0639\u0644\u064A\u0642",
10111
10245
  labelToggle: "\u062A\u0633\u0645\u064A\u0629",
10112
10246
  centerParagraph: "\u062A\u0648\u0633\u064A\u0637 \u0627\u0644\u0641\u0642\u0631\u0629",
@@ -11234,6 +11368,12 @@ function RefChip({
11234
11368
  ] });
11235
11369
  }
11236
11370
 
11371
+ // src/react-document2/xelatexTextValidation.ts
11372
+ var XELATEX_UNSUPPORTED_EMOJI_PATTERN = /[\p{Emoji_Presentation}\p{Emoji_Modifier}\p{Regional_Indicator}\uFE0F\u20E3]/u;
11373
+ function hasXeLatexUnsupportedEmoji(value) {
11374
+ return XELATEX_UNSUPPORTED_EMOJI_PATTERN.test(value);
11375
+ }
11376
+
11237
11377
  // src/react-document2/InlineField.tsx
11238
11378
  var import_jsx_runtime6 = require("react/jsx-runtime");
11239
11379
  function rememberCaret(element, blockId, fieldId, tokenId, onFieldFocus) {
@@ -11253,6 +11393,9 @@ function fitTextareaHeight(element) {
11253
11393
  element.style.height = "auto";
11254
11394
  element.style.height = `${String(element.scrollHeight)}px`;
11255
11395
  }
11396
+ function xeLatexUnsupportedEmojiMessage(uiLocale) {
11397
+ return uiLocale === "ar" ? "\u0647\u0630\u0627 \u0627\u0644\u0631\u0645\u0632 \u0627\u0644\u062A\u0639\u0628\u064A\u0631\u064A \u063A\u064A\u0631 \u0645\u062F\u0639\u0648\u0645 \u0641\u064A \u062A\u0635\u062F\u064A\u0631 XeLaTeX \u0627\u0644\u062D\u0627\u0644\u064A \u0628\u062E\u0637 Amiri." : "This emoji is not supported by the current XeLaTeX export using the Amiri font.";
11398
+ }
11256
11399
  function InlineField({
11257
11400
  field,
11258
11401
  blockId,
@@ -11371,74 +11514,92 @@ function InlineField({
11371
11514
  const backwardArrowKey = documentDirection === "rtl" ? "ArrowRight" : "ArrowLeft";
11372
11515
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "butex-document2-widget__inline-field", dir: documentDirection, "data-document-direction": documentDirection, children: field.tokens.map((token) => {
11373
11516
  if (token.kind === "text") {
11374
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
11375
- "textarea",
11376
- {
11377
- className: "butex-document2-widget__inline-text",
11378
- value: token.text,
11379
- "data-bold": token.style?.bold === true ? "true" : void 0,
11380
- "data-italic": token.style?.italic === true ? "true" : void 0,
11381
- "data-underline": token.style?.underline === true ? "true" : void 0,
11382
- dir: documentDirection,
11383
- "aria-label": messages.text,
11384
- rows: 1,
11385
- "data-field-id": field.id,
11386
- "data-text-token-id": token.id,
11387
- ref: (element) => {
11388
- if (element) {
11389
- textRefs.current.set(token.id, element);
11390
- fitTextareaHeight(element);
11391
- } else {
11392
- textRefs.current.delete(token.id);
11393
- }
11394
- },
11395
- onChange: (event) => {
11396
- onTextChange(field.id, token.id, event.currentTarget.value);
11397
- fitTextareaHeight(event.currentTarget);
11398
- },
11399
- onKeyDown: (event) => {
11400
- const element = event.currentTarget;
11401
- const collapsed = element.selectionStart === element.selectionEnd;
11402
- if (!collapsed) {
11403
- return;
11404
- }
11405
- if (event.key === forwardArrowKey && element.selectionStart === element.value.length) {
11406
- const next = adjacentIslandId(token.id, 1);
11407
- if (next) {
11408
- event.preventDefault();
11409
- if (next.kind === "math") {
11410
- focusMathToken(next.id);
11411
- } else if (next.kind === "cite") {
11412
- focusCiteToken(next.id);
11413
- } else {
11414
- focusRefToken(next.id);
11415
- }
11517
+ const unsupportedEmoji = hasXeLatexUnsupportedEmoji(token.text);
11518
+ const errorId = `butex-document2-xelatex-text-error-${token.id}`;
11519
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react3.Fragment, { children: [
11520
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
11521
+ "textarea",
11522
+ {
11523
+ className: "butex-document2-widget__inline-text",
11524
+ value: token.text,
11525
+ "data-bold": token.style?.bold === true ? "true" : void 0,
11526
+ "data-italic": token.style?.italic === true ? "true" : void 0,
11527
+ "data-underline": token.style?.underline === true ? "true" : void 0,
11528
+ dir: documentDirection,
11529
+ "aria-label": messages.text,
11530
+ "aria-invalid": unsupportedEmoji ? true : void 0,
11531
+ "aria-describedby": unsupportedEmoji ? errorId : void 0,
11532
+ rows: 1,
11533
+ "data-field-id": field.id,
11534
+ "data-text-token-id": token.id,
11535
+ style: unsupportedEmoji ? {
11536
+ borderColor: "var(--butex-document2-error)",
11537
+ background: "var(--butex-document2-error-bg)"
11538
+ } : void 0,
11539
+ ref: (element) => {
11540
+ if (element) {
11541
+ textRefs.current.set(token.id, element);
11542
+ fitTextareaHeight(element);
11543
+ } else {
11544
+ textRefs.current.delete(token.id);
11545
+ }
11546
+ },
11547
+ onChange: (event) => {
11548
+ onTextChange(field.id, token.id, event.currentTarget.value);
11549
+ fitTextareaHeight(event.currentTarget);
11550
+ },
11551
+ onKeyDown: (event) => {
11552
+ const element = event.currentTarget;
11553
+ const collapsed = element.selectionStart === element.selectionEnd;
11554
+ if (!collapsed) {
11555
+ return;
11416
11556
  }
11417
- } else if (event.key === backwardArrowKey && element.selectionStart === 0) {
11418
- const previous = adjacentIslandId(token.id, -1);
11419
- if (previous) {
11420
- event.preventDefault();
11421
- if (previous.kind === "math") {
11422
- focusMathToken(previous.id);
11423
- } else if (previous.kind === "cite") {
11424
- focusCiteToken(previous.id);
11425
- } else {
11426
- focusRefToken(previous.id);
11557
+ if (event.key === forwardArrowKey && element.selectionStart === element.value.length) {
11558
+ const next = adjacentIslandId(token.id, 1);
11559
+ if (next) {
11560
+ event.preventDefault();
11561
+ if (next.kind === "math") {
11562
+ focusMathToken(next.id);
11563
+ } else if (next.kind === "cite") {
11564
+ focusCiteToken(next.id);
11565
+ } else {
11566
+ focusRefToken(next.id);
11567
+ }
11568
+ }
11569
+ } else if (event.key === backwardArrowKey && element.selectionStart === 0) {
11570
+ const previous = adjacentIslandId(token.id, -1);
11571
+ if (previous) {
11572
+ event.preventDefault();
11573
+ if (previous.kind === "math") {
11574
+ focusMathToken(previous.id);
11575
+ } else if (previous.kind === "cite") {
11576
+ focusCiteToken(previous.id);
11577
+ } else {
11578
+ focusRefToken(previous.id);
11579
+ }
11427
11580
  }
11428
11581
  }
11429
- }
11430
- },
11431
- onFocus: (event) => rememberCaret(event.currentTarget, blockId, field.id, token.id, onFieldFocus),
11432
- onClick: (event) => rememberCaret(event.currentTarget, blockId, field.id, token.id, onFieldFocus),
11433
- onKeyUp: (event) => {
11434
- rememberCaret(event.currentTarget, blockId, field.id, token.id, onFieldFocus);
11435
- fitTextareaHeight(event.currentTarget);
11436
- },
11437
- onSelect: (event) => rememberCaret(event.currentTarget, blockId, field.id, token.id, onFieldFocus),
11438
- onBlur: () => onFieldBlur?.()
11439
- },
11440
- token.id
11441
- );
11582
+ },
11583
+ onFocus: (event) => rememberCaret(event.currentTarget, blockId, field.id, token.id, onFieldFocus),
11584
+ onClick: (event) => rememberCaret(event.currentTarget, blockId, field.id, token.id, onFieldFocus),
11585
+ onKeyUp: (event) => {
11586
+ rememberCaret(event.currentTarget, blockId, field.id, token.id, onFieldFocus);
11587
+ fitTextareaHeight(event.currentTarget);
11588
+ },
11589
+ onSelect: (event) => rememberCaret(event.currentTarget, blockId, field.id, token.id, onFieldFocus),
11590
+ onBlur: () => onFieldBlur?.()
11591
+ }
11592
+ ),
11593
+ unsupportedEmoji ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
11594
+ "p",
11595
+ {
11596
+ id: errorId,
11597
+ className: "butex-document2-widget__field-error",
11598
+ style: { flexBasis: "100%" },
11599
+ children: xeLatexUnsupportedEmojiMessage(uiLocale)
11600
+ }
11601
+ ) : null
11602
+ ] }, token.id);
11442
11603
  }
11443
11604
  if (token.kind === "cite") {
11444
11605
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
@@ -12028,13 +12189,13 @@ function BlockEditor({
12028
12189
  }
12029
12190
  ) : null;
12030
12191
  if (isCollapsed && showChrome) {
12031
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("section", { className: chromeClass, children: [
12192
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("section", { className: chromeClass, "data-butex-block-source": block.metadata?.source, children: [
12032
12193
  header,
12033
12194
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "butex-document2-widget__block-summary", children: blockSummary(block, references.length, messages) })
12034
12195
  ] });
12035
12196
  }
12036
12197
  if (block.kind === "textBlock") {
12037
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("section", { className: chromeClass, children: [
12198
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("section", { className: chromeClass, "data-butex-block-source": block.metadata?.source, children: [
12038
12199
  header,
12039
12200
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(InlineField, { field: block.field, ...fieldProps }),
12040
12201
  block.command === "\\paragraph" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "butex-document2-widget__float-meta butex-document2-widget__float-meta--compact", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "butex-document2-widget__float-meta-toggle", children: [
@@ -12054,7 +12215,7 @@ function BlockEditor({
12054
12215
  ] });
12055
12216
  }
12056
12217
  if (block.kind === "list") {
12057
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("section", { className: chromeClass, children: [
12218
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("section", { className: chromeClass, "data-butex-block-source": block.metadata?.source, children: [
12058
12219
  header,
12059
12220
  block.items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "butex-document2-widget__field", dir: "rtl", children: [
12060
12221
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "butex-document2-widget__toolbar-label", children: block.command === "\\begin{enumerate}" ? `${messages.item} ${String(index + 1)}` : messages.item }),
@@ -12105,7 +12266,7 @@ function BlockEditor({
12105
12266
  ] });
12106
12267
  }
12107
12268
  if (block.kind === "table") {
12108
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("section", { className: chromeClass, children: [
12269
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("section", { className: chromeClass, "data-butex-block-source": block.metadata?.source, children: [
12109
12270
  header,
12110
12271
  block.rows.map((row, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "butex-document2-widget__row", dir: documentDirection, children: row.map((cell) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "butex-document2-widget__table-cell", dir: documentDirection, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(InlineField, { field: cell, ...fieldProps }) }, cell.id)) }, rowIndex)),
12111
12272
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
@@ -12127,7 +12288,7 @@ function BlockEditor({
12127
12288
  ] });
12128
12289
  }
12129
12290
  if (block.kind === "image") {
12130
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("section", { className: chromeClass, children: [
12291
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("section", { className: chromeClass, "data-butex-block-source": block.metadata?.source, children: [
12131
12292
  header,
12132
12293
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
12133
12294
  ImageAssetEditor,
@@ -12164,7 +12325,7 @@ function BlockEditor({
12164
12325
  ] });
12165
12326
  }
12166
12327
  if (block.kind === "bibliography") {
12167
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("section", { className: chromeClass, children: [
12328
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("section", { className: chromeClass, "data-butex-block-source": block.metadata?.source, children: [
12168
12329
  header,
12169
12330
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("ol", { className: "butex-document2-widget__bibliography-editor", dir: documentDirection, children: referenceList.map((reference, index) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("li", { children: [
12170
12331
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("strong", { children: [
@@ -12180,7 +12341,7 @@ function BlockEditor({
12180
12341
  onManageReferences ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", onClick: onManageReferences, children: messages.manageReferences }) : null
12181
12342
  ] });
12182
12343
  }
12183
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("section", { className: chromeClass, children: [
12344
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("section", { className: chromeClass, "data-butex-block-source": block.metadata?.source, children: [
12184
12345
  header,
12185
12346
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("pre", { className: "butex-document2-widget__raw", children: block.value })
12186
12347
  ] });
@@ -12669,6 +12830,7 @@ function PreviewBlock({
12669
12830
  }) {
12670
12831
  const messages = document2Messages(uiLocale);
12671
12832
  const floatCaptionSeparator = uiLocale === "ar" ? ": " : ". ";
12833
+ const source = "metadata" in block ? block.metadata?.source : void 0;
12672
12834
  function FloatCaption({ numberLabel, caption }) {
12673
12835
  if (!numberLabel && !caption) {
12674
12836
  return null;
@@ -12708,14 +12870,14 @@ function PreviewBlock({
12708
12870
  }
12709
12871
  if (block.kind === "heading") {
12710
12872
  const Tag = block.level === 1 ? "h1" : block.level === 2 ? "h2" : "h3";
12711
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Tag, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PreviewInlines, { inlines: block.inlines, output }) });
12873
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Tag, { "data-butex-block-source": source, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PreviewInlines, { inlines: block.inlines, output }) });
12712
12874
  }
12713
12875
  if (block.kind === "paragraph") {
12714
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: block.centered ? "butex-document2-widget__preview-paragraph--centered" : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PreviewInlines, { inlines: block.inlines, output }) });
12876
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { "data-butex-block-source": source, className: block.centered ? "butex-document2-widget__preview-paragraph--centered" : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PreviewInlines, { inlines: block.inlines, output }) });
12715
12877
  }
12716
12878
  if (block.kind === "list") {
12717
12879
  const Tag = block.ordered ? "ol" : "ul";
12718
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Tag, { children: block.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("li", { children: [
12880
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Tag, { "data-butex-block-source": source, children: block.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("li", { children: [
12719
12881
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PreviewInlines, { inlines: item.inlines, output }),
12720
12882
  item.blocks.map((child) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
12721
12883
  PreviewBlock,
@@ -12735,20 +12897,20 @@ function PreviewBlock({
12735
12897
  return null;
12736
12898
  }
12737
12899
  if (block.kind === "table") {
12738
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("figure", { className: "butex-document2-widget__preview-float", children: [
12900
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("figure", { className: "butex-document2-widget__preview-float", "data-butex-block-source": source, children: [
12739
12901
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("table", { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("tbody", { children: block.rows.map((row, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("tr", { children: row.map((cell, columnIndex) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PreviewInlines, { inlines: cell, output }) }, columnIndex)) }, rowIndex)) }) }),
12740
12902
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FloatCaption, { numberLabel: block.numberLabel, caption: block.caption })
12741
12903
  ] });
12742
12904
  }
12743
12905
  if (block.kind === "image") {
12744
12906
  const src = resolveImageUrl ? resolveImageUrl({ assetId: block.assetId, value: block.src }) : block.src;
12745
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("figure", { className: "butex-document2-widget__preview-float", children: [
12907
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("figure", { className: "butex-document2-widget__preview-float", "data-butex-block-source": source, children: [
12746
12908
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("img", { src, alt: block.caption ?? "" }),
12747
12909
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FloatCaption, { numberLabel: block.numberLabel, caption: block.caption })
12748
12910
  ] });
12749
12911
  }
12750
12912
  if (block.kind === "bibliography") {
12751
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("ol", { className: "butex-document2-widget__preview-bibliography", children: block.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("li", { children: [
12913
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("ol", { className: "butex-document2-widget__preview-bibliography", "data-butex-block-source": source, children: block.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("li", { children: [
12752
12914
  /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "butex-document2-widget__preview-bib-number", children: [
12753
12915
  item.numberLabel,
12754
12916
  "."