slides.ts 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. import { IBarChartOptions, ILineChartOptions, IPieChartOptions } from 'chartist'
  2. export interface PPTElementShadow {
  3. h: number;
  4. v: number;
  5. blur: number;
  6. color: string;
  7. }
  8. export const enum ElementTypes {
  9. TEXT = 'text',
  10. IMAGE = 'image',
  11. SHAPE = 'shape',
  12. LINE = 'line',
  13. CHART = 'chart',
  14. TABLE = 'table',
  15. }
  16. export interface PPTElementOutline {
  17. style?: 'dashed' | 'solid';
  18. width?: number;
  19. color?: string;
  20. }
  21. export interface PPTTextElement {
  22. type: 'text';
  23. id: string;
  24. left: number;
  25. top: number;
  26. lock?: boolean;
  27. groupId?: string;
  28. width: number;
  29. height: number;
  30. content: string;
  31. rotate?: number;
  32. outline?: PPTElementOutline;
  33. fill?: string;
  34. lineHeight?: number;
  35. wordSpace?: number;
  36. opacity?: number;
  37. shadow?: PPTElementShadow;
  38. }
  39. export interface ImageOrShapeFlip {
  40. x?: number;
  41. y?: number;
  42. }
  43. export interface ImageElementFilters {
  44. 'blur'?: string;
  45. 'brightness'?: string;
  46. 'contrast'?: string;
  47. 'grayscale'?: string;
  48. 'saturate'?: string;
  49. 'hue-rotate'?: string;
  50. 'opacity'?: string;
  51. }
  52. export interface ImageElementClip {
  53. range: [[number, number], [number, number]];
  54. shape: string;
  55. }
  56. export interface PPTImageElement {
  57. type: 'image';
  58. id: string;
  59. left: number;
  60. top: number;
  61. lock?: boolean;
  62. groupId?: string;
  63. width: number;
  64. height: number;
  65. fixedRatio: boolean;
  66. src: string;
  67. rotate?: number;
  68. outline?: PPTElementOutline;
  69. filters?: ImageElementFilters;
  70. clip?: ImageElementClip;
  71. flip?: ImageOrShapeFlip;
  72. shadow?: PPTElementShadow;
  73. }
  74. export interface ShapeGradient {
  75. type: 'linear' | 'radial';
  76. color: [string, string];
  77. rotate: number;
  78. }
  79. export interface PPTShapeElement {
  80. type: 'shape';
  81. id: string;
  82. left: number;
  83. top: number;
  84. lock?: boolean;
  85. groupId?: string;
  86. width: number;
  87. height: number;
  88. viewBox: number;
  89. path: string;
  90. fixedRatio: boolean;
  91. fill: string;
  92. gradient?: ShapeGradient;
  93. rotate?: number;
  94. outline?: PPTElementOutline;
  95. opacity?: number;
  96. flip?: ImageOrShapeFlip;
  97. shadow?: PPTElementShadow;
  98. }
  99. export interface PPTLineElement {
  100. type: 'line';
  101. id: string;
  102. left: number;
  103. top: number;
  104. lock?: boolean;
  105. groupId?: string;
  106. start: [number, number];
  107. end: [number, number];
  108. width: number;
  109. style: string;
  110. color: string;
  111. points: [string, string];
  112. shadow?: PPTElementShadow;
  113. }
  114. export type ChartType = 'bar' | 'line' | 'pie'
  115. export interface ChartData {
  116. labels: string[];
  117. series: number[][];
  118. }
  119. export interface PPTChartElement {
  120. type: 'chart';
  121. id: string;
  122. left: number;
  123. top: number;
  124. lock?: boolean;
  125. groupId?: string;
  126. width: number;
  127. height: number;
  128. fill?: string;
  129. chartType: ChartType;
  130. data: ChartData;
  131. options?: ILineChartOptions & IBarChartOptions & IPieChartOptions;
  132. outline?: PPTElementOutline;
  133. themeColor: string;
  134. gridColor?: string;
  135. }
  136. export interface TableCellStyle {
  137. bold?: boolean;
  138. em?: boolean;
  139. underline?: boolean;
  140. strikethrough?: boolean;
  141. color?: string;
  142. backcolor?: string;
  143. fontsize?: string;
  144. fontname?: string;
  145. align?: string;
  146. }
  147. export interface TableCell {
  148. id: string;
  149. colspan: number;
  150. rowspan: number;
  151. text: string;
  152. style?: TableCellStyle;
  153. }
  154. export interface TableTheme {
  155. color: string;
  156. rowHeader: boolean;
  157. rowFooter: boolean;
  158. colHeader: boolean;
  159. colFooter: boolean;
  160. }
  161. export interface PPTTableElement {
  162. type: 'table';
  163. id: string;
  164. left: number;
  165. top: number;
  166. lock?: boolean;
  167. groupId?: string;
  168. width: number;
  169. height: number;
  170. outline: PPTElementOutline;
  171. theme?: TableTheme;
  172. colWidths: number[];
  173. data: TableCell[][];
  174. }
  175. export type PPTElement = PPTTextElement | PPTImageElement | PPTShapeElement | PPTLineElement | PPTChartElement | PPTTableElement
  176. export interface PPTAnimation {
  177. elId: string;
  178. type: string;
  179. duration: number;
  180. }
  181. export interface SlideBackground {
  182. type: 'solid' | 'image' | 'gradient';
  183. color?: string;
  184. image?: string;
  185. imageSize?: 'cover' | 'contain' | 'repeat' | 'initial';
  186. gradientType?: 'linear' | 'radial';
  187. gradientColor?: [string, string];
  188. gradientRotate?: number;
  189. }
  190. export interface Slide {
  191. id: string;
  192. elements: PPTElement[];
  193. background?: SlideBackground;
  194. animations?: PPTAnimation[];
  195. turningMode?: 'no' | 'fade' | 'slideX' | 'slideY';
  196. }
  197. export interface SlideTheme {
  198. backgroundColor: string;
  199. themeColor: string;
  200. fontColor: string;
  201. fontName: string;
  202. }