-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
202 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
packages/app-desktop/gui/WindowCommandsAndDialogs/commands/showEditorPlugin.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { CommandContext, CommandDeclaration, CommandRuntime } from '@joplin/lib/services/CommandService'; | ||
import Setting from '@joplin/lib/models/Setting'; | ||
import getActivePluginEditorView from '@joplin/lib/services/plugins/utils/getActivePluginEditorView'; | ||
import Logger from '@joplin/utils/Logger'; | ||
|
||
const logger = Logger.create('showEditorPlugin'); | ||
|
||
export const declaration: CommandDeclaration = { | ||
name: 'showEditorPlugin', | ||
label: () => 'Show editor plugin', | ||
iconName: 'fas fa-eye', | ||
}; | ||
|
||
export const runtime = (): CommandRuntime => { | ||
return { | ||
execute: async (context: CommandContext, editorViewId = '', show = true) => { | ||
logger.info('View:', editorViewId, 'Show:', show); | ||
|
||
const shownEditorViewIds = Setting.value('plugins.shownEditorViewIds'); | ||
|
||
if (!editorViewId) { | ||
const { editorPlugin, editorView } = getActivePluginEditorView(context.state.pluginService.plugins); | ||
|
||
if (!editorPlugin) { | ||
logger.warn('No editor plugin to toggle to'); | ||
return; | ||
} | ||
|
||
editorViewId = editorView.id; | ||
} | ||
|
||
const idx = shownEditorViewIds.indexOf(editorViewId); | ||
|
||
if (show) { | ||
if (idx >= 0) { | ||
logger.info(`Editor is already visible: ${editorViewId}`); | ||
return; | ||
} | ||
|
||
shownEditorViewIds.push(editorViewId); | ||
} else { | ||
if (idx < 0) { | ||
logger.info(`Editor is already hidden: ${editorViewId}`); | ||
return; | ||
} | ||
|
||
shownEditorViewIds.splice(idx, 1); | ||
} | ||
|
||
Setting.setValue('plugins.shownEditorViewIds', shownEditorViewIds); | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.