Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .release-it.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ module.exports = {
"before:init": ["node esbuild.config.mjs production"],
"after:bump": [
"node esbuild.config.mjs production",
// Keep the tracked root styles.css (what the community directory
// scanner lints) in sync with the released CSS
"node esbuild.config.mjs styles",
"node ./scripts/zip.mjs",
// 使用自定义 changelog 生成器替代 conventional-changelog
"node ./scripts/custom-changelog.mjs ${version}",
Expand Down
34 changes: 33 additions & 1 deletion esbuild.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ if you want to view the source, please visit the github repository of this plugi
`;

const prod = process.argv[2] === "production";
// `styles` regenerates only the tracked styles.css at the repo root (see the
// end of this file); main.js is left alone.
const stylesOnly = process.argv[2] === "styles";
const outDir = prod ? "dist" : ".";

// Ensure dist directory exists in production mode
Expand Down Expand Up @@ -181,7 +184,36 @@ const buildOptions = {
: [],
};

if (prod) {
if (stylesOnly) {
// The community directory scanner lints the styles.css committed at the
// repo root, not the release asset. Write it unminified and without a
// source map, so its findings point at readable lines; release-it runs this
// on every release so the file matches the released CSS.
const generated = ["rename-styles", "css-settings-plugin", "copy-manifest"];
const result = await esbuild
.build({
...buildOptions,
minify: false,
sourcemap: false,
pure: [],
write: false,
outfile: "main.js",
plugins: buildOptions.plugins.filter(
(plugin) => !generated.includes(plugin.name),
),
})
.catch(() => process.exit(1));
const css = result.outputFiles.find((file) => file.path.endsWith(".css"));
if (!css) {
console.error("No CSS output produced");
process.exit(1);
}
const settingsComment =
fs.readFileSync("src/styles/index.scss", "utf8").split("*/")[0] +
"*/\n\n";
fs.writeFileSync("styles.css", settingsComment + css.text);
console.log("Wrote styles.css");
} else if (prod) {
// Production build
esbuild.build(buildOptions).catch(() => process.exit(1));
} else {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"scripts": {
"dev": "node esbuild.config.mjs",
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
"build:styles": "node esbuild.config.mjs styles",
"version": "node version-bump.mjs && git add manifest.json manifest-beta.json versions.json",
"e-t": "cross-env node scripts/extract-translations.cjs",
"g-l": "cross-env node scripts/generate-locale-files.cjs",
Expand Down
8 changes: 8 additions & 0 deletions src/__tests__/InlineEditor.metadataCommit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ function installDomHelpers() {
proto.addClass = function (...c: string[]) {
this.classList.add(...c);
};
proto.removeClass = function (...c: string[]) {
this.classList.remove(...c);
};
proto.toggleClass = function (c: string | string[], value: boolean) {
for (const cls of Array.isArray(c) ? c : [c]) {
this.classList.toggle(cls, value);
}
};
(global as any).createDiv = (o?: any) => create.call(null, "div", o);
}

Expand Down
2 changes: 2 additions & 0 deletions src/components/features/calendar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1571,6 +1571,8 @@ export class CalendarComponent extends Component {
const checkboxContainer = eventEl.createDiv({
cls: "task-checkbox-overlay",
});
// Lets the stylesheet keep the title clear of the checkbox
eventEl.addClass("has-checkbox-overlay");

const checkbox = checkboxContainer.createEl("input", {
cls: "task-list-item-checkbox",
Expand Down
6 changes: 6 additions & 0 deletions src/components/features/calendar/rendering/event-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ export class CalendarEventComponent extends Component {
// --- View-Specific Rendering ---
this.renderByViewType();

// Lets the stylesheet lay out the checkbox and the title in a row
this.eventEl.toggleClass(
"has-task-checkbox",
this.eventEl.querySelector(".task-list-item-checkbox") !== null,
);

// --- Common Click Handler ---
this.registerEventListeners();
}
Expand Down
8 changes: 8 additions & 0 deletions src/components/features/habit/habitcard/habitcard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ export class HabitCard extends Component {
cell.setText(customContent);
} else if (customContent.instanceOf(HTMLElement)) {
cell.appendChild(customContent);
cell.toggleClass(
"has-pie-dot",
cell.querySelector(".pie-dot-container") !== null,
);
}
} else if (isFilled) {
cell.addClass("filled");
Expand Down Expand Up @@ -237,6 +241,10 @@ export class HabitCard extends Component {
cell.setText(customContent);
} else if (customContent.instanceOf(HTMLElement)) {
cell.appendChild(customContent);
cell.toggleClass(
"has-pie-dot",
cell.querySelector(".pie-dot-container") !== null,
);
}
} else if (isFilled) {
cell.addClass("filled");
Expand Down
15 changes: 15 additions & 0 deletions src/components/features/onboarding/OnboardingLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,21 @@ export class OnboardingLayout extends Component {
this.contentEl?.empty();
}

/**
* Flag the view after a step renders, so the stylesheet can adjust the
* header and content spacing for component previews and intro text
*/
updateStepClasses() {
this.container.toggleClass(
"has-component-showcase",
this.container.querySelector(".component-showcase") !== null,
);
this.container.toggleClass(
"has-intro-line",
this.container.querySelector(".intro-line") !== null,
);
}

/**
* Show/hide footer
*/
Expand Down
3 changes: 3 additions & 0 deletions src/components/features/onboarding/OnboardingView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ export class OnboardingView extends ItemView {
CompleteStep.render(headerEl, contentEl, this.controller);
break;
}

this.layout.updateStepClasses();
});
}

Expand Down Expand Up @@ -327,6 +329,7 @@ export class OnboardingView extends ItemView {
},
state.userHasChanges,
);
this.layout.updateStepClasses();
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ export class FluentOverviewStep {
cls: "onboarding-subtitle",
});

const showcase = contentEl.createDiv({ cls: "component-showcase" });
// The sidebar and top navigation previews sit side by side
const showcase = contentEl.createDiv({
cls: "component-showcase has-sidebar-and-topnav",
});
const preview = showcase.createDiv({ cls: "component-showcase-preview" });
const desc = showcase.createDiv({ cls: "component-showcase-description" });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ export class FluentTopNavigationStep {
cls: "onboarding-subtitle",
});

const showcase = contentEl.createDiv({ cls: "component-showcase" });
// A top navigation preview without a sidebar stacks above its description
const showcase = contentEl.createDiv({
cls: "component-showcase is-topnav-only",
});
const preview = showcase.createDiv({
cls: "component-showcase-preview focus-mode",
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,15 @@ export abstract class BaseQuickCaptureModal extends Modal {
});
}

if (!(this.fileModeAvailable && this.inlineModeAvailable)) {
const tabsHidden = !(
this.fileModeAvailable && this.inlineModeAvailable
);
if (tabsHidden) {
tabContainer.classList.add("is-hidden");
tabContainer.setAttribute("aria-hidden", "true");
}
// The stylesheet hides the title bar when the tabs are hidden
this.headerContainer.toggleClass("has-hidden-tabs", tabsHidden);

// Right side: Clear button with improved styling
if (this.fileModeAvailable && this.inlineModeAvailable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,7 @@ function renderMultiCycleManagement(
cls: "status-cycle-card",
});
cycleCard.setAttribute("data-cycle-id", cycle.id);
cycleCard.toggleClass("is-cycle-disabled", !cycle.enabled);

// Card header with collapse button, up/down buttons, title and controls
const cardHeader = cycleCard.createDiv({
Expand Down Expand Up @@ -1187,6 +1188,7 @@ function renderMultiCycleManagement(
.setTooltip(t("Enable/disable this cycle"))
.onChange(async (value) => {
cycle.enabled = value;
cycleCard.toggleClass("is-cycle-disabled", !value);
settingTab.applySettingsUpdate();
window.setTimeout(() => settingTab.display(), 200);
});
Expand Down
6 changes: 6 additions & 0 deletions src/components/features/table/TableRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,12 @@ export class TableRenderer extends Component {
: t("Expand subtasks");
}

// Cells with an expand button drop their left padding
cellEl.toggleClass(
"has-expand-btn",
treeContainer.querySelector(".task-table-expand-btn") !== null,
);

// Create content wrapper
const contentWrapper = treeContainer.createDiv(
"task-table-content-wrapper",
Expand Down
12 changes: 12 additions & 0 deletions src/components/features/task/view/InlineEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export class InlineEditor extends Component {
private activeInput: HTMLInputElement | HTMLSelectElement | null = null;
private activeSuggest: ProjectSuggest | TagSuggest | ContextSuggest | null =
null;
// Element whose metadata is being edited with a text input
private metadataTargetEl: HTMLElement | null = null;

// Debounced save function - only created when needed
private debouncedSave: (() => void) | null = null;
Expand Down Expand Up @@ -323,6 +325,13 @@ export class InlineEditor extends Component {
this.createIdEditor(editorContainer, currentValue);
break;
}

// Text inputs drop the editor box and restyle the element around them
const hasInput = editorContainer.querySelector("input") !== null;
editorContainer.toggleClass("has-input", hasInput);
this.metadataTargetEl?.removeClass("has-inline-input");
targetEl.toggleClass("has-inline-input", hasInput);
this.metadataTargetEl = hasInput ? targetEl : null;
}

/**
Expand Down Expand Up @@ -1443,6 +1452,9 @@ export class InlineEditor extends Component {
this.activeInput = null;
this.contentInput = null;

this.metadataTargetEl?.removeClass("has-inline-input");
this.metadataTargetEl = null;

// Clean up debounced save function
this.debouncedSave = null;
}
Expand Down
3 changes: 3 additions & 0 deletions src/components/features/task/view/TwoColumnViewBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,9 @@ export abstract class TwoColumnViewBase<T extends string> extends Component {
visible = !this.leftColumnEl.hasClass("is-visible");
}

// The container dims the rest of the view while the column is open
this.containerEl.toggleClass("is-left-column-visible", visible);

if (visible) {
this.leftColumnEl.addClass("is-visible");
this.leftColumnEl.show();
Expand Down
10 changes: 10 additions & 0 deletions src/components/features/task/view/forecast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1279,17 +1279,27 @@ export class ForecastComponent extends Component {
onunload() {
// Renderers are children, handled by Obsidian unload.
// No need to manually remove DOM event listeners registered with this.registerDomEvent
this.setViewOverlayVisible(false);
this.containerEl.empty();
this.containerEl.remove();
}

// The view container dims the rest of the view while the left column is open on phones
private setViewOverlayVisible(visible: boolean) {
this.containerEl
.closest(".task-genius-container")
?.toggleClass("is-forecast-left-column-visible", visible);
}

// Toggle left column visibility with animation support
private toggleLeftColumnVisibility(visible?: boolean) {
if (visible === undefined) {
// Toggle based on current state
visible = !this.leftColumnEl.hasClass("is-visible");
}

this.setViewOverlayVisible(visible);

if (visible) {
this.leftColumnEl.addClass("is-visible");
this.leftColumnEl.show();
Expand Down
3 changes: 3 additions & 0 deletions src/components/features/task/view/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1584,6 +1584,9 @@ export class ProjectsComponent extends Component {
visible = !this.leftColumnEl.hasClass("is-visible");
}

// The container dims the rest of the view while the column is open
this.containerEl.toggleClass("is-left-column-visible", visible);

if (visible) {
this.leftColumnEl.addClass("is-visible");
this.leftColumnEl.show();
Expand Down
3 changes: 3 additions & 0 deletions src/components/features/task/view/review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,9 @@ export class ReviewComponent extends Component {
visible = !this.leftColumnEl.hasClass("is-visible");
}

// The container dims the rest of the view while the column is open
this.containerEl.toggleClass("is-left-column-visible", visible);

if (visible) {
this.leftColumnEl.addClass("is-visible");
this.leftColumnEl.show();
Expand Down
3 changes: 3 additions & 0 deletions src/components/features/task/view/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,9 @@ export class TagsComponent extends Component {
visible = !this.leftColumnEl.hasClass("is-visible");
}

// The container dims the rest of the view while the column is open
this.containerEl.toggleClass("is-left-column-visible", visible);

if (visible) {
this.leftColumnEl.addClass("is-visible");
this.leftColumnEl.show();
Expand Down
7 changes: 7 additions & 0 deletions src/pages/TaskSpecificView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,15 @@ export class TaskSpecificView extends ItemView {
},
);
if (this.tabActionButton) {
// Side splits hide the status container that holds the button
this.leaf.tabHeaderStatusContainerEl?.addClass(
"has-task-genius-action",
);
this.register(() => {
this.tabActionButton.detach();
this.leaf.tabHeaderStatusContainerEl?.removeClass(
"has-task-genius-action",
);
});
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/pages/TaskView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,14 @@ export class TaskView extends ItemView {
});
},
);
// Side splits hide the status container that holds the button
this.leaf.tabHeaderStatusContainerEl.addClass("has-task-genius-action");

this.register(() => {
this.tabActionButton.detach();
this.leaf.tabHeaderStatusContainerEl.removeClass(
"has-task-genius-action",
);
});

this.checkAndCollapseSidebar();
Expand Down
3 changes: 2 additions & 1 deletion src/styles/calendar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@
}

@media (max-width: 1400px) {
.task-genius-container:has(.task-details.visible)
/* The view sets .details-visible on its container while the details panel is open */
.task-genius-container.details-visible
.mini-calendar-container
.forecast-left-column {
display: none;
Expand Down
Loading
Loading