docs: 补充类型注释

This commit is contained in:
pipipi-pikachu 2021-08-21 14:34:04 +08:00
parent ddc25a1151
commit e7bdbffdf2

View File

@ -1,12 +1,5 @@
import { IBarChartOptions, ILineChartOptions, IPieChartOptions } from 'chartist'
export interface PPTElementShadow {
h: number;
v: number;
blur: number;
color: string;
}
export const enum ElementTypes {
TEXT = 'text',
IMAGE = 'image',
@ -16,12 +9,59 @@ export const enum ElementTypes {
TABLE = 'table',
}
/**
*
*
* h: 水平偏移量
*
* v: 垂直偏移量
*
* blur: 模糊程度
*
* color: 阴影颜色
*/
export interface PPTElementShadow {
h: number;
v: number;
blur: number;
color: string;
}
/**
*
*
* style?: 边框样式线线
*
* width?: 边框宽度
*
* color?: 边框颜色
*/
export interface PPTElementOutline {
style?: 'dashed' | 'solid';
width?: number;
color?: string;
}
/**
*
*
* id: 元素ID
*
* left: 元素水平方向位置
*
* top: 元素垂直方向位置
*
* lock?: 锁定元素
*
* groupId?: 组合IDID的元素即为同一组合元素成员
*
* width: 元素宽度
*
* height: 元素高度
*
* link?: 超链接地址
*/
interface PPTBaseElement {
id: string;
left: number;
@ -33,6 +73,32 @@ interface PPTBaseElement {
link?: string;
}
/**
*
*
* type: text
*
* content: 文本内容HTML字符串
*
* rotate: 旋转角度
*
* defaultFontName: 默认字体HTML内联样式覆盖
*
* defaultColor: 默认颜色HTML内联样式覆盖
*
* outline?: 边框
*
* fill?: 填充色
*
* lineHeight?: 行高1.5
*
* wordSpace?: 字间距0
*
* opacity?: 不透明度1
*
* shadow?: 阴影
*/
export interface PPTTextElement extends PPTBaseElement {
type: 'text';
content: string;
@ -47,10 +113,38 @@ export interface PPTTextElement extends PPTBaseElement {
shadow?: PPTElementShadow;
}
/**
*
*
* flipH?: 水平翻转
*
* flipV?: 垂直翻转
*/
export interface ImageOrShapeFlip {
flipH?: boolean;
flipV?: boolean;
}
/**
*
*
* https://developer.mozilla.org/zh-CN/docs/Web/CSS/filter
*
* 'blur'?: 0px
*
* 'brightness'?: 100%
*
* 'contrast'?: 100%
*
* 'grayscale'?: 0%
*
* 'saturate'?: 100%
*
* 'hue-rotate'?: 0deg
*
* 'opacity'?: 100%
*/
export interface ImageElementFilters {
'blur'?: string;
'brightness'?: string;
@ -60,10 +154,42 @@ export interface ImageElementFilters {
'hue-rotate'?: string;
'opacity'?: string;
}
/**
*
*
* range: 裁剪范围[[10, 10], [90, 90]] 10%, 10% 90%, 90%
*
* shape: 裁剪形状 configs/imageClip.ts CLIPPATHS
*/
export interface ImageElementClip {
range: [[number, number], [number, number]];
shape: string;
}
/**
*
*
* type: image
*
* fixedRatio: 固定图片宽高比例
*
* src: 图片地址
*
* rotate: 旋转角度
*
* outline?: 边框
*
* filters?: 图片滤镜
*
* clip?: 裁剪信息
*
* flipH?: 水平翻转
*
* flipV?: 垂直翻转
*
* shadow?: 阴影
*/
export interface PPTImageElement extends PPTBaseElement {
type: 'image';
fixedRatio: boolean;
@ -77,17 +203,71 @@ export interface PPTImageElement extends PPTBaseElement {
shadow?: PPTElementShadow;
}
/**
*
*
* type: 线
*
* color: 渐变颜色
*
* rotate: 渐变角度线
*/
export interface ShapeGradient {
type: 'linear' | 'radial';
color: [string, string];
rotate: number;
}
/**
*
*
* content: 文本内容HTML字符串
*
* defaultFontName: 默认字体HTML内联样式覆盖
*
* defaultColor: 默认颜色HTML内联样式覆盖
*
* align: 文本对齐方向
*/
export interface ShapeText {
content: string;
defaultFontName: string;
defaultColor: string;
align: 'top' | 'middle' | 'bottom';
}
/**
*
*
* type: shape
*
* viewBox: SVG的viewBox属性 1000 '0 0 1000 1000'
*
* path: 形状路径SVG path d
*
* fixedRatio: 固定形状宽高比例
*
* fill: 填充
*
* gradient?: 渐变
*
* rotate: 旋转角度
*
* outline?: 边框
*
* opacity?: 不透明度
*
* flipH?: 水平翻转
*
* flipV?: 垂直翻转
*
* shadow?: 阴影
*
* special?: 特殊形状使 L Q C A
*
* text?: 形状内文本
*/
export interface PPTShapeElement extends PPTBaseElement {
type: 'shape';
viewBox: number;
@ -105,6 +285,28 @@ export interface PPTShapeElement extends PPTBaseElement {
text?: ShapeText;
}
/**
* 线
*
* type: line
*
* start: 起点位置[x, y]
*
* end: 终点位置[x, y]
*
* style: 线条样式线线
*
* color: 线条颜色
*
* points: 端点样式[, ]
*
* shadow?: 阴影
*
* broken?: 折线中点位置[x, y]
*
* curve?: 曲线中点位置[x, y]
*/
export interface PPTLineElement extends Omit<PPTBaseElement, 'height'> {
type: 'line';
start: [number, number];
@ -117,11 +319,32 @@ export interface PPTLineElement extends Omit<PPTBaseElement, 'height'> {
curve?: [number, number];
}
export type ChartType = 'bar' | 'line' | 'pie'
export interface ChartData {
labels: string[];
series: number[][];
}
/**
*
*
* type: chart
*
* fill?: 填充色
*
* chartType: 图表类型
*
* data: 图表数据
*
* options?: 图表配置项
*
* outline?: 边框
*
* themeColor: 主题色
*
* gridColor?: 网格&
*/
export interface PPTChartElement extends PPTBaseElement {
type: 'chart';
fill?: string;
@ -133,6 +356,28 @@ export interface PPTChartElement extends PPTBaseElement {
gridColor?: string;
}
/**
*
*
* bold?: 加粗
*
* em?: 斜体
*
* underline?: 下划线
*
* strikethrough?: 删除线
*
* color?: 字体颜色
*
* backcolor?: 填充色
*
* fontsize?: 字体大小
*
* fontname?: 字体
*
* align?: 对齐方式
*/
export interface TableCellStyle {
bold?: boolean;
em?: boolean;
@ -144,6 +389,21 @@ export interface TableCellStyle {
fontname?: string;
align?: 'left' | 'center' | 'right';
}
/**
*
*
* id: 单元格ID
*
* colspan: 合并列数
*
* rowspan: 合并行数
*
* text: 文字内容
*
* style?: 单元格样式
*/
export interface TableCell {
id: string;
colspan: number;
@ -151,13 +411,41 @@ export interface TableCell {
text: string;
style?: TableCellStyle;
}
/**
*
*
* color: 主题色
*
* rowHeader: 标题行
*
* rowFooter: 汇总行
*
* colHeader: 第一列
*
* colFooter: 最后一列
*/
export interface TableTheme {
color: string;
rowHeader: boolean;
rowFooter: boolean;
colHeader: boolean;
colFooter: boolean;
}
}
/**
*
*
* type: table
*
* outline: 边框
*
* theme?: 主题
*
* colWidths: 列宽数组[30, 50, 20]30%, 50%, 20%
*
* data: 表格数据
*/
export interface PPTTableElement extends PPTBaseElement {
type: 'table';
outline: PPTElementOutline;
@ -166,14 +454,42 @@ export interface PPTTableElement extends PPTBaseElement {
data: TableCell[][];
}
export type PPTElement = PPTTextElement | PPTImageElement | PPTShapeElement | PPTLineElement | PPTChartElement | PPTTableElement
/**
*
*
* elId: 元素ID
*
* type:
*
* duration: 动画持续时间
*/
export interface PPTAnimation {
elId: string;
type: string;
duration: number;
}
/**
*
*
* type:
*
* color?: 背景颜色
*
* image?: 图片地址
*
* imageSize?: 图片填充方式
*
* gradientType?: 渐变类型线
*
* gradientColor?: 渐变颜色
*
* gradientRotate?: 渐变角度线
*/
export interface SlideBackground {
type: 'solid' | 'image' | 'gradient';
color?: string;
@ -184,6 +500,21 @@ export interface SlideBackground {
gradientRotate?: number;
}
/**
*
*
* id: 页面ID
*
* elements: 元素集合
*
* remark?: 备注
*
* background?: 页面背景
*
* animations?: 元素动画集合
*
* turningMode?: 翻页方式
*/
export interface Slide {
id: string;
elements: PPTElement[];
@ -193,6 +524,17 @@ export interface Slide {
turningMode?: 'no' | 'fade' | 'slideX' | 'slideY';
}
/**
*
*
* backgroundColor: 页面背景颜色
*
* themeColor: 主题色
*
* fontColor: 字体颜色
*
* fontName: 字体
*/
export interface SlideTheme {
backgroundColor: string;
themeColor: string;