Skip to content

Commit

Permalink
Fix graph editor and small text editor bug
Browse files Browse the repository at this point in the history
  • Loading branch information
vezwork committed Oct 16, 2023
1 parent 6c75a7c commit 6f4e7cc
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 502 deletions.
4 changes: 2 additions & 2 deletions lib/dist/editors/ColoredGraphEditorElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class ColoredGraphEditorElement extends EditorElement {
this.shadowRoot.append(editor);
this.blur();
setTimeout(() => editor.focusEditor());
this.fromNode = node;
//this.fromNode = node;
this.render();
this.parentEditor?.dispatchEvent(new CustomEvent("childEditorUpdate", {
detail: {
Expand All @@ -124,7 +124,7 @@ export class ColoredGraphEditorElement extends EditorElement {
}));
});
this.addEventListener("mouseup", (e) => {
const targetEl = e.path[0];
const targetEl = e.composedPath()[0];
const targetNode = this.nodes.find(({ editor }) => editor.contains(targetEl) || editor.shadowRoot.contains(targetEl));
if (targetNode) {
if (this.fromNode &&
Expand Down
4 changes: 2 additions & 2 deletions lib/dist/editors/ForceColoredGraphEditorElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class ForceColoredGraphEditorElement extends EditorElement {
this.shadowRoot.append(editor);
this.blur();
setTimeout(() => editor.focusEditor());
this.fromNode = node;
//this.fromNode = node;
this.render();
this.parentEditor?.dispatchEvent(new CustomEvent("childEditorUpdate", {
detail: {
Expand All @@ -125,7 +125,7 @@ export class ForceColoredGraphEditorElement extends EditorElement {
}));
});
this.addEventListener("mouseup", (e) => {
const targetEl = e.path[0];
const targetEl = e.composedPath()[0];
const targetNode = this.nodes.find(({ editor }) => editor.contains(targetEl) || editor.shadowRoot.contains(targetEl));
if (targetNode) {
if (this.fromNode &&
Expand Down
8 changes: 5 additions & 3 deletions lib/dist/editors/ForceGraphEditorElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class ForceGraphEditorElement extends EditorElement {
this.shadowRoot.append(editor);
this.blur();
setTimeout(() => editor.focusEditor());
this.fromNode = node;
//this.fromNode = node;
this.render();
new CustomEvent("childEditorUpdate", {
detail: {
Expand All @@ -107,8 +107,10 @@ export class ForceGraphEditorElement extends EditorElement {
});
});
this.addEventListener("mouseup", (e) => {
const targetEl = e.path[0];
const targetNode = this.nodes.find(({ editor }) => editor.contains(targetEl) || editor.shadowRoot.contains(targetEl));
const targetEl = e.composedPath()[0];
const targetNode = this.nodes.find(({ editor }) => editor === targetEl ||
editor.contains(targetEl) ||
editor.shadowRoot.contains(targetEl));
if (targetNode) {
if (this.fromNode &&
this.fromNode !== targetNode &&
Expand Down
4 changes: 2 additions & 2 deletions lib/dist/editors/MakeGraphEditorElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const MakeGraphEditorElement = (NestedEditorConstructor = TextEditorEleme
this.shadowRoot.append(editor);
this.blur();
setTimeout(() => editor.focusEditor());
this.fromNode = node;
//this.fromNode = node;
this.render();
this.parentEditor?.dispatchEvent(new CustomEvent("childEditorUpdate", {
detail: {
Expand All @@ -113,7 +113,7 @@ export const MakeGraphEditorElement = (NestedEditorConstructor = TextEditorEleme
}));
});
this.addEventListener("mouseup", (e) => {
const targetEl = e.path[0];
const targetEl = e.composedPath()[0];
const targetNode = this.nodes.find(({ editor }) => editor.contains(targetEl) || editor.shadowRoot.contains(targetEl));
if (targetNode) {
if (this.fromNode &&
Expand Down
17 changes: 11 additions & 6 deletions lib/dist/editors/TextEditorElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,23 @@ export class TextEditorElement extends EditorElement {
this.addEventListener("mousedown", (e) => {
if (e.buttons === 1) {
const pos = this.cursorPosFromMouseEvent(e);
this.caret = pos;
this.minorCaret = pos;
this.render();
setTimeout(() => this.focusEditor());
if (pos !== -1) {
this.caret = pos;
this.minorCaret = pos;
this.render();
setTimeout(() => this.focusEditor());
}
//
}
});
this.addEventListener("mousemove", (e) => {
if (this.isFocused) {
if (e.buttons === 1) {
const pos = this.cursorPosFromMouseEvent(e);
this.caret = pos;
this.render();
if (pos !== -1) {
this.caret = pos;
this.render();
}
}
}
});
Expand Down
Empty file removed lib/dist/editors/TextLikeEditor.js
Empty file.
Loading

0 comments on commit 6f4e7cc

Please sign in to comment.