custom.d.ts 5.5 KB

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