Skip to content

feat: add excalidraw support #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions server/plugins/com.msgbyte.excalidraw/.ministarrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const path = require('path');

module.exports = {
externalDeps: [
'react',
'react-router',
'axios',
'styled-components',
'zustand',
'zustand/middleware/immer',
],
pluginRoot: path.resolve(__dirname, './web'),
outDir: path.resolve(__dirname, '../../public'),
};
26 changes: 26 additions & 0 deletions server/plugins/com.msgbyte.excalidraw/models/excalidraw.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { db } from 'tailchat-server-sdk';
const { getModelForClass, prop, modelOptions, TimeStamps } = db;

@modelOptions({
options: {
customName: 'p_excalidraw',
},
})
export class Excalidraw extends TimeStamps implements db.Base {
_id: db.Types.ObjectId;
id: string;

@prop()
userId: string;

@prop()
dataState: Record<string, any>;
}

export type ExcalidrawDocument = db.DocumentType<Excalidraw>;

const model = getModelForClass(Excalidraw);

export type ExcalidrawModel = typeof model;

export default model;
20 changes: 20 additions & 0 deletions server/plugins/com.msgbyte.excalidraw/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "tailchat-plugin-excalidraw",
"version": "1.0.0",
"main": "index.js",
"author": "moonrailgun",
"description": "Add excalidraw support in Tailchat",
"license": "MIT",
"private": true,
"scripts": {
"build:web": "ministar buildPlugin all",
"build:web:watch": "ministar watchPlugin all"
},
"devDependencies": {
"@types/react": "18.0.20",
"mini-star": "*"
},
"dependencies": {
"tailchat-server-sdk": "*"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { TcService, TcDbService } from 'tailchat-server-sdk';
import type { ExcalidrawDocument, ExcalidrawModel } from '../models/excalidraw';

/**
* Excalidraw
*
* Add excalidraw support in Tailchat
*/
interface ExcalidrawService
extends TcService,
TcDbService<ExcalidrawDocument, ExcalidrawModel> {}
class ExcalidrawService extends TcService {
get serviceName() {
return 'plugin:com.msgbyte.excalidraw';
}

onInit() {
this.registerLocalDb(require('../models/excalidraw').default);
}
}

export default ExcalidrawService;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"label": "Excalidraw",
"name": "com.msgbyte.excalidraw",
"url": "{BACKEND}/plugins/com.msgbyte.excalidraw/index.js",
"version": "0.0.0",
"author": "moonrailgun",
"description": "Add excalidraw support in Tailchat",
"requireRestart": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@plugins/com.msgbyte.excalidraw",
"main": "src/index.tsx",
"version": "0.0.0",
"description": "Add excalidraw support in Tailchat",
"private": true,
"scripts": {
"sync:declaration": "tailchat declaration github"
},
"dependencies": {
"@excalidraw/excalidraw": "^0.15.2"
},
"devDependencies": {
"@types/styled-components": "^5.1.26",
"react": "18.2.0",
"styled-components": "^5.3.6"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';
import { Excalidraw } from '@excalidraw/excalidraw';

export const ExcalidrawRender: React.FC = React.memo(() => {
return (
<div style={{ height: '100%', width: '100%' }}>
<Excalidraw initialData={{ elements: [] }} />
</div>
);
});
ExcalidrawRender.displayName = 'ExcalidrawRender';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('Plugin Excalidraw is loaded');
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"compilerOptions": {
"esModuleInterop": true,
"jsx": "react",
"importsNotUsedAsValues": "error"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare module '@capital/common';
declare module '@capital/component';