{
const url = `${this.documentUrl.replace('{id}', mapId)}/xml`;
+ const crfs = this.getCSRFToken();
+ const headers = {
+ 'Content-Type': 'text/plain; charset=utf-8',
+ Accept: 'application/xml',
+ };
+ if (crfs) {
+ headers['X-CSRF-Token'] = crfs;
+ }
+
return fetch(url, {
method: 'get',
- headers: {
- 'Content-Type': 'text/plain',
- Accept: 'application/xml',
- 'X-CSRF-Token': this.getCSRFToken(),
- },
+ headers,
})
.then((response: Response) => {
if (!response.ok) {
diff --git a/packages/mindplot/src/components/ScreenManager.ts b/packages/mindplot/src/components/ScreenManager.ts
index 390de950..1ed35f81 100644
--- a/packages/mindplot/src/components/ScreenManager.ts
+++ b/packages/mindplot/src/components/ScreenManager.ts
@@ -16,7 +16,7 @@
* limitations under the License.
*/
import $ from 'jquery';
-import { $assert, $defined } from '@wisemapping/core-js';
+import { $assert } from '@wisemapping/core-js';
import { Point } from '@wisemapping/web2d';
// https://stackoverflow.com/questions/60357083/does-not-use-passive-listeners-to-improve-scrolling-performance-lighthouse-repo
// https://web.dev/uses-passive-event-listeners/?utm_source=lighthouse&utm_medium=lr
diff --git a/packages/mindplot/src/components/Topic.ts b/packages/mindplot/src/components/Topic.ts
index ed1e6e0f..13d25de6 100644
--- a/packages/mindplot/src/components/Topic.ts
+++ b/packages/mindplot/src/components/Topic.ts
@@ -629,7 +629,7 @@ abstract class Topic extends NodeGraph {
group.setTestId(model.getId());
}
- _registerDefaultListenersToElement(elem: ElementClass, topic: Topic) {
+ private _registerDefaultListenersToElement(elem: ElementClass, topic: Topic) {
const mouseOver = function mouseOver() {
if (topic.isMouseEventsEnabled()) {
topic.handleMouseOver();
diff --git a/packages/mindplot/src/components/TopicStyle.js b/packages/mindplot/src/components/TopicStyle.ts
similarity index 76%
rename from packages/mindplot/src/components/TopicStyle.js
rename to packages/mindplot/src/components/TopicStyle.ts
index 37cb4beb..5f4e07bd 100644
--- a/packages/mindplot/src/components/TopicStyle.js
+++ b/packages/mindplot/src/components/TopicStyle.ts
@@ -15,59 +15,26 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import { $assert, $defined } from '@wisemapping/core-js';
+import { $assert } from '@wisemapping/core-js';
import { $msg } from './Messages';
import { TopicShape } from './model/INodeModel';
+import Topic from './Topic';
-class TopicStyle {
- static _getStyles(topic) {
- $assert(topic, 'topic can not be null');
+type TopicStyleType = {
+ borderColor: string;
+ backgroundColor: string;
+ fontStyle: {
+ font: string;
+ size: number;
+ style: string;
+ weight: string;
+ color: string;
+ };
+ msgKey: string;
+ shapeType: string;
+};
- let result;
- if (topic.isCentralTopic()) {
- result = TopicStyle.STYLES.CENTRAL_TOPIC;
- } else {
- const targetTopic = topic.getOutgoingConnectedTopic();
- if ($defined(targetTopic)) {
- if (targetTopic.isCentralTopic()) {
- result = TopicStyle.STYLES.MAIN_TOPIC;
- } else {
- result = TopicStyle.STYLES.SUB_TOPIC;
- }
- } else {
- result = TopicStyle.STYLES.ISOLATED_TOPIC;
- }
- }
- return result;
- }
-
- static defaultText(topic) {
- const { msgKey } = this._getStyles(topic);
- return $msg(msgKey);
- }
-
- static defaultFontStyle(topic) {
- return this._getStyles(topic).fontStyle;
- }
-
- static defaultBackgroundColor(topic) {
- return this._getStyles(topic).backgroundColor;
- }
-
- static defaultBorderColor(topic) {
- return this._getStyles(topic).borderColor;
- }
-
- static getInnerPadding(topic) {
- return Math.round(topic.getTextShape().getFontHeight() * 0.5);
- }
-
- static defaultShapeType(topic) {
- return this._getStyles(topic).shapeType;
- }
-}
-
-TopicStyle.STYLES = {
+const TopicDefaultStyles = {
CENTRAL_TOPIC: {
borderColor: 'rgb(57,113,177)',
backgroundColor: 'rgb(80,157,192)',
@@ -81,7 +48,6 @@ TopicStyle.STYLES = {
msgKey: 'CENTRAL_TOPIC',
shapeType: TopicShape.ROUNDED_RECT,
},
-
MAIN_TOPIC: {
borderColor: 'rgb(2,59,185)',
backgroundColor: 'rgb(224,229,239)',
@@ -95,7 +61,6 @@ TopicStyle.STYLES = {
msgKey: 'MAIN_TOPIC',
shapeType: TopicShape.LINE,
},
-
SUB_TOPIC: {
borderColor: 'rgb(2,59,185)',
backgroundColor: 'rgb(224,229,239)',
@@ -125,4 +90,52 @@ TopicStyle.STYLES = {
},
};
+class TopicStyle {
+ static _getStyles(topic: Topic): TopicStyleType {
+ $assert(topic, 'topic can not be null');
+
+ let result: TopicStyleType;
+ if (topic.isCentralTopic()) {
+ result = TopicDefaultStyles.CENTRAL_TOPIC;
+ } else {
+ const targetTopic = topic.getOutgoingConnectedTopic();
+ if (targetTopic) {
+ if (targetTopic.isCentralTopic()) {
+ result = TopicDefaultStyles.MAIN_TOPIC;
+ } else {
+ result = TopicDefaultStyles.SUB_TOPIC;
+ }
+ } else {
+ result = TopicDefaultStyles.ISOLATED_TOPIC;
+ }
+ }
+ return result;
+ }
+
+ static defaultText(topic: Topic) {
+ const { msgKey } = this._getStyles(topic);
+ return $msg(msgKey);
+ }
+
+ static defaultFontStyle(topic: Topic) {
+ return this._getStyles(topic).fontStyle;
+ }
+
+ static defaultBackgroundColor(topic: Topic) {
+ return this._getStyles(topic).backgroundColor;
+ }
+
+ static defaultBorderColor(topic: Topic) {
+ return this._getStyles(topic).borderColor;
+ }
+
+ static getInnerPadding(topic: Topic) {
+ return Math.round(topic.getTextShape().getFontHeight() * 0.5);
+ }
+
+ static defaultShapeType(topic) {
+ return this._getStyles(topic).shapeType;
+ }
+}
+
export default TopicStyle;
diff --git a/packages/mindplot/src/components/WidgetManager.ts b/packages/mindplot/src/components/WidgetManager.ts
index 821b9382..7dd4aa6d 100644
--- a/packages/mindplot/src/components/WidgetManager.ts
+++ b/packages/mindplot/src/components/WidgetManager.ts
@@ -24,9 +24,11 @@ abstract class WidgetManager {
linkModel?: LinkModel,
noteModel?: NoteModel,
) {
- const webcomponentShadowRoot = $($('#mindmap-comp')[0].shadowRoot);
+ const { shadowRoot } = $('#mindmap-comp')[0];
+ const webcomponentShadowRoot = $(shadowRoot!);
+
let tooltip = webcomponentShadowRoot.find('#mindplot-svg-tooltip');
- if (!tooltip.length) {
+ if (!tooltip.length || !tooltip) {
webcomponentShadowRoot.append(
'