@coorax/core 0.0.0-canary.1 → 0.0.0-canary.3

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 (46) hide show
  1. package/dist/base/types/field/field.blockquote.types.d.ts +4 -0
  2. package/dist/base/types/field/field.d.ts +14 -3
  3. package/dist/base/types/field/field.image.types.d.ts +3 -0
  4. package/dist/base/types/field/field.video.types.d.ts +8 -0
  5. package/dist/base/types/field/fields.iframe.types.d.ts +7 -0
  6. package/dist/base/types/global.types.d.ts +2 -0
  7. package/dist/base/types/tree/tree.d.ts +2 -1
  8. package/dist/constants/field.constants.d.ts +1 -0
  9. package/dist/constants/index.d.ts +1 -0
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.js +1511 -361
  12. package/dist/modules/caption/caption.module.d.ts +35 -0
  13. package/dist/modules/caption/caption.test.d.ts +1 -0
  14. package/dist/modules/code/code.module.d.ts +37 -0
  15. package/dist/modules/deletion/deletion.module.d.ts +26 -0
  16. package/dist/modules/divider/divider.module.d.ts +58 -0
  17. package/dist/modules/focus/focus.module.d.ts +1 -1
  18. package/dist/modules/history/history.module.d.ts +14 -0
  19. package/dist/modules/hover/hover.module.d.ts +1 -1
  20. package/dist/modules/index.d.ts +6 -1
  21. package/dist/modules/insertion/insertion.module.d.ts +20 -1
  22. package/dist/modules/media/media.module.d.ts +52 -0
  23. package/dist/modules/modules-manager.d.ts +2 -0
  24. package/dist/modules/paragraph-theme/paragraph-theme.module.d.ts +49 -0
  25. package/dist/modules/selection/selection.module.d.ts +1 -1
  26. package/dist/modules/text-editing/text-editing.constants.d.ts +1 -1
  27. package/dist/modules/text-editing/text-editing.module.d.ts +1 -2
  28. package/dist/modules/text-editing/text-editing.utils.d.ts +1 -1
  29. package/dist/services/document/document.d.ts +1 -2
  30. package/dist/services/eventbus/eventbus.d.ts +4 -4
  31. package/dist/services/eventbus/eventbus.test.d.ts +1 -1
  32. package/dist/services/eventbus/subscriber.d.ts +4 -4
  33. package/dist/services/mutations/mutations.d.ts +10 -5
  34. package/dist/services/tasks/tasks.service.d.ts +1 -1
  35. package/dist/services/text-marks/index.d.ts +0 -1
  36. package/dist/services/text-marks/text-marks.d.ts +1 -1
  37. package/dist/services/ui/contributions.types.d.ts +79 -0
  38. package/dist/services/ui/default-styles.d.ts +1 -1
  39. package/dist/services/ui/index.d.ts +0 -1
  40. package/dist/services/ui/ui.d.ts +7 -6
  41. package/dist/services/ui/ui.types.d.ts +7 -95
  42. package/dist/styles.css +1 -536
  43. package/dist/utils/fields.utils.d.ts +10 -2
  44. package/dist/utils/index.d.ts +0 -6
  45. package/package.json +12 -8
  46. package/styles.css +4 -2
@@ -1,6 +1,7 @@
1
- import type { NodeCommonProps } from "../../base/types/global.types";
1
+ import { type NodeCommonProps } from "@coorax/schema";
2
2
  import type { CommandsInterface, CommandType } from "../commandsbus/commandsbus";
3
- import type { UiInterface, StyleName, SlotName, Contribution, SlotKey, ContributionKind, StylesMap, ContributionDisposer, PayloadInterceptor, UIContext, ButtonContributionId } from "./ui.types";
3
+ import type { UiInterface, StyleName, StylesMap, ContributionDisposer, PayloadInterceptor, UIContext } from "./ui.types";
4
+ import type { ButtonId, Contribution, SlotName } from "./contributions.types";
4
5
  export declare class UiService implements UiInterface {
5
6
  private commands;
6
7
  private styles;
@@ -9,10 +10,10 @@ export declare class UiService implements UiInterface {
9
10
  private listeners;
10
11
  private interceptors;
11
12
  constructor(commands: CommandsInterface);
12
- interceptPayload<C extends CommandType>(contributionId: ButtonContributionId, fn: PayloadInterceptor<C>): () => Map<keyof ButtonContributionIdentityMap, PayloadInterceptor<any>[]>;
13
- runContribution<C extends CommandType>(c: Contribution<SlotName, SlotKey, C, "button">, ui: UIContext): Promise<void>;
14
- contribute<S extends SlotName = SlotName, Arg2 extends SlotKey | CommandType = SlotKey, Arg3 extends CommandType | ContributionKind = Arg2 extends SlotKey ? CommandType : ContributionKind, Arg4 extends ContributionKind = ContributionKind>(slotName: S, c: Contribution<S, Arg2, Arg3, Arg4>): ContributionDisposer;
15
- getSlots(slot: SlotName): readonly (import("./ui.types").ComponentContribution<keyof import("./ui.types").SlotMap, keyof SlotComponentMap> | import("./ui.types").ButtonContribution<keyof import("./ui.types").SlotMap, keyof import("../commandsbus").CommandMap, keyof SlotButtonPropsMap>)[];
13
+ interceptPayload<C extends CommandType>(contributionId: ButtonId, fn: PayloadInterceptor<C>): () => Map<string, PayloadInterceptor<any>[]>;
14
+ runContribution(c: Contribution<"button">, ui: UIContext): Promise<void>;
15
+ contribute(c: Contribution): ContributionDisposer;
16
+ getSlots(slot: SlotName): readonly Contribution[];
16
17
  subscribe(slot: SlotName, fn: () => void): ContributionDisposer;
17
18
  private notify;
18
19
  registerStyle(styleName: StyleName, style: NodeCommonProps): ContributionDisposer;
@@ -1,113 +1,25 @@
1
- import type { BlockId, Block } from "../../base";
2
- import type { NodeCommonProps } from "../../base/types/global.types";
1
+ import type { NodeCommonProps, StyleName, StylesMap } from "@coorax/schema";
3
2
  import type { CommandPayload, CommandType } from "../commandsbus";
4
3
  import type { StateMap } from "../state";
4
+ import type { ButtonIdMap, Contribution, SlotName } from "./contributions.types";
5
5
  export type MaybePromise<T> = T | Promise<T>;
6
6
  export type PayloadInterceptor<C extends CommandType> = (payload: CommandPayload<C>, ui: UIContext) => MaybePromise<CommandPayload<C> | null>;
7
- export interface SlotMap {
8
- toolbar: {};
9
- "block-actions": {};
10
- sidebar: {};
11
- inspector: {};
12
- overlay: {};
13
- }
14
- export type SlotName = keyof SlotMap;
15
- export interface IconMap {
16
- TextIcon: {};
17
- CursorIcon: {};
18
- HeadingIcon: {};
19
- CameraIcon: {};
20
- ImagePlus: {};
21
- TvMinimalPlayIcon: {};
22
- QuoteIcon: {};
23
- BracesIcon: {};
24
- MinusIcon: {};
25
- PlusIcon: {};
26
- BoldIcon: {};
27
- }
28
- export type SlotIcon = keyof IconMap;
29
- export interface SlotComponentMap {
30
- TextInspector: {
31
- blockId: BlockId;
32
- };
33
- }
34
- export type SlotComponentKey = keyof SlotComponentMap;
35
- export interface SlotButtonPropsMap {
36
- BlockActionButton: {
37
- variant: "default" | "outline" | "secondary";
38
- size: "icon" | "default" | "icon-lg";
39
- isBaseButton?: boolean;
40
- };
41
- }
42
- export type SlotButtonKey = keyof SlotButtonPropsMap;
43
- export type SlotKey = SlotButtonKey | SlotComponentKey;
44
- export interface ButtonContributionIdentityMap {
45
- }
46
- export type ButtonContributionId = keyof ButtonContributionIdentityMap;
47
- export interface ComponentContributionIdentityMap {
48
- }
49
- export type ComponentContributionId = keyof ComponentContributionIdentityMap;
50
- export type ContributionId = ComponentContributionId | ButtonContributionId;
51
- type BaseContribution<T extends SlotName = SlotName> = {
52
- id: ContributionId;
53
- slot: T;
54
- order?: number;
55
- when?: (ui: UIContext) => boolean;
56
- };
57
- export type ButtonContribution<S extends SlotName = SlotName, C extends CommandType = CommandType, K extends SlotButtonKey = SlotButtonKey> = {
58
- [Key in K]: BaseContribution<S> & {
59
- command: C;
60
- label?: string;
61
- name: Key;
62
- icon: SlotIcon;
63
- kind: "button";
64
- getPayload: (ui: UIContext) => CommandPayload<C>;
65
- getProps: (ui: UIContext) => SlotButtonPropsMap[Key] | null;
66
- };
67
- }[K];
68
- export type ComponentContribution<T extends SlotName = SlotName, K extends SlotComponentKey = SlotComponentKey> = {
69
- [Key in K]: BaseContribution<T> & {
70
- kind: "component";
71
- name: Key;
72
- getProps: (ui: UIContext) => SlotComponentMap[Key] | null;
73
- };
74
- }[K];
75
- export interface ContributionMap<S extends SlotName = SlotName, C extends CommandType = CommandType, B extends SlotKey = SlotKey> {
76
- button: ButtonContribution<S, C, Extract<B, SlotButtonKey>>;
77
- component: ComponentContribution<S, Extract<B, SlotComponentKey>>;
78
- }
79
- export type ContributionKind<S extends SlotName = SlotName, Arg2 = any, Arg3 = any> = [
80
- S,
81
- Arg2,
82
- Arg3
83
- ] extends [any, any, any] ? "button" | "component" : never;
84
7
  export interface UIContext {
85
8
  selection: StateMap["selection"];
86
9
  focus: StateMap["focus"];
87
10
  hover: StateMap["hover"];
88
11
  textSelection: StateMap["textSelection"];
89
12
  }
90
- export type Contribution<S extends SlotName = SlotName, Arg2 extends SlotKey | CommandType = SlotKey, Arg3 extends CommandType | ContributionKind = Arg2 extends SlotKey ? CommandType : ContributionKind, Arg4 extends ContributionKind = ContributionKind> = [Arg2] extends [SlotKey] ? ContributionMap<S, Arg3 extends CommandType ? Arg3 : CommandType, Arg2>[Arg4] : ContributionMap<S, Arg2 extends CommandType ? Arg2 : CommandType, SlotKey>[Arg3 extends ContributionKind ? Arg3 : ContributionKind];
91
- export type SlotBaseProps<S extends SlotName = SlotName, Arg2 extends SlotKey | CommandType = SlotKey, Arg3 extends CommandType | ContributionKind = Arg2 extends SlotKey ? CommandType : ContributionKind, Arg4 extends ContributionKind = ContributionKind> = {
92
- c: Contribution<S, Arg2, Arg3, Arg4>;
93
- ui: UIContext;
94
- };
95
13
  export type ContributionDisposer = () => void;
96
- type BlockStyles = {
97
- [K in Block["type"]]: NodeCommonProps;
98
- };
99
- export interface StylesMap extends BlockStyles {
100
- }
101
- export type StyleName = keyof StylesMap;
14
+ export type { StylesMap, StyleName };
102
15
  export interface UiInterface {
103
- contribute<S extends SlotName = SlotName, Arg2 extends SlotKey | CommandType = SlotKey, Arg3 extends CommandType | ContributionKind = Arg2 extends SlotKey ? CommandType : ContributionKind, Arg4 extends ContributionKind = ContributionKind>(slotName: S, contribution: Contribution<S, Arg2, Arg3, Arg4>): ContributionDisposer;
16
+ contribute(c: Contribution): ContributionDisposer;
104
17
  getSlots(name: SlotName): readonly Contribution[];
105
18
  subscribe(name: SlotName, fn: () => void): ContributionDisposer;
19
+ interceptPayload<I extends keyof ButtonIdMap>(id: I, fn: PayloadInterceptor<ButtonIdMap[I] & CommandType>): ContributionDisposer;
20
+ runContribution(c: Contribution<"button">, ui: UIContext): Promise<void>;
106
21
  getStyle: <T extends StyleName = StyleName>(styleName: T) => NodeCommonProps;
107
22
  registerStyle: (styleName: StyleName, style: NodeCommonProps) => ContributionDisposer;
108
23
  patchStyle: (styleName: StyleName, style: NodeCommonProps) => ContributionDisposer;
109
- interceptPayload<C extends CommandType>(contributionId: ButtonContributionId, fn: PayloadInterceptor<C>): ContributionDisposer;
110
- runContribution<C extends CommandType>(c: Contribution<SlotName, SlotKey, C, "button">, ui: UIContext): Promise<void>;
111
24
  }
112
- export declare function createContribution<S extends SlotName = SlotName, Arg2 extends SlotKey | CommandType = SlotKey, Arg3 extends CommandType | ContributionKind = Arg2 extends SlotKey ? CommandType : ContributionKind, Arg4 extends ContributionKind = ContributionKind>(contribution: Contribution<S, Arg2, Arg3, Arg4>): Contribution<S, Arg2, Arg3, Arg4>;
113
- export {};
25
+ export * from "./contributions.types";