iEmanuele

BBCode - Headings

May 20th, 2025
501
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * H1 BBCode
  3.  */
  4. $.sceditor.command.set('h1', {
  5.     tooltip: 'Heading 1',
  6.     state: function(parent, firstBlock) {
  7.         var $firstBlock = $(firstBlock);
  8.  
  9.         //  < 0 is disabled
  10.         // == 0 is enabled but not active
  11.         //  > 0 is active
  12.         return ($firstBlock.is('h1') || $firstBlock.parents('h1').length) ? 1 : 0;
  13.     },
  14.     exec: function() {
  15.        
  16.         this.insert('[h1]', '[/h1]');
  17.     },
  18.     txtExec: ['[h1]', '[/h1]']
  19. });
  20.  
  21. $.sceditorBBCodePlugin.bbcode.set('h1', {
  22.     allowsEmpty: true,
  23.     isInline: false,
  24.     tags: {
  25.        
  26.         h1: null
  27.     },
  28.     format: function(element, content) {
  29.         return '[h1]' + content + '[/h1]'
  30.     },
  31.     html: function(token, attrs, content) {
  32.         return '<h1>' + content + '</h1>'
  33.     }
  34. });
  35.  
  36. /**
  37.  * H2 BBCode
  38.  */
  39. $.sceditor.command.set('h2', {
  40.     tooltip: 'Heading 2',
  41.     state: function(parent, firstBlock) {
  42.         var $firstBlock = $(firstBlock);
  43.  
  44.         //  < 0 is disabled
  45.         // == 0 is enabled but not active
  46.         //  > 0 is active
  47.         return ($firstBlock.is('h2') || $firstBlock.parents('h2').length) ? 1 : 0;
  48.     },
  49.     exec: function() {
  50.        
  51.         this.insert('[h2]', '[/h2]');
  52.     },
  53.     txtExec: ['[h2]', '[/h2]']
  54. });
  55.  
  56. $.sceditorBBCodePlugin.bbcode.set('h2', {
  57.     allowsEmpty: true,
  58.     isInline: false,
  59.     tags: {
  60.        
  61.         h2: null
  62.     },
  63.     format: function(element, content) {
  64.         return '[h2]' + content + '[/h2]'
  65.     },
  66.     html: function(token, attrs, content) {
  67.         return '<h2>' + content + '</h2>'
  68.     }
  69. });
  70.  
  71. /**
  72.  * H3 BBCode
  73.  */
  74. $.sceditor.command.set('h3', {
  75.     tooltip: 'Heading 3',
  76.     state: function(parent, firstBlock) {
  77.         var $firstBlock = $(firstBlock);
  78.  
  79.         //  < 0 is disabled
  80.         // == 0 is enabled but not active
  81.         //  > 0 is active
  82.         return ($firstBlock.is('h3') || $firstBlock.parents('h3').length) ? 1 : 0;
  83.     },
  84.     exec: function() {
  85.        
  86.         this.insert('[h3]', '[/h3]');
  87.     },
  88.     txtExec: ['[h3]', '[/h3]']
  89. });
  90.  
  91. $.sceditorBBCodePlugin.bbcode.set('h3', {
  92.     allowsEmpty: true,
  93.     isInline: false,
  94.     tags: {
  95.        
  96.         h3: null
  97.     },
  98.     format: function(element, content) {
  99.         return '[h3]' + content + '[/h3]'
  100.     },
  101.     html: function(token, attrs, content) {
  102.         return '<h3>' + content + '</h3>'
  103.     }
  104. });
  105.  
  106.  
  107. /**
  108.  * H4 BBCode
  109.  */
  110. $.sceditor.command.set('h4', {
  111.     tooltip: 'Heading 4',
  112.     state: function(parent, firstBlock) {
  113.         var $firstBlock = $(firstBlock);
  114.  
  115.         //  < 0 is disabled
  116.         // == 0 is enabled but not active
  117.         //  > 0 is active
  118.         return ($firstBlock.is('h4') || $firstBlock.parents('h4').length) ? 1 : 0;
  119.     },
  120.     exec: function() {
  121.        
  122.         this.insert('[h4]', '[/h4]');
  123.     },
  124.     txtExec: ['[h4]', '[/h4]']
  125. });
  126.  
  127. $.sceditorBBCodePlugin.bbcode.set('h4', {
  128.     allowsEmpty: true,
  129.     isInline: false,
  130.     tags: {
  131.        
  132.         h4: null
  133.     },
  134.     format: function(element, content) {
  135.         return '[h4]' + content + '[/h4]'
  136.     },
  137.     html: function(token, attrs, content) {
  138.         return '<h4>' + content + '</h4>'
  139.     }
  140. });
  141.  
  142. /**
  143.  * H5 BBCode
  144.  */
  145. $.sceditor.command.set('h5', {
  146.     tooltip: 'Heading 5',
  147.     state: function(parent, firstBlock) {
  148.         var $firstBlock = $(firstBlock);
  149.  
  150.         //  < 0 is disabled
  151.         // == 0 is enabled but not active
  152.         //  > 0 is active
  153.         return ($firstBlock.is('h5') || $firstBlock.parents('h5').length) ? 1 : 0;
  154.     },
  155.     exec: function() {
  156.        
  157.         this.insert('[h5]', '[/h5]');
  158.     },
  159.     txtExec: ['[h5]', '[/h5]']
  160. });
  161.  
  162. $.sceditorBBCodePlugin.bbcode.set('h5', {
  163.     allowsEmpty: true,
  164.     isInline: false,
  165.     tags: {
  166.        
  167.         h5: null
  168.     },
  169.     format: function(element, content) {
  170.         return '[h5]' + content + '[/h5]'
  171.     },
  172.     html: function(token, attrs, content) {
  173.         return '<h5>' + content + '</h5>'
  174.     }
  175. });
  176.  
  177. /**
  178.  * H6 BBCode
  179.  */
  180. $.sceditor.command.set('h6', {
  181.     tooltip: 'Heading 6',
  182.     state: function(parent, firstBlock) {
  183.         var $firstBlock = $(firstBlock);
  184.  
  185.         //  < 0 is disabled
  186.         // == 0 is enabled but not active
  187.         //  > 0 is active
  188.         return ($firstBlock.is('h6') || $firstBlock.parents('h6').length) ? 1 : 0;
  189.     },
  190.     exec: function() {
  191.        
  192.         this.insert('[h6]', '[/h6]');
  193.     },
  194.     txtExec: ['[h6]', '[/h6]']
  195. });
  196.  
  197. $.sceditorBBCodePlugin.bbcode.set('h6', {
  198.     allowsEmpty: true,
  199.     isInline: false,
  200.     tags: {
  201.        
  202.         h6: null
  203.     },
  204.     format: function(element, content) {
  205.         return '[h6]' + content + '[/h6]'
  206.     },
  207.     html: function(token, attrs, content) {
  208.         return '<h6>' + content + '</h6>'
  209.     }
  210. });
Advertisement
Add Comment
Please, Sign In to add comment