custom.d.ts 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. declare module '*.svg' {
  2. const content: string;
  3. export default content;
  4. }
  5. declare module 'pdfjs-dist/es5/build/pdf.js';
  6. declare module 'query-string';
  7. declare module 'react-color';
  8. declare module 'react-color/lib/components/common';
  9. declare module 'react-toast-notifications';
  10. interface RefObject<T> {
  11. readonly current: T | null;
  12. }
  13. type SelectOptionType = {
  14. key: string | number;
  15. content: React.ReactNode;
  16. child: React.ReactNode;
  17. };
  18. type RenderingStateType = 'RENDERING' | 'LOADING' | 'FINISHED' | 'PAUSED';
  19. type LineType = 'Highlight' | 'Underline' | 'Squiggly' | 'StrikeOut';
  20. type FormType = 'textfield' | 'checkbox' | 'radio';
  21. type ToolType = 'highlight' | 'freehand' | 'text' | 'sticky' | 'shape';
  22. type SidebarType = 'markup-tools' | 'create-form' | 'watermark' | 'image';
  23. type ViewportType = {
  24. width: number;
  25. height: number;
  26. };
  27. type ProgressType = {
  28. loaded: number;
  29. total: number;
  30. };
  31. type ScrollStateType = {
  32. right: boolean;
  33. down: boolean;
  34. lastX: number;
  35. lastY: number;
  36. subscriber: Subscription;
  37. };
  38. type PositionType = {
  39. top: number;
  40. bottom: number;
  41. left: number;
  42. right: number;
  43. };
  44. type HTMLCoordinateType = {
  45. top: number;
  46. left: number;
  47. width: number;
  48. height: number;
  49. };
  50. type PointType = {
  51. x: number;
  52. y: number;
  53. };
  54. type LinePositionType = {
  55. start: PointType;
  56. end: PointType;
  57. };
  58. type AnnotationPositionType =
  59. | PositionType
  60. | LinePositionType
  61. | PointType
  62. | (PositionType | PointType[])[];
  63. type AnnotationAttributeType = {
  64. title?: string;
  65. date?: string;
  66. page: number;
  67. bdcolor?: string | undefined;
  68. position?: AnnotationPositionType;
  69. transparency?: number | undefined;
  70. content?: string | undefined;
  71. style?: string | undefined;
  72. fcolor?: string | undefined;
  73. ftransparency?: number | undefined;
  74. bdwidth?: number | undefined;
  75. fontname?: string | undefined;
  76. fontsize?: number | undefined;
  77. textcolor?: string | undefined;
  78. is_arrow?: boolean | undefined;
  79. src?: string | undefined;
  80. };
  81. type AnnotationType = {
  82. id?: string;
  83. obj_type: string;
  84. obj_attr: AnnotationAttributeType;
  85. };
  86. type UpdateData = {
  87. bdcolor?: string;
  88. transparency?: number;
  89. position?: AnnotationPositionType;
  90. content?: string;
  91. fontsize?: number;
  92. };
  93. type OnUpdateType = (data: UpdateData) => void;
  94. type AnnotationElementPropsType = AnnotationType & {
  95. isCovered: boolean;
  96. isCollapse: boolean;
  97. mousePosition: Record<string, unknown>;
  98. onUpdate: OnUpdateType;
  99. onDelete: () => void;
  100. scale: number;
  101. viewport: ViewportType;
  102. onEdit: () => void;
  103. isEdit: boolean;
  104. onBlur: () => void;
  105. onMouseOver?: () => void;
  106. onMouseOut?: () => void;
  107. };
  108. type OptionPropsType = {
  109. type?: string;
  110. color?: string;
  111. opacity?: number;
  112. fontName?: string;
  113. fontSize?: number;
  114. width?: number;
  115. align?: string;
  116. fontStyle?: string;
  117. shape?: string;
  118. text?: string;
  119. setDataState?: (arg: Record<string, unknown>) => void;
  120. };
  121. type CoordType = {
  122. left: number;
  123. top: number;
  124. width?: number;
  125. height?: number;
  126. };
  127. type CircleType = {
  128. direction: string;
  129. cx: number;
  130. cy: number;
  131. r: number;
  132. };
  133. type WatermarkType = {
  134. type?: 'image' | 'text';
  135. scale?: number;
  136. opacity?: number;
  137. rotation?: number;
  138. pages?: string;
  139. vertalign?: 'top' | 'center' | 'bottom';
  140. horizalign?: 'left' | 'center' | 'right';
  141. xoffset?: number;
  142. yoffset?: number;
  143. imagepath?: string;
  144. text?: string;
  145. textcolor?: string;
  146. isfront?: 'yes' | 'no';
  147. };
  148. type MatchType = {
  149. page: number;
  150. index: number;
  151. };
  152. type ColorType = {
  153. h?: string;
  154. s?: string;
  155. l?: string;
  156. v?: string;
  157. a?: string;
  158. hex?: string;
  159. };
  160. type PdfType = {
  161. getPage: (number) => Promise<PdfPageType>;
  162. numPages: number;
  163. } | null;
  164. type GetPageType = () => Promise<PdfPageType>;
  165. type TextItem = {
  166. items: unknown[];
  167. };
  168. type PdfPageType = {
  169. getTextContent: ({ normalizeWhitespace: boolean }) => Promise<TextItemp>;
  170. getViewport: (any) => ViewportType;
  171. cleanup: () => void;
  172. render: ({ canvasContext: any, viewport: any }) => RenderTaskType;
  173. } | null;
  174. type RenderTaskType = {
  175. cancel: () => void;
  176. promise: {
  177. catch: (arg0: (reason: sting) => void) => string;
  178. };
  179. };
  180. type ElementAttributeType = {
  181. title: Attr;
  182. date: Attr;
  183. page: Attr;
  184. color: Attr;
  185. width: Attr;
  186. opacity: Attr;
  187. 'interior-color': Attr;
  188. 'interior-opacity': Attr;
  189. tail: Attr;
  190. style: Attr;
  191. start: Attr;
  192. end: Attr;
  193. rect: Attr;
  194. coords: Attr;
  195. } & NamedNodeMap;
  196. type DispatchObjType = {
  197. type: string;
  198. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  199. payload: any;
  200. };
  201. type DispatchType = ({ type, payload }: DispatchObjType) => void;
  202. type ActionType = (
  203. dispatch: DispatchType,
  204. ) => Record<string, (arg0?: unknown, arg1?: unknown) => void>;
  205. type ReducerFuncType = (
  206. state: MainStateType & PdfStateType & SearchStateType,
  207. action: DispatchObjType,
  208. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  209. ) => any;
  210. type MainStateType = {
  211. displayMode: 'full' | 'normal';
  212. navbarState: 'search' | 'annotations' | 'thumbnails' | '';
  213. sidebarState: SidebarType | '';
  214. toolState: ToolType | FormType | '';
  215. info: { token: string; id: string };
  216. initiated: boolean;
  217. isLoading: boolean;
  218. };
  219. type PdfStateType = {
  220. totalPage: number;
  221. currentPage: number;
  222. pdf: PdfType;
  223. progress: ProgressType;
  224. viewport: ViewportType;
  225. scale: number;
  226. rotation: number;
  227. annotations: AnnotationType[];
  228. watermark: WatermarkType;
  229. };
  230. type SearchStateType = {
  231. queryString: string;
  232. currentIndex: number;
  233. matchesMap: MatchType[];
  234. };