Cleanup/code cleanup 2026 03 (#45)
* chore: cleanup of unused exports and stuff * fix: media and languages was broken for english media * fix: embedding model load was broken on standalone --------- Co-authored-by: hugo <hugoms@me.com>
This commit is contained in:
@@ -50,8 +50,8 @@ function getNodeColor(depth: number): string {
|
||||
|
||||
/* ── Constants ──────────────────────────────────────────────── */
|
||||
|
||||
export const FONT_SIZE = 13;
|
||||
export const CHAR_WIDTH = 7.8;
|
||||
const FONT_SIZE = 13;
|
||||
const CHAR_WIDTH = 7.8;
|
||||
export const LINE_HEIGHT = 18;
|
||||
const NODE_PADDING_X = 14;
|
||||
const NODE_PADDING_Y = 8;
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
export { A2UIText } from './A2UIText';
|
||||
export { A2UIButton } from './A2UIButton';
|
||||
export { A2UICard } from './A2UICard';
|
||||
export { A2UIChart } from './A2UIChart';
|
||||
export { A2UITable } from './A2UITable';
|
||||
export { A2UIForm } from './A2UIForm';
|
||||
export { A2UITextField } from './A2UITextField';
|
||||
export { A2UICheckBox } from './A2UICheckBox';
|
||||
export { A2UIDateTimeInput } from './A2UIDateTimeInput';
|
||||
export { A2UIChoicePicker } from './A2UIChoicePicker';
|
||||
export { A2UIImage } from './A2UIImage';
|
||||
export { A2UITabs } from './A2UITabs';
|
||||
export { A2UIMetric } from './A2UIMetric';
|
||||
export { A2UIList } from './A2UIList';
|
||||
export { A2UIRow } from './A2UIRow';
|
||||
export { A2UIColumn } from './A2UIColumn';
|
||||
export { A2UIDivider } from './A2UIDivider';
|
||||
@@ -302,5 +302,3 @@ export const AssistantSidebar: React.FC = () => {
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default AssistantSidebar;
|
||||
|
||||
@@ -171,62 +171,3 @@ export function useMarkdownImages(content: string): LightboxImage[] {
|
||||
}, [content]);
|
||||
}
|
||||
|
||||
// Component to render images with lightbox support
|
||||
interface ImageGalleryProps {
|
||||
images: LightboxImage[];
|
||||
}
|
||||
|
||||
export const ImageGallery: React.FC<ImageGalleryProps> = ({ images }) => {
|
||||
const [lightboxOpen, setLightboxOpen] = useState(false);
|
||||
const [selectedIndex, setSelectedIndex] = useState(0);
|
||||
|
||||
if (images.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const openLightbox = (index: number) => {
|
||||
setSelectedIndex(index);
|
||||
setLightboxOpen(true);
|
||||
};
|
||||
|
||||
if (images.length === 1) {
|
||||
return (
|
||||
<>
|
||||
<div className="single-image" onClick={() => openLightbox(0)}>
|
||||
<img src={images[0].src} alt={images[0].alt || ''} />
|
||||
{images[0].caption && <p className="image-caption">{images[0].caption}</p>}
|
||||
</div>
|
||||
<Lightbox
|
||||
images={images}
|
||||
initialIndex={selectedIndex}
|
||||
isOpen={lightboxOpen}
|
||||
onClose={() => setLightboxOpen(false)}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className={`image-gallery gallery-${Math.min(images.length, 4)}`}>
|
||||
{images.map((image, index) => (
|
||||
<div
|
||||
key={index}
|
||||
className="gallery-item"
|
||||
onClick={() => openLightbox(index)}
|
||||
>
|
||||
<img src={image.src} alt={image.alt || ''} />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<Lightbox
|
||||
images={images}
|
||||
initialIndex={selectedIndex}
|
||||
isOpen={lightboxOpen}
|
||||
onClose={() => setLightboxOpen(false)}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Lightbox;
|
||||
|
||||
@@ -1 +1 @@
|
||||
export { Lightbox, ImageGallery, useMarkdownImages } from './Lightbox';
|
||||
export { Lightbox, useMarkdownImages } from './Lightbox';
|
||||
|
||||
@@ -345,5 +345,3 @@ export const LinkedMediaPanel: React.FC<LinkedMediaPanelProps> = ({
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default LinkedMediaPanel;
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
export { LinkedMediaPanel } from './LinkedMediaPanel';
|
||||
export { default } from './LinkedMediaPanel';
|
||||
|
||||
@@ -391,5 +391,3 @@ const MilkdownProviderInner: React.FC<MilkdownEditorProps> = ({
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default MilkdownEditor;
|
||||
|
||||
@@ -116,5 +116,3 @@ export const PostLinks: React.FC<PostLinksProps> = ({ postId, onPostClick, updat
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default PostLinks;
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
export { PostLinks } from './PostLinks';
|
||||
export { default } from './PostLinks';
|
||||
|
||||
@@ -1,130 +0,0 @@
|
||||
.post-search-modal-backdrop {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 10000;
|
||||
}
|
||||
|
||||
.post-search-modal {
|
||||
background: var(--color-bg-secondary, #1e1e1e);
|
||||
border: 1px solid var(--color-border, #3c3c3c);
|
||||
border-radius: 8px;
|
||||
width: 600px;
|
||||
max-height: 500px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
.post-search-header {
|
||||
border-bottom: 1px solid var(--color-border, #3c3c3c);
|
||||
}
|
||||
|
||||
.post-search-input {
|
||||
width: 100%;
|
||||
padding: 16px 20px;
|
||||
font-size: 16px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: var(--color-text, #ccc);
|
||||
outline: none;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.post-search-input::placeholder {
|
||||
color: var(--color-text-muted, #888);
|
||||
}
|
||||
|
||||
.post-search-results {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 8px;
|
||||
min-height: 200px;
|
||||
}
|
||||
|
||||
.post-search-loading,
|
||||
.post-search-empty {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 40px 20px;
|
||||
color: var(--color-text-muted, #888);
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.post-search-result-item {
|
||||
padding: 12px 16px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
margin-bottom: 4px;
|
||||
transition: background-color 0.15s ease;
|
||||
}
|
||||
|
||||
.post-search-result-item:hover,
|
||||
.post-search-result-item.selected {
|
||||
background: var(--color-bg-tertiary, #2a2a2a);
|
||||
}
|
||||
|
||||
.post-search-result-item.selected {
|
||||
border-left: 3px solid var(--color-primary, #0e639c);
|
||||
padding-left: 13px;
|
||||
}
|
||||
|
||||
.post-search-result-title {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--color-text, #fff);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.post-search-result-excerpt {
|
||||
font-size: 12px;
|
||||
color: var(--color-text-muted, #888);
|
||||
line-height: 1.4;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.post-search-result-slug {
|
||||
font-size: 11px;
|
||||
color: var(--color-text-muted, #666);
|
||||
font-family: 'Cascadia Code', 'Consolas', 'Courier New', monospace;
|
||||
}
|
||||
|
||||
.post-search-footer {
|
||||
border-top: 1px solid var(--color-border, #3c3c3c);
|
||||
padding: 8px 16px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.post-search-hint {
|
||||
font-size: 11px;
|
||||
color: var(--color-text-muted, #888);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
/* Scrollbar styling */
|
||||
.post-search-results::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
}
|
||||
|
||||
.post-search-results::-webkit-scrollbar-track {
|
||||
background: var(--color-bg-secondary, #1e1e1e);
|
||||
}
|
||||
|
||||
.post-search-results::-webkit-scrollbar-thumb {
|
||||
background: var(--color-border, #3c3c3c);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.post-search-results::-webkit-scrollbar-thumb:hover {
|
||||
background: var(--color-text-muted, #555);
|
||||
}
|
||||
@@ -1,166 +0,0 @@
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { useI18n } from '../../i18n';
|
||||
import './PostSearchModal.css';
|
||||
|
||||
interface SearchResult {
|
||||
id: string;
|
||||
title: string;
|
||||
slug: string;
|
||||
excerpt?: string;
|
||||
}
|
||||
|
||||
interface PostSearchModalProps {
|
||||
onSelect: (post: SearchResult) => void;
|
||||
onClose: () => void;
|
||||
initialQuery?: string;
|
||||
}
|
||||
|
||||
export const PostSearchModal: React.FC<PostSearchModalProps> = ({
|
||||
onSelect,
|
||||
onClose,
|
||||
initialQuery = ''
|
||||
}) => {
|
||||
const { t } = useI18n();
|
||||
const [query, setQuery] = useState(initialQuery);
|
||||
const [results, setResults] = useState<SearchResult[]>([]);
|
||||
const [selectedIndex, setSelectedIndex] = useState(0);
|
||||
const [isSearching, setIsSearching] = useState(false);
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
// Focus search input on mount
|
||||
useEffect(() => {
|
||||
inputRef.current?.focus();
|
||||
}, []);
|
||||
|
||||
// Debounced search effect
|
||||
useEffect(() => {
|
||||
if (query.length < 2) {
|
||||
setResults([]);
|
||||
setSelectedIndex(0);
|
||||
return;
|
||||
}
|
||||
|
||||
const timeoutId = setTimeout(async () => {
|
||||
setIsSearching(true);
|
||||
try {
|
||||
const searchResults = await window.electronAPI.posts.search(query);
|
||||
setResults(searchResults || []);
|
||||
setSelectedIndex(0);
|
||||
} catch (error) {
|
||||
console.error('Search failed:', error);
|
||||
setResults([]);
|
||||
} finally {
|
||||
setIsSearching(false);
|
||||
}
|
||||
}, 300);
|
||||
|
||||
return () => clearTimeout(timeoutId);
|
||||
}, [query]);
|
||||
|
||||
// Keyboard navigation handler
|
||||
const handleKeyDown = useCallback((e: React.KeyboardEvent) => {
|
||||
switch (e.key) {
|
||||
case 'Escape':
|
||||
e.preventDefault();
|
||||
onClose();
|
||||
break;
|
||||
case 'ArrowDown':
|
||||
e.preventDefault();
|
||||
setSelectedIndex(prev => Math.min(prev + 1, results.length - 1));
|
||||
break;
|
||||
case 'ArrowUp':
|
||||
e.preventDefault();
|
||||
setSelectedIndex(prev => Math.max(prev - 1, 0));
|
||||
break;
|
||||
case 'Enter':
|
||||
e.preventDefault();
|
||||
if (results[selectedIndex]) {
|
||||
onSelect(results[selectedIndex]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}, [results, selectedIndex, onClose, onSelect]);
|
||||
|
||||
// Backdrop click handler
|
||||
const handleBackdropClick = useCallback((e: React.MouseEvent) => {
|
||||
if (e.target === e.currentTarget) {
|
||||
onClose();
|
||||
}
|
||||
}, [onClose]);
|
||||
|
||||
// Result click handler
|
||||
const handleResultClick = useCallback((post: SearchResult) => {
|
||||
onSelect(post);
|
||||
}, [onSelect]);
|
||||
|
||||
// Scroll selected item into view
|
||||
useEffect(() => {
|
||||
const selectedElement = document.querySelector('.post-search-result-item.selected');
|
||||
if (selectedElement) {
|
||||
selectedElement.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
|
||||
}
|
||||
}, [selectedIndex]);
|
||||
|
||||
return (
|
||||
<div className="post-search-modal-backdrop" onClick={handleBackdropClick}>
|
||||
<div className="post-search-modal" onKeyDown={handleKeyDown}>
|
||||
<div className="post-search-header">
|
||||
<input
|
||||
ref={inputRef}
|
||||
type="text"
|
||||
className="post-search-input"
|
||||
placeholder={t('postSearch.placeholder')}
|
||||
value={query}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
autoComplete="off"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="post-search-results">
|
||||
{isSearching && (
|
||||
<div className="post-search-loading">
|
||||
{t('postSearch.searching')}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!isSearching && query.length < 2 && (
|
||||
<div className="post-search-empty">
|
||||
{t('postSearch.typeMore')}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!isSearching && query.length >= 2 && results.length === 0 && (
|
||||
<div className="post-search-empty">
|
||||
{t('postSearch.noResults', { query })}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!isSearching && results.length > 0 && results.map((post, index) => (
|
||||
<div
|
||||
key={post.id}
|
||||
className={`post-search-result-item ${index === selectedIndex ? 'selected' : ''}`}
|
||||
onClick={() => handleResultClick(post)}
|
||||
onMouseEnter={() => setSelectedIndex(index)}
|
||||
>
|
||||
<div className="post-search-result-title">{post.title}</div>
|
||||
{post.excerpt && (
|
||||
<div className="post-search-result-excerpt">
|
||||
{post.excerpt.length > 120
|
||||
? post.excerpt.substring(0, 120) + '...'
|
||||
: post.excerpt}
|
||||
</div>
|
||||
)}
|
||||
<div className="post-search-result-slug">/posts/{post.slug}</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="post-search-footer">
|
||||
<span className="post-search-hint">
|
||||
{t('postSearch.hint')}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1 +0,0 @@
|
||||
export { PostSearchModal } from './PostSearchModal';
|
||||
@@ -387,5 +387,3 @@ export const ProjectSelector: React.FC = () => {
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ProjectSelector;
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
export { ProjectSelector } from './ProjectSelector';
|
||||
export { default } from './ProjectSelector';
|
||||
|
||||
@@ -119,5 +119,3 @@ export const ResizablePanel: React.FC<ResizablePanelProps> = ({
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ResizablePanel;
|
||||
|
||||
@@ -2246,5 +2246,3 @@ export const SettingsView: React.FC = () => {
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SettingsView;
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
export { SettingsView, scrollToSettingsSection } from './SettingsView';
|
||||
export type { SettingsCategory } from './SettingsView';
|
||||
export { SettingsView } from './SettingsView';
|
||||
|
||||
@@ -136,5 +136,3 @@ export const StyleView: React.FC = () => {
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default StyleView;
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
export { StyleView } from './StyleView';
|
||||
@@ -839,5 +839,3 @@ export const TabBar: React.FC = () => {
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default TabBar;
|
||||
|
||||
@@ -221,5 +221,3 @@ export const TaskPopup: React.FC = () => {
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default TaskPopup;
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
export { TaskPopup } from './TaskPopup';
|
||||
@@ -2,11 +2,8 @@ import React from 'react';
|
||||
import { Toaster, toast } from 'react-hot-toast';
|
||||
import './Toast.css';
|
||||
|
||||
// Re-export toast for use throughout the app
|
||||
export { toast };
|
||||
|
||||
// Toast types
|
||||
export type ToastType = 'success' | 'error' | 'loading' | 'info';
|
||||
type ToastType = 'success' | 'error' | 'loading' | 'info';
|
||||
|
||||
// Custom toast functions
|
||||
export const showToast = {
|
||||
@@ -84,5 +81,3 @@ export const ToastContainer: React.FC = () => {
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default ToastContainer;
|
||||
|
||||
@@ -1 +1 @@
|
||||
export { ToastContainer, toast, showToast, type ToastType } from './Toast';
|
||||
export { ToastContainer, showToast } from './Toast';
|
||||
|
||||
@@ -505,6 +505,4 @@ export const WindowTitleBar: React.FC = () => {
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default WindowTitleBar;
|
||||
};
|
||||
@@ -4,26 +4,7 @@ export { Editor } from './Editor';
|
||||
export { StatusBar } from './StatusBar';
|
||||
export { Panel } from './Panel';
|
||||
export { TabBar } from './TabBar';
|
||||
export { ToastContainer, toast, showToast, type ToastType } from './Toast';
|
||||
export { ProjectSelector } from './ProjectSelector';
|
||||
export { MilkdownEditor } from './MilkdownEditor';
|
||||
export { Lightbox, ImageGallery, useMarkdownImages } from './Lightbox';
|
||||
export { TaskPopup } from './TaskPopup';
|
||||
export { ToastContainer, showToast } from './Toast';
|
||||
export { ResizablePanel } from './ResizablePanel';
|
||||
export { SettingsView } from './SettingsView';
|
||||
export { StyleView } from './StyleView';
|
||||
export { TagsView, scrollToTagsSection, type TagsCategory } from './TagsView';
|
||||
export { TagInput } from './TagInput';
|
||||
export { PostLinks } from './PostLinks';
|
||||
export { LinkedMediaPanel } from './LinkedMediaPanel';
|
||||
export { ErrorModal, type ErrorDetails } from './ErrorModal';
|
||||
export { ConfirmDeleteModal, type ConfirmDeleteDetails, type DeleteReference } from './ConfirmDeleteModal';
|
||||
export { AISuggestionsModal, type AISuggestions, type CurrentValues } from './AISuggestionsModal/AISuggestionsModal';
|
||||
export { ChatPanel } from './ChatPanel';
|
||||
export { ImportAnalysisView } from './ImportAnalysisView';
|
||||
export { InsertModal } from './InsertModal';
|
||||
export { WindowTitleBar } from './WindowTitleBar';
|
||||
export { DocumentationView } from './DocumentationView/DocumentationView';
|
||||
export { SiteValidationView } from './SiteValidationView';
|
||||
export { ScriptsView } from './ScriptsView/ScriptsView';
|
||||
export { AssistantSidebar } from './AssistantSidebar';
|
||||
|
||||
@@ -9,7 +9,7 @@ export type UiLanguage = 'en' | 'de' | 'fr' | 'it' | 'es';
|
||||
|
||||
export const UI_LANGUAGE_STORAGE_KEY = 'bds-ui-language';
|
||||
|
||||
export const SUPPORTED_UI_LANGUAGES: UiLanguage[] = ['en', 'de', 'fr', 'it', 'es'];
|
||||
const SUPPORTED_UI_LANGUAGES: UiLanguage[] = ['en', 'de', 'fr', 'it', 'es'];
|
||||
|
||||
type TranslationTable = Record<string, string>;
|
||||
|
||||
|
||||
@@ -74,5 +74,3 @@ const galleryMacro: MacroDefinition = {
|
||||
|
||||
// Self-register
|
||||
registerMacro(galleryMacro);
|
||||
|
||||
export default galleryMacro;
|
||||
|
||||
@@ -34,7 +34,7 @@ function getMonthName(month: number): string {
|
||||
return MONTH_NAMES[month - 1] || 'Unknown';
|
||||
}
|
||||
|
||||
const photoArchiveMacro: MacroDefinition = {
|
||||
export const photoArchiveMacro: MacroDefinition = {
|
||||
name: 'photo_archive',
|
||||
description: 'Creates a photo archive gallery organized by year and month',
|
||||
|
||||
@@ -125,5 +125,3 @@ const photoArchiveMacro: MacroDefinition = {
|
||||
// Self-register
|
||||
registerMacro(photoArchiveMacro);
|
||||
|
||||
export default photoArchiveMacro;
|
||||
export { getMonthName, MONTH_NAMES };
|
||||
|
||||
@@ -72,5 +72,3 @@ const vimeoMacro: MacroDefinition = {
|
||||
|
||||
// Self-register
|
||||
registerMacro(vimeoMacro);
|
||||
|
||||
export default vimeoMacro;
|
||||
|
||||
@@ -85,5 +85,3 @@ const youtubeMacro: MacroDefinition = {
|
||||
|
||||
// Self-register
|
||||
registerMacro(youtubeMacro);
|
||||
|
||||
export default youtubeMacro;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/**
|
||||
* Macros Module
|
||||
*
|
||||
*
|
||||
* Provides a simple extension system for rendering custom content blocks
|
||||
* in markdown using [[macro param="value"]] syntax.
|
||||
*
|
||||
*
|
||||
* Usage:
|
||||
* 1. Import this module to register all macros
|
||||
* 2. Use the registry functions to render macros
|
||||
*
|
||||
*
|
||||
* Adding new macros:
|
||||
* 1. Create a file in ./definitions/ (e.g., myMacro.ts)
|
||||
* 2. Implement MacroDefinition interface
|
||||
@@ -18,31 +18,8 @@
|
||||
// Import all macro definitions so they register
|
||||
import './definitions';
|
||||
|
||||
// Re-export types
|
||||
export type {
|
||||
MacroDefinition,
|
||||
MacroParams,
|
||||
MacroRenderContext,
|
||||
ParsedMacro,
|
||||
PythonMacroInfo,
|
||||
PythonMacroResolver,
|
||||
PythonMacroRendererFn,
|
||||
} from './types';
|
||||
|
||||
// Re-export registry functions
|
||||
// Re-export registry functions used by app
|
||||
export {
|
||||
registerMacro,
|
||||
getMacro,
|
||||
hasMacro,
|
||||
getMacroNames,
|
||||
getAllMacros,
|
||||
clearMacros,
|
||||
parseParams,
|
||||
parseMacros,
|
||||
renderMacro,
|
||||
renderAllMacros,
|
||||
getEditorPreview,
|
||||
setPythonMacroResolver,
|
||||
refreshPythonMacroSlugs,
|
||||
} from './registry';
|
||||
|
||||
|
||||
@@ -1,164 +0,0 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
const textElementSchema = z.object({
|
||||
type: z.literal('text'),
|
||||
text: z.string().min(1),
|
||||
});
|
||||
|
||||
const metricElementSchema = z.object({
|
||||
type: z.literal('metric'),
|
||||
label: z.string().min(1),
|
||||
value: z.string().min(1),
|
||||
});
|
||||
|
||||
const listElementSchema = z.object({
|
||||
type: z.literal('list'),
|
||||
title: z.string().optional(),
|
||||
items: z.array(z.string().min(1)).min(1),
|
||||
});
|
||||
|
||||
const tableElementSchema = z.object({
|
||||
type: z.literal('table'),
|
||||
columns: z.array(z.string().min(1)).min(1),
|
||||
rows: z.array(z.array(z.string())).min(1),
|
||||
});
|
||||
|
||||
const actionElementSchema = z.object({
|
||||
type: z.literal('action'),
|
||||
label: z.string().min(1),
|
||||
action: z.string().min(1),
|
||||
payload: z.record(z.string(), z.unknown()).optional(),
|
||||
});
|
||||
|
||||
const segmentSchema = z.object({
|
||||
label: z.string().min(1),
|
||||
value: z.number(),
|
||||
});
|
||||
|
||||
const chartElementSchema = z.object({
|
||||
type: z.literal('chart'),
|
||||
chartType: z.enum(['bar', 'stacked-bar', 'line', 'area', 'pie', 'donut', 'heatmap']),
|
||||
title: z.string().min(1).optional(),
|
||||
series: z.array(
|
||||
z.object({
|
||||
label: z.string().min(1),
|
||||
value: z.number(),
|
||||
segments: z.array(segmentSchema).optional(),
|
||||
}),
|
||||
).min(1),
|
||||
});
|
||||
|
||||
const inputTypeSchema = z.enum(['text', 'textarea', 'select', 'checkbox', 'date', 'number']);
|
||||
|
||||
const inputOptionSchema = z.object({
|
||||
label: z.string().min(1),
|
||||
value: z.string(),
|
||||
});
|
||||
|
||||
const inputElementSchema = z.object({
|
||||
type: z.literal('input'),
|
||||
key: z.string().min(1),
|
||||
label: z.string().min(1),
|
||||
inputType: inputTypeSchema,
|
||||
placeholder: z.string().optional(),
|
||||
defaultValue: z.union([z.string(), z.number(), z.boolean()]).optional(),
|
||||
options: z.array(inputOptionSchema).optional(),
|
||||
action: z.string().min(1).optional(),
|
||||
submitLabel: z.string().min(1).optional(),
|
||||
payload: z.record(z.string(), z.unknown()).optional(),
|
||||
});
|
||||
|
||||
const datePickerElementSchema = z.object({
|
||||
type: z.literal('datePicker'),
|
||||
key: z.string().min(1),
|
||||
label: z.string().min(1),
|
||||
defaultValue: z.string().optional(),
|
||||
min: z.string().optional(),
|
||||
max: z.string().optional(),
|
||||
action: z.string().min(1).optional(),
|
||||
submitLabel: z.string().min(1).optional(),
|
||||
payload: z.record(z.string(), z.unknown()).optional(),
|
||||
});
|
||||
|
||||
const formFieldSchema = z.object({
|
||||
key: z.string().min(1),
|
||||
label: z.string().min(1),
|
||||
inputType: inputTypeSchema,
|
||||
placeholder: z.string().optional(),
|
||||
defaultValue: z.union([z.string(), z.number(), z.boolean()]).optional(),
|
||||
options: z.array(inputOptionSchema).optional(),
|
||||
required: z.boolean().optional(),
|
||||
});
|
||||
|
||||
const formElementSchema = z.object({
|
||||
type: z.literal('form'),
|
||||
formId: z.string().min(1),
|
||||
title: z.string().optional(),
|
||||
submitLabel: z.string().min(1),
|
||||
action: z.string().min(1),
|
||||
payload: z.record(z.string(), z.unknown()).optional(),
|
||||
fields: z.array(formFieldSchema).min(1),
|
||||
});
|
||||
|
||||
const cardActionSchema = z.object({
|
||||
label: z.string().min(1),
|
||||
action: z.string().min(1),
|
||||
payload: z.record(z.string(), z.unknown()).optional(),
|
||||
});
|
||||
|
||||
const cardElementSchema = z.object({
|
||||
type: z.literal('card'),
|
||||
title: z.string().min(1),
|
||||
body: z.string().min(1),
|
||||
subtitle: z.string().optional(),
|
||||
actions: z.array(cardActionSchema).optional(),
|
||||
});
|
||||
|
||||
const imageElementSchema = z.object({
|
||||
type: z.literal('image'),
|
||||
src: z.string().min(1),
|
||||
alt: z.string().optional(),
|
||||
caption: z.string().optional(),
|
||||
action: z.string().min(1).optional(),
|
||||
payload: z.record(z.string(), z.unknown()).optional(),
|
||||
});
|
||||
|
||||
let assistantPanelElementSchemaRef: z.ZodTypeAny;
|
||||
|
||||
const tabsElementSchema: z.ZodTypeAny = z.lazy(() => z.object({
|
||||
type: z.literal('tabs'),
|
||||
widgetId: z.string().min(1).optional(),
|
||||
defaultTabId: z.string().min(1).optional(),
|
||||
tabs: z.array(
|
||||
z.object({
|
||||
id: z.string().min(1),
|
||||
label: z.string().min(1),
|
||||
elements: z.array(assistantPanelElementSchemaRef).min(1),
|
||||
}),
|
||||
).min(1),
|
||||
}));
|
||||
|
||||
assistantPanelElementSchemaRef = z.union([
|
||||
textElementSchema,
|
||||
metricElementSchema,
|
||||
listElementSchema,
|
||||
tableElementSchema,
|
||||
actionElementSchema,
|
||||
chartElementSchema,
|
||||
inputElementSchema,
|
||||
formElementSchema,
|
||||
datePickerElementSchema,
|
||||
cardElementSchema,
|
||||
imageElementSchema,
|
||||
tabsElementSchema,
|
||||
]);
|
||||
|
||||
export const assistantPanelElementSchema = assistantPanelElementSchemaRef;
|
||||
|
||||
export const assistantPanelSpecSchema = z.object({
|
||||
specVersion: z.literal('1'),
|
||||
elements: z.array(assistantPanelElementSchema).min(1),
|
||||
});
|
||||
|
||||
export type AssistantPanelElement = z.infer<typeof assistantPanelElementSchema>;
|
||||
export type AssistantPanelSpec = z.infer<typeof assistantPanelSpecSchema>;
|
||||
@@ -133,11 +133,11 @@ export function openTemplateTab(
|
||||
openTab(getTemplateTabSpec(templateId, intent));
|
||||
}
|
||||
|
||||
export function getGitDiffFileTabId(filePath: string): string {
|
||||
function getGitDiffFileTabId(filePath: string): string {
|
||||
return `git-diff:${filePath}`;
|
||||
}
|
||||
|
||||
export function getGitDiffCommitTabId(commitHash: string): string {
|
||||
function getGitDiffCommitTabId(commitHash: string): string {
|
||||
return `git-diff:commit:${commitHash}`;
|
||||
}
|
||||
|
||||
|
||||
@@ -147,5 +147,3 @@ export const imageResolverPlugin = $prose(() => {
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
export default imageResolverPlugin;
|
||||
|
||||
@@ -84,12 +84,12 @@ const remarkMacroParser: Plugin<[], Root> = () => {
|
||||
/**
|
||||
* Remark plugin registration for Milkdown
|
||||
*/
|
||||
export const remarkMacro = $remark('remarkMacro', () => remarkMacroParser);
|
||||
const remarkMacro = $remark('remarkMacro', () => remarkMacroParser);
|
||||
|
||||
/**
|
||||
* ProseMirror node schema for macros
|
||||
*/
|
||||
export const macroNode = $node('macro', () => ({
|
||||
const macroNode = $node('macro', () => ({
|
||||
group: 'inline',
|
||||
inline: true,
|
||||
atom: true, // Treated as a single unit, not editable as text
|
||||
@@ -154,7 +154,7 @@ export const macroNode = $node('macro', () => ({
|
||||
* Input rule to convert typed [[macro...]] to macro node
|
||||
* Triggers when user types ]] to close a macro
|
||||
*/
|
||||
export const macroInputRule = $inputRule(() => {
|
||||
const macroInputRule = $inputRule(() => {
|
||||
// Match [[macroName param="value"]] when user types the closing ]]
|
||||
return new InputRule(
|
||||
/\[\[(\w+)(?:\s+([^\]]+))?\]\]$/,
|
||||
@@ -185,5 +185,3 @@ export const macroPlugin = [
|
||||
macroNode,
|
||||
macroInputRule,
|
||||
].flat();
|
||||
|
||||
export default macroPlugin;
|
||||
|
||||
@@ -3,7 +3,6 @@ export {
|
||||
BDS_PYTHON_API_CONTRACT_V1,
|
||||
listPythonApiMethodNames,
|
||||
getPythonApiMethodContract,
|
||||
getPythonApiDataStructureContracts,
|
||||
} from '../../main/shared/pythonApiContractV1';
|
||||
|
||||
export type {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
export { AutoSaveManager, type AutoSaveConfig } from './autoSave';
|
||||
export { AutoSaveManager } from './autoSave';
|
||||
export { getContrastColor } from './color';
|
||||
export { unescapeMacroSyntax } from './markdownEscape';
|
||||
export { groupPostsByStatus, type GroupedPosts, type PostStatus } from './postGrouping';
|
||||
export { groupPostsByStatus } from './postGrouping';
|
||||
export { loadTabsForProject, saveTabsForProject } from './tabPersistence';
|
||||
export { buildTagColorMap, loadTagColorMap } from './tagColors';
|
||||
export { loadTagColorMap } from './tagColors';
|
||||
export { BDS_EVENT_SCRIPTS_CHANGED, BDS_EVENT_TEMPLATES_CHANGED, addWindowEventListener, dispatchWindowEvent, type BdsWindowEventName } from './windowEvents';
|
||||
|
||||
Reference in New Issue
Block a user