comparison src/bbcode/bbcode.js @ 49:f225e82b2bf8

add code bbcode
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 17 Nov 2022 16:46:21 -0700
parents 4e1a01db19ec
children 0d99cec5142c
comparison
equal deleted inserted replaced
48:4e1a01db19ec 49:f225e82b2bf8
47 <button type=button strikethrough title="Strikethrough"><img src="/bbcode/icons/format_strikethrough.svg"></button> 47 <button type=button strikethrough title="Strikethrough"><img src="/bbcode/icons/format_strikethrough.svg"></button>
48 <button type=button sub title="Subscript"><img src="/bbcode/icons/subscript.svg"></button> 48 <button type=button sub title="Subscript"><img src="/bbcode/icons/subscript.svg"></button>
49 <button type=button sup title="Superscript"><img src="/bbcode/icons/superscript.svg"></button> 49 <button type=button sup title="Superscript"><img src="/bbcode/icons/superscript.svg"></button>
50 <button type=button ul title="Bullet list"><img src="/bbcode/icons/format_list_bulleted.svg"></button> 50 <button type=button ul title="Bullet list"><img src="/bbcode/icons/format_list_bulleted.svg"></button>
51 <button type=button ol title="Numbered list"><img src="/bbcode/icons/format_list_numbered.svg"></button> 51 <button type=button ol title="Numbered list"><img src="/bbcode/icons/format_list_numbered.svg"></button>
52 <button type=button code_block title="Code block"><img src="/bbcode/icons/code_blocks.svg"></button>
53 <button type=button code_inline title="Inline code"><img src="/bbcode/icons/code.svg"></button>
52 <button type=button more checked title="More..."><img src="/bbcode/icons/more_horiz.svg"></button> 54 <button type=button more checked title="More..."><img src="/bbcode/icons/more_horiz.svg"></button>
53 <input type=file> 55 <input type=file>
54 <button type=button upload title="Upload File"><img src="/bbcode/icons/file_upload.svg"></button> 56 <button type=button upload title="Upload File"><img src="/bbcode/icons/file_upload.svg"></button>
55 ` ; 57 ` ;
56 if(save) { 58 if(save) {
127 add('strikethrough','[s]','[/s]'); 129 add('strikethrough','[s]','[/s]');
128 add('sub','[sub]','[/sub]'); 130 add('sub','[sub]','[/sub]');
129 add('sup','[sup]','[/sup]'); 131 add('sup','[sup]','[/sup]');
130 add('ul','[list]\n[item]','[/item]\n[/list]'); 132 add('ul','[list]\n[item]','[/item]\n[/list]');
131 add('ol','[list=1]\n[item]','[/item]\n[/list]'); 133 add('ol','[list=1]\n[item]','[/item]\n[/list]');
134 add('code_block','[code]','[/code]');
135 add('code_inline','[code=inline]','[/code]');
132 136
133 let fileInput = div.querySelector('input[type="file"]'); 137 let fileInput = div.querySelector('input[type="file"]');
134 div.querySelector('button[upload]').onclick = function(){ fileInput.click(); }; 138 div.querySelector('button[upload]').onclick = function(){ fileInput.click(); };
135 function uploaded(input,url,filename) { 139 function uploaded(input,url,filename) {
136 textarea.setRangeText(url,textarea.selectionStart,textarea.selectionEnd,'select'); 140 textarea.setRangeText(url,textarea.selectionStart,textarea.selectionEnd,'select');