Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions code/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- [#288](https://github.com/InditexTech/weavejs/issues/288) Provide a tool for erasing elements

### Fixed

- [#290](https://github.com/InditexTech/weavejs/issues/290) Maintain text node size when changed

## [0.18.0] - 2025-05-27

### Changed
Expand Down
6 changes: 6 additions & 0 deletions code/packages/sdk/src/actions/text-tool/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ export const TEXT_TOOL_STATE = {
['ADDING']: 'adding',
['FINISHED']: 'finished',
} as const;

export const TEXT_LAYOUT = {
['AUTO_ALL']: 'auto-all',
['AUTO_HEIGHT']: 'auto-height',
['FIXED']: 'fixed',
} as const;
11 changes: 8 additions & 3 deletions code/packages/sdk/src/actions/text-tool/text-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import { v4 as uuidv4 } from 'uuid';
import { WeaveAction } from '@/actions/action';
import { type Vector2d } from 'konva/lib/types';
import { type WeaveTextToolActionState } from './types';
import { TEXT_TOOL_ACTION_NAME, TEXT_TOOL_STATE } from './constants';
import {
TEXT_LAYOUT,
TEXT_TOOL_ACTION_NAME,
TEXT_TOOL_STATE,
} from './constants';
import Konva from 'konva';
import { WeaveNodesSelectionPlugin } from '@/plugins/nodes-selection/nodes-selection';
import type { WeaveTextNode } from '@/nodes/text/text';
Expand Down Expand Up @@ -103,8 +107,9 @@ export class WeaveTextToolAction extends WeaveAction {
const node = nodeHandler.create(this.textId, {
x: this.clickPoint?.x ?? 0,
y: this.clickPoint?.y ?? 0,
text: 'Your text here...',
width: 300,
text: '',
layout: TEXT_LAYOUT.AUTO_ALL,
width: 10,
fontSize: 20,
fontFamily: 'Arial, sans-serif',
fill: '#000000ff',
Expand Down
8 changes: 6 additions & 2 deletions code/packages/sdk/src/actions/text-tool/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
//
// SPDX-License-Identifier: Apache-2.0

import { TEXT_TOOL_STATE } from "./constants";
import { TEXT_TOOL_STATE, TEXT_LAYOUT } from './constants';

export type WeaveTextToolActionStateKeys = keyof typeof TEXT_TOOL_STATE;
export type WeaveTextToolActionState = (typeof TEXT_TOOL_STATE)[WeaveTextToolActionStateKeys];
export type WeaveTextToolActionState =
(typeof TEXT_TOOL_STATE)[WeaveTextToolActionStateKeys];

export type WeaveTextLayoutKeys = keyof typeof TEXT_LAYOUT;
export type WeaveTextLayout = (typeof TEXT_LAYOUT)[WeaveTextLayoutKeys];
Loading