{"id":24241746,"url":"https://github.com/neosh11/tldraw-web-component","last_synced_at":"2025-03-04T15:26:22.304Z","repository":{"id":272386925,"uuid":"916421611","full_name":"neosh11/tldraw-web-component","owner":"neosh11","description":"Library enabling the use of tldraw on multiple frameworks.","archived":false,"fork":false,"pushed_at":"2025-01-29T00:51:11.000Z","size":3095,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-24T05:55:48.247Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/neosh11.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-14T03:59:59.000Z","updated_at":"2025-01-29T00:51:15.000Z","dependencies_parsed_at":"2025-01-14T05:26:55.242Z","dependency_job_id":"29e0558a-c090-4f16-a2f7-c2a876f7b779","html_url":"https://github.com/neosh11/tldraw-web-component","commit_stats":null,"previous_names":["neosh11/tldraw-web-component"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neosh11%2Ftldraw-web-component","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neosh11%2Ftldraw-web-component/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neosh11%2Ftldraw-web-component/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neosh11%2Ftldraw-web-component/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neosh11","download_url":"https://codeload.github.com/neosh11/tldraw-web-component/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241870674,"owners_count":20034334,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-14T21:40:23.921Z","updated_at":"2025-03-04T15:26:22.297Z","avatar_url":"https://github.com/neosh11.png","language":"TypeScript","funding_links":[],"categories":["Development Utilities"],"sub_categories":["Internationalization"],"readme":"[![npm version](https://badge.fury.io/js/tldraw-web-component.svg)](https://badge.fury.io/js/tldraw-web-component)\n\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)\n\n\n# tldraw web component\n\u003e Make tldraw work with frameworks other than React;\n\n## Getting Started\nInstall with\n\n```\nnpm i tldraw-web-component\n```\n\n# Usage\nYou need to simply include the esm module in order to use the webcomponent.\n```js\nimport 'tldraw-web-component'\n```\n\nThis allows using the webcomponent in your html template.\n\n```html\n\u003cdiv style=\"display: flex;flex-flow: column;height: 100%;\"\u003e\n    \u003ch1\u003ePure HTML + TlDraw Web Component\u003c/h1\u003e\n    \u003cdiv style=\"flex-grow: 1;\"\u003e\n        \u003ctldraw-sync-web-component\n            room-id=\"10\"\n            server-uri=\"http://localhost:5858\"\n            multiplayer-assets-func=\"multiplayerAssets\"\n        \u003e\n        \u003c/tldraw-sync-web-component\u003e\n    \u003c/div\u003e\n\u003c/div\u003e\n\u003cscript\u003e\n    function multiplayerAssets() {\n        return {\n            async upload(_asset, file) {\n                const id = Math.random().toString(36).substr(2, 9); // Generate a unique ID\n                const objectName = `${id}-${file.name}`;\n                const url = `${'http://localhost:5858/uploads'}/${encodeURIComponent(objectName)}`;\n                const response = await fetch(url, {\n                    method: 'PUT',\n                    body: file,\n                });\n\n                if (!response.ok) {\n                    throw new Error(`Failed to upload asset: ${response.statusText}`);\n                }\n\n                return url;\n            },\n            resolve(asset) {\n                return asset.props.src;\n            },\n        };\n    }\n\u003c/script\u003e\n```\n\n## Usage with angular\nCheck `examples/angular`\n\u003cimg width=\"1512\" alt=\"Screenshot 2025-01-14 at 10 36 56 pm\" src=\"https://github.com/user-attachments/assets/3bd15c35-5ab6-430a-a961-db84fedc5218\" /\u003e\n\n## Functions available with tldraw-sync-web-component\n\n**Sync Attr**\n| Name    | type |  Desciption |\n| -------- | ------- | ------- |\n| `room-id`  | string    | The id of the room  |\n| `server-uri`  | string    | The uri of the tldraw/sync server. |\n| `query-params`  | json    | A json containing the query params to be sent when making the connection |\n| `multiplayer-assets-func`  | function    | A function in window / global scope. |\n\n**Draw Attr**\n| Name    | type |  Desciption |\n| -------- | ------- | ------- |\n| `auto-focus`  | boolean    | if tldraw should be in focus when component loads  |\n| `force-mobile`  | boolean    |  Whether to always should the mobile breakpoints |\n| `hide-ui`  | boolean    |  Whether to hide the UI |\n| `infer-dark-mode`  | boolean    |  Whether to infer dark mode from the user's OS. Defaults to false. |\n| `on-mount`  | function    |  Called when the editor has mounted. |\n| `initial-state`  | string    |  The editor's initial state (usually the id of the first active tool). |\n| `license-key`  | string    |  The license key. |\n| `max-asset-size`  | number    |  The maximum size (in bytes) of an asset. Assets larger than this will be rejected. Defaults to 10mb (10 * 1024 * 1024). |\n| `max-image-dimension`  | number    |  The maximum dimension (width or height) of an image. Images larger than this will be rescaled to fit. Defaults to infinity. |\n| `get-user-func`  | function  |  Returns an object with shape {id?: string; name?: string; color?: string; colorScheme?: \"dark\" \\| \"light\" \\| \"system\" \\| undefined; } \\| undefined; |\n| `make-real-func`  | function  | Optional function that returns a promise (developerPrompt: any, image: any, messages: any) =\u003e Promise\u003cany\u003e |\n\n## Contributing\n\nPlease create an issue when you make a PR.\n\n1.  Fork it!\n2.  Create your feature branch: `git checkout -b my-new-feature`\n3.  Add your changes: `git add .`\n4.  Commit your changes: `git commit -am 'Add some feature'`\n5.  Push to the branch: `git push origin my-new-feature`\n6.  Submit a pull request :sunglasses:\n\n## Credits\n\ntldraw;\nhttps://github.com/tldraw/tldraw\n\n## License\n\n[tldraw license](https://github.com/tldraw/tldraw/blob/main/LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneosh11%2Ftldraw-web-component","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneosh11%2Ftldraw-web-component","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneosh11%2Ftldraw-web-component/lists"}