File tree Expand file tree Collapse file tree 4 files changed +31
-8
lines changed Expand file tree Collapse file tree 4 files changed +31
-8
lines changed Original file line number Diff line number Diff line change 7
7
createEditorUtils ,
8
8
findStartIndex ,
9
9
getBuiltinActions ,
10
+ getBuiltinRightActions ,
10
11
handleImageUpload ,
11
12
} from ' ./editor'
12
13
import Help from ' ./help.svelte'
106
107
107
108
keyMap = {}
108
109
// TODO: nested shortcuts
109
- actions .forEach (({ handler }) => {
110
+ actions .leftActions . forEach (({ handler }) => {
110
111
if (handler ?.type === ' action' && handler .shortcut ) {
111
112
keyMap [handler .shortcut ] = () => {
112
113
handler .click (context )
349
350
{activeTab }
350
351
{sidebar }
351
352
{fullscreen }
353
+ rightAfferentActions ={actions .rightActions }
352
354
locale ={mergedLocale }
353
- {actions }
355
+ actions = {actions . leftActions }
354
356
on:key ={(e ) => {
355
357
editor .setOption (' keyMap' , e .detail )
356
358
editor .focus ()
408
410
>
409
411
{@html icons .Close ({})}
410
412
</div >
411
- <Help locale ={mergedLocale } {actions } visible ={sidebar === ' help' } />
413
+ <Help
414
+ locale ={mergedLocale }
415
+ actions ={actions .leftActions }
416
+ visible ={sidebar === ' help' }
417
+ />
412
418
<Toc
413
419
{hast }
414
420
locale ={mergedLocale }
Original file line number Diff line number Diff line change @@ -166,8 +166,8 @@ export function getBuiltinActions(
166
166
locale : BytemdLocale ,
167
167
plugins : BytemdPlugin [ ] ,
168
168
uploadImages : EditorProps [ 'uploadImages' ]
169
- ) : BytemdAction [ ] {
170
- const items : BytemdAction [ ] = [
169
+ ) : { leftActions : BytemdAction [ ] ; rightActions : BytemdAction [ ] } {
170
+ const leftActions : BytemdAction [ ] = [
171
171
{
172
172
icon : icons . H ( { } ) ,
173
173
handler : {
@@ -339,9 +339,18 @@ export function getBuiltinActions(
339
339
cheatsheet : '---' ,
340
340
} ,
341
341
]
342
-
342
+ const rightActions : BytemdAction [ ] = [ ]
343
343
plugins . forEach ( ( { actions } ) => {
344
- if ( actions ) items . push ( ...actions )
344
+ if ( actions ) {
345
+ actions . forEach ( ( action ) => {
346
+ if ( ! action . position || action . position !== 'right' )
347
+ leftActions . push ( action )
348
+ else rightActions . push ( action )
349
+ } )
350
+ }
345
351
} )
346
- return items
352
+ return {
353
+ leftActions,
354
+ rightActions,
355
+ }
347
356
}
Original file line number Diff line number Diff line change 17
17
export let sidebar: false | ' help' | ' toc'
18
18
export let locale: BytemdLocale
19
19
export let actions: BytemdAction []
20
+ export let rightAfferentActions: BytemdAction []
20
21
21
22
interface RightAction extends BytemdAction {
22
23
active? : boolean
131
132
},
132
133
},
133
134
},
135
+ ... rightAfferentActions
134
136
] as RightAction []
135
137
136
138
const tippyClass = ' bytemd-tippy'
Original file line number Diff line number Diff line change @@ -116,6 +116,12 @@ export interface BytemdAction {
116
116
* Action title
117
117
*/
118
118
title ?: string
119
+ /**
120
+ * Action icon position
121
+ *
122
+ * Specifies that the action icon is in the toolbar position, which defaults to the left
123
+ */
124
+ position ?: 'left' | 'right'
119
125
/**
120
126
* Action icon (16x16), usually inline svg
121
127
*/
You can’t perform that action at this time.
0 commit comments