DRY refactoring pass: shared mixins, route helpers, composables, CSS
Backend: - models/base.py: TimestampMixin + CreatedAtMixin; applied to all 10+ models - routes/utils.py: not_found() + parse_iso_date() helpers; used across all route files - routes/milestones.py: _milestone_dict() helper replaces 5 repeated to_dict + progress blocks Frontend: - 5 new composables: useAutoSave, useEditorGuards, useTagSuggestions, useFloatingAssist, useListKeyboardNavigation - ConfirmDialog.vue: reusable confirm modal replacing inline <teleport> blocks - editor-shared.css: sidebar CSS consolidated from both editor views - viewer-shared.css: context-bar/breadcrumb CSS consolidated from both viewer views - NoteEditorView + TaskEditorView: ~120 lines each replaced with composable calls; duplicate scoped sidebar CSS removed - NotesListView + TasksListView: inline keyboard-nav replaced with composable - NoteViewerView + TaskViewerView: duplicate context-bar CSS removed No behaviour changes. Net: -634 lines, +237 lines across 31 files. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { ref } from "vue";
|
||||
|
||||
type Selection = { text: string; start: number; end: number };
|
||||
|
||||
export function useFloatingAssist(onRequest: (sel: Selection) => void) {
|
||||
const floatingAssist = ref({ show: false, top: 0, left: 0 });
|
||||
const pendingSelection = ref<Selection | null>(null);
|
||||
|
||||
function onSelectionChange(payload: Selection) {
|
||||
if (payload.text.trim().length > 0) {
|
||||
const sel = window.getSelection();
|
||||
if (sel && sel.rangeCount > 0) {
|
||||
const rect = sel.getRangeAt(0).getBoundingClientRect();
|
||||
floatingAssist.value = {
|
||||
show: true,
|
||||
top: rect.top - 44,
|
||||
left: rect.left + rect.width / 2,
|
||||
};
|
||||
pendingSelection.value = payload;
|
||||
}
|
||||
} else {
|
||||
floatingAssist.value.show = false;
|
||||
pendingSelection.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
function handleInlineAssist() {
|
||||
if (!pendingSelection.value) return;
|
||||
floatingAssist.value.show = false;
|
||||
onRequest(pendingSelection.value);
|
||||
}
|
||||
|
||||
return { floatingAssist, onSelectionChange, handleInlineAssist };
|
||||
}
|
||||
Reference in New Issue
Block a user