Something went wrong. Try again.
[mirror] A local-first desktop markdown writer with grammar checking, at proto integration, and more github.com/stormlightlabs/writer/releases
atproto codemirror markdown tauri rust react
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573import type { StyleCheckSettings } from "$types";import { useShallow } from "zustand/react/shallow";import { useDocxExportStore } from "./stores/docx-export";import { useLayoutStore } from "./stores/layout";import { usePdfExportStore } from "./stores/pdf-export";import { useSearchStore } from "./stores/search";import { useTabsStore } from "./stores/tabs";import { useTextExportStore } from "./stores/text-export";import { useUiStore } from "./stores/ui";import { useWorkspaceStore } from "./stores/workspace";import type { EditorPresentation } from "./types";
const FOCUS_MODE_STYLE_CHECK_SETTINGS: StyleCheckSettings = { enabled: false, categories: { filler: true, redundancy: true, cliche: true }, customPatterns: [], markerStyle: "highlight",};
export const useLayoutChromeState = () => useLayoutStore( useShallow((state) => ({ sidebarCollapsed: state.sidebarCollapsed, topBarsCollapsed: state.topBarsCollapsed, statusBarCollapsed: state.statusBarCollapsed, showSearch: state.showSearch, reduceMotion: state.reduceMotion, showFilenames: state.showFilenames, createReadmeInNewLocations: state.createReadmeInNewLocations, })), );
export const useLayoutChromeActions = () => useLayoutStore( useShallow((state) => ({ setSidebarCollapsed: state.setSidebarCollapsed, toggleSidebarCollapsed: state.toggleSidebarCollapsed, setTopBarsCollapsed: state.setTopBarsCollapsed, toggleTabBarCollapsed: state.toggleTabBarCollapsed, setStatusBarCollapsed: state.setStatusBarCollapsed, toggleStatusBarCollapsed: state.toggleStatusBarCollapsed, setShowSearch: state.setShowSearch, toggleShowSearch: state.toggleShowSearch, setFilenameVisibility: state.setFilenameVisibility, toggleFilenameVisibility: state.toggleFilenameVisibility, })), );
export const useEditorPresentationStateRaw = () => useLayoutStore( useShallow((state) => ({ lineNumbersVisible: state.lineNumbersVisible, textWrappingEnabled: state.textWrappingEnabled, syntaxHighlightingEnabled: state.syntaxHighlightingEnabled, editorFontSize: state.editorFontSize, editorFontFamily: state.editorFontFamily, renderedFontFamily: state.renderedFontFamily, markdownPreviewStyle: state.markdownPreviewStyle, theme: state.theme, })), );
export const useEditorPresentationActions = () => useLayoutStore( useShallow((state) => ({ setLineNumbersVisible: state.setLineNumbersVisible, toggleLineNumbersVisible: state.toggleLineNumbersVisible, setTextWrappingEnabled: state.setTextWrappingEnabled, toggleTextWrappingEnabled: state.toggleTextWrappingEnabled, setSyntaxHighlightingEnabled: state.setSyntaxHighlightingEnabled, toggleSyntaxHighlightingEnabled: state.toggleSyntaxHighlightingEnabled, setEditorFontSize: state.setEditorFontSize, setEditorFontFamily: state.setEditorFontFamily, setRenderedFontFamily: state.setRenderedFontFamily, setMarkdownPreviewStyle: state.setMarkdownPreviewStyle, })), );
export const useViewModeState = () => useLayoutStore( useShallow((state) => ({ isSplitView: state.isSplitView, isFocusMode: state.isFocusMode, isPreviewVisible: state.isPreviewVisible, focusModeSettings: state.focusModeSettings, })), );
export const useViewModeActions = () => useLayoutStore( useShallow((state) => ({ setSplitView: state.setSplitView, toggleSplitView: state.toggleSplitView, setEditorOnlyMode: state.setEditorOnlyMode, setFocusMode: state.setFocusMode, toggleFocusMode: state.toggleFocusMode, setFocusModeSettings: state.setFocusModeSettings, setTypewriterScrollingEnabled: state.setTypewriterScrollingEnabled, setFocusDimmingMode: state.setFocusDimmingMode, toggleTypewriterScrolling: state.toggleTypewriterScrolling, setPreviewVisible: state.setPreviewVisible, togglePreviewVisible: state.togglePreviewVisible, })), );
export const useWritingToolsState = () => useLayoutStore( useShallow((state) => ({ posHighlightingEnabled: state.posHighlightingEnabled, styleCheckSettings: state.styleCheckSettings, })), );
export const useWritingActions = () => useLayoutStore( useShallow((state) => ({ setPosHighlightingEnabled: state.setPosHighlightingEnabled, togglePosHighlighting: state.togglePosHighlighting, setStyleCheckSettings: state.setStyleCheckSettings, toggleStyleCheck: state.toggleStyleCheck, setStyleCheckCategory: state.setStyleCheckCategory, addCustomPattern: state.addCustomPattern, removeCustomPattern: state.removeCustomPattern, })), );
export const useWorkspaceLocationsState = () => useWorkspaceStore( useShallow((state) => ({ locations: state.locations, isLoadingLocations: state.isLoadingLocations, selectedLocationId: state.selectedLocationId, sidebarFilter: state.sidebarFilter, })), );
export const useWorkspaceLocationsActions = () => useWorkspaceStore( useShallow((state) => ({ setSidebarFilter: state.setSidebarFilter, setLocations: state.setLocations, setLoadingLocations: state.setLoadingLocations, setSelectedLocation: state.setSelectedLocation, })), );
export const useWorkspaceDocumentsState = () => useWorkspaceStore( useShallow((state) => ({ selectedDocPath: state.selectedDocPath, documents: state.documents, directories: state.directories, documentsByLocation: state.documentsByLocation, directoriesByLocation: state.directoriesByLocation, expandedLocationIds: state.expandedLocationIds, expandedDirectoriesByLocation: state.expandedDirectoriesByLocation, isLoadingDocuments: state.isLoadingDocuments, refreshingLocationId: state.refreshingLocationId, sidebarRefreshReason: state.sidebarRefreshReason, externalDropTargetId: state.externalDropTargetId, externalDropFolderPath: state.externalDropFolderPath, activeDropTarget: state.activeDropTarget, folderSortOrderByLocation: state.folderSortOrderByLocation, })), );
export const useWorkspaceDocumentsActions = () => useWorkspaceStore( useShallow((state) => ({ setSelectedDocPath: state.setSelectedDocPath, setDocuments: state.setDocuments, setDirectories: state.setDirectories, setDocumentsForLocation: state.setDocumentsForLocation, setDirectoriesForLocation: state.setDirectoriesForLocation, setSidebarTreeState: state.setSidebarTreeState, toggleExpandedLocation: state.toggleExpandedLocation, toggleExpandedDirectory: state.toggleExpandedDirectory, expandDirectories: state.expandDirectories, collapseDirectories: state.collapseDirectories, setLoadingDocuments: state.setLoadingDocuments, setSidebarRefreshState: state.setSidebarRefreshState, setExternalDropTarget: state.setExternalDropTarget, setActiveDropTarget: state.setActiveDropTarget, reorderFolderSortOrder: state.reorderFolderSortOrder, })), );
export const useTabsState = () => useTabsStore( useShallow((state) => ({ tabs: state.tabs, activeTabId: state.activeTabId, isSessionHydrated: state.isSessionHydrated, })), );
export const useTabsActions = () => useTabsStore(useShallow((state) => ({ applySessionState: state.applySessionState })));
export const usePdfExportState = () => usePdfExportStore( useShallow((state) => ({ isExportingPdf: state.isExportingPdf, pdfExportError: state.pdfExportError })), );
export const usePdfExportActions = () => usePdfExportStore( useShallow((state) => ({ startPdfExport: state.startPdfExport, finishPdfExport: state.finishPdfExport, failPdfExport: state.failPdfExport, resetPdfExport: state.resetPdfExport, })), );
export const useTextExportState = () => useTextExportStore( useShallow((state) => ({ isExportingText: state.isExportingText, textExportError: state.textExportError })), );
export const useTextExportActions = () => useTextExportStore( useShallow((state) => ({ startTextExport: state.startTextExport, finishTextExport: state.finishTextExport, failTextExport: state.failTextExport, resetTextExport: state.resetTextExport, })), );
export const useDocxExportState = () => useDocxExportStore( useShallow((state) => ({ isExportingDocx: state.isExportingDocx, docxExportError: state.docxExportError })), );
export const useDocxExportActions = () => useDocxExportStore( useShallow((state) => ({ startDocxExport: state.startDocxExport, finishDocxExport: state.finishDocxExport, failDocxExport: state.failDocxExport, resetDocxExport: state.resetDocxExport, })), );
export const useSearchState = () => useSearchStore( useShallow((state) => ({ searchQuery: state.searchQuery, searchResults: state.searchResults, isSearching: state.isSearching, filters: state.searchFilters, })), );
export const useSearchActions = () => useSearchStore( useShallow((state) => ({ setSearchQuery: state.setSearchQuery, setSearchResults: state.setSearchResults, setIsSearching: state.setIsSearching, setFilters: state.setSearchFilters, resetSearch: state.resetSearch, })), );
export const useActiveSearchFilterCount = () => useSearchStore((state) => { const filters = state.searchFilters; return (filters.locations?.length ?? 0) + (filters.fileTypes?.length ?? 0) + (filters.dateRange ? 1 : 0); });
export const useLayoutSettingsUiState = () => useUiStore(useShallow((state) => ({ isOpen: state.layoutSettingsOpen, setOpen: state.setLayoutSettingsOpen })));
export const usePdfDialogUiState = () => useUiStore( useShallow((state) => ({ isOpen: state.pdfExportDialogOpen, setOpen: state.setPdfExportDialogOpen, options: state.pdfExportOptions, setOptions: state.setPdfExportOptions, resetOptions: state.resetPdfExportOptions, setPageSize: state.setPdfPageSize, setOrientation: state.setPdfOrientation, setFontSize: state.setPdfFontSize, setMargin: state.setPdfMargin, setIncludeTitle: state.setPdfIncludeTitle, setIncludeHeader: state.setPdfIncludeHeader, setIncludeFooter: state.setPdfIncludeFooter, })), );
export const useGlobalCaptureSettingsState = () => useUiStore( useShallow((state) => ({ settings: state.globalCaptureSettings, setSettings: state.setGlobalCaptureSettings, setQuickCaptureEnabled: state.setQuickCaptureEnabled, })), );
export const useLayoutSettingsChromeState = () => useLayoutStore( useShallow((state) => ({ sidebarCollapsed: state.sidebarCollapsed, topBarsCollapsed: state.topBarsCollapsed, statusBarCollapsed: state.statusBarCollapsed, toggleSidebarCollapsed: state.toggleSidebarCollapsed, toggleTabBarCollapsed: state.toggleTabBarCollapsed, toggleStatusBarCollapsed: state.toggleStatusBarCollapsed, })), );
export const useLayoutSettingsEditorState = () => useLayoutStore( useShallow((state) => ({ lineNumbersVisible: state.lineNumbersVisible, textWrappingEnabled: state.textWrappingEnabled, syntaxHighlightingEnabled: state.syntaxHighlightingEnabled, editorFontSize: state.editorFontSize, editorFontFamily: state.editorFontFamily, renderedFontFamily: state.renderedFontFamily, markdownPreviewStyle: state.markdownPreviewStyle, toggleLineNumbersVisible: state.toggleLineNumbersVisible, toggleTextWrappingEnabled: state.toggleTextWrappingEnabled, toggleSyntaxHighlightingEnabled: state.toggleSyntaxHighlightingEnabled, setEditorFontSize: state.setEditorFontSize, setEditorFontFamily: state.setEditorFontFamily, setRenderedFontFamily: state.setRenderedFontFamily, setMarkdownPreviewStyle: state.setMarkdownPreviewStyle, })), );
export const useLayoutSettingsFocusState = () => useLayoutStore( useShallow((state) => ({ focusModeSettings: state.focusModeSettings, setTypewriterScrollingEnabled: state.setTypewriterScrollingEnabled, setFocusDimmingMode: state.setFocusDimmingMode, setAutoEnterFocusMode: state.setAutoEnterFocusMode, })), );
export const useLayoutSettingsWritingState = () => useLayoutStore( useShallow((state) => ({ posHighlightingEnabled: state.posHighlightingEnabled, styleCheckSettings: state.styleCheckSettings, togglePosHighlighting: state.togglePosHighlighting, setStyleCheckSettings: state.setStyleCheckSettings, setStyleCheckCategory: state.setStyleCheckCategory, addCustomPattern: state.addCustomPattern, removeCustomPattern: state.removeCustomPattern, })), );
export const useAppHeaderBarState = () => useLayoutStore( useShallow((state) => ({ sidebarCollapsed: state.sidebarCollapsed, tabBarCollapsed: state.topBarsCollapsed, statusBarCollapsed: state.statusBarCollapsed, toggleSidebarCollapsed: state.toggleSidebarCollapsed, toggleTabBarCollapsed: state.toggleTabBarCollapsed, toggleStatusBarCollapsed: state.toggleStatusBarCollapsed, setShowSearch: state.setShowSearch, })), );
export const useWorkspacePanelSidebarState = () => useLayoutStore(useShallow((state) => ({ sidebarCollapsed: state.sidebarCollapsed })));
export const useWorkspacePanelModeState = () => useLayoutStore(useShallow((state) => ({ isSplitView: state.isSplitView, isPreviewVisible: state.isPreviewVisible })));
export const useWorkspacePanelTopBarsCollapsed = () => useLayoutStore((state) => state.topBarsCollapsed);
export const useWorkspacePanelStatusBarCollapsed = () => useLayoutStore((state) => state.statusBarCollapsed);
export const useSearchOverlayState = () => useLayoutStore(useShallow((state) => ({ isVisible: state.showSearch, setShowSearch: state.setShowSearch })));
export const useFocusModePanelState = () => useLayoutStore( useShallow((state) => ({ statusBarCollapsed: state.statusBarCollapsed, setFocusMode: state.setFocusMode })), );
export const useSidebarState = () => { const layoutState = useLayoutStore( useShallow((state) => ({ toggleSidebarCollapsed: state.toggleSidebarCollapsed, filenameVisibility: state.showFilenames, })), ); const workspaceState = useWorkspaceStore( useShallow((state) => ({ locations: state.locations, selectedLocationId: state.selectedLocationId, selectedDocPath: state.selectedDocPath, documents: state.documents, directories: state.directories, documentsByLocation: state.documentsByLocation, directoriesByLocation: state.directoriesByLocation, expandedLocationIds: state.expandedLocationIds, expandedDirectoriesByLocation: state.expandedDirectoriesByLocation, isLoadingLocations: state.isLoadingLocations, isLoadingDocuments: state.isLoadingDocuments, refreshingLocationId: state.refreshingLocationId, sidebarRefreshReason: state.sidebarRefreshReason, externalDropTargetId: state.externalDropTargetId, externalDropFolderPath: state.externalDropFolderPath, activeDropTarget: state.activeDropTarget, folderSortOrderByLocation: state.folderSortOrderByLocation, filterText: state.sidebarFilter, setFilterText: state.setSidebarFilter, selectLocation: state.setSelectedLocation, setDocuments: state.setDocuments, setDirectories: state.setDirectories, setDocumentsForLocation: state.setDocumentsForLocation, setDirectoriesForLocation: state.setDirectoriesForLocation, setSidebarTreeState: state.setSidebarTreeState, toggleExpandedLocation: state.toggleExpandedLocation, toggleExpandedDirectory: state.toggleExpandedDirectory, expandDirectories: state.expandDirectories, collapseDirectories: state.collapseDirectories, setExternalDropTarget: state.setExternalDropTarget, setActiveDropTarget: state.setActiveDropTarget, reorderFolderSortOrder: state.reorderFolderSortOrder, })), );
return { locations: workspaceState.locations, selectedLocationId: workspaceState.selectedLocationId, selectedDocPath: workspaceState.selectedDocPath, documents: workspaceState.documents, directories: workspaceState.directories, documentsByLocation: workspaceState.documentsByLocation, directoriesByLocation: workspaceState.directoriesByLocation, expandedLocationIds: workspaceState.expandedLocationIds, expandedDirectoriesByLocation: workspaceState.expandedDirectoriesByLocation, isLoading: workspaceState.isLoadingLocations || workspaceState.isLoadingDocuments, refreshingLocationId: workspaceState.refreshingLocationId, sidebarRefreshReason: workspaceState.sidebarRefreshReason, externalDropTargetId: workspaceState.externalDropTargetId, externalDropFolderPath: workspaceState.externalDropFolderPath, activeDropTarget: workspaceState.activeDropTarget, folderSortOrderByLocation: workspaceState.folderSortOrderByLocation, filterText: workspaceState.filterText, setFilterText: workspaceState.setFilterText, selectLocation: workspaceState.selectLocation, setDocuments: workspaceState.setDocuments, setDirectories: workspaceState.setDirectories, setDocumentsForLocation: workspaceState.setDocumentsForLocation, setDirectoriesForLocation: workspaceState.setDirectoriesForLocation, setSidebarTreeState: workspaceState.setSidebarTreeState, toggleExpandedLocation: workspaceState.toggleExpandedLocation, toggleExpandedDirectory: workspaceState.toggleExpandedDirectory, expandDirectories: workspaceState.expandDirectories, collapseDirectories: workspaceState.collapseDirectories, toggleSidebarCollapsed: layoutState.toggleSidebarCollapsed, filenameVisibility: layoutState.filenameVisibility, setExternalDropTarget: workspaceState.setExternalDropTarget, setActiveDropTarget: workspaceState.setActiveDropTarget, reorderFolderSortOrder: workspaceState.reorderFolderSortOrder, };};
export const useToolbarState = () => useLayoutStore( useShallow((state) => ({ isSplitView: state.isSplitView, isFocusMode: state.isFocusMode, isPreviewVisible: state.isPreviewVisible, setEditorOnlyMode: state.setEditorOnlyMode, toggleSplitView: state.toggleSplitView, toggleFocusMode: state.toggleFocusMode, togglePreviewVisible: state.togglePreviewVisible, })), );
export const useEditorPresentationState = () => useLayoutStore( useShallow((state): EditorPresentation => ({ theme: state.theme, showLineNumbers: state.isFocusMode ? false : state.lineNumbersVisible, textWrappingEnabled: state.textWrappingEnabled, syntaxHighlightingEnabled: state.syntaxHighlightingEnabled, fontSize: state.editorFontSize, fontFamily: state.editorFontFamily, renderedFontFamily: state.renderedFontFamily, markdownPreviewStyle: state.markdownPreviewStyle, typewriterScrollingEnabled: state.isFocusMode ? state.focusModeSettings.typewriterScrollingEnabled : false, focusDimmingMode: state.isFocusMode ? state.focusModeSettings.dimmingMode : "off", posHighlightingEnabled: state.posHighlightingEnabled, styleCheckSettings: state.isFocusMode ? FOCUS_MODE_STYLE_CHECK_SETTINGS : state.styleCheckSettings, })), );
export const useReduceMotionState = () => useLayoutStore(useShallow((state) => ({ reduceMotion: state.reduceMotion, setReduceMotion: state.setReduceMotion })));
export const useShowFilenamesState = () => useLayoutStore( useShallow((state) => ({ filenameVisibility: state.showFilenames, setFilenameVisibility: state.setFilenameVisibility, toggleFilenameVisibility: state.toggleFilenameVisibility, })), );
export const useCreateReadmeState = () => useLayoutStore( useShallow((state) => ({ createReadmeInNewLocations: state.createReadmeInNewLocations, setCreateReadmeInNewLocations: state.setCreateReadmeInNewLocations, })), );
export const useHelpSheetState = () => useUiStore( useShallow((state) => ({ isOpen: state.helpSheetOpen, setOpen: state.setHelpSheetOpen, toggle: state.toggleHelpSheet, })), );
export const useStyleDiagnosticsUiState = () => useUiStore( useShallow((state) => ({ isOpen: state.styleDiagnosticsOpen, setOpen: state.setStyleDiagnosticsOpen, toggle: state.toggleStyleDiagnostics, })), );
export const useAtProtoUiState = () => useUiStore( useShallow((state) => ({ sheetMode: state.atProtoSheetMode, session: state.atProtoSession, isHydrated: state.atProtoHydrated, isPending: state.atProtoPending, openLoginSheet: state.openAtProtoLoginSheet, openSessionSheet: state.openAtProtoSessionSheet, openImportSheet: state.openAtProtoImportSheet, openPublishSheet: state.openAtProtoPublishSheet, closeSheet: state.closeAtProtoSheet, setSession: state.setAtProtoSession, setHydrated: state.setAtProtoHydrated, setPending: state.setAtProtoPending, })), );
export const useStandardSiteUiState = () => useUiStore( useShallow((state) => ({ sheetMode: state.standardSiteSheetMode, openPostImportSheet: state.openStandardSitePostImportSheet, closeSheet: state.closeStandardSiteSheet, })), );
export type SidebarStateReturn = ReturnType<typeof useSidebarState>;export type ToolbarStateReturn = ReturnType<typeof useToolbarState>;export type EditorPresentationStateReturn = ReturnType<typeof useEditorPresentationState>;export type WorkspacePanelSidebarStateReturn = ReturnType<typeof useWorkspacePanelSidebarState>;export type WorkspacePanelModeStateReturn = ReturnType<typeof useWorkspacePanelModeState>;export type TopBarsCollapsedReturn = ReturnType<typeof useWorkspacePanelTopBarsCollapsed>;export type StatusBarCollapsedReturn = ReturnType<typeof useWorkspacePanelStatusBarCollapsed>;export type AtProtoUiStateReturn = ReturnType<typeof useAtProtoUiState>;