mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 15:19:01 +02:00
feat(views/board): reintroduce one-click title edit
This commit is contained in:
parent
69f12a2916
commit
dfeb414aff
@ -24,6 +24,31 @@ export class ColumnDragHandler implements BaseDragHandler {
|
|||||||
|
|
||||||
$titleEl.attr("draggable", "true");
|
$titleEl.attr("draggable", "true");
|
||||||
|
|
||||||
|
// Delay drag start to allow click detection
|
||||||
|
let dragStartTimer: number | null = null;
|
||||||
|
|
||||||
|
$titleEl.on("mousedown", () => {
|
||||||
|
// Clear any existing timer
|
||||||
|
if (dragStartTimer) {
|
||||||
|
clearTimeout(dragStartTimer);
|
||||||
|
dragStartTimer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set a short delay before enabling dragging
|
||||||
|
dragStartTimer = window.setTimeout(() => {
|
||||||
|
$titleEl.attr("draggable", "true");
|
||||||
|
dragStartTimer = null;
|
||||||
|
}, 150);
|
||||||
|
});
|
||||||
|
|
||||||
|
$titleEl.on("mouseup mouseleave", () => {
|
||||||
|
// Cancel drag start timer on mouse up or leave
|
||||||
|
if (dragStartTimer) {
|
||||||
|
clearTimeout(dragStartTimer);
|
||||||
|
dragStartTimer = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$titleEl.on("dragstart", (e) => {
|
$titleEl.on("dragstart", (e) => {
|
||||||
// Only start dragging if the target is not an input (for inline editing)
|
// Only start dragging if the target is not an input (for inline editing)
|
||||||
if ($(e.target).is('input') || $titleEl.hasClass('editing')) {
|
if ($(e.target).is('input') || $titleEl.hasClass('editing')) {
|
||||||
@ -54,10 +79,13 @@ export class ColumnDragHandler implements BaseDragHandler {
|
|||||||
this.context.draggedColumnElement = null;
|
this.context.draggedColumnElement = null;
|
||||||
this.cleanupColumnDropIndicators();
|
this.cleanupColumnDropIndicators();
|
||||||
this.cleanupGlobalColumnDragTracking();
|
this.cleanupGlobalColumnDragTracking();
|
||||||
|
|
||||||
|
// Re-enable draggable
|
||||||
|
$titleEl.attr("draggable", "true");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setupColumnDropZone($columnEl: JQuery<HTMLElement>, _columnValue: string) {
|
setupColumnDropZone($columnEl: JQuery<HTMLElement>) {
|
||||||
$columnEl.on("dragover", (e) => {
|
$columnEl.on("dragover", (e) => {
|
||||||
// Only handle column drops when a column is being dragged
|
// Only handle column drops when a column is being dragged
|
||||||
if (this.context.draggedColumn && !this.context.draggedNote) {
|
if (this.context.draggedColumn && !this.context.draggedNote) {
|
||||||
|
@ -321,7 +321,7 @@ export class DifferentialBoardRenderer {
|
|||||||
|
|
||||||
// Setup drop zones for both notes and columns
|
// Setup drop zones for both notes and columns
|
||||||
this.dragHandler.setupNoteDropZone($columnEl, column);
|
this.dragHandler.setupNoteDropZone($columnEl, column);
|
||||||
this.dragHandler.setupColumnDropZone($columnEl, column);
|
this.dragHandler.setupColumnDropZone($columnEl);
|
||||||
|
|
||||||
// Add cards
|
// Add cards
|
||||||
for (const item of columnItems) {
|
for (const item of columnItems) {
|
||||||
|
@ -42,8 +42,8 @@ export class BoardDragHandler {
|
|||||||
this.columnDragHandler.setupColumnDrag($columnEl, columnValue);
|
this.columnDragHandler.setupColumnDrag($columnEl, columnValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
setupColumnDropZone($columnEl: JQuery<HTMLElement>, columnValue: string) {
|
setupColumnDropZone($columnEl: JQuery<HTMLElement>) {
|
||||||
this.columnDragHandler.setupColumnDropZone($columnEl, columnValue);
|
this.columnDragHandler.setupColumnDropZone($columnEl);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Common methods
|
// Common methods
|
||||||
|
@ -348,15 +348,39 @@ export default class BoardView extends ViewMode<BoardData> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private setupBoardInteractions() {
|
private setupBoardInteractions() {
|
||||||
// Handle column title editing - double-click on h3 to edit
|
// Handle column title editing with click detection that works with dragging
|
||||||
this.$container.on('dblclick', 'h3[data-column-value]', (e) => {
|
this.$container.on('mousedown', 'h3[data-column-value]', (e) => {
|
||||||
e.stopPropagation();
|
|
||||||
const $titleEl = $(e.currentTarget);
|
const $titleEl = $(e.currentTarget);
|
||||||
const columnValue = $titleEl.attr('data-column-value');
|
const startTime = Date.now();
|
||||||
if (columnValue) {
|
let hasMoved = false;
|
||||||
const columnItems = this.api?.getColumn(columnValue) || [];
|
const startX = e.clientX;
|
||||||
this.startEditingColumnTitle($titleEl, columnValue, columnItems);
|
const startY = e.clientY;
|
||||||
}
|
|
||||||
|
const handleMouseMove = (moveEvent: JQuery.MouseMoveEvent) => {
|
||||||
|
const deltaX = Math.abs(moveEvent.clientX - startX);
|
||||||
|
const deltaY = Math.abs(moveEvent.clientY - startY);
|
||||||
|
if (deltaX > 5 || deltaY > 5) {
|
||||||
|
hasMoved = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleMouseUp = (upEvent: JQuery.MouseUpEvent) => {
|
||||||
|
const duration = Date.now() - startTime;
|
||||||
|
$(document).off('mousemove', handleMouseMove);
|
||||||
|
$(document).off('mouseup', handleMouseUp);
|
||||||
|
|
||||||
|
// If it was a quick click without much movement, treat as edit request
|
||||||
|
if (duration < 500 && !hasMoved && upEvent.button === 0) {
|
||||||
|
const columnValue = $titleEl.attr('data-column-value');
|
||||||
|
if (columnValue) {
|
||||||
|
const columnItems = this.api?.getColumn(columnValue) || [];
|
||||||
|
this.startEditingColumnTitle($titleEl, columnValue, columnItems);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$(document).on('mousemove', handleMouseMove);
|
||||||
|
$(document).on('mouseup', handleMouseUp);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle add column button
|
// Handle add column button
|
||||||
@ -370,7 +394,7 @@ export default class BoardView extends ViewMode<BoardData> {
|
|||||||
const $titleText = $("<span>").text(title);
|
const $titleText = $("<span>").text(title);
|
||||||
const $editIcon = $("<span>")
|
const $editIcon = $("<span>")
|
||||||
.addClass("edit-icon icon bx bx-edit-alt")
|
.addClass("edit-icon icon bx bx-edit-alt")
|
||||||
.attr("title", "Double-click to edit column title");
|
.attr("title", "Click to edit column title");
|
||||||
|
|
||||||
return { $titleText, $editIcon };
|
return { $titleText, $editIcon };
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user