dw-guten.js 982 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. ( function( wp ) {
  2. var SupButton = function( props ) {
  3. return wp.element.createElement(
  4. wp.editor.RichTextToolbarButton, {
  5. icon: 'arrow-up',
  6. title: 'Sup',
  7. onClick: function() {
  8. props.onChange( wp.richText.toggleFormat(
  9. props.value,
  10. { type: 'dw-guten/sup' }
  11. ) );
  12. },
  13. isActive: props.isActive,
  14. }
  15. );
  16. }
  17. var SubButton = function( props ) {
  18. return wp.element.createElement(
  19. wp.editor.RichTextToolbarButton, {
  20. icon: 'arrow-down',
  21. title: 'Sub',
  22. onClick: function() {
  23. props.onChange( wp.richText.toggleFormat(
  24. props.value,
  25. { type: 'dw-guten/sub' }
  26. ) );
  27. },
  28. isActive: props.isActive,
  29. }
  30. );
  31. }
  32. wp.richText.registerFormatType(
  33. 'dw-guten/sup', {
  34. title: 'Sup',
  35. tagName: 'sup',
  36. className: null,
  37. edit: SupButton
  38. }
  39. );
  40. wp.richText.registerFormatType(
  41. 'dw-guten/sub', {
  42. title: 'Sub',
  43. tagName: 'sub',
  44. className: null,
  45. edit: SubButton
  46. }
  47. );
  48. } )( window.wp );