mirror of
https://github.com/taskgenius/taskgenius-plugin.git
synced 2026-07-22 06:40:25 +00:00
Merge branch 'feat/move-metadata-to-same-line'
This commit is contained in:
commit
9e240d77c6
5 changed files with 154 additions and 12135 deletions
|
|
@ -24,6 +24,7 @@ export class TaskListItemComponent extends Component {
|
|||
private markdownRenderer: MarkdownRendererComponent;
|
||||
private containerEl: HTMLElement;
|
||||
private contentEl: HTMLElement;
|
||||
private contentMetadataContainer: HTMLElement;
|
||||
|
||||
private metadataEl: HTMLElement;
|
||||
|
||||
|
|
@ -184,19 +185,22 @@ export class TaskListItemComponent extends Component {
|
|||
cls: "task-item-container",
|
||||
});
|
||||
|
||||
// Task content
|
||||
this.contentEl = createDiv({
|
||||
cls: "task-item-content",
|
||||
// Create content-metadata container for dynamic layout
|
||||
this.contentMetadataContainer = this.containerEl.createDiv({
|
||||
cls: "task-content-metadata-container",
|
||||
});
|
||||
|
||||
this.containerEl.appendChild(this.contentEl);
|
||||
// Task content
|
||||
this.contentEl = this.contentMetadataContainer.createDiv({
|
||||
cls: "task-item-content",
|
||||
});
|
||||
|
||||
// Make content clickable for editing
|
||||
this.registerContentClickHandler();
|
||||
|
||||
this.renderMarkdown();
|
||||
|
||||
this.metadataEl = this.containerEl.createDiv({
|
||||
this.metadataEl = this.contentMetadataContainer.createDiv({
|
||||
cls: "task-item-metadata",
|
||||
});
|
||||
|
||||
|
|
@ -750,6 +754,35 @@ export class TaskListItemComponent extends Component {
|
|||
|
||||
// Re-register the click event for editing after rendering
|
||||
this.registerContentClickHandler();
|
||||
|
||||
// Update layout mode after content is rendered
|
||||
// Use requestAnimationFrame to ensure the content is fully rendered
|
||||
requestAnimationFrame(() => {
|
||||
this.updateLayoutMode();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect content height and update layout mode
|
||||
*/
|
||||
private updateLayoutMode() {
|
||||
if (!this.contentEl || !this.contentMetadataContainer) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the line height of the content element
|
||||
const computedStyle = window.getComputedStyle(this.contentEl);
|
||||
const lineHeight = parseFloat(computedStyle.lineHeight) || parseFloat(computedStyle.fontSize) * 1.4;
|
||||
|
||||
// Get actual content height
|
||||
const contentHeight = this.contentEl.scrollHeight;
|
||||
|
||||
// Check if content is multi-line (with some tolerance)
|
||||
const isMultiLine = contentHeight > lineHeight * 1.2;
|
||||
|
||||
// Apply appropriate layout class using Obsidian's toggleClass method
|
||||
this.contentMetadataContainer.toggleClass("multi-line-content", isMultiLine);
|
||||
this.contentMetadataContainer.toggleClass("single-line-content", !isMultiLine);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ export class TaskTreeItemComponent extends Component {
|
|||
|
||||
private markdownRenderer: MarkdownRendererComponent;
|
||||
private contentEl: HTMLElement;
|
||||
private contentMetadataContainer: HTMLElement;
|
||||
private taskMap: Map<string, Task>;
|
||||
|
||||
// Use shared editor manager instead of individual editors
|
||||
|
|
@ -268,8 +269,13 @@ export class TaskTreeItemComponent extends Component {
|
|||
cls: "task-item-container",
|
||||
});
|
||||
|
||||
// Create content-metadata container for dynamic layout
|
||||
this.contentMetadataContainer = taskItemContainer.createDiv({
|
||||
cls: "task-content-metadata-container",
|
||||
});
|
||||
|
||||
// Task content with markdown rendering
|
||||
this.contentEl = taskItemContainer.createDiv({
|
||||
this.contentEl = this.contentMetadataContainer.createDiv({
|
||||
cls: "task-item-content",
|
||||
});
|
||||
|
||||
|
|
@ -279,7 +285,7 @@ export class TaskTreeItemComponent extends Component {
|
|||
this.renderMarkdown();
|
||||
|
||||
// Metadata container
|
||||
const metadataEl = taskItemContainer.createDiv({
|
||||
const metadataEl = this.contentMetadataContainer.createDiv({
|
||||
cls: "task-metadata",
|
||||
});
|
||||
|
||||
|
|
@ -824,6 +830,35 @@ export class TaskTreeItemComponent extends Component {
|
|||
|
||||
// Re-register the click event for editing after rendering
|
||||
this.registerContentClickHandler();
|
||||
|
||||
// Update layout mode after content is rendered
|
||||
// Use requestAnimationFrame to ensure the content is fully rendered
|
||||
requestAnimationFrame(() => {
|
||||
this.updateLayoutMode();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect content height and update layout mode
|
||||
*/
|
||||
private updateLayoutMode() {
|
||||
if (!this.contentEl || !this.contentMetadataContainer) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the line height of the content element
|
||||
const computedStyle = window.getComputedStyle(this.contentEl);
|
||||
const lineHeight = parseFloat(computedStyle.lineHeight) || parseFloat(computedStyle.fontSize) * 1.4;
|
||||
|
||||
// Get actual content height
|
||||
const contentHeight = this.contentEl.scrollHeight;
|
||||
|
||||
// Check if content is multi-line (with some tolerance)
|
||||
const isMultiLine = contentHeight > lineHeight * 1.2;
|
||||
|
||||
// Apply appropriate layout class using Obsidian's toggleClass method
|
||||
this.contentMetadataContainer.toggleClass("multi-line-content", isMultiLine);
|
||||
this.contentMetadataContainer.toggleClass("single-line-content", !isMultiLine);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -68,6 +68,45 @@
|
|||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
/* Dynamic content-metadata container */
|
||||
.task-content-metadata-container {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-start;
|
||||
gap: var(--size-2-2);
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
/* Single line content layout - horizontal */
|
||||
.task-content-metadata-container.single-line-content {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.task-content-metadata-container.single-line-content .task-item-content {
|
||||
flex: 1;
|
||||
min-width: 0; /* Allow content to shrink */
|
||||
}
|
||||
|
||||
.task-content-metadata-container.single-line-content .task-item-metadata {
|
||||
flex-shrink: 0;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
/* Multi-line content layout - vertical */
|
||||
.task-content-metadata-container.multi-line-content {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.task-content-metadata-container.multi-line-content .task-item-content {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.task-content-metadata-container.multi-line-content .task-item-metadata {
|
||||
margin-top: var(--size-2-2);
|
||||
}
|
||||
|
||||
.task-item-metadata {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
|
|
|||
|
|
@ -100,6 +100,45 @@
|
|||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
/* Dynamic content-metadata container for tree view */
|
||||
.tree-task-item .task-content-metadata-container {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-start;
|
||||
gap: var(--size-2-2);
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
/* Single line content layout - horizontal */
|
||||
.tree-task-item .task-content-metadata-container.single-line-content {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.tree-task-item .task-content-metadata-container.single-line-content .task-item-content {
|
||||
flex: 1;
|
||||
min-width: 0; /* Allow content to shrink */
|
||||
}
|
||||
|
||||
.tree-task-item .task-content-metadata-container.single-line-content .task-metadata {
|
||||
flex-shrink: 0;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
/* Multi-line content layout - vertical */
|
||||
.tree-task-item .task-content-metadata-container.multi-line-content {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.tree-task-item .task-content-metadata-container.multi-line-content .task-item-content {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.tree-task-item .task-content-metadata-container.multi-line-content .task-metadata {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
/* Task metadata */
|
||||
.task-metadata {
|
||||
display: flex;
|
||||
|
|
|
|||
12129
styles.css
12129
styles.css
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue