@prismicio/editor-fields 0.4.68 → 0.4.70

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 (25) hide show
  1. package/dist/core/APIExplorer/components/APIExplorerContext.d.ts +2 -0
  2. package/dist/core/APIExplorer/components/Request/components/RequestLangFieldset.d.ts +5 -0
  3. package/dist/core/APIExplorer/components/Request/components/index.d.ts +1 -0
  4. package/dist/core/APIExplorer/components/Request/createRequest.d.ts +6 -2
  5. package/dist/core/service/customType.d.ts +11 -11
  6. package/dist/core/service/document.d.ts +11 -11
  7. package/dist/fields/LinkField/useLinkField.d.ts +1 -1
  8. package/dist/fields/RichTextField/RichTextField.d.ts +1 -1
  9. package/dist/fields/RichTextField/extensions/Table/TableCell/plugins/TableHandles/TableHandlesPlugin.d.ts +8 -0
  10. package/dist/fields/RichTextField/extensions/Table/TableCell/plugins/TableHandles/events.d.ts +19 -0
  11. package/dist/fields/RichTextField/extensions/Table/TableCell/plugins/TableHandles/index.d.ts +1 -0
  12. package/dist/fields/RichTextField/extensions/Table/TableCell/plugins/TableHandles/utils.d.ts +23 -0
  13. package/dist/fields/RichTextField/extensions/Table/TableCell/plugins/index.d.ts +1 -0
  14. package/dist/fields/RichTextField/extensions/Table/TableControlsWrapper.d.ts +3 -0
  15. package/dist/fields/RichTextField/extensions/Table/plugins/TableHandles/TableHandlesPluginDef.d.ts +8 -0
  16. package/dist/fields/RichTextField/extensions/Table/plugins/TableHandles/TableHandlesPluginView.d.ts +34 -0
  17. package/dist/fields/RichTextField/extensions/Table/plugins/TableHandles/TableHandlesPluginViewClass.d.ts +34 -0
  18. package/dist/index.cjs.js +133 -46
  19. package/dist/index.es.js +36245 -32077
  20. package/dist/slices/utils.d.ts +1 -1
  21. package/package.json +4 -4
  22. /package/dist/fields/RichTextField/extensions/Table/{plugins/tableHandles/tableHandlesPluginView.d.ts → TableCell/plugins/TableHandles/TableHandlesPluginView.d.ts} +0 -0
  23. /package/dist/fields/RichTextField/extensions/Table/plugins/{tableHandles/tableHandlesPlugin.d.ts → TableHandles/TableHandlesPlugin.d.ts} +0 -0
  24. /package/dist/fields/RichTextField/extensions/Table/plugins/{tableHandles → TableHandles}/index.d.ts +0 -0
  25. /package/dist/fields/RichTextField/extensions/Table/plugins/{tableHandles → TableHandles}/utils.d.ts +0 -0
@@ -31,6 +31,7 @@ export type UseAPIExplorerRequestProperties = {
31
31
  [Type in RequestTypes]?: Record<string, string>;
32
32
  };
33
33
  pagination: RequestPagination;
34
+ lang?: string;
34
35
  response?: ResponsePending | ResponseSuccess | ResponseError;
35
36
  };
36
37
  type UseAPIExplorerRequestMethods = {
@@ -42,6 +43,7 @@ type UseAPIExplorerRequestMethods = {
42
43
  page?: number;
43
44
  pageSize?: number;
44
45
  }) => void;
46
+ setLang: (lang?: string) => void;
45
47
  run: () => Promise<void>;
46
48
  };
47
49
  type APIExplorerContextType = {
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * Display a fieldset managing a request document lang setting.
4
+ */
5
+ export declare function RequestLangFieldset(): JSX.Element;
@@ -1,3 +1,4 @@
1
1
  export { RequestFormInput } from "./RequestFormInput";
2
+ export { RequestLangFieldset } from "./RequestLangFieldset";
2
3
  export { RequestPaginationFieldset } from "./RequestPaginationFieldset";
3
4
  export { RequestTypeFieldset } from "./RequestTypeFieldset";
@@ -2,11 +2,14 @@
2
2
  import type { Client } from "@prismicio/client";
3
3
  import type { RequestPagination } from "../APIExplorerContext";
4
4
  import type { RequestRunReturnType } from "./types";
5
+ type RequestOptions = Record<string, string | number | undefined> & RequestPagination & {
6
+ lang?: string;
7
+ };
5
8
  export type RequestConfig<TType extends string> = {
6
9
  type: TType;
7
10
  Fieldset?: () => JSX.Element;
8
- getSnippet: (options: Record<string, string | number> & RequestPagination) => string;
9
- run: (client: Client, options: Record<string, string | number> & RequestPagination) => Promise<RequestRunReturnType>;
11
+ getSnippet: (options: RequestOptions) => string;
12
+ run: (client: Client, options: RequestOptions) => Promise<RequestRunReturnType>;
10
13
  };
11
14
  /**
12
15
  * A factory for creating request handlers (fieldset, snippet, runner, erc.) for the API explorer.
@@ -15,3 +18,4 @@ export type RequestConfig<TType extends string> = {
15
18
  * @returns A request handler to be referenced in `./types.ts` for the API explorer to use.
16
19
  */
17
20
  export declare function createRequest<TType extends string>(config: RequestConfig<TType>): RequestConfig<TType>;
21
+ export {};
@@ -154,7 +154,7 @@ export declare function useStaticCustomType(args: CustomTypeOptionsArgs): import
154
154
  label?: string | null | undefined;
155
155
  useAsTitle?: boolean | undefined;
156
156
  placeholder?: string | undefined;
157
- select?: "web" | "document" | "media" | null | undefined;
157
+ select?: "web" | "media" | "document" | null | undefined;
158
158
  customtypes?: readonly string[] | undefined;
159
159
  masks?: readonly string[] | undefined;
160
160
  tags?: readonly string[] | undefined;
@@ -329,7 +329,7 @@ export declare function useStaticCustomType(args: CustomTypeOptionsArgs): import
329
329
  label?: string | null | undefined;
330
330
  useAsTitle?: boolean | undefined;
331
331
  placeholder?: string | undefined;
332
- select?: "web" | "document" | "media" | null | undefined;
332
+ select?: "web" | "media" | "document" | null | undefined;
333
333
  customtypes?: readonly string[] | undefined;
334
334
  masks?: readonly string[] | undefined;
335
335
  tags?: readonly string[] | undefined;
@@ -504,7 +504,7 @@ export declare function useStaticCustomType(args: CustomTypeOptionsArgs): import
504
504
  label?: string | null | undefined;
505
505
  useAsTitle?: boolean | undefined;
506
506
  placeholder?: string | undefined;
507
- select?: "web" | "document" | "media" | null | undefined;
507
+ select?: "web" | "media" | "document" | null | undefined;
508
508
  customtypes?: readonly string[] | undefined;
509
509
  masks?: readonly string[] | undefined;
510
510
  tags?: readonly string[] | undefined;
@@ -689,7 +689,7 @@ export declare function useStaticCustomType(args: CustomTypeOptionsArgs): import
689
689
  label?: string | null | undefined;
690
690
  useAsTitle?: boolean | undefined;
691
691
  placeholder?: string | undefined;
692
- select?: "web" | "document" | "media" | null | undefined;
692
+ select?: "web" | "media" | "document" | null | undefined;
693
693
  customtypes?: readonly string[] | undefined;
694
694
  masks?: readonly string[] | undefined;
695
695
  tags?: readonly string[] | undefined;
@@ -864,7 +864,7 @@ export declare function useStaticCustomType(args: CustomTypeOptionsArgs): import
864
864
  label?: string | null | undefined;
865
865
  useAsTitle?: boolean | undefined;
866
866
  placeholder?: string | undefined;
867
- select?: "web" | "document" | "media" | null | undefined;
867
+ select?: "web" | "media" | "document" | null | undefined;
868
868
  customtypes?: readonly string[] | undefined;
869
869
  masks?: readonly string[] | undefined;
870
870
  tags?: readonly string[] | undefined;
@@ -1040,7 +1040,7 @@ export declare function useStaticCustomType(args: CustomTypeOptionsArgs): import
1040
1040
  label?: string | null | undefined;
1041
1041
  useAsTitle?: boolean | undefined;
1042
1042
  placeholder?: string | undefined;
1043
- select?: "web" | "document" | "media" | null | undefined;
1043
+ select?: "web" | "media" | "document" | null | undefined;
1044
1044
  customtypes?: readonly string[] | undefined;
1045
1045
  masks?: readonly string[] | undefined;
1046
1046
  tags?: readonly string[] | undefined;
@@ -1208,7 +1208,7 @@ export declare function useStaticCustomType(args: CustomTypeOptionsArgs): import
1208
1208
  label?: string | null | undefined;
1209
1209
  useAsTitle?: boolean | undefined;
1210
1210
  placeholder?: string | undefined;
1211
- select?: "web" | "document" | "media" | null | undefined;
1211
+ select?: "web" | "media" | "document" | null | undefined;
1212
1212
  customtypes?: readonly string[] | undefined;
1213
1213
  masks?: readonly string[] | undefined;
1214
1214
  tags?: readonly string[] | undefined;
@@ -1392,7 +1392,7 @@ export declare function useStaticCustomType(args: CustomTypeOptionsArgs): import
1392
1392
  label?: string | null | undefined;
1393
1393
  useAsTitle?: boolean | undefined;
1394
1394
  placeholder?: string | undefined;
1395
- select?: "web" | "document" | "media" | null | undefined;
1395
+ select?: "web" | "media" | "document" | null | undefined;
1396
1396
  customtypes?: readonly string[] | undefined;
1397
1397
  masks?: readonly string[] | undefined;
1398
1398
  tags?: readonly string[] | undefined;
@@ -1567,7 +1567,7 @@ export declare function useStaticCustomType(args: CustomTypeOptionsArgs): import
1567
1567
  label?: string | null | undefined;
1568
1568
  useAsTitle?: boolean | undefined;
1569
1569
  placeholder?: string | undefined;
1570
- select?: "web" | "document" | "media" | null | undefined;
1570
+ select?: "web" | "media" | "document" | null | undefined;
1571
1571
  customtypes?: readonly string[] | undefined;
1572
1572
  masks?: readonly string[] | undefined;
1573
1573
  tags?: readonly string[] | undefined;
@@ -1742,7 +1742,7 @@ export declare function useStaticCustomType(args: CustomTypeOptionsArgs): import
1742
1742
  label?: string | null | undefined;
1743
1743
  useAsTitle?: boolean | undefined;
1744
1744
  placeholder?: string | undefined;
1745
- select?: "web" | "document" | "media" | null | undefined;
1745
+ select?: "web" | "media" | "document" | null | undefined;
1746
1746
  customtypes?: readonly string[] | undefined;
1747
1747
  masks?: readonly string[] | undefined;
1748
1748
  tags?: readonly string[] | undefined;
@@ -1916,7 +1916,7 @@ export declare function useStaticCustomType(args: CustomTypeOptionsArgs): import
1916
1916
  label?: string | null | undefined;
1917
1917
  useAsTitle?: boolean | undefined;
1918
1918
  placeholder?: string | undefined;
1919
- select?: "web" | "document" | "media" | null | undefined;
1919
+ select?: "web" | "media" | "document" | null | undefined;
1920
1920
  customtypes?: readonly string[] | undefined;
1921
1921
  masks?: readonly string[] | undefined;
1922
1922
  tags?: readonly string[] | undefined;
@@ -1460,7 +1460,7 @@ export declare const documentSchema: z.ZodEffects<z.ZodType<unknown, z.ZodTypeDe
1460
1460
  content: ({
1461
1461
  key: string;
1462
1462
  } & {
1463
- type: "tableCell" | "tableHeader";
1463
+ type: "tableHeader" | "tableCell";
1464
1464
  content: {
1465
1465
  __TYPE__: "StructuredTextContent";
1466
1466
  value: (({
@@ -2061,7 +2061,7 @@ export declare const documentSchema: z.ZodEffects<z.ZodType<unknown, z.ZodTypeDe
2061
2061
  content: ({
2062
2062
  key: string;
2063
2063
  } & {
2064
- type: "tableCell" | "tableHeader";
2064
+ type: "tableHeader" | "tableCell";
2065
2065
  content: {
2066
2066
  __TYPE__: "StructuredTextContent";
2067
2067
  value: (({
@@ -2654,7 +2654,7 @@ export declare const documentSchema: z.ZodEffects<z.ZodType<unknown, z.ZodTypeDe
2654
2654
  content: ({
2655
2655
  key: string;
2656
2656
  } & {
2657
- type: "tableCell" | "tableHeader";
2657
+ type: "tableHeader" | "tableCell";
2658
2658
  content: {
2659
2659
  __TYPE__: "StructuredTextContent";
2660
2660
  value: (({
@@ -3246,7 +3246,7 @@ export declare const documentSchema: z.ZodEffects<z.ZodType<unknown, z.ZodTypeDe
3246
3246
  content: ({
3247
3247
  key: string;
3248
3248
  } & {
3249
- type: "tableCell" | "tableHeader";
3249
+ type: "tableHeader" | "tableCell";
3250
3250
  content: {
3251
3251
  __TYPE__: "StructuredTextContent";
3252
3252
  value: (({
@@ -3839,7 +3839,7 @@ export declare const documentSchema: z.ZodEffects<z.ZodType<unknown, z.ZodTypeDe
3839
3839
  content: ({
3840
3840
  key: string;
3841
3841
  } & {
3842
- type: "tableCell" | "tableHeader";
3842
+ type: "tableHeader" | "tableCell";
3843
3843
  content: {
3844
3844
  __TYPE__: "StructuredTextContent";
3845
3845
  value: (({
@@ -4427,7 +4427,7 @@ export declare const documentSchema: z.ZodEffects<z.ZodType<unknown, z.ZodTypeDe
4427
4427
  content: ({
4428
4428
  key: string;
4429
4429
  } & {
4430
- type: "tableCell" | "tableHeader";
4430
+ type: "tableHeader" | "tableCell";
4431
4431
  content: {
4432
4432
  __TYPE__: "StructuredTextContent";
4433
4433
  value: (({
@@ -5027,7 +5027,7 @@ export declare const sliceItemContentSchema: z.ZodEffects<z.ZodUnknown, {
5027
5027
  content: ({
5028
5028
  key: string;
5029
5029
  } & {
5030
- type: "tableCell" | "tableHeader";
5030
+ type: "tableHeader" | "tableCell";
5031
5031
  content: {
5032
5032
  __TYPE__: "StructuredTextContent";
5033
5033
  value: (({
@@ -5620,7 +5620,7 @@ export declare const sliceItemContentSchema: z.ZodEffects<z.ZodUnknown, {
5620
5620
  content: ({
5621
5621
  key: string;
5622
5622
  } & {
5623
- type: "tableCell" | "tableHeader";
5623
+ type: "tableHeader" | "tableCell";
5624
5624
  content: {
5625
5625
  __TYPE__: "StructuredTextContent";
5626
5626
  value: (({
@@ -6215,7 +6215,7 @@ export declare const sliceItemContentSchema: z.ZodEffects<z.ZodUnknown, {
6215
6215
  content: ({
6216
6216
  key: string;
6217
6217
  } & {
6218
- type: "tableCell" | "tableHeader";
6218
+ type: "tableHeader" | "tableCell";
6219
6219
  content: {
6220
6220
  __TYPE__: "StructuredTextContent";
6221
6221
  value: (({
@@ -6808,7 +6808,7 @@ export declare const sliceItemContentSchema: z.ZodEffects<z.ZodUnknown, {
6808
6808
  content: ({
6809
6809
  key: string;
6810
6810
  } & {
6811
- type: "tableCell" | "tableHeader";
6811
+ type: "tableHeader" | "tableCell";
6812
6812
  content: {
6813
6813
  __TYPE__: "StructuredTextContent";
6814
6814
  value: (({
@@ -7399,7 +7399,7 @@ export declare const sliceItemContentSchema: z.ZodEffects<z.ZodUnknown, {
7399
7399
  content: ({
7400
7400
  key: string;
7401
7401
  } & {
7402
- type: "tableCell" | "tableHeader";
7402
+ type: "tableHeader" | "tableCell";
7403
7403
  content: {
7404
7404
  __TYPE__: "StructuredTextContent";
7405
7405
  value: (({
@@ -11,7 +11,7 @@ interface useLinkFieldParams {
11
11
  }
12
12
  export declare function useLinkField(params: useLinkFieldParams): {
13
13
  contentType: "ImageLink" | "FileLink" | "DocumentLink" | "ExternalLink" | "MediaLink" | "AnyLink" | undefined;
14
- selectType: "web" | "document" | "media" | "any" | undefined;
14
+ selectType: "web" | "media" | "document" | "any" | undefined;
15
15
  fieldValue: string;
16
16
  onDisplayTextChange: (displayText: string) => void;
17
17
  onValueChange: (value: string, options?: {
@@ -15,5 +15,5 @@ interface Props<TContent extends ExtendedRichTextContent> {
15
15
  * @default false */
16
16
  shouldReturnEmptyContent?: boolean;
17
17
  }
18
- export declare function RichTextField<TContent extends ExtendedRichTextContent>(props: Props<TContent>): JSX.Element;
18
+ export declare function RichTextField<TContent extends ExtendedRichTextContent>(props: Props<TContent>): JSX.Element | null;
19
19
  export {};
@@ -0,0 +1,8 @@
1
+ import type { Editor } from "@tiptap/core";
2
+ import { Plugin } from "@tiptap/pm/state";
3
+ import { DecorationSet } from "@tiptap/pm/view";
4
+ /** Plugin responsible for showing and hiding the row and column handles. */
5
+ export declare function TableHandlesPlugin(this: {
6
+ editor: Editor;
7
+ name: string;
8
+ }): Plugin<DecorationSet>;
@@ -0,0 +1,19 @@
1
+ import type { Editor } from "@tiptap/core";
2
+ export type TableHandleEventDetail = {
3
+ type: "row" | "column";
4
+ referenceElement: HTMLElement;
5
+ };
6
+ export type TableHandleEventType = {
7
+ name: "handleClick";
8
+ detail: TableHandleEventDetail;
9
+ };
10
+ export declare class TableHandleEvent extends CustomEvent<TableHandleEventType["detail"]> {
11
+ constructor({ name, detail }: TableHandleEventType);
12
+ static dispatch<TEvent extends TableHandleEventType>(name: TEvent["name"], args: {
13
+ editor: Editor;
14
+ } & TEvent["detail"]): void;
15
+ static listen<TEvent extends TableHandleEventType>(name: TEvent["name"], args: {
16
+ editor: Editor;
17
+ callback: (detail: TEvent["detail"]) => void;
18
+ }): () => void;
19
+ }
@@ -0,0 +1 @@
1
+ export { TableHandlesPlugin } from "./TableHandlesPlugin";
@@ -0,0 +1,23 @@
1
+ import { type Editor } from "@tiptap/core";
2
+ import type { Node as ProseMirrorNode } from "@tiptap/pm/model";
3
+ import type { Selection } from "@tiptap/pm/state";
4
+ interface NodePos {
5
+ pos: number;
6
+ start: number;
7
+ node: ProseMirrorNode | null | undefined;
8
+ }
9
+ export declare function getCellsInColumn(columnIndex: number | number[]): (selection: Selection) => NodePos[] | null;
10
+ export declare function getCellsInRow(rowIndex: number | number[]): (selection: Selection) => NodePos[] | null;
11
+ /** Finds the table handle element for the given type and element. */
12
+ export declare function findTableHandleElement(args: {
13
+ type: "row" | "column";
14
+ element: Element;
15
+ }): Element;
16
+ /** Creates a table handle element for the given type. */
17
+ export declare function createTableHandleElement(args: {
18
+ type: "row" | "column";
19
+ editor: Editor;
20
+ rowIndex: number;
21
+ columnIndex: number;
22
+ }): HTMLButtonElement;
23
+ export {};
@@ -0,0 +1 @@
1
+ export { TableHandlesPlugin } from "./TableHandles";
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { type NodeViewProps } from "@tiptap/react";
3
+ export declare function TableControlsWrapper({ editor }: NodeViewProps): JSX.Element;
@@ -0,0 +1,8 @@
1
+ import type { Editor } from "@tiptap/core";
2
+ import { Plugin } from "@tiptap/pm/state";
3
+ import { DecorationSet } from "@tiptap/pm/view";
4
+ /** Plugin responsible for showing and hiding the row and column handles. */
5
+ export declare function tableHandlesPlugin(args: {
6
+ editor: Editor;
7
+ name: string;
8
+ }): Plugin<DecorationSet>;
@@ -0,0 +1,34 @@
1
+ import { type PluginView } from "@tiptap/pm/state";
2
+ import type { EditorView } from "@tiptap/pm/view";
3
+ /**
4
+ * This plugin centralizes the logic for showing and hiding the row and column
5
+ * handle buttons (the ones that on click open a floating menu).
6
+ *
7
+ * Ideally, hiding and showing the handles would be handled using only CSS,
8
+ * but identifying the topmost cell in a column is not trivial, as the grouping
9
+ * of cells in a column is not clearly defined in the DOM (only by colgroup),
10
+ * and CSS cannot dynamically select it depending on the hovered cell.
11
+ *
12
+ * Another option was to dynamically generate hardcoded selectors, given that
13
+ * we know the number of rows and cells, but inline styles can only contain
14
+ * property declarations, not pseudo-classes like :hover.
15
+ *
16
+ * That leaves us with handling it solely in JavaScript, which is what this
17
+ * plugin does.
18
+ */
19
+ export declare class TableHandlesPluginView implements PluginView {
20
+ private readonly view;
21
+ private abortController;
22
+ private currentRowHandle;
23
+ private currentColumnHandle;
24
+ constructor(view: EditorView);
25
+ update(view: EditorView): void;
26
+ destroy(): void;
27
+ private attachEventListeners;
28
+ private showCurrentHandles;
29
+ private hidePreviousHandles;
30
+ private getRowHandle;
31
+ private getColumnHandle;
32
+ private displayHandle;
33
+ private hideHandle;
34
+ }
@@ -0,0 +1,34 @@
1
+ import { type PluginView } from "@tiptap/pm/state";
2
+ import type { EditorView } from "@tiptap/pm/view";
3
+ /**
4
+ * This plugin centralizes the logic for showing and hiding the row and column
5
+ * handle buttons (the ones that on click open a floating menu).
6
+ *
7
+ * Ideally, hiding and showing the handles would be handled using only CSS,
8
+ * but identifying the topmost cell in a column is not trivial, as the grouping
9
+ * of cells in a column is not clearly defined in the DOM (only by colgroup),
10
+ * and CSS cannot dynamically select it depending on the hovered cell.
11
+ *
12
+ * Another option was to dynamically generate hardcoded selectors, given that
13
+ * we know the number of rows and cells, but inline styles can only contain
14
+ * property declarations, not pseudo-classes like :hover.
15
+ *
16
+ * That leaves us with handling it solely in JavaScript, which is what this
17
+ * plugin does.
18
+ */
19
+ export declare class TableHandlesPluginView implements PluginView {
20
+ private readonly view;
21
+ private abortController;
22
+ private currentRowHandle;
23
+ private currentColumnHandle;
24
+ constructor(view: EditorView);
25
+ update(view: EditorView): void;
26
+ destroy(): void;
27
+ private attachEventListeners;
28
+ private showCurrentHandles;
29
+ private hidePreviousHandles;
30
+ private getRowHandle;
31
+ private getColumnHandle;
32
+ private displayHandle;
33
+ private hideHandle;
34
+ }