@dhwaniapp/plugin-sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -0
- package/index.d.ts +189 -0
- package/package.json +20 -0
- package/plugin-manifest.schema.json +93 -0
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# @dhwaniapp/plugin-sdk
|
|
2
|
+
|
|
3
|
+
Software Development Kit (SDK) typings and manifest schemas for building custom extensions in **Dhwani Note Taking**.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Install the SDK as a devDependency in your plugin project:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install --save-dev @dhwaniapp/plugin-sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 1. JSON Schema Validation (`application.json`)
|
|
18
|
+
|
|
19
|
+
To enable autocomplete and inline schema validation in your editor (e.g. VS Code), add the `$schema` reference pointing to the node_modules location at the top of your `application.json` manifest:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"$schema": "./node_modules/@dhwaniapp/plugin-sdk/plugin-manifest.schema.json",
|
|
24
|
+
"display_name": "My Custom Node Plugin",
|
|
25
|
+
"system_name": "my.custom.node",
|
|
26
|
+
"version": "1.0.0",
|
|
27
|
+
"author": "Developer Name",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"permissions_required": ["use_page_extention"]
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 2. Editor typings and Intellisense (`dist/*.js`)
|
|
36
|
+
|
|
37
|
+
To enable code suggestions for `window.Dhwani` and `window.DhwaniEditorSDK` namespaces, add the type reference directive at the top of your JavaScript source files:
|
|
38
|
+
|
|
39
|
+
```javascript
|
|
40
|
+
/// <reference types="@dhwaniapp/plugin-sdk" />
|
|
41
|
+
|
|
42
|
+
(function() {
|
|
43
|
+
const React = window.React;
|
|
44
|
+
const { Node, ReactNodeViewRenderer, NodeViewWrapper } = window.DhwaniEditorSDK;
|
|
45
|
+
|
|
46
|
+
// Your custom editor node view code...
|
|
47
|
+
})();
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
If you are developing your plugin with TypeScript, configure your project's `tsconfig.json` to load the SDK typings automatically:
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"compilerOptions": {
|
|
55
|
+
"types": ["@dhwaniapp/plugin-sdk"]
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dhwani Plugin SDK Declaration File
|
|
3
|
+
* Provides auto-suggestions, typings, and intellisense in VS Code for Dhwani plugins.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
declare namespace DhwaniEditorSDK {
|
|
7
|
+
/**
|
|
8
|
+
* Base Tiptap Node class for building custom editor blocks.
|
|
9
|
+
*/
|
|
10
|
+
export class Node {
|
|
11
|
+
name: string;
|
|
12
|
+
static create(config: {
|
|
13
|
+
name: string;
|
|
14
|
+
group?: "block" | "inline";
|
|
15
|
+
content?: string;
|
|
16
|
+
defining?: boolean;
|
|
17
|
+
inline?: boolean;
|
|
18
|
+
draggable?: boolean;
|
|
19
|
+
parseHTML?(): { tag: string; getAttrs?: (node: any) => any }[];
|
|
20
|
+
renderHTML?(props: { HTMLAttributes: Record<string, any> }): [string, any, ...any[]];
|
|
21
|
+
addNodeView?(): any;
|
|
22
|
+
addAttributes?(): Record<string, { default?: any; parseHTML?: (element: any) => any }>;
|
|
23
|
+
addCommands?(): Record<string, (...args: any[]) => any>;
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
}): any;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Base Tiptap Mark class for styling text (e.g. bold, highlight).
|
|
30
|
+
*/
|
|
31
|
+
export class Mark {
|
|
32
|
+
name: string;
|
|
33
|
+
static create(config: {
|
|
34
|
+
name: string;
|
|
35
|
+
parseHTML?(): { tag: string }[];
|
|
36
|
+
renderHTML?(props: { HTMLAttributes: Record<string, any> }): [string, any, ...any[]];
|
|
37
|
+
[key: string]: any;
|
|
38
|
+
}): any;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Base Tiptap Extension class for adding custom behaviors and commands.
|
|
43
|
+
*/
|
|
44
|
+
export class Extension {
|
|
45
|
+
name: string;
|
|
46
|
+
static create(config: {
|
|
47
|
+
name: string;
|
|
48
|
+
addOptions?(): Record<string, any>;
|
|
49
|
+
addCommands?(): Record<string, (...args: any[]) => any>;
|
|
50
|
+
[key: string]: any;
|
|
51
|
+
}): any;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Merges HTML attributes safely during Tiptap rendering.
|
|
56
|
+
*/
|
|
57
|
+
export function mergeAttributes(...attributes: Record<string, any>[]): Record<string, any>;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Renderer to map custom React components as Tiptap interactive node views.
|
|
61
|
+
*/
|
|
62
|
+
export function ReactNodeViewRenderer(component: any, options?: { stopPropagation?: boolean }): any;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* React component wrapper for custom Node Views (holds outer container bindings).
|
|
66
|
+
*/
|
|
67
|
+
export const NodeViewWrapper: React.ComponentType<{
|
|
68
|
+
className?: string;
|
|
69
|
+
style?: React.CSSProperties;
|
|
70
|
+
children?: React.ReactNode;
|
|
71
|
+
[key: string]: any;
|
|
72
|
+
}>;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* React component placeholder for editable nested text blocks inside a custom Node View.
|
|
76
|
+
*/
|
|
77
|
+
export const NodeViewContent: React.ComponentType<{
|
|
78
|
+
className?: string;
|
|
79
|
+
style?: React.CSSProperties;
|
|
80
|
+
[key: string]: any;
|
|
81
|
+
}>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Tiptap Editor interface wrapper.
|
|
86
|
+
*/
|
|
87
|
+
interface DhwaniTiptapEditor {
|
|
88
|
+
/**
|
|
89
|
+
* Starts a command chain transaction (e.g., editor.chain().focus().insertContent(...).run()).
|
|
90
|
+
*/
|
|
91
|
+
chain(): DhwaniTiptapEditorChain;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Direct commands register.
|
|
95
|
+
*/
|
|
96
|
+
commands: {
|
|
97
|
+
/**
|
|
98
|
+
* Sets text selection cursor at document index.
|
|
99
|
+
*/
|
|
100
|
+
setTextSelection(position: number): boolean;
|
|
101
|
+
[key: string]: any;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Current editor ProseMirror state.
|
|
106
|
+
*/
|
|
107
|
+
state: {
|
|
108
|
+
selection: {
|
|
109
|
+
from: number;
|
|
110
|
+
to: number;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Tiptap Command Chain Helper.
|
|
117
|
+
*/
|
|
118
|
+
interface DhwaniTiptapEditorChain {
|
|
119
|
+
/**
|
|
120
|
+
* Directs keyboard focus to the editor.
|
|
121
|
+
*/
|
|
122
|
+
focus(): DhwaniTiptapEditorChain;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Inserts content (HTML markup, markdown, or node objects) at the cursor.
|
|
126
|
+
*/
|
|
127
|
+
insertContent(content: string | Record<string, any>): DhwaniTiptapEditorChain;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Runs and executes the chained transactions.
|
|
131
|
+
*/
|
|
132
|
+
run(): boolean;
|
|
133
|
+
|
|
134
|
+
[key: string]: any;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Registry configuration structure for custom Page Extensions.
|
|
139
|
+
*/
|
|
140
|
+
interface PageExtensionConfig {
|
|
141
|
+
/**
|
|
142
|
+
* Unique identifier matching the Tiptap node view name.
|
|
143
|
+
*/
|
|
144
|
+
name: string;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Tiptap Node extension instance.
|
|
148
|
+
*/
|
|
149
|
+
tiptapExtension: any;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Slash commands registry configuration.
|
|
153
|
+
*/
|
|
154
|
+
slashCommand: {
|
|
155
|
+
/**
|
|
156
|
+
* Heading title inside the dropdown.
|
|
157
|
+
*/
|
|
158
|
+
title: string;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Sub-text details describing the action.
|
|
162
|
+
*/
|
|
163
|
+
description: string;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Inline SVG markup string for the command icon.
|
|
167
|
+
*/
|
|
168
|
+
icon: string;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Callback fired when selected from the dropdown list.
|
|
172
|
+
*/
|
|
173
|
+
command: (editor: DhwaniTiptapEditor, range?: { from: number; to: number }) => void;
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
declare namespace Dhwani {
|
|
178
|
+
/**
|
|
179
|
+
* Registers a custom page extension and slash command in the Dhwani editor workspace.
|
|
180
|
+
*/
|
|
181
|
+
export function registerPageExtension(config: PageExtensionConfig): void;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
interface Window {
|
|
185
|
+
DhwaniEditorSDK: typeof DhwaniEditorSDK;
|
|
186
|
+
Dhwani: typeof Dhwani;
|
|
187
|
+
React: typeof import("react");
|
|
188
|
+
ReactDOM: typeof import("react-dom");
|
|
189
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dhwaniapp/plugin-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Software Development Kit (SDK) and manifest schemas for building Dhwani Note Taking plugins.",
|
|
5
|
+
"main": "",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"index.d.ts",
|
|
9
|
+
"plugin-manifest.schema.json"
|
|
10
|
+
],
|
|
11
|
+
"author": "Dhwani Team",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"dhwani",
|
|
15
|
+
"plugin",
|
|
16
|
+
"sdk",
|
|
17
|
+
"tiptap",
|
|
18
|
+
"electron"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "DhwaniPluginManifest",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"description": "Manifest schema for Dhwani Note Taking plugins",
|
|
6
|
+
"properties": {
|
|
7
|
+
"$schema": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "Path or URL to the plugin manifest schema file"
|
|
10
|
+
},
|
|
11
|
+
"display_name": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"description": "The user-facing display name of the plugin",
|
|
14
|
+
"minLength": 1
|
|
15
|
+
},
|
|
16
|
+
"system_name": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "Unique system identifier for the plugin. Can only contain alphanumeric characters and dots (.)",
|
|
19
|
+
"pattern": "^[a-zA-Z0-9\\.]+$"
|
|
20
|
+
},
|
|
21
|
+
"version": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"description": "Semantic version number of the plugin (e.g. '1.0.0')",
|
|
24
|
+
"pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
|
|
25
|
+
},
|
|
26
|
+
"description": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"description": "Brief description of what the plugin does"
|
|
29
|
+
},
|
|
30
|
+
"author": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"description": "The author or organization who developed the plugin"
|
|
33
|
+
},
|
|
34
|
+
"license": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"description": "Software license for the plugin (e.g., 'MIT', 'GPL-3.0')"
|
|
37
|
+
},
|
|
38
|
+
"permissions_required": {
|
|
39
|
+
"type": "array",
|
|
40
|
+
"description": "List of system permissions requested by the plugin",
|
|
41
|
+
"uniqueItems": true,
|
|
42
|
+
"items": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"enum": ["use_page_extention"],
|
|
45
|
+
"description": "System permissions available in Dhwani"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"icon_in_svg": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"description": "Relative path to the plugin's main SVG icon inside the ZIP package (e.g. 'assets/icon.svg')"
|
|
51
|
+
},
|
|
52
|
+
"extentions": {
|
|
53
|
+
"type": "array",
|
|
54
|
+
"description": "List of editor extensions provided by this plugin",
|
|
55
|
+
"items": {
|
|
56
|
+
"type": "object",
|
|
57
|
+
"required": [
|
|
58
|
+
"type",
|
|
59
|
+
"extention_file",
|
|
60
|
+
"extention_svg_icon",
|
|
61
|
+
"extention_display_name"
|
|
62
|
+
],
|
|
63
|
+
"properties": {
|
|
64
|
+
"type": {
|
|
65
|
+
"type": "string",
|
|
66
|
+
"enum": ["page"],
|
|
67
|
+
"description": "Type of editor extension (currently only 'page' is supported)"
|
|
68
|
+
},
|
|
69
|
+
"extention_file": {
|
|
70
|
+
"type": "string",
|
|
71
|
+
"description": "Relative path to the compiled JavaScript asset file (e.g., 'dist/tip-callout.js')"
|
|
72
|
+
},
|
|
73
|
+
"extention_svg_icon": {
|
|
74
|
+
"type": "string",
|
|
75
|
+
"description": "Relative path to the extension's icon inside the ZIP package (e.g., 'assets/tip.svg')"
|
|
76
|
+
},
|
|
77
|
+
"extention_display_name": {
|
|
78
|
+
"type": "string",
|
|
79
|
+
"description": "User-facing label for the slash command / extension"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"required": [
|
|
86
|
+
"display_name",
|
|
87
|
+
"system_name",
|
|
88
|
+
"version",
|
|
89
|
+
"author",
|
|
90
|
+
"license",
|
|
91
|
+
"permissions_required"
|
|
92
|
+
]
|
|
93
|
+
}
|