no impure getters pt 11 (#2236)
follow up to #2189 adds runtime warnings for deprecated fields. cleans up remaining fields and usages. Adds a lint rule to prevent access to deprecated fields. Adds a lint rule to prevent using getters. ### Change Type - [x] `patch` — Bug fix
This commit is contained in:
parent
431ce73476
commit
34cfb85169
68 changed files with 651 additions and 272 deletions
11
.eslintrc.js
11
.eslintrc.js
|
@ -6,13 +6,22 @@ module.exports = {
|
||||||
'plugin:@next/next/core-web-vitals',
|
'plugin:@next/next/core-web-vitals',
|
||||||
],
|
],
|
||||||
ignorePatterns: [],
|
ignorePatterns: [],
|
||||||
plugins: ['@typescript-eslint', 'no-only-tests', 'import', 'local', '@next/next', 'react-hooks'],
|
plugins: [
|
||||||
|
'@typescript-eslint',
|
||||||
|
'no-only-tests',
|
||||||
|
'import',
|
||||||
|
'local',
|
||||||
|
'@next/next',
|
||||||
|
'react-hooks',
|
||||||
|
'deprecation',
|
||||||
|
],
|
||||||
settings: {
|
settings: {
|
||||||
next: {
|
next: {
|
||||||
rootDir: ['apps/*/', 'packages/*/'],
|
rootDir: ['apps/*/', 'packages/*/'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
|
'deprecation/deprecation': 'error',
|
||||||
'@next/next/no-html-link-for-pages': 'off',
|
'@next/next/no-html-link-for-pages': 'off',
|
||||||
'react/jsx-key': 'off',
|
'react/jsx-key': 'off',
|
||||||
'no-non-null-assertion': 'off',
|
'no-non-null-assertion': 'off',
|
||||||
|
|
|
@ -198,7 +198,7 @@ test.describe('Export snapshots', () => {
|
||||||
editor
|
editor
|
||||||
.updateInstanceState({ exportBackground: false })
|
.updateInstanceState({ exportBackground: false })
|
||||||
.selectAll()
|
.selectAll()
|
||||||
.deleteShapes(editor.selectedShapeIds)
|
.deleteShapes(editor.getSelectedShapeIds())
|
||||||
.createShapes(shapes)
|
.createShapes(shapes)
|
||||||
}, shapes as any)
|
}, shapes as any)
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ export default function ExternalContentSourcesExample() {
|
||||||
const htmlSource = sources?.find((s) => s.type === 'text' && s.subtype === 'html')
|
const htmlSource = sources?.find((s) => s.type === 'text' && s.subtype === 'html')
|
||||||
|
|
||||||
if (htmlSource) {
|
if (htmlSource) {
|
||||||
const center = point ?? editor.viewportPageCenter
|
const center = point ?? editor.getViewportPageCenter()
|
||||||
|
|
||||||
editor.createShape({
|
editor.createShape({
|
||||||
type: 'html',
|
type: 'html',
|
||||||
|
|
|
@ -61,10 +61,10 @@ export class ScreenshotDragging extends StateNode {
|
||||||
// [3]
|
// [3]
|
||||||
override onPointerUp = () => {
|
override onPointerUp = () => {
|
||||||
const { editor } = this
|
const { editor } = this
|
||||||
const box = this.screenshotBox.value
|
const box = this.screenshotBox.get()
|
||||||
|
|
||||||
// get all shapes contained by or intersecting the box
|
// get all shapes contained by or intersecting the box
|
||||||
const shapes = editor.currentPageShapes.filter((s) => {
|
const shapes = editor.getCurrentPageShapes().filter((s) => {
|
||||||
const pageBounds = editor.getShapeMaskedPageBounds(s)
|
const pageBounds = editor.getShapeMaskedPageBounds(s)
|
||||||
if (!pageBounds) return false
|
if (!pageBounds) return false
|
||||||
return box.includes(pageBounds)
|
return box.includes(pageBounds)
|
||||||
|
@ -77,7 +77,7 @@ export class ScreenshotDragging extends StateNode {
|
||||||
editor,
|
editor,
|
||||||
shapes.map((s) => s.id),
|
shapes.map((s) => s.id),
|
||||||
'png',
|
'png',
|
||||||
{ bounds: box, background: editor.instanceState.exportBackground }
|
{ bounds: box, background: editor.getInstanceState().exportBackground }
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
// Export the shapes as a png
|
// Export the shapes as a png
|
||||||
|
@ -85,7 +85,7 @@ export class ScreenshotDragging extends StateNode {
|
||||||
editor,
|
editor,
|
||||||
shapes.map((s) => s.id),
|
shapes.map((s) => s.id),
|
||||||
'png',
|
'png',
|
||||||
{ bounds: box, background: editor.instanceState.exportBackground }
|
{ bounds: box, background: editor.getInstanceState().exportBackground }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ function ScreenshotBox() {
|
||||||
// want to show it in front of the canvas, so we'll need to convert it to
|
// want to show it in front of the canvas, so we'll need to convert it to
|
||||||
// "page space", i.e. uneffected by scale, and relative to the tldraw
|
// "page space", i.e. uneffected by scale, and relative to the tldraw
|
||||||
// page's top left corner.
|
// page's top left corner.
|
||||||
const { zoomLevel } = editor
|
const zoomLevel = editor.getZoomLevel()
|
||||||
const { x, y } = editor.pageToScreen({ x: box.x, y: box.y })
|
const { x, y } = editor.pageToScreen({ x: box.x, y: box.y })
|
||||||
return new Box2d(x, y, box.w * zoomLevel, box.h * zoomLevel)
|
return new Box2d(x, y, box.w * zoomLevel, box.h * zoomLevel)
|
||||||
},
|
},
|
||||||
|
|
|
@ -26,7 +26,7 @@ export default function UserPresenceExample() {
|
||||||
|
|
||||||
const peerPresence = InstancePresenceRecordType.create({
|
const peerPresence = InstancePresenceRecordType.create({
|
||||||
id: InstancePresenceRecordType.createId(editor.store.id),
|
id: InstancePresenceRecordType.createId(editor.store.id),
|
||||||
currentPageId: editor.currentPageId,
|
currentPageId: editor.getCurrentPageId(),
|
||||||
userId: 'peer-1',
|
userId: 'peer-1',
|
||||||
userName: USER_NAME,
|
userName: USER_NAME,
|
||||||
cursor: { x: 0, y: 0, type: 'default', rotation: 0 },
|
cursor: { x: 0, y: 0, type: 'default', rotation: 0 },
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
{
|
{
|
||||||
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
|
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
|
||||||
"packages": [
|
"packages": ["packages/*"],
|
||||||
"packages/*"
|
|
||||||
],
|
|
||||||
"version": "2.0.0-alpha.18"
|
"version": "2.0.0-alpha.18"
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,7 @@
|
||||||
"auto": "^10.46.0",
|
"auto": "^10.46.0",
|
||||||
"eslint": "^8.37.0",
|
"eslint": "^8.37.0",
|
||||||
"eslint-config-prettier": "^8.8.0",
|
"eslint-config-prettier": "^8.8.0",
|
||||||
|
"eslint-plugin-deprecation": "^2.0.0",
|
||||||
"eslint-plugin-import": "^2.27.5",
|
"eslint-plugin-import": "^2.27.5",
|
||||||
"eslint-plugin-local": "^1.0.0",
|
"eslint-plugin-local": "^1.0.0",
|
||||||
"eslint-plugin-no-only-tests": "^3.1.0",
|
"eslint-plugin-no-only-tests": "^3.1.0",
|
||||||
|
|
|
@ -614,12 +614,15 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
createShapes<T extends TLUnknownShape>(shapes: OptionalKeys<TLShapePartial<T>, 'id'>[]): this;
|
createShapes<T extends TLUnknownShape>(shapes: OptionalKeys<TLShapePartial<T>, 'id'>[]): this;
|
||||||
// @deprecated (undocumented)
|
// @deprecated (undocumented)
|
||||||
get croppingShapeId(): null | TLShapeId;
|
get croppingShapeId(): null | TLShapeId;
|
||||||
|
// @deprecated (undocumented)
|
||||||
get currentPage(): TLPage;
|
get currentPage(): TLPage;
|
||||||
// @deprecated (undocumented)
|
// @deprecated (undocumented)
|
||||||
get currentPageBounds(): Box2d | undefined;
|
get currentPageBounds(): Box2d | undefined;
|
||||||
|
// @deprecated (undocumented)
|
||||||
get currentPageId(): TLPageId;
|
get currentPageId(): TLPageId;
|
||||||
// @deprecated (undocumented)
|
// @deprecated (undocumented)
|
||||||
get currentPageRenderingShapesSorted(): TLShape[];
|
get currentPageRenderingShapesSorted(): TLShape[];
|
||||||
|
// @deprecated (undocumented)
|
||||||
get currentPageShapeIds(): Set<TLShapeId>;
|
get currentPageShapeIds(): Set<TLShapeId>;
|
||||||
// @deprecated (undocumented)
|
// @deprecated (undocumented)
|
||||||
get currentPageShapes(): TLShape[];
|
get currentPageShapes(): TLShape[];
|
||||||
|
@ -699,8 +702,11 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
// @internal
|
// @internal
|
||||||
getCrashingError(): unknown;
|
getCrashingError(): unknown;
|
||||||
getCroppingShapeId(): null | TLShapeId;
|
getCroppingShapeId(): null | TLShapeId;
|
||||||
|
getCurrentPage(): TLPage;
|
||||||
getCurrentPageBounds(): Box2d | undefined;
|
getCurrentPageBounds(): Box2d | undefined;
|
||||||
|
getCurrentPageId(): TLPageId;
|
||||||
getCurrentPageRenderingShapesSorted(): TLShape[];
|
getCurrentPageRenderingShapesSorted(): TLShape[];
|
||||||
|
getCurrentPageShapeIds(): Set<TLShapeId>;
|
||||||
getCurrentPageShapes(): TLShape[];
|
getCurrentPageShapes(): TLShape[];
|
||||||
getCurrentPageShapesSorted(): TLShape[];
|
getCurrentPageShapesSorted(): TLShape[];
|
||||||
getCurrentPageState(): TLInstancePageState;
|
getCurrentPageState(): TLInstancePageState;
|
||||||
|
|
|
@ -8004,7 +8004,7 @@
|
||||||
{
|
{
|
||||||
"kind": "Property",
|
"kind": "Property",
|
||||||
"canonicalReference": "@tldraw/editor!Editor#currentPage:member",
|
"canonicalReference": "@tldraw/editor!Editor#currentPage:member",
|
||||||
"docComment": "/**\n * The current page.\n *\n * @public\n */\n",
|
"docComment": "/**\n * @deprecated\n *\n * use `getCurrentPage` instead.\n */\n",
|
||||||
"excerptTokens": [
|
"excerptTokens": [
|
||||||
{
|
{
|
||||||
"kind": "Content",
|
"kind": "Content",
|
||||||
|
@ -8070,7 +8070,7 @@
|
||||||
{
|
{
|
||||||
"kind": "Property",
|
"kind": "Property",
|
||||||
"canonicalReference": "@tldraw/editor!Editor#currentPageId:member",
|
"canonicalReference": "@tldraw/editor!Editor#currentPageId:member",
|
||||||
"docComment": "/**\n * The current page id.\n *\n * @public\n */\n",
|
"docComment": "/**\n * @deprecated\n *\n * Use `getCurrentPageId` instead.\n */\n",
|
||||||
"excerptTokens": [
|
"excerptTokens": [
|
||||||
{
|
{
|
||||||
"kind": "Content",
|
"kind": "Content",
|
||||||
|
@ -8136,7 +8136,7 @@
|
||||||
{
|
{
|
||||||
"kind": "Property",
|
"kind": "Property",
|
||||||
"canonicalReference": "@tldraw/editor!Editor#currentPageShapeIds:member",
|
"canonicalReference": "@tldraw/editor!Editor#currentPageShapeIds:member",
|
||||||
"docComment": "/**\n * An array of all of the shapes on the current page.\n *\n * @public\n */\n",
|
"docComment": "/**\n * @deprecated\n *\n * Use `getCurrentPageShapeIds` instead.\n */\n",
|
||||||
"excerptTokens": [
|
"excerptTokens": [
|
||||||
{
|
{
|
||||||
"kind": "Content",
|
"kind": "Content",
|
||||||
|
@ -8281,7 +8281,7 @@
|
||||||
{
|
{
|
||||||
"kind": "Property",
|
"kind": "Property",
|
||||||
"canonicalReference": "@tldraw/editor!Editor#currentTool:member",
|
"canonicalReference": "@tldraw/editor!Editor#currentTool:member",
|
||||||
"docComment": "/**\n * @deprecated\n *\n * Use `getCurrentTool` instead.\n *\n * @public\n */\n",
|
"docComment": "/**\n * @deprecated\n *\n * Use `getCurrentTool` instead.\n */\n",
|
||||||
"excerptTokens": [
|
"excerptTokens": [
|
||||||
{
|
{
|
||||||
"kind": "Content",
|
"kind": "Content",
|
||||||
|
@ -10289,6 +10289,38 @@
|
||||||
"isAbstract": false,
|
"isAbstract": false,
|
||||||
"name": "getCroppingShapeId"
|
"name": "getCroppingShapeId"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"kind": "Method",
|
||||||
|
"canonicalReference": "@tldraw/editor!Editor#getCurrentPage:member(1)",
|
||||||
|
"docComment": "/**\n * The current page.\n *\n * @public\n */\n",
|
||||||
|
"excerptTokens": [
|
||||||
|
{
|
||||||
|
"kind": "Content",
|
||||||
|
"text": "getCurrentPage(): "
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "Reference",
|
||||||
|
"text": "TLPage",
|
||||||
|
"canonicalReference": "@tldraw/tlschema!TLPage:interface"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "Content",
|
||||||
|
"text": ";"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"isStatic": false,
|
||||||
|
"returnTypeTokenRange": {
|
||||||
|
"startIndex": 1,
|
||||||
|
"endIndex": 2
|
||||||
|
},
|
||||||
|
"releaseTag": "Public",
|
||||||
|
"isProtected": false,
|
||||||
|
"overloadIndex": 1,
|
||||||
|
"parameters": [],
|
||||||
|
"isOptional": false,
|
||||||
|
"isAbstract": false,
|
||||||
|
"name": "getCurrentPage"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"kind": "Method",
|
"kind": "Method",
|
||||||
"canonicalReference": "@tldraw/editor!Editor#getCurrentPageBounds:member(1)",
|
"canonicalReference": "@tldraw/editor!Editor#getCurrentPageBounds:member(1)",
|
||||||
|
@ -10325,6 +10357,38 @@
|
||||||
"isAbstract": false,
|
"isAbstract": false,
|
||||||
"name": "getCurrentPageBounds"
|
"name": "getCurrentPageBounds"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"kind": "Method",
|
||||||
|
"canonicalReference": "@tldraw/editor!Editor#getCurrentPageId:member(1)",
|
||||||
|
"docComment": "/**\n * The current page id.\n *\n * @public\n */\n",
|
||||||
|
"excerptTokens": [
|
||||||
|
{
|
||||||
|
"kind": "Content",
|
||||||
|
"text": "getCurrentPageId(): "
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "Reference",
|
||||||
|
"text": "TLPageId",
|
||||||
|
"canonicalReference": "@tldraw/tlschema!TLPageId:type"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "Content",
|
||||||
|
"text": ";"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"isStatic": false,
|
||||||
|
"returnTypeTokenRange": {
|
||||||
|
"startIndex": 1,
|
||||||
|
"endIndex": 2
|
||||||
|
},
|
||||||
|
"releaseTag": "Public",
|
||||||
|
"isProtected": false,
|
||||||
|
"overloadIndex": 1,
|
||||||
|
"parameters": [],
|
||||||
|
"isOptional": false,
|
||||||
|
"isAbstract": false,
|
||||||
|
"name": "getCurrentPageId"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"kind": "Method",
|
"kind": "Method",
|
||||||
"canonicalReference": "@tldraw/editor!Editor#getCurrentPageRenderingShapesSorted:member(1)",
|
"canonicalReference": "@tldraw/editor!Editor#getCurrentPageRenderingShapesSorted:member(1)",
|
||||||
|
@ -10361,6 +10425,51 @@
|
||||||
"isAbstract": false,
|
"isAbstract": false,
|
||||||
"name": "getCurrentPageRenderingShapesSorted"
|
"name": "getCurrentPageRenderingShapesSorted"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"kind": "Method",
|
||||||
|
"canonicalReference": "@tldraw/editor!Editor#getCurrentPageShapeIds:member(1)",
|
||||||
|
"docComment": "/**\n * An array of all of the shapes on the current page.\n *\n * @public\n */\n",
|
||||||
|
"excerptTokens": [
|
||||||
|
{
|
||||||
|
"kind": "Content",
|
||||||
|
"text": "getCurrentPageShapeIds(): "
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "Reference",
|
||||||
|
"text": "Set",
|
||||||
|
"canonicalReference": "!Set:interface"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "Content",
|
||||||
|
"text": "<"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "Reference",
|
||||||
|
"text": "TLShapeId",
|
||||||
|
"canonicalReference": "@tldraw/tlschema!TLShapeId:type"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "Content",
|
||||||
|
"text": ">"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "Content",
|
||||||
|
"text": ";"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"isStatic": false,
|
||||||
|
"returnTypeTokenRange": {
|
||||||
|
"startIndex": 1,
|
||||||
|
"endIndex": 5
|
||||||
|
},
|
||||||
|
"releaseTag": "Public",
|
||||||
|
"isProtected": false,
|
||||||
|
"overloadIndex": 1,
|
||||||
|
"parameters": [],
|
||||||
|
"isOptional": false,
|
||||||
|
"isAbstract": false,
|
||||||
|
"name": "getCurrentPageShapeIds"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"kind": "Method",
|
"kind": "Method",
|
||||||
"canonicalReference": "@tldraw/editor!Editor#getCurrentPageShapes:member(1)",
|
"canonicalReference": "@tldraw/editor!Editor#getCurrentPageShapes:member(1)",
|
||||||
|
|
|
@ -465,7 +465,7 @@ const DebugSvgCopy = track(function DupSvg({ id }: { id: TLShapeId }) {
|
||||||
|
|
||||||
const [html, setHtml] = React.useState('')
|
const [html, setHtml] = React.useState('')
|
||||||
|
|
||||||
const isInRoot = shape?.parentId === editor.currentPageId
|
const isInRoot = shape?.parentId === editor.getCurrentPageId()
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (!isInRoot) return
|
if (!isInRoot) return
|
||||||
|
|
|
@ -31,7 +31,7 @@ const CollaboratorGuard = track(function CollaboratorGuard({
|
||||||
const presence = usePresence(collaboratorId)
|
const presence = usePresence(collaboratorId)
|
||||||
const collaboratorState = useCollaboratorState(presence)
|
const collaboratorState = useCollaboratorState(presence)
|
||||||
|
|
||||||
if (!(presence && presence.currentPageId === editor.currentPageId)) {
|
if (!(presence && presence.currentPageId === editor.getCurrentPageId())) {
|
||||||
// No need to render if we don't have a presence or if they're on a different page
|
// No need to render if we don't have a presence or if they're on a different page
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,7 @@ export const DefaultErrorFallback: TLErrorFallbackComponent = ({ error, editor }
|
||||||
textarea.value = errorStack ?? errorMessage
|
textarea.value = errorStack ?? errorMessage
|
||||||
document.body.appendChild(textarea)
|
document.body.appendChild(textarea)
|
||||||
textarea.select()
|
textarea.select()
|
||||||
|
// eslint-disable-next-line deprecation/deprecation
|
||||||
document.execCommand('copy')
|
document.execCommand('copy')
|
||||||
textarea.remove()
|
textarea.remove()
|
||||||
setDidCopy(true)
|
setDidCopy(true)
|
||||||
|
|
|
@ -38,6 +38,7 @@ function iOS() {
|
||||||
if (!window) return false
|
if (!window) return false
|
||||||
return (
|
return (
|
||||||
['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(
|
['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(
|
||||||
|
// eslint-disable-next-line deprecation/deprecation
|
||||||
window.navigator.platform
|
window.navigator.platform
|
||||||
) ||
|
) ||
|
||||||
// iPad on iOS 13 detection
|
// iPad on iOS 13 detection
|
||||||
|
|
|
@ -49,6 +49,7 @@ import {
|
||||||
hasOwnProperty,
|
hasOwnProperty,
|
||||||
sortById,
|
sortById,
|
||||||
structuredClone,
|
structuredClone,
|
||||||
|
warnDeprecatedGetter,
|
||||||
} from '@tldraw/utils'
|
} from '@tldraw/utils'
|
||||||
import { EventEmitter } from 'eventemitter3'
|
import { EventEmitter } from 'eventemitter3'
|
||||||
import { TLUser, createTLUser } from '../config/createTLUser'
|
import { TLUser, createTLUser } from '../config/createTLUser'
|
||||||
|
@ -600,7 +601,9 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
this._currentPageShapeIds = deriveShapeIdsInCurrentPage(this.store, () => this.currentPageId)
|
this._currentPageShapeIds = deriveShapeIdsInCurrentPage(this.store, () =>
|
||||||
|
this.getCurrentPageId()
|
||||||
|
)
|
||||||
this._parentIdsToChildIds = parentsToChildren(this.store)
|
this._parentIdsToChildIds = parentsToChildren(this.store)
|
||||||
|
|
||||||
this.disposables.add(
|
this.disposables.add(
|
||||||
|
@ -807,6 +810,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get canUndo(): boolean {
|
get canUndo(): boolean {
|
||||||
|
warnDeprecatedGetter('canUndo')
|
||||||
return this.getCanUndo()
|
return this.getCanUndo()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -839,6 +843,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get canRedo(): boolean {
|
get canRedo(): boolean {
|
||||||
|
warnDeprecatedGetter('canRedo')
|
||||||
return this.getCanRedo()
|
return this.getCanRedo()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1141,10 +1146,10 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use `getCurrentTool` instead.
|
* @deprecated Use `getCurrentTool` instead.
|
||||||
* @public
|
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get currentTool() {
|
get currentTool() {
|
||||||
|
warnDeprecatedGetter('currentTool')
|
||||||
return this.getCurrentTool()
|
return this.getCurrentTool()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1164,6 +1169,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get currentToolId() {
|
get currentToolId() {
|
||||||
|
warnDeprecatedGetter('currentToolId')
|
||||||
return this.getCurrentToolId()
|
return this.getCurrentToolId()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1209,6 +1215,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get documentSettings() {
|
get documentSettings() {
|
||||||
|
warnDeprecatedGetter('documentSettings')
|
||||||
return this.getDocumentSettings()
|
return this.getDocumentSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1238,6 +1245,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get instanceState() {
|
get instanceState() {
|
||||||
|
warnDeprecatedGetter('instanceState')
|
||||||
return this.getInstanceState()
|
return this.getInstanceState()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1323,6 +1331,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get openMenus() {
|
get openMenus() {
|
||||||
|
warnDeprecatedGetter('openMenus')
|
||||||
return this.getOpenMenus()
|
return this.getOpenMenus()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1383,6 +1392,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get isMenuOpen() {
|
get isMenuOpen() {
|
||||||
|
warnDeprecatedGetter('isMenuOpen')
|
||||||
return this.getIsMenuOpen()
|
return this.getIsMenuOpen()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1420,6 +1430,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get pageStates() {
|
get pageStates() {
|
||||||
|
warnDeprecatedGetter('pageStates')
|
||||||
return this.getPageStates()
|
return this.getPageStates()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1442,12 +1453,13 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get currentPageState() {
|
get currentPageState() {
|
||||||
|
warnDeprecatedGetter('currentPageState')
|
||||||
return this.getCurrentPageState()
|
return this.getCurrentPageState()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
@computed private _getCurrentPageStateId() {
|
@computed private _getCurrentPageStateId() {
|
||||||
return InstancePageStateRecordType.createId(this.currentPageId)
|
return InstancePageStateRecordType.createId(this.getCurrentPageId())
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1508,6 +1520,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get selectedShapeIds() {
|
get selectedShapeIds() {
|
||||||
|
warnDeprecatedGetter('selectedShapeIds')
|
||||||
return this.getSelectedShapeIds()
|
return this.getSelectedShapeIds()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1527,6 +1540,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get selectedShapes() {
|
get selectedShapes() {
|
||||||
|
warnDeprecatedGetter('selectedShapes')
|
||||||
return this.getSelectedShapes()
|
return this.getSelectedShapes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1659,7 +1673,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
selectAll(): this {
|
selectAll(): this {
|
||||||
const ids = this.getSortedChildIdsForParent(this.currentPageId)
|
const ids = this.getSortedChildIdsForParent(this.getCurrentPageId())
|
||||||
// page might have no shapes
|
// page might have no shapes
|
||||||
if (ids.length <= 0) return this
|
if (ids.length <= 0) return this
|
||||||
this.setSelectedShapes(this._getUnlockedShapeIds(ids))
|
this.setSelectedShapes(this._getUnlockedShapeIds(ids))
|
||||||
|
@ -1704,6 +1718,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get onlySelectedShape() {
|
get onlySelectedShape() {
|
||||||
|
warnDeprecatedGetter('onlySelectedShape')
|
||||||
return this.getOnlySelectedShape()
|
return this.getOnlySelectedShape()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1728,6 +1743,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get selectionPageBounds() {
|
get selectionPageBounds() {
|
||||||
|
warnDeprecatedGetter('selectionPageBounds')
|
||||||
return this.getSelectionPageBounds()
|
return this.getSelectionPageBounds()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1759,6 +1775,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get selectionRotation() {
|
get selectionRotation() {
|
||||||
|
warnDeprecatedGetter('selectionRotation')
|
||||||
return this.getSelectionRotation()
|
return this.getSelectionRotation()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1807,6 +1824,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get selectionRotatedPageBounds() {
|
get selectionRotatedPageBounds() {
|
||||||
|
warnDeprecatedGetter('selectionRotatedPageBounds')
|
||||||
return this.getSelectionRotatedPageBounds()
|
return this.getSelectionRotatedPageBounds()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1818,7 +1836,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
@computed getFocusedGroupId(): TLShapeId | TLPageId {
|
@computed getFocusedGroupId(): TLShapeId | TLPageId {
|
||||||
return this.getCurrentPageState().focusedGroupId ?? this.currentPageId
|
return this.getCurrentPageState().focusedGroupId ?? this.getCurrentPageId()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1826,6 +1844,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get focusedGroupId() {
|
get focusedGroupId() {
|
||||||
|
warnDeprecatedGetter('focusedGroupId')
|
||||||
return this.getFocusedGroupId()
|
return this.getFocusedGroupId()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1844,6 +1863,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get focusedGroup() {
|
get focusedGroup() {
|
||||||
|
warnDeprecatedGetter('focusedGroup')
|
||||||
return this.getFocusedGroup()
|
return this.getFocusedGroup()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1942,6 +1962,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get editingShapeId() {
|
get editingShapeId() {
|
||||||
|
warnDeprecatedGetter('editingShapeId')
|
||||||
return this.getEditingShapeId()
|
return this.getEditingShapeId()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1960,6 +1981,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get editingShape() {
|
get editingShape() {
|
||||||
|
warnDeprecatedGetter('editingShape')
|
||||||
return this.getEditingShape()
|
return this.getEditingShape()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2010,6 +2032,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get hoveredShapeId() {
|
get hoveredShapeId() {
|
||||||
|
warnDeprecatedGetter('hoveredShapeId')
|
||||||
return this.getHoveredShapeId()
|
return this.getHoveredShapeId()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2028,6 +2051,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get hoveredShape() {
|
get hoveredShape() {
|
||||||
|
warnDeprecatedGetter('hoveredShape')
|
||||||
return this.getHoveredShape()
|
return this.getHoveredShape()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2067,6 +2091,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get hintingShapeIds() {
|
get hintingShapeIds() {
|
||||||
|
warnDeprecatedGetter('hintingShapeIds')
|
||||||
return this.getHintingShapeIds()
|
return this.getHintingShapeIds()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2085,6 +2110,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get hintingShape() {
|
get hintingShape() {
|
||||||
|
warnDeprecatedGetter('hintingShape')
|
||||||
return this.getHintingShape()
|
return this.getHintingShape()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2127,6 +2153,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get erasingShapeIds() {
|
get erasingShapeIds() {
|
||||||
|
warnDeprecatedGetter('erasingShapeIds')
|
||||||
return this.getErasingShapeIds()
|
return this.getErasingShapeIds()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2145,6 +2172,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get erasingShapes() {
|
get erasingShapes() {
|
||||||
|
warnDeprecatedGetter('erasingShapes')
|
||||||
return this.getErasingShapes()
|
return this.getErasingShapes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2202,6 +2230,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get croppingShapeId() {
|
get croppingShapeId() {
|
||||||
|
warnDeprecatedGetter('croppingShapeId')
|
||||||
return this.getCroppingShapeId()
|
return this.getCroppingShapeId()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2240,7 +2269,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
/** @internal */
|
/** @internal */
|
||||||
@computed
|
@computed
|
||||||
private getCameraId() {
|
private getCameraId() {
|
||||||
return CameraRecordType.createId(this.currentPageId)
|
return CameraRecordType.createId(this.getCurrentPageId())
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2266,6 +2295,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get zoomLevel() {
|
get zoomLevel() {
|
||||||
|
warnDeprecatedGetter('zoomLevel')
|
||||||
return this.getZoomLevel()
|
return this.getZoomLevel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2406,7 +2436,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
zoomToFit(animation?: TLAnimationOptions): this {
|
zoomToFit(animation?: TLAnimationOptions): this {
|
||||||
if (!this.getInstanceState().canMoveCamera) return this
|
if (!this.getInstanceState().canMoveCamera) return this
|
||||||
|
|
||||||
const ids = [...this.currentPageShapeIds]
|
const ids = [...this.getCurrentPageShapeIds()]
|
||||||
if (ids.length <= 0) return this
|
if (ids.length <= 0) return this
|
||||||
|
|
||||||
const pageBounds = Box2d.Common(compact(ids.map((id) => this.getShapePageBounds(id))))
|
const pageBounds = Box2d.Common(compact(ids.map((id) => this.getShapePageBounds(id))))
|
||||||
|
@ -2831,7 +2861,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're not on the same page, move to the page they're on
|
// If we're not on the same page, move to the page they're on
|
||||||
const isOnSamePage = presence.currentPageId === this.currentPageId
|
const isOnSamePage = presence.currentPageId === this.getCurrentPageId()
|
||||||
if (!isOnSamePage) {
|
if (!isOnSamePage) {
|
||||||
this.setCurrentPage(presence.currentPageId)
|
this.setCurrentPage(presence.currentPageId)
|
||||||
}
|
}
|
||||||
|
@ -2978,6 +3008,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get viewportScreenBounds() {
|
get viewportScreenBounds() {
|
||||||
|
warnDeprecatedGetter('viewportScreenBounds')
|
||||||
return this.getViewportScreenBounds()
|
return this.getViewportScreenBounds()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2995,6 +3026,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get viewportScreenCenter() {
|
get viewportScreenCenter() {
|
||||||
|
warnDeprecatedGetter('viewportScreenCenter')
|
||||||
return this.getViewportScreenCenter()
|
return this.getViewportScreenCenter()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3014,6 +3046,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get viewportPageBounds() {
|
get viewportPageBounds() {
|
||||||
|
warnDeprecatedGetter('viewportPageBounds')
|
||||||
return this.getViewportPageBounds()
|
return this.getViewportPageBounds()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3031,6 +3064,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get viewportPageCenter() {
|
get viewportPageCenter() {
|
||||||
|
warnDeprecatedGetter('viewportPageCenter')
|
||||||
return this.getViewportPageCenter()
|
return this.getViewportPageCenter()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3130,7 +3164,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change page if leader is on a different page
|
// Change page if leader is on a different page
|
||||||
const isOnSamePage = leaderPresence.currentPageId === this.currentPageId
|
const isOnSamePage = leaderPresence.currentPageId === this.getCurrentPageId()
|
||||||
const chaseProportion = isOnSamePage ? FOLLOW_CHASE_PROPORTION : 1
|
const chaseProportion = isOnSamePage ? FOLLOW_CHASE_PROPORTION : 1
|
||||||
if (!isOnSamePage) {
|
if (!isOnSamePage) {
|
||||||
this.stopFollowingUser()
|
this.stopFollowingUser()
|
||||||
|
@ -3235,6 +3269,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get cameraState() {
|
get cameraState() {
|
||||||
|
warnDeprecatedGetter('cameraState')
|
||||||
return this.getCameraState()
|
return this.getCameraState()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3378,7 +3413,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const childId of this.getSortedChildIdsForParent(this.currentPageId)) {
|
for (const childId of this.getSortedChildIdsForParent(this.getCurrentPageId())) {
|
||||||
addShapeById(childId, 1, false)
|
addShapeById(childId, 1, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3411,6 +3446,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get renderingShapes() {
|
get renderingShapes() {
|
||||||
|
warnDeprecatedGetter('renderingShapes')
|
||||||
return this.getRenderingShapes()
|
return this.getRenderingShapes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3426,9 +3462,9 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
/**
|
/**
|
||||||
* @deprecated Use `getRenderingBounds` instead.
|
* @deprecated Use `getRenderingBounds` instead.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get renderingBounds() {
|
get renderingBounds() {
|
||||||
|
warnDeprecatedGetter('renderingBounds')
|
||||||
return this.getRenderingBounds()
|
return this.getRenderingBounds()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3450,6 +3486,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get renderingBoundsExpanded() {
|
get renderingBoundsExpanded() {
|
||||||
|
warnDeprecatedGetter('renderingBoundsExpanded')
|
||||||
return this.getRenderingBoundsExpanded()
|
return this.getRenderingBoundsExpanded()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3511,6 +3548,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get pages() {
|
get pages() {
|
||||||
|
warnDeprecatedGetter('pages')
|
||||||
return this.getPages()
|
return this.getPages()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3519,10 +3557,17 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*
|
*
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
|
getCurrentPage(): TLPage {
|
||||||
|
return this.getPage(this.getCurrentPageId())!
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use `getCurrentPage` instead.
|
||||||
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get currentPage(): TLPage {
|
get currentPage() {
|
||||||
const page = this.getPage(this.currentPageId)!
|
warnDeprecatedGetter('currentPage')
|
||||||
return page
|
return this.getCurrentPage()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3530,11 +3575,19 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*
|
*
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
getCurrentPageId(): TLPageId {
|
||||||
get currentPageId(): TLPageId {
|
|
||||||
return this.getInstanceState().currentPageId
|
return this.getInstanceState().currentPageId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use `getCurrentPageId` instead.
|
||||||
|
*/
|
||||||
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
|
get currentPageId() {
|
||||||
|
warnDeprecatedGetter('currentPageId')
|
||||||
|
return this.getCurrentPageId()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a page.
|
* Get a page.
|
||||||
*
|
*
|
||||||
|
@ -3560,9 +3613,16 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*
|
*
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
|
getCurrentPageShapeIds() {
|
||||||
|
return this._currentPageShapeIds.get()
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @deprecated Use `getCurrentPageShapeIds` instead.
|
||||||
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get currentPageShapeIds() {
|
get currentPageShapeIds() {
|
||||||
return this._currentPageShapeIds.get()
|
warnDeprecatedGetter('currentPageShapeIds')
|
||||||
|
return this.getCurrentPageShapeIds()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3615,7 +3675,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
this.stopFollowingUser()
|
this.stopFollowingUser()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data: { toId: pageId, fromId: this.currentPageId },
|
data: { toId: pageId, fromId: this.getCurrentPageId() },
|
||||||
squashing: true,
|
squashing: true,
|
||||||
preservesRedoStack: true,
|
preservesRedoStack: true,
|
||||||
...historyOptions,
|
...historyOptions,
|
||||||
|
@ -3806,7 +3866,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
|
|
||||||
if (!deletedPage) return null
|
if (!deletedPage) return null
|
||||||
|
|
||||||
if (id === this.currentPageId) {
|
if (id === this.getCurrentPageId()) {
|
||||||
const index = pages.findIndex((page) => page.id === id)
|
const index = pages.findIndex((page) => page.id === id)
|
||||||
const next = pages[index - 1] ?? pages[index + 1]
|
const next = pages[index - 1] ?? pages[index + 1]
|
||||||
this.setCurrentPage(next.id)
|
this.setCurrentPage(next.id)
|
||||||
|
@ -3819,7 +3879,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
const pages = this.getPages()
|
const pages = this.getPages()
|
||||||
if (pages.length === 1) return
|
if (pages.length === 1) return
|
||||||
|
|
||||||
if (deletedPage.id === this.currentPageId) {
|
if (deletedPage.id === this.getCurrentPageId()) {
|
||||||
const index = pages.findIndex((page) => page.id === deletedPage.id)
|
const index = pages.findIndex((page) => page.id === deletedPage.id)
|
||||||
const next = pages[index - 1] ?? pages[index + 1]
|
const next = pages[index - 1] ?? pages[index + 1]
|
||||||
this.setCurrentPage(next.id)
|
this.setCurrentPage(next.id)
|
||||||
|
@ -3915,6 +3975,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get assets() {
|
get assets() {
|
||||||
|
warnDeprecatedGetter('assets')
|
||||||
return this.getAssets()
|
return this.getAssets()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4518,7 +4579,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
@computed getCurrentPageBounds(): Box2d | undefined {
|
@computed getCurrentPageBounds(): Box2d | undefined {
|
||||||
let commonBounds: Box2d | undefined
|
let commonBounds: Box2d | undefined
|
||||||
|
|
||||||
this.currentPageShapeIds.forEach((shapeId) => {
|
this.getCurrentPageShapeIds().forEach((shapeId) => {
|
||||||
const bounds = this.getShapeMaskedPageBounds(shapeId)
|
const bounds = this.getShapeMaskedPageBounds(shapeId)
|
||||||
if (!bounds) return
|
if (!bounds) return
|
||||||
if (!commonBounds) {
|
if (!commonBounds) {
|
||||||
|
@ -4536,6 +4597,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get currentPageBounds() {
|
get currentPageBounds() {
|
||||||
|
warnDeprecatedGetter('currentPageBounds')
|
||||||
return this.getCurrentPageBounds()
|
return this.getCurrentPageBounds()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4845,7 +4907,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
@computed getCurrentPageShapes(): TLShape[] {
|
@computed getCurrentPageShapes(): TLShape[] {
|
||||||
return Array.from(this.currentPageShapeIds, (id) => this.store.get(id)! as TLShape)
|
return Array.from(this.getCurrentPageShapeIds(), (id) => this.store.get(id)! as TLShape)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4853,6 +4915,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get currentPageShapes() {
|
get currentPageShapes() {
|
||||||
|
warnDeprecatedGetter('currentPageShapes')
|
||||||
return this.getCurrentPageShapes()
|
return this.getCurrentPageShapes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4895,6 +4958,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get currentPageShapesSorted() {
|
get currentPageShapesSorted() {
|
||||||
|
warnDeprecatedGetter('currentPageShapesSorted')
|
||||||
return this.getCurrentPageShapesSorted()
|
return this.getCurrentPageShapesSorted()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4916,6 +4980,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get currentPageRenderingShapesSorted() {
|
get currentPageRenderingShapesSorted() {
|
||||||
|
warnDeprecatedGetter('currentPageRenderingShapesSorted')
|
||||||
return this.getCurrentPageRenderingShapesSorted()
|
return this.getCurrentPageRenderingShapesSorted()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5022,7 +5087,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*
|
*
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
isShapeInPage(shape: TLShape | TLShapeId, pageId = this.currentPageId): boolean {
|
isShapeInPage(shape: TLShape | TLShapeId, pageId = this.getCurrentPageId()): boolean {
|
||||||
const id = typeof shape === 'string' ? shape : shape.id
|
const id = typeof shape === 'string' ? shape : shape.id
|
||||||
const shapeToCheck = this.getShape(id)
|
const shapeToCheck = this.getShape(id)
|
||||||
if (!shapeToCheck) return false
|
if (!shapeToCheck) return false
|
||||||
|
@ -5510,7 +5575,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
oy = vec.y
|
oy = vec.y
|
||||||
}
|
}
|
||||||
|
|
||||||
const parentId = shape.parentId ?? this.currentPageId
|
const parentId = shape.parentId ?? this.getCurrentPageId()
|
||||||
const siblings = this.getSortedChildIdsForParent(parentId)
|
const siblings = this.getSortedChildIdsForParent(parentId)
|
||||||
const currentIndex = siblings.indexOf(shape.id)
|
const currentIndex = siblings.indexOf(shape.id)
|
||||||
const siblingAboveId = siblings[currentIndex + 1]
|
const siblingAboveId = siblings[currentIndex + 1]
|
||||||
|
@ -5613,14 +5678,14 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
|
|
||||||
this.history.batch(() => {
|
this.history.batch(() => {
|
||||||
const maxShapesReached =
|
const maxShapesReached =
|
||||||
shapesToCreate.length + this.currentPageShapeIds.size > MAX_SHAPES_PER_PAGE
|
shapesToCreate.length + this.getCurrentPageShapeIds().size > MAX_SHAPES_PER_PAGE
|
||||||
|
|
||||||
if (maxShapesReached) {
|
if (maxShapesReached) {
|
||||||
alertMaxShapes(this)
|
alertMaxShapes(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
const newShapes = maxShapesReached
|
const newShapes = maxShapesReached
|
||||||
? shapesToCreate.slice(0, MAX_SHAPES_PER_PAGE - this.currentPageShapeIds.size)
|
? shapesToCreate.slice(0, MAX_SHAPES_PER_PAGE - this.getCurrentPageShapeIds().size)
|
||||||
: shapesToCreate
|
: shapesToCreate
|
||||||
|
|
||||||
const ids = newShapes.map((s) => s.id)
|
const ids = newShapes.map((s) => s.id)
|
||||||
|
@ -5667,7 +5732,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
if (ids.length === 0) return this
|
if (ids.length === 0) return this
|
||||||
if (this.getInstanceState().isReadonly) return this
|
if (this.getInstanceState().isReadonly) return this
|
||||||
|
|
||||||
const { currentPageId } = this
|
const currentPageId = this.getCurrentPageId()
|
||||||
|
|
||||||
if (pageId === currentPageId) return this
|
if (pageId === currentPageId) return this
|
||||||
if (!this.store.has(pageId)) return this
|
if (!this.store.has(pageId)) return this
|
||||||
|
@ -6813,7 +6878,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
if (this.getInstanceState().isReadonly) return null
|
if (this.getInstanceState().isReadonly) return null
|
||||||
if (partials.length <= 0) return null
|
if (partials.length <= 0) return null
|
||||||
|
|
||||||
const { currentPageShapeIds } = this
|
const currentPageShapeIds = this.getCurrentPageShapeIds()
|
||||||
|
|
||||||
const maxShapesReached = partials.length + currentPageShapeIds.size > MAX_SHAPES_PER_PAGE
|
const maxShapesReached = partials.length + currentPageShapeIds.size > MAX_SHAPES_PER_PAGE
|
||||||
|
|
||||||
|
@ -6827,7 +6892,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data: {
|
data: {
|
||||||
currentPageId: this.currentPageId,
|
currentPageId: this.getCurrentPageId(),
|
||||||
partials: partials.map((p) =>
|
partials: partials.map((p) =>
|
||||||
p.id ? p : { ...p, id: createShapeId() }
|
p.id ? p : { ...p, id: createShapeId() }
|
||||||
) as TLShapePartial[],
|
) as TLShapePartial[],
|
||||||
|
@ -7151,7 +7216,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
|
|
||||||
const { x, y } = pageBounds.point
|
const { x, y } = pageBounds.point
|
||||||
|
|
||||||
const parentId = this.findCommonAncestor(shapesToGroup) ?? this.currentPageId
|
const parentId = this.findCommonAncestor(shapesToGroup) ?? this.getCurrentPageId()
|
||||||
|
|
||||||
// Only group when the select tool is active
|
// Only group when the select tool is active
|
||||||
if (this.getCurrentToolId() !== 'select') return this
|
if (this.getCurrentToolId() !== 'select') return this
|
||||||
|
@ -7613,6 +7678,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get sharedStyles() {
|
get sharedStyles() {
|
||||||
|
warnDeprecatedGetter('sharedStyles')
|
||||||
return this.getSharedStyles()
|
return this.getSharedStyles()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7663,6 +7729,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get sharedOpacity() {
|
get sharedOpacity() {
|
||||||
|
warnDeprecatedGetter('sharedOpacity')
|
||||||
return this.getSharedOpacity()
|
return this.getSharedOpacity()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8060,7 +8127,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
shape.x = pagePoint.x
|
shape.x = pagePoint.x
|
||||||
shape.y = pagePoint.y
|
shape.y = pagePoint.y
|
||||||
shape.rotation = pageRotation
|
shape.rotation = pageRotation
|
||||||
shape.parentId = this.currentPageId
|
shape.parentId = this.getCurrentPageId()
|
||||||
|
|
||||||
rootShapeIds.push(shape.id)
|
rootShapeIds.push(shape.id)
|
||||||
}
|
}
|
||||||
|
@ -8114,13 +8181,13 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
|
|
||||||
// decide on a parent for the put shapes; if the parent is among the put shapes(?) then use its parent
|
// decide on a parent for the put shapes; if the parent is among the put shapes(?) then use its parent
|
||||||
|
|
||||||
const { currentPageId } = this
|
const currentPageId = this.getCurrentPageId()
|
||||||
const { assets, shapes, rootShapeIds } = content
|
const { assets, shapes, rootShapeIds } = content
|
||||||
|
|
||||||
const idMap = new Map<any, TLShapeId>(shapes.map((shape) => [shape.id, createShapeId()]))
|
const idMap = new Map<any, TLShapeId>(shapes.map((shape) => [shape.id, createShapeId()]))
|
||||||
|
|
||||||
// By default, the paste parent will be the current page.
|
// By default, the paste parent will be the current page.
|
||||||
let pasteParentId = this.currentPageId as TLPageId | TLShapeId
|
let pasteParentId = this.getCurrentPageId() as TLPageId | TLShapeId
|
||||||
let lowestDepth = Infinity
|
let lowestDepth = Infinity
|
||||||
let lowestAncestors: TLShape[] = []
|
let lowestAncestors: TLShape[] = []
|
||||||
|
|
||||||
|
@ -8246,7 +8313,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
return newShape
|
return newShape
|
||||||
})
|
})
|
||||||
|
|
||||||
if (newShapes.length + this.currentPageShapeIds.size > MAX_SHAPES_PER_PAGE) {
|
if (newShapes.length + this.getCurrentPageShapeIds().size > MAX_SHAPES_PER_PAGE) {
|
||||||
// There's some complexity here involving children
|
// There's some complexity here involving children
|
||||||
// that might be created without their parents, so
|
// that might be created without their parents, so
|
||||||
// if we're going over the limit then just don't paste.
|
// if we're going over the limit then just don't paste.
|
||||||
|
@ -9311,7 +9378,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function alertMaxShapes(editor: Editor, pageId = editor.currentPageId) {
|
function alertMaxShapes(editor: Editor, pageId = editor.getCurrentPageId()) {
|
||||||
const name = editor.getPage(pageId)!.name
|
const name = editor.getPage(pageId)!.name
|
||||||
editor.emit('max-shapes', { name, pageId, count: MAX_SHAPES_PER_PAGE })
|
editor.emit('max-shapes', { name, pageId, count: MAX_SHAPES_PER_PAGE })
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { atom, transact } from '@tldraw/state'
|
import { atom, transact } from '@tldraw/state'
|
||||||
import { devFreeze } from '@tldraw/store'
|
import { devFreeze } from '@tldraw/store'
|
||||||
|
import { warnDeprecatedGetter } from '@tldraw/utils'
|
||||||
import { uniqueId } from '../../utils/uniqueId'
|
import { uniqueId } from '../../utils/uniqueId'
|
||||||
import { TLCommandHandler, TLCommandHistoryOptions, TLHistoryEntry } from '../types/history-types'
|
import { TLCommandHandler, TLCommandHistoryOptions, TLHistoryEntry } from '../types/history-types'
|
||||||
import { Stack, stack } from './Stack'
|
import { Stack, stack } from './Stack'
|
||||||
|
@ -41,6 +42,7 @@ export class HistoryManager<
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get numUndos() {
|
get numUndos() {
|
||||||
|
warnDeprecatedGetter('numUndos')
|
||||||
return this.getNumUndos()
|
return this.getNumUndos()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +54,7 @@ export class HistoryManager<
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get numRedos() {
|
get numRedos() {
|
||||||
|
warnDeprecatedGetter('numRedos')
|
||||||
return this.getNumRedos()
|
return this.getNumRedos()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { atom, computed, EMPTY_ARRAY } from '@tldraw/state'
|
import { atom, computed, EMPTY_ARRAY } from '@tldraw/state'
|
||||||
import { TLGroupShape, TLParentId, TLShape, TLShapeId, Vec2dModel } from '@tldraw/tlschema'
|
import { TLGroupShape, TLParentId, TLShape, TLShapeId, Vec2dModel } from '@tldraw/tlschema'
|
||||||
import { dedupe, deepCopy } from '@tldraw/utils'
|
import { dedupe, deepCopy, warnDeprecatedGetter } from '@tldraw/utils'
|
||||||
import {
|
import {
|
||||||
Box2d,
|
Box2d,
|
||||||
flipSelectionHandleX,
|
flipSelectionHandleX,
|
||||||
|
@ -221,6 +221,7 @@ export class SnapManager {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get lines() {
|
get lines() {
|
||||||
|
warnDeprecatedGetter('lines')
|
||||||
return this.getLines()
|
return this.getLines()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,6 +255,7 @@ export class SnapManager {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get snapPointsCache() {
|
get snapPointsCache() {
|
||||||
|
warnDeprecatedGetter('snapPointsCache')
|
||||||
return this.getSnapPointsCache()
|
return this.getSnapPointsCache()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,6 +268,7 @@ export class SnapManager {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get snapThreshold() {
|
get snapThreshold() {
|
||||||
|
warnDeprecatedGetter('snapThreshold')
|
||||||
return this.getSnapThreshold()
|
return this.getSnapThreshold()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,7 +306,7 @@ export class SnapManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
collectSnappableShapesFromParent(this.getCurrentCommonAncestor() ?? editor.currentPageId)
|
collectSnappableShapesFromParent(this.getCurrentCommonAncestor() ?? editor.getCurrentPageId())
|
||||||
|
|
||||||
return snappableShapes
|
return snappableShapes
|
||||||
}
|
}
|
||||||
|
@ -314,6 +317,7 @@ export class SnapManager {
|
||||||
|
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get snappableShapes() {
|
get snappableShapes() {
|
||||||
|
warnDeprecatedGetter('snappableShapes')
|
||||||
return this.getSnappableShapes()
|
return this.getSnappableShapes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,6 +331,7 @@ export class SnapManager {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get currentCommonAncestor() {
|
get currentCommonAncestor() {
|
||||||
|
warnDeprecatedGetter('currentCommonAncestor')
|
||||||
return this.getCurrentCommonAncestor()
|
return this.getCurrentCommonAncestor()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,6 +356,7 @@ export class SnapManager {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get snappablePoints() {
|
get snappablePoints() {
|
||||||
|
warnDeprecatedGetter('snappablePoints')
|
||||||
return this.getSnappablePoints()
|
return this.getSnappablePoints()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -456,6 +462,7 @@ export class SnapManager {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get visibleGaps() {
|
get visibleGaps() {
|
||||||
|
warnDeprecatedGetter('visibleGaps')
|
||||||
return this.getVisibleGaps()
|
return this.getVisibleGaps()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -567,6 +574,7 @@ export class SnapManager {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get outlinesInPageSpace() {
|
get outlinesInPageSpace() {
|
||||||
|
warnDeprecatedGetter('outlinesInPageSpace')
|
||||||
return this.getOutlinesInPageSpace()
|
return this.getOutlinesInPageSpace()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { computed } from '@tldraw/state'
|
import { computed } from '@tldraw/state'
|
||||||
|
import { warnDeprecatedGetter } from '@tldraw/utils'
|
||||||
import {
|
import {
|
||||||
TLUserPreferences,
|
TLUserPreferences,
|
||||||
defaultUserPreferences,
|
defaultUserPreferences,
|
||||||
|
@ -31,6 +32,7 @@ export class UserPreferencesManager {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get userPreferences() {
|
get userPreferences() {
|
||||||
|
warnDeprecatedGetter('userPreferences')
|
||||||
return this.getUserPreferences()
|
return this.getUserPreferences()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +48,7 @@ export class UserPreferencesManager {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get isDarkMode() {
|
get isDarkMode() {
|
||||||
|
warnDeprecatedGetter('isDarkMode')
|
||||||
return this.getIsDarkMode()
|
return this.getIsDarkMode()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +61,7 @@ export class UserPreferencesManager {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get animationSpeed() {
|
get animationSpeed() {
|
||||||
|
warnDeprecatedGetter('animationSpeed')
|
||||||
return this.getAnimationSpeed()
|
return this.getAnimationSpeed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +74,7 @@ export class UserPreferencesManager {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get id() {
|
get id() {
|
||||||
|
warnDeprecatedGetter('id')
|
||||||
return this.getId()
|
return this.getId()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,6 +87,7 @@ export class UserPreferencesManager {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get name() {
|
get name() {
|
||||||
|
warnDeprecatedGetter('name')
|
||||||
return this.getName()
|
return this.getName()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,6 +100,7 @@ export class UserPreferencesManager {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get locale() {
|
get locale() {
|
||||||
|
warnDeprecatedGetter('locale')
|
||||||
return this.getLocale()
|
return this.getLocale()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,6 +113,7 @@ export class UserPreferencesManager {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get color() {
|
get color() {
|
||||||
|
warnDeprecatedGetter('color')
|
||||||
return this.getColor()
|
return this.getColor()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,6 +126,7 @@ export class UserPreferencesManager {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get isSnapMode() {
|
get isSnapMode() {
|
||||||
|
warnDeprecatedGetter('isSnapMode')
|
||||||
return this.getIsSnapMode()
|
return this.getIsSnapMode()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { Atom, Computed, atom, computed } from '@tldraw/state'
|
import { Atom, Computed, atom, computed } from '@tldraw/state'
|
||||||
|
import { warnDeprecatedGetter } from '@tldraw/utils'
|
||||||
import type { Editor } from '../Editor'
|
import type { Editor } from '../Editor'
|
||||||
import {
|
import {
|
||||||
EVENT_NAME_MAP,
|
EVENT_NAME_MAP,
|
||||||
|
@ -187,10 +188,12 @@ export abstract class StateNode implements Partial<TLEventHandlers> {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
get currentToolIdMask() {
|
get currentToolIdMask() {
|
||||||
|
warnDeprecatedGetter('currentToolIdMask')
|
||||||
return this._currentToolIdMask.get()
|
return this._currentToolIdMask.get()
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
set currentToolIdMask(id: string | undefined) {
|
set currentToolIdMask(id: string | undefined) {
|
||||||
|
warnDeprecatedGetter('currentToolIdMask')
|
||||||
this._currentToolIdMask.set(id)
|
this._currentToolIdMask.set(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,13 +30,17 @@ export function useDocumentEvents() {
|
||||||
}
|
}
|
||||||
if (media.addEventListener) {
|
if (media.addEventListener) {
|
||||||
media.addEventListener('change', updatePixelRatio)
|
media.addEventListener('change', updatePixelRatio)
|
||||||
|
// eslint-disable-next-line deprecation/deprecation
|
||||||
} else if (media.addListener) {
|
} else if (media.addListener) {
|
||||||
|
// eslint-disable-next-line deprecation/deprecation
|
||||||
media.addListener(safariCb)
|
media.addListener(safariCb)
|
||||||
}
|
}
|
||||||
remove = () => {
|
remove = () => {
|
||||||
if (media.removeEventListener) {
|
if (media.removeEventListener) {
|
||||||
media.removeEventListener('change', updatePixelRatio)
|
media.removeEventListener('change', updatePixelRatio)
|
||||||
|
// eslint-disable-next-line deprecation/deprecation
|
||||||
} else if (media.removeListener) {
|
} else if (media.removeListener) {
|
||||||
|
// eslint-disable-next-line deprecation/deprecation
|
||||||
media.removeListener(safariCb)
|
media.removeListener(safariCb)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ export function useZoomCss() {
|
||||||
const setScaleDebounced = debounce(setScale, 100)
|
const setScaleDebounced = debounce(setScale, 100)
|
||||||
|
|
||||||
const scheduler = new EffectScheduler('useZoomCss', () => {
|
const scheduler = new EffectScheduler('useZoomCss', () => {
|
||||||
const numShapes = editor.currentPageShapeIds.size
|
const numShapes = editor.getCurrentPageShapeIds().size
|
||||||
if (numShapes < 300) {
|
if (numShapes < 300) {
|
||||||
setScale(editor.getZoomLevel())
|
setScale(editor.getZoomLevel())
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// Reasonable defaults
|
// Reasonable defaults
|
||||||
const MAX_ZOOM_STEP = 10
|
const MAX_ZOOM_STEP = 10
|
||||||
const IS_DARWIN = /Mac|iPod|iPhone|iPad/.test(
|
const IS_DARWIN = /Mac|iPod|iPhone|iPad/.test(
|
||||||
|
// eslint-disable-next-line deprecation/deprecation
|
||||||
typeof window === 'undefined' ? 'node' : window.navigator.platform
|
typeof window === 'undefined' ? 'node' : window.navigator.platform
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,8 @@
|
||||||
let didWarnDotValue = false
|
let didWarnDotValue = false
|
||||||
const isDev = typeof process !== 'undefined' && process.env?.NODE_ENV === 'development'
|
|
||||||
const isProd = !isDev
|
|
||||||
|
|
||||||
// remove this once we've removed all getters from our app
|
// remove this once we've removed all getters from our app
|
||||||
const ROLLOUT_OVERRIDE_REMOVE_ME = true
|
|
||||||
|
|
||||||
export function logDotValueWarning() {
|
export function logDotValueWarning() {
|
||||||
if (ROLLOUT_OVERRIDE_REMOVE_ME) return
|
|
||||||
if (isProd) return
|
|
||||||
if (didWarnDotValue) return
|
if (didWarnDotValue) return
|
||||||
didWarnDotValue = true
|
didWarnDotValue = true
|
||||||
console.warn(
|
console.warn(
|
||||||
|
@ -18,8 +13,6 @@ export function logDotValueWarning() {
|
||||||
let didWarnComputedGetter = false
|
let didWarnComputedGetter = false
|
||||||
|
|
||||||
export function logComputedGetterWarning() {
|
export function logComputedGetterWarning() {
|
||||||
if (ROLLOUT_OVERRIDE_REMOVE_ME) return
|
|
||||||
if (isProd) return
|
|
||||||
if (didWarnComputedGetter) return
|
if (didWarnComputedGetter) return
|
||||||
didWarnComputedGetter = true
|
didWarnComputedGetter = true
|
||||||
console.warn(
|
console.warn(
|
||||||
|
|
|
@ -513,7 +513,7 @@ describe("an arrow's parents", () => {
|
||||||
end: { type: 'binding', boundShapeId: frameId },
|
end: { type: 'binding', boundShapeId: frameId },
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
expect(editor.getShape(arrowId)?.parentId).toBe(editor.currentPageId)
|
expect(editor.getShape(arrowId)?.parentId).toBe(editor.getCurrentPageId())
|
||||||
|
|
||||||
// move arrow to b
|
// move arrow to b
|
||||||
editor.pointerMove(15, 85)
|
editor.pointerMove(15, 85)
|
||||||
|
@ -527,7 +527,7 @@ describe("an arrow's parents", () => {
|
||||||
|
|
||||||
// move back to empty space
|
// move back to empty space
|
||||||
editor.pointerMove(50, 50)
|
editor.pointerMove(50, 50)
|
||||||
expect(editor.getShape(arrowId)?.parentId).toBe(editor.currentPageId)
|
expect(editor.getShape(arrowId)?.parentId).toBe(editor.getCurrentPageId())
|
||||||
expect(editor.getShape(arrowId)).toMatchObject({
|
expect(editor.getShape(arrowId)).toMatchObject({
|
||||||
props: {
|
props: {
|
||||||
start: { type: 'binding', boundShapeId: boxAid },
|
start: { type: 'binding', boundShapeId: boxAid },
|
||||||
|
@ -552,7 +552,7 @@ describe("an arrow's parents", () => {
|
||||||
// move b outside of frame
|
// move b outside of frame
|
||||||
editor.select(boxBid).translateSelection(200, 0)
|
editor.select(boxBid).translateSelection(200, 0)
|
||||||
expect(editor.getShape(arrowId)).toMatchObject({
|
expect(editor.getShape(arrowId)).toMatchObject({
|
||||||
parentId: editor.currentPageId,
|
parentId: editor.getCurrentPageId(),
|
||||||
props: {
|
props: {
|
||||||
start: { type: 'binding', boundShapeId: boxAid },
|
start: { type: 'binding', boundShapeId: boxAid },
|
||||||
end: { type: 'binding', boundShapeId: boxBid },
|
end: { type: 'binding', boundShapeId: boxBid },
|
||||||
|
@ -566,7 +566,7 @@ describe("an arrow's parents", () => {
|
||||||
editor.pointerDown(15, 15).pointerMove(115, 15).pointerUp()
|
editor.pointerDown(15, 15).pointerMove(115, 15).pointerUp()
|
||||||
const arrowId = editor.getOnlySelectedShape()!.id
|
const arrowId = editor.getOnlySelectedShape()!.id
|
||||||
expect(editor.getShape(arrowId)).toMatchObject({
|
expect(editor.getShape(arrowId)).toMatchObject({
|
||||||
parentId: editor.currentPageId,
|
parentId: editor.getCurrentPageId(),
|
||||||
props: {
|
props: {
|
||||||
start: { type: 'binding', boundShapeId: boxAid },
|
start: { type: 'binding', boundShapeId: boxAid },
|
||||||
end: { type: 'binding', boundShapeId: boxCid },
|
end: { type: 'binding', boundShapeId: boxCid },
|
||||||
|
|
|
@ -209,7 +209,7 @@ export class FrameShapeUtil extends BaseBoxShapeUtil<TLFrameShape> {
|
||||||
if (isInGroup) {
|
if (isInGroup) {
|
||||||
this.editor.reparentShapes(shapes, parent.id)
|
this.editor.reparentShapes(shapes, parent.id)
|
||||||
} else {
|
} else {
|
||||||
this.editor.reparentShapes(shapes, this.editor.currentPageId)
|
this.editor.reparentShapes(shapes, this.editor.getCurrentPageId())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +227,7 @@ export class FrameShapeUtil extends BaseBoxShapeUtil<TLFrameShape> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shapesToReparent.length > 0) {
|
if (shapesToReparent.length > 0) {
|
||||||
this.editor.reparentShapes(shapesToReparent, this.editor.currentPageId)
|
this.editor.reparentShapes(shapesToReparent, this.editor.getCurrentPageId())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,7 +195,7 @@ describe('Misc', () => {
|
||||||
editor.pointerMove(50, 50) // Move shape by 25, 25
|
editor.pointerMove(50, 50) // Move shape by 25, 25
|
||||||
editor.pointerUp().keyUp('Alt')
|
editor.pointerUp().keyUp('Alt')
|
||||||
|
|
||||||
expect(Array.from(editor.currentPageShapeIds.values()).length).toEqual(2)
|
expect(Array.from(editor.getCurrentPageShapeIds().values()).length).toEqual(2)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('deletes', () => {
|
it('deletes', () => {
|
||||||
|
@ -207,7 +207,7 @@ describe('Misc', () => {
|
||||||
editor.pointerMove(50, 50) // Move shape by 25, 25
|
editor.pointerMove(50, 50) // Move shape by 25, 25
|
||||||
editor.pointerUp().keyUp('Alt')
|
editor.pointerUp().keyUp('Alt')
|
||||||
|
|
||||||
let ids = Array.from(editor.currentPageShapeIds.values())
|
let ids = Array.from(editor.getCurrentPageShapeIds().values())
|
||||||
expect(ids.length).toEqual(2)
|
expect(ids.length).toEqual(2)
|
||||||
|
|
||||||
const duplicate = ids.filter((i) => i !== id)[0]
|
const duplicate = ids.filter((i) => i !== id)[0]
|
||||||
|
@ -215,7 +215,7 @@ describe('Misc', () => {
|
||||||
|
|
||||||
editor.deleteShapes(editor.getSelectedShapeIds())
|
editor.deleteShapes(editor.getSelectedShapeIds())
|
||||||
|
|
||||||
ids = Array.from(editor.currentPageShapeIds.values())
|
ids = Array.from(editor.getCurrentPageShapeIds().values())
|
||||||
expect(ids.length).toEqual(1)
|
expect(ids.length).toEqual(1)
|
||||||
expect(ids[0]).toEqual(id)
|
expect(ids[0]).toEqual(id)
|
||||||
})
|
})
|
||||||
|
|
|
@ -40,6 +40,7 @@ export class TextHelpers {
|
||||||
field.focus()
|
field.focus()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line deprecation/deprecation
|
||||||
if (!document.execCommand('insertText', false, text)) {
|
if (!document.execCommand('insertText', false, text)) {
|
||||||
TextHelpers.insertTextFirefox(field, text)
|
TextHelpers.insertTextFirefox(field, text)
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,8 +96,8 @@ export class Brushing extends StateNode {
|
||||||
private hitTestShapes() {
|
private hitTestShapes() {
|
||||||
const zoomLevel = this.editor.getZoomLevel()
|
const zoomLevel = this.editor.getZoomLevel()
|
||||||
const currentPageShapes = this.editor.getCurrentPageShapes()
|
const currentPageShapes = this.editor.getCurrentPageShapes()
|
||||||
|
const currentPageId = this.editor.getCurrentPageId()
|
||||||
const {
|
const {
|
||||||
currentPageId,
|
|
||||||
inputs: { originPagePoint, currentPagePoint, shiftKey, ctrlKey },
|
inputs: { originPagePoint, currentPagePoint, shiftKey, ctrlKey },
|
||||||
} = this.editor
|
} = this.editor
|
||||||
|
|
||||||
|
|
|
@ -388,7 +388,7 @@ export class Idle extends StateNode {
|
||||||
|
|
||||||
override onCancel: TLEventHandlers['onCancel'] = () => {
|
override onCancel: TLEventHandlers['onCancel'] = () => {
|
||||||
if (
|
if (
|
||||||
this.editor.getFocusedGroupId() !== this.editor.currentPageId &&
|
this.editor.getFocusedGroupId() !== this.editor.getCurrentPageId() &&
|
||||||
this.editor.getSelectedShapeIds().length > 0
|
this.editor.getSelectedShapeIds().length > 0
|
||||||
) {
|
) {
|
||||||
this.editor.popFocusedGroupId()
|
this.editor.popFocusedGroupId()
|
||||||
|
|
|
@ -208,8 +208,8 @@ export class DraggingHandle extends StateNode {
|
||||||
const { editor, shapeId, initialPagePoint } = this
|
const { editor, shapeId, initialPagePoint } = this
|
||||||
const { initialHandle, initialPageRotation, initialAdjacentHandle } = this
|
const { initialHandle, initialPageRotation, initialAdjacentHandle } = this
|
||||||
const hintingShapeIds = this.editor.getHintingShapeIds()
|
const hintingShapeIds = this.editor.getHintingShapeIds()
|
||||||
|
const isSnapMode = this.editor.user.getIsSnapMode()
|
||||||
const {
|
const {
|
||||||
user: { isSnapMode },
|
|
||||||
snaps,
|
snaps,
|
||||||
inputs: { currentPagePoint, shiftKey, ctrlKey, altKey, pointerVelocity },
|
inputs: { currentPagePoint, shiftKey, ctrlKey, altKey, pointerVelocity },
|
||||||
} = editor
|
} = editor
|
||||||
|
|
|
@ -8,7 +8,7 @@ export const MoveToPageMenu = track(function MoveToPageMenu() {
|
||||||
const editor = useEditor()
|
const editor = useEditor()
|
||||||
const container = useContainer()
|
const container = useContainer()
|
||||||
const pages = editor.getPages()
|
const pages = editor.getPages()
|
||||||
const currentPageId = editor.currentPageId
|
const currentPageId = editor.getCurrentPageId()
|
||||||
const msg = useTranslation()
|
const msg = useTranslation()
|
||||||
const { addToast } = useToasts()
|
const { addToast } = useToasts()
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ export function Minimap({ shapeFill, selectFill, viewportFill }: MinimapProps) {
|
||||||
|
|
||||||
const onDoubleClick = React.useCallback(
|
const onDoubleClick = React.useCallback(
|
||||||
(e: React.MouseEvent<HTMLCanvasElement>) => {
|
(e: React.MouseEvent<HTMLCanvasElement>) => {
|
||||||
if (!editor.currentPageShapeIds.size) return
|
if (!editor.getCurrentPageShapeIds().size) return
|
||||||
|
|
||||||
const point = minimap.minimapScreenPointToPagePoint(e.clientX, e.clientY, false, false)
|
const point = minimap.minimapScreenPointToPagePoint(e.clientX, e.clientY, false, false)
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ export function Minimap({ shapeFill, selectFill, viewportFill }: MinimapProps) {
|
||||||
(e: React.PointerEvent<HTMLCanvasElement>) => {
|
(e: React.PointerEvent<HTMLCanvasElement>) => {
|
||||||
const elm = e.currentTarget
|
const elm = e.currentTarget
|
||||||
setPointerCapture(elm, e)
|
setPointerCapture(elm, e)
|
||||||
if (!editor.currentPageShapeIds.size) return
|
if (!editor.getCurrentPageShapeIds().size) return
|
||||||
|
|
||||||
rPointing.current = true
|
rPointing.current = true
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ export function Minimap({ shapeFill, selectFill, viewportFill }: MinimapProps) {
|
||||||
useQuickReactor(
|
useQuickReactor(
|
||||||
'minimap render when pagebounds or collaborators changes',
|
'minimap render when pagebounds or collaborators changes',
|
||||||
() => {
|
() => {
|
||||||
const { currentPageShapeIds: shapeIdsOnCurrentPage } = editor
|
const shapeIdsOnCurrentPage = editor.getCurrentPageShapeIds()
|
||||||
const commonBoundsOfAllShapesOnCurrentPage = editor.getCurrentPageBounds()
|
const commonBoundsOfAllShapesOnCurrentPage = editor.getCurrentPageBounds()
|
||||||
const viewportPageBounds = editor.getViewportPageBounds()
|
const viewportPageBounds = editor.getViewportPageBounds()
|
||||||
|
|
||||||
|
|
|
@ -301,7 +301,7 @@ export class MinimapManager {
|
||||||
const px = 2.5 / sx
|
const px = 2.5 / sx
|
||||||
const py = 2.5 / sy
|
const py = 2.5 / sy
|
||||||
|
|
||||||
const { currentPageId } = editor
|
const currentPageId = editor.getCurrentPageId()
|
||||||
|
|
||||||
let collaborator: TLInstancePresence
|
let collaborator: TLInstancePresence
|
||||||
for (let i = 0; i < this.collaborators.length; i++) {
|
for (let i = 0; i < this.collaborators.length; i++) {
|
||||||
|
|
|
@ -12,7 +12,7 @@ export const ZoomMenu = track(function ZoomMenu() {
|
||||||
const breakpoint = useBreakpoint()
|
const breakpoint = useBreakpoint()
|
||||||
|
|
||||||
const zoom = editor.getZoomLevel()
|
const zoom = editor.getZoomLevel()
|
||||||
const hasShapes = editor.currentPageShapeIds.size > 0
|
const hasShapes = editor.getCurrentPageShapeIds().size > 0
|
||||||
const hasSelected = editor.getSelectedShapeIds().length > 0
|
const hasSelected = editor.getSelectedShapeIds().length > 0
|
||||||
const isZoomedTo100 = editor.getZoomLevel() === 1
|
const isZoomedTo100 = editor.getZoomLevel() === 1
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,8 @@ export const PageMenu = function PageMenu() {
|
||||||
const rSortableContainer = useRef<HTMLDivElement>(null)
|
const rSortableContainer = useRef<HTMLDivElement>(null)
|
||||||
|
|
||||||
const pages = useValue('pages', () => editor.getPages(), [editor])
|
const pages = useValue('pages', () => editor.getPages(), [editor])
|
||||||
const currentPage = useValue('currentPage', () => editor.currentPage, [editor])
|
const currentPage = useValue('currentPage', () => editor.getCurrentPage(), [editor])
|
||||||
const currentPageId = useValue('currentPageId', () => editor.currentPageId, [editor])
|
const currentPageId = useValue('currentPageId', () => editor.getCurrentPageId(), [editor])
|
||||||
|
|
||||||
// When in readonly mode, we don't allow a user to edit the pages
|
// When in readonly mode, we don't allow a user to edit the pages
|
||||||
const isReadonlyMode = useReadonly()
|
const isReadonlyMode = useReadonly()
|
||||||
|
|
|
@ -35,6 +35,7 @@ export const Icon = memo(function Icon({
|
||||||
// HACK: Fix for <https://linear.app/tldraw/issue/TLD-1700/dragging-around-with-the-handtool-makes-lots-of-requests-for-icons>
|
// HACK: Fix for <https://linear.app/tldraw/issue/TLD-1700/dragging-around-with-the-handtool-makes-lots-of-requests-for-icons>
|
||||||
// It seems that passing `WebkitMask` to react will cause a render on each call, no idea why... but this appears to be the fix.
|
// It seems that passing `WebkitMask` to react will cause a render on each call, no idea why... but this appears to be the fix.
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
// eslint-disable-next-line deprecation/deprecation
|
||||||
ref.current.style.webkitMask = `url(${asset}) center 100% / 100% no-repeat`
|
ref.current.style.webkitMask = `url(${asset}) center 100% / 100% no-repeat`
|
||||||
}
|
}
|
||||||
}, [ref, asset, icon])
|
}, [ref, asset, icon])
|
||||||
|
|
|
@ -44,7 +44,7 @@ export async function pasteExcalidrawContent(editor: Editor, clipboard: any, poi
|
||||||
const groupShapeIdToChildren = new Map<string, TLShapeId[]>()
|
const groupShapeIdToChildren = new Map<string, TLShapeId[]>()
|
||||||
const rotatedElements = new Map<TLShapeId, number>()
|
const rotatedElements = new Map<TLShapeId, number>()
|
||||||
|
|
||||||
const { currentPageId } = editor
|
const currentPageId = editor.getCurrentPageId()
|
||||||
|
|
||||||
const excElementIdsToTldrawShapeIds = new Map<string, TLShapeId>()
|
const excElementIdsToTldrawShapeIds = new Map<string, TLShapeId>()
|
||||||
const rootShapeIds: TLShapeId[] = []
|
const rootShapeIds: TLShapeId[] = []
|
||||||
|
|
|
@ -64,7 +64,7 @@ export const TLUiContextMenuSchemaProvider = track(function TLUiContextMenuSchem
|
||||||
const threeStackableItems = useThreeStackableItems()
|
const threeStackableItems = useThreeStackableItems()
|
||||||
const atLeastOneShapeOnPage = useValue(
|
const atLeastOneShapeOnPage = useValue(
|
||||||
'atLeastOneShapeOnPage',
|
'atLeastOneShapeOnPage',
|
||||||
() => editor.currentPageShapeIds.size > 0,
|
() => editor.getCurrentPageShapeIds().size > 0,
|
||||||
[]
|
[]
|
||||||
)
|
)
|
||||||
const isTransparentBg = useValue(
|
const isTransparentBg = useValue(
|
||||||
|
|
|
@ -14,7 +14,7 @@ export function useExportAs() {
|
||||||
(ids: TLShapeId[], format: TLExportType = 'png') => {
|
(ids: TLShapeId[], format: TLExportType = 'png') => {
|
||||||
exportAs(editor, ids, format, {
|
exportAs(editor, ids, format, {
|
||||||
scale: 1,
|
scale: 1,
|
||||||
background: editor.instanceState.exportBackground,
|
background: editor.getInstanceState().exportBackground,
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
console.error(e.message)
|
console.error(e.message)
|
||||||
addToast({
|
addToast({
|
||||||
|
|
|
@ -62,7 +62,9 @@ export function TLUiMenuSchemaProvider({ overrides, children }: TLUiMenuSchemaPr
|
||||||
[editor]
|
[editor]
|
||||||
)
|
)
|
||||||
|
|
||||||
const emptyPage = useValue('emptyPage', () => editor.currentPageShapeIds.size === 0, [editor])
|
const emptyPage = useValue('emptyPage', () => editor.getCurrentPageShapeIds().size === 0, [
|
||||||
|
editor,
|
||||||
|
])
|
||||||
|
|
||||||
const selectedCount = useValue('selectedCount', () => editor.getSelectedShapeIds().length, [
|
const selectedCount = useValue('selectedCount', () => editor.getSelectedShapeIds().length, [
|
||||||
editor,
|
editor,
|
||||||
|
|
|
@ -165,6 +165,7 @@ export function usePrint() {
|
||||||
window.print()
|
window.print()
|
||||||
} else if (editor.environment.isSafari) {
|
} else if (editor.environment.isSafari) {
|
||||||
beforePrintHandler()
|
beforePrintHandler()
|
||||||
|
// eslint-disable-next-line deprecation/deprecation
|
||||||
document.execCommand('print', false)
|
document.execCommand('print', false)
|
||||||
} else {
|
} else {
|
||||||
window.print()
|
window.print()
|
||||||
|
@ -172,7 +173,7 @@ export function usePrint() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectedShapeIds = editor.getSelectedShapeIds()
|
const selectedShapeIds = editor.getSelectedShapeIds()
|
||||||
const { currentPageId } = editor
|
const currentPageId = editor.getCurrentPageId()
|
||||||
const pages = editor.getPages()
|
const pages = editor.getPages()
|
||||||
|
|
||||||
const preserveAspectRatio = 'xMidYMid meet'
|
const preserveAspectRatio = 'xMidYMid meet'
|
||||||
|
@ -205,7 +206,7 @@ export function usePrint() {
|
||||||
}
|
}
|
||||||
triggerPrint()
|
triggerPrint()
|
||||||
} else {
|
} else {
|
||||||
const page = editor.currentPage
|
const page = editor.getCurrentPage()
|
||||||
const svg = await editor.getSvg(editor.getSortedChildIdsForParent(page.id), svgOpts)
|
const svg = await editor.getSvg(editor.getSortedChildIdsForParent(page.id), svgOpts)
|
||||||
if (svg) {
|
if (svg) {
|
||||||
addPageToPrint(`tldraw — ${page.name}`, null, svg)
|
addPageToPrint(`tldraw — ${page.name}`, null, svg)
|
||||||
|
|
|
@ -26,9 +26,9 @@ export function copyAs(
|
||||||
const write = window.navigator.clipboard?.write
|
const write = window.navigator.clipboard?.write
|
||||||
|
|
||||||
return editor
|
return editor
|
||||||
.getSvg(ids?.length ? ids : [...editor.currentPageShapeIds], {
|
.getSvg(ids?.length ? ids : [...editor.getCurrentPageShapeIds()], {
|
||||||
scale: 1,
|
scale: 1,
|
||||||
background: editor.instanceState.exportBackground,
|
background: editor.getInstanceState().exportBackground,
|
||||||
...opts,
|
...opts,
|
||||||
})
|
})
|
||||||
.then((svg) => {
|
.then((svg) => {
|
||||||
|
|
|
@ -122,6 +122,7 @@ export async function getSvgAsDataUrl(svg: SVGElement) {
|
||||||
|
|
||||||
const svgStr = new XMLSerializer().serializeToString(clone)
|
const svgStr = new XMLSerializer().serializeToString(clone)
|
||||||
// NOTE: `unescape` works everywhere although deprecated
|
// NOTE: `unescape` works everywhere although deprecated
|
||||||
|
// eslint-disable-next-line deprecation/deprecation
|
||||||
const base64SVG = window.btoa(unescape(encodeURIComponent(svgStr)))
|
const base64SVG = window.btoa(unescape(encodeURIComponent(svgStr)))
|
||||||
return `data:image/svg+xml;base64,${base64SVG}`
|
return `data:image/svg+xml;base64,${base64SVG}`
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,55 +20,57 @@ export function exportAs(
|
||||||
format: TLExportType = 'png',
|
format: TLExportType = 'png',
|
||||||
opts = {} as Partial<TLSvgOptions>
|
opts = {} as Partial<TLSvgOptions>
|
||||||
) {
|
) {
|
||||||
return editor.getSvg(ids?.length ? ids : [...editor.currentPageShapeIds], opts).then((svg) => {
|
return editor
|
||||||
if (!svg) {
|
.getSvg(ids?.length ? ids : [...editor.getCurrentPageShapeIds()], opts)
|
||||||
throw new Error('Could not construct SVG.')
|
.then((svg) => {
|
||||||
}
|
if (!svg) {
|
||||||
|
throw new Error('Could not construct SVG.')
|
||||||
let name = 'shapes' + getTimestamp()
|
|
||||||
|
|
||||||
if (ids.length === 1) {
|
|
||||||
const first = editor.getShape(ids[0])!
|
|
||||||
if (editor.isShapeOfType<TLFrameShape>(first, 'frame')) {
|
|
||||||
name = first.props.name ?? 'frame'
|
|
||||||
} else {
|
|
||||||
name = first.id.replace(/:/, '_')
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
switch (format) {
|
let name = 'shapes' + getTimestamp()
|
||||||
case 'svg': {
|
|
||||||
getSvgAsDataUrl(svg).then((dataURL) => downloadDataURLAsFile(dataURL, `${name}.svg`))
|
if (ids.length === 1) {
|
||||||
return
|
const first = editor.getShape(ids[0])!
|
||||||
|
if (editor.isShapeOfType<TLFrameShape>(first, 'frame')) {
|
||||||
|
name = first.props.name ?? 'frame'
|
||||||
|
} else {
|
||||||
|
name = first.id.replace(/:/, '_')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case 'webp':
|
|
||||||
case 'png': {
|
switch (format) {
|
||||||
getSvgAsImage(svg, editor.environment.isSafari, {
|
case 'svg': {
|
||||||
type: format,
|
getSvgAsDataUrl(svg).then((dataURL) => downloadDataURLAsFile(dataURL, `${name}.svg`))
|
||||||
quality: 1,
|
return
|
||||||
scale: 2,
|
}
|
||||||
}).then((image) => {
|
case 'webp':
|
||||||
if (!image) throw Error()
|
case 'png': {
|
||||||
const dataURL = URL.createObjectURL(image)
|
getSvgAsImage(svg, editor.environment.isSafari, {
|
||||||
downloadDataURLAsFile(dataURL, `${name}.${format}`)
|
type: format,
|
||||||
|
quality: 1,
|
||||||
|
scale: 2,
|
||||||
|
}).then((image) => {
|
||||||
|
if (!image) throw Error()
|
||||||
|
const dataURL = URL.createObjectURL(image)
|
||||||
|
downloadDataURLAsFile(dataURL, `${name}.${format}`)
|
||||||
|
URL.revokeObjectURL(dataURL)
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'json': {
|
||||||
|
const data = editor.getContentFromCurrentPage(ids)
|
||||||
|
const blob = new Blob([JSON.stringify(data, null, 4)], { type: 'application/json' })
|
||||||
|
const dataURL = URL.createObjectURL(blob)
|
||||||
|
downloadDataURLAsFile(dataURL, `${name || 'shapes'}.json`)
|
||||||
URL.revokeObjectURL(dataURL)
|
URL.revokeObjectURL(dataURL)
|
||||||
})
|
return
|
||||||
return
|
}
|
||||||
}
|
|
||||||
|
|
||||||
case 'json': {
|
default:
|
||||||
const data = editor.getContentFromCurrentPage(ids)
|
throw new Error(`Export type ${format} not supported.`)
|
||||||
const blob = new Blob([JSON.stringify(data, null, 4)], { type: 'application/json' })
|
|
||||||
const dataURL = URL.createObjectURL(blob)
|
|
||||||
downloadDataURLAsFile(dataURL, `${name || 'shapes'}.json`)
|
|
||||||
URL.revokeObjectURL(dataURL)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
default:
|
|
||||||
throw new Error(`Export type ${format} not supported.`)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTimestamp() {
|
function getTimestamp() {
|
||||||
|
|
|
@ -109,7 +109,7 @@ export function buildFromV1Document(editor: Editor, document: LegacyTldrawDocume
|
||||||
.sort((a, b) => ((a.childIndex ?? 1) < (b.childIndex ?? 1) ? -1 : 1))
|
.sort((a, b) => ((a.childIndex ?? 1) < (b.childIndex ?? 1) ? -1 : 1))
|
||||||
.forEach((v1Page, i) => {
|
.forEach((v1Page, i) => {
|
||||||
if (i === 0) {
|
if (i === 0) {
|
||||||
v1PageIdsToV2PageIds.set(v1Page.id, editor.currentPageId)
|
v1PageIdsToV2PageIds.set(v1Page.id, editor.getCurrentPageId())
|
||||||
} else {
|
} else {
|
||||||
const pageId = PageRecordType.createId()
|
const pageId = PageRecordType.createId()
|
||||||
v1PageIdsToV2PageIds.set(v1Page.id, pageId)
|
v1PageIdsToV2PageIds.set(v1Page.id, pageId)
|
||||||
|
|
|
@ -35,7 +35,7 @@ beforeEach(() => {
|
||||||
{ id: ids.box3, type: 'geo', x: 500, y: 500, props: { w: 100, h: 100 }, parentId: ids.group1 },
|
{ id: ids.box3, type: 'geo', x: 500, y: 500, props: { w: 100, h: 100 }, parentId: ids.group1 },
|
||||||
])
|
])
|
||||||
|
|
||||||
const page1 = editor.currentPageId
|
const page1 = editor.getCurrentPageId()
|
||||||
editor.createPage({ name: 'page 2', id: ids.page2 })
|
editor.createPage({ name: 'page 2', id: ids.page2 })
|
||||||
editor.setCurrentPage(page1)
|
editor.setCurrentPage(page1)
|
||||||
})
|
})
|
||||||
|
@ -55,7 +55,7 @@ describe('shapes that are moved to another page', () => {
|
||||||
editor.setFocusedGroup(ids.group1)
|
editor.setFocusedGroup(ids.group1)
|
||||||
expect(editor.getFocusedGroupId()).toBe(ids.group1)
|
expect(editor.getFocusedGroupId()).toBe(ids.group1)
|
||||||
moveShapesToPage2()
|
moveShapesToPage2()
|
||||||
expect(editor.getFocusedGroupId()).toBe(editor.currentPageId)
|
expect(editor.getFocusedGroupId()).toBe(editor.getCurrentPageId())
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("should be excluded from the previous page's hintingShapeIds", () => {
|
describe("should be excluded from the previous page's hintingShapeIds", () => {
|
||||||
|
@ -492,7 +492,7 @@ describe('getShapeUtil', () => {
|
||||||
editor.createShapes([
|
editor.createShapes([
|
||||||
{ id: ids.box1, type: 'blorg', x: 100, y: 100, props: { w: 100, h: 100 } },
|
{ id: ids.box1, type: 'blorg', x: 100, y: 100, props: { w: 100, h: 100 } },
|
||||||
])
|
])
|
||||||
const page1 = editor.currentPageId
|
const page1 = editor.getCurrentPageId()
|
||||||
editor.createPage({ name: 'page 2', id: ids.page2 })
|
editor.createPage({ name: 'page 2', id: ids.page2 })
|
||||||
editor.setCurrentPage(page1)
|
editor.setCurrentPage(page1)
|
||||||
})
|
})
|
||||||
|
|
|
@ -47,7 +47,7 @@ describe('TLSelectTool.Translating', () => {
|
||||||
|
|
||||||
expect(editor.getCurrentPageShapes().length).toBe(1)
|
expect(editor.getCurrentPageShapes().length).toBe(1)
|
||||||
editor.expectShapeToMatch({ id: ids.box1, x: 150, y: 150 })
|
editor.expectShapeToMatch({ id: ids.box1, x: 150, y: 150 })
|
||||||
const t1 = [...editor.currentPageShapeIds.values()]
|
const t1 = [...editor.getCurrentPageShapeIds().values()]
|
||||||
|
|
||||||
editor.keyDown('Alt')
|
editor.keyDown('Alt')
|
||||||
expect(editor.getCurrentPageShapes().length).toBe(2)
|
expect(editor.getCurrentPageShapes().length).toBe(2)
|
||||||
|
@ -67,7 +67,7 @@ describe('TLSelectTool.Translating', () => {
|
||||||
|
|
||||||
editor.expectShapeToMatch({ id: ids.box1, x: 150, y: 150 })
|
editor.expectShapeToMatch({ id: ids.box1, x: 150, y: 150 })
|
||||||
|
|
||||||
expect([...editor.currentPageShapeIds.values()]).toMatchObject(t1)
|
expect([...editor.getCurrentPageShapeIds().values()]).toMatchObject(t1)
|
||||||
|
|
||||||
// todo: Should cloning again duplicate new shapes, or restore the last clone?
|
// todo: Should cloning again duplicate new shapes, or restore the last clone?
|
||||||
// editor.keyDown('Alt')
|
// editor.keyDown('Alt')
|
||||||
|
|
|
@ -95,7 +95,7 @@ describe('restoring bound arrows multiplayer', () => {
|
||||||
editor.undo() // undo creating the arrow
|
editor.undo() // undo creating the arrow
|
||||||
|
|
||||||
// arrow is gone too now
|
// arrow is gone too now
|
||||||
expect(editor.currentPageShapeIds.size).toBe(0)
|
expect(editor.getCurrentPageShapeIds().size).toBe(0)
|
||||||
|
|
||||||
editor.redo() // redo creating the arrow
|
editor.redo() // redo creating the arrow
|
||||||
|
|
||||||
|
@ -106,11 +106,11 @@ describe('restoring bound arrows multiplayer', () => {
|
||||||
|
|
||||||
editor.undo() // undo creating arrow
|
editor.undo() // undo creating arrow
|
||||||
|
|
||||||
expect(editor.currentPageShapeIds.size).toBe(0)
|
expect(editor.getCurrentPageShapeIds().size).toBe(0)
|
||||||
|
|
||||||
editor.undo() // undo creating box
|
editor.undo() // undo creating box
|
||||||
|
|
||||||
expect(editor.currentPageShapeIds.size).toBe(0)
|
expect(editor.getCurrentPageShapeIds().size).toBe(0)
|
||||||
|
|
||||||
editor.redo() // redo creating box
|
editor.redo() // redo creating box
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ beforeEach(() => {
|
||||||
|
|
||||||
it('gets common bounds', () => {
|
it('gets common bounds', () => {
|
||||||
// Put the ellipse back on the page to avoid a weird bounding box width
|
// Put the ellipse back on the page to avoid a weird bounding box width
|
||||||
editor.reparentShapes([defaultShapesIds.ellipse1], editor.currentPageId)
|
editor.reparentShapes([defaultShapesIds.ellipse1], editor.getCurrentPageId())
|
||||||
|
|
||||||
editor.updateShapes([
|
editor.updateShapes([
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,26 +8,26 @@ beforeEach(() => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Creates a page', () => {
|
it('Creates a page', () => {
|
||||||
const oldPageId = editor.currentPageId
|
const oldPageId = editor.getCurrentPageId()
|
||||||
const n = editor.getPages().length
|
const n = editor.getPages().length
|
||||||
editor.mark('creating new page')
|
editor.mark('creating new page')
|
||||||
editor.createPage({ name: 'Page 1' })
|
editor.createPage({ name: 'Page 1' })
|
||||||
expect(editor.getPages().length).toBe(n + 1)
|
expect(editor.getPages().length).toBe(n + 1)
|
||||||
const newPageId = editor.getPages()[n].id
|
const newPageId = editor.getPages()[n].id
|
||||||
// does not move to the new page right away
|
// does not move to the new page right away
|
||||||
expect(editor.currentPageId).toBe(oldPageId)
|
expect(editor.getCurrentPageId()).toBe(oldPageId)
|
||||||
|
|
||||||
// needs to be done manually
|
// needs to be done manually
|
||||||
editor.setCurrentPage(newPageId)
|
editor.setCurrentPage(newPageId)
|
||||||
expect(editor.currentPageId).toBe(newPageId)
|
expect(editor.getCurrentPageId()).toBe(newPageId)
|
||||||
|
|
||||||
editor.undo()
|
editor.undo()
|
||||||
expect(editor.getPages().length).toBe(n)
|
expect(editor.getPages().length).toBe(n)
|
||||||
expect(editor.currentPageId).toBe(oldPageId)
|
expect(editor.getCurrentPageId()).toBe(oldPageId)
|
||||||
|
|
||||||
editor.redo()
|
editor.redo()
|
||||||
expect(editor.getPages().length).toBe(n + 1)
|
expect(editor.getPages().length).toBe(n + 1)
|
||||||
expect(editor.currentPageId).toBe(newPageId)
|
expect(editor.getCurrentPageId()).toBe(newPageId)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("Doesn't create a page if max pages is reached", () => {
|
it("Doesn't create a page if max pages is reached", () => {
|
||||||
|
|
|
@ -84,7 +84,7 @@ it('Uses typescript generics', () => {
|
||||||
|
|
||||||
it('Parents shapes to the current page if the parent is not found', () => {
|
it('Parents shapes to the current page if the parent is not found', () => {
|
||||||
editor.createShapes([{ id: ids.box1, parentId: ids.missing, type: 'geo' }])
|
editor.createShapes([{ id: ids.box1, parentId: ids.missing, type: 'geo' }])
|
||||||
expect(editor.getShape(ids.box1)!.parentId).toEqual(editor.currentPageId)
|
expect(editor.getShape(ids.box1)!.parentId).toEqual(editor.getCurrentPageId())
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Creates shapes with the current style', () => {
|
it('Creates shapes with the current style', () => {
|
||||||
|
@ -118,13 +118,13 @@ it('Creates shapes at the correct index', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Throws out all shapes if any shape is invalid', () => {
|
it('Throws out all shapes if any shape is invalid', () => {
|
||||||
const n = editor.currentPageShapeIds.size
|
const n = editor.getCurrentPageShapeIds().size
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
editor.createShapes([{ id: ids.box1, type: 'geo' }])
|
editor.createShapes([{ id: ids.box1, type: 'geo' }])
|
||||||
}).not.toThrow()
|
}).not.toThrow()
|
||||||
|
|
||||||
expect(editor.currentPageShapeIds.size).toBe(n + 1)
|
expect(editor.getCurrentPageShapeIds().size).toBe(n + 1)
|
||||||
|
|
||||||
console.error = jest.fn()
|
console.error = jest.fn()
|
||||||
|
|
||||||
|
@ -137,5 +137,5 @@ it('Throws out all shapes if any shape is invalid', () => {
|
||||||
])
|
])
|
||||||
}).toThrow()
|
}).toThrow()
|
||||||
|
|
||||||
expect(editor.currentPageShapeIds.size).toBe(n + 1)
|
expect(editor.getCurrentPageShapeIds().size).toBe(n + 1)
|
||||||
})
|
})
|
||||||
|
|
|
@ -56,14 +56,14 @@ describe('deletePage', () => {
|
||||||
editor.mark('before creating page')
|
editor.mark('before creating page')
|
||||||
editor.createPage({ name: 'New Page 2', id: page2Id })
|
editor.createPage({ name: 'New Page 2', id: page2Id })
|
||||||
|
|
||||||
const currentPageId = editor.currentPageId
|
const currentPageId = editor.getCurrentPageId()
|
||||||
editor.deletePage(currentPageId)
|
editor.deletePage(currentPageId)
|
||||||
expect(editor.getPages().length).toBe(1)
|
expect(editor.getPages().length).toBe(1)
|
||||||
expect(editor.currentPageId).not.toBe(currentPageId)
|
expect(editor.getCurrentPageId()).not.toBe(currentPageId)
|
||||||
expect(editor.currentPageId).toBe(editor.getPages()[0].id)
|
expect(editor.getCurrentPageId()).toBe(editor.getPages()[0].id)
|
||||||
})
|
})
|
||||||
it('switches the page if another user or tab deletes the current page', () => {
|
it('switches the page if another user or tab deletes the current page', () => {
|
||||||
const currentPageId = editor.currentPageId
|
const currentPageId = editor.getCurrentPageId()
|
||||||
const page2Id = PageRecordType.createId('page2')
|
const page2Id = PageRecordType.createId('page2')
|
||||||
editor.mark('before creating')
|
editor.mark('before creating')
|
||||||
editor.createPage({ name: 'New Page 2', id: page2Id })
|
editor.createPage({ name: 'New Page 2', id: page2Id })
|
||||||
|
@ -73,7 +73,7 @@ describe('deletePage', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(editor.getPages().length).toBe(1)
|
expect(editor.getPages().length).toBe(1)
|
||||||
expect(editor.currentPageId).not.toBe(currentPageId)
|
expect(editor.getCurrentPageId()).not.toBe(currentPageId)
|
||||||
expect(editor.currentPageId).toBe(editor.getPages()[0].id)
|
expect(editor.getCurrentPageId()).toBe(editor.getPages()[0].id)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -14,21 +14,21 @@ beforeEach(() => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Duplicates a page', () => {
|
it('Duplicates a page', () => {
|
||||||
const oldPageId = editor.currentPageId
|
const oldPageId = editor.getCurrentPageId()
|
||||||
const camera = { ...editor.getCamera() }
|
const camera = { ...editor.getCamera() }
|
||||||
const n = editor.getPages().length
|
const n = editor.getPages().length
|
||||||
expect(editor.getCurrentPageShapes().length).toBe(1)
|
expect(editor.getCurrentPageShapes().length).toBe(1)
|
||||||
|
|
||||||
const existingIds = new Set(editor.getPages().map((s) => s.id))
|
const existingIds = new Set(editor.getPages().map((s) => s.id))
|
||||||
|
|
||||||
editor.duplicatePage(editor.currentPageId)
|
editor.duplicatePage(editor.getCurrentPageId())
|
||||||
|
|
||||||
// Creates the new page
|
// Creates the new page
|
||||||
expect(editor.getPages().length).toBe(n + 1)
|
expect(editor.getPages().length).toBe(n + 1)
|
||||||
|
|
||||||
// Navigates to the new page
|
// Navigates to the new page
|
||||||
const newPageId = editor.getPages().find((p) => !existingIds.has(p.id))!.id
|
const newPageId = editor.getPages().find((p) => !existingIds.has(p.id))!.id
|
||||||
expect(editor.currentPageId).toBe(newPageId)
|
expect(editor.getCurrentPageId()).toBe(newPageId)
|
||||||
|
|
||||||
// Duplicates the shapes
|
// Duplicates the shapes
|
||||||
expect(editor.getCurrentPageShapes().length).toBe(1)
|
expect(editor.getCurrentPageShapes().length).toBe(1)
|
||||||
|
@ -40,16 +40,16 @@ it('Duplicates a page', () => {
|
||||||
|
|
||||||
editor.undo()
|
editor.undo()
|
||||||
expect(editor.getPages().length).toBe(n)
|
expect(editor.getPages().length).toBe(n)
|
||||||
expect(editor.currentPageId).toBe(oldPageId)
|
expect(editor.getCurrentPageId()).toBe(oldPageId)
|
||||||
|
|
||||||
editor.redo()
|
editor.redo()
|
||||||
expect(editor.getPages().length).toBe(n + 1)
|
expect(editor.getPages().length).toBe(n + 1)
|
||||||
expect(editor.currentPageId).toBe(newPageId)
|
expect(editor.getCurrentPageId()).toBe(newPageId)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("Doesn't duplicate the page if max pages is reached", () => {
|
it("Doesn't duplicate the page if max pages is reached", () => {
|
||||||
for (let i = 0; i < MAX_PAGES; i++) {
|
for (let i = 0; i < MAX_PAGES; i++) {
|
||||||
editor.duplicatePage(editor.currentPageId)
|
editor.duplicatePage(editor.getCurrentPageId())
|
||||||
}
|
}
|
||||||
expect(editor.getPages().length).toBe(MAX_PAGES)
|
expect(editor.getPages().length).toBe(MAX_PAGES)
|
||||||
})
|
})
|
||||||
|
|
|
@ -14,18 +14,18 @@ const ids = {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
editor = new TestEditor()
|
editor = new TestEditor()
|
||||||
const page0Id = editor.currentPageId
|
const page0Id = editor.getCurrentPageId()
|
||||||
editor.createPage({ name: ids.page1, id: ids.page1 })
|
editor.createPage({ name: ids.page1, id: ids.page1 })
|
||||||
expect(editor.currentPageId).toBe(page0Id)
|
expect(editor.getCurrentPageId()).toBe(page0Id)
|
||||||
editor.setCurrentPage(ids.page1)
|
editor.setCurrentPage(ids.page1)
|
||||||
expect(editor.currentPageId).toBe(ids.page1)
|
expect(editor.getCurrentPageId()).toBe(ids.page1)
|
||||||
editor.createShapes([
|
editor.createShapes([
|
||||||
{ id: ids.ellipse1, type: 'geo', x: 0, y: 0, props: { geo: 'ellipse' } },
|
{ id: ids.ellipse1, type: 'geo', x: 0, y: 0, props: { geo: 'ellipse' } },
|
||||||
{ id: ids.box1, type: 'geo', x: 0, y: 0 },
|
{ id: ids.box1, type: 'geo', x: 0, y: 0 },
|
||||||
{ id: ids.box2, parentId: ids.box1, type: 'geo', x: 150, y: 150 },
|
{ id: ids.box2, parentId: ids.box1, type: 'geo', x: 150, y: 150 },
|
||||||
])
|
])
|
||||||
editor.createPage({ name: ids.page2, id: ids.page2 })
|
editor.createPage({ name: ids.page2, id: ids.page2 })
|
||||||
expect(editor.currentPageId).toBe(ids.page1)
|
expect(editor.getCurrentPageId()).toBe(ids.page1)
|
||||||
|
|
||||||
expect(editor.getShape(ids.box1)!.parentId).toEqual(ids.page1)
|
expect(editor.getShape(ids.box1)!.parentId).toEqual(ids.page1)
|
||||||
expect(editor.getShape(ids.box2)!.parentId).toEqual(ids.box1)
|
expect(editor.getShape(ids.box2)!.parentId).toEqual(ids.box1)
|
||||||
|
@ -34,7 +34,7 @@ beforeEach(() => {
|
||||||
describe('Editor.moveShapesToPage', () => {
|
describe('Editor.moveShapesToPage', () => {
|
||||||
it('Moves shapes to page', () => {
|
it('Moves shapes to page', () => {
|
||||||
editor.moveShapesToPage([ids.box2, ids.ellipse1], ids.page2)
|
editor.moveShapesToPage([ids.box2, ids.ellipse1], ids.page2)
|
||||||
expect(editor.currentPageId).toBe(ids.page2)
|
expect(editor.getCurrentPageId()).toBe(ids.page2)
|
||||||
|
|
||||||
expect(editor.getShape(ids.box2)!.parentId).toBe(ids.page2)
|
expect(editor.getShape(ids.box2)!.parentId).toBe(ids.page2)
|
||||||
expect(editor.getShape(ids.ellipse1)!.parentId).toBe(ids.page2)
|
expect(editor.getShape(ids.ellipse1)!.parentId).toBe(ids.page2)
|
||||||
|
@ -42,13 +42,13 @@ describe('Editor.moveShapesToPage', () => {
|
||||||
// box1 didn't get moved, still on page 1
|
// box1 didn't get moved, still on page 1
|
||||||
expect(editor.getShape(ids.box1)!.parentId).toBe(ids.page1)
|
expect(editor.getShape(ids.box1)!.parentId).toBe(ids.page1)
|
||||||
|
|
||||||
expect([...editor.currentPageShapeIds].sort()).toMatchObject([ids.box2, ids.ellipse1])
|
expect([...editor.getCurrentPageShapeIds()].sort()).toMatchObject([ids.box2, ids.ellipse1])
|
||||||
|
|
||||||
expect(editor.currentPageId).toBe(ids.page2)
|
expect(editor.getCurrentPageId()).toBe(ids.page2)
|
||||||
|
|
||||||
editor.setCurrentPage(ids.page1)
|
editor.setCurrentPage(ids.page1)
|
||||||
|
|
||||||
expect([...editor.currentPageShapeIds]).toEqual([ids.box1])
|
expect([...editor.getCurrentPageShapeIds()]).toEqual([ids.box1])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Moves children to page', () => {
|
it('Moves children to page', () => {
|
||||||
|
@ -83,24 +83,32 @@ describe('Editor.moveShapesToPage', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Restores on undo / redo', () => {
|
it('Restores on undo / redo', () => {
|
||||||
expect(editor.currentPageId).toBe(ids.page1)
|
expect(editor.getCurrentPageId()).toBe(ids.page1)
|
||||||
expect([...editor.currentPageShapeIds].sort()).toMatchObject([ids.box1, ids.box2, ids.ellipse1])
|
expect([...editor.getCurrentPageShapeIds()].sort()).toMatchObject([
|
||||||
|
ids.box1,
|
||||||
|
ids.box2,
|
||||||
|
ids.ellipse1,
|
||||||
|
])
|
||||||
|
|
||||||
editor.mark('move shapes to page')
|
editor.mark('move shapes to page')
|
||||||
editor.moveShapesToPage([ids.box2], ids.page2)
|
editor.moveShapesToPage([ids.box2], ids.page2)
|
||||||
|
|
||||||
expect(editor.currentPageId).toBe(ids.page2)
|
expect(editor.getCurrentPageId()).toBe(ids.page2)
|
||||||
expect([...editor.currentPageShapeIds].sort()).toMatchObject([ids.box2])
|
expect([...editor.getCurrentPageShapeIds()].sort()).toMatchObject([ids.box2])
|
||||||
|
|
||||||
editor.undo()
|
editor.undo()
|
||||||
|
|
||||||
expect(editor.currentPageId).toBe(ids.page1)
|
expect(editor.getCurrentPageId()).toBe(ids.page1)
|
||||||
expect([...editor.currentPageShapeIds].sort()).toMatchObject([ids.box1, ids.box2, ids.ellipse1])
|
expect([...editor.getCurrentPageShapeIds()].sort()).toMatchObject([
|
||||||
|
ids.box1,
|
||||||
|
ids.box2,
|
||||||
|
ids.ellipse1,
|
||||||
|
])
|
||||||
|
|
||||||
editor.redo()
|
editor.redo()
|
||||||
|
|
||||||
expect(editor.currentPageId).toBe(ids.page2)
|
expect(editor.getCurrentPageId()).toBe(ids.page2)
|
||||||
expect([...editor.currentPageShapeIds].sort()).toMatchObject([ids.box2])
|
expect([...editor.getCurrentPageShapeIds()].sort()).toMatchObject([ids.box2])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Sets the correct indices', () => {
|
it('Sets the correct indices', () => {
|
||||||
|
@ -109,7 +117,7 @@ describe('Editor.moveShapesToPage', () => {
|
||||||
|
|
||||||
editor.createPage({ name: 'New Page 2', id: page2Id })
|
editor.createPage({ name: 'New Page 2', id: page2Id })
|
||||||
editor.setCurrentPage(page2Id)
|
editor.setCurrentPage(page2Id)
|
||||||
expect(editor.currentPageId).toBe(page2Id)
|
expect(editor.getCurrentPageId()).toBe(page2Id)
|
||||||
editor.createShapes([{ id: ids.box1, type: 'geo', x: 0, y: 0, props: { geo: 'ellipse' } }])
|
editor.createShapes([{ id: ids.box1, type: 'geo', x: 0, y: 0, props: { geo: 'ellipse' } }])
|
||||||
editor.expectShapeToMatch({
|
editor.expectShapeToMatch({
|
||||||
id: ids.box1,
|
id: ids.box1,
|
||||||
|
@ -121,7 +129,7 @@ describe('Editor.moveShapesToPage', () => {
|
||||||
|
|
||||||
editor.createPage({ name: 'New Page 3', id: page3Id })
|
editor.createPage({ name: 'New Page 3', id: page3Id })
|
||||||
editor.setCurrentPage(page3Id)
|
editor.setCurrentPage(page3Id)
|
||||||
expect(editor.currentPageId).toBe(page3Id)
|
expect(editor.getCurrentPageId()).toBe(page3Id)
|
||||||
editor.createShapes([{ id: ids.box2, type: 'geo', x: 0, y: 0, props: { geo: 'ellipse' } }])
|
editor.createShapes([{ id: ids.box2, type: 'geo', x: 0, y: 0, props: { geo: 'ellipse' } }])
|
||||||
editor.expectShapeToMatch({
|
editor.expectShapeToMatch({
|
||||||
id: ids.box2,
|
id: ids.box2,
|
||||||
|
@ -133,7 +141,7 @@ describe('Editor.moveShapesToPage', () => {
|
||||||
editor.select(ids.box1)
|
editor.select(ids.box1)
|
||||||
editor.moveShapesToPage([ids.box1], page3Id)
|
editor.moveShapesToPage([ids.box1], page3Id)
|
||||||
|
|
||||||
expect(editor.currentPageId).toBe(page3Id)
|
expect(editor.getCurrentPageId()).toBe(page3Id)
|
||||||
|
|
||||||
editor.expectShapeToMatch(
|
editor.expectShapeToMatch(
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,11 +30,11 @@ beforeEach(() => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('reparents a shape', () => {
|
it('reparents a shape', () => {
|
||||||
expect(editor.getShape(ids.box2)!.parentId).toBe(editor.currentPageId)
|
expect(editor.getShape(ids.box2)!.parentId).toBe(editor.getCurrentPageId())
|
||||||
editor.reparentShapes([ids.box2], ids.box1)
|
editor.reparentShapes([ids.box2], ids.box1)
|
||||||
expect(editor.getShape(ids.box2)!.parentId).toBe(ids.box1)
|
expect(editor.getShape(ids.box2)!.parentId).toBe(ids.box1)
|
||||||
editor.reparentShapes([ids.box2], editor.currentPageId)
|
editor.reparentShapes([ids.box2], editor.getCurrentPageId())
|
||||||
expect(editor.getShape(ids.box2)!.parentId).toBe(editor.currentPageId)
|
expect(editor.getShape(ids.box2)!.parentId).toBe(editor.getCurrentPageId())
|
||||||
})
|
})
|
||||||
|
|
||||||
it('preserves shape page transfors', () => {
|
it('preserves shape page transfors', () => {
|
||||||
|
@ -63,7 +63,7 @@ it('adds children to the top of the parents children by default', () => {
|
||||||
expect(editor.getShape(ids.box2)!.index).toBe('a1')
|
expect(editor.getShape(ids.box2)!.index).toBe('a1')
|
||||||
expect(editor.getShape(ids.box3)!.index).toBe('a2')
|
expect(editor.getShape(ids.box3)!.index).toBe('a2')
|
||||||
|
|
||||||
editor.reparentShapes([ids.box2], editor.currentPageId)
|
editor.reparentShapes([ids.box2], editor.getCurrentPageId())
|
||||||
|
|
||||||
// When moving back, place at the top of the stack
|
// When moving back, place at the top of the stack
|
||||||
expect(editor.getShape(ids.box2)!.index).toBe('a6')
|
expect(editor.getShape(ids.box2)!.index).toBe('a6')
|
||||||
|
@ -143,7 +143,7 @@ it('adds children at a given index', () => {
|
||||||
|
|
||||||
// Handles collisions (trying to move boxes 2, 3, and 5 to a0, but box1 is there already)
|
// Handles collisions (trying to move boxes 2, 3, and 5 to a0, but box1 is there already)
|
||||||
// Should order them between box1 and box4
|
// Should order them between box1 and box4
|
||||||
editor.reparentShapes([ids.box2, ids.box3, ids.box5], editor.currentPageId, 'a1')
|
editor.reparentShapes([ids.box2, ids.box3, ids.box5], editor.getCurrentPageId(), 'a1')
|
||||||
|
|
||||||
// Page
|
// Page
|
||||||
// - box1 a1
|
// - box1 a1
|
||||||
|
|
|
@ -13,29 +13,29 @@ describe('setCurrentPage', () => {
|
||||||
const page2Id = PageRecordType.createId('page2')
|
const page2Id = PageRecordType.createId('page2')
|
||||||
|
|
||||||
editor.createPage({ name: 'New Page 2', id: page2Id })
|
editor.createPage({ name: 'New Page 2', id: page2Id })
|
||||||
expect(editor.currentPageId).toBe(page1Id)
|
expect(editor.getCurrentPageId()).toBe(page1Id)
|
||||||
|
|
||||||
editor.setCurrentPage(page2Id)
|
editor.setCurrentPage(page2Id)
|
||||||
expect(editor.currentPageId).toEqual(page2Id)
|
expect(editor.getCurrentPageId()).toEqual(page2Id)
|
||||||
|
|
||||||
expect(editor.currentPage).toEqual(editor.getPages()[1])
|
expect(editor.getCurrentPage()).toEqual(editor.getPages()[1])
|
||||||
|
|
||||||
editor.setCurrentPage(page1Id)
|
editor.setCurrentPage(page1Id)
|
||||||
|
|
||||||
expect(editor.currentPage).toEqual(editor.getPages()[0])
|
expect(editor.getCurrentPage()).toEqual(editor.getPages()[0])
|
||||||
|
|
||||||
const page3Id = PageRecordType.createId('page3')
|
const page3Id = PageRecordType.createId('page3')
|
||||||
editor.createPage({ name: 'New Page 3', id: page3Id })
|
editor.createPage({ name: 'New Page 3', id: page3Id })
|
||||||
expect(editor.currentPageId).toBe(page1Id)
|
expect(editor.getCurrentPageId()).toBe(page1Id)
|
||||||
editor.setCurrentPage(page3Id)
|
editor.setCurrentPage(page3Id)
|
||||||
|
|
||||||
expect(editor.currentPageId).toEqual(page3Id)
|
expect(editor.getCurrentPageId()).toEqual(page3Id)
|
||||||
expect(editor.currentPage).toEqual(editor.getPages()[2])
|
expect(editor.getCurrentPage()).toEqual(editor.getPages()[2])
|
||||||
|
|
||||||
editor.setCurrentPage(editor.getPages()[0].id)
|
editor.setCurrentPage(editor.getPages()[0].id)
|
||||||
|
|
||||||
expect(editor.currentPageId).toEqual(editor.getPages()[0].id)
|
expect(editor.getCurrentPageId()).toEqual(editor.getPages()[0].id)
|
||||||
expect(editor.currentPage).toEqual(editor.getPages()[0])
|
expect(editor.getCurrentPage()).toEqual(editor.getPages()[0])
|
||||||
})
|
})
|
||||||
|
|
||||||
it("adding a page to the store by any means adds tab state for the page if it doesn't already exist", () => {
|
it("adding a page to the store by any means adds tab state for the page if it doesn't already exist", () => {
|
||||||
|
@ -74,8 +74,8 @@ describe('setCurrentPage', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('logs an error when trying to navigate to a page that does not exist', () => {
|
it('logs an error when trying to navigate to a page that does not exist', () => {
|
||||||
const initialPageId = editor.currentPageId
|
const initialPageId = editor.getCurrentPageId()
|
||||||
expect(editor.currentPageId).toBe(initialPageId)
|
expect(editor.getCurrentPageId()).toBe(initialPageId)
|
||||||
console.error = jest.fn()
|
console.error = jest.fn()
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
|
@ -83,6 +83,6 @@ describe('setCurrentPage', () => {
|
||||||
}).not.toThrow()
|
}).not.toThrow()
|
||||||
|
|
||||||
expect(console.error).toHaveBeenCalled()
|
expect(console.error).toHaveBeenCalled()
|
||||||
expect(editor.currentPageId).toBe(initialPageId)
|
expect(editor.getCurrentPageId()).toBe(initialPageId)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -245,7 +245,7 @@ describe('frame shapes', () => {
|
||||||
{ type: 'geo', id: ids.boxA, x: 250, y: 250, props: { w: 50, h: 50, fill: 'solid' } },
|
{ type: 'geo', id: ids.boxA, x: 250, y: 250, props: { w: 50, h: 50, fill: 'solid' } },
|
||||||
])
|
])
|
||||||
|
|
||||||
expect(editor.getOnlySelectedShape()!.parentId).toBe(editor.currentPageId)
|
expect(editor.getOnlySelectedShape()!.parentId).toBe(editor.getCurrentPageId())
|
||||||
|
|
||||||
editor.setCurrentTool('select')
|
editor.setCurrentTool('select')
|
||||||
editor.pointerDown(275, 275).pointerMove(150, 150)
|
editor.pointerDown(275, 275).pointerMove(150, 150)
|
||||||
|
@ -258,7 +258,7 @@ describe('frame shapes', () => {
|
||||||
editor.pointerMove(275, 275)
|
editor.pointerMove(275, 275)
|
||||||
jest.advanceTimersByTime(250)
|
jest.advanceTimersByTime(250)
|
||||||
|
|
||||||
expect(editor.getOnlySelectedShape()!.parentId).toBe(editor.currentPageId)
|
expect(editor.getOnlySelectedShape()!.parentId).toBe(editor.getCurrentPageId())
|
||||||
|
|
||||||
editor.pointerMove(150, 150)
|
editor.pointerMove(150, 150)
|
||||||
jest.advanceTimersByTime(250)
|
jest.advanceTimersByTime(250)
|
||||||
|
@ -282,14 +282,14 @@ describe('frame shapes', () => {
|
||||||
])
|
])
|
||||||
|
|
||||||
// It should be a child of the page
|
// It should be a child of the page
|
||||||
expect(editor.getOnlySelectedShape()!.parentId).toBe(editor.currentPageId)
|
expect(editor.getOnlySelectedShape()!.parentId).toBe(editor.getCurrentPageId())
|
||||||
|
|
||||||
// Drag the shape on top of the frame
|
// Drag the shape on top of the frame
|
||||||
editor.setCurrentTool('select')
|
editor.setCurrentTool('select')
|
||||||
editor.pointerDown(275, 275, ids.boxA).pointerMove(150, 150)
|
editor.pointerDown(275, 275, ids.boxA).pointerMove(150, 150)
|
||||||
|
|
||||||
// The timeout has not fired yet, so the shape is still a child of the current page
|
// The timeout has not fired yet, so the shape is still a child of the current page
|
||||||
expect(editor.getOnlySelectedShape()!.parentId).toBe(editor.currentPageId)
|
expect(editor.getOnlySelectedShape()!.parentId).toBe(editor.getCurrentPageId())
|
||||||
|
|
||||||
// On pointer up, the shape should be dropped into the frame
|
// On pointer up, the shape should be dropped into the frame
|
||||||
editor.pointerUp()
|
editor.pointerUp()
|
||||||
|
@ -384,7 +384,7 @@ describe('frame shapes', () => {
|
||||||
})
|
})
|
||||||
expect(editor.snaps.getLines()).toHaveLength(0)
|
expect(editor.snaps.getLines()).toHaveLength(0)
|
||||||
// and if we unparent the box it should snap
|
// and if we unparent the box it should snap
|
||||||
editor.reparentShapes([innerBoxId], editor.currentPageId)
|
editor.reparentShapes([innerBoxId], editor.getCurrentPageId())
|
||||||
|
|
||||||
editor.pointerMove(287.5, 126.5).pointerMove(277.5, 126.5)
|
editor.pointerMove(287.5, 126.5).pointerMove(277.5, 126.5)
|
||||||
expect(editor.snaps.getLines()).toHaveLength(1)
|
expect(editor.snaps.getLines()).toHaveLength(1)
|
||||||
|
@ -441,7 +441,7 @@ describe('frame shapes', () => {
|
||||||
`"polygon(-50px -50px,50px -50px,50px 50px,-50px 50px)"`
|
`"polygon(-50px -50px,50px -50px,50px 50px,-50px 50px)"`
|
||||||
)
|
)
|
||||||
|
|
||||||
editor.reparentShapes([editor.getOnlySelectedShape()!.id], editor.currentPageId)
|
editor.reparentShapes([editor.getOnlySelectedShape()!.id], editor.getCurrentPageId())
|
||||||
|
|
||||||
expect(editor.getShapeClipPath(editor.getOnlySelectedShape()!.id)).toBeUndefined()
|
expect(editor.getShapeClipPath(editor.getOnlySelectedShape()!.id)).toBeUndefined()
|
||||||
})
|
})
|
||||||
|
@ -481,7 +481,7 @@ describe('frame shapes', () => {
|
||||||
expect(arrow.props.start).toMatchObject({ boundShapeId: frameId })
|
expect(arrow.props.start).toMatchObject({ boundShapeId: frameId })
|
||||||
expect(arrow.props.end).toMatchObject({ type: 'point' })
|
expect(arrow.props.end).toMatchObject({ type: 'point' })
|
||||||
|
|
||||||
expect(arrow.parentId).toBe(editor.currentPageId)
|
expect(arrow.parentId).toBe(editor.getCurrentPageId())
|
||||||
})
|
})
|
||||||
|
|
||||||
it('arrows started within the frame can bind to a shape within the frame ', () => {
|
it('arrows started within the frame can bind to a shape within the frame ', () => {
|
||||||
|
@ -506,7 +506,7 @@ describe('frame shapes', () => {
|
||||||
expect(arrow.props.start).toMatchObject({ boundShapeId: boxId })
|
expect(arrow.props.start).toMatchObject({ boundShapeId: boxId })
|
||||||
expect(arrow.props.end).toMatchObject({ boundShapeId: frameId })
|
expect(arrow.props.end).toMatchObject({ boundShapeId: frameId })
|
||||||
|
|
||||||
expect(arrow.parentId).toBe(editor.currentPageId)
|
expect(arrow.parentId).toBe(editor.getCurrentPageId())
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can be edited', () => {
|
it('can be edited', () => {
|
||||||
|
@ -706,9 +706,9 @@ test('arrows bound to a shape within a group within a frame are reparented if th
|
||||||
editor.translateSelection(200, 0)
|
editor.translateSelection(200, 0)
|
||||||
|
|
||||||
// expect group parent to be the page
|
// expect group parent to be the page
|
||||||
expect(editor.getShape(groupId)!.parentId).toBe(editor.currentPageId)
|
expect(editor.getShape(groupId)!.parentId).toBe(editor.getCurrentPageId())
|
||||||
// expect arrow parent to be the page
|
// expect arrow parent to be the page
|
||||||
expect(editor.getShape(arrowId)!.parentId).toBe(editor.currentPageId)
|
expect(editor.getShape(arrowId)!.parentId).toBe(editor.getCurrentPageId())
|
||||||
// expect arrow index to be greater than group index
|
// expect arrow index to be greater than group index
|
||||||
expect(editor.getShape(arrowId)?.index.localeCompare(editor.getShape(groupId)!.index)).toBe(1)
|
expect(editor.getShape(arrowId)?.index.localeCompare(editor.getShape(groupId)!.index)).toBe(1)
|
||||||
})
|
})
|
||||||
|
@ -772,6 +772,6 @@ describe('When dragging a shape inside a group inside a frame', () => {
|
||||||
|
|
||||||
jest.advanceTimersByTime(300)
|
jest.advanceTimersByTime(300)
|
||||||
|
|
||||||
expect(editor.getShape(ids.box1)!.parentId).toBe(editor.currentPageId)
|
expect(editor.getShape(ids.box1)!.parentId).toBe(editor.getCurrentPageId())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -272,9 +272,9 @@ describe('creating groups', () => {
|
||||||
expect(children(groupB).size).toBe(2)
|
expect(children(groupB).size).toBe(2)
|
||||||
expect(children(groupC).size).toBe(2)
|
expect(children(groupC).size).toBe(2)
|
||||||
|
|
||||||
expect(groupA.parentId).toBe(editor.currentPageId)
|
expect(groupA.parentId).toBe(editor.getCurrentPageId())
|
||||||
expect(groupB.parentId).toBe(editor.currentPageId)
|
expect(groupB.parentId).toBe(editor.getCurrentPageId())
|
||||||
expect(groupC.parentId).toBe(editor.currentPageId)
|
expect(groupC.parentId).toBe(editor.getCurrentPageId())
|
||||||
|
|
||||||
expect(editor.getShape(ids.boxA)!.parentId).toBe(groupA.id)
|
expect(editor.getShape(ids.boxA)!.parentId).toBe(groupA.id)
|
||||||
expect(editor.getShape(ids.boxC)!.parentId).toBe(groupA.id)
|
expect(editor.getShape(ids.boxC)!.parentId).toBe(groupA.id)
|
||||||
|
@ -320,7 +320,7 @@ describe('creating groups', () => {
|
||||||
.sort(sortByIndex)
|
.sort(sortByIndex)
|
||||||
.map((shape) => shape.id)
|
.map((shape) => shape.id)
|
||||||
|
|
||||||
const sortedIds = editor.getSortedChildIdsForParent(editor.currentPageId)
|
const sortedIds = editor.getSortedChildIdsForParent(editor.getCurrentPageId())
|
||||||
expect(sortedIds.length).toBe(3)
|
expect(sortedIds.length).toBe(3)
|
||||||
expect(sortedIds[0]).toBe(ids.boxA)
|
expect(sortedIds[0]).toBe(ids.boxA)
|
||||||
expect(sortedIds[1]).toBe(groupAId)
|
expect(sortedIds[1]).toBe(groupAId)
|
||||||
|
@ -354,7 +354,7 @@ describe('creating groups', () => {
|
||||||
.sort(sortByIndex)
|
.sort(sortByIndex)
|
||||||
.map((shape) => shape.id)
|
.map((shape) => shape.id)
|
||||||
|
|
||||||
const sortedIds = editor.getSortedChildIdsForParent(editor.currentPageId)
|
const sortedIds = editor.getSortedChildIdsForParent(editor.getCurrentPageId())
|
||||||
expect(sortedIds.length).toBe(3)
|
expect(sortedIds.length).toBe(3)
|
||||||
expect(sortedIds[0]).toBe(ids.boxB)
|
expect(sortedIds[0]).toBe(ids.boxB)
|
||||||
expect(sortedIds[1]).toBe(groupAId)
|
expect(sortedIds[1]).toBe(groupAId)
|
||||||
|
@ -827,7 +827,7 @@ describe('focus layers', () => {
|
||||||
editor.selectNone()
|
editor.selectNone()
|
||||||
})
|
})
|
||||||
it('should adjust to the parent layer of any selected shape', () => {
|
it('should adjust to the parent layer of any selected shape', () => {
|
||||||
expect(editor.getFocusedGroupId()).toBe(editor.currentPageId)
|
expect(editor.getFocusedGroupId()).toBe(editor.getCurrentPageId())
|
||||||
editor.select(ids.boxA)
|
editor.select(ids.boxA)
|
||||||
expect(editor.getFocusedGroupId()).toBe(groupAId)
|
expect(editor.getFocusedGroupId()).toBe(groupAId)
|
||||||
editor.select(ids.boxB)
|
editor.select(ids.boxB)
|
||||||
|
@ -840,7 +840,7 @@ describe('focus layers', () => {
|
||||||
expect(editor.getFocusedGroupId()).toBe(groupCId)
|
expect(editor.getFocusedGroupId()).toBe(groupCId)
|
||||||
})
|
})
|
||||||
it('should adjust to the common ancestor of selected shapes in multiple groups', () => {
|
it('should adjust to the common ancestor of selected shapes in multiple groups', () => {
|
||||||
expect(editor.getFocusedGroupId()).toBe(editor.currentPageId)
|
expect(editor.getFocusedGroupId()).toBe(editor.getCurrentPageId())
|
||||||
editor.select(ids.boxA)
|
editor.select(ids.boxA)
|
||||||
expect(editor.getFocusedGroupId()).toBe(groupAId)
|
expect(editor.getFocusedGroupId()).toBe(groupAId)
|
||||||
editor.setSelectedShapes([...editor.getSelectedShapeIds(), ids.boxC])
|
editor.setSelectedShapes([...editor.getSelectedShapeIds(), ids.boxC])
|
||||||
|
@ -851,7 +851,7 @@ describe('focus layers', () => {
|
||||||
expect(editor.getFocusedGroupId()).toBe(groupCId)
|
expect(editor.getFocusedGroupId()).toBe(groupCId)
|
||||||
})
|
})
|
||||||
it('should not adjust the focus layer when clearing the selection', () => {
|
it('should not adjust the focus layer when clearing the selection', () => {
|
||||||
expect(editor.getFocusedGroupId()).toBe(editor.currentPageId)
|
expect(editor.getFocusedGroupId()).toBe(editor.getCurrentPageId())
|
||||||
editor.select(ids.boxA)
|
editor.select(ids.boxA)
|
||||||
expect(editor.getFocusedGroupId()).toBe(groupAId)
|
expect(editor.getFocusedGroupId()).toBe(groupAId)
|
||||||
editor.deselect(ids.boxA)
|
editor.deselect(ids.boxA)
|
||||||
|
@ -924,7 +924,7 @@ describe('the select tool', () => {
|
||||||
it('should select the outermost non-selected group when you click on one of the shapes in that group', () => {
|
it('should select the outermost non-selected group when you click on one of the shapes in that group', () => {
|
||||||
editor.pointerDown(0, 0, ids.boxA).pointerUp(0, 0)
|
editor.pointerDown(0, 0, ids.boxA).pointerUp(0, 0)
|
||||||
expect(onlySelectedId()).toBe(groupCId)
|
expect(onlySelectedId()).toBe(groupCId)
|
||||||
expect(editor.getFocusedGroupId()).toBe(editor.currentPageId)
|
expect(editor.getFocusedGroupId()).toBe(editor.getCurrentPageId())
|
||||||
editor.pointerDown(0, 0, ids.boxA)
|
editor.pointerDown(0, 0, ids.boxA)
|
||||||
editor.pointerUp(0, 0, ids.boxA)
|
editor.pointerUp(0, 0, ids.boxA)
|
||||||
expect(onlySelectedId()).toBe(groupAId)
|
expect(onlySelectedId()).toBe(groupAId)
|
||||||
|
@ -941,7 +941,7 @@ describe('the select tool', () => {
|
||||||
.pointerDown(0, 0, { target: 'shape', shape: boxA, button: 2 })
|
.pointerDown(0, 0, { target: 'shape', shape: boxA, button: 2 })
|
||||||
.pointerUp(0, 0, { button: 2 })
|
.pointerUp(0, 0, { button: 2 })
|
||||||
expect(onlySelectedId()).toBe(groupCId)
|
expect(onlySelectedId()).toBe(groupCId)
|
||||||
expect(editor.getFocusedGroupId()).toBe(editor.currentPageId)
|
expect(editor.getFocusedGroupId()).toBe(editor.getCurrentPageId())
|
||||||
editor
|
editor
|
||||||
.pointerDown(0, 0, { target: 'shape', shape: boxA, button: 2 })
|
.pointerDown(0, 0, { target: 'shape', shape: boxA, button: 2 })
|
||||||
.pointerUp(0, 0, { button: 2 })
|
.pointerUp(0, 0, { button: 2 })
|
||||||
|
@ -981,7 +981,7 @@ describe('the select tool', () => {
|
||||||
|
|
||||||
// click outside the focused group, but inside another group
|
// click outside the focused group, but inside another group
|
||||||
editor.pointerDown(-235, 5, { target: 'canvas' }).pointerUp(-235, 5)
|
editor.pointerDown(-235, 5, { target: 'canvas' }).pointerUp(-235, 5)
|
||||||
expect(editor.getFocusedGroupId()).toBe(editor.currentPageId)
|
expect(editor.getFocusedGroupId()).toBe(editor.getCurrentPageId())
|
||||||
expect(editor.getSelectedShapeIds()).toHaveLength(0)
|
expect(editor.getSelectedShapeIds()).toHaveLength(0)
|
||||||
|
|
||||||
editor.select(ids.boxA)
|
editor.select(ids.boxA)
|
||||||
|
@ -989,7 +989,7 @@ describe('the select tool', () => {
|
||||||
|
|
||||||
// click the empty canvas
|
// click the empty canvas
|
||||||
editor.pointerDown(-235, 50, { target: 'canvas' }).pointerUp(-235, 50)
|
editor.pointerDown(-235, 50, { target: 'canvas' }).pointerUp(-235, 50)
|
||||||
expect(editor.getFocusedGroupId()).toBe(editor.currentPageId)
|
expect(editor.getFocusedGroupId()).toBe(editor.getCurrentPageId())
|
||||||
expect(editor.getSelectedShapeIds()).toHaveLength(0)
|
expect(editor.getSelectedShapeIds()).toHaveLength(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1026,10 +1026,10 @@ describe('the select tool', () => {
|
||||||
// pop focus layer
|
// pop focus layer
|
||||||
editor.cancel()
|
editor.cancel()
|
||||||
expect(editor.getSelectedShapeIds().length).toBe(1) // Group C
|
expect(editor.getSelectedShapeIds().length).toBe(1) // Group C
|
||||||
expect(editor.getFocusedGroupId()).toBe(editor.currentPageId)
|
expect(editor.getFocusedGroupId()).toBe(editor.getCurrentPageId())
|
||||||
editor.cancel()
|
editor.cancel()
|
||||||
expect(editor.getSelectedShapeIds().length).toBe(0)
|
expect(editor.getSelectedShapeIds().length).toBe(0)
|
||||||
expect(editor.getFocusedGroupId()).toBe(editor.currentPageId)
|
expect(editor.getFocusedGroupId()).toBe(editor.getCurrentPageId())
|
||||||
})
|
})
|
||||||
|
|
||||||
// ! Removed: pointing a group is impossible; you'd be pointing the selection instead.
|
// ! Removed: pointing a group is impossible; you'd be pointing the selection instead.
|
||||||
|
@ -1163,7 +1163,7 @@ describe('creating new shapes', () => {
|
||||||
editor.pointerDown(20, 20).pointerMove(80, 80).pointerUp(80, 80)
|
editor.pointerDown(20, 20).pointerMove(80, 80).pointerUp(80, 80)
|
||||||
const boxC = onlySelectedShape()
|
const boxC = onlySelectedShape()
|
||||||
|
|
||||||
expect(boxC.parentId).toBe(editor.currentPageId)
|
expect(boxC.parentId).toBe(editor.getCurrentPageId())
|
||||||
expect(editor.getShapePageBounds(boxC.id)).toCloselyMatchObject({
|
expect(editor.getShapePageBounds(boxC.id)).toCloselyMatchObject({
|
||||||
x: 20,
|
x: 20,
|
||||||
y: 20,
|
y: 20,
|
||||||
|
@ -1251,7 +1251,7 @@ describe('creating new shapes', () => {
|
||||||
editor.pointerDown(20, 20).pointerMove(80, 80).pointerUp(80, 80)
|
editor.pointerDown(20, 20).pointerMove(80, 80).pointerUp(80, 80)
|
||||||
|
|
||||||
const lineC = onlySelectedShape()
|
const lineC = onlySelectedShape()
|
||||||
expect(lineC.parentId).toBe(editor.currentPageId)
|
expect(lineC.parentId).toBe(editor.getCurrentPageId())
|
||||||
})
|
})
|
||||||
|
|
||||||
it('does draw inside the group if the group is focused', () => {
|
it('does draw inside the group if the group is focused', () => {
|
||||||
|
@ -1332,7 +1332,7 @@ describe('creating new shapes', () => {
|
||||||
|
|
||||||
const lineC = onlySelectedShape()
|
const lineC = onlySelectedShape()
|
||||||
expect(lineC.type).toBe('line')
|
expect(lineC.type).toBe('line')
|
||||||
expect(lineC.parentId).toBe(editor.currentPageId)
|
expect(lineC.parentId).toBe(editor.getCurrentPageId())
|
||||||
})
|
})
|
||||||
|
|
||||||
it('does draw inside the group if the group is focused', () => {
|
it('does draw inside the group if the group is focused', () => {
|
||||||
|
@ -1380,13 +1380,13 @@ describe('creating new shapes', () => {
|
||||||
describe('sticky notes', () => {
|
describe('sticky notes', () => {
|
||||||
it('does not draw inside the group if the group is only selected and not focused', () => {
|
it('does not draw inside the group if the group is only selected and not focused', () => {
|
||||||
editor.select(groupA.id)
|
editor.select(groupA.id)
|
||||||
expect(editor.getFocusedGroupId() === editor.currentPageId).toBe(true)
|
expect(editor.getFocusedGroupId() === editor.getCurrentPageId()).toBe(true)
|
||||||
|
|
||||||
editor.setCurrentTool('note')
|
editor.setCurrentTool('note')
|
||||||
editor.pointerDown(20, 20).pointerUp()
|
editor.pointerDown(20, 20).pointerUp()
|
||||||
|
|
||||||
const postit = onlySelectedShape()
|
const postit = onlySelectedShape()
|
||||||
expect(postit.parentId).toBe(editor.currentPageId)
|
expect(postit.parentId).toBe(editor.getCurrentPageId())
|
||||||
})
|
})
|
||||||
|
|
||||||
it('does draw inside the group if the group is focused', () => {
|
it('does draw inside the group if the group is focused', () => {
|
||||||
|
@ -1625,7 +1625,7 @@ describe('bindings', () => {
|
||||||
editor.pointerDown(5, 5).pointerMove(5, 25).pointerUp()
|
editor.pointerDown(5, 5).pointerMove(5, 25).pointerUp()
|
||||||
const arrow = onlySelectedShape() as TLArrowShape
|
const arrow = onlySelectedShape() as TLArrowShape
|
||||||
|
|
||||||
expect(arrow.parentId).toBe(editor.currentPageId)
|
expect(arrow.parentId).toBe(editor.getCurrentPageId())
|
||||||
|
|
||||||
expect(arrow.props.start).toMatchObject({ boundShapeId: ids.boxA })
|
expect(arrow.props.start).toMatchObject({ boundShapeId: ids.boxA })
|
||||||
expect(arrow.props.end).toMatchObject({ boundShapeId: ids.boxE })
|
expect(arrow.props.end).toMatchObject({ boundShapeId: ids.boxE })
|
||||||
|
@ -1648,7 +1648,7 @@ describe('bindings', () => {
|
||||||
editor.pointerDown(5, 25).pointerMove(27, 7).pointerMove(25, 5).pointerUp()
|
editor.pointerDown(5, 25).pointerMove(27, 7).pointerMove(25, 5).pointerUp()
|
||||||
const arrow = onlySelectedShape() as TLArrowShape
|
const arrow = onlySelectedShape() as TLArrowShape
|
||||||
|
|
||||||
expect(arrow.parentId).toBe(editor.currentPageId)
|
expect(arrow.parentId).toBe(editor.getCurrentPageId())
|
||||||
expect(arrow.props.start).toMatchObject({ boundShapeId: ids.boxE })
|
expect(arrow.props.start).toMatchObject({ boundShapeId: ids.boxE })
|
||||||
expect(arrow.props.end).toMatchObject({ boundShapeId: ids.boxB })
|
expect(arrow.props.end).toMatchObject({ boundShapeId: ids.boxB })
|
||||||
})
|
})
|
||||||
|
|
|
@ -47,7 +47,7 @@ describe('parentsToChildrenWithIndexes', () => {
|
||||||
{ type: 'geo', id: ids.box3 },
|
{ type: 'geo', id: ids.box3 },
|
||||||
])
|
])
|
||||||
|
|
||||||
expect(editor.getSortedChildIdsForParent(editor.currentPageId)).toEqual([
|
expect(editor.getSortedChildIdsForParent(editor.getCurrentPageId())).toEqual([
|
||||||
ids.box1,
|
ids.box1,
|
||||||
ids.box2,
|
ids.box2,
|
||||||
ids.box3,
|
ids.box3,
|
||||||
|
@ -61,7 +61,7 @@ describe('parentsToChildrenWithIndexes', () => {
|
||||||
{ type: 'geo', id: ids.box3 },
|
{ type: 'geo', id: ids.box3 },
|
||||||
])
|
])
|
||||||
|
|
||||||
expect(editor.getSortedChildIdsForParent(editor.currentPageId)).toEqual([
|
expect(editor.getSortedChildIdsForParent(editor.getCurrentPageId())).toEqual([
|
||||||
ids.box1,
|
ids.box1,
|
||||||
ids.box2,
|
ids.box2,
|
||||||
ids.box3,
|
ids.box3,
|
||||||
|
@ -74,7 +74,7 @@ describe('parentsToChildrenWithIndexes', () => {
|
||||||
index: getIndexBetween(editor.getShape(ids.box2)!.index, editor.getShape(ids.box3)!.index),
|
index: getIndexBetween(editor.getShape(ids.box2)!.index, editor.getShape(ids.box3)!.index),
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
expect(editor.getSortedChildIdsForParent(editor.currentPageId)).toEqual([
|
expect(editor.getSortedChildIdsForParent(editor.getCurrentPageId())).toEqual([
|
||||||
ids.box2,
|
ids.box2,
|
||||||
ids.box1,
|
ids.box1,
|
||||||
ids.box3,
|
ids.box3,
|
||||||
|
@ -84,7 +84,7 @@ describe('parentsToChildrenWithIndexes', () => {
|
||||||
{ id: ids.box2, type: 'geo', index: getIndexAbove(editor.getShape(ids.box3)!.index) },
|
{ id: ids.box2, type: 'geo', index: getIndexAbove(editor.getShape(ids.box3)!.index) },
|
||||||
])
|
])
|
||||||
|
|
||||||
expect(editor.getSortedChildIdsForParent(editor.currentPageId)).toEqual([
|
expect(editor.getSortedChildIdsForParent(editor.getCurrentPageId())).toEqual([
|
||||||
ids.box1,
|
ids.box1,
|
||||||
ids.box3,
|
ids.box3,
|
||||||
ids.box2,
|
ids.box2,
|
||||||
|
|
|
@ -171,8 +171,8 @@ describe('When pasting', () => {
|
||||||
editor.paste()
|
editor.paste()
|
||||||
|
|
||||||
const shapes = getShapes()
|
const shapes = getShapes()
|
||||||
expect(shapes.new.box1?.parentId).toBe(editor.currentPageId)
|
expect(shapes.new.box1?.parentId).toBe(editor.getCurrentPageId())
|
||||||
expect(shapes.new.box2?.parentId).toBe(editor.currentPageId)
|
expect(shapes.new.box2?.parentId).toBe(editor.getCurrentPageId())
|
||||||
|
|
||||||
expect(editor.getCurrentPageShapesSorted().map((m) => m.id)).toStrictEqual([
|
expect(editor.getCurrentPageShapesSorted().map((m) => m.id)).toStrictEqual([
|
||||||
shapes.old.frame1.id,
|
shapes.old.frame1.id,
|
||||||
|
@ -265,8 +265,8 @@ describe('When pasting', () => {
|
||||||
const shapes = getShapes()
|
const shapes = getShapes()
|
||||||
|
|
||||||
// Should make the pasted shapes the children of the frame
|
// Should make the pasted shapes the children of the frame
|
||||||
expect(shapes.new.box1?.parentId).toBe(editor.currentPageId)
|
expect(shapes.new.box1?.parentId).toBe(editor.getCurrentPageId())
|
||||||
expect(shapes.new.box2?.parentId).toBe(editor.currentPageId)
|
expect(shapes.new.box2?.parentId).toBe(editor.getCurrentPageId())
|
||||||
|
|
||||||
// Should put the pasted shapes centered in the frame
|
// Should put the pasted shapes centered in the frame
|
||||||
editor.select(shapes.new.box1!.id, shapes.new.box1!.id)
|
editor.select(shapes.new.box1!.id, shapes.new.box1!.id)
|
||||||
|
@ -357,7 +357,7 @@ it('pastes shapes with children', () => {
|
||||||
// Should make the pasted shapes the children of the frame
|
// Should make the pasted shapes the children of the frame
|
||||||
expect(shapes.new.box1.parentId).toBe(shapes.new.frame3.id)
|
expect(shapes.new.box1.parentId).toBe(shapes.new.frame3.id)
|
||||||
expect(shapes.new.box2.parentId).toBe(shapes.new.frame3.id)
|
expect(shapes.new.box2.parentId).toBe(shapes.new.frame3.id)
|
||||||
expect(shapes.new.frame3.parentId).toBe(editor.currentPageId)
|
expect(shapes.new.frame3.parentId).toBe(editor.getCurrentPageId())
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('When pasting into frames...', () => {
|
describe('When pasting into frames...', () => {
|
||||||
|
|
|
@ -580,7 +580,7 @@ describe('when shape is inside of a frame', () => {
|
||||||
editor.deleteShape(ids.box1)
|
editor.deleteShape(ids.box1)
|
||||||
editor.createShape({
|
editor.createShape({
|
||||||
id: ids.box5,
|
id: ids.box5,
|
||||||
parentId: editor.currentPageId,
|
parentId: editor.getCurrentPageId(),
|
||||||
type: 'geo',
|
type: 'geo',
|
||||||
props: {
|
props: {
|
||||||
w: 75,
|
w: 75,
|
||||||
|
@ -1330,15 +1330,15 @@ describe('When children / descendants of a group are selected', () => {
|
||||||
it('does not allow ancestors and children to be selected, picking the ancestor', () => {
|
it('does not allow ancestors and children to be selected, picking the ancestor', () => {
|
||||||
editor.select(ids.group3, ids.box1)
|
editor.select(ids.group3, ids.box1)
|
||||||
expect(editor.getSelectedShapeIds()).toEqual([ids.group3])
|
expect(editor.getSelectedShapeIds()).toEqual([ids.group3])
|
||||||
expect(editor.getFocusedGroupId()).toBe(editor.currentPageId)
|
expect(editor.getFocusedGroupId()).toBe(editor.getCurrentPageId())
|
||||||
|
|
||||||
editor.select(ids.group3, ids.box1, ids.box2)
|
editor.select(ids.group3, ids.box1, ids.box2)
|
||||||
expect(editor.getSelectedShapeIds()).toEqual([ids.group3])
|
expect(editor.getSelectedShapeIds()).toEqual([ids.group3])
|
||||||
expect(editor.getFocusedGroupId()).toBe(editor.currentPageId)
|
expect(editor.getFocusedGroupId()).toBe(editor.getCurrentPageId())
|
||||||
|
|
||||||
editor.select(ids.group3, ids.group2, ids.box1)
|
editor.select(ids.group3, ids.group2, ids.box1)
|
||||||
expect(editor.getSelectedShapeIds()).toEqual([ids.group3])
|
expect(editor.getSelectedShapeIds()).toEqual([ids.group3])
|
||||||
expect(editor.getFocusedGroupId()).toBe(editor.currentPageId)
|
expect(editor.getFocusedGroupId()).toBe(editor.getCurrentPageId())
|
||||||
})
|
})
|
||||||
|
|
||||||
it('picks the highest common focus layer id', () => {
|
it('picks the highest common focus layer id', () => {
|
||||||
|
@ -1350,16 +1350,16 @@ describe('When children / descendants of a group are selected', () => {
|
||||||
it('picks the highest common focus layer id', () => {
|
it('picks the highest common focus layer id', () => {
|
||||||
editor.select(ids.box1, ids.box5) // child of group1 and child of the page
|
editor.select(ids.box1, ids.box5) // child of group1 and child of the page
|
||||||
expect(editor.getSelectedShapeIds()).toEqual([ids.box1, ids.box5])
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box1, ids.box5])
|
||||||
expect(editor.getFocusedGroupId()).toBe(editor.currentPageId)
|
expect(editor.getFocusedGroupId()).toBe(editor.getCurrentPageId())
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets the parent to the highest common ancestor', () => {
|
it('sets the parent to the highest common ancestor', () => {
|
||||||
editor.selectNone()
|
editor.selectNone()
|
||||||
expect(editor.getFocusedGroupId()).toBe(editor.currentPageId)
|
expect(editor.getFocusedGroupId()).toBe(editor.getCurrentPageId())
|
||||||
editor.select(ids.group3)
|
editor.select(ids.group3)
|
||||||
expect(editor.getFocusedGroupId()).toBe(editor.currentPageId)
|
expect(editor.getFocusedGroupId()).toBe(editor.getCurrentPageId())
|
||||||
editor.select(ids.group3, ids.box1)
|
editor.select(ids.group3, ids.box1)
|
||||||
expect(editor.getFocusedGroupId()).toBe(editor.currentPageId)
|
expect(editor.getFocusedGroupId()).toBe(editor.getCurrentPageId())
|
||||||
expect(editor.getSelectedShapeIds()).toEqual([ids.group3])
|
expect(editor.getSelectedShapeIds()).toEqual([ids.group3])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1382,10 +1382,10 @@ describe('When pressing the enter key with groups selected', () => {
|
||||||
editor.select(ids.group1, ids.group2)
|
editor.select(ids.group1, ids.group2)
|
||||||
editor.keyDown('Enter')
|
editor.keyDown('Enter')
|
||||||
expect(editor.getSelectedShapeIds()).toEqual([ids.group1, ids.group2])
|
expect(editor.getSelectedShapeIds()).toEqual([ids.group1, ids.group2])
|
||||||
expect(editor.getFocusedGroupId()).toBe(editor.currentPageId)
|
expect(editor.getFocusedGroupId()).toBe(editor.getCurrentPageId())
|
||||||
editor.keyUp('Enter')
|
editor.keyUp('Enter')
|
||||||
expect(editor.getSelectedShapeIds()).toEqual([ids.box1, ids.box2, ids.box3, ids.box4])
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box1, ids.box2, ids.box3, ids.box4])
|
||||||
expect(editor.getFocusedGroupId()).toBe(editor.currentPageId)
|
expect(editor.getFocusedGroupId()).toBe(editor.getCurrentPageId())
|
||||||
})
|
})
|
||||||
|
|
||||||
it('repeats children of the groups on enter up', () => {
|
it('repeats children of the groups on enter up', () => {
|
||||||
|
|
|
@ -19,30 +19,32 @@ const ids = {
|
||||||
|
|
||||||
describe('shapeIdsInCurrentPage', () => {
|
describe('shapeIdsInCurrentPage', () => {
|
||||||
it('keeps the shape ids in the current page', () => {
|
it('keeps the shape ids in the current page', () => {
|
||||||
expect(new Set(editor.currentPageShapeIds)).toEqual(new Set([]))
|
expect(new Set(editor.getCurrentPageShapeIds())).toEqual(new Set([]))
|
||||||
editor.createShapes([{ type: 'geo', id: ids.box1 }])
|
editor.createShapes([{ type: 'geo', id: ids.box1 }])
|
||||||
|
|
||||||
expect(new Set(editor.currentPageShapeIds)).toEqual(new Set([ids.box1]))
|
expect(new Set(editor.getCurrentPageShapeIds())).toEqual(new Set([ids.box1]))
|
||||||
|
|
||||||
editor.createShapes([{ type: 'geo', id: ids.box2 }])
|
editor.createShapes([{ type: 'geo', id: ids.box2 }])
|
||||||
|
|
||||||
expect(new Set(editor.currentPageShapeIds)).toEqual(new Set([ids.box1, ids.box2]))
|
expect(new Set(editor.getCurrentPageShapeIds())).toEqual(new Set([ids.box1, ids.box2]))
|
||||||
|
|
||||||
editor.createShapes([{ type: 'geo', id: ids.box3 }])
|
editor.createShapes([{ type: 'geo', id: ids.box3 }])
|
||||||
|
|
||||||
expect(new Set(editor.currentPageShapeIds)).toEqual(new Set([ids.box1, ids.box2, ids.box3]))
|
expect(new Set(editor.getCurrentPageShapeIds())).toEqual(
|
||||||
|
new Set([ids.box1, ids.box2, ids.box3])
|
||||||
|
)
|
||||||
|
|
||||||
editor.deleteShapes([ids.box2])
|
editor.deleteShapes([ids.box2])
|
||||||
|
|
||||||
expect(new Set(editor.currentPageShapeIds)).toEqual(new Set([ids.box1, ids.box3]))
|
expect(new Set(editor.getCurrentPageShapeIds())).toEqual(new Set([ids.box1, ids.box3]))
|
||||||
|
|
||||||
editor.deleteShapes([ids.box1])
|
editor.deleteShapes([ids.box1])
|
||||||
|
|
||||||
expect(new Set(editor.currentPageShapeIds)).toEqual(new Set([ids.box3]))
|
expect(new Set(editor.getCurrentPageShapeIds())).toEqual(new Set([ids.box3]))
|
||||||
|
|
||||||
editor.deleteShapes([ids.box3])
|
editor.deleteShapes([ids.box3])
|
||||||
|
|
||||||
expect(new Set(editor.currentPageShapeIds)).toEqual(new Set([]))
|
expect(new Set(editor.getCurrentPageShapeIds())).toEqual(new Set([]))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('changes when the current page changes', () => {
|
it('changes when the current page changes', () => {
|
||||||
|
@ -60,10 +62,14 @@ describe('shapeIdsInCurrentPage', () => {
|
||||||
{ type: 'geo', id: ids.box6 },
|
{ type: 'geo', id: ids.box6 },
|
||||||
])
|
])
|
||||||
|
|
||||||
expect(new Set(editor.currentPageShapeIds)).toEqual(new Set([ids.box4, ids.box5, ids.box6]))
|
expect(new Set(editor.getCurrentPageShapeIds())).toEqual(
|
||||||
|
new Set([ids.box4, ids.box5, ids.box6])
|
||||||
|
)
|
||||||
|
|
||||||
editor.setCurrentPage(editor.getPages()[0].id)
|
editor.setCurrentPage(editor.getPages()[0].id)
|
||||||
|
|
||||||
expect(new Set(editor.currentPageShapeIds)).toEqual(new Set([ids.box1, ids.box2, ids.box3]))
|
expect(new Set(editor.getCurrentPageShapeIds())).toEqual(
|
||||||
|
new Set([ids.box1, ids.box2, ids.box3])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -23,7 +23,7 @@ function asPlainObject(styles: ReadonlySharedStyleMap | null) {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
editor = new TestEditor()
|
editor = new TestEditor()
|
||||||
editor.createShapes(createDefaultShapes())
|
editor.createShapes(createDefaultShapes())
|
||||||
editor.reparentShapes([defaultShapesIds.ellipse1], editor.currentPageId)
|
editor.reparentShapes([defaultShapesIds.ellipse1], editor.getCurrentPageId())
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Editor.styles', () => {
|
describe('Editor.styles', () => {
|
||||||
|
|
|
@ -173,15 +173,15 @@ describe('When cloning...', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clones a single shape and restores when stopping cloning', () => {
|
it('clones a single shape and restores when stopping cloning', () => {
|
||||||
expect(editor.currentPageShapeIds.size).toBe(3)
|
expect(editor.getCurrentPageShapeIds().size).toBe(3)
|
||||||
expect(editor.currentPageShapeIds.size).toBe(3)
|
expect(editor.getCurrentPageShapeIds().size).toBe(3)
|
||||||
editor.select(ids.box1).pointerDown(50, 50, ids.box1).pointerMove(50, 40) // [0, -10]
|
editor.select(ids.box1).pointerDown(50, 50, ids.box1).pointerMove(50, 40) // [0, -10]
|
||||||
expect(editor.currentPageShapeIds.size).toBe(3)
|
expect(editor.getCurrentPageShapeIds().size).toBe(3)
|
||||||
editor.expectShapeToMatch({ id: ids.box1, x: 10, y: 0 }) // Translated A...
|
editor.expectShapeToMatch({ id: ids.box1, x: 10, y: 0 }) // Translated A...
|
||||||
|
|
||||||
// Start cloning!
|
// Start cloning!
|
||||||
editor.keyDown('Alt')
|
editor.keyDown('Alt')
|
||||||
expect(editor.currentPageShapeIds.size).toBe(4)
|
expect(editor.getCurrentPageShapeIds().size).toBe(4)
|
||||||
const newShape = editor.getSelectedShapes()[0]
|
const newShape = editor.getSelectedShapes()[0]
|
||||||
expect(newShape.id).not.toBe(ids.box1)
|
expect(newShape.id).not.toBe(ids.box1)
|
||||||
|
|
||||||
|
@ -202,13 +202,13 @@ describe('When cloning...', () => {
|
||||||
|
|
||||||
it('clones multiple single shape and restores when stopping cloning', () => {
|
it('clones multiple single shape and restores when stopping cloning', () => {
|
||||||
editor.select(ids.box1, ids.box2).pointerDown(50, 50, ids.box1).pointerMove(50, 40) // [0, -10]
|
editor.select(ids.box1, ids.box2).pointerDown(50, 50, ids.box1).pointerMove(50, 40) // [0, -10]
|
||||||
expect(editor.currentPageShapeIds.size).toBe(3)
|
expect(editor.getCurrentPageShapeIds().size).toBe(3)
|
||||||
editor.expectShapeToMatch({ id: ids.box1, x: 10, y: 0 }) // Translated A...
|
editor.expectShapeToMatch({ id: ids.box1, x: 10, y: 0 }) // Translated A...
|
||||||
editor.expectShapeToMatch({ id: ids.box2, x: 200, y: 190 }) // Translated B...
|
editor.expectShapeToMatch({ id: ids.box2, x: 200, y: 190 }) // Translated B...
|
||||||
|
|
||||||
// Start cloning!
|
// Start cloning!
|
||||||
editor.keyDown('Alt')
|
editor.keyDown('Alt')
|
||||||
expect(editor.currentPageShapeIds.size).toBe(5) // Two new shapes!
|
expect(editor.getCurrentPageShapeIds().size).toBe(5) // Two new shapes!
|
||||||
const newShapeA = editor.getShape(editor.getSelectedShapeIds()[0])!
|
const newShapeA = editor.getShape(editor.getSelectedShapeIds()[0])!
|
||||||
const newShapeB = editor.getShape(editor.getSelectedShapeIds()[1])!
|
const newShapeB = editor.getShape(editor.getSelectedShapeIds()[1])!
|
||||||
expect(newShapeA).toBeDefined()
|
expect(newShapeA).toBeDefined()
|
||||||
|
@ -242,9 +242,9 @@ describe('When cloning...', () => {
|
||||||
expect(editor.getShape(ids.line1)!.parentId).toBe(ids.box2)
|
expect(editor.getShape(ids.line1)!.parentId).toBe(ids.box2)
|
||||||
editor.select(ids.box2).pointerDown(250, 250, ids.box2).pointerMove(250, 240) // [0, -10]
|
editor.select(ids.box2).pointerDown(250, 250, ids.box2).pointerMove(250, 240) // [0, -10]
|
||||||
|
|
||||||
expect(editor.currentPageShapeIds.size).toBe(3)
|
expect(editor.getCurrentPageShapeIds().size).toBe(3)
|
||||||
editor.keyDown('Alt', { altKey: true })
|
editor.keyDown('Alt', { altKey: true })
|
||||||
expect(editor.currentPageShapeIds.size).toBe(5) // Creates a clone of B and C (its descendant)
|
expect(editor.getCurrentPageShapeIds().size).toBe(5) // Creates a clone of B and C (its descendant)
|
||||||
|
|
||||||
const newShapeA = editor.getShape(editor.getSelectedShapeIds()[0])!
|
const newShapeA = editor.getShape(editor.getSelectedShapeIds()[0])!
|
||||||
const newShapeB = editor.getShape(editor.getSortedChildIdsForParent(newShapeA.id)[0])!
|
const newShapeB = editor.getShape(editor.getSortedChildIdsForParent(newShapeA.id)[0])!
|
||||||
|
@ -1730,7 +1730,7 @@ describe('When dragging a shape onto a parent', () => {
|
||||||
editor.pointerDown(550, 550, ids.box1).pointerMove(350, 350).pointerUp()
|
editor.pointerDown(550, 550, ids.box1).pointerMove(350, 350).pointerUp()
|
||||||
|
|
||||||
// It should not become the child of frame2 because it is clipped
|
// It should not become the child of frame2 because it is clipped
|
||||||
expect(editor.getShape(ids.box1)?.parentId).toBe(editor.currentPageId)
|
expect(editor.getShape(ids.box1)?.parentId).toBe(editor.getCurrentPageId())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -248,6 +248,9 @@ export function throttle<T extends (...args: any) => any>(func: T, limit: number
|
||||||
// @internal
|
// @internal
|
||||||
export function throttledRaf(fn: () => void): void;
|
export function throttledRaf(fn: () => void): void;
|
||||||
|
|
||||||
|
// @internal (undocumented)
|
||||||
|
export function warnDeprecatedGetter(name: string): void;
|
||||||
|
|
||||||
// (No @packageDocumentation comment for this package)
|
// (No @packageDocumentation comment for this package)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
@ -34,3 +34,4 @@ export { sortById } from './lib/sort'
|
||||||
export type { Expand, RecursivePartial, Required } from './lib/types'
|
export type { Expand, RecursivePartial, Required } from './lib/types'
|
||||||
export { isValidUrl } from './lib/url'
|
export { isValidUrl } from './lib/url'
|
||||||
export { isDefined, isNonNull, isNonNullish, structuredClone } from './lib/value'
|
export { isDefined, isNonNull, isNonNullish, structuredClone } from './lib/value'
|
||||||
|
export { warnDeprecatedGetter } from './lib/warnDeprecatedGetter'
|
||||||
|
|
15
packages/utils/src/lib/warnDeprecatedGetter.ts
Normal file
15
packages/utils/src/lib/warnDeprecatedGetter.ts
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
const warnedNames = new Set<string>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
export function warnDeprecatedGetter(name: string) {
|
||||||
|
if (warnedNames.has(name)) return
|
||||||
|
|
||||||
|
warnedNames.add(name)
|
||||||
|
console.warn(
|
||||||
|
`Using '${name}' is deprecated and will be removed in the near future. Please refactor to use 'get${name[0].toLocaleUpperCase()}${name.slice(
|
||||||
|
1
|
||||||
|
)}' instead.`
|
||||||
|
)
|
||||||
|
}
|
127
public-yarn.lock
127
public-yarn.lock
|
@ -2298,7 +2298,7 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@eslint-community/eslint-utils@npm:^4.2.0":
|
"@eslint-community/eslint-utils@npm:^4.2.0, @eslint-community/eslint-utils@npm:^4.4.0":
|
||||||
version: 4.4.0
|
version: 4.4.0
|
||||||
resolution: "@eslint-community/eslint-utils@npm:4.4.0"
|
resolution: "@eslint-community/eslint-utils@npm:4.4.0"
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -4514,6 +4514,7 @@ __metadata:
|
||||||
auto: ^10.46.0
|
auto: ^10.46.0
|
||||||
eslint: ^8.37.0
|
eslint: ^8.37.0
|
||||||
eslint-config-prettier: ^8.8.0
|
eslint-config-prettier: ^8.8.0
|
||||||
|
eslint-plugin-deprecation: ^2.0.0
|
||||||
eslint-plugin-import: ^2.27.5
|
eslint-plugin-import: ^2.27.5
|
||||||
eslint-plugin-local: ^1.0.0
|
eslint-plugin-local: ^1.0.0
|
||||||
eslint-plugin-no-only-tests: ^3.1.0
|
eslint-plugin-no-only-tests: ^3.1.0
|
||||||
|
@ -5047,6 +5048,13 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"@types/json-schema@npm:^7.0.12":
|
||||||
|
version: 7.0.15
|
||||||
|
resolution: "@types/json-schema@npm:7.0.15"
|
||||||
|
checksum: 97ed0cb44d4070aecea772b7b2e2ed971e10c81ec87dd4ecc160322ffa55ff330dace1793489540e3e318d90942064bb697cc0f8989391797792d919737b3b98
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"@types/json-schema@npm:^7.0.6, @types/json-schema@npm:^7.0.9":
|
"@types/json-schema@npm:^7.0.6, @types/json-schema@npm:^7.0.9":
|
||||||
version: 7.0.11
|
version: 7.0.11
|
||||||
resolution: "@types/json-schema@npm:7.0.11"
|
resolution: "@types/json-schema@npm:7.0.11"
|
||||||
|
@ -5296,6 +5304,13 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"@types/semver@npm:^7.5.0":
|
||||||
|
version: 7.5.5
|
||||||
|
resolution: "@types/semver@npm:7.5.5"
|
||||||
|
checksum: 533e6c93d1262d65f449423d94a445f7f3db0672e7429f21b6a1636d6051dbab3a2989ddcda9b79c69bb37830931d09fc958a65305a891357f5cea3257c297f5
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"@types/stack-utils@npm:^2.0.0":
|
"@types/stack-utils@npm:^2.0.0":
|
||||||
version: 2.0.1
|
version: 2.0.1
|
||||||
resolution: "@types/stack-utils@npm:2.0.1"
|
resolution: "@types/stack-utils@npm:2.0.1"
|
||||||
|
@ -5430,6 +5445,16 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"@typescript-eslint/scope-manager@npm:6.11.0":
|
||||||
|
version: 6.11.0
|
||||||
|
resolution: "@typescript-eslint/scope-manager@npm:6.11.0"
|
||||||
|
dependencies:
|
||||||
|
"@typescript-eslint/types": 6.11.0
|
||||||
|
"@typescript-eslint/visitor-keys": 6.11.0
|
||||||
|
checksum: d219a96fd80fb14176cdcc47b070e870c73ccc0dfb32a8657f6ceaefb613dc0ea240a77250dcfc437d9c9360ca165c2765d4cf8fe689dae7e9eee2c0d6a98a50
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"@typescript-eslint/type-utils@npm:5.59.0":
|
"@typescript-eslint/type-utils@npm:5.59.0":
|
||||||
version: 5.59.0
|
version: 5.59.0
|
||||||
resolution: "@typescript-eslint/type-utils@npm:5.59.0"
|
resolution: "@typescript-eslint/type-utils@npm:5.59.0"
|
||||||
|
@ -5454,6 +5479,13 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"@typescript-eslint/types@npm:6.11.0":
|
||||||
|
version: 6.11.0
|
||||||
|
resolution: "@typescript-eslint/types@npm:6.11.0"
|
||||||
|
checksum: ca8a11320286c9b0759a70ec83b9fd99937c9686fafdd41d8ea09ed7b2fa12e6b342bf65547efe5495926cd04cfc6488315920e3caffd27f12d42cb9a8cf88c8
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"@typescript-eslint/typescript-estree@npm:5.59.0":
|
"@typescript-eslint/typescript-estree@npm:5.59.0":
|
||||||
version: 5.59.0
|
version: 5.59.0
|
||||||
resolution: "@typescript-eslint/typescript-estree@npm:5.59.0"
|
resolution: "@typescript-eslint/typescript-estree@npm:5.59.0"
|
||||||
|
@ -5472,6 +5504,24 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"@typescript-eslint/typescript-estree@npm:6.11.0":
|
||||||
|
version: 6.11.0
|
||||||
|
resolution: "@typescript-eslint/typescript-estree@npm:6.11.0"
|
||||||
|
dependencies:
|
||||||
|
"@typescript-eslint/types": 6.11.0
|
||||||
|
"@typescript-eslint/visitor-keys": 6.11.0
|
||||||
|
debug: ^4.3.4
|
||||||
|
globby: ^11.1.0
|
||||||
|
is-glob: ^4.0.3
|
||||||
|
semver: ^7.5.4
|
||||||
|
ts-api-utils: ^1.0.1
|
||||||
|
peerDependenciesMeta:
|
||||||
|
typescript:
|
||||||
|
optional: true
|
||||||
|
checksum: e137ba7c4cad08853a44d9c40072496ca5f2d440828be9fd2d207a59db56b05a6dcb4756f3ba341ee2ae714de45df80114477946d30801c5a46eed67314fd9c6
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"@typescript-eslint/utils@npm:5.59.0, @typescript-eslint/utils@npm:^5.59.0":
|
"@typescript-eslint/utils@npm:5.59.0, @typescript-eslint/utils@npm:^5.59.0":
|
||||||
version: 5.59.0
|
version: 5.59.0
|
||||||
resolution: "@typescript-eslint/utils@npm:5.59.0"
|
resolution: "@typescript-eslint/utils@npm:5.59.0"
|
||||||
|
@ -5490,6 +5540,23 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"@typescript-eslint/utils@npm:^6.0.0":
|
||||||
|
version: 6.11.0
|
||||||
|
resolution: "@typescript-eslint/utils@npm:6.11.0"
|
||||||
|
dependencies:
|
||||||
|
"@eslint-community/eslint-utils": ^4.4.0
|
||||||
|
"@types/json-schema": ^7.0.12
|
||||||
|
"@types/semver": ^7.5.0
|
||||||
|
"@typescript-eslint/scope-manager": 6.11.0
|
||||||
|
"@typescript-eslint/types": 6.11.0
|
||||||
|
"@typescript-eslint/typescript-estree": 6.11.0
|
||||||
|
semver: ^7.5.4
|
||||||
|
peerDependencies:
|
||||||
|
eslint: ^7.0.0 || ^8.0.0
|
||||||
|
checksum: e90aa2c8c56038a48de65a5303f9e4a4a70bb0d4d0a05cfcd28157fc0f06b2fc186c2e76a495f4540a903ea37577daa1403bab923d940114ec27a6326153d60f
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"@typescript-eslint/visitor-keys@npm:5.59.0":
|
"@typescript-eslint/visitor-keys@npm:5.59.0":
|
||||||
version: 5.59.0
|
version: 5.59.0
|
||||||
resolution: "@typescript-eslint/visitor-keys@npm:5.59.0"
|
resolution: "@typescript-eslint/visitor-keys@npm:5.59.0"
|
||||||
|
@ -5500,6 +5567,16 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"@typescript-eslint/visitor-keys@npm:6.11.0":
|
||||||
|
version: 6.11.0
|
||||||
|
resolution: "@typescript-eslint/visitor-keys@npm:6.11.0"
|
||||||
|
dependencies:
|
||||||
|
"@typescript-eslint/types": 6.11.0
|
||||||
|
eslint-visitor-keys: ^3.4.1
|
||||||
|
checksum: 6aae9dd79963bbefbf2e310015b909627da541a13ab4d8359eea3c86c34fdbb91e583f65b5a99dee1959f7c5d67b21b45e5a05c63ddb4b82dacd60c890ce8b25
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"@ungap/promise-all-settled@npm:1.1.2":
|
"@ungap/promise-all-settled@npm:1.1.2":
|
||||||
version: 1.1.2
|
version: 1.1.2
|
||||||
resolution: "@ungap/promise-all-settled@npm:1.1.2"
|
resolution: "@ungap/promise-all-settled@npm:1.1.2"
|
||||||
|
@ -8872,6 +8949,20 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"eslint-plugin-deprecation@npm:^2.0.0":
|
||||||
|
version: 2.0.0
|
||||||
|
resolution: "eslint-plugin-deprecation@npm:2.0.0"
|
||||||
|
dependencies:
|
||||||
|
"@typescript-eslint/utils": ^6.0.0
|
||||||
|
tslib: ^2.3.1
|
||||||
|
tsutils: ^3.21.0
|
||||||
|
peerDependencies:
|
||||||
|
eslint: ^7.0.0 || ^8.0.0
|
||||||
|
typescript: ^4.2.4 || ^5.0.0
|
||||||
|
checksum: d79611e902ac419a21e51eab582fcdbcf8170aff820c5e5197e7d242e7ca6bda59c0077d88404970c25993017398dd65c96df7d31a833e332d45dd330935324b
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"eslint-plugin-import@npm:^2.27.5":
|
"eslint-plugin-import@npm:^2.27.5":
|
||||||
version: 2.27.5
|
version: 2.27.5
|
||||||
resolution: "eslint-plugin-import@npm:2.27.5"
|
resolution: "eslint-plugin-import@npm:2.27.5"
|
||||||
|
@ -8996,6 +9087,13 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"eslint-visitor-keys@npm:^3.4.1":
|
||||||
|
version: 3.4.3
|
||||||
|
resolution: "eslint-visitor-keys@npm:3.4.3"
|
||||||
|
checksum: 36e9ef87fca698b6fd7ca5ca35d7b2b6eeaaf106572e2f7fd31c12d3bfdaccdb587bba6d3621067e5aece31c8c3a348b93922ab8f7b2cbc6aaab5e1d89040c60
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"eslint@npm:^8.37.0":
|
"eslint@npm:^8.37.0":
|
||||||
version: 8.38.0
|
version: 8.38.0
|
||||||
resolution: "eslint@npm:8.38.0"
|
resolution: "eslint@npm:8.38.0"
|
||||||
|
@ -15667,6 +15765,17 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"semver@npm:^7.5.4":
|
||||||
|
version: 7.5.4
|
||||||
|
resolution: "semver@npm:7.5.4"
|
||||||
|
dependencies:
|
||||||
|
lru-cache: ^6.0.0
|
||||||
|
bin:
|
||||||
|
semver: bin/semver.js
|
||||||
|
checksum: 12d8ad952fa353b0995bf180cdac205a4068b759a140e5d3c608317098b3575ac2f1e09182206bf2eb26120e1c0ed8fb92c48c592f6099680de56bb071423ca3
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"send@npm:0.18.0":
|
"send@npm:0.18.0":
|
||||||
version: 0.18.0
|
version: 0.18.0
|
||||||
resolution: "send@npm:0.18.0"
|
resolution: "send@npm:0.18.0"
|
||||||
|
@ -16599,6 +16708,15 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"ts-api-utils@npm:^1.0.1":
|
||||||
|
version: 1.0.3
|
||||||
|
resolution: "ts-api-utils@npm:1.0.3"
|
||||||
|
peerDependencies:
|
||||||
|
typescript: ">=4.2.0"
|
||||||
|
checksum: 441cc4489d65fd515ae6b0f4eb8690057add6f3b6a63a36073753547fb6ce0c9ea0e0530220a0b282b0eec535f52c4dfc315d35f8a4c9a91c0def0707a714ca6
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"ts-dedent@npm:^2.2.0":
|
"ts-dedent@npm:^2.2.0":
|
||||||
version: 2.2.0
|
version: 2.2.0
|
||||||
resolution: "ts-dedent@npm:2.2.0"
|
resolution: "ts-dedent@npm:2.2.0"
|
||||||
|
@ -16787,6 +16905,13 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"tslib@npm:^2.3.1":
|
||||||
|
version: 2.6.2
|
||||||
|
resolution: "tslib@npm:2.6.2"
|
||||||
|
checksum: 329ea56123005922f39642318e3d1f0f8265d1e7fcb92c633e0809521da75eeaca28d2cf96d7248229deb40e5c19adf408259f4b9640afd20d13aecc1430f3ad
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"tsutils@npm:^3.21.0":
|
"tsutils@npm:^3.21.0":
|
||||||
version: 3.21.0
|
version: 3.21.0
|
||||||
resolution: "tsutils@npm:3.21.0"
|
resolution: "tsutils@npm:3.21.0"
|
||||||
|
|
Loading…
Reference in a new issue