Fix error on change color.

This commit is contained in:
Paulo Gustavo Veiga 2023-01-05 22:24:07 -08:00
parent 44c0a9ee9c
commit 12835ded0a
6 changed files with 20 additions and 21 deletions

View File

@ -779,8 +779,6 @@ class Designer extends Events {
} }
changeFontColor(color: string | undefined): void { changeFontColor(color: string | undefined): void {
$assert(color, 'color can not be null');
const topicsIds = this.getModel().filterTopicsIds(); const topicsIds = this.getModel().filterTopicsIds();
if (topicsIds.length > 0) { if (topicsIds.length > 0) {
@ -788,7 +786,6 @@ class Designer extends Events {
} }
} }
/** */
changeBackgroundColor(color: string | undefined): void { changeBackgroundColor(color: string | undefined): void {
const validateFunc = (topic: Topic) => topic.getShapeType() !== 'line'; const validateFunc = (topic: Topic) => topic.getShapeType() !== 'line';
const validateError = 'Color can not be set to line topics.'; const validateError = 'Color can not be set to line topics.';

View File

@ -476,7 +476,7 @@ abstract class Topic extends NodeGraph {
this.redraw(); this.redraw();
} }
setText(text: string | undefined) { setText(text: string | undefined): void {
// Avoid empty nodes ... // Avoid empty nodes ...
const modelText = !text || text.trim().length === 0 ? undefined : text; const modelText = !text || text.trim().length === 0 ? undefined : text;
@ -1250,8 +1250,10 @@ abstract class Topic extends NodeGraph {
} else { } else {
// In case of images, the size is fixed ... // In case of images, the size is fixed ...
const size = this.getModel().getImageSize(); const size = this.getModel().getImageSize();
if (size) {
this.setSize(size, false); this.setSize(size, false);
} }
}
if (redrawChildren) { if (redrawChildren) {
this.getChildren().forEach((t) => t.redraw(redrawChildren)); this.getChildren().forEach((t) => t.redraw(redrawChildren));

View File

@ -23,6 +23,7 @@ import { FontWeightType } from '../FontWeightType';
import { FontStyleType } from '../FontStyleType'; import { FontStyleType } from '../FontStyleType';
import FeatureModel from './FeatureModel'; import FeatureModel from './FeatureModel';
import Mindmap from './Mindmap'; import Mindmap from './Mindmap';
import SizeType from '../SizeType';
export type NodeModelType = 'CentralTopic' | 'MainTopic'; export type NodeModelType = 'CentralTopic' | 'MainTopic';
@ -93,14 +94,14 @@ abstract class INodeModel {
return result; return result;
} }
setImageSize(width: number, height: number) { setImageSize(width: number, height: number): void {
this.putProperty('imageSize', `{width:${width},height:${height}}`); this.putProperty('imageSize', `{width:${width},height:${height}}`);
} }
getImageSize(): { width: number; height: number } { getImageSize(): SizeType | undefined {
const value = this.getProperty('imageSize') as string; const value = this.getProperty('imageSize') as string;
let result; let result: SizeType | undefined;
if (value != null) { if (value) {
result = parseJsObject(value); result = parseJsObject(value);
} }
return result; return result;
@ -143,7 +144,7 @@ abstract class INodeModel {
this.putProperty('shapeType', type); this.putProperty('shapeType', type);
} }
setOrder(value: number) { setOrder(value: number): void {
$assert( $assert(
(typeof value === 'number' && Number.isFinite(value)) || value == null, (typeof value === 'number' && Number.isFinite(value)) || value == null,
'Order must be null or a number', 'Order must be null or a number',
@ -163,7 +164,7 @@ abstract class INodeModel {
return this.getProperty('fontFamily') as string; return this.getProperty('fontFamily') as string;
} }
setFontStyle(fontStyle: FontStyleType) { setFontStyle(fontStyle: FontStyleType | undefined) {
this.putProperty('fontStyle', fontStyle); this.putProperty('fontStyle', fontStyle);
} }
@ -336,9 +337,8 @@ abstract class INodeModel {
return result; return result;
} }
findNodeById(id: number): INodeModel { findNodeById(id: number): INodeModel | undefined {
$assert(Number.isFinite(id)); let result: INodeModel | undefined;
let result;
if (this.getId() === id) { if (this.getId() === id) {
result = this; result = this;
} else { } else {

View File

@ -98,9 +98,8 @@ class XMLSerializerTango implements XMLMindmapSerializer {
const shape = topic.getShapeType(); const shape = topic.getShapeType();
if ($defined(shape)) { if ($defined(shape)) {
parentTopic.setAttribute('shape', shape); parentTopic.setAttribute('shape', shape);
if (shape === 'image') {
const size = topic.getImageSize(); const size = topic.getImageSize();
if (shape === 'image' && size) {
parentTopic.setAttribute('image', `${size.width},${size.height}:${topic.getImageUrl()}`); parentTopic.setAttribute('image', `${size.width},${size.height}:${topic.getImageUrl()}`);
} }
} }

View File

@ -29,11 +29,13 @@ class ImageTopicShape extends Image {
const size = model.getImageSize(); const size = model.getImageSize();
super.setHref(url); super.setHref(url);
if (size) {
super.setSize(size.width, size.height); super.setSize(size.width, size.height);
}
this._topic = topic; this._topic = topic;
} }
getSize(): SizeType { getSize(): SizeType | undefined {
return this._topic.getModel().getImageSize(); return this._topic.getModel().getImageSize();
} }

View File

@ -1,6 +1,5 @@
const path = require('path');
/** @type {import('webpack').Configuration} */ /** @type {import('webpack').Configuration} */
module.exports = { module.exports = {
plugins: [new CleanWebpackPlugin()],
}; };