mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-01-23 02:36:05 +00:00
feat(plugin): cleanup and improve
This commit is contained in:
parent
d79f9267ac
commit
5d3bae6fc6
7 changed files with 9 additions and 159 deletions
|
|
@ -25,21 +25,18 @@ module.exports = {
|
|||
return;
|
||||
}
|
||||
|
||||
// Make sure collapsible is expanded - click the title to toggle
|
||||
// Make sure collapsible is expanded - click the header to toggle
|
||||
const collapsible = document.querySelector('.plugin-section collapsible');
|
||||
if (collapsible) {
|
||||
const isExpanded = collapsible.classList.contains('isExpanded');
|
||||
if (!isExpanded) {
|
||||
// Click the collapsible title to expand it
|
||||
const titleWrapper =
|
||||
collapsible.querySelector('.collapsible-title-wrapper') ||
|
||||
collapsible.querySelector('[mat-button]') ||
|
||||
collapsible.querySelector('button');
|
||||
if (titleWrapper) {
|
||||
(titleWrapper as HTMLElement).click();
|
||||
// Click the collapsible header to expand it
|
||||
const header = collapsible.querySelector('.collapsible-header');
|
||||
if (header) {
|
||||
(header as HTMLElement).click();
|
||||
console.log('Clicked to expand plugin collapsible');
|
||||
} else {
|
||||
console.error('Could not find collapsible toggle button');
|
||||
console.error('Could not find collapsible header');
|
||||
}
|
||||
} else {
|
||||
console.log('Plugin collapsible already expanded');
|
||||
|
|
|
|||
|
|
@ -109,23 +109,3 @@ const ea: ElectronAPI = {
|
|||
request,
|
||||
) as Promise<PluginNodeScriptResult>,
|
||||
};
|
||||
// Debug: Log the ea object before exposing
|
||||
console.log('ea object keys:', Object.keys(ea));
|
||||
console.log('pluginExecNodeScript type:', typeof ea.pluginExecNodeScript);
|
||||
|
||||
contextBridge.exposeInMainWorld('ea', ea);
|
||||
|
||||
// contextBridge.exposeInIsolatedWorld();
|
||||
console.log('preload script loading complete');
|
||||
|
||||
// Debug: Verify after exposing
|
||||
setTimeout(() => {
|
||||
// @ts-ignore - window is not available in preload context types
|
||||
console.log('window.ea exists:', typeof window !== 'undefined' && !!(window as any).ea);
|
||||
// @ts-ignore - window is not available in preload context types
|
||||
console.log(
|
||||
'window.ea.pluginExecNodeScript exists:',
|
||||
typeof window !== 'undefined' &&
|
||||
!!((window as any).ea && (window as any).ea.pluginExecNodeScript),
|
||||
);
|
||||
}, 1000);
|
||||
|
|
|
|||
|
|
@ -1,100 +0,0 @@
|
|||
// Example TypeScript plugin using @super-productivity/plugin-api
|
||||
|
||||
import type {
|
||||
PluginAPI,
|
||||
PluginHooks,
|
||||
TaskData,
|
||||
PluginManifest,
|
||||
} from '@super-productivity/plugin-api';
|
||||
|
||||
// Example manifest (would be in manifest.json)
|
||||
const manifest: PluginManifest = {
|
||||
name: 'My Awesome Plugin',
|
||||
id: 'my-awesome-plugin',
|
||||
manifestVersion: 1,
|
||||
version: '1.0.0',
|
||||
minSupVersion: '13.0.0',
|
||||
description: 'An example plugin with full TypeScript support',
|
||||
hooks: [PluginHooks.TASK_COMPLETE, PluginHooks.TASK_UPDATE],
|
||||
permissions: ['showSnack', 'getTasks', 'addTask', 'showIndexHtmlAsView', 'openDialog'],
|
||||
iFrame: true,
|
||||
icon: 'icon.svg',
|
||||
};
|
||||
|
||||
// Plugin code with full type safety
|
||||
console.log('My Plugin initializing...', PluginAPI);
|
||||
|
||||
// Register hook with typed parameters
|
||||
PluginAPI.registerHook(PluginHooks.TASK_COMPLETE, (taskData: TaskData) => {
|
||||
console.log('Task completed!', taskData);
|
||||
|
||||
PluginAPI.showSnack({
|
||||
msg: `🎉 Completed: ${taskData.title}`,
|
||||
type: 'SUCCESS',
|
||||
ico: 'celebration',
|
||||
});
|
||||
});
|
||||
|
||||
// Register header button with type safety
|
||||
PluginAPI.registerHeaderButton({
|
||||
label: 'My Dashboard',
|
||||
icon: 'dashboard',
|
||||
onClick: () => {
|
||||
PluginAPI.showIndexHtmlAsView();
|
||||
},
|
||||
});
|
||||
|
||||
// Register keyboard shortcut
|
||||
PluginAPI.registerShortcut({
|
||||
id: 'create_example_task',
|
||||
label: 'Create Example Task',
|
||||
onExec: async () => {
|
||||
try {
|
||||
const taskId = await PluginAPI.addTask({
|
||||
title: '🔌 Task from TypeScript Plugin',
|
||||
notes: 'This task was created with full type safety!',
|
||||
tagIds: [],
|
||||
});
|
||||
|
||||
PluginAPI.showSnack({
|
||||
msg: `✅ Created task: ${taskId}`,
|
||||
type: 'SUCCESS',
|
||||
});
|
||||
} catch (error) {
|
||||
PluginAPI.showSnack({
|
||||
msg: '❌ Failed to create task',
|
||||
type: 'ERROR',
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// Example of working with tasks
|
||||
async function processAllTasks() {
|
||||
try {
|
||||
const tasks = await PluginAPI.getTasks();
|
||||
const completedTasks = tasks.filter((task) => task.isDone);
|
||||
|
||||
PluginAPI.openDialog({
|
||||
htmlContent: `
|
||||
<div style="padding: 20px;">
|
||||
<h2>Task Summary</h2>
|
||||
<p>Total tasks: ${tasks.length}</p>
|
||||
<p>Completed: ${completedTasks.length}</p>
|
||||
<p>Remaining: ${tasks.length - completedTasks.length}</p>
|
||||
</div>
|
||||
`,
|
||||
buttons: [
|
||||
{
|
||||
label: 'Close',
|
||||
icon: 'close',
|
||||
onClick: () => {
|
||||
console.log('Dialog closed');
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Failed to process tasks:', error);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
'use strict';
|
||||
// Types for Super Productivity Plugin API
|
||||
// This package provides TypeScript types for developing plugins
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
exports.PluginHooks = void 0;
|
||||
var PluginHooks;
|
||||
(function (PluginHooks) {
|
||||
PluginHooks['TASK_COMPLETE'] = 'taskComplete';
|
||||
PluginHooks['TASK_UPDATE'] = 'taskUpdate';
|
||||
PluginHooks['TASK_DELETE'] = 'taskDelete';
|
||||
PluginHooks['CURRENT_TASK_CHANGE'] = 'currentTaskChange';
|
||||
PluginHooks['FINISH_DAY'] = 'finishDay';
|
||||
PluginHooks['LANGUAGE_CHANGE'] = 'languageChange';
|
||||
PluginHooks['PERSISTED_DATA_UPDATE'] = 'persistedDataUpdate';
|
||||
PluginHooks['ACTION'] = 'action';
|
||||
})(PluginHooks || (exports.PluginHooks = PluginHooks = {}));
|
||||
// Global PluginAPI interface for runtime use
|
||||
// Note: This is commented out to avoid conflicts with node_modules version
|
||||
// declare global {
|
||||
// interface Window {
|
||||
// PluginAPI: PluginAPI;
|
||||
// }
|
||||
//
|
||||
// // For plugin development without window reference
|
||||
// const PluginAPI: PluginAPI;
|
||||
// }
|
||||
//# sourceMappingURL=types.js.map
|
||||
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":";AAAA,0CAA0C;AAC1C,gEAAgE;;;AAShE,IAAY,WASX;AATD,WAAY,WAAW;IACrB,6CAA8B,CAAA;IAC9B,yCAA0B,CAAA;IAC1B,yCAA0B,CAAA;IAC1B,wDAAyC,CAAA;IACzC,uCAAwB,CAAA;IACxB,iDAAkC,CAAA;IAClC,4DAA6C,CAAA;IAC7C,gCAAiB,CAAA;AACnB,CAAC,EATW,WAAW,2BAAX,WAAW,QAStB;AA0PD,6CAA6C;AAC7C,2EAA2E;AAC3E,mBAAmB;AACnB,uBAAuB;AACvB,4BAA4B;AAC5B,MAAM;AACN,EAAE;AACF,uDAAuD;AACvD,gCAAgC;AAChC,IAAI"}
|
||||
|
|
@ -23,10 +23,11 @@ import { PluginService } from '../../plugins/plugin.service';
|
|||
import { PluginPanelContainerComponent } from '../../plugins/ui/plugin-panel-container/plugin-panel-container.component';
|
||||
import { Store } from '@ngrx/store';
|
||||
import {
|
||||
selectIsShowPluginPanel,
|
||||
selectActivePluginId,
|
||||
selectIsShowPluginPanel,
|
||||
} from '../../core-ui/layout/store/layout.reducer';
|
||||
import { hidePluginPanel } from '../../core-ui/layout/store/layout.actions';
|
||||
import { fastArrayCompare } from '../../util/fast-array-compare';
|
||||
|
||||
@Component({
|
||||
selector: 'right-panel',
|
||||
|
|
@ -117,7 +118,7 @@ export class RightPanelComponent implements OnDestroy {
|
|||
});
|
||||
return keys;
|
||||
}),
|
||||
distinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)),
|
||||
distinctUntilChanged((a, b) => fastArrayCompare(a, b)),
|
||||
);
|
||||
|
||||
isOpen$: Observable<boolean> = combineLatest([
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue