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.

CustomStyle.js 1.3 KiB

il y a 4 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. }