Simple text editor based on tiptap. HTML format.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

130 lignes
3.3 KiB

  1. const defaultEnvName = "ar";
  2. export default class Environment {
  3. constructor(options = {}) {
  4. this.name = options.name ? options.name : defaultEnvName;
  5. this.defaultOptions = {
  6. paragraphs: {
  7. T1: true,
  8. T2: true,
  9. T3: true,
  10. T4: true,
  11. quote: true
  12. },
  13. characters: [
  14. {
  15. label: "mot",
  16. styles: [
  17. {
  18. "label": "étranger",
  19. "class": "foreign"
  20. },
  21. {
  22. "label": "accronyme",
  23. "class": "acronym"
  24. }
  25. ]
  26. },
  27. {
  28. label: "nom",
  29. styles: [
  30. {
  31. "label": "Auteur - Citation",
  32. "class": "author-quotation"
  33. },
  34. {
  35. "label": "Auteur - Œuvre",
  36. "class": "author-work"
  37. },
  38. {
  39. "label": "Marque",
  40. "class": "brand"
  41. },
  42. {
  43. "label": "Nom propre",
  44. "class": "proper-noun"
  45. }
  46. ]
  47. },
  48. {
  49. label: "numéral",
  50. styles: [
  51. {
  52. "label": "siècle",
  53. "class": "century"
  54. },
  55. {
  56. "label": "date",
  57. "class": "date"
  58. }
  59. ]
  60. },
  61. {
  62. label: "typo",
  63. styles: [
  64. {
  65. "label": "indice",
  66. "class": "subscript"
  67. },
  68. {
  69. "label": "exposant",
  70. "class": "superscript"
  71. }
  72. ]
  73. }
  74. ],
  75. };
  76. this.setOptions({
  77. ...this.defaultOptions,
  78. ...options,
  79. })
  80. }
  81. setOptions(options) {
  82. this.options = {
  83. ...this.options,
  84. ...options,
  85. }
  86. }
  87. hasParagraphOption(optionKey) {
  88. return this.options.paragraphs[optionKey] | false;
  89. }
  90. getCharacterOptions() {
  91. return this.options.characters;
  92. }
  93. static async loadEnvironment(envName) {
  94. if (envName === defaultEnvName)
  95. return new Environment();
  96. else
  97. return Environment.loadEnvironmentFromJSONFile('/dedediteur/env/' + envName + '.json')
  98. }
  99. static async loadEnvironmentFromJSONFile(filePath) {
  100. let res = await fetch(filePath);
  101. let json = await res.json();
  102. return Environment.loadEnvironmentFromJSON(json);
  103. }
  104. static loadEnvironmentFromJSON(json) {
  105. return new Environment(json);
  106. }
  107. }