From 2e1f0d93ab2e4d230d7d8c37f9ff7730e4b2f36d Mon Sep 17 00:00:00 2001 From: Jos Warmer Date: Thu, 31 Oct 2024 08:30:34 +0100 Subject: [PATCH 1/2] When creating a new expression skip thye left nmost action biox when setting the focus. --- packages/core/src/editor/FreEditor.ts | 9 ++++++--- packages/core/src/editor/actions/FreCreatePartCommand.ts | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/core/src/editor/FreEditor.ts b/packages/core/src/editor/FreEditor.ts index 01e12ef11..cc6ba819a 100644 --- a/packages/core/src/editor/FreEditor.ts +++ b/packages/core/src/editor/FreEditor.ts @@ -18,7 +18,7 @@ import { RoleProvider } from "./index.js"; import { FreError, FreErrorSeverity } from "../validator/index.js"; -import { isExpressionPreOrPost, isNullOrUndefined } from "../util/index.js"; +import { isExpressionPreOrPost, isNullOrUndefined, LEFT_MOST } from "../util/index.js"; import {FreErrorDecorator} from "./FreErrorDecorator.js"; const LOGGER = new FreLogger("FreEditor").mute(); @@ -292,9 +292,12 @@ export class FreEditor { * Sets 'element' to be the selectedElement, and its first child, which is editable, to the selectedBox. * @param element */ - selectFirstEditableChildBox(element: FreNode) { + selectFirstEditableChildBox(element: FreNode, skip: boolean = false) { if (this.checkParam(element)) { - const first = this.projection.getBox(element).firstEditableChild; + let first = this.projection.getBox(element).firstEditableChild; + if (skip && first.role === LEFT_MOST) { + first = first.nextLeafRight + } if (!isNullOrUndefined(first)) { this._selectedBox = first; this._selectedProperty = first.propertyName; diff --git a/packages/core/src/editor/actions/FreCreatePartCommand.ts b/packages/core/src/editor/actions/FreCreatePartCommand.ts index 12d69c2cf..feb427de7 100644 --- a/packages/core/src/editor/actions/FreCreatePartCommand.ts +++ b/packages/core/src/editor/actions/FreCreatePartCommand.ts @@ -93,7 +93,7 @@ export class FreCreatePartCommand extends FreCommand { " of kind " + editor.selectedBox.kind, ); - editor.selectFirstEditableChildBox(newElement); + editor.selectFirstEditableChildBox(newElement, true); }; } From 34533d9dd9c0b07d68e266cce7301c5444db2fc8 Mon Sep 17 00:00:00 2001 From: Jos Warmer Date: Thu, 31 Oct 2024 08:31:12 +0100 Subject: [PATCH 2/2] Fix several small TODO's --- packages/core/src/editor/util/FreExpressionUtil.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/core/src/editor/util/FreExpressionUtil.ts b/packages/core/src/editor/util/FreExpressionUtil.ts index 1efbe9e34..1b5ffc073 100644 --- a/packages/core/src/editor/util/FreExpressionUtil.ts +++ b/packages/core/src/editor/util/FreExpressionUtil.ts @@ -41,13 +41,9 @@ export function createDefaultExpressionBox(exp: FreExpressionNode, children: Box result = BoxFactory.horizontalLayout(exp, EXPRESSION, "", children); } if (isLeftMost) { - // TODO Change into Svelte Style - // result.insertChild(new ActionBox(exp, LEFT_MOST, NBSP, { style: STYLES.aliasExpression })); result.insertChild(BoxFactory.action(exp, LEFT_MOST, NBSP)); } if (isRightMost) { - // TODO Change into Svelte Style - // result.addChild(new ActionBox(exp, RIGHT_MOST, NBSP, { style: STYLES.aliasExpression })); result.addChild(BoxFactory.action(exp, RIGHT_MOST, NBSP)); } FreUtils.initializeObject(result, initializer); @@ -96,10 +92,8 @@ export function createDefaultBinaryBox( propertyName: "left", conceptName: leftConceptName, }), - // TODO Change into Svelte styles: style: STYLES.aliasExpression BoxFactory.action(exp, BEFORE_BINARY_OPERATOR, NBSP), createOperatorBox(editor, exp, symbol), - // TODO Change into Svelte styles: style: STYLES.aliasExpression BoxFactory.action(exp, AFTER_BINARY_OPERATOR, NBSP), !!exp.freRight() ? boxProviderCache.getBoxProvider(exp.freRight()).box