Enhance inline micro edge handling and settings
- Introduced new settings for enabling inline micro edge suggestions and configuring the maximum number of alternatives displayed. - Updated the InterviewWizardModal to support inline micro edging, allowing users to select edge types immediately after inserting links. - Enhanced the semantic mapping builder to incorporate pending edge assignments, improving the handling of rel:type links. - Improved the user experience with clearer logging and error handling during inline edge type selection and mapping processes.
This commit is contained in:
1 parent
0fa2197ab2
commit
7ea36fbed4
15 files changed
+1171
-27
No files matched your search
@@ -123,7 +123,7 @@ function parseProfile(
|
||||
const edgingRaw = raw.edging as Record<string, unknown>;
|
||||
profile.edging = {};
|
||||
|
||||
if (edgingRaw.mode === "none" || edgingRaw.mode === "post_run" || edgingRaw.mode === "inline_micro") {
|
||||
if (edgingRaw.mode === "none" || edgingRaw.mode === "post_run" || edgingRaw.mode === "inline_micro" || edgingRaw.mode === "both") {
|
||||
profile.edging.mode = edgingRaw.mode;
|
||||
}
|
||||
if (typeof edgingRaw.wrapperCalloutType === "string") {
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
/**
|
||||
* Section key resolution for inline micro edge assignments.
|
||||
*/
|
||||
|
||||
import { App, TFile } from "obsidian";
|
||||
import type { InterviewStep } from "./types";
|
||||
|
||||
export interface SectionKeyContext {
|
||||
file: TFile;
|
||||
step: InterviewStep;
|
||||
insertionPoint?: number; // Line number where link is inserted (optional)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get section key for wizard context.
|
||||
*
|
||||
* Options:
|
||||
* A) if step config provides output.sectionKey -> use it
|
||||
* B) else parse active file headings and choose nearest heading at insertion point
|
||||
* C) fallback "ROOT"
|
||||
*/
|
||||
export async function getSectionKeyForWizardContext(
|
||||
app: App,
|
||||
context: SectionKeyContext
|
||||
): Promise<string> {
|
||||
// Option A: Check if step config provides output.sectionKey
|
||||
// Note: Only some step types have output property (e.g., CaptureTextStep, CaptureTextLineStep)
|
||||
if (
|
||||
(context.step.type === "capture_text" || context.step.type === "capture_text_line") &&
|
||||
"output" in context.step &&
|
||||
context.step.output &&
|
||||
typeof context.step.output === "object"
|
||||
) {
|
||||
const output = context.step.output as Record<string, unknown>;
|
||||
if (typeof output.sectionKey === "string" && output.sectionKey.trim()) {
|
||||
return output.sectionKey.trim();
|
||||
}
|
||||
}
|
||||
|
||||
// Option B: Parse file headings and find nearest heading
|
||||
try {
|
||||
const content = await app.vault.read(context.file);
|
||||
const lines = content.split(/\r?\n/);
|
||||
|
||||
// Find headings in file
|
||||
const headings: Array<{ level: number; text: string; lineIndex: number }> = [];
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const line = lines[i];
|
||||
if (!line) continue;
|
||||
|
||||
// Match markdown headings: # Heading, ## Heading, etc.
|
||||
const headingMatch = line.match(/^(#{1,6})\s+(.+)$/);
|
||||
if (headingMatch && headingMatch[1] && headingMatch[2]) {
|
||||
const level = headingMatch[1].length;
|
||||
const text = headingMatch[2].trim();
|
||||
headings.push({ level, text, lineIndex: i });
|
||||
}
|
||||
}
|
||||
|
||||
// If we have an insertion point, find nearest heading before it
|
||||
if (context.insertionPoint !== undefined && headings.length > 0) {
|
||||
// Find last heading before insertion point
|
||||
let nearestHeading: typeof headings[0] | null = null;
|
||||
for (const heading of headings) {
|
||||
if (heading.lineIndex <= context.insertionPoint) {
|
||||
if (!nearestHeading || heading.lineIndex > nearestHeading.lineIndex) {
|
||||
nearestHeading = heading;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nearestHeading) {
|
||||
// Format: "H2:Heading Text..." (truncate if too long)
|
||||
const prefix = `H${nearestHeading.level}:`;
|
||||
const text = nearestHeading.text.length > 50
|
||||
? nearestHeading.text.substring(0, 50) + "..."
|
||||
: nearestHeading.text;
|
||||
return `${prefix}${text}`;
|
||||
}
|
||||
}
|
||||
|
||||
// If no insertion point or no heading found before it, use last heading
|
||||
if (headings.length > 0) {
|
||||
const lastHeading = headings[headings.length - 1];
|
||||
if (lastHeading) {
|
||||
const prefix = `H${lastHeading.level}:`;
|
||||
const text = lastHeading.text.length > 50
|
||||
? lastHeading.text.substring(0, 50) + "..."
|
||||
: lastHeading.text;
|
||||
return `${prefix}${text}`;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn("[Mindnet] Failed to parse headings for section key:", e);
|
||||
}
|
||||
|
||||
// Option C: Fallback to "ROOT"
|
||||
return "ROOT";
|
||||
}
|
||||
@@ -16,7 +16,7 @@ export interface InterviewProfile {
|
||||
defaults?: Record<string, unknown>;
|
||||
steps: InterviewStep[];
|
||||
edging?: {
|
||||
mode?: "none" | "post_run" | "inline_micro"; // Semantic mapping mode (default: "none")
|
||||
mode?: "none" | "post_run" | "inline_micro" | "both"; // Semantic mapping mode (default: "none"). "both" enables inline_micro + post_run
|
||||
wrapperCalloutType?: string; // Override wrapper callout type
|
||||
wrapperTitle?: string; // Override wrapper title
|
||||
wrapperFolded?: boolean; // Override wrapper folded state
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
import type { InterviewProfile, InterviewStep } from "./types";
|
||||
import type { LoopRuntimeState } from "./loopState";
|
||||
|
||||
export interface PendingEdgeAssignment {
|
||||
filePath: string;
|
||||
sectionKey: string; // identifies heading/section in file (e.g. "H2:Wendepunkte..." or "ROOT")
|
||||
linkBasename: string; // target note basename
|
||||
chosenRawType: string; // user chosen edge type (alias allowed)
|
||||
sourceNoteId?: string; // from frontmatter.id (optional)
|
||||
targetNoteId?: string; // if resolved (optional)
|
||||
createdAt: number;
|
||||
}
|
||||
|
||||
export interface WizardState {
|
||||
profile: InterviewProfile;
|
||||
currentStepIndex: number;
|
||||
@@ -10,6 +20,7 @@ export interface WizardState {
|
||||
loopRuntimeStates: Map<string, LoopRuntimeState>; // loop step key -> runtime state
|
||||
patches: Patch[]; // Collected patches to apply
|
||||
activeLoopPath: string[]; // Stack of loop keys representing current nesting level (e.g. ["items", "item_list"])
|
||||
pendingEdgeAssignments: PendingEdgeAssignment[]; // Inline micro edge assignments collected during wizard
|
||||
}
|
||||
|
||||
export interface Patch {
|
||||
@@ -38,6 +49,7 @@ export function createWizardState(profile: InterviewProfile): WizardState {
|
||||
loopRuntimeStates: new Map(),
|
||||
patches: [],
|
||||
activeLoopPath: [], // Start at top level
|
||||
pendingEdgeAssignments: [], // Start with empty pending assignments
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user