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.
 
 
 
 
 
 

65 lignes
1.4 KiB

  1. import {Mark} from "tiptap";
  2. import {toggleMark} from "tiptap-commands";
  3. // — Mot - Accronyme
  4. // — Mot - Etranger
  5. // — Nom - Auteur - Citation
  6. // — Nom - Auteur - Œuvre
  7. // — Nom - Marque
  8. // — Nom - Propre
  9. // — Numeral - Chapitre
  10. // — Numeral - Date
  11. // — Numeral - Siecle
  12. // — Typo - Particulier
  13. export default class CustomStyle extends Mark {
  14. get name() {
  15. return "customstyle";
  16. }
  17. get defaultOptions() {
  18. return {
  19. types: [
  20. // "acronym",
  21. // "foreign",
  22. // "author-quotation",
  23. // "author-work",
  24. // "brand",
  25. // "proper-noun",
  26. // "century",
  27. // "date",
  28. // "chapter"
  29. ]
  30. };
  31. }
  32. get schema() {
  33. return {
  34. attrs: {
  35. type: {
  36. default: ""
  37. }
  38. },
  39. parseDOM: [
  40. {
  41. tag: "span.dede-style",
  42. getAttrs(dom) {
  43. return {type: dom.classList[1]};
  44. }
  45. }
  46. ],
  47. toDOM: mark => {
  48. return ["span", {class: `dede-style ${mark.attrs.type}`}, 0];
  49. }
  50. };
  51. }
  52. commands({type}) {
  53. return attrs => toggleMark(type, attrs);
  54. }
  55. }