mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-15 05:37:32 +00:00
chore: merge blocksuite source code (#9213)
This commit is contained in:
3
blocksuite/affine/model/src/consts/brush.ts
Normal file
3
blocksuite/affine/model/src/consts/brush.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { LineColor } from './line.js';
|
||||
|
||||
export const DEFAULT_BRUSH_COLOR = LineColor.Blue;
|
||||
39
blocksuite/affine/model/src/consts/connector.ts
Normal file
39
blocksuite/affine/model/src/consts/connector.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { createEnumMap } from '../utils/enum.js';
|
||||
import { LineColor } from './line.js';
|
||||
|
||||
export enum ConnectorEndpoint {
|
||||
Front = 'Front',
|
||||
Rear = 'Rear',
|
||||
}
|
||||
|
||||
export enum PointStyle {
|
||||
Arrow = 'Arrow',
|
||||
Circle = 'Circle',
|
||||
Diamond = 'Diamond',
|
||||
None = 'None',
|
||||
Triangle = 'Triangle',
|
||||
}
|
||||
|
||||
export const PointStyleMap = createEnumMap(PointStyle);
|
||||
|
||||
export const DEFAULT_CONNECTOR_COLOR = LineColor.Grey;
|
||||
|
||||
export const DEFAULT_CONNECTOR_TEXT_COLOR = LineColor.Black;
|
||||
|
||||
export const DEFAULT_FRONT_END_POINT_STYLE = PointStyle.None;
|
||||
|
||||
export const DEFAULT_REAR_END_POINT_STYLE = PointStyle.Arrow;
|
||||
|
||||
export const CONNECTOR_LABEL_MAX_WIDTH = 280;
|
||||
|
||||
export enum ConnectorLabelOffsetAnchor {
|
||||
Bottom = 'bottom',
|
||||
Center = 'center',
|
||||
Top = 'top',
|
||||
}
|
||||
|
||||
export enum ConnectorMode {
|
||||
Straight,
|
||||
Orthogonal,
|
||||
Curve,
|
||||
}
|
||||
44
blocksuite/affine/model/src/consts/doc.ts
Normal file
44
blocksuite/affine/model/src/consts/doc.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export type DocMode = 'edgeless' | 'page';
|
||||
|
||||
export const DocModes = ['edgeless', 'page'] as const;
|
||||
|
||||
/**
|
||||
* Custom title and description information.
|
||||
*
|
||||
* Supports the following blocks:
|
||||
*
|
||||
* 1. Inline View: `AffineReference` - title
|
||||
* 2. Card View: `EmbedLinkedDocBlock` - title & description
|
||||
* 3. Embed View: `EmbedSyncedDocBlock` - title
|
||||
*/
|
||||
export const AliasInfoSchema = z
|
||||
.object({
|
||||
title: z.string(),
|
||||
description: z.string(),
|
||||
})
|
||||
.partial();
|
||||
|
||||
export type AliasInfo = z.infer<typeof AliasInfoSchema>;
|
||||
|
||||
export const ReferenceParamsSchema = z
|
||||
.object({
|
||||
mode: z.enum(DocModes),
|
||||
blockIds: z.string().array(),
|
||||
elementIds: z.string().array(),
|
||||
databaseId: z.string().optional(),
|
||||
databaseRowId: z.string().optional(),
|
||||
})
|
||||
.partial();
|
||||
|
||||
export type ReferenceParams = z.infer<typeof ReferenceParamsSchema>;
|
||||
|
||||
export const ReferenceInfoSchema = z
|
||||
.object({
|
||||
pageId: z.string(),
|
||||
params: ReferenceParamsSchema.optional(),
|
||||
})
|
||||
.merge(AliasInfoSchema);
|
||||
|
||||
export type ReferenceInfo = z.infer<typeof ReferenceInfoSchema>;
|
||||
27
blocksuite/affine/model/src/consts/frame.ts
Normal file
27
blocksuite/affine/model/src/consts/frame.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export enum FrameBackgroundColor {
|
||||
Blue = '--affine-tag-blue',
|
||||
Gray = '--affine-tag-gray',
|
||||
Green = '--affine-tag-green',
|
||||
Orange = '--affine-tag-orange',
|
||||
Pink = '--affine-tag-pink',
|
||||
Purple = '--affine-tag-purple',
|
||||
Red = '--affine-tag-red',
|
||||
Teal = '--affine-tag-teal',
|
||||
Yellow = '--affine-tag-yellow',
|
||||
}
|
||||
|
||||
export const FRAME_BACKGROUND_COLORS = [
|
||||
FrameBackgroundColor.Gray,
|
||||
FrameBackgroundColor.Red,
|
||||
FrameBackgroundColor.Orange,
|
||||
FrameBackgroundColor.Yellow,
|
||||
FrameBackgroundColor.Green,
|
||||
FrameBackgroundColor.Teal,
|
||||
FrameBackgroundColor.Blue,
|
||||
FrameBackgroundColor.Purple,
|
||||
FrameBackgroundColor.Pink,
|
||||
];
|
||||
|
||||
export const FrameBackgroundColorsSchema = z.nativeEnum(FrameBackgroundColor);
|
||||
9
blocksuite/affine/model/src/consts/index.ts
Normal file
9
blocksuite/affine/model/src/consts/index.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export * from './brush.js';
|
||||
export * from './connector.js';
|
||||
export * from './doc.js';
|
||||
export * from './frame.js';
|
||||
export * from './line.js';
|
||||
export * from './mindmap.js';
|
||||
export * from './note.js';
|
||||
export * from './shape.js';
|
||||
export * from './text.js';
|
||||
46
blocksuite/affine/model/src/consts/line.ts
Normal file
46
blocksuite/affine/model/src/consts/line.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { createEnumMap } from '../utils/enum.js';
|
||||
|
||||
export enum LineWidth {
|
||||
Eight = 8,
|
||||
// Thin
|
||||
Four = 4,
|
||||
Six = 6,
|
||||
// Thick
|
||||
Ten = 10,
|
||||
Twelve = 12,
|
||||
Two = 2,
|
||||
}
|
||||
|
||||
export enum LineColor {
|
||||
Black = '--affine-palette-line-black',
|
||||
Blue = '--affine-palette-line-blue',
|
||||
Green = '--affine-palette-line-green',
|
||||
Grey = '--affine-palette-line-grey',
|
||||
Magenta = '--affine-palette-line-magenta',
|
||||
Orange = '--affine-palette-line-orange',
|
||||
Purple = '--affine-palette-line-purple',
|
||||
Red = '--affine-palette-line-red',
|
||||
Teal = '--affine-palette-line-teal',
|
||||
White = '--affine-palette-line-white',
|
||||
Yellow = '--affine-palette-line-yellow',
|
||||
}
|
||||
|
||||
export const LineColorMap = createEnumMap(LineColor);
|
||||
|
||||
export const LINE_COLORS = [
|
||||
LineColor.Yellow,
|
||||
LineColor.Orange,
|
||||
LineColor.Red,
|
||||
LineColor.Magenta,
|
||||
LineColor.Purple,
|
||||
LineColor.Blue,
|
||||
LineColor.Teal,
|
||||
LineColor.Green,
|
||||
LineColor.Black,
|
||||
LineColor.Grey,
|
||||
LineColor.White,
|
||||
] as const;
|
||||
|
||||
export const LineColorsSchema = z.nativeEnum(LineColor);
|
||||
12
blocksuite/affine/model/src/consts/mindmap.ts
Normal file
12
blocksuite/affine/model/src/consts/mindmap.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
export enum LayoutType {
|
||||
BALANCE = 2,
|
||||
LEFT = 1,
|
||||
RIGHT = 0,
|
||||
}
|
||||
|
||||
export enum MindmapStyle {
|
||||
FOUR = 4,
|
||||
ONE = 1,
|
||||
THREE = 3,
|
||||
TWO = 2,
|
||||
}
|
||||
107
blocksuite/affine/model/src/consts/note.ts
Normal file
107
blocksuite/affine/model/src/consts/note.ts
Normal file
@@ -0,0 +1,107 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { createEnumMap } from '../utils/enum.js';
|
||||
|
||||
export const NOTE_MIN_WIDTH = 450 + 24 * 2;
|
||||
export const NOTE_MIN_HEIGHT = 92;
|
||||
|
||||
export const DEFAULT_NOTE_WIDTH = NOTE_MIN_WIDTH;
|
||||
export const DEFAULT_NOTE_HEIGHT = NOTE_MIN_HEIGHT;
|
||||
|
||||
export enum NoteBackgroundColor {
|
||||
Black = '--affine-note-background-black',
|
||||
Blue = '--affine-note-background-blue',
|
||||
Green = '--affine-note-background-green',
|
||||
Grey = '--affine-note-background-grey',
|
||||
Magenta = '--affine-note-background-magenta',
|
||||
Orange = '--affine-note-background-orange',
|
||||
Purple = '--affine-note-background-purple',
|
||||
Red = '--affine-note-background-red',
|
||||
Teal = '--affine-note-background-teal',
|
||||
White = '--affine-note-background-white',
|
||||
Yellow = '--affine-note-background-yellow',
|
||||
}
|
||||
|
||||
export const NoteBackgroundColorMap = createEnumMap(NoteBackgroundColor);
|
||||
|
||||
export const NOTE_BACKGROUND_COLORS = [
|
||||
NoteBackgroundColor.Yellow,
|
||||
NoteBackgroundColor.Orange,
|
||||
NoteBackgroundColor.Red,
|
||||
NoteBackgroundColor.Magenta,
|
||||
NoteBackgroundColor.Purple,
|
||||
NoteBackgroundColor.Blue,
|
||||
NoteBackgroundColor.Teal,
|
||||
NoteBackgroundColor.Green,
|
||||
NoteBackgroundColor.Black,
|
||||
NoteBackgroundColor.Grey,
|
||||
NoteBackgroundColor.White,
|
||||
] as const;
|
||||
|
||||
export const DEFAULT_NOTE_BACKGROUND_COLOR = NoteBackgroundColor.White;
|
||||
|
||||
export const NoteBackgroundColorsSchema = z.nativeEnum(NoteBackgroundColor);
|
||||
|
||||
export enum NoteShadow {
|
||||
Box = '--affine-note-shadow-box',
|
||||
Film = '--affine-note-shadow-film',
|
||||
Float = '--affine-note-shadow-float',
|
||||
None = '',
|
||||
Paper = '--affine-note-shadow-paper',
|
||||
Sticker = '--affine-note-shadow-sticker',
|
||||
}
|
||||
|
||||
export const NoteShadowMap = createEnumMap(NoteShadow);
|
||||
|
||||
export const NOTE_SHADOWS = [
|
||||
NoteShadow.None,
|
||||
NoteShadow.Box,
|
||||
NoteShadow.Sticker,
|
||||
NoteShadow.Paper,
|
||||
NoteShadow.Float,
|
||||
NoteShadow.Film,
|
||||
] as const;
|
||||
|
||||
export const DEFAULT_NOTE_SHADOW = NoteShadow.Box;
|
||||
|
||||
export const NoteShadowsSchema = z.nativeEnum(NoteShadow);
|
||||
|
||||
export enum NoteDisplayMode {
|
||||
DocAndEdgeless = 'both',
|
||||
DocOnly = 'doc',
|
||||
EdgelessOnly = 'edgeless',
|
||||
}
|
||||
|
||||
export enum StrokeStyle {
|
||||
Dash = 'dash',
|
||||
None = 'none',
|
||||
Solid = 'solid',
|
||||
}
|
||||
|
||||
export const DEFAULT_NOTE_BORDER_STYLE = StrokeStyle.None;
|
||||
|
||||
export const StrokeStyleMap = createEnumMap(StrokeStyle);
|
||||
|
||||
export enum NoteCorners {
|
||||
Huge = 32,
|
||||
Large = 24,
|
||||
Medium = 16,
|
||||
None = 0,
|
||||
Small = 8,
|
||||
}
|
||||
|
||||
export const NoteCornersMap = createEnumMap(NoteCorners);
|
||||
|
||||
export const NOTE_CORNERS = [
|
||||
NoteCorners.None,
|
||||
NoteCorners.Small,
|
||||
NoteCorners.Medium,
|
||||
NoteCorners.Large,
|
||||
NoteCorners.Huge,
|
||||
] as const;
|
||||
|
||||
export const DEFAULT_NOTE_CORNER = NoteCorners.Small;
|
||||
|
||||
export const NoteCornersSchema = z.nativeEnum(NoteCorners);
|
||||
|
||||
export const DEFAULT_NOTE_BORDER_SIZE = 4;
|
||||
90
blocksuite/affine/model/src/consts/shape.ts
Normal file
90
blocksuite/affine/model/src/consts/shape.ts
Normal file
@@ -0,0 +1,90 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { LINE_COLORS, LineColor } from './line.js';
|
||||
|
||||
export const DEFAULT_ROUGHNESS = 1.4;
|
||||
|
||||
// TODO: need to check the default central area ratio
|
||||
export const DEFAULT_CENTRAL_AREA_RATIO = 0.3;
|
||||
|
||||
export enum ShapeTextFontSize {
|
||||
LARGE = 28,
|
||||
MEDIUM = 20,
|
||||
SMALL = 12,
|
||||
XLARGE = 36,
|
||||
}
|
||||
|
||||
export enum ShapeType {
|
||||
Diamond = 'diamond',
|
||||
Ellipse = 'ellipse',
|
||||
Rect = 'rect',
|
||||
Triangle = 'triangle',
|
||||
}
|
||||
|
||||
export type ShapeName = ShapeType | 'roundedRect';
|
||||
|
||||
export function getShapeName(type: ShapeType, radius: number): ShapeName {
|
||||
if (type === ShapeType.Rect && radius > 0) {
|
||||
return 'roundedRect';
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
export function getShapeType(name: ShapeName): ShapeType {
|
||||
if (name === 'roundedRect') {
|
||||
return ShapeType.Rect;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
export function getShapeRadius(name: ShapeName): number {
|
||||
if (name === 'roundedRect') {
|
||||
return 0.1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
export enum ShapeStyle {
|
||||
General = 'General',
|
||||
Scribbled = 'Scribbled',
|
||||
}
|
||||
|
||||
export enum ShapeFillColor {
|
||||
Black = '--affine-palette-shape-black',
|
||||
Blue = '--affine-palette-shape-blue',
|
||||
Green = '--affine-palette-shape-green',
|
||||
Grey = '--affine-palette-shape-grey',
|
||||
Magenta = '--affine-palette-shape-magenta',
|
||||
Orange = '--affine-palette-shape-orange',
|
||||
Purple = '--affine-palette-shape-purple',
|
||||
Red = '--affine-palette-shape-red',
|
||||
Teal = '--affine-palette-shape-teal',
|
||||
White = '--affine-palette-shape-white',
|
||||
Yellow = '--affine-palette-shape-yellow',
|
||||
}
|
||||
|
||||
export const SHAPE_FILL_COLORS = [
|
||||
ShapeFillColor.Yellow,
|
||||
ShapeFillColor.Orange,
|
||||
ShapeFillColor.Red,
|
||||
ShapeFillColor.Magenta,
|
||||
ShapeFillColor.Purple,
|
||||
ShapeFillColor.Blue,
|
||||
ShapeFillColor.Teal,
|
||||
ShapeFillColor.Green,
|
||||
ShapeFillColor.Black,
|
||||
ShapeFillColor.Grey,
|
||||
ShapeFillColor.White,
|
||||
] as const;
|
||||
|
||||
export const DEFAULT_SHAPE_FILL_COLOR = ShapeFillColor.Yellow;
|
||||
|
||||
export const FillColorsSchema = z.nativeEnum(ShapeFillColor);
|
||||
|
||||
export const SHAPE_STROKE_COLORS = LINE_COLORS;
|
||||
|
||||
export const DEFAULT_SHAPE_STROKE_COLOR = LineColor.Yellow;
|
||||
|
||||
export const DEFAULT_SHAPE_TEXT_COLOR = LineColor.Black;
|
||||
|
||||
export const StrokeColorsSchema = z.nativeEnum(LineColor);
|
||||
70
blocksuite/affine/model/src/consts/text.ts
Normal file
70
blocksuite/affine/model/src/consts/text.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
import { createEnumMap } from '../utils/enum.js';
|
||||
import { LineColor } from './line.js';
|
||||
|
||||
export enum ColorScheme {
|
||||
Dark = 'dark',
|
||||
Light = 'light',
|
||||
}
|
||||
|
||||
export type Color = string | Partial<Record<ColorScheme | 'normal', string>>;
|
||||
|
||||
export enum TextAlign {
|
||||
Center = 'center',
|
||||
Left = 'left',
|
||||
Right = 'right',
|
||||
}
|
||||
|
||||
export const TextAlignMap = createEnumMap(TextAlign);
|
||||
|
||||
export enum TextVerticalAlign {
|
||||
Bottom = 'bottom',
|
||||
Center = 'center',
|
||||
Top = 'top',
|
||||
}
|
||||
|
||||
export type TextStyleProps = {
|
||||
color: Color;
|
||||
fontFamily: FontFamily;
|
||||
fontSize: number;
|
||||
fontStyle: FontStyle;
|
||||
fontWeight: FontWeight;
|
||||
textAlign: TextAlign;
|
||||
};
|
||||
|
||||
export enum FontWeight {
|
||||
Bold = '700',
|
||||
Light = '300',
|
||||
Medium = '500',
|
||||
Regular = '400',
|
||||
SemiBold = '600',
|
||||
}
|
||||
|
||||
export const FontWeightMap = createEnumMap(FontWeight);
|
||||
|
||||
export enum FontStyle {
|
||||
Italic = 'italic',
|
||||
Normal = 'normal',
|
||||
}
|
||||
|
||||
export enum FontFamily {
|
||||
BebasNeue = 'blocksuite:surface:BebasNeue',
|
||||
Inter = 'blocksuite:surface:Inter',
|
||||
Kalam = 'blocksuite:surface:Kalam',
|
||||
Lora = 'blocksuite:surface:Lora',
|
||||
OrelegaOne = 'blocksuite:surface:OrelegaOne',
|
||||
Poppins = 'blocksuite:surface:Poppins',
|
||||
Satoshi = 'blocksuite:surface:Satoshi',
|
||||
}
|
||||
|
||||
export const FontFamilyMap = createEnumMap(FontFamily);
|
||||
|
||||
export const FontFamilyList = Object.entries(FontFamilyMap) as {
|
||||
[K in FontFamily]: [K, (typeof FontFamilyMap)[K]];
|
||||
}[FontFamily][];
|
||||
|
||||
export enum TextResizing {
|
||||
AUTO_WIDTH_AND_HEIGHT,
|
||||
AUTO_HEIGHT,
|
||||
}
|
||||
|
||||
export const DEFAULT_TEXT_COLOR = LineColor.Blue;
|
||||
Reference in New Issue
Block a user