constants.ts 1.47 KB
// File type constants from OnlyOffice SDK
export const oAscFileType = {
  UNKNOWN: 0,
  PDF: 513,
  PDFA: 521,
  DJVU: 515,
  XPS: 516,
  DOCX: 65,
  DOC: 66,
  ODT: 67,
  RTF: 68,
  TXT: 69,
  HTML: 70,
  MHT: 71,
  EPUB: 72,
  FB2: 73,
  MOBI: 74,
  DOCM: 75,
  DOTX: 76,
  DOTM: 77,
  FODT: 78,
  OTT: 79,
  DOC_FLAT: 80,
  DOCX_FLAT: 81,
  HTML_IN_CONTAINER: 82,
  DOCX_PACKAGE: 84,
  OFORM: 85,
  DOCXF: 86,
  DOCY: 4097,
  CANVAS_WORD: 8193,
  JSON: 2056,
  XLSX: 257,
  XLS: 258,
  ODS: 259,
  CSV: 260,
  XLSM: 261,
  XLTX: 262,
  XLTM: 263,
  XLSB: 264,
  FODS: 265,
  OTS: 266,
  XLSX_FLAT: 267,
  XLSX_PACKAGE: 268,
  XLSY: 4098,
  PPTX: 129,
  PPT: 130,
  ODP: 131,
  PPSX: 132,
  PPTM: 133,
  PPSM: 134,
  POTX: 135,
  POTM: 136,
  FODP: 137,
  OTP: 138,
  PPTX_PACKAGE: 139,
  IMG: 1024,
  JPG: 1025,
  TIFF: 1026,
  TGA: 1027,
  GIF: 1028,
  PNG: 1029,
  EMF: 1030,
  WMF: 1031,
  BMP: 1032,
  CR2: 1033,
  PCX: 1034,
  RAS: 1035,
  PSD: 1036,
  ICO: 1037,
} as const;

export const c_oAscFileType2 = Object.fromEntries(
  Object.entries(oAscFileType).map(([key, value]) => [value, key]),
) as Record<number, keyof typeof oAscFileType>;

export type DocumentType = 'word' | 'cell' | 'slide';

export const DOCUMENT_TYPE_MAP: Record<string, DocumentType> = {
  docx: 'word',
  doc: 'word',
  odt: 'word',
  rtf: 'word',
  txt: 'word',
  xlsx: 'cell',
  xls: 'cell',
  ods: 'cell',
  csv: 'cell',
  pptx: 'slide',
  ppt: 'slide',
  odp: 'slide',
};

export const BASE_PATH = '/document/';