Skip to content

Commit

Permalink
feat!: save with rest
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin-Guillemin committed Jan 4, 2024
1 parent c7f38c0 commit fcaf682
Show file tree
Hide file tree
Showing 42 changed files with 2,906 additions and 6,054 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
VITE_BASE_URI="/"
VITE_PERSISTANCE_API_URL="/"
VITE_USER_INFO_API_URI="/portail/api/v5-1/userinfo?claims=private&groups="
1 change: 1 addition & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_BASE_URI="/"
49 changes: 5 additions & 44 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,50 +1,11 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:react-hooks/recommended'],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
settings: {
react: {
version: 'detect',
},
'import/resolver': {
node: {
paths: ['src'],
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
},
},
env: {
browser: true,
amd: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:jsx-a11y/recommended',
'plugin:prettier/recommended',
],
plugins: ['prettier'],
plugins: ['react-refresh'],
rules: {
'prettier/prettier': ['error', {}, { usePrettierrc: true }],
'react/react-in-jsx-scope': 'off',
'jsx-a11y/accessible-emoji': 'off',
'react/prop-types': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'jsx-a11y/anchor-is-valid': [
'error',
{
components: ['Link'],
specialLink: ['hrefLeft', 'hrefRight'],
aspects: ['invalidHref', 'preferButton'],
},
],
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
},
};
2 changes: 1 addition & 1 deletion .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"src/**/*.{js,ts,vue}": ["prettier --write", "eslint --fix"],
"src/**/*.{js,jsx,ts,tsx}": ["prettier --write", "eslint --fix"],
"*.json": ["prettier --write"]
}
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18
v20
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
src/main.tsx
src/dev.tsx
874 changes: 0 additions & 874 deletions .yarn/releases/yarn-3.6.4.cjs

This file was deleted.

893 changes: 893 additions & 0 deletions .yarn/releases/yarn-4.0.2.cjs

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
yarnPath: .yarn/releases/yarn-3.6.4.cjs
compressionLevel: mixed

enableGlobalCache: false

nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.0.2.cjs
33 changes: 5 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,11 @@ document.body.appendChild(tldrawEditor);

## **Paramètres**

| Nom | Type | Requis | Default | Description |
| --------------- | :-------: | :-----: | :-----: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `idb-name` | `string` | `true` | | Nom de l'indexed db |
| `upload-api` | `string` | `false` | | URL de l'API REST pour la gestion des fichiers (sauvagarde dans le local storage par défaut) |
| `ws-url` | `string` | `false` | | URL du serveur de WebSocket [Yjs](https://github.com/yjs/yjs) |
| `user-api` | `string` | `false` | | URL de l'API des infromations utilisateurs `@uportal/open-id-connect` OU informations Nextcloud WEBDAV après `/remote.php/dav/files/` (Utilisé pour l'export dans Nextcloud et les noms d'utilisateurs pour le multiplayer) |
| `nextcloud-url` | `string` | `false` | | URL du serveur Nextcloud |
| `room-id` | `string` | `false` | | Identifiant de la salle multiplayer courante |
| `language` | `string` | `false` | `en` | Langue par défaut de l'interface (regarder [tldraw translation](https://github.com/tldraw/tldraw/tree/main/assets/translations) pour les traductions disponibles) |
| `read-only` | `boolean` | `false` | `false` | Désactiver l'édition lors de en mode multiplayer |
| `no-join` | `boolean` | `false` | `false` | Ne pas autoriser à rejoindre une salle |
| `no-leave` | `boolean` | `false` | `false` | Ne pas autoriser à quitter la salle |
| `no-share` | `boolean` | `false` | `false` | Ne pas autoriser à partager la salle |

/!\ NE PAS UTILISER DE `/` A LA FIN DES URLs
| Nom | Type | Requis | Default | Description |
| --------------------- | :------: | :----: | :-----: | --------------------------------- |
| `persistance-api-url` | `string` | `true` | | URL du fichier (GET & PUT) |
| `user-info-api-url` | `string` | `true` | | URL des informations utilisateurs |

```html
<tldraw-editor
idb-name=""
upload-api=""
ws-url=""
user-api=""
nextcloud-url=""
room-id=""
language=""
read-only="true"
no-join="true"
no-share="true"
no-leave="true"
/>
<tldraw-editor persistance-api-url="" user-info-api-url="" />
```
13 changes: 3 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,11 @@
<html lang="">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"
/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>tldraw</title>
</head>
<body>
<tldraw-editor
idb-name="my-tldraw-editor"
ws-url="ws://localhost:1234/ws"
language="fr"
/>
<script type="module" src="/src/main.tsx"></script>
<div id="root"></div>
<script type="module" src="/src/dev.tsx"></script>
</body>
</html>
80 changes: 30 additions & 50 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"name": "@gip-recia/tldraw-webcomponent",
"version": "0.1.3",
"version": "1.0.0",
"type": "module",
"files": [
"dist/*.js",
"dist/assets"
"dist"
],
"description": "tldraw web component",
"keywords": [
Expand Down Expand Up @@ -35,62 +34,43 @@
"url": "https://github.com/GIP-RECIA/tldraw-webcomponent.git"
},
"scripts": {
"dev": "concurrently -n WS,APP \"yarn start:ws\" \"vite --host\"",
"start:ws": "HOST=localhost PORT=1234 node ./node_modules/y-websocket/bin/server.js",
"build": "tsc && vite build",
"dev": "vite --host",
"build": "vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
"lint": "eslint src/ --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"format:check": "prettier --check src/",
"format": "prettier --write src/"
"format": "prettier --write src/",
"prepare": "husky install"
},
"dependencies": {
"@tldraw/tldraw": "1.29.2",
"@tldraw/tldraw": "^1.29.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hotkeys-hook": "^4.4.1",
"react-i18next": "^13.3.1",
"react-toastify": "^9.1.3",
"y-presence": "^0.2.3",
"y-websocket": "^1.5.0",
"yjs": "^13.6.8"
"react-dom": "^18.2.0"
},
"devDependencies": {
"@fortawesome/fontawesome-svg-core": "^6.4.2",
"@fortawesome/free-solid-svg-icons": "^6.4.2",
"@fortawesome/react-fontawesome": "^0.2.0",
"@r2wc/react-to-web-component": "^2.0.3",
"@trivago/prettier-plugin-sort-imports": "^4.2.1",
"@types/lodash": "^4.14.200",
"@types/node": "^18.18.8",
"@types/react": "^18.2.36",
"@types/react-dom": "^18.2.14",
"@types/uuid": "^9.0.6",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/node": "^20.10.6",
"@types/react": "^18.2.46",
"@types/react-dom": "^18.2.18",
"@typescript-eslint/eslint-plugin": "^6.17.0",
"@typescript-eslint/parser": "^6.17.0",
"@uportal/open-id-connect": "^1.40.2",
"@vitejs/plugin-react": "^4.1.1",
"axios": "^1.6.0",
"concurrently": "^8.2.2",
"eslint": "^8.53.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-react": "^7.33.2",
"@vitejs/plugin-react": "^4.2.1",
"axios": "^1.6.4",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"husky": "^8.0.3",
"i18next": "^23.6.0",
"i18next-browser-languagedetector": "^7.1.0",
"i18next-http-backend": "^2.3.1",
"lint-staged": "^15.0.2",
"lodash": "^4.17.21",
"prettier": "^3.0.3",
"prop-types": "^15.8.1",
"regenerator-runtime": "^0.14.0",
"sass": "^1.69.5",
"typescript": "^5.2.2",
"uuid": "^9.0.1",
"vite": "^4.5.0",
"vite-plugin-css-injected-by-js": "^3.3.0"
"lint-staged": "^15.2.0",
"prettier": "^3.1.1",
"regenerator-runtime": "^0.14.1",
"sass": "^1.69.7",
"typescript": "^5.3.3",
"vite": "^5.0.10",
"vite-plugin-css-injected-by-js": "^3.3.1"
},
"packageManager": "yarn@3.6.4"
"packageManager": "yarn@4.0.2"
}
14 changes: 14 additions & 0 deletions src/AppDev.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import './assets/scss/app.scss';
import Editor from './components/Editor.tsx';

function App() {
const { VITE_PERSISTANCE_API_URL, VITE_USER_INFO_API_URI } = import.meta.env;

return (
<div className="tldraw__editor">
<Editor persistanceApiUrl={VITE_PERSISTANCE_API_URL} userInfoApiUrl={VITE_USER_INFO_API_URI} />
</div>
);
}

export default App;
31 changes: 31 additions & 0 deletions src/assets/scss/app.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
html,
body {
padding: 0;
margin: 0;
font-family:
-apple-system,
BlinkMacSystemFont,
Segoe UI,
Roboto,
Oxygen,
Ubuntu,
Cantarell,
Fira Sans,
Droid Sans,
Helvetica Neue,
sans-serif;
}

* {
box-sizing: border-box;
}

.tldraw__editor {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
}
85 changes: 0 additions & 85 deletions src/assets/scss/editor.scss

This file was deleted.

0 comments on commit fcaf682

Please sign in to comment.