Mattermost plugin first commit
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
.eslintcache
|
||||
junit.xml
|
||||
node_modules
|
||||
@@ -0,0 +1 @@
|
||||
{}
|
||||
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"name": "silverbullet-mattermost-plugin",
|
||||
"private": true,
|
||||
"author": {
|
||||
"name": "Zef Hemel",
|
||||
"email": "zef@zef.me"
|
||||
},
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"watch": "rm -rf .parcel-cache && parcel watch",
|
||||
"build": "parcel build",
|
||||
"clean": "rm -rf dist"
|
||||
},
|
||||
"targets": {
|
||||
"plugin": {
|
||||
"source": [
|
||||
"src/index.tsx"
|
||||
],
|
||||
"distDir": "dist",
|
||||
"context": "browser"
|
||||
}
|
||||
},
|
||||
"alias": {
|
||||
"react": "./src/hack.js",
|
||||
"react/jsx-runtime": "react/jsx-runtime"
|
||||
},
|
||||
"dependencies": {
|
||||
"@codemirror/autocomplete": "6.0.1",
|
||||
"@codemirror/commands": "6.0.0",
|
||||
"@codemirror/lang-javascript": "6.0.0",
|
||||
"@codemirror/lang-markdown": "6.0.0",
|
||||
"@codemirror/language": "6.0.0",
|
||||
"@codemirror/legacy-modes": "6.0.0",
|
||||
"@codemirror/search": "6.0.0",
|
||||
"@codemirror/state": "6.0.0",
|
||||
"@codemirror/view": "6.0.0",
|
||||
"@fortawesome/fontawesome-svg-core": "1.3.0",
|
||||
"@fortawesome/free-solid-svg-icons": "6.0.0",
|
||||
"@fortawesome/react-fontawesome": "0.1.17",
|
||||
"@jest/globals": "^27.5.1",
|
||||
"@lezer/highlight": "1.0.0",
|
||||
"@lezer/markdown": "1.0.1",
|
||||
"fake-indexeddb": "^3.1.7",
|
||||
"fuzzysort": "^1.9.0",
|
||||
"jest": "^27.5.1",
|
||||
"knex": "^1.0.4",
|
||||
"react": "17.0.2",
|
||||
"react-dom": "17.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@parcel/packager-raw-url": "2.5.0",
|
||||
"@parcel/service-worker": "2.5.0",
|
||||
"@parcel/transformer-inline-string": "2.5.0",
|
||||
"@parcel/transformer-sass": "2.5.0",
|
||||
"@parcel/transformer-webmanifest": "2.5.0",
|
||||
"@parcel/validator-typescript": "2.5.0",
|
||||
"@types/cors": "^2.8.12",
|
||||
"@types/events": "^3.0.0",
|
||||
"@types/jest": "^27.4.1",
|
||||
"@types/react": "17.0.2",
|
||||
"@types/react-dom": "17.0.2",
|
||||
"assert": "^2.0.0",
|
||||
"nodemon": "^2.0.18",
|
||||
"parcel": "2.5.0",
|
||||
"prettier": "^2.5.1",
|
||||
"typescript": "^4.6.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default window.React;
|
||||
const { useEffect, useRef } = window.React;
|
||||
export { useEffect, useRef };
|
||||
@@ -0,0 +1,63 @@
|
||||
import manifest from "./manifest";
|
||||
import React, { useEffect, useRef } from "react";
|
||||
import { Editor } from "@silverbulletmd/web/editor";
|
||||
import { HttpSpacePrimitives } from "@silverbulletmd/common/spaces/http_space_primitives";
|
||||
import { safeRun } from "@plugos/plugos/util";
|
||||
import { Space } from "@silverbulletmd/common/spaces/space";
|
||||
|
||||
import "../../../packages/web/styles/main.scss";
|
||||
import "./styles.scss";
|
||||
|
||||
function loadSheet(file: string) {
|
||||
var sbCSS = document.createElement("link");
|
||||
sbCSS.rel = "stylesheet";
|
||||
sbCSS.type = "text/css";
|
||||
sbCSS.href = `/static/plugins/silverbullet/${file}`;
|
||||
document.getElementsByTagName("head")[0].appendChild(sbCSS);
|
||||
}
|
||||
|
||||
const MainApp = (): React.ReactElement => {
|
||||
let ref = useRef<HTMLDivElement>(null);
|
||||
useEffect(() => {
|
||||
loadSheet("index.css");
|
||||
|
||||
safeRun(async () => {
|
||||
let httpPrimitives = new HttpSpacePrimitives("/plugins/silverbullet", "");
|
||||
const editor = new Editor(
|
||||
new Space(httpPrimitives, true),
|
||||
ref.current!,
|
||||
"/plugins/silverbullet"
|
||||
);
|
||||
await editor.init();
|
||||
});
|
||||
}, []);
|
||||
return (
|
||||
<div id="sb-root" ref={ref}>
|
||||
This is Silver Bullet
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default class Plugin {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
|
||||
public async initialize(registry: any, store: any) {
|
||||
// @see https://developers.mattermost.com/extend/plugins/webapp/reference/
|
||||
console.log("SUP YALL SILVER BULLET!!!");
|
||||
|
||||
registry.registerProduct(
|
||||
"/plugins/silverbullet",
|
||||
"product-boards",
|
||||
"Silver Bullet",
|
||||
"/plugins/silverbullet",
|
||||
MainApp
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
registerPlugin(id: string, plugin: Plugin): void;
|
||||
}
|
||||
}
|
||||
|
||||
window.registerPlugin(manifest.id, new Plugin());
|
||||
@@ -0,0 +1,5 @@
|
||||
import manifest from '../../plugin.json';
|
||||
|
||||
export default manifest;
|
||||
export const id = manifest.id;
|
||||
export const version = manifest.version;
|
||||
Reference in New Issue
Block a user