sanity 6.6.0-next.53 → 6.6.0-next.56
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.
|
@@ -27,6 +27,7 @@ import { PortableTextMemberSchemaTypes } from "@portabletext/sanity-bridge";
|
|
|
27
27
|
import { ImageUrlBuilder, ImageUrlBuilder as ImageUrlBuilder$1 } from "@sanity/image-url";
|
|
28
28
|
import { MarkdownShortcutsPluginProps } from "@portabletext/plugin-markdown-shortcuts";
|
|
29
29
|
import { PasteLinkPluginProps } from "@portabletext/plugin-paste-link";
|
|
30
|
+
import { TableContainers } from "@portabletext/plugin-table";
|
|
30
31
|
import { TypographyPluginProps } from "@portabletext/plugin-typography";
|
|
31
32
|
import { Node } from "@sanity/comlink";
|
|
32
33
|
interface CreateSanityMediaLibrarySourceProps {
|
|
@@ -12332,6 +12333,19 @@ interface PortableTextPluginsProps {
|
|
|
12332
12333
|
* @defaultValue false
|
|
12333
12334
|
*/
|
|
12334
12335
|
enabled?: boolean;
|
|
12336
|
+
/**
|
|
12337
|
+
* Native `@portabletext/plugin-table` container definitions, one per
|
|
12338
|
+
* role, for binding the plugin to your own type and field names
|
|
12339
|
+
* (adopting a table shape that already exists in your dataset).
|
|
12340
|
+
* Omitted renders fall back to the studio's table UI, and omitted
|
|
12341
|
+
* roles fall back to the canonical `table`/`row`/`cell` names. The
|
|
12342
|
+
* nesting shape and the `headerRows` field name stay fixed, and the
|
|
12343
|
+
* schema must declare the same names the containers use.
|
|
12344
|
+
*
|
|
12345
|
+
* Define the containers at module scope: a new object identity
|
|
12346
|
+
* re-registers the plugin on every render.
|
|
12347
|
+
*/
|
|
12348
|
+
containers?: TableContainers;
|
|
12335
12349
|
};
|
|
12336
12350
|
};
|
|
12337
12351
|
}
|
package/lib/_chunks-es/index2.js
CHANGED
|
@@ -5,7 +5,7 @@ import * as PathUtils from "@sanity/util/paths";
|
|
|
5
5
|
import { toString, FOCUS_TERMINATOR, startsWith, isEqual as isEqual$2, pathFor, fromString, get as get$1, trimChildPath as trimChildPath$1, trimLeft } from "@sanity/util/paths";
|
|
6
6
|
import { forwardRef, useRef, useState, useId, useCallback, useMemo, useImperativeHandle, useEffect, isValidElement, Fragment, cloneElement, memo, useSyncExternalStore, Suspense, useContext, useReducer, Component, startTransition, use, useLayoutEffect, useEffectEvent, PureComponent, Children, lazy, useTransition, useInsertionEffect, useDeferredValue, version, StrictMode } from "react";
|
|
7
7
|
import deepEquals from "react-fast-compare";
|
|
8
|
-
import { LocaleContext, VisibleWorkspacesContext, ConfigErrorContext, WorkspacesContext, MediaLibraryIdsContext, PerspectiveContext, UserColorManagerContext, DocumentChangeContext, ReviewChangesContext, DiffContext, PresenceContext, FormBuilderContext, PortableTextMemberSchemaTypesContext, SelectedAnnotationsContext, ValidationContext, PortableTextMarkersContext, PortableTextMemberItemsContext, ChangeIndicatorTrackerContextGetSnapshot, ChangeIndicatorTrackerContextStore, FormCallbacksContext, ParseErrorsContext, ReferenceInputOptionsContext, WorkspaceContext, DocumentDivergencesContext, ActiveWorkspaceMatcherContext, DocumentIdContext, HoveredFieldContext, FieldActionsContext, FormValueContext, ArrayItemRootElementContext, ReferenceItemRefContext, GetFormValueContext, EnhancedObjectDialogContext, DocumentFieldActionsContext, ArrayValidationContext, SortableItemIdContext, EditDialogOuterBoundaryContext, SourceContext, VirtualizerScrollInstanceContext, PortableTextMemberItemElementRefsContext, ScrollContext, FullscreenPTEContext,
|
|
8
|
+
import { LocaleContext, VisibleWorkspacesContext, ConfigErrorContext, WorkspacesContext, MediaLibraryIdsContext, PerspectiveContext, UserColorManagerContext, DocumentChangeContext, ReviewChangesContext, DiffContext, PresenceContext, FormBuilderContext, PortableTextMemberSchemaTypesContext, SelectedAnnotationsContext, ValidationContext, PortableTextMarkersContext, PortableTextMemberItemsContext, ChangeIndicatorTrackerContextGetSnapshot, ChangeIndicatorTrackerContextStore, FormCallbacksContext, ParseErrorsContext, ReferenceInputOptionsContext, WorkspaceContext, DocumentDivergencesContext, ActiveWorkspaceMatcherContext, DocumentIdContext, HoveredFieldContext, FieldActionsContext, FormValueContext, ArrayItemRootElementContext, ReferenceItemRefContext, GetFormValueContext, EnhancedObjectDialogContext, DocumentFieldActionsContext, ArrayValidationContext, SortableItemIdContext, EditDialogOuterBoundaryContext, SourceContext, VirtualizerScrollInstanceContext, PortableTextMemberItemElementRefsContext, ScrollContext, FullscreenPTEContext, ColorSchemeSetValueContext, ColorSchemeValueContext, AssetLimitUpsellContext, DialogStackContext, ResourceCacheContext, EventsContext, ReleasesUpsellContext, SingleDocReleaseContext, SingleDocReleaseEnabledContext, SingleDocReleaseUpsellContext, PresenceTrackerContextStore, PresenceTrackerContextGetSnapshot, FormFieldPresenceContext, SearchContext, CalendarContext, AppIdCacheContext, CommentsIntentContext, CommentInputContext, CommentsContext, CommentsEnabledContext, CommentsSelectedPathContext, ScheduledPublishingEnabledContext, DocumentActionPropsContext, SchedulePublishUpsellContext, TasksEnabledContext, IsLastPaneContext, MentionUserContext, TasksNavigationContext, TasksContext, TasksUpsellContext, LoggedOutReasonContext, StudioErrorHandlerContext, RouterHistoryContext, AddonDatasetContext, DocumentLimitUpsellContext, NavbarContext, FreeTrialContext, FeedbackContext, LiveUserApplicationContext, PackageVersionInfoContext, StudioAnnouncementContext, CopyPasteContext, UserApplicationCacheContext, PreviewCardContext, ZIndexContext, zIndexContextDefaults, CommentsAuthoringPathContext } from "sanity/_singletons";
|
|
9
9
|
import { useVirtualizer, defaultRangeExtractor, elementScroll } from "@tanstack/react-virtual";
|
|
10
10
|
import throttle from "lodash-es/throttle.js";
|
|
11
11
|
import { styled, css, useTheme as useTheme$1, createGlobalStyle, keyframes } from "styled-components";
|
|
@@ -48,7 +48,7 @@ import { isIndexSegment, isKeySegment, isIndexTuple, isKeyedObject, isTypedObjec
|
|
|
48
48
|
import { observableCallback } from "observable-callback";
|
|
49
49
|
import { useTelemetry, TelemetryProvider, DeferredTelemetryProvider } from "@sanity/telemetry/react";
|
|
50
50
|
import { ClipboardIcon } from "@sanity/icons/Clipboard";
|
|
51
|
-
import { usePortableTextEditor, PortableTextEditor, usePortableTextEditorSelection, useEditor, useEditorSelector, PortableTextEditable, defineTextBlock, defineBlockObject, defineInlineObject,
|
|
51
|
+
import { usePortableTextEditor, PortableTextEditor, usePortableTextEditorSelection, useEditor, useEditorSelector, PortableTextEditable, defineTextBlock, defineBlockObject, defineInlineObject, EditorProvider, defineSchema, keyGenerator as keyGenerator$1 } from "@portabletext/editor";
|
|
52
52
|
import { fromUrl } from "@sanity/bifur-client";
|
|
53
53
|
import debug$c from "debug";
|
|
54
54
|
import startCase from "lodash-es/startCase.js";
|
|
@@ -17377,19 +17377,19 @@ function whatwgRNG(length = 16) {
|
|
|
17377
17377
|
return crypto.getRandomValues(rnds8), rnds8;
|
|
17378
17378
|
}
|
|
17379
17379
|
const getByteHexTable = /* @__PURE__ */ (() => {
|
|
17380
|
-
let
|
|
17380
|
+
let table;
|
|
17381
17381
|
return () => {
|
|
17382
|
-
if (
|
|
17383
|
-
return
|
|
17384
|
-
|
|
17382
|
+
if (table)
|
|
17383
|
+
return table;
|
|
17384
|
+
table = [];
|
|
17385
17385
|
for (let i = 0; i < 256; ++i)
|
|
17386
|
-
|
|
17387
|
-
return
|
|
17386
|
+
table[i] = (i + 256).toString(16).slice(1);
|
|
17387
|
+
return table;
|
|
17388
17388
|
};
|
|
17389
17389
|
})();
|
|
17390
17390
|
function randomKey(length) {
|
|
17391
|
-
const
|
|
17392
|
-
return whatwgRNG(length).reduce((str, n) => str +
|
|
17391
|
+
const table = getByteHexTable();
|
|
17392
|
+
return whatwgRNG(length).reduce((str, n) => str + table[n], "").slice(0, length);
|
|
17393
17393
|
}
|
|
17394
17394
|
function hasKey$1(item) {
|
|
17395
17395
|
return item._key !== void 0;
|
|
@@ -32073,45 +32073,85 @@ function useColorSchemeOptions(setScheme, t) {
|
|
|
32073
32073
|
let t15;
|
|
32074
32074
|
return $[33] !== t14 || $[34] !== t4 || $[35] !== t9 ? (t15 = [t4, t9, t14], $[33] = t14, $[34] = t4, $[35] = t9, $[36] = t15) : t15 = $[36], t15;
|
|
32075
32075
|
}
|
|
32076
|
-
const
|
|
32077
|
-
|
|
32078
|
-
|
|
32079
|
-
|
|
32080
|
-
|
|
32081
|
-
|
|
32082
|
-
|
|
32083
|
-
|
|
32084
|
-
|
|
32085
|
-
|
|
32086
|
-
|
|
32087
|
-
|
|
32088
|
-
|
|
32089
|
-
|
|
32090
|
-
|
|
32091
|
-
|
|
32092
|
-
|
|
32093
|
-
|
|
32094
|
-
|
|
32095
|
-
|
|
32096
|
-
|
|
32097
|
-
|
|
32098
|
-
|
|
32099
|
-
|
|
32100
|
-
|
|
32101
|
-
|
|
32102
|
-
|
|
32103
|
-
|
|
32104
|
-
|
|
32105
|
-
|
|
32106
|
-
|
|
32107
|
-
|
|
32108
|
-
|
|
32109
|
-
|
|
32110
|
-
|
|
32111
|
-
|
|
32112
|
-
|
|
32113
|
-
|
|
32114
|
-
|
|
32076
|
+
const studioTableRender = (props2) => /* @__PURE__ */ jsx(StudioTable, { ...props2 });
|
|
32077
|
+
function resolveContainers(containers) {
|
|
32078
|
+
const tableRole = containers?.table ?? {
|
|
32079
|
+
kind: "container",
|
|
32080
|
+
type: "table",
|
|
32081
|
+
arrayField: "rows"
|
|
32082
|
+
};
|
|
32083
|
+
return {
|
|
32084
|
+
table: {
|
|
32085
|
+
...tableRole,
|
|
32086
|
+
render: tableRole.render ?? studioTableRender
|
|
32087
|
+
},
|
|
32088
|
+
row: containers?.row ? {
|
|
32089
|
+
...containers.row,
|
|
32090
|
+
render: containers.row.render ?? referenceContainers.row?.render
|
|
32091
|
+
} : referenceContainers.row,
|
|
32092
|
+
cell: containers?.cell ? {
|
|
32093
|
+
...containers.cell,
|
|
32094
|
+
render: containers.cell.render ?? referenceContainers.cell?.render
|
|
32095
|
+
} : referenceContainers.cell
|
|
32096
|
+
};
|
|
32097
|
+
}
|
|
32098
|
+
function createScaffoldBehaviors(table, tableType, rowsField) {
|
|
32099
|
+
return [defineBehavior({
|
|
32100
|
+
on: "insert.block",
|
|
32101
|
+
guard: ({
|
|
32102
|
+
event
|
|
32103
|
+
}) => {
|
|
32104
|
+
if (event.block._type !== tableType)
|
|
32105
|
+
return !1;
|
|
32106
|
+
const rows = rowsField in event.block ? event.block[rowsField] : void 0;
|
|
32107
|
+
return !(Array.isArray(rows) && rows.length > 0);
|
|
32108
|
+
},
|
|
32109
|
+
actions: [({
|
|
32110
|
+
event
|
|
32111
|
+
}) => [raise({
|
|
32112
|
+
...event,
|
|
32113
|
+
block: {
|
|
32114
|
+
...event.block,
|
|
32115
|
+
...table.createBlock({
|
|
32116
|
+
headerRows: 1
|
|
32117
|
+
})
|
|
32118
|
+
}
|
|
32119
|
+
})]]
|
|
32120
|
+
})];
|
|
32121
|
+
}
|
|
32122
|
+
function PortableTextTablePlugin(props2) {
|
|
32123
|
+
const $ = c(14), {
|
|
32124
|
+
containers
|
|
32125
|
+
} = props2;
|
|
32126
|
+
let t0, t1;
|
|
32127
|
+
if ($[0] !== containers) {
|
|
32128
|
+
const resolved = resolveContainers(containers), tableDefinition = defineTable({
|
|
32129
|
+
containers: resolved
|
|
32130
|
+
});
|
|
32131
|
+
t0 = tableDefinition, t1 = createScaffoldBehaviors(tableDefinition, resolved.table.type, resolved.table.arrayField), $[0] = containers, $[1] = t0, $[2] = t1;
|
|
32132
|
+
} else
|
|
32133
|
+
t0 = $[1], t1 = $[2];
|
|
32134
|
+
let t2;
|
|
32135
|
+
$[3] !== t0 || $[4] !== t1 ? (t2 = {
|
|
32136
|
+
table: t0,
|
|
32137
|
+
scaffoldBehaviors: t1
|
|
32138
|
+
}, $[3] = t0, $[4] = t1, $[5] = t2) : t2 = $[5];
|
|
32139
|
+
const {
|
|
32140
|
+
table,
|
|
32141
|
+
scaffoldBehaviors
|
|
32142
|
+
} = t2;
|
|
32143
|
+
let t3;
|
|
32144
|
+
$[6] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t3 = /* @__PURE__ */ jsx(HeaderCellWeight, {}), $[6] = t3) : t3 = $[6];
|
|
32145
|
+
let t4;
|
|
32146
|
+
$[7] !== table.Plugin ? (t4 = /* @__PURE__ */ jsx(table.Plugin, {}), $[7] = table.Plugin, $[8] = t4) : t4 = $[8];
|
|
32147
|
+
let t5;
|
|
32148
|
+
$[9] !== scaffoldBehaviors ? (t5 = /* @__PURE__ */ jsx(BehaviorPlugin, { behaviors: scaffoldBehaviors }), $[9] = scaffoldBehaviors, $[10] = t5) : t5 = $[10];
|
|
32149
|
+
let t6;
|
|
32150
|
+
return $[11] !== t4 || $[12] !== t5 ? (t6 = /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
32151
|
+
t3,
|
|
32152
|
+
t4,
|
|
32153
|
+
t5
|
|
32154
|
+
] }), $[11] = t4, $[12] = t5, $[13] = t6) : t6 = $[13], t6;
|
|
32115
32155
|
}
|
|
32116
32156
|
function StudioTable(props2) {
|
|
32117
32157
|
const $ = c(27), portal = usePortal(), {
|
|
@@ -32400,11 +32440,11 @@ function DefaultMarkdownShortcutsPlugin(incomingProps) {
|
|
|
32400
32440
|
return $[12] !== restMarkdownConfig || $[13] !== t1 || $[14] !== t2 ? (t3 = /* @__PURE__ */ jsx(MarkdownShortcutsPlugin, { orderedList: t1, unorderedList: t2, ...restMarkdownConfig }), $[12] = restMarkdownConfig, $[13] = t1, $[14] = t2, $[15] = t3) : t3 = $[15], t3;
|
|
32401
32441
|
}
|
|
32402
32442
|
function DefaultTablePlugin(props2) {
|
|
32403
|
-
const $ = c(
|
|
32443
|
+
const $ = c(2);
|
|
32404
32444
|
if (props2?.enabled !== !0)
|
|
32405
32445
|
return null;
|
|
32406
32446
|
let t0;
|
|
32407
|
-
return $[0]
|
|
32447
|
+
return $[0] !== props2.containers ? (t0 = /* @__PURE__ */ jsx(PortableTextTablePlugin, { containers: props2.containers }), $[0] = props2.containers, $[1] = t0) : t0 = $[1], t0;
|
|
32408
32448
|
}
|
|
32409
32449
|
function DefaultPasteLinkPlugin(props2) {
|
|
32410
32450
|
const $ = c(7);
|