Kaynağa Gözat

changelog

main
Steve Ruiz 3 yıl önce
ebeveyn
işleme
5be36d9bd8
4 değiştirilmiş dosya ile 123 ekleme ve 74 silme
  1. 4
    0
      CHANGELOG.md
  2. 2
    2
      lerna.json
  3. 8
    1
      packages/tldraw/CHANGELOG.md
  4. 109
    71
      packages/tldraw/README.md

+ 4
- 0
CHANGELOG.md Dosyayı Görüntüle

@@ -1,3 +1,7 @@
1
+## 0.1.13
2
+
3
+- Fixes bugs related to `readOnly` mode.
4
+
1 5
 ## 0.1.12
2 6
 
3 7
 - Fixes behavior of context menu.

+ 2
- 2
lerna.json Dosyayı Görüntüle

@@ -1,5 +1,5 @@
1 1
 {
2
-  "version": "0.1.12",
2
+  "version": "0.1.11",
3 3
   "registry": "https://registry.npmjs.org/",
4 4
   "publishConfig": {
5 5
     "access": "public",
@@ -7,4 +7,4 @@
7 7
   },
8 8
   "npmClient": "yarn",
9 9
   "useWorkspaces": true
10
-}
10
+}

+ 8
- 1
packages/tldraw/CHANGELOG.md Dosyayı Görüntüle

@@ -1,6 +1,13 @@
1
-## 0.1.11
1
+## 0.1.13
2
+
3
+- Fixes bugs related to `readOnly` mode.
4
+
5
+## 0.1.12
2 6
 
3 7
 - Fixes behavior of context menu.
8
+
9
+## 0.1.11
10
+
4 11
 - Fixes appearance of keyboard shortcuts in tooltips.
5 12
 
6 13
 ## 0.1.10

+ 109
- 71
packages/tldraw/README.md Dosyayı Görüntüle

@@ -98,29 +98,51 @@ Internally, the `TLDraw` component's user interface uses this API to make change
98 98
 
99 99
 The `TLDraw` React component is the [tldraw](https://tldraw.com) editor exported as a standalone component. You can control the editor through props, or through the `TLDrawState`'s imperative API. **All props are optional.**
100 100
 
101
-| Prop            | Type             | Description                                                                                  |
102
-| --------------- | ---------------- | -------------------------------------------------------------------------------------------- |
103
-| `id`            | `string`         | An id under which to persist the component's state.                                          |
104
-| `document`      | `TLDrawDocument` | An initial [`TLDrawDocument`](#tldrawdocument) object.                                       |
105
-| `currentPageId` | `string`         | A current page id, referencing the `TLDrawDocument` object provided via the `document` prop. |
106
-| `onMount`       | `Function`       | Called when the editor first mounts, receiving the current `TLDrawState`.                    |
107
-| `onPatch`       | `Function`       | Called when the state is updated via a patch.                                                |
108
-| `onCommand`     | `Function`       | Called when the state is updated via a command.                                              |
109
-| `onPersist`     | `Function`       | Called when the state is persisted after an action.                                          |
110
-| `onChange`      | `Function`       | Called when the `TLDrawState` updates for any reason.                                        |
111
-| `onUndo`        | `Function`       | Called when the `TLDrawState` updates after an undo.                                         |
112
-| `onRedo`        | `Function`       | Called when the `TLDrawState` updates after a redo.                                          |
113
-| `onUserChange`  | `Function`       | Called when the user's "presence" information changes.                                       |
114
-| `autofocus`     | `boolean`        | Whether the editor should immediately receive focus. Defaults to true.                       |
115
-| `showMenu`      | `boolean`        | Whether to show the menu.                                                                    |
116
-| `showPages`     | `boolean`        | Whether to show the pages menu.                                                              |
117
-| `showStyles`    | `boolean`        | Whether to show the styles menu.                                                             |
118
-| `showTools`     | `boolean`        | Whether to show the tools.                                                                   |
119
-| `showUI`        | `boolean`        | Whether to show any UI other than the canvas.                                                |
101
+| Prop              | Type             | Description                                                                                               |
102
+| ----------------- | ---------------- | --------------------------------------------------------------------------------------------------------- |
103
+| `id`              | `string`         | An id under which to persist the component's state.                                                       |
104
+| `document`        | `TLDrawDocument` | An initial [`TLDrawDocument`](#tldrawdocument) object.                                                    |
105
+| `currentPageId`   | `string`         | A current page id, referencing the `TLDrawDocument` object provided via the `document` prop.              |
106
+| `autofocus`       | `boolean`        | Whether the editor should immediately receive focus. Defaults to true.                                    |
107
+| `showMenu`        | `boolean`        | Whether to show the menu.                                                                                 |
108
+| `showPages`       | `boolean`        | Whether to show the pages menu.                                                                           |
109
+| `showStyles`      | `boolean`        | Whether to show the styles menu.                                                                          |
110
+| `showTools`       | `boolean`        | Whether to show the tools.                                                                                |
111
+| `showUI`          | `boolean`        | Whether to show any UI other than the canvas.                                                             |
112
+| `onMount`         | `Function`       | Called when the editor first mounts, receiving the current `TLDrawState`.                                 |
113
+| `onPatch`         | `Function`       | Called when the state is updated via a patch.                                                             |
114
+| `onCommand`       | `Function`       | Called when the state is updated via a command.                                                           |
115
+| `onPersist`       | `Function`       | Called when the state is persisted after an action.                                                       |
116
+| `onChange`        | `Function`       | Called when the `TLDrawState` updates for any reason.                                                     |
117
+| `onUserChange`    | `Function`       | Called when the user's "presence" information changes.                                                    |
118
+| `onUndo`          | `Function`       | Called when the `TLDrawState` updates after an undo.                                                      |
119
+| `onRedo`          | `Function`       | Called when the `TLDrawState` updates after a redo.                                                       |
120
+| `onSignIn`        | `Function`       | Called when the user selects Sign In from the menu.                                                       |
121
+| `onSignOut`       | `Function`       | Called when the user selects Sign Out from the menu.                                                      |
122
+| `onNewProject`    | `Function`       | Called when the user when the user creates a new project through the menu or through a keyboard shortcut. |
123
+| `onSaveProject`   | `Function`       | Called when the user saves a project through the menu or through a keyboard shortcut.                     |
124
+| `onSaveProjectAs` | `Function`       | Called when the user saves a project as a new project through the menu or through a keyboard shortcut.    |
125
+| `onOpenProject`   | `Function`       | Called when the user opens new project through the menu or through a keyboard shortcut.                   |
126
+
127
+> **Note**: For help with the file-related callbacks, see `useFileSystem`.
128
+
129
+### `useFileSystem`
130
+
131
+You can use the `useFileSystem` hook to get prepared callbacks for `onNewProject`, `onOpenProject`, `onSaveProject`, and `onSaveProjectAs`. These callbacks allow a user to save files via the [FileSystem](https://developer.mozilla.org/en-US/docs/Web/API/FileSystem) API.
132
+
133
+```ts
134
+import { TLDraw, useFileSystem } from '@tldraw/tldraw'
135
+
136
+function App() {
137
+  const fileSystemEvents = useFileSystem()
138
+
139
+  return <TLDraw {...fileSystemEvents} />
140
+}
141
+```
120 142
 
121 143
 ### `TLDrawDocument`
122 144
 
123
-A `TLDrawDocument` is an object with three properties:
145
+You can initialize or control the `<TLDraw>` component via its `document` property. A `TLDrawDocument` is an object with three properties:
124 146
 
125 147
 - `id` - A unique ID for this document
126 148
 - `pages` - A table of `TLDrawPage` objects
@@ -130,7 +152,7 @@ A `TLDrawDocument` is an object with three properties:
130 152
 ```ts
131 153
 import { TLDrawDocument, TLDrawState } from '@tldraw/tldraw'
132 154
 
133
-const tldocument: TLDrawDocument = {
155
+const myDocument: TLDrawDocument = {
134 156
   id: 'doc',
135 157
   version: TLDrawState.version,
136 158
   pages: {
@@ -152,9 +174,13 @@ const tldocument: TLDrawDocument = {
152 174
     },
153 175
   },
154 176
 }
177
+
178
+function App() {
179
+  return <TLDraw document={myDocument} />
180
+}
155 181
 ```
156 182
 
157
-**Tip:** TLDraw is built on [@tldraw/core](https://github.com/tldraw/core). The pages and pageStates in TLDraw are just objects containing `TLPage` and `TLPageState` objects from the core library. For more about these types, check out the [@tldraw/core](https://github.com/tldraw/core) documentation.
183
+**Tip:** TLDraw is built on [@tldraw/core](https://github.com/tldraw/core). The pages and pageStates in TLDraw are objects containing `TLPage` and `TLPageState` objects from the core library. For more about these types, check out the [@tldraw/core](https://github.com/tldraw/core) documentation.
158 184
 
159 185
 **Important:** In the `pages` object, each `TLPage` object must be keyed under its `id` property. Likewise, each `TLPageState` object must be keyed under its `id`. In addition, each `TLPageState` object must have an `id` that matches its corresponding page.
160 186
 
@@ -179,7 +205,7 @@ Your `TLPage` objects may include shapes: objects that fit one of the `TLDrawSha
179 205
 | `isGenerated`         | `boolean`        | (optional) True if the shape is generated.                      |
180 206
 | `isAspectRatioLocked` | `boolean`        | (optional) True if the shape's aspect ratio is locked.          |
181 207
 
182
-> **Important:** In order for re-ordering to work correctly, a shape's `childIndex` values _must_ start from 1, not 0. The page or parent shape's "bottom-most" child should have a `childIndex` of 1.
208
+> **Important:** In order for re-ordering to work, a shape's `childIndex` values _must_ start from 1, not 0. The page or parent shape's "bottom-most" child should have a `childIndex` of 1.
183 209
 
184 210
 The `ShapeStyle` object is a common style API for all shapes.
185 211
 
@@ -268,71 +294,81 @@ function App() {
268 294
 }
269 295
 ```
270 296
 
271
-The `TLDrawState` API is too large to document here. To view documentation for the API, build the documentation by running `yarn docs` from the root folder and open the file at `/packages/tldraw/docs/classes/TLDrawState.html` in your browser.
297
+To view the full documentation of the `TLDrawState` API, generate the project's documentation by running `yarn docs` from the root folder, then open the file at:
298
+
299
+```
300
+/packages/tldraw/docs/classes/TLDrawState.html
301
+```
272 302
 
273 303
 Here are some useful methods:
274 304
 
275
-| Method            | Description |
276
-| ----------------- | ----------- |
277
-| `loadDocument`    |             |
278
-| `select`          |             |
279
-| `selectAll`       |             |
280
-| `selectNone`      |             |
281
-| `delete`          |             |
282
-| `deleteAll`       |             |
283
-| `deletePage`      |             |
284
-| `changePage`      |             |
285
-| `cut`             |             |
286
-| `copy`            |             |
287
-| `paste`           |             |
288
-| `copyJson`        |             |
289
-| `copySvg`         |             |
290
-| `undo`            |             |
291
-| `redo`            |             |
292
-| `zoomIn`          |             |
293
-| `zoomOut`         |             |
294
-| `zoomToContent`   |             |
295
-| `zoomToSelection` |             |
296
-| `zoomToFit`       |             |
297
-| `zoomTo`          |             |
298
-| `resetZoom`       |             |
299
-| `setCamera`       |             |
300
-| `resetCamera`     |             |
301
-| `align`           |             |
302
-| `distribute`      |             |
303
-| `stretch`         |             |
304
-| `nudge`           |             |
305
-| `duplicate`       |             |
306
-| `flipHorizontal`  |             |
307
-| `flipVertical`    |             |
308
-| `rotate`          |             |
309
-| `style`           |             |
310
-| `group`           |             |
311
-| `ungroup`         |             |
312
-| `createShapes`    |             |
313
-| `updateShapes`    |             |
314
-| `updateDocument`  |             |
315
-| `updateUsers`     |             |
316
-| `removeUser`      |             |
317
-| `setSetting`      |             |
318
-| `selectTool`      |             |
319
-| `cancel`          |             |
305
+- `loadDocument`
306
+- `select`
307
+- `selectAll`
308
+- `selectNone`
309
+- `delete`
310
+- `deleteAll`
311
+- `deletePage`
312
+- `changePage`
313
+- `cut`
314
+- `copy`
315
+- `paste`
316
+- `copyJson`
317
+- `copySvg`
318
+- `undo`
319
+- `redo`
320
+- `zoomIn`
321
+- `zoomOut`
322
+- `zoomToContent`
323
+- `zoomToSelection`
324
+- `zoomToFit`
325
+- `zoomTo`
326
+- `resetZoom`
327
+- `setCamera`
328
+- `resetCamera`
329
+- `align`
330
+- `distribute`
331
+- `stretch`
332
+- `nudge`
333
+- `duplicate`
334
+- `flipHorizontal`
335
+- `flipVertical`
336
+- `rotate`
337
+- `style`
338
+- `group`
339
+- `ungroup`
340
+- `createShapes`
341
+- `updateShapes`
342
+- `updateDocument`
343
+- `updateUsers`
344
+- `removeUser`
345
+- `setSetting`
346
+- `selectTool`
347
+- `cancel`
348
+
349
+Check the generated docs, source or the TypeScript types for more on these and other methods.
320 350
 
321 351
 ## Local Development
322 352
 
353
+From the root folder:
354
+
323 355
 - Run `yarn` to install dependencies.
324 356
 
325 357
 - Run `yarn start` to start the development server for the package and for the example.
326 358
 
327 359
 - Open `localhost:5420` to view the example project.
328 360
 
361
+**Note:** The multiplayer examples and endpoints currently require an API key from [Liveblocks](https://liveblocks.io/), however the storage services that are used in TLDraw are currently in alpha and (as of November 2021) not accessible to the general public. You won't be able to authenticate and run these parts of the project.
362
+
363
+Other scripts:
364
+
329 365
 - Run `yarn test` to execute unit tests via [Jest](https://jestjs.io).
330 366
 
331 367
 - Run `yarn docs` to build the docs via [ts-doc](https://typedoc.org/).
332 368
 
333 369
 ## Example
334 370
 
335
-See the `example` folder.
371
+See the `example` folder for examples of how to use the `<TLDraw/>` component.
336 372
 
337 373
 ## Community
338 374
 
@@ -346,7 +382,9 @@ Want to connect with other devs? Visit the [Discord channel](https://discord.gg/
346 382
 
347 383
 ### License
348 384
 
349
-This project is licensed under MIT. If you're using the library in a commercial product, please consider [becoming a sponsor](https://github.com/sponsors/steveruizok?frequency=recurring&sponsor=steveruizok).
385
+This project is licensed under MIT.
386
+
387
+If you're using the library in a commercial product, please consider [becoming a sponsor](https://github.com/sponsors/steveruizok?frequency=recurring&sponsor=steveruizok).
350 388
 
351 389
 ## Author
352 390
 

Loading…
İptal
Kaydet