Skip to content
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

feat: add poll shape to Tldraw #15

Closed
wants to merge 18 commits into from
Closed
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
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
require('ts-node/register')
module.exports = require('./scripts/lib/eslint-plugin.ts')

module.exports = {
extends: [
'prettier',
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ jobs:
build:
name: 'Build and run checks'
timeout-minutes: 15
runs-on: ubuntu-latest-16-cores-open # TODO: this should probably run on multiple OSes
runs-on: ubuntu-latest # TODO: this should probably run on multiple OSes

steps:
- name: Check out code
2 changes: 1 addition & 1 deletion .github/workflows/playwright-update-snapshots.yml
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ jobs:
update_snapshots:
name: 'Run'
timeout-minutes: 60
runs-on: ubuntu-latest-16-cores-open
runs-on: ubuntu-22.04
if: github.event.label.name == 'update-snapshots'

permissions:
29 changes: 27 additions & 2 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ jobs:
build:
name: 'End to end tests'
timeout-minutes: 60
runs-on: ubuntu-latest-16-cores-open
runs-on: ubuntu-22.04

steps:
- name: Check out code
@@ -37,6 +37,20 @@ jobs:
- name: Install dependencies
run: yarn

- name: Run script to generate CSS
run: |
echo "Current directory: $(pwd)"
node packages/tldraw/scripts/copy-css-files.mjs

- name: Verify CSS file exists
run: |
if [ -f packages/tldraw/tldraw.css ]; then
echo "CSS file exists"
else
echo "CSS file is missing"
exit 1
fi

- name: Get installed Playwright version
id: playwright-version
run: |
@@ -56,8 +70,19 @@ jobs:
run: npx playwright install --with-deps chromium chrome
if: steps.playwright-cache.outputs.cache-hit != 'true'

- name: Start the development server
run: yarn dev &
working-directory: apps/examples

- name: Wait for server to be ready
run: |
for i in `seq 1 30`; do
curl --silent http://localhost:5420 && break
sleep 1
done

- name: Run Playwright tests
run: 'yarn e2e'
run: 'xvfb-run yarn e2e'
working-directory: apps/examples

- uses: actions/upload-artifact@v3
10 changes: 6 additions & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

# if the folder we're in is called bublic, it means we're a submodule in the brivate repo.
# If the folder we're in is called bublic, it means we're a submodule in the private repo.
# We need to grab .envrc to set up yarn correctly.
current_file="$(readlink -f "$0")"
if [[ $current_file == */bublic/.husky/pre-commit ]]; then
source "$(dirname -- "$0")/../../.envrc"
fi
case "$current_file" in
*/bublic/.husky/pre-commit)
. "$(dirname -- "$0")/../../.envrc"
;;
esac

npx lazy run build-api
git add packages/*/api-report.md
10 changes: 6 additions & 4 deletions apps/examples/e2e/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -16,13 +16,13 @@ const config: PlaywrightTestConfig = {
globalSetup: './global-setup.ts',
globalTeardown: './global-teardown.ts',
/* Maximum time one test can run for. */
timeout: 30 * 1000,
timeout: 60 * 1000,
expect: {
/**
* Maximum time expect() should wait for the condition to be met.
* For example in `await expect(locator).toHaveText();`
*/
timeout: 2000,
timeout: 5000,
toHaveScreenshot: {
maxDiffPixelRatio: 0.001,
threshold: 0.01,
@@ -39,7 +39,7 @@ const config: PlaywrightTestConfig = {
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
actionTimeout: 0,
actionTimeout: 10000,
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://localhost:5420',

@@ -100,8 +100,10 @@ const config: PlaywrightTestConfig = {
webServer: {
command: 'yarn dev',
port: 5420,
reuseExistingServer: !process.env.CI,
// reuseExistingServer: !process.env.CI,
reuseExistingServer: true,
cwd: path.join(__dirname, '../../..'),
timeout: 120 * 1000,
},
}

32 changes: 16 additions & 16 deletions apps/examples/src/examples/ZonesExample.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import { OfflineIndicator, Tldraw } from '@bigbluebutton/tldraw'
import { Tldraw } from '@bigbluebutton/tldraw'
import '@bigbluebutton/tldraw/tldraw.css'

export default function Example() {
return (
<div className="tldraw__editor">
<Tldraw topZone={<OfflineIndicator />} shareZone={<CustomShareZone />} />
<Tldraw />
</div>
)
}

function CustomShareZone() {
return (
<div
style={{
backgroundColor: 'thistle',
width: '100%',
textAlign: 'center',
minWidth: '80px',
}}
>
<p>Share Zone</p>
</div>
)
}
// function CustomShareZone() {
// return (
// <div
// style={{
// backgroundColor: 'thistle',
// width: '100%',
// textAlign: 'center',
// minWidth: '80px',
// }}
// >
// <p>Share Zone</p>
// </div>
// )
// }
6 changes: 2 additions & 4 deletions apps/examples/src/index.tsx
Original file line number Diff line number Diff line change
@@ -3,9 +3,8 @@ import {
DefaultErrorFallback,
ErrorBoundary,
setDefaultEditorAssetUrls,
setDefaultUiAssetUrls,
} from '@bigbluebutton/tldraw'
import { StrictMode } from 'react'
import React, { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { RouterProvider, createBrowserRouter } from 'react-router-dom'

@@ -49,12 +48,11 @@ import YjsExample from './examples/yjs/YjsExample'
// top-level so assets don't need to be passed down in every single example.
const assetUrls = getAssetUrlsByMetaUrl()
setDefaultEditorAssetUrls(assetUrls)
setDefaultUiAssetUrls(assetUrls)

type Example = {
path: string
title?: string
element: JSX.Element
element: React.JSX.Element
}

export const allExamples: Example[] = [
4 changes: 2 additions & 2 deletions apps/vscode/editor/src/ChangeResponder.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
debounce,
parseAndLoadDocument,
// parseAndLoadDocument,
serializeTldrawJson,
useDefaultHelpers,
useEditor,
@@ -28,7 +28,7 @@ export const ChangeResponder = () => {
// break
// }
case 'vscode:revert': {
parseAndLoadDocument(editor, message.data.fileContents, msg, addToast)
// parseAndLoadDocument(editor, message.data.fileContents, msg, addToast)
break
}
}
37 changes: 18 additions & 19 deletions apps/vscode/editor/src/FileOpen.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { parseAndLoadDocument, useDefaultHelpers, useEditor } from '@bigbluebutton/tldraw'
import { useDefaultHelpers, useEditor } from '@bigbluebutton/tldraw'
import React from 'react'
import { vscode } from './utils/vscode'

export function FileOpen({
fileContents,
@@ -15,25 +14,25 @@ export function FileOpen({

React.useEffect(() => {
if (isFileLoaded) return
function onV1FileLoad() {
vscode.postMessage({
type: 'vscode:v1-file-opened',
data: {
description: msg('vscode.file-open.desc'),
backup: msg('vscode.file-open.backup'),
backupSaved: msg('vscode.file-open.backup-saved'),
backupFailed: msg('vscode.file-open.backup-failed'),
dontAskAgain: msg('vscode.file-open.dont-show-again'),
open: msg('vscode.file-open.open'),
},
})
}
// function onV1FileLoad() {
// vscode.postMessage({
// type: 'vscode:v1-file-opened',
// data: {
// description: msg('vscode.file-open.desc'),
// backup: msg('vscode.file-open.backup'),
// backupSaved: msg('vscode.file-open.backup-saved'),
// backupFailed: msg('vscode.file-open.backup-failed'),
// dontAskAgain: msg('vscode.file-open.dont-show-again'),
// open: msg('vscode.file-open.open'),
// },
// })
// }

async function loadFile() {
await parseAndLoadDocument(editor, fileContents, msg, addToast, onV1FileLoad, forceDarkMode)
}
// async function loadFile() {
// await parseAndLoadDocument(editor, fileContents, msg, addToast, onV1FileLoad, forceDarkMode)
// }

loadFile()
// loadFile()
setIsFileLoaded(true)
return () => {
clearToasts()
2 changes: 1 addition & 1 deletion apps/vscode/extension/package.json
Original file line number Diff line number Diff line change
@@ -136,7 +136,7 @@
"process": "^0.11.10",
"ts-loader": "^9.2.5",
"tslib": "^2.4.0",
"tsx": "^3.12.7",
"tsx": "4.17.0",
"vsce": "^2.15.0"
},
"gitHead": "4b1137849ad07da36fc8f0f19cb64e7535a79296",
7 changes: 6 additions & 1 deletion assets/translations/de.json
Original file line number Diff line number Diff line change
@@ -306,5 +306,10 @@
"cursor-chat.type-to-chat": "Tippen, um zu chatten...",
"geo-style.cloud": "Wolke",
"tool.cloud": "Wolke",
"action.unlock-all": "Alle entsperren"
"action.unlock-all": "Alle entsperren",
"app.poll.t": "Richtig",
"app.poll.f": "Falsch",
"app.poll.y": "Ja",
"app.poll.n": "Nein",
"app.poll.abstention": "Enthaltung"
}
7 changes: 6 additions & 1 deletion assets/translations/main.json
Original file line number Diff line number Diff line change
@@ -351,5 +351,10 @@
"vscode.file-open.backup-saved": "Backup saved",
"vscode.file-open.backup-failed": "Backup failed: this is not a .tldr file.",
"vscode.file-open.dont-show-again": "Don't ask again",
"cursor-chat.type-to-chat": "Type to chat..."
"cursor-chat.type-to-chat": "Type to chat...",
"app.poll.t": "True",
"app.poll.f": "False",
"app.poll.y": "Yes",
"app.poll.n": "No",
"app.poll.abstention": "Abstention"
}
7 changes: 6 additions & 1 deletion assets/translations/pt-br.json
Original file line number Diff line number Diff line change
@@ -329,5 +329,10 @@
"vscode.file-open.backup-saved": "Backup salvo",
"vscode.file-open.backup-failed": "Falha no backup: este não é um arquivo .tldr.",
"vscode.file-open.dont-show-again": "Não perguntar novamente",
"cursor-chat.type-to-chat": "Digite para conversar..."
"cursor-chat.type-to-chat": "Digite para conversar...",
"app.poll.t": "Verdadeiro",
"app.poll.f": "Falso",
"app.poll.y": "Sim",
"app.poll.n": "Não",
"app.poll.abstention": "Abstenção"
}
7 changes: 6 additions & 1 deletion assets/translations/zh-cn.json
Original file line number Diff line number Diff line change
@@ -349,5 +349,10 @@
"status.offline": "离线",
"status.online": "在线",
"action.remove-frame": "移除框架",
"action.fit-frame-to-content": "适合于内容"
"action.fit-frame-to-content": "适合于内容",
"app.poll.t": "正确",
"app.poll.f": "错误",
"app.poll.y": "是",
"app.poll.n": "否",
"app.poll.abstention": "无法作答"
}
Loading