Skip to content

Commit

Permalink
made connecting cards easier
Browse files Browse the repository at this point in the history
  • Loading branch information
leth4 committed Dec 2, 2024
1 parent 6d8f156 commit b82b5a1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions web/src/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ export default class Edit {
insertText = '\n';
else if (this.#activeEditor().value[lineStart] === '—' && this.#activeEditor().selectionEnd - lineStart > 1)
(/^[\s]*$/.test(this.#activeEditor().value.slice(lineStart, lineEnd))) ? deleteLine = true : insertText = '\n— ';
else if (this.#activeEditor().value[lineStart] === '-' && this.#activeEditor().selectionEnd - lineStart > 1)
(/^-[\s]*$/.test(this.#activeEditor().value.slice(lineStart, lineEnd))) ? deleteLine = true : insertText = '\n- ';
else if (this.#activeEditor().value[lineStart] === '→' && this.#activeEditor().selectionEnd - lineStart > 1)
(/^[\s]*$/.test(this.#activeEditor().value.slice(lineStart, lineEnd))) ? deleteLine = true : insertText = '\n→ ';
else if (this.#activeEditor().value.slice(lineStart, lineStart + 3) === '[ ]' && this.#activeEditor().selectionEnd - lineStart > 3)
(/^\[ \][\s]*$/.test(this.#activeEditor().value.slice(lineStart, lineEnd))) ? deleteLine = true : insertText = '\n[ ] ';
else if (this.#activeEditor().value.slice(lineStart, lineStart + 3) === '[x]' && this.#activeEditor().selectionEnd - lineStart > 3)
Expand Down
12 changes: 12 additions & 0 deletions web/src/lea.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default class Lea {

#draggedItem;
#previousCursorPosition = {x: 0, y: 0};
#previousCursorTarget;
#startDragPosition;

#isBoxSelecting;
Expand Down Expand Up @@ -247,6 +248,16 @@ export default class Lea {
if (this.#selectedCards.length == 0) return;

if (this.#selectedCards.length == 1) {
if (this.#previousCursorTarget.classList.contains("card")) {
new Arrow(this.#selectedCards[0].getAttribute('data-index'), this.#previousCursorTarget.getAttribute('data-index')).create(this.#arrows, this.#cards);
return;
}

if (this.#previousCursorTarget.parentElement.classList.contains("card")) {
new Arrow(this.#selectedCards[0].getAttribute('data-index'), this.#previousCursorTarget.parentElement.getAttribute('data-index')).create(this.#arrows, this.#cards);
return;
}

var initialCardIndex = this.#selectedCards[0].getAttribute('data-index');
this.createEmptyCard();
new Arrow(initialCardIndex, this.#cards.length - 1).create(this.#arrows, this.#cards);
Expand Down Expand Up @@ -435,6 +446,7 @@ export default class Lea {
if (this.#draggedItem == null) {
document.querySelector(':root').style.setProperty('--cards-pointer-events', event.ctrlKey || this.#isBoxSelecting ? 'none' : 'auto');
this.#previousCursorPosition = cursorPosition;
this.#previousCursorTarget = event.target;
return;
}

Expand Down

0 comments on commit b82b5a1

Please sign in to comment.