rename app to editor (#1503)
This PR renames `App`, `app` and all appy names to `Editor`, `editor`, and editorry names. ### Change Type - [x] `major` — Breaking Change ### Release Notes - Rename `App` to `Editor` and many other things that reference `app` to `editor`.
This commit is contained in:
parent
640bc9de24
commit
735f1c41b7
311 changed files with 8365 additions and 8209 deletions
|
@ -1,4 +1,4 @@
|
|||
import { App, TLArrowUtil, useApp } from '@tldraw/editor'
|
||||
import { Editor, TLArrowUtil, useEditor } from '@tldraw/editor'
|
||||
import { assert, exhaustiveSwitchError } from '@tldraw/utils'
|
||||
import { useValue } from 'signia-react'
|
||||
import { ActionItem } from './useActions'
|
||||
|
@ -128,18 +128,18 @@ export function menuItem(
|
|||
}
|
||||
}
|
||||
|
||||
function shapesWithUnboundArrows(app: App) {
|
||||
const { selectedIds } = app
|
||||
function shapesWithUnboundArrows(editor: Editor) {
|
||||
const { selectedIds } = editor
|
||||
const selectedShapes = selectedIds.map((id) => {
|
||||
return app.getShapeById(id)
|
||||
return editor.getShapeById(id)
|
||||
})
|
||||
|
||||
return selectedShapes.filter((shape) => {
|
||||
if (!shape) return false
|
||||
if (app.isShapeOfType(shape, TLArrowUtil) && shape.props.start.type === 'binding') {
|
||||
if (editor.isShapeOfType(shape, TLArrowUtil) && shape.props.start.type === 'binding') {
|
||||
return false
|
||||
}
|
||||
if (app.isShapeOfType(shape, TLArrowUtil) && shape.props.end.type === 'binding') {
|
||||
if (editor.isShapeOfType(shape, TLArrowUtil) && shape.props.end.type === 'binding') {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
@ -148,22 +148,22 @@ function shapesWithUnboundArrows(app: App) {
|
|||
|
||||
/** @public */
|
||||
export const useThreeStackableItems = () => {
|
||||
const app = useApp()
|
||||
return useValue('threeStackableItems', () => shapesWithUnboundArrows(app).length > 2, [app])
|
||||
const editor = useEditor()
|
||||
return useValue('threeStackableItems', () => shapesWithUnboundArrows(editor).length > 2, [editor])
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export const useAllowGroup = () => {
|
||||
const app = useApp()
|
||||
return useValue('allowGroup', () => shapesWithUnboundArrows(app).length > 1, [app])
|
||||
const editor = useEditor()
|
||||
return useValue('allowGroup', () => shapesWithUnboundArrows(editor).length > 1, [editor])
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export const useAllowUngroup = () => {
|
||||
const app = useApp()
|
||||
const editor = useEditor()
|
||||
return useValue(
|
||||
'allowUngroup',
|
||||
() => app.selectedIds.some((id) => app.getShapeById(id)?.type === 'group'),
|
||||
() => editor.selectedIds.some((id) => editor.getShapeById(id)?.type === 'group'),
|
||||
[]
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue