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

View File

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

View File

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

View File

@ -98,9 +98,8 @@ class XMLSerializerTango implements XMLMindmapSerializer {
const shape = topic.getShapeType();
if ($defined(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()}`);
}
}

View File

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

View File

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