Skip to content

Commit 462e46d

Browse files
committed
Progress
1 parent ca4d2d0 commit 462e46d

5 files changed

Lines changed: 35 additions & 7 deletions

File tree

‎package-lock.json‎

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"@pictogrammers/element-esbuild": "^0.0.20",
2929
"@pictogrammers/element-jest": "^0.1.10",
3030
"@pictogrammers/fnt": "^1.2.0",
31-
"@pictogrammers/node-connector": "^0.9.9",
31+
"@pictogrammers/node-connector": "^0.9.11",
3232
"cross-env": "^7.0.3",
3333
"npm-run-all": "^4.1.5",
3434
"raw-loader": "^4.0.2",

‎src/components/pg/nodeEditorTextArray/nodeEditorTextArray.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,12 @@ export default class PgNodeEditorTextArray extends HTMLElement {
7171
const $items = Array.from(this.$inputs.children);
7272
if ($items.length > 1) {
7373
if (index === 0) {
74+
($items[$items.length - 1] as any).selectionStart = selectionIndex;
75+
($items[$items.length - 1] as any).selectionEnd = selectionIndex;
7476
($items[$items.length - 1] as any).focus();
7577
} else {
78+
($items[index - 1] as any).selectionStart = selectionIndex;
79+
($items[index - 1] as any).selectionEnd = selectionIndex;
7680
($items[index - 1] as any).focus();
7781
}
7882
}
@@ -82,8 +86,12 @@ export default class PgNodeEditorTextArray extends HTMLElement {
8286
const $items = Array.from(this.$inputs.children);
8387
if ($items.length > 1) {
8488
if (index === $items.length - 1) {
89+
($items[0] as any).selectionStart = selectionIndex;
90+
($items[0] as any).selectionEnd = selectionIndex;
8591
($items[0] as any).focus();
8692
} else {
93+
($items[index + 1] as any).selectionStart = selectionIndex;
94+
($items[index + 1] as any).selectionEnd = selectionIndex;
8795
($items[index + 1] as any).focus();
8896
}
8997
}

‎src/components/pg/nodeInputText/nodeInputText.ts‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,21 @@ export default class PgNodeInputText extends HTMLElement {
3737
});
3838
this.$input.addEventListener('keydown', (e: KeyboardEvent) => {
3939
if (e.key === 'ArrowUp') {
40+
e.preventDefault();
4041
this.dispatchEvent(new CustomEvent('inputprevious', {
4142
detail: {
4243
index: this.index,
43-
selectionStart: this.$input.selectionDirection
44+
selectionIndex: this.$input.selectionDirection === 'forward'
4445
? this.$input.selectionStart
4546
: this.$input.selectionEnd,
4647
}
4748
}));
4849
} else if (e.key === 'ArrowDown') {
50+
e.preventDefault();
4951
this.dispatchEvent(new CustomEvent('inputnext', {
5052
detail: {
5153
index: this.index,
52-
selectionIndex: this.$input.selectionDirection
54+
selectionIndex: this.$input.selectionDirection === 'forward'
5355
? this.$input.selectionStart
5456
: this.$input.selectionEnd,
5557
}
@@ -77,4 +79,18 @@ export default class PgNodeInputText extends HTMLElement {
7779
focus() {
7880
this.$input.focus();
7981
}
82+
83+
get selectionStart(){
84+
return this.$input.selectionStart || 0;
85+
}
86+
set selectionStart(value: number) {
87+
this.$input.selectionStart = value;
88+
}
89+
90+
get selectionEnd(){
91+
return this.$input.selectionEnd || 0;
92+
}
93+
set selectionEnd(value: number) {
94+
this.$input.selectionEnd = value;
95+
}
8096
}

‎src/components/pg/nodes/nodes.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ export default class PgNodes extends HTMLElement {
6262
connector.bridgeColor = '#0a0c14';
6363
this.#connector = connector;
6464

65+
connector.on('create', (event) => {
66+
const { x, y, sourceY, sourceNodeId, sourceKey } = event;
67+
console.log(x, y, sourceY, sourceNodeId, sourceKey);
68+
});
6569
connector.on('change', (change) => {
6670
console.log(change.type, change.sourceNodeId, change.sourceKey, change.targetNodeId, change.targetKey);
6771
const targetNodeId = parseInt(change.targetNodeId, 10);

0 commit comments

Comments
 (0)