-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Axel Boberg <[email protected]>
- Loading branch information
1 parent
a5be1db
commit 4f154ee
Showing
3 changed files
with
63 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Hello World example plugin | ||
This is an example plugin registering a 'Hello World widget' in the Bridge UI | ||
Copy the entire directory to Bridge's plugin path and restart Bridge to make it appear in the widget selection menu in the edit mode. | ||
|
||
**Tip: find the plugin path via the application's menu bar after you've started Bridge. Plugins > Manage Plugins...** |
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,44 @@ | ||
const bridge = require('bridge') | ||
|
||
/* | ||
The exported 'activate' function is the plugin's initialization function, | ||
it will be called when the plugin is loaded and every time a workspace | ||
is opened | ||
*/ | ||
exports.activate = async () => { | ||
/* | ||
Create a new widget by serving either a file | ||
or a string through Bridge's web server, | ||
this way Bridge will ensure that it's reachable | ||
within the desktop app as well as in browsers | ||
Use the stylesheet provided by Bridge | ||
to match the interface and automatically | ||
apply the current theme | ||
*/ | ||
const htmlPath = await bridge.server.serveString(` | ||
<html> | ||
<head> | ||
<title>My widget</title> | ||
<base href="/"></base> | ||
<link rel="stylesheet" href="${bridge.server.uris.STYLE_RESET}" /> | ||
</head> | ||
<body> | ||
Hello World | ||
</body> | ||
</html> | ||
`) | ||
|
||
/* | ||
Next, register a new widget | ||
This will make the widget appear | ||
in the Bridge interface | ||
*/ | ||
bridge.widgets.registerWidget({ | ||
id: 'bridge.plugins.helloWorld', | ||
name: 'Hello World', | ||
uri: htmlPath, | ||
description: 'Hello World widget' | ||
}) | ||
} |
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,14 @@ | ||
{ | ||
"name": "plugin-hello-world", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"engines": { | ||
"bridge": "^0.0.1" | ||
}, | ||
"author": "", | ||
"license": "ISC" | ||
} |