@plait/core 0.5.0 → 0.8.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.
@@ -13,9 +13,11 @@ import { RectangleClient } from './rectangle-client';
13
13
  import { PathRef, PathRefOptions } from './path-ref';
14
14
  import { PlaitNode } from './node';
15
15
  import { Path } from './path';
16
+ import { PlaitTheme, ThemeColor } from './theme';
16
17
  export interface PlaitBoard {
17
18
  viewport: Viewport;
18
19
  children: PlaitElement[];
20
+ theme: PlaitTheme;
19
21
  operations: PlaitOperation[];
20
22
  selection: Selection | null;
21
23
  pointer: PlaitPointerType | string;
@@ -46,17 +48,20 @@ export interface PlaitBoard {
46
48
  isWithinSelection: (element: PlaitElement) => boolean;
47
49
  pathRef: (path: Path, options?: PathRefOptions) => PathRef;
48
50
  pathRefs: () => Set<PathRef>;
51
+ applyTheme: (element: PlaitElement) => void;
49
52
  }
50
53
  export interface PlaitBoardChangeEvent {
51
54
  children: PlaitElement[];
52
55
  operations: PlaitOperation[];
53
56
  viewport: Viewport;
54
57
  selection: Selection | null;
58
+ theme: PlaitTheme;
55
59
  }
56
60
  export interface PlaitBoardOptions {
57
- readonly: boolean;
58
- hideScrollbar: boolean;
59
- disabledScrollOnNonFocus: boolean;
61
+ readonly?: boolean;
62
+ hideScrollbar?: boolean;
63
+ disabledScrollOnNonFocus?: boolean;
64
+ themeColors?: ThemeColor[];
60
65
  }
61
66
  export interface PlaitBoardMove {
62
67
  x: number;
@@ -73,9 +78,10 @@ export declare const PlaitBoard: {
73
78
  getRectangle(board: PlaitBoard): RectangleClient;
74
79
  getViewportContainer(board: PlaitBoard): HTMLElement;
75
80
  isFocus(board: PlaitBoard): boolean;
76
- isReadonly(board: PlaitBoard): boolean;
81
+ isReadonly(board: PlaitBoard): boolean | undefined;
77
82
  hasBeenTextEditing(board: PlaitBoard): boolean;
78
83
  getPointer<T = PlaitPointerType>(board: PlaitBoard): T;
79
84
  isPointer<T_1 = PlaitPointerType>(board: PlaitBoard, pointer: T_1): boolean;
80
85
  getMovingPoint(board: PlaitBoard): Point | undefined;
86
+ getThemeColors<T_2 extends ThemeColor = ThemeColor>(board: PlaitBoard): T_2[];
81
87
  };
@@ -13,3 +13,4 @@ export * from './selection';
13
13
  export * from './viewport';
14
14
  export * from './history';
15
15
  export * from './plugin-key';
16
+ export * from './theme';
@@ -1,6 +1,7 @@
1
1
  import { PlaitNode } from '../interfaces/node';
2
2
  import { Path } from './path';
3
3
  import { Selection } from './selection';
4
+ import { PlaitTheme } from './theme';
4
5
  import { Viewport } from './viewport';
5
6
  export type InsertNodeOperation = {
6
7
  type: 'insert_node';
@@ -17,6 +18,11 @@ export type MoveNodeOperation = {
17
18
  path: Path;
18
19
  newPath: Path;
19
20
  };
21
+ export type SetThemeOperation = {
22
+ type: 'set_theme';
23
+ properties: Partial<PlaitTheme>;
24
+ newProperties: Partial<PlaitTheme>;
25
+ };
20
26
  export type SetViewportOperation = {
21
27
  type: 'set_viewport';
22
28
  properties: Partial<Viewport>;
@@ -33,7 +39,7 @@ export type SetNodeOperation = {
33
39
  properties: Partial<PlaitNode>;
34
40
  newProperties: Partial<PlaitNode>;
35
41
  };
36
- export type PlaitOperation = InsertNodeOperation | SetViewportOperation | SetSelectionOperation | SetNodeOperation | RemoveNodeOperation | MoveNodeOperation;
42
+ export type PlaitOperation = InsertNodeOperation | SetViewportOperation | SetSelectionOperation | SetNodeOperation | RemoveNodeOperation | MoveNodeOperation | SetThemeOperation;
37
43
  export interface PlaitOperationInterface {
38
44
  inverse: (op: PlaitOperation) => PlaitOperation;
39
45
  isSetViewportOperation: (value: any) => boolean;
@@ -0,0 +1,23 @@
1
+ export interface PlaitTheme {
2
+ themeColorMode: ThemeColorMode;
3
+ }
4
+ export interface ThemeColor {
5
+ mode: ThemeColorMode | string;
6
+ boardBackground?: string;
7
+ textColor: string;
8
+ }
9
+ export declare enum ThemeColorMode {
10
+ 'default' = "default",
11
+ 'colorful' = "colorful",
12
+ 'soft' = "soft",
13
+ 'retro' = "retro",
14
+ 'dark' = "dark",
15
+ 'starry' = "starry"
16
+ }
17
+ export declare const DefaultThemeColor: ThemeColor;
18
+ export declare const ColorfulThemeColor: ThemeColor;
19
+ export declare const SoftThemeColor: ThemeColor;
20
+ export declare const RetroThemeColor: ThemeColor;
21
+ export declare const DarkThemeColor: ThemeColor;
22
+ export declare const StarryThemeColor: ThemeColor;
23
+ export declare const ThemeColors: ThemeColor[];
@@ -2,7 +2,6 @@ import { ExtendedType } from './custom-types';
2
2
  import { Point } from './point';
3
3
  export interface BaseViewport {
4
4
  [key: string]: any;
5
- viewBackgroundColor: string;
6
5
  zoom: number;
7
6
  origination?: Point;
8
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plait/core",
3
- "version": "0.5.0",
3
+ "version": "0.8.0",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^15.2.2",
6
6
  "@angular/core": "^15.2.2"
@@ -0,0 +1,18 @@
1
+ @mixin board-background-color {
2
+ &.theme-colorful .board-host-svg,
3
+ &.theme-default .board-host-svg {
4
+ background-color: #ffffff;
5
+ }
6
+ &.theme-soft .board-host-svg {
7
+ background-color: #f5f5f5;
8
+ }
9
+ &.theme-retro .board-host-svg {
10
+ background-color: #f9f8ed;
11
+ }
12
+ &.theme-dark .board-host-svg {
13
+ background-color: #141414;
14
+ }
15
+ &.theme-starry .board-host-svg {
16
+ background-color: #0d2537;
17
+ }
18
+ }
@@ -1,3 +1,5 @@
1
+ @use './mixins.scss' as mixins;
2
+
1
3
  .plait-board-container {
2
4
  display: block;
3
5
  width: 100%;
@@ -49,4 +51,6 @@
49
51
  opacity: 0;
50
52
  }
51
53
  }
54
+
55
+ @include mixins.board-background-color();
52
56
  }
@@ -1,13 +1,20 @@
1
+ import { ThemeColorMode } from '../interfaces/theme';
1
2
  import { PlaitBoard } from '../interfaces/board';
2
3
  import { Point } from '../interfaces/point';
3
4
  import { PlaitPointerType } from '../interfaces/pointer';
4
5
  declare function updateViewport(board: PlaitBoard, origination: Point, zoom?: number): void;
5
6
  declare function updateZoom(board: PlaitBoard, newZoom: number, isCenter?: boolean): void;
6
7
  declare function fitViewport(board: PlaitBoard): void;
8
+ /**
9
+ * apply theme to every element (remove element custom properties)
10
+ * invoke applyThemeColor
11
+ */
12
+ declare function updateThemeColor(board: PlaitBoard, mode: ThemeColorMode): void;
7
13
  export declare const BoardTransforms: {
8
14
  updatePointerType: <T extends string = PlaitPointerType>(board: PlaitBoard, pointer: T) => void;
9
15
  updateViewport: typeof updateViewport;
10
16
  fitViewport: typeof fitViewport;
11
17
  updateZoom: typeof updateZoom;
18
+ updateThemeColor: typeof updateThemeColor;
12
19
  };
13
20
  export {};
@@ -0,0 +1,7 @@
1
+ import { PlaitBoard } from '../interfaces/board';
2
+ import { PlaitTheme } from '../interfaces';
3
+ export declare function setTheme(board: PlaitBoard, themeColorMode: PlaitTheme): void;
4
+ export interface ThemeTransforms {
5
+ setTheme: (board: PlaitBoard, themeColorMode: PlaitTheme) => void;
6
+ }
7
+ export declare const ViewportTransforms: ThemeTransforms;