diff --git a/.changeset/silver-spies-change.md b/.changeset/silver-spies-change.md new file mode 100644 index 000000000..9fbe90fd7 --- /dev/null +++ b/.changeset/silver-spies-change.md @@ -0,0 +1,5 @@ +--- +'tldraw-gitbook-block': minor +--- + +Add tldraw integration diff --git a/integrations/tldraw/.eslintrc.json b/integrations/tldraw/.eslintrc.json new file mode 100644 index 000000000..2486b4b2d --- /dev/null +++ b/integrations/tldraw/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": ["@gitbook/eslint-config/integration"] +} diff --git a/integrations/tldraw/README.md b/integrations/tldraw/README.md new file mode 100644 index 000000000..00dbd4d75 --- /dev/null +++ b/integrations/tldraw/README.md @@ -0,0 +1,3 @@ +# tldraw integration + +Add a tldraw shared project. \ No newline at end of file diff --git a/integrations/tldraw/assets/icon.png b/integrations/tldraw/assets/icon.png new file mode 100644 index 000000000..0c7b59e66 Binary files /dev/null and b/integrations/tldraw/assets/icon.png differ diff --git a/integrations/tldraw/gitbook-manifest.yaml b/integrations/tldraw/gitbook-manifest.yaml new file mode 100644 index 000000000..f71a20ffa --- /dev/null +++ b/integrations/tldraw/gitbook-manifest.yaml @@ -0,0 +1,21 @@ +name: tldraw +title: tldraw +organization: tldraw +visibility: public +icon: ./assets/icon.png +description: 'Add a tldraw project' +script: src/index.tsx +scopes: [] +blocks: + - id: tldraw-block + title: tldraw + description: Add a tldraw project. + urlUnfurl: + - https://tldraw.com/r/** + - https://tldraw.com/v/** + - https://tldraw.com/s/** + - https://www.tldraw.com/r/** + - https://www.tldraw.com/v/** + - https://www.tldraw.com/s/** + +secrets: {} diff --git a/integrations/tldraw/package.json b/integrations/tldraw/package.json new file mode 100644 index 000000000..dbe1ffbce --- /dev/null +++ b/integrations/tldraw/package.json @@ -0,0 +1,18 @@ +{ + "name": "tldraw-gitbook-block", + "private": true, + "version": "0.0.1", + "scripts": { + "lint": "eslint --ext .js,.jsx,.ts,.tsx .", + "typecheck": "tsc --noEmit", + "publish": "gitbook publish ." + }, + "dependencies": { + "@gitbook/runtime": "*" + }, + "devDependencies": { + "@gitbook/cli": "^0.13.1", + "@gitbook/eslint-config": "*", + "@gitbook/tsconfig": "*" + } +} diff --git a/integrations/tldraw/src/index.tsx b/integrations/tldraw/src/index.tsx new file mode 100644 index 000000000..b34e06993 --- /dev/null +++ b/integrations/tldraw/src/index.tsx @@ -0,0 +1,86 @@ +import { createIntegration, createComponent } from '@gitbook/runtime'; + +const tldrawBlock = createComponent<{ url: string }>({ + componentId: 'tldraw-block', + + async action(element, action: any) { + switch (action.action) { + case '@link.unfurl': { + const { url } = action; + return { + props: { + url, + }, + }; + } + } + + return element; + }, + + async render(element, context) { + const { url } = element.props; + + element.setCache({ maxAge: 1 }); + + return ( + + + } + onPress={{ + action: '@ui.modal.open', + componentId: 'tldraw-modal', + props: { + url, + }, + }} + buttons={[ +