@@ -5,6 +5,7 @@ import statusBarTemplate from './statusbar.html'
55import toolBarTemplate from './toolbar.html'
66import './markdown-lint'
77import { initTableEditor } from './table-editor'
8+ import { options , Alignment , FormatType } from '@susisu/mte-kernel'
89
910/* config section */
1011const isMac = CodeMirror . keyMap . default === CodeMirror . keyMap . macDefault
@@ -161,6 +162,19 @@ export default class Editor {
161162 var makeLine = $ ( '#makeLine' )
162163 var makeComment = $ ( '#makeComment' )
163164
165+ var insertRow = $ ( '#insertRow' )
166+ var deleteRow = $ ( '#deleteRow' )
167+ var moveRowUp = $ ( '#moveRowUp' )
168+ var moveRowDown = $ ( '#moveRowDown' )
169+ var insertColumn = $ ( '#insertColumn' )
170+ var deleteColumn = $ ( '#deleteColumn' )
171+ var moveColumnLeft = $ ( '#moveColumnLeft' )
172+ var moveColumnRight = $ ( '#moveColumnRight' )
173+ var alignLeft = $ ( '#alignLeft' )
174+ var alignCenter = $ ( '#alignCenter' )
175+ var alignRight = $ ( '#alignRight' )
176+ var alignNone = $ ( '#alignNone' )
177+
164178 makeBold . click ( ( ) => {
165179 utils . wrapTextWith ( this . editor , this . editor , '**' )
166180 this . editor . focus ( )
@@ -220,6 +234,72 @@ export default class Editor {
220234 makeComment . click ( ( ) => {
221235 utils . insertText ( this . editor , '> []' )
222236 } )
237+
238+ // table tools UI
239+ const opts = options ( {
240+ smartCursor : true ,
241+ formatType : FormatType . NORMAL
242+ } )
243+
244+ insertRow . click ( ( ) => {
245+ this . tableEditor . insertRow ( opts )
246+ this . editor . focus ( )
247+ } )
248+
249+ deleteRow . click ( ( ) => {
250+ this . tableEditor . deleteRow ( opts )
251+ this . editor . focus ( )
252+ } )
253+
254+ moveRowUp . click ( ( ) => {
255+ this . tableEditor . moveRow ( - 1 , opts )
256+ this . editor . focus ( )
257+ } )
258+
259+ moveRowDown . click ( ( ) => {
260+ this . tableEditor . moveRow ( 1 , opts )
261+ this . editor . focus ( )
262+ } )
263+
264+ insertColumn . click ( ( ) => {
265+ this . tableEditor . insertColumn ( opts )
266+ this . editor . focus ( )
267+ } )
268+
269+ deleteColumn . click ( ( ) => {
270+ this . tableEditor . deleteColumn ( opts )
271+ this . editor . focus ( )
272+ } )
273+
274+ moveColumnLeft . click ( ( ) => {
275+ this . tableEditor . moveColumn ( - 1 , opts )
276+ this . editor . focus ( )
277+ } )
278+
279+ moveColumnRight . click ( ( ) => {
280+ this . tableEditor . moveColumn ( 1 , opts )
281+ this . editor . focus ( )
282+ } )
283+
284+ alignLeft . click ( ( ) => {
285+ this . tableEditor . alignColumn ( Alignment . LEFT , opts )
286+ this . editor . focus ( )
287+ } )
288+
289+ alignCenter . click ( ( ) => {
290+ this . tableEditor . alignColumn ( Alignment . CENTER , opts )
291+ this . editor . focus ( )
292+ } )
293+
294+ alignRight . click ( ( ) => {
295+ this . tableEditor . alignColumn ( Alignment . RIGHT , opts )
296+ this . editor . focus ( )
297+ } )
298+
299+ alignNone . click ( ( ) => {
300+ this . tableEditor . alignColumn ( Alignment . NONE , opts )
301+ this . editor . focus ( )
302+ } )
223303 }
224304
225305 addStatusBar ( ) {
0 commit comments