@pantheon-systems/puck-css 0.11.1 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/config.d.ts +9 -0
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +17 -2
- package/dist/core/config.js.map +1 -1
- package/dist/core/types.d.ts +17 -4
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/utils/requestError.d.ts +7 -0
- package/dist/core/utils/requestError.d.ts.map +1 -0
- package/dist/core/utils/requestError.js +12 -0
- package/dist/core/utils/requestError.js.map +1 -0
- package/dist/data/dal/init.d.ts.map +1 -1
- package/dist/data/dal/init.js +8 -3
- package/dist/data/dal/init.js.map +1 -1
- package/dist/data/dal/p1-store.d.ts +1 -1
- package/dist/data/dal/p1-store.d.ts.map +1 -1
- package/dist/data/dal/p1-store.js +54 -12
- package/dist/data/dal/p1-store.js.map +1 -1
- package/dist/data/fields.d.ts.map +1 -1
- package/dist/data/fields.js +10 -0
- package/dist/data/fields.js.map +1 -1
- package/dist/editor/P1PuckProvider.d.ts.map +1 -1
- package/dist/editor/P1PuckProvider.js +37 -5
- package/dist/editor/P1PuckProvider.js.map +1 -1
- package/dist/editor/useP1Editor.d.ts.map +1 -1
- package/dist/editor/useP1Editor.js +12 -5
- package/dist/editor/useP1Editor.js.map +1 -1
- package/dist/features/content-type-templates/hooks/useTemplateList.d.ts.map +1 -1
- package/dist/features/content-type-templates/hooks/useTemplateList.js +3 -1
- package/dist/features/content-type-templates/hooks/useTemplateList.js.map +1 -1
- package/dist/features/content-type-templates/permissions/role-permissions.d.ts +1 -0
- package/dist/features/content-type-templates/permissions/role-permissions.d.ts.map +1 -1
- package/dist/features/content-type-templates/permissions/role-permissions.js +2 -0
- package/dist/features/content-type-templates/permissions/role-permissions.js.map +1 -1
- package/dist/features/content-type-templates/types.d.ts +2 -1
- package/dist/features/content-type-templates/types.d.ts.map +1 -1
- package/dist/p1/editor/connect/field-connect-plugin.d.ts +8 -2
- package/dist/p1/editor/connect/field-connect-plugin.d.ts.map +1 -1
- package/dist/p1/editor/connect/field-connect-plugin.js +12 -2
- package/dist/p1/editor/connect/field-connect-plugin.js.map +1 -1
- package/dist/p1/editor/hooks/index.d.ts +1 -0
- package/dist/p1/editor/hooks/index.d.ts.map +1 -1
- package/dist/p1/editor/hooks/index.js +1 -0
- package/dist/p1/editor/hooks/index.js.map +1 -1
- package/dist/p1/editor/hooks/useLiveEditorContext.d.ts +24 -0
- package/dist/p1/editor/hooks/useLiveEditorContext.d.ts.map +1 -0
- package/dist/p1/editor/hooks/useLiveEditorContext.js +36 -0
- package/dist/p1/editor/hooks/useLiveEditorContext.js.map +1 -0
- package/dist/p1/editor/hooks/useLiveRemoteDatasources.d.ts +11 -7
- package/dist/p1/editor/hooks/useLiveRemoteDatasources.d.ts.map +1 -1
- package/dist/p1/editor/hooks/useLiveRemoteDatasources.js +10 -19
- package/dist/p1/editor/hooks/useLiveRemoteDatasources.js.map +1 -1
- package/dist/p1/editor/hooks/useP1Plugins.d.ts +5 -0
- package/dist/p1/editor/hooks/useP1Plugins.d.ts.map +1 -1
- package/dist/p1/editor/hooks/useP1Plugins.js +10 -18
- package/dist/p1/editor/hooks/useP1Plugins.js.map +1 -1
- package/package.json +2 -2
- package/src/pds/theme/PuckEditorTheme.css +18 -0
- package/src/pds/theme/PuckEditorTheme.test.ts +9 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/features/content-type-templates/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/features/content-type-templates/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,eAAe,CAAC;AAE1E,YAAY,EACV,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,8BAA8B,CAAC;AAEtC;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,kBAAkB;IAClB,UAAU,EAAE,MAAM,CAAC;IAEnB,4CAA4C;IAC5C,UAAU,EAAE,MAAM,CAAC;IAEnB,qEAAqE;IACrE,eAAe,EAAE,MAAM,CAAC;CACzB"}
|
|
@@ -2,9 +2,15 @@ import type { Config, Plugin } from "@puckeditor/core";
|
|
|
2
2
|
import type { RemoteDatasourceDefinition } from "../../../data/remote-datasources/remote-datasource-registry";
|
|
3
3
|
import type { RouteRow } from "../../../data/page-store";
|
|
4
4
|
export declare function createFieldConnectPlugin(opts: {
|
|
5
|
-
routes: RouteRow[];
|
|
6
5
|
config: Config;
|
|
7
6
|
editorPath: string;
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Fallback until live data resolves — and the only source if the host does not
|
|
9
|
+
* serve /p1/api/editor-context. Inside a P1PuckProvider these are never used.
|
|
10
|
+
* @deprecated the plugin reads live data on its own.
|
|
11
|
+
*/
|
|
12
|
+
routes?: RouteRow[];
|
|
13
|
+
/** @deprecated see routes */
|
|
14
|
+
remoteDatasourceRegistry?: RemoteDatasourceDefinition[];
|
|
9
15
|
}): Plugin;
|
|
10
16
|
//# sourceMappingURL=field-connect-plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-connect-plugin.d.ts","sourceRoot":"","sources":["../../../../src/p1/editor/connect/field-connect-plugin.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAIvD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,6DAA6D,CAAC;AAC9G,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"field-connect-plugin.d.ts","sourceRoot":"","sources":["../../../../src/p1/editor/connect/field-connect-plugin.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAIvD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,6DAA6D,CAAC;AAC9G,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAczD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC;IACpB,6BAA6B;IAC7B,wBAAwB,CAAC,EAAE,0BAA0B,EAAE,CAAC;CACzD,GAAG,MAAM,CAgFT"}
|
|
@@ -3,14 +3,24 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
import { isCrossPageRefTemplateString } from "../../../data/cross-reference";
|
|
5
5
|
import { TemplateAutocompleteLayer } from "../template-autocomplete-layer";
|
|
6
|
+
import { useLiveEditorContext } from "../hooks/useLiveEditorContext";
|
|
6
7
|
import { ConnectFieldModal } from "./connect-field-modal";
|
|
7
8
|
export function createFieldConnectPlugin(opts) {
|
|
8
|
-
const {
|
|
9
|
+
const { config, editorPath, routes: fallbackRoutes = [], remoteDatasourceRegistry: fallbackRegistry = [], } = opts;
|
|
9
10
|
function ConnectableScalarField(props) {
|
|
10
11
|
const [open, setOpen] = useState(false);
|
|
11
12
|
const { children, readOnly, onChange, value } = props;
|
|
12
13
|
const linked = isCrossPageRefTemplateString(value);
|
|
13
|
-
|
|
14
|
+
// useLiveEditorContext, not useLiveRemoteDatasources — this only needs the
|
|
15
|
+
// registry/routes, and it runs for every text field in the sidebar (bound or
|
|
16
|
+
// not), so it must skip the per-datasource context-resolution queries.
|
|
17
|
+
const live = useLiveEditorContext(editorPath);
|
|
18
|
+
// live.hasLoaded (not registry.length) distinguishes "not loaded yet"
|
|
19
|
+
// from "loaded and genuinely empty" — a length check would keep showing
|
|
20
|
+
// a stale fallback forever once live data legitimately resolves empty.
|
|
21
|
+
const registry = live.hasLoaded ? live.registry : fallbackRegistry;
|
|
22
|
+
const routes = live.hasLoaded ? live.routes : fallbackRoutes;
|
|
23
|
+
return (_jsx(TemplateAutocompleteLayer, { readOnly: readOnly, onChange: onChange, registry: registry, children: _jsxs("div", { style: { position: "relative", paddingBottom: 2 }, children: [children, !readOnly && (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", onClick: (e) => {
|
|
14
24
|
e.preventDefault();
|
|
15
25
|
e.stopPropagation();
|
|
16
26
|
setOpen(true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-connect-plugin.js","sourceRoot":"","sources":["../../../../src/p1/editor/connect/field-connect-plugin.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAEjD,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAG7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAW1D,MAAM,UAAU,wBAAwB,CAAC,
|
|
1
|
+
{"version":3,"file":"field-connect-plugin.js","sourceRoot":"","sources":["../../../../src/p1/editor/connect/field-connect-plugin.tsx"],"names":[],"mappings":"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"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from "./api-hooks";
|
|
2
2
|
export { useEditorContext } from "./useEditorContext";
|
|
3
|
+
export { useLiveEditorContext } from "./useLiveEditorContext";
|
|
3
4
|
export { useLiveRemoteDatasources } from "./useLiveRemoteDatasources";
|
|
4
5
|
export { useP1Plugins } from "./useP1Plugins";
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/p1/editor/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/p1/editor/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from "./api-hooks";
|
|
2
2
|
export { useEditorContext } from "./useEditorContext";
|
|
3
|
+
export { useLiveEditorContext } from "./useLiveEditorContext";
|
|
3
4
|
export { useLiveRemoteDatasources } from "./useLiveRemoteDatasources";
|
|
4
5
|
export { useP1Plugins } from "./useP1Plugins";
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/p1/editor/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/p1/editor/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { RouteRow } from "../../../data/page-store";
|
|
2
|
+
import type { RemoteDatasourceDefinition } from "../../../data/remote-datasources/remote-datasource-registry";
|
|
3
|
+
/**
|
|
4
|
+
* Live registry/routes for components rendered by a Puck plugin, without the
|
|
5
|
+
* per-datasource context-resolution queries that useLiveRemoteDatasources
|
|
6
|
+
* also runs. Use this when a component only needs the registry/routes (not
|
|
7
|
+
* resolved datasource values) and is instantiated once per field rather than
|
|
8
|
+
* once per canvas — e.g. field-connect-plugin, which wraps every text field in
|
|
9
|
+
* the sidebar (bound or not), so the full per-datasource query set would be
|
|
10
|
+
* multiplied by the field count for no benefit.
|
|
11
|
+
*
|
|
12
|
+
* `fallbackPath` is only used outside a P1PuckProvider (e.g. the published
|
|
13
|
+
* `EditorClient`), where there is no context to read the open document from.
|
|
14
|
+
*/
|
|
15
|
+
export declare function useLiveEditorContext(fallbackPath: string): {
|
|
16
|
+
path: string;
|
|
17
|
+
branchId: string | undefined;
|
|
18
|
+
hasLoaded: boolean;
|
|
19
|
+
registry: RemoteDatasourceDefinition[];
|
|
20
|
+
routes: RouteRow[];
|
|
21
|
+
routeTemplateKeys: string[];
|
|
22
|
+
savedPreviewParams: Record<string, string>;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=useLiveEditorContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLiveEditorContext.d.ts","sourceRoot":"","sources":["../../../../src/p1/editor/hooks/useLiveEditorContext.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,6DAA6D,CAAC;AAQ9G;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM;;;;;;;;EAkBxD"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useP1PuckOptional } from "../../../core/P1PuckContext";
|
|
3
|
+
import { useEditorContext } from "./useEditorContext";
|
|
4
|
+
const EMPTY_REGISTRY = [];
|
|
5
|
+
const EMPTY_ROUTES = [];
|
|
6
|
+
const EMPTY_TEMPLATE_KEYS = [];
|
|
7
|
+
const EMPTY_PREVIEW_PARAMS = {};
|
|
8
|
+
/**
|
|
9
|
+
* Live registry/routes for components rendered by a Puck plugin, without the
|
|
10
|
+
* per-datasource context-resolution queries that useLiveRemoteDatasources
|
|
11
|
+
* also runs. Use this when a component only needs the registry/routes (not
|
|
12
|
+
* resolved datasource values) and is instantiated once per field rather than
|
|
13
|
+
* once per canvas — e.g. field-connect-plugin, which wraps every text field in
|
|
14
|
+
* the sidebar (bound or not), so the full per-datasource query set would be
|
|
15
|
+
* multiplied by the field count for no benefit.
|
|
16
|
+
*
|
|
17
|
+
* `fallbackPath` is only used outside a P1PuckProvider (e.g. the published
|
|
18
|
+
* `EditorClient`), where there is no context to read the open document from.
|
|
19
|
+
*/
|
|
20
|
+
export function useLiveEditorContext(fallbackPath) {
|
|
21
|
+
const p1Puck = useP1PuckOptional();
|
|
22
|
+
const path = p1Puck?.currentDocument?.path ?? fallbackPath;
|
|
23
|
+
const branchId = p1Puck?.branchId;
|
|
24
|
+
const { data: editorContext } = useEditorContext(path, branchId);
|
|
25
|
+
const hasLoaded = editorContext !== undefined;
|
|
26
|
+
return {
|
|
27
|
+
path,
|
|
28
|
+
branchId,
|
|
29
|
+
hasLoaded,
|
|
30
|
+
registry: editorContext?.remoteDatasourceRegistry ?? EMPTY_REGISTRY,
|
|
31
|
+
routes: editorContext?.routes ?? EMPTY_ROUTES,
|
|
32
|
+
routeTemplateKeys: editorContext?.routeTemplateKeys ?? EMPTY_TEMPLATE_KEYS,
|
|
33
|
+
savedPreviewParams: editorContext?.savedPreviewParams ?? EMPTY_PREVIEW_PARAMS,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=useLiveEditorContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLiveEditorContext.js","sourceRoot":"","sources":["../../../../src/p1/editor/hooks/useLiveEditorContext.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,cAAc,GAAiC,EAAE,CAAC;AACxD,MAAM,YAAY,GAAe,EAAE,CAAC;AACpC,MAAM,mBAAmB,GAAa,EAAE,CAAC;AACzC,MAAM,oBAAoB,GAA2B,EAAE,CAAC;AAExD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,oBAAoB,CAAC,YAAoB;IACvD,MAAM,MAAM,GAAG,iBAAiB,EAAE,CAAC;IACnC,MAAM,IAAI,GAAG,MAAM,EAAE,eAAe,EAAE,IAAI,IAAI,YAAY,CAAC;IAC3D,MAAM,QAAQ,GAAG,MAAM,EAAE,QAAQ,CAAC;IAElC,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,gBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACjE,MAAM,SAAS,GAAG,aAAa,KAAK,SAAS,CAAC;IAE9C,OAAO;QACL,IAAI;QACJ,QAAQ;QACR,SAAS;QACT,QAAQ,EAAE,aAAa,EAAE,wBAAwB,IAAI,cAAc;QACnE,MAAM,EAAE,aAAa,EAAE,MAAM,IAAI,YAAY;QAC7C,iBAAiB,EAAE,aAAa,EAAE,iBAAiB,IAAI,mBAAmB;QAC1E,kBAAkB,EAChB,aAAa,EAAE,kBAAkB,IAAI,oBAAoB;KAC5D,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { RouteRow } from "../../../data/page-store";
|
|
2
|
-
import type { RemoteDatasourceDefinition } from "../../../data/remote-datasources/remote-datasource-registry";
|
|
3
1
|
/**
|
|
4
2
|
* Live datasource state for components rendered by a Puck plugin.
|
|
5
3
|
*
|
|
@@ -15,16 +13,22 @@ import type { RemoteDatasourceDefinition } from "../../../data/remote-datasource
|
|
|
15
13
|
* current document path stay live without anything crossing the plugin
|
|
16
14
|
* boundary.
|
|
17
15
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
16
|
+
* This also resolves each registry entry's datasource context (one query per
|
|
17
|
+
* entry) — only use it where that's actually needed. A component instantiated
|
|
18
|
+
* once per field should use useLiveEditorContext instead, which skips that.
|
|
19
|
+
*
|
|
20
|
+
* `fallbackPath` is only used outside a P1PuckProvider (e.g. the published
|
|
21
|
+
* `EditorClient`), where there is no context to read the open document from.
|
|
20
22
|
*/
|
|
21
23
|
export declare function useLiveRemoteDatasources(fallbackPath: string): {
|
|
22
|
-
path: string;
|
|
23
|
-
registry: RemoteDatasourceDefinition[];
|
|
24
24
|
context: import("../../../server").RemoteDatasourceContext;
|
|
25
25
|
loadingIds: Set<string>;
|
|
26
26
|
isLoading: boolean;
|
|
27
|
-
|
|
27
|
+
path: string;
|
|
28
|
+
branchId: string | undefined;
|
|
29
|
+
hasLoaded: boolean;
|
|
30
|
+
registry: import("../../..").RemoteDatasourceDefinition[];
|
|
31
|
+
routes: import("../../..").RouteRow[];
|
|
28
32
|
routeTemplateKeys: string[];
|
|
29
33
|
savedPreviewParams: Record<string, string>;
|
|
30
34
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLiveRemoteDatasources.d.ts","sourceRoot":"","sources":["../../../../src/p1/editor/hooks/useLiveRemoteDatasources.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLiveRemoteDatasources.d.ts","sourceRoot":"","sources":["../../../../src/p1/editor/hooks/useLiveRemoteDatasources.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,wBAAwB,CAAC,YAAY,EAAE,MAAM;;;;;;;;;;;EAc5D"}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useP1PuckOptional } from "../../../core/P1PuckContext";
|
|
3
2
|
import { useRemoteDatasourceContext } from "./api-hooks";
|
|
4
|
-
import {
|
|
5
|
-
const EMPTY_REGISTRY = [];
|
|
6
|
-
const EMPTY_ROUTES = [];
|
|
7
|
-
const EMPTY_TEMPLATE_KEYS = [];
|
|
8
|
-
const EMPTY_PREVIEW_PARAMS = {};
|
|
3
|
+
import { useLiveEditorContext } from "./useLiveEditorContext";
|
|
9
4
|
/**
|
|
10
5
|
* Live datasource state for components rendered by a Puck plugin.
|
|
11
6
|
*
|
|
@@ -21,25 +16,21 @@ const EMPTY_PREVIEW_PARAMS = {};
|
|
|
21
16
|
* current document path stay live without anything crossing the plugin
|
|
22
17
|
* boundary.
|
|
23
18
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
19
|
+
* This also resolves each registry entry's datasource context (one query per
|
|
20
|
+
* entry) — only use it where that's actually needed. A component instantiated
|
|
21
|
+
* once per field should use useLiveEditorContext instead, which skips that.
|
|
22
|
+
*
|
|
23
|
+
* `fallbackPath` is only used outside a P1PuckProvider (e.g. the published
|
|
24
|
+
* `EditorClient`), where there is no context to read the open document from.
|
|
26
25
|
*/
|
|
27
26
|
export function useLiveRemoteDatasources(fallbackPath) {
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const branchId = p1Puck?.branchId;
|
|
31
|
-
const { data: editorContext } = useEditorContext(path, branchId);
|
|
32
|
-
const registry = editorContext?.remoteDatasourceRegistry ?? EMPTY_REGISTRY;
|
|
33
|
-
const { context, loadingIds, isLoading } = useRemoteDatasourceContext(path, registry, branchId);
|
|
27
|
+
const live = useLiveEditorContext(fallbackPath);
|
|
28
|
+
const { context, loadingIds, isLoading } = useRemoteDatasourceContext(live.path, live.registry, live.branchId);
|
|
34
29
|
return {
|
|
35
|
-
|
|
36
|
-
registry,
|
|
30
|
+
...live,
|
|
37
31
|
context,
|
|
38
32
|
loadingIds,
|
|
39
33
|
isLoading,
|
|
40
|
-
routes: editorContext?.routes ?? EMPTY_ROUTES,
|
|
41
|
-
routeTemplateKeys: editorContext?.routeTemplateKeys ?? EMPTY_TEMPLATE_KEYS,
|
|
42
|
-
savedPreviewParams: editorContext?.savedPreviewParams ?? EMPTY_PREVIEW_PARAMS,
|
|
43
34
|
};
|
|
44
35
|
}
|
|
45
36
|
//# sourceMappingURL=useLiveRemoteDatasources.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLiveRemoteDatasources.js","sourceRoot":"","sources":["../../../../src/p1/editor/hooks/useLiveRemoteDatasources.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useLiveRemoteDatasources.js","sourceRoot":"","sources":["../../../../src/p1/editor/hooks/useLiveRemoteDatasources.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,wBAAwB,CAAC,YAAoB;IAC3D,MAAM,IAAI,GAAG,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAChD,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,0BAA0B,CACnE,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,QAAQ,CACd,CAAC;IAEF,OAAO;QACL,GAAG,IAAI;QACP,OAAO;QACP,UAAU;QACV,SAAS;KACV,CAAC;AACJ,CAAC"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import type { Config, Plugin } from "@puckeditor/core";
|
|
2
|
+
/**
|
|
3
|
+
* A new `plugins` array remounts the whole canvas, so this must stay stable
|
|
4
|
+
* from the first render — never gated behind async data. Plugins read their own
|
|
5
|
+
* live data via useLiveEditorContext/useLiveRemoteDatasources instead.
|
|
6
|
+
*/
|
|
2
7
|
export declare function useP1Plugins(path: string, config: Config): Plugin[];
|
|
3
8
|
//# sourceMappingURL=useP1Plugins.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useP1Plugins.d.ts","sourceRoot":"","sources":["../../../../src/p1/editor/hooks/useP1Plugins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"useP1Plugins.d.ts","sourceRoot":"","sources":["../../../../src/p1/editor/hooks/useP1Plugins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAMvD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CASnE"}
|
|
@@ -2,24 +2,16 @@ import { useMemo } from "react";
|
|
|
2
2
|
import { createPreviewResolvePlugin } from "../editor-preview-resolve";
|
|
3
3
|
import { createRemoteDatasourceExplorerPlugin } from "../remote-datasources/remote-datasource-explorer-plugin";
|
|
4
4
|
import { createFieldConnectPlugin } from "../connect/field-connect-plugin";
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* A new `plugins` array remounts the whole canvas, so this must stay stable
|
|
7
|
+
* from the first render — never gated behind async data. Plugins read their own
|
|
8
|
+
* live data via useLiveEditorContext/useLiveRemoteDatasources instead.
|
|
9
|
+
*/
|
|
7
10
|
export function useP1Plugins(path, config) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return [
|
|
14
|
-
createPreviewResolvePlugin({ editorPath: path }),
|
|
15
|
-
createRemoteDatasourceExplorerPlugin({ editorPath: path }),
|
|
16
|
-
createFieldConnectPlugin({
|
|
17
|
-
routes: ctx.routes,
|
|
18
|
-
config,
|
|
19
|
-
editorPath: path,
|
|
20
|
-
remoteDatasourceRegistry: ctx.remoteDatasourceRegistry,
|
|
21
|
-
}),
|
|
22
|
-
];
|
|
23
|
-
}, [ctx, path, config]);
|
|
11
|
+
return useMemo(() => [
|
|
12
|
+
createPreviewResolvePlugin({ editorPath: path }),
|
|
13
|
+
createRemoteDatasourceExplorerPlugin({ editorPath: path }),
|
|
14
|
+
createFieldConnectPlugin({ config, editorPath: path }),
|
|
15
|
+
], [path, config]);
|
|
24
16
|
}
|
|
25
17
|
//# sourceMappingURL=useP1Plugins.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useP1Plugins.js","sourceRoot":"","sources":["../../../../src/p1/editor/hooks/useP1Plugins.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,oCAAoC,EAAE,MAAM,yDAAyD,CAAC;AAC/G,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"useP1Plugins.js","sourceRoot":"","sources":["../../../../src/p1/editor/hooks/useP1Plugins.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,oCAAoC,EAAE,MAAM,yDAAyD,CAAC;AAC/G,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAE3E;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,MAAc;IACvD,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC;QACJ,0BAA0B,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;QAChD,oCAAoC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;QAC1D,wBAAwB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;KACvD,EACD,CAAC,IAAI,EAAE,MAAM,CAAC,CACf,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pantheon-systems/puck-css",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Puck editor integration with Collaborative State System",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"jsep": "^1.4.0",
|
|
97
97
|
"lodash.isequal": "^4.5.0",
|
|
98
98
|
"yjs": "^13.6.29",
|
|
99
|
-
"@pantheon-systems/css-client": "0.
|
|
99
|
+
"@pantheon-systems/css-client": "0.12.0"
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
102
|
"@floating-ui/react": "^0.27.19",
|
|
@@ -358,3 +358,21 @@
|
|
|
358
358
|
flex: 1;
|
|
359
359
|
min-height: 0;
|
|
360
360
|
}
|
|
361
|
+
|
|
362
|
+
/* ── Richtext toolbar: opaque background prevents scroll bleed-through ──
|
|
363
|
+
*
|
|
364
|
+
* @puckeditor/core's richtext toolbar wrapper (._RichTextEditor-menu_) is
|
|
365
|
+
* `position: sticky; top: 0; z-index: 1` but declares no background of its own.
|
|
366
|
+
* When a richtext field holds more content than its height, the ProseMirror
|
|
367
|
+
* text scrolls *underneath* the sticky toolbar and shows through it — the
|
|
368
|
+
* toolbar icons and the field's first line of text visibly overlap (the
|
|
369
|
+
* artefact reported alongside the paste bug). Painting the sticky wrapper with
|
|
370
|
+
* the field's own surface colour (the same `--puck-color-white` the editor body
|
|
371
|
+
* uses, remapped to `--pds-color-bg-default` above) stops the bleed-through.
|
|
372
|
+
*
|
|
373
|
+
* Substring selector (not the hashed CSS-module class) so it survives
|
|
374
|
+
* @puckeditor/core upgrades, and scoped to `.puck-editor-theme` so — like every
|
|
375
|
+
* rule here — it never matches inside the preview iframe. */
|
|
376
|
+
.puck-editor-theme [class*="_RichTextEditor-menu_"] {
|
|
377
|
+
background: var(--puck-color-white);
|
|
378
|
+
}
|
|
@@ -171,6 +171,15 @@ describe('PuckEditorTheme.css', () => {
|
|
|
171
171
|
);
|
|
172
172
|
});
|
|
173
173
|
|
|
174
|
+
it('paints the sticky richtext toolbar so scrolled content does not show through', () => {
|
|
175
|
+
const css = readThemeCSS();
|
|
176
|
+
// The toolbar wrapper is position:sticky with no background; without an
|
|
177
|
+
// opaque fill the ProseMirror text scrolls under it and bleeds through.
|
|
178
|
+
expect(css).toMatch(
|
|
179
|
+
/\.puck-editor-theme \[class\*="_RichTextEditor-menu_"\]\s*\{[^}]*background:\s*var\(--puck-color-white\)[^}]*\}/,
|
|
180
|
+
);
|
|
181
|
+
});
|
|
182
|
+
|
|
174
183
|
it('does not use a bare body selector, which would leak into the preview iframe', () => {
|
|
175
184
|
const css = readThemeCSS();
|
|
176
185
|
// The preview iframe renders its own <body>. Because this stylesheet is a
|