From 0fb9650d4eef59df9900f8f5bc859d5623ee1344 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Fri, 10 Apr 2026 16:04:48 +0400 Subject: [PATCH] Allow dynamic boxRect for CanvasSpot (#6744) * Allow dynamic boxRect for CanvasSpot * Switch to ORG_NPM_TOKEN --- .github/workflows/publish-core-latest.yml | 2 +- .github/workflows/publish-core-rc.yml | 2 +- .github/workflows/publish.yml | 2 +- packages/core/src/canvas/model/CanvasSpot.ts | 7 ++++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish-core-latest.yml b/.github/workflows/publish-core-latest.yml index b548d43d9..434a3ed79 100644 --- a/.github/workflows/publish-core-latest.yml +++ b/.github/workflows/publish-core-latest.yml @@ -20,7 +20,7 @@ jobs: run: pnpm run ts:check - name: Publish to npm env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.ORG_NPM_TOKEN }} run: | echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" >> ./packages/core/.npmrc pnpm publish:core:latest diff --git a/.github/workflows/publish-core-rc.yml b/.github/workflows/publish-core-rc.yml index f1ea6b791..a9625948d 100644 --- a/.github/workflows/publish-core-rc.yml +++ b/.github/workflows/publish-core-rc.yml @@ -20,7 +20,7 @@ jobs: run: pnpm run ts:check - name: Publish to npm env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.ORG_NPM_TOKEN }} run: | echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" >> ./packages/core/.npmrc pnpm publish:core:rc diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0a67bc295..38fd2443f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -19,4 +19,4 @@ jobs: - run: yarn build - run: npm publish env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.ORG_NPM_TOKEN }} diff --git a/packages/core/src/canvas/model/CanvasSpot.ts b/packages/core/src/canvas/model/CanvasSpot.ts index 96c18e57e..2be1654e9 100644 --- a/packages/core/src/canvas/model/CanvasSpot.ts +++ b/packages/core/src/canvas/model/CanvasSpot.ts @@ -1,3 +1,4 @@ +import { isFunction } from 'underscore'; import CanvasModule from '..'; import { ModuleModel } from '../../abstract'; import { BoxRect, LiteralUnion } from '../../common'; @@ -31,7 +32,7 @@ export interface CanvasSpotBase { /** * Fixed box rect of the spot, eg. `{ width: 100, height: 100, x: 0, y: 0 }`. */ - boxRect?: BoxRect; + boxRect?: BoxRect | (() => BoxRect); /** * Component to which the spot will be attached. */ @@ -97,10 +98,10 @@ export default class CanvasSpot ext getBoxRect(opts?: GetBoxRectOptions) { const { el, em } = this; const cvView = em.Canvas.getCanvasView(); - const boxRect = this.get('boxRect'); + const boxRect = this.attributes.boxRect; if (boxRect) { - return boxRect; + return isFunction(boxRect) ? boxRect() : (boxRect as BoxRect); } else if (el && cvView) { return cvView.getElBoxRect(el, opts); }