diff --git a/smart_env.config.js b/smart_env.config.js index cb91dff..ee09ade 100644 --- a/smart_env.config.js +++ b/smart_env.config.js @@ -21,7 +21,7 @@ import { env_copy_selected_notes_to_clipboard as env_copy_selected_notes_to_clip import { env_open_file_selection_in_context_builder as env_open_file_selection_in_context_builder_action, menus as env_open_file_selection_in_context_builder_action_menus } from './src/actions/env/open_file_selection_in_context_builder.js'; import { env_open_folder_in_context_builder as env_open_folder_in_context_builder_action, menus as env_open_folder_in_context_builder_action_menus } from './src/actions/env/open_folder_in_context_builder.js'; import { smart_contexts_insert_codeblock as smart_contexts_insert_codeblock_action, commands as smart_contexts_insert_codeblock_action_commands } from './src/actions/smart-contexts/insert_codeblock.js'; -import { smart_contexts_open_dashboard as smart_contexts_open_dashboard_action, ribbon_icons as smart_contexts_open_dashboard_action_ribbon_icons, menus as smart_contexts_open_dashboard_action_menus } from './src/actions/smart-contexts/open_dashboard.js'; +import { smart_contexts_open_dashboard as smart_contexts_open_dashboard_action, commands as smart_contexts_open_dashboard_action_commands, ribbon_icons as smart_contexts_open_dashboard_action_ribbon_icons, menus as smart_contexts_open_dashboard_action_menus } from './src/actions/smart-contexts/open_dashboard.js'; import { smart_contexts_open_new as smart_contexts_open_new_action, commands as smart_contexts_open_new_action_commands, ribbon_icons as smart_contexts_open_new_action_ribbon_icons } from './src/actions/smart-contexts/open_new.js'; import { smart_contexts_open_onboarding as smart_contexts_open_onboarding_action, commands as smart_contexts_open_onboarding_action_commands, menus as smart_contexts_open_onboarding_action_menus } from './src/actions/smart-contexts/open_onboarding.js'; import { source_copy_current as source_copy_current_action, commands as source_copy_current_action_commands, ribbon_icons as source_copy_current_action_ribbon_icons } from './src/actions/source/copy_current.js'; @@ -59,7 +59,7 @@ export const smart_env_config = { env_open_file_selection_in_context_builder: { action: env_open_file_selection_in_context_builder_action, menus: env_open_file_selection_in_context_builder_action_menus, version: "2.4.6" }, env_open_folder_in_context_builder: { action: env_open_folder_in_context_builder_action, menus: env_open_folder_in_context_builder_action_menus, version: "2.4.6" }, smart_contexts_insert_codeblock: { action: smart_contexts_insert_codeblock_action, commands: smart_contexts_insert_codeblock_action_commands, version: "2.4.6" }, - smart_contexts_open_dashboard: { action: smart_contexts_open_dashboard_action, ribbon_icons: smart_contexts_open_dashboard_action_ribbon_icons, menus: smart_contexts_open_dashboard_action_menus, version: "2.4.6" }, + smart_contexts_open_dashboard: { action: smart_contexts_open_dashboard_action, commands: smart_contexts_open_dashboard_action_commands, ribbon_icons: smart_contexts_open_dashboard_action_ribbon_icons, menus: smart_contexts_open_dashboard_action_menus, version: "2.4.6" }, smart_contexts_open_new: { action: smart_contexts_open_new_action, commands: smart_contexts_open_new_action_commands, ribbon_icons: smart_contexts_open_new_action_ribbon_icons, version: "2.4.6" }, smart_contexts_open_onboarding: { action: smart_contexts_open_onboarding_action, commands: smart_contexts_open_onboarding_action_commands, menus: smart_contexts_open_onboarding_action_menus, version: "2.4.6" }, source_copy_current: { action: source_copy_current_action, commands: source_copy_current_action_commands, ribbon_icons: source_copy_current_action_ribbon_icons, version: "2.4.6" }, diff --git a/src/actions/smart-contexts/open_dashboard.js b/src/actions/smart-contexts/open_dashboard.js index 3e2e473..a4de303 100644 --- a/src/actions/smart-contexts/open_dashboard.js +++ b/src/actions/smart-contexts/open_dashboard.js @@ -3,20 +3,35 @@ * * @this {import('smart-contexts').SmartContexts} Collection scope * @param {object} [params={}] + * @param {object} [params.plugin] * @returns {boolean} */ export function smart_contexts_open_dashboard(params = {}) { - const app = params.app - || this?.env?.plugin?.app - || this?.env?.obsidian_app - || globalThis.app - ; - if (typeof app?.commands?.executeCommandById !== 'function') return false; + const plugin = params.plugin || this?.env?.smart_context_plugin; + if (typeof plugin?.open_contexts_dashboard !== 'function') return false; - app.commands.executeCommandById('smart-context:smart-contexts-dashboard'); + plugin.open_contexts_dashboard(); return true; } +export const commands = { + 'smart-contexts-dashboard': { + name: 'Open: Management dashboard (show named contexts) view', + + register_when({ plugin }) { + return plugin.manifest.id === 'smart-context'; + }, + + params({ plugin }) { + return { plugin }; + }, + + get_scope({ env }) { + return env.smart_contexts; + }, + }, +}; + export const menus = { 'smart_contexts:menu': { title: 'Open named contexts dashboard', @@ -34,8 +49,8 @@ export const ribbon_icons = { return plugin.manifest.id === 'smart-context'; }, - params({ app }) { - return { app }; + params({ plugin }) { + return { plugin }; }, get_scope({ env }) { diff --git a/src/components/context/codeblock.js b/src/components/context/codeblock.js index 0b5c258..bf88944 100644 --- a/src/components/context/codeblock.js +++ b/src/components/context/codeblock.js @@ -115,7 +115,7 @@ export async function post_process(ctx, container, params = {}) { menu.addSeparator(); ctx.env?.build_menu?.('smart_context:copy_menu', menu, ctx, menu_params); menu.addSeparator(); - ctx.env?.build_menu?.('smart_contexts:menu', menu, ctx, menu_params); + ctx.env?.build_menu?.('smart_contexts:menu', menu, ctx.collection, menu_params); show_menu(menu, event, menu_btn); }; diff --git a/src/main.js b/src/main.js index 89a089b..5031e77 100644 --- a/src/main.js +++ b/src/main.js @@ -53,8 +53,8 @@ export default class SmartContextPlugin extends SmartPlugin { this.register_folder_menu(); this.register_files_menu(); - ContextsDashboardView.register_item_view(this); - this.ReleaseNotesView.register_item_view(this); + ContextsDashboardView.register_item_view(this, { skip_command_registration: true }); + this.ReleaseNotesView.register_item_view(this, { skip_command_registration: true }); // First-run onboarding if (this.is_new_user()) {