Simple text editor based on tiptap. HTML format.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

64 lines
1.3 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. get schema() {
  32. return {
  33. attrs: {
  34. type: {
  35. default: "acronym"
  36. }
  37. },
  38. parseDOM: [
  39. {
  40. tag: "span.dede-style",
  41. getAttrs(dom) {
  42. return {type: dom.classList[1]};
  43. }
  44. }
  45. ],
  46. toDOM: mark => {
  47. return ["span", {class: `dede-style ${mark.attrs.type}`}, 0];
  48. }
  49. };
  50. }
  51. commands({type}) {
  52. return attrs => toggleMark(type, attrs);
  53. }
  54. }