Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2a37a9f
Initial commit with boilerplate
boris0301 Jul 9, 2024
abd78fb
feat: readme updated
boris0301 Jul 9, 2024
b8e1821
feat: add-ons menu added
boris0301 Jul 24, 2024
6af1aed
feat: implemented ui updates and new features
boris0301 Jul 31, 2024
55d6a59
fix: unused import removed
boris0301 Jul 31, 2024
55e6451
feat: added diagram preview and edit functionality
boris0301 Aug 6, 2024
f786750
fix: link errors fixed
boris0301 Aug 6, 2024
a715300
fix: added test deploymnen option
boris0301 Aug 8, 2024
b01a2cb
fix: tsconfix fix
boris0301 Aug 8, 2024
28cbf4d
fix: button styles ported to css modules
boris0301 Aug 13, 2024
c625dfb
fix: sidebar and button fixes
boris0301 Aug 14, 2024
289b4ec
fix: removed integration test gh action
boris0301 Aug 14, 2024
be013a5
fix: edit dialog fix and alerts added
boris0301 Aug 15, 2024
0fcf8bb
MC-3915 Update the UI and added Edit and delete functionality for the…
Almoizs-1310 Dec 5, 2025
97cd824
Fix lint issue
Almoizs-1310 Dec 5, 2025
f50c691
increased dialog size and updated the loading state for the diagrams
Almoizs-1310 Dec 9, 2025
a1d1b83
Fix lint issue
Almoizs-1310 Dec 9, 2025
e08dc67
Added loader for better visuability
Almoizs-1310 Dec 11, 2025
34510db
Fix the issue where large diagrams were not able to get inserted into…
Almoizs-1310 Dec 11, 2025
59304c5
updated the project with new scriptId and new version
Almoizs-1310 Dec 17, 2025
582ab53
Added utm params in logic flow and integrated mixpanel to trace user …
Almoizs-1310 Dec 29, 2025
1e15901
Improved the Performance for inserting diagram and added proper Analy…
Almoizs-1310 Jan 21, 2026
a0549fa
Updated the UI for docs Plugin
Almoizs-1310 Jan 28, 2026
d16f48c
update the menu items as per user login state
Almoizs-1310 Feb 6, 2026
2846824
Fix the issue where menu-items were not loading
Almoizs-1310 Feb 11, 2026
034edc3
updates the desigh of the google-docs plugin as per the new figma design
Almoizs-1310 Mar 5, 2026
d16ed65
Removed unwanted icon
Almoizs-1310 Mar 5, 2026
fd59d86
update the UI as per the Figma design
Almoizs-1310 Mar 11, 2026
8d8f49d
Added loader state for the recent sections
Almoizs-1310 Mar 11, 2026
d6cc117
resolv the insert diagrma issue when sidebar is closed
Prashant-7718 Jun 10, 2026
a41fdcc
resolve lint issues
Prashant-7718 Jun 10, 2026
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
5 changes: 5 additions & 0 deletions .clasp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"scriptId": "1IzIEW1uGP4WWdowrlYyNEwhasdXObby_Lik-xwRXn3uWFUitm19SHAhU",
"rootDir": "dist",
"parentId": ["1NVNWs4Wdj2ib6hhPgq1kzA-BMtydvk_SnxoK1K2yX5o"]
}
7 changes: 7 additions & 0 deletions .clasp.json.SAMPLE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"rootDir": "dist",
"scriptId": "...add scriptId here...",
"parentId": [
"...spreadsheet/doc url ID here..."
]
}
2 changes: 2 additions & 0 deletions .claspignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
main.js
*-impl.html
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/dist
/node_modules

tailwind.config.js
vite.config.ts
26 changes: 26 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"extends": [
"plugin:prettier/recommended",
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"plugins": ["prettier", "googleappsscript"],
"env": {
"googleappsscript/googleappsscript": true
},
"rules": {
"prettier/prettier": "error",
"camelcase": "warn",
"prefer-object-spread": "warn"
},
"ignorePatterns": ["dist", ".eslintrc.json"],
"settings": {
"import/resolver": {
"node": {
"extensions": [".js", ".ts"]
}
}
}
}
18 changes: 18 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Lint

on: [push, pull_request]

jobs:
lint:
runs-on: macos-13
timeout-minutes: 8
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install packages
run: yarn install
- name: Run lint
run: yarn lint
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# npm
node_modules

# clasp files
creds.json

# certs
*.pem
certs/

# build
dist/

# mac
.DS_Store

#secret
.env
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/gallium
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "es5"
}
17 changes: 17 additions & 0 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"rules": {
"at-rule-no-unknown": [
true,
{
"ignoreAtRules": [
"extends",
"apply",
"tailwind",
"components",
"utilities",
"screen"
]
}
]
}
}
21 changes: 21 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch spreadsheet with debugger",
"trace": true,
"sourceMaps": true,
"pauseForSourceMap": false,
"skipFiles": ["**/node_modules/**", "!${workspaceFolder}/**"],
"webRoot": "${workspaceFolder}/src/client",
// Need random open port for logging into spreadsheets:
// https://github.com/microsoft/vscode-js-debug/issues/918
"port": 12345
}
]
}
12 changes: 12 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"json.schemas": [
{
"fileMatch": ["appsscript.json"],
"url": "http://json.schemastore.org/appsscript"
},
{
"fileMatch": [".clasp.json"],
"url": "http://json.schemastore.org/clasp"
}
]
}
194 changes: 194 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
## 🚜 Install <a name = "install"></a>

These instructions will get you set up with a copy of the React project code on your local machine. It will also get you logged in to `clasp`, which lets you manage script projects from the command line.

See [deploy](#deploy) for notes on how to deploy the project and see it live in a Google Docs.

### Prerequisites <a name = "prerequisites"></a>

- Make sure you're running at least [Node.js](https://nodejs.org/en/download/) v18 and [yarn (classic)](https://classic.yarnpkg.com/lang/en/docs/install/).

- You'll need to enable the Google Apps Script API. You can do that by visiting [script.google.com/home/usersettings](https://script.google.com/home/usersettings).

- To use live reload while developing, you'll need to serve your files locally using HTTPS. See [local development](#local-development) below for instructions on setting up your local environment.

### 🏁 Getting started <a name = "getting-started"></a>

**1.** First, let's clone the repo and install the dependencies. This project is published as a public template, so you can also fork the repo or select "Use this template" in GitHub.

```bash
git clone https://github.com/Mermaid-Chart/google-plugin.git
cd google-plugin
yarn install
```

**2.** Next, we'll need to log in to [clasp](https://github.com/google/clasp), which lets us manage our Google Apps Script projects locally.

```bash
yarn run login
```

**3.** Now let's run the setup script to create a New document and script project from the command line.

```bash
yarn run setup
```

Alternatively, you can use an existing Google document and Script file instead of creating a new one.

<details>
<summary>See instructions here for using an existing project.</summary>

You will need to update the `.clasp.json` file in the root of this project with the following three key/value pairs (see .clasp.json.SAMPLE for reference):

```json
{
"scriptId": "1PY037hPcy................................................",
"parentId": ["1Df30......................................."],
"rootDir": "./dist"
}
```

- `scriptId`: Your existing script project's `scriptId`. You can find it by opening your document, selecting **Tools > Script Editor** from the menubar, then **File > Project properties**, and it will be listed as "Script ID".

- `parentId`: An array with a single string, the ID of the parent file (document, doc, etc.) that the script project is bound to. You can get this ID from the url, where the format is usually `https://docs.google.com/documents/d/{id}/edit`. This allows you to run `npm run open` and open your file directly from the command line.

- `rootDir`: This should always be `"./dist"`, i.e. the local build folder that is used to store project files.

</details>

<br/>

## 🚀 Deploy <a name = "deploy"></a>

Run the deploy command. You may be prompted to update your manifest file. Type 'yes'.

```bash
yarn run deploy
```

The deploy command will build all necessary files using production settings, including all server code (Google Apps Script code), client code (React bundle), and config files. All bundled files will be outputted to the `dist/` folder, then pushed to the Google Apps Script project.

Now open Google Docs and navigate to your new document (e.g. the file "My React Project"). You can also run `yarn run open`. Make sure to refresh the page if you already had it open. You will now see a new menu item appear containing your app!

<br/>

## 🎈 Local Development <a name="local-development"></a>

We can develop our client-side React apps locally, and see our changes directly inside our Google document dialog window.

There are two steps to getting started: installing a certificate (first time only), and running the start command.

1. Generating a certificate for local development <a name = "generatingcerts"></a>

Install the mkcert package:

```bash
# mac:
brew install mkcert

# windows:
choco install mkcert
```

[More install options here.](https://github.com/FiloSottile/mkcert#installation)

Then run the mkcert install script:

```bash
mkcert -install
```

Create the certs in your repo:

```
yarn run setup:https
```

2. Now you're ready to start:
```bash
yarn run start
```

The start command will create and deploy a development build, and serve your local files.

After running the start command, navigate to your document and open one of the menu items. It should now be serving your local files. When you make and save changes to your React app, your app will reload instantly within the Google Docs, and have access to any server-side functions!

<br/>

### Typescript

This project is built mainly with typescript but also supports Javascript, and examples of both are included here, both in server-side and client-side (React) code. The included sample app has a typescript example using the Bootstrap component library.

To use typescript, simply use a typescript extension in either the client code (.ts/.tsx) or the server code (.ts), and your typescript file will compile to the proper format.

To use typescript in server code, just change the file extension to .ts. The server-side code already utilizes type definitions for Google Apps Script APIs.

A basic typescript configuration is used here that correctly transpiles to code that is compatible with Google Apps Script. However, if you want more control over your setup you can modify the included [tsconfig.json file](./tsconfig.json).

### Adding packages

You can add packages to your client-side React app.

For instance, install `react-transition-group`:

```bash
yarn add react-transition-group
```

Important: Since Google Apps Scripts projects don't let you easily reference external files, this project will bundle an entire app into one HTML file. If you are importing large libraries this can result in a large file. To help reduce the size of these large HTML files, you can try to externalize packages by using a CDN to load packages. For packages that can be loaded through a CDN (usually they will have a UMD build), you can configure the externals and globals details in the [vite config file](./vite.config.ts). You will also need to include a script element in the head of the `index.html` file, loading the library from a CDN, and making sure it supports a UMD build, e.g.
`<script crossorigin src="https://unpkg.com/react-transition-group@4.4.2/dist/react-transition-group.min.js"></script>`.

If set up properly, this will load packages from the CDN in production and will reduce your overall bundle size.

Make sure that you update the script tag with the same version of the package you are installing with yarn, so that you are using the same version in development and production.

### Styles

By default this project supports global CSS stylesheets. Make sure to import your stylesheet in your entrypoint file [index.js](./src/client/dialog-demo/index.js):

```javascript
import './styles.css';
```

Many external component libraries require a css stylesheet in order to work properly. You can import stylesheets in the HTML template, [as shown here with the Bootstrap stylesheet](./src/client/dialog-demo-bootstrap/index.html).

### Modifying scopes

The included app only requires access to Google documents and to loading dialog windows. If you make changes to the app's requirements, for instance, if you modify this project to work with Google Forms or Docs, make sure to edit the oauthScopes in the [appscript.json file](./appsscript.json).

See https://developers.google.com/apps-script/manifest for information on the `appsscript.json` structure.

### Calling server-side Google Apps Script functions

This project uses the [gas-client](https://github.com/enuchi/gas-client) package to more easily call server-side functions using promises.

```js
// Google's client-side google.script.run utility requires calling server-side functions like this:
google.script.run
.withSuccessHandler((response) => doSomething(response))
.withFailureHandler((err) => handleError(err))
.addSheet(sheetTitle);

// Using gas-client we can use more familiar promises style like this:
import Server from 'gas-client';
const { serverFunctions } = new Server();

// We now have access to all our server functions, which return promises!
serverFunctions
.addSheet(sheetTitle)
.then((response) => doSomething(response))
.catch((err) => handleError(err));

// Or with async/await:
async () => {
try {
const response = await serverFunctions.addSheet(sheetTitle);
doSomething(response);
} catch (err) {
handleError(err);
}
};
```

In development, `gas-client` will allow you to call server-side functions from your local environment. In production, it will use Google's underlying `google.script.run` utility.
19 changes: 19 additions & 0 deletions appsscript.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"timeZone": "America/New_York",
"dependencies": {
"libraries": [
{
"userSymbol": "OAuth2",
"version": "43",
"libraryId": "1B7FSrk5Zi6L1rSxxTDgDEUsPzlukDsi4KGuTMorsTQHhGBzBkMun4iDF"
}
]
},
"exceptionLogging": "STACKDRIVER",
"oauthScopes": [
"https://www.googleapis.com/auth/script.container.ui",
"https://www.googleapis.com/auth/script.external_request",
"https://www.googleapis.com/auth/documents.currentonly"
],
"runtimeVersion": "V8"
}
Loading