@columnus/sdk 0.3.0 → 0.3.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.
Files changed (30) hide show
  1. package/dist/blocknote-editor-FP33A6RJ.js +7 -0
  2. package/dist/{blocknote-editor-547WFBXP.js.map → blocknote-editor-FP33A6RJ.js.map} +1 -1
  3. package/dist/blocknote-preview-QZ5SC2GJ.js +7 -0
  4. package/dist/{blocknote-preview-CTMNUSYX.js.map → blocknote-preview-QZ5SC2GJ.js.map} +1 -1
  5. package/dist/{chunk-JYSABU33.js → chunk-6LKVKI5O.js} +3 -3
  6. package/dist/{chunk-JYSABU33.js.map → chunk-6LKVKI5O.js.map} +1 -1
  7. package/dist/{chunk-BQCD5MEV.js → chunk-CKNRITN3.js} +4 -4
  8. package/dist/{chunk-BQCD5MEV.js.map → chunk-CKNRITN3.js.map} +1 -1
  9. package/dist/{chunk-IMYSQX2X.js → chunk-FKHOREJP.js} +4 -4
  10. package/dist/{chunk-IMYSQX2X.js.map → chunk-FKHOREJP.js.map} +1 -1
  11. package/dist/{chunk-XWMTXQF3.js → chunk-LTPU2AL3.js} +83 -36
  12. package/dist/chunk-LTPU2AL3.js.map +1 -0
  13. package/dist/{chunk-SKE2RDD2.js → chunk-QN3K6RRP.js} +212 -104
  14. package/dist/chunk-QN3K6RRP.js.map +1 -0
  15. package/dist/cms/convex/index.js +2 -2
  16. package/dist/cms/index.js +2 -2
  17. package/dist/cms/tables/tables-dialog.js +2 -2
  18. package/dist/{editor-543ARQ6S.js → editor-HJ3UNV3Q.js} +10 -10
  19. package/dist/{editor-543ARQ6S.js.map → editor-HJ3UNV3Q.js.map} +1 -1
  20. package/dist/mcp-cli.js +23 -9
  21. package/dist/types/cms/src/projection/cms-projection.d.ts +13 -1
  22. package/dist/types/cms/src/provider/cms-provider.d.ts +11 -0
  23. package/dist/types/fields/src/components/row-edit-panel.d.ts +2 -0
  24. package/dist/types/fields/src/components/row-editor.d.ts +3 -1
  25. package/dist/types/fields/src/components/use-picker-combobox.d.ts +2 -0
  26. package/package.json +1 -1
  27. package/dist/blocknote-editor-547WFBXP.js +0 -7
  28. package/dist/blocknote-preview-CTMNUSYX.js +0 -7
  29. package/dist/chunk-SKE2RDD2.js.map +0 -1
  30. package/dist/chunk-XWMTXQF3.js.map +0 -1
@@ -1,8 +1,8 @@
1
1
  import { useMarkdownInsertPickers } from './chunk-ZTWPGA37.js';
2
2
  import { readSessionCookie } from './chunk-QPQRNIKG.js';
3
- import { cmsBackdrop, cmsBox, cmsButton, ghostBtn, CMS_FIELD_EDITOR_Z_INDEX, buildStampAttrs, ACCENT_FG, ACCENT, primaryBtn, IconPublish, dangerBtn, IconTrash, cmsMuted, CMS_ROW_EDITOR_Z_INDEX, Icon, CMS_MARKDOWN_EDITOR_Z_INDEX } from './chunk-ICKWVUW7.js';
4
- import { createInertFieldsDataAdapter, inertRichtextHostAdapter, RichtextHostProvider, FieldsDataProvider, ImageCell, FieldInput, isPickerOverlayTarget, RowEditor, Dialog, DialogContent, preventDismissOnPickerOverlay, DialogHeader, DialogTitle, DialogDescription, DialogFooter, Button, Label, RichDocView, previewLabel, MarkdownFieldTrigger, validateFileForKind, CellRenderer } from './chunk-XWMTXQF3.js';
5
- import { fallbackPreviewLabel, filterSortDocuments, myDraft, toDocumentId, isValidAssetId, stripSystemFields, tableDisplayName, fieldDisplayName, editorAccessEnabled, richContentPlainText, newProvisionalRowId, findTableAccess, findProposalIdsOverlappingTarget, validatePatch, stringifyRichDoc, SHARE_LIST_LIMIT, collectRichDocAssetIds, formatNumericDate, looksLikeId, normalizeRichField, emptyToUndefined, isHttpUrl, focalObjectPosition, formatIdShort, refTarget, staleFieldNames, proposalDiffFieldNames, computeProposalRecordDiff, plainTextIfRichDoc } from './chunk-5IPH2A64.js';
3
+ import { cmsBackdrop, cmsBox, cmsButton, ghostBtn, CMS_FIELD_EDITOR_Z_INDEX, buildStampAttrs, ACCENT_FG, ACCENT, primaryBtn, dangerBtn, IconTrash, cmsMuted, CMS_ROW_EDITOR_Z_INDEX, Icon, CMS_MARKDOWN_EDITOR_Z_INDEX } from './chunk-ICKWVUW7.js';
4
+ import { createInertFieldsDataAdapter, inertRichtextHostAdapter, RichtextHostProvider, FieldsDataProvider, TooltipProvider, ImageCell, FieldInput, isPickerOverlayTarget, RowEditor, Dialog, DialogContent, preventDismissOnPickerOverlay, DialogHeader, DialogTitle, DialogDescription, DialogFooter, Button, Label, RichDocView, previewLabel, MarkdownFieldTrigger, validateFileForKind, CellRenderer } from './chunk-LTPU2AL3.js';
5
+ import { fallbackPreviewLabel, filterSortDocuments, myDraft, toDocumentId, isValidAssetId, stripSystemFields, tableDisplayName, fieldDisplayName, editorAccessEnabled, richContentPlainText, newProvisionalRowId, findTableAccess, findProposalIdsOverlappingTarget, validatePatch, stringifyRichDoc, SHARE_LIST_LIMIT, collectRichDocAssetIds, formatNumericDate, looksLikeId, normalizeRichField, emptyToUndefined, isHttpUrl, focalObjectPosition, formatIdShort, plainTextIfRichDoc, refTarget, staleFieldNames, proposalDiffFieldNames, computeProposalRecordDiff } from './chunk-5IPH2A64.js';
6
6
  import { createContext, lazy, useMemo, useState, useRef, useCallback, useEffect, useContext, useId, useLayoutEffect, Suspense } from 'react';
7
7
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
8
8
  import { createPortal } from 'react-dom';
@@ -237,7 +237,7 @@ function DefaultRichtextHostProvider({
237
237
  return /* @__PURE__ */ jsx(RichtextHostProvider, { adapter: resolved, children });
238
238
  }
239
239
  var MarkdownEditorDialogLazy = lazy(
240
- () => import('./editor-543ARQ6S.js').then((m) => ({ default: m.MarkdownEditorDialog }))
240
+ () => import('./editor-HJ3UNV3Q.js').then((m) => ({ default: m.MarkdownEditorDialog }))
241
241
  );
242
242
  function defaultRenderMarkdownField(props) {
243
243
  return /* @__PURE__ */ jsx(CmsMarkdownFieldInput, { ...props });
@@ -555,6 +555,11 @@ function draftTitle(proposal, mine) {
555
555
  if (!mine) return proposal.createdByName ?? "Another editor";
556
556
  return proposal.draftLabel ?? (proposal.draftKey ? "Builder session" : "Toolbar edits");
557
557
  }
558
+ var changeKey = (proposalId, target) => JSON.stringify([proposalId, target.table, target.rowId, target.field ?? null]);
559
+ function isOnPage(proposal, editorUserId, draftKey) {
560
+ const mine = editorUserId !== null && proposal.createdByUserId === editorUserId;
561
+ return !mine || proposal.draftKey === draftKey;
562
+ }
558
563
  var EMPTY_FIELD = { value: void 0, origin: null };
559
564
  function tableRowsFor(tables, table) {
560
565
  let rows = tables.get(table);
@@ -581,26 +586,26 @@ function rowFor(tables, table, rowId) {
581
586
  }
582
587
  return row;
583
588
  }
584
- function applyFields(row, patch, origin) {
589
+ function applyFields(row, patch, origin, skip) {
585
590
  for (const [field, value] of Object.entries(patch.fields)) {
586
- if (field === "_id") continue;
591
+ if (field === "_id" || skip?.has(field)) continue;
587
592
  row.value[field] = value;
588
593
  row.origins.set(field, origin);
589
594
  }
590
595
  for (const field of patch.clearFields ?? []) {
591
- if (field === "_id") continue;
596
+ if (field === "_id" || skip?.has(field)) continue;
592
597
  delete row.value[field];
593
598
  row.origins.set(field, origin);
594
599
  }
595
600
  }
596
- function applyPatch(row, patch, origin, placement) {
601
+ function applyPatch(row, patch, origin, placement, skip) {
597
602
  if (patch.op === "delete") {
598
603
  row.deletedBy = origin;
599
604
  return;
600
605
  }
601
606
  if (patch.op === "update" && !row.placement) {
602
607
  row.deletedBy = null;
603
- applyFields(row, patch, origin);
608
+ applyFields(row, patch, origin, skip);
604
609
  return;
605
610
  }
606
611
  if (patch.op === "insert" && !row.live) {
@@ -609,7 +614,7 @@ function applyPatch(row, patch, origin, placement) {
609
614
  row.placement = placement;
610
615
  }
611
616
  row.deletedBy = null;
612
- applyFields(row, patch, origin);
617
+ applyFields(row, patch, origin, skip);
613
618
  }
614
619
  function sortedProposalPatches(proposal) {
615
620
  return proposal.patches.map((patch, index) => ({ patch, index })).sort(
@@ -621,7 +626,8 @@ function createCmsProjection({
621
626
  draft,
622
627
  proposals,
623
628
  editorUserId,
624
- draftKey
629
+ draftKey,
630
+ hidden
625
631
  }) {
626
632
  const tables = /* @__PURE__ */ new Map();
627
633
  for (const [table, rows] of Object.entries(liveRows)) {
@@ -640,7 +646,8 @@ function createCmsProjection({
640
646
  }
641
647
  const isMine = (proposal) => editorUserId !== null && proposal.createdByUserId === editorUserId;
642
648
  const activeProposals = proposals.filter((proposal) => proposal.status === "active").sort((a, b) => a.createdAt - b.createdAt || a.id.localeCompare(b.id));
643
- activeProposals.filter((proposal) => !isMine(proposal) || proposal.draftKey === draftKey).forEach((proposal, rank) => {
649
+ let hidesChanges = false;
650
+ activeProposals.filter((proposal) => isOnPage(proposal, editorUserId, draftKey)).forEach((proposal, rank) => {
644
651
  const mine2 = isMine(proposal);
645
652
  const origin = {
646
653
  kind: "proposal",
@@ -650,7 +657,13 @@ function createCmsProjection({
650
657
  label: draftTitle(proposal, mine2)
651
658
  };
652
659
  for (const patch of sortedProposalPatches(proposal)) {
653
- applyPatch(rowFor(tables, patch.table, patch.rowId), patch, origin, [1, -rank]);
660
+ const isHidden = (field) => hidden?.has(changeKey(proposal.id, { table: patch.table, rowId: patch.rowId, field })) ?? false;
661
+ const fields = [...Object.keys(patch.fields), ...patch.clearFields ?? []];
662
+ const skip = new Set(patch.op === "update" ? fields.filter(isHidden) : []);
663
+ const whole = patch.op === "update" ? skip.size > 0 && skip.size === fields.length : isHidden();
664
+ hidesChanges ||= whole || skip.size > 0;
665
+ if (whole) continue;
666
+ applyPatch(rowFor(tables, patch.table, patch.rowId), patch, origin, [1, -rank], skip);
654
667
  }
655
668
  });
656
669
  const proposalDeletes = /* @__PURE__ */ new Map();
@@ -678,6 +691,7 @@ function createCmsProjection({
678
691
  );
679
692
  return {
680
693
  conflictsWithMine,
694
+ hidesChanges,
681
695
  field({ table, rowId, field }) {
682
696
  const row = tables.get(table)?.get(rowId);
683
697
  if (!row) return EMPTY_FIELD;
@@ -962,10 +976,12 @@ function buildCompoundCreateDraft(args) {
962
976
  }
963
977
  var SESSION_CHANGED = "The builder session changed since these changes were made: check the page, then try again";
964
978
  var WORK_ELSEWHERE = "This page holds unsaved work from another builder session: discard it first";
979
+ var CHANGES_HIDDEN = "The page hides some changes: show them all to edit";
965
980
  var stagedFor = (key) => (entry) => entry.madeUnder !== null && entry.madeUnder.key === key;
966
981
  var CmsContext = createContext(null);
967
982
  var OUTCOME_DISPLAY_MS = 5e3;
968
983
  var EMPTY_PROPOSALS = [];
984
+ var NO_HIDDEN = /* @__PURE__ */ new Set();
969
985
  var EMPTY_TABLE_ROWS = {};
970
986
  function CmsProvider(props) {
971
987
  const sessionKey = `${props.profileSlug}\0${props.editor?.user.id ?? "signed-out"}`;
@@ -991,6 +1007,7 @@ function CmsProviderSession({
991
1007
  richtextHostAdapter
992
1008
  }) {
993
1009
  const [editMode, setEditModeState] = useState(false);
1010
+ const [hidden, setHidden] = useState(NO_HIDDEN);
994
1011
  const [activeInPlaceKey, setActiveInPlaceKey] = useState(null);
995
1012
  const [pendingInPlaceKey, setPendingInPlaceKey] = useState(null);
996
1013
  const inPlaceHandlersRef = useRef(null);
@@ -1004,11 +1021,31 @@ function CmsProviderSession({
1004
1021
  const setEditMode = useCallback(
1005
1022
  (next) => {
1006
1023
  setEditModeState(next);
1007
- if (!next) clearInPlaceSession();
1024
+ if (next) setHidden(NO_HIDDEN);
1025
+ else clearInPlaceSession();
1026
+ },
1027
+ [clearInPlaceSession]
1028
+ );
1029
+ const setShowChanges = useCallback(
1030
+ (show) => {
1031
+ setHidden(show ? NO_HIDDEN : "all");
1032
+ if (!show) clearInPlaceSession();
1033
+ },
1034
+ [clearInPlaceSession]
1035
+ );
1036
+ const setChangeShown = useCallback(
1037
+ (key, shown) => {
1038
+ setHidden((prev) => {
1039
+ if (prev === "all") return prev;
1040
+ const next = new Set(prev);
1041
+ if (shown) next.delete(key);
1042
+ else next.add(key);
1043
+ return next;
1044
+ });
1045
+ if (!shown) clearInPlaceSession();
1008
1046
  },
1009
1047
  [clearInPlaceSession]
1010
1048
  );
1011
- const toggleEditMode = useCallback(() => setEditMode(!editMode), [editMode, setEditMode]);
1012
1049
  const registerInPlaceHandlers = useCallback((handlers) => {
1013
1050
  inPlaceHandlersRef.current = handlers;
1014
1051
  setInPlaceDirty(handlers?.isDirty() ?? false);
@@ -1062,7 +1099,11 @@ function CmsProviderSession({
1062
1099
  [createRecipesProp, manifest]
1063
1100
  );
1064
1101
  const { currentDraft, currentDraftRef, connectBuilder, lookupDraft, refreshBuilderSession } = useBuilderDraft();
1065
- const [changesOpen, setChangesOpen] = useState(false);
1102
+ const [changesOpen, setChangesOpenState] = useState(false);
1103
+ const setChangesOpen = useCallback((open) => {
1104
+ setChangesOpenState(open);
1105
+ if (!open) setHidden(NO_HIDDEN);
1106
+ }, []);
1066
1107
  const [highlight, setHighlight] = useState(null);
1067
1108
  const [draft, setDraft] = useState([]);
1068
1109
  const draftRef = useRef(draft);
@@ -1084,15 +1125,32 @@ function CmsProviderSession({
1084
1125
  (prev) => prev.some((entry) => entry.madeUnder === null) ? prev.map((entry) => ({ ...entry, madeUnder: entry.madeUnder ?? currentDraft })) : prev
1085
1126
  );
1086
1127
  }, [currentDraft]);
1087
- const refuseWorkElsewhere = useCallback(() => {
1128
+ const editorUserId = editor?.user.id ?? null;
1129
+ const projection = useMemo(
1130
+ () => createCmsProjection({
1131
+ liveRows: tableRows,
1132
+ draft: hidden === "all" ? [] : draft,
1133
+ proposals: hidden === "all" ? [] : proposals,
1134
+ editorUserId,
1135
+ // Before the builder first answers, none of my drafts.
1136
+ draftKey: currentDraft ? currentDraft.key : null,
1137
+ hidden: hidden === "all" ? void 0 : hidden
1138
+ }),
1139
+ [tableRows, draft, proposals, editorUserId, currentDraft, hidden]
1140
+ );
1141
+ const pageShows = hidden === "all" ? "none" : projection.hidesChanges ? "some" : "all";
1142
+ const editingAllowed = pageShows === "all";
1143
+ const editing = editMode && editingAllowed;
1144
+ const toggleEditMode = useCallback(() => setEditMode(!editing), [editing, setEditMode]);
1145
+ const refuseNewWork = useCallback(() => {
1088
1146
  const current = currentDraftRef.current;
1089
- if (current === null || localWorkFor(current)) return false;
1090
- setOutcomes([{ id: "_error", outcome: "rejected", message: WORK_ELSEWHERE }]);
1091
- return true;
1092
- }, [currentDraftRef, localWorkFor]);
1147
+ const message = !editingAllowed ? CHANGES_HIDDEN : current !== null && !localWorkFor(current) ? WORK_ELSEWHERE : null;
1148
+ if (message) setOutcomes([{ id: "_error", outcome: "rejected", message }]);
1149
+ return message !== null;
1150
+ }, [currentDraftRef, localWorkFor, editingAllowed]);
1093
1151
  const mutateDraft = useCallback(
1094
1152
  (next) => {
1095
- if (refuseWorkElsewhere()) return;
1153
+ if (refuseNewWork()) return;
1096
1154
  setDraft((prev) => {
1097
1155
  const value2 = next(prev);
1098
1156
  if (value2.length > 0 && prev.length === 0) {
@@ -1102,7 +1160,7 @@ function CmsProviderSession({
1102
1160
  return value2;
1103
1161
  });
1104
1162
  },
1105
- [currentDraftRef, refuseWorkElsewhere]
1163
+ [currentDraftRef, refuseNewWork]
1106
1164
  );
1107
1165
  const clearDraft = useCallback(() => {
1108
1166
  draftRef.current = [];
@@ -1137,18 +1195,6 @@ function CmsProviderSession({
1137
1195
  },
1138
1196
  []
1139
1197
  );
1140
- const editorUserId = editor?.user.id ?? null;
1141
- const projection = useMemo(
1142
- () => createCmsProjection({
1143
- liveRows: tableRows,
1144
- draft,
1145
- proposals,
1146
- editorUserId,
1147
- // Before the builder first answers, none of my drafts.
1148
- draftKey: currentDraft ? currentDraft.key : null
1149
- }),
1150
- [tableRows, draft, proposals, editorUserId, currentDraft]
1151
- );
1152
1198
  useEffect(() => {
1153
1199
  if (!proposalFeedError) return;
1154
1200
  setOutcomes([
@@ -1190,7 +1236,7 @@ function CmsProviderSession({
1190
1236
  );
1191
1237
  const registerPendingReplace = useCallback(
1192
1238
  (input2) => {
1193
- if (refuseWorkElsewhere()) return;
1239
+ if (refuseNewWork()) return;
1194
1240
  const kind = input2.kind ?? "file";
1195
1241
  setPendingReplaces((prev) => {
1196
1242
  const next = prev.filter((entry) => entry.assetId !== input2.assetId);
@@ -1199,7 +1245,7 @@ function CmsProviderSession({
1199
1245
  return next;
1200
1246
  });
1201
1247
  },
1202
- [currentDraftRef, refuseWorkElsewhere]
1248
+ [currentDraftRef, refuseNewWork]
1203
1249
  );
1204
1250
  const discardDraft = useCallback(() => {
1205
1251
  inPlaceHandlersRef.current?.discard();
@@ -1429,7 +1475,8 @@ function CmsProviderSession({
1429
1475
  const value = useMemo(
1430
1476
  () => ({
1431
1477
  editor,
1432
- editMode: editor !== null && editMode,
1478
+ editMode: editor !== null && editing,
1479
+ pageShows,
1433
1480
  setEditMode,
1434
1481
  toggleEditMode,
1435
1482
  readableTables,
@@ -1455,6 +1502,9 @@ function CmsProviderSession({
1455
1502
  resolve,
1456
1503
  changesOpen,
1457
1504
  setChangesOpen,
1505
+ setShowChanges,
1506
+ hiddenChanges: hidden === "all" ? NO_HIDDEN : hidden,
1507
+ setChangeShown,
1458
1508
  highlight,
1459
1509
  setHighlight,
1460
1510
  actionPhase,
@@ -1483,7 +1533,7 @@ function CmsProviderSession({
1483
1533
  }),
1484
1534
  [
1485
1535
  editor,
1486
- editMode,
1536
+ editing,
1487
1537
  toggleEditMode,
1488
1538
  readableTables,
1489
1539
  manifest,
@@ -1507,6 +1557,11 @@ function CmsProviderSession({
1507
1557
  discard,
1508
1558
  resolve,
1509
1559
  changesOpen,
1560
+ setChangesOpen,
1561
+ pageShows,
1562
+ setShowChanges,
1563
+ hidden,
1564
+ setChangeShown,
1510
1565
  highlight,
1511
1566
  actionPhase,
1512
1567
  proposalsLoadingProp,
@@ -1533,10 +1588,10 @@ function CmsProviderSession({
1533
1588
  pendingReplaces.length
1534
1589
  ]
1535
1590
  );
1536
- return /* @__PURE__ */ jsx(CmsContext.Provider, { value, children: /* @__PURE__ */ jsx(FieldsDataProvider, { adapter: adapters.fieldsDataAdapter, children: /* @__PURE__ */ jsx(CmsTableRowsContext.Provider, { value: tableRows, children: /* @__PURE__ */ jsxs(DefaultRichtextHostProvider, { manifest, adapter: richtextHostAdapter, children: [
1591
+ return /* @__PURE__ */ jsx(CmsContext.Provider, { value, children: /* @__PURE__ */ jsx(FieldsDataProvider, { adapter: adapters.fieldsDataAdapter, children: /* @__PURE__ */ jsx(CmsTableRowsContext.Provider, { value: tableRows, children: /* @__PURE__ */ jsx(DefaultRichtextHostProvider, { manifest, adapter: richtextHostAdapter, children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
1537
1592
  children,
1538
1593
  pendingInPlaceKey ? /* @__PURE__ */ jsx(InPlaceSwitchModal, { onChoose: resolveInPlaceSwitch }) : null
1539
- ] }) }) }) });
1594
+ ] }) }) }) }) });
1540
1595
  }
1541
1596
  function useCms() {
1542
1597
  const ctx = useContext(CmsContext);
@@ -1760,10 +1815,10 @@ function FieldEditorDialog({
1760
1815
  );
1761
1816
  }
1762
1817
  var MarkdownEditorLazy = lazy(
1763
- () => import('./editor-543ARQ6S.js').then((m) => ({ default: m.MarkdownEditor }))
1818
+ () => import('./editor-HJ3UNV3Q.js').then((m) => ({ default: m.MarkdownEditor }))
1764
1819
  );
1765
1820
  var MarkdownInsertPickersLazy = lazy(
1766
- () => import('./editor-543ARQ6S.js').then((m) => ({ default: m.MarkdownInsertPickers }))
1821
+ () => import('./editor-HJ3UNV3Q.js').then((m) => ({ default: m.MarkdownInsertPickers }))
1767
1822
  );
1768
1823
  var shellStyle = {
1769
1824
  display: "block",
@@ -2812,6 +2867,7 @@ function ResolveDialog({
2812
2867
  }
2813
2868
  ) });
2814
2869
  }
2870
+ var EDITING_FIRST = "Save or cancel the field you are editing first";
2815
2871
  var WARN = "color-mix(in oklab, darkorange 80%, CanvasText)";
2816
2872
  var panel = {
2817
2873
  ...cmsBox,
@@ -2833,6 +2889,17 @@ var card = {
2833
2889
  borderRadius: 8,
2834
2890
  padding: "10px 12px"
2835
2891
  };
2892
+ var pausedNotice = {
2893
+ position: "sticky",
2894
+ bottom: 0,
2895
+ marginTop: "auto",
2896
+ marginBottom: 0,
2897
+ padding: "8px 12px",
2898
+ borderRadius: 8,
2899
+ border: "1px solid color-mix(in oklab, darkorange 60%, transparent)",
2900
+ background: "color-mix(in oklab, darkorange 18%, Canvas)",
2901
+ fontWeight: 600
2902
+ };
2836
2903
  var smallBtn = { padding: "3px 8px", fontSize: 12 };
2837
2904
  var list = { listStyle: "none", margin: 0, padding: 0 };
2838
2905
  var item = {
@@ -2904,6 +2971,7 @@ function groupOf(manifest, drafts, me, currentDraft, proposal) {
2904
2971
  proposal,
2905
2972
  mine,
2906
2973
  current: mine && currentDraft !== null && proposal.draftKey === currentDraft.key,
2974
+ onPage: isOnPage(proposal, me ?? null, currentDraft ? currentDraft.key : null),
2907
2975
  title: draftTitle(proposal, mine),
2908
2976
  count: proposal.patches.reduce((sum, patch) => sum + patchChangeCount(patch), 0),
2909
2977
  changes: proposal.patches.flatMap((patch) => patchChanges(manifest, proposal, patch, drafts))
@@ -2952,12 +3020,60 @@ function ResolveGroup({ group, onClose }) {
2952
3020
  revision
2953
3021
  );
2954
3022
  }
3023
+ var CONTEXT = 40;
3024
+ var MAX_PART = 160;
3025
+ function crop(text, max, fromEnd = false) {
3026
+ if (text.length <= max) return text;
3027
+ if (fromEnd) {
3028
+ const tail = text.slice(-max);
3029
+ const at = tail.search(/\s/);
3030
+ return `\u2026${at < 0 ? tail : tail.slice(at + 1)}`;
3031
+ }
3032
+ const head = text.slice(0, max);
3033
+ const cut = head.search(/\s\S*$/);
3034
+ return `${cut > 0 ? head.slice(0, cut) : head}\u2026`;
3035
+ }
3036
+ function textChange(beforeText, afterText) {
3037
+ const shortest = Math.min(beforeText.length, afterText.length);
3038
+ let start = 0;
3039
+ while (start < shortest && beforeText[start] === afterText[start]) start++;
3040
+ let end = 0;
3041
+ while (end < shortest - start && beforeText[beforeText.length - 1 - end] === afterText[afterText.length - 1 - end]) {
3042
+ end++;
3043
+ }
3044
+ while (start > 0 && !/\s/.test(beforeText[start - 1])) start--;
3045
+ while (end > 0 && !/\s/.test(beforeText[beforeText.length - end])) end--;
3046
+ return {
3047
+ lead: crop(beforeText.slice(0, start), CONTEXT, true),
3048
+ removed: crop(beforeText.slice(start, beforeText.length - end), MAX_PART),
3049
+ added: crop(afterText.slice(start, afterText.length - end), MAX_PART),
3050
+ trail: crop(beforeText.slice(beforeText.length - end), CONTEXT)
3051
+ };
3052
+ }
3053
+ function TextChangeLine({ beforeText, afterText }) {
3054
+ const { lead, removed, added, trail } = textChange(beforeText, afterText);
3055
+ return /* @__PURE__ */ jsxs("span", { children: [
3056
+ /* @__PURE__ */ jsx("span", { style: { color: cmsMuted }, children: lead }),
3057
+ removed ? /* @__PURE__ */ jsx("del", { style: before, children: removed }) : null,
3058
+ removed && added ? " " : null,
3059
+ added ? /* @__PURE__ */ jsx("ins", { style: { ...after, textDecoration: "none" }, children: added }) : null,
3060
+ /* @__PURE__ */ jsx("span", { style: { color: cmsMuted }, children: trail })
3061
+ ] });
3062
+ }
2955
3063
  function ChangeLine({ change }) {
2956
3064
  if (change.kind === "insert") return /* @__PURE__ */ jsxs("span", { style: after, children: [
2957
3065
  "+ ",
2958
3066
  String(change.after)
2959
3067
  ] });
2960
3068
  if (change.kind === "delete") return /* @__PURE__ */ jsx("span", { style: before, children: "\u2212 delete row" });
3069
+ const beforeText = plainTextIfRichDoc(change.before);
3070
+ const afterText = plainTextIfRichDoc(change.after);
3071
+ if (typeof beforeText === "string" && typeof afterText === "string") {
3072
+ if (beforeText === afterText) return /* @__PURE__ */ jsx("span", { style: after, children: "Formatting changed" });
3073
+ if (Math.max(beforeText.length, afterText.length) > 80) {
3074
+ return /* @__PURE__ */ jsx(TextChangeLine, { beforeText, afterText });
3075
+ }
3076
+ }
2961
3077
  return /* @__PURE__ */ jsxs("span", { children: [
2962
3078
  change.before === void 0 ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
2963
3079
  /* @__PURE__ */ jsx("span", { style: before, children: /* @__PURE__ */ jsx(Value, { value: change.before, type: change.type }) }),
@@ -2979,11 +3095,16 @@ function ChangesView({
2979
3095
  publishDraft,
2980
3096
  withdrawDraft,
2981
3097
  discard,
2982
- setHighlight
3098
+ setHighlight,
3099
+ pageShows,
3100
+ setShowChanges,
3101
+ hiddenChanges,
3102
+ setChangeShown,
3103
+ inPlaceDirty
2983
3104
  } = useCms();
2984
3105
  const [confirmWithdraw, setConfirmWithdraw] = useState(null);
2985
3106
  const [resolving, setResolving] = useState(null);
2986
- const [hidden, setHidden] = useState(null);
3107
+ const [offPageHint, setOffPageHint] = useState(null);
2987
3108
  const busy = actionPhase !== "idle";
2988
3109
  const me = editor?.user.id;
2989
3110
  const rank = (group) => group.current ? 0 : !group.mine ? 3 : group.proposal.draftKey === void 0 ? 2 : 1;
@@ -2992,11 +3113,11 @@ function ChangesView({
2992
3113
  );
2993
3114
  const resolvingGroup = groups.find((group) => group.proposal.id === resolving);
2994
3115
  const pointAt = (group, change, id) => {
2995
- if (group.mine && !group.current) setHidden(id);
3116
+ if (!group.onPage) setOffPageHint(id);
2996
3117
  else setHighlight({ table: change.table, rowId: change.rowId, field: change.field });
2997
3118
  };
2998
3119
  const leave = () => {
2999
- setHidden(null);
3120
+ setOffPageHint(null);
3000
3121
  setHighlight(null);
3001
3122
  };
3002
3123
  return /* @__PURE__ */ jsxs(
@@ -3007,6 +3128,28 @@ function ChangesView({
3007
3128
  children: [
3008
3129
  /* @__PURE__ */ jsxs("header", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
3009
3130
  /* @__PURE__ */ jsx("strong", { style: { fontSize: 15, flex: 1 }, children: "Changes" }),
3131
+ /* @__PURE__ */ jsxs(
3132
+ "label",
3133
+ {
3134
+ style: { display: "flex", alignItems: "center", gap: 4, color: cmsMuted },
3135
+ title: inPlaceDirty ? EDITING_FIRST : "Show the drafts on the page, or the live site",
3136
+ children: [
3137
+ /* @__PURE__ */ jsx(
3138
+ "input",
3139
+ {
3140
+ type: "checkbox",
3141
+ checked: pageShows === "all",
3142
+ ref: (input2) => {
3143
+ if (input2) input2.indeterminate = pageShows === "some";
3144
+ },
3145
+ disabled: inPlaceDirty,
3146
+ onChange: (event) => setShowChanges(event.target.checked)
3147
+ }
3148
+ ),
3149
+ "Show on page"
3150
+ ]
3151
+ }
3152
+ ),
3010
3153
  /* @__PURE__ */ jsx("button", { type: "button", style: ghostBtn, "aria-label": "Close changes", onClick: onClose, children: "\xD7" })
3011
3154
  ] }),
3012
3155
  proposals.length >= SHARE_LIST_LIMIT ? /* @__PURE__ */ jsxs("p", { role: "status", style: { margin: 0, color: WARN }, children: [
@@ -3074,7 +3217,7 @@ function ChangesView({
3074
3217
  }
3075
3218
  ) : null,
3076
3219
  /* @__PURE__ */ jsx("ul", { style: list, children: group.changes.map((change) => {
3077
- const id = `${proposal.id}\0${change.path}`;
3220
+ const id = changeKey(proposal.id, change);
3078
3221
  return /* @__PURE__ */ jsxs(
3079
3222
  "li",
3080
3223
  {
@@ -3083,6 +3226,18 @@ function ChangesView({
3083
3226
  onMouseEnter: () => pointAt(group, change, id),
3084
3227
  onMouseLeave: leave,
3085
3228
  children: [
3229
+ group.onPage ? /* @__PURE__ */ jsx(
3230
+ "input",
3231
+ {
3232
+ type: "checkbox",
3233
+ "aria-label": "Show on page",
3234
+ title: inPlaceDirty ? EDITING_FIRST : "Show this change on the page",
3235
+ style: { marginTop: 2 },
3236
+ checked: pageShows !== "none" && !hiddenChanges.has(id),
3237
+ disabled: pageShows === "none" || inPlaceDirty,
3238
+ onChange: (event) => setChangeShown(id, event.target.checked)
3239
+ }
3240
+ ) : null,
3086
3241
  /* @__PURE__ */ jsxs("div", { style: { flex: 1, minWidth: 0 }, children: [
3087
3242
  /* @__PURE__ */ jsxs("div", { style: { color: cmsMuted }, children: [
3088
3243
  change.path,
@@ -3090,7 +3245,7 @@ function ChangesView({
3090
3245
  change.shared ? /* @__PURE__ */ jsx(Marker, { title: "Another draft also changes this", children: "\u21C4" }) : null
3091
3246
  ] }),
3092
3247
  /* @__PURE__ */ jsx(ChangeLine, { change }),
3093
- hidden === id ? /* @__PURE__ */ jsx("div", { role: "status", style: { color: cmsMuted, fontSize: 12 }, children: "Not shown on the page: resume the session to see it" }) : null
3248
+ offPageHint === id ? /* @__PURE__ */ jsx("div", { role: "status", style: { color: cmsMuted, fontSize: 12 }, children: "Not shown on the page: resume the session to see it" }) : null
3094
3249
  ] }),
3095
3250
  group.mine ? /* @__PURE__ */ jsx(
3096
3251
  "button",
@@ -3115,6 +3270,7 @@ function ChangesView({
3115
3270
  }) })
3116
3271
  ] }, proposal.id);
3117
3272
  }),
3273
+ pageShows === "all" ? null : /* @__PURE__ */ jsx("p", { role: "status", style: pausedNotice, children: pageShows === "none" ? "The page shows the live site; editing is paused." : "Some changes are hidden on the page; editing is paused." }),
3118
3274
  resolvingGroup ? /* @__PURE__ */ jsx(ResolveGroup, { group: resolvingGroup, onClose: () => setResolving(null) }) : null
3119
3275
  ]
3120
3276
  }
@@ -3372,8 +3528,6 @@ function CmsFloatingToolbar({
3372
3528
  outcomes,
3373
3529
  saveDraft,
3374
3530
  discardDraft,
3375
- publishMine,
3376
- withdrawMine,
3377
3531
  inPlaceDirty,
3378
3532
  navigation,
3379
3533
  manifest,
@@ -3432,12 +3586,13 @@ function CmsFloatingToolbar({
3432
3586
  }, [settingsOpen]);
3433
3587
  const integrityReason = useMemo(() => {
3434
3588
  if (!activeNavRowId || !navigation.ok) return null;
3435
- return describeContentRefIntegrity({
3589
+ const integrity = describeContentRefIntegrity({
3436
3590
  manifest,
3437
3591
  navigationTable: navigation.table,
3438
3592
  projection,
3439
3593
  navRowId: activeNavRowId
3440
- }).reason;
3594
+ });
3595
+ return integrity.code === "empty_body" ? null : integrity.reason;
3441
3596
  }, [activeNavRowId, navigation, manifest, projection]);
3442
3597
  const hasProposalActions = proposalActions !== null;
3443
3598
  const draftCount = draft.length;
@@ -3552,14 +3707,6 @@ function CmsFloatingToolbar({
3552
3707
  setEditMode(false);
3553
3708
  setConfirm(null);
3554
3709
  }
3555
- async function onPublishMine() {
3556
- await publishMine();
3557
- setConfirm(null);
3558
- }
3559
- async function onWithdrawConfirmed() {
3560
- await withdrawMine();
3561
- setConfirm(null);
3562
- }
3563
3710
  const outcome = outcomes && outcomes.length > 0 ? summarizeOutcomes(outcomes) : null;
3564
3711
  return /* @__PURE__ */ jsxs("div", { style: barStyle, "data-columnus-cms-toolbar": "true", role: "toolbar", "aria-label": "Columnus CMS", children: [
3565
3712
  chatPanel,
@@ -3574,24 +3721,13 @@ function CmsFloatingToolbar({
3574
3721
  onConfirm: onDiscardConfirmed,
3575
3722
  onDismiss: () => setConfirm(null)
3576
3723
  }
3577
- ) : confirm === "withdraw" ? /* @__PURE__ */ jsx(
3578
- ConfirmPanel,
3579
- {
3580
- label: "withdraw",
3581
- prompt: "Withdraw your pending proposal?",
3582
- confirmLabel: actionPhase === "withdrawing" ? "Withdrawing\u2026" : "Withdraw",
3583
- dismissLabel: "Cancel",
3584
- busy,
3585
- onConfirm: () => void onWithdrawConfirmed(),
3586
- onDismiss: () => setConfirm(null)
3587
- }
3588
3724
  ) : /* @__PURE__ */ jsxs(Fragment, { children: [
3589
3725
  /* @__PURE__ */ jsxs("div", { style: actionsCluster, children: [
3590
3726
  changeCount > 0 || changesOpen ? /* @__PURE__ */ jsxs(
3591
3727
  "button",
3592
3728
  {
3593
3729
  type: "button",
3594
- style: ghostBtn,
3730
+ style: canPublish && !editMode ? primaryBtn : ghostBtn,
3595
3731
  "aria-pressed": changesOpen,
3596
3732
  onClick: () => showPanel(changesOpen ? null : "changes"),
3597
3733
  children: [
@@ -3600,35 +3736,6 @@ function CmsFloatingToolbar({
3600
3736
  ]
3601
3737
  }
3602
3738
  ) : null,
3603
- !editMode && canPublish ? /* @__PURE__ */ jsxs(Fragment, { children: [
3604
- /* @__PURE__ */ jsxs(
3605
- "button",
3606
- {
3607
- type: "button",
3608
- style: primaryBtn,
3609
- disabled: busy,
3610
- title: "Publish your current draft to the live site",
3611
- onClick: () => void onPublishMine(),
3612
- children: [
3613
- /* @__PURE__ */ jsx(IconPublish, {}),
3614
- actionPhase === "publishing" ? "Publishing\u2026" : "Publish mine"
3615
- ]
3616
- }
3617
- ),
3618
- /* @__PURE__ */ jsxs(
3619
- "button",
3620
- {
3621
- type: "button",
3622
- style: dangerBtn,
3623
- disabled: busy,
3624
- onClick: () => setConfirm("withdraw"),
3625
- children: [
3626
- /* @__PURE__ */ jsx(IconX, {}),
3627
- "Withdraw mine"
3628
- ]
3629
- }
3630
- )
3631
- ] }) : null,
3632
3739
  !editMode ? /* @__PURE__ */ jsxs(
3633
3740
  "button",
3634
3741
  {
@@ -3918,6 +4025,7 @@ function DraftRowDialog({
3918
4025
  initial: initialDoc,
3919
4026
  saveLabel: "Add to draft",
3920
4027
  overlayZIndex: CMS_ROW_EDITOR_Z_INDEX,
4028
+ forEditors: true,
3921
4029
  allowCreate: (refTable) => cms.canProposeOp(refTable, "insert"),
3922
4030
  onSubmit: async (doc) => {
3923
4031
  const fields = stripSystemFields(doc);
@@ -4213,5 +4321,5 @@ function CmsRichDocView(props) {
4213
4321
  }
4214
4322
 
4215
4323
  export { CmsCompoundCreate, CmsCreateButton, CmsField, CmsFieldStamp, CmsFloatingToolbar, CmsLoginPage, CmsProvider, CmsRichDocView, CmsRow, DefaultRichtextHostProvider, DraftRowDialog, FieldEditorDialog, HTML_CACHE_BYPASS_HEADER, InsertRowDialog, applyDeleteToDraft, applyFieldToDraft, applyRowToDraft, buildInsertDraft, canProposeField, canProposeOp, cmsReadableTables, createDefaultCmsRichtextAdapters, createDefaultRichtextHostAdapter, createTableRowsRichtextHostAdapter, describeContentRefIntegrity, findContentRefField, inferNavigationTable, isCmsPath, mergeDraftIntoProposal, proposeEditableTable, readSession, resolveEditSurface, resolveStampDisplay, shouldBypassHtmlCache, slugifyDe, stampEditKey, uniqueSlug, useCms, useCmsOptional, useCmsProjectedField, useCmsProjectedString, useCmsProjectedTable, useCmsRelatedRow, useCmsRow, useCmsRowOptional, writeSession };
4216
- //# sourceMappingURL=chunk-SKE2RDD2.js.map
4217
- //# sourceMappingURL=chunk-SKE2RDD2.js.map
4324
+ //# sourceMappingURL=chunk-QN3K6RRP.js.map
4325
+ //# sourceMappingURL=chunk-QN3K6RRP.js.map