chore: lint and fmt
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
import { ComputedRef, onUnmounted, Ref, toValue } from "vue"
|
||||
|
||||
import { isExternalLink } from "@/utils/link"
|
||||
import { useRouteQueryStackedNotes } from "@/hooks/useRouteQueryStackedNotes.hook"
|
||||
import { parseAtUri } from "@/modules/atproto/parseAtUri"
|
||||
import { toShortDid } from "@/modules/atproto/shortDid"
|
||||
import { router } from "@/router/router"
|
||||
import { isExternalLink } from "@/utils/link"
|
||||
|
||||
export const useATProtoLinks = (
|
||||
className: ComputedRef<string> | string,
|
||||
options: {
|
||||
currentAtUri?: Ref<string> | string | ComputedRef<string>
|
||||
mainNoteId: Ref<string> | string | ComputedRef<string>
|
||||
},
|
||||
}
|
||||
) => {
|
||||
const { addStackedNote, scrollToFocusedNote } = useRouteQueryStackedNotes()
|
||||
const { currentAtUri, mainNoteId } = options
|
||||
@@ -38,7 +38,7 @@ export const useATProtoLinks = (
|
||||
|
||||
if (href.startsWith(window.location.origin)) {
|
||||
const { params } = router.resolve(
|
||||
href.replace(window.location.origin, ""),
|
||||
href.replace(window.location.origin, "")
|
||||
)
|
||||
|
||||
if (!params.shortDid || !params.rkey) {
|
||||
@@ -57,7 +57,7 @@ export const useATProtoLinks = (
|
||||
addStackedNote(
|
||||
toValue(currentAtUri) ?? "",
|
||||
noteId,
|
||||
`${params.shortDid}-${params.rkey}`,
|
||||
`${params.shortDid}-${params.rkey}`
|
||||
)
|
||||
return
|
||||
}
|
||||
@@ -111,6 +111,6 @@ export const useATProtoLinks = (
|
||||
})
|
||||
|
||||
return {
|
||||
listenToClick,
|
||||
listenToClick
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
import { computed, ref } from 'vue'
|
||||
import { computed, ref } from "vue"
|
||||
|
||||
import { getAuthor } from '@/modules/atproto/getAuthor'
|
||||
import { restoreSession, sdkSignOut, signInWithHandle } from '@/modules/atproto/service/atprotoOAuth'
|
||||
import { clearSession, loadSession, saveSession } from '@/modules/atproto/service/atprotoSession'
|
||||
import { getAuthor } from "@/modules/atproto/getAuthor"
|
||||
import {
|
||||
restoreSession,
|
||||
sdkSignOut,
|
||||
signInWithHandle
|
||||
} from "@/modules/atproto/service/atprotoOAuth"
|
||||
import {
|
||||
clearSession,
|
||||
loadSession,
|
||||
saveSession
|
||||
} from "@/modules/atproto/service/atprotoSession"
|
||||
|
||||
const did = ref<string | null>(null)
|
||||
const handle = ref<string | null>(null)
|
||||
@@ -12,20 +20,24 @@ let init = true
|
||||
const initializeAuth = async () => {
|
||||
// Load cached session from IndexedDB first (fast, local) so the UI can render immediately
|
||||
const stored = await loadSession()
|
||||
did.value = stored?.did ?? ''
|
||||
handle.value = stored?.handle ?? ''
|
||||
did.value = stored?.did ?? ""
|
||||
handle.value = stored?.handle ?? ""
|
||||
|
||||
// Then restore OAuth session in the background (may involve network)
|
||||
const session = await restoreSession()
|
||||
if (session) {
|
||||
const author = await getAuthor(session.did)
|
||||
const resolvedHandle = author?.handle ?? ''
|
||||
const resolvedHandle = author?.handle ?? ""
|
||||
|
||||
did.value = session.did
|
||||
handle.value = resolvedHandle
|
||||
await saveSession(session.did, resolvedHandle)
|
||||
|
||||
window.history.replaceState(null, '', window.location.pathname + window.location.search)
|
||||
window.history.replaceState(
|
||||
null,
|
||||
"",
|
||||
window.location.pathname + window.location.search
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,8 +59,8 @@ export const useATProtoLogin = () => {
|
||||
await sdkSignOut(did.value)
|
||||
}
|
||||
await clearSession()
|
||||
did.value = ''
|
||||
handle.value = ''
|
||||
did.value = ""
|
||||
handle.value = ""
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -57,6 +69,6 @@ export const useATProtoLogin = () => {
|
||||
isLoggedIn,
|
||||
isATProtoReady,
|
||||
signIn,
|
||||
signOut,
|
||||
signOut
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { useAsyncState } from '@vueuse/core'
|
||||
import { ComputedRef, onUnmounted, toValue } from 'vue'
|
||||
import { useAsyncState } from "@vueuse/core"
|
||||
import { ComputedRef, onUnmounted, toValue } from "vue"
|
||||
|
||||
import { backlinkEventBus } from '@/bus/backlinkEventBus'
|
||||
import { data } from '@/data/data'
|
||||
import { DataType } from '@/data/DataType.enum'
|
||||
import { BacklinkNote } from '@/modules/note/models/BacklinkNote'
|
||||
import { backlinkEventBus } from "@/bus/backlinkEventBus"
|
||||
import { data } from "@/data/data"
|
||||
import { DataType } from "@/data/DataType.enum"
|
||||
import { BacklinkNote } from "@/modules/note/models/BacklinkNote"
|
||||
|
||||
export const useBacklinks = (sha: string | ComputedRef<string>) => {
|
||||
sha = toValue(sha)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ref, Ref, toValue, onUnmounted } from "vue"
|
||||
import { useDebounceFn } from "@vueuse/core"
|
||||
import { onUnmounted, Ref, ref, toValue } from "vue"
|
||||
|
||||
import { useGitHubContent } from "@/hooks/useGitHubContent.hook"
|
||||
|
||||
const CHECKBOX_PATTERN = /\[([ xX])\]/g
|
||||
@@ -7,7 +8,7 @@ const CHECKBOX_PATTERN = /\[([ xX])\]/g
|
||||
const setCheckboxInMarkdown = (
|
||||
markdown: string,
|
||||
index: number,
|
||||
checked: boolean,
|
||||
checked: boolean
|
||||
): string => {
|
||||
let currentIndex = 0
|
||||
|
||||
@@ -21,7 +22,7 @@ const setCheckboxInMarkdown = (
|
||||
|
||||
const findCheckboxIndex = (
|
||||
container: Element,
|
||||
checkbox: HTMLInputElement,
|
||||
checkbox: HTMLInputElement
|
||||
): number => {
|
||||
const allCheckboxes = container.querySelectorAll('input[type="checkbox"]')
|
||||
return Array.from(allCheckboxes).indexOf(checkbox)
|
||||
@@ -34,7 +35,7 @@ export const useCheckboxCommit = ({
|
||||
initialContent,
|
||||
initialSha,
|
||||
containerSelector,
|
||||
debounceMs = 1000,
|
||||
debounceMs = 1000
|
||||
}: {
|
||||
user: string
|
||||
repo: string
|
||||
@@ -76,7 +77,7 @@ export const useCheckboxCommit = ({
|
||||
const newSha = await updateFile({
|
||||
content: pendingContent.value,
|
||||
path: pathValue,
|
||||
sha: currentSha.value,
|
||||
sha: currentSha.value
|
||||
})
|
||||
|
||||
if (newSha) {
|
||||
@@ -109,7 +110,7 @@ export const useCheckboxCommit = ({
|
||||
pendingContent.value = setCheckboxInMarkdown(
|
||||
pendingContent.value,
|
||||
index,
|
||||
target.checked,
|
||||
target.checked
|
||||
)
|
||||
hasPendingChanges.value = true
|
||||
|
||||
@@ -142,6 +143,6 @@ export const useCheckboxCommit = ({
|
||||
isCommitting,
|
||||
hasPendingChanges,
|
||||
syncContent,
|
||||
listenToCheckboxes,
|
||||
listenToCheckboxes
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { watch } from 'vue'
|
||||
import { watch } from "vue"
|
||||
|
||||
import { backlinkEventBus } from '@/bus/backlinkEventBus'
|
||||
import { data } from '@/data/data'
|
||||
import { DataType } from '@/data/DataType.enum'
|
||||
import { useFile } from '@/hooks/useFile.hook'
|
||||
import { Backlink } from '@/modules/note/models/Backlink'
|
||||
import { BacklinkNote } from '@/modules/note/models/BacklinkNote'
|
||||
import { resolvePath } from '@/modules/repo/services/resolvePath'
|
||||
import { useUserRepoStore } from '@/modules/repo/store/userRepo.store'
|
||||
import { isExternalLink } from '@/utils/link'
|
||||
import { filenameToNoteTitle } from '@/utils/noteTitle'
|
||||
import { confirmMessage } from '@/utils/notif'
|
||||
import { backlinkEventBus } from "@/bus/backlinkEventBus"
|
||||
import { data } from "@/data/data"
|
||||
import { DataType } from "@/data/DataType.enum"
|
||||
import { useFile } from "@/hooks/useFile.hook"
|
||||
import { Backlink } from "@/modules/note/models/Backlink"
|
||||
import { BacklinkNote } from "@/modules/note/models/BacklinkNote"
|
||||
import { resolvePath } from "@/modules/repo/services/resolvePath"
|
||||
import { useUserRepoStore } from "@/modules/repo/store/userRepo.store"
|
||||
import { isExternalLink } from "@/utils/link"
|
||||
import { filenameToNoteTitle } from "@/utils/noteTitle"
|
||||
import { confirmMessage } from "@/utils/notif"
|
||||
|
||||
const isMarkdown = (filename?: string) => filename?.endsWith('.md') ?? false
|
||||
const isMarkdown = (filename?: string) => filename?.endsWith(".md") ?? false
|
||||
|
||||
export const useComputeBacklinks = () => {
|
||||
const store = useUserRepoStore()
|
||||
@@ -51,18 +51,18 @@ export const useComputeBacklinks = () => {
|
||||
}
|
||||
|
||||
const parser = new DOMParser()
|
||||
const htmlDoc = parser.parseFromString(note, 'text/html')
|
||||
const htmlDoc = parser.parseFromString(note, "text/html")
|
||||
|
||||
const links = htmlDoc.querySelectorAll('a')
|
||||
const links = htmlDoc.querySelectorAll("a")
|
||||
|
||||
for (const link of links) {
|
||||
const href = link.getAttribute('href') ?? ''
|
||||
const href = link.getAttribute("href") ?? ""
|
||||
|
||||
if (isExternalLink(href) || !isMarkdown(href)) {
|
||||
continue
|
||||
}
|
||||
|
||||
const path = resolvePath(file.path ?? '', href)
|
||||
const path = resolvePath(file.path ?? "", href)
|
||||
const backlinkFile = store.files.find((file) => file.path === path)
|
||||
|
||||
if (!backlinkFile?.sha || !backlinkFile?.path) {
|
||||
@@ -77,14 +77,14 @@ export const useComputeBacklinks = () => {
|
||||
|
||||
if (!notifiedForComputation) {
|
||||
notifiedForComputation = true
|
||||
confirmMessage('Updating backlinks...')
|
||||
confirmMessage("Updating backlinks...")
|
||||
}
|
||||
|
||||
backlinks.set(backlinkFile.sha, [
|
||||
...previousBacklinks,
|
||||
{
|
||||
sha: file.sha,
|
||||
title: filenameToNoteTitle(file.path ?? '')
|
||||
title: filenameToNoteTitle(file.path ?? "")
|
||||
}
|
||||
])
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { useMagicKeys } from '@vueuse/core'
|
||||
import { ref, watch } from 'vue'
|
||||
import { useMagicKeys } from "@vueuse/core"
|
||||
import { ref, watch } from "vue"
|
||||
|
||||
export const useEditionMode = () => {
|
||||
const mode = ref<'read' | 'edit'>('read')
|
||||
const mode = ref<"read" | "edit">("read")
|
||||
const toggleMode = () => {
|
||||
mode.value = mode.value === 'read' ? 'edit' : 'read'
|
||||
mode.value = mode.value === "read" ? "edit" : "read"
|
||||
}
|
||||
|
||||
const { escape } = useMagicKeys()
|
||||
|
||||
watch(escape, () => {
|
||||
if (mode.value === 'edit') {
|
||||
if (mode.value === "edit") {
|
||||
toggleMode()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -17,18 +17,18 @@ export const useFile = (sha: Ref<string> | string, retrieveContent = true) => {
|
||||
const {
|
||||
render,
|
||||
renderFromUTF8,
|
||||
getRawContent: getRawContentFromFile,
|
||||
getRawContent: getRawContentFromFile
|
||||
} = markdownBuilder(shaValue)
|
||||
|
||||
const { getCachedNote, saveCacheNote } = prepareNoteCache(
|
||||
shaValue,
|
||||
toValue(path),
|
||||
toValue(path)
|
||||
)
|
||||
|
||||
const fromCache = ref(false)
|
||||
const rawContent = ref("")
|
||||
const content = computed(() =>
|
||||
rawContent.value ? renderFromUTF8(rawContent.value) : "",
|
||||
rawContent.value ? renderFromUTF8(rawContent.value) : ""
|
||||
)
|
||||
|
||||
const getEditedSha = async () => {
|
||||
@@ -55,7 +55,7 @@ export const useFile = (sha: Ref<string> | string, retrieveContent = true) => {
|
||||
}
|
||||
saveCacheNote(fileContent)
|
||||
rawContent.value = getRawContentFromFile(fileContent)
|
||||
},
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -111,6 +111,6 @@ export const useFile = (sha: Ref<string> | string, retrieveContent = true) => {
|
||||
getCachedFileContent,
|
||||
getEditedSha,
|
||||
fromCache,
|
||||
saveCacheNote,
|
||||
saveCacheNote
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
import { computedAsync } from "@vueuse/core"
|
||||
import { computed, Ref, ref, watch } from "vue"
|
||||
|
||||
import { Author, getAuthors } from "@/modules/atproto/getAuthor"
|
||||
import { PublicNoteListItem } from "@/modules/note/models/Note"
|
||||
import { computedAsync } from "@vueuse/core"
|
||||
import { computed, ref, Ref, watch } from "vue"
|
||||
|
||||
export function useFollowingNoteList(
|
||||
dids: Ref<Set<string>>,
|
||||
enabled: Ref<boolean>,
|
||||
enabled: Ref<boolean>
|
||||
) {
|
||||
const isLoading = ref(false)
|
||||
const notes = ref<PublicNoteListItem[]>([])
|
||||
const cursor = ref<string | null | undefined>(null)
|
||||
const canLoadMore = computed(
|
||||
() => dids.value.size > 0 && cursor.value !== undefined,
|
||||
() => dids.value.size > 0 && cursor.value !== undefined
|
||||
)
|
||||
|
||||
const onLoadMore = async () => {
|
||||
@@ -22,7 +23,7 @@ export function useFollowingNoteList(
|
||||
|
||||
const body: { dids: string[]; limit: number; cursor?: string } = {
|
||||
dids: [...dids.value],
|
||||
limit: 20,
|
||||
limit: 20
|
||||
}
|
||||
|
||||
if (cursor.value) {
|
||||
@@ -32,7 +33,7 @@ export function useFollowingNoteList(
|
||||
const response = await fetch("https://api.remanso.space/notes/feed", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(body),
|
||||
body: JSON.stringify(body)
|
||||
})
|
||||
|
||||
const data: { notes: PublicNoteListItem[]; cursor?: string } =
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Ref, ref, watch } from 'vue'
|
||||
import { Ref, ref, watch } from "vue"
|
||||
|
||||
import { getFollows } from '@/modules/atproto/service/getFollows'
|
||||
import { getFollows } from "@/modules/atproto/service/getFollows"
|
||||
|
||||
export const useFollows = (did: Ref<string | null>) => {
|
||||
const follows = ref<Set<string>>(new Set())
|
||||
@@ -14,7 +14,7 @@ export const useFollows = (did: Ref<string | null>) => {
|
||||
follows.value = new Set()
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
return { follows }
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ref } from "vue"
|
||||
import { useRouter } from "vue-router"
|
||||
|
||||
export const useForm = () => {
|
||||
const userInput = ref('')
|
||||
const repoInput = ref('')
|
||||
const userInput = ref("")
|
||||
const repoInput = ref("")
|
||||
const { push } = useRouter()
|
||||
|
||||
const submit = () => {
|
||||
@@ -12,7 +12,7 @@ export const useForm = () => {
|
||||
}
|
||||
|
||||
push({
|
||||
name: 'FluxNoteView',
|
||||
name: "FluxNoteView",
|
||||
params: {
|
||||
user: userInput.value,
|
||||
repo: repoInput.value
|
||||
|
||||
@@ -4,7 +4,7 @@ import { confirmMessage, errorMessage } from "@/utils/notif"
|
||||
|
||||
export const useGitHubContent = ({
|
||||
user,
|
||||
repo,
|
||||
repo
|
||||
}: {
|
||||
user: string
|
||||
repo: string
|
||||
@@ -12,7 +12,7 @@ export const useGitHubContent = ({
|
||||
const putFile = async ({
|
||||
content,
|
||||
path,
|
||||
sha,
|
||||
sha
|
||||
}: {
|
||||
content: string
|
||||
path: string
|
||||
@@ -29,8 +29,8 @@ export const useGitHubContent = ({
|
||||
path,
|
||||
message: `Updating ${path} from Remanso`,
|
||||
content: encodeUTF8ToBase64(content),
|
||||
sha,
|
||||
},
|
||||
sha
|
||||
}
|
||||
)
|
||||
|
||||
confirmMessage("✅ Note saved")
|
||||
@@ -48,6 +48,6 @@ export const useGitHubContent = ({
|
||||
updateFile: async (props: { content: string; path: string; sha: string }) =>
|
||||
putFile(props),
|
||||
createFile: async (props: { content: string; path: string }) =>
|
||||
putFile(props),
|
||||
putFile(props)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { computed, ref } from 'vue'
|
||||
import { computed, ref } from "vue"
|
||||
|
||||
import { GithubToken } from '@/modules/user/interfaces/GithubToken'
|
||||
import { getAccessToken, saveAccessToken } from '@/modules/user/service/signIn'
|
||||
import { confirmMessage } from '@/utils/notif'
|
||||
import { GithubToken } from "@/modules/user/interfaces/GithubToken"
|
||||
import { getAccessToken, saveAccessToken } from "@/modules/user/service/signIn"
|
||||
import { confirmMessage } from "@/utils/notif"
|
||||
|
||||
const username = ref<string | null>(null)
|
||||
const accessToken = ref<string | null>(null)
|
||||
@@ -11,8 +11,8 @@ let init = true
|
||||
|
||||
const saveAccessTokenToLocal = async () => {
|
||||
const response = await getAccessToken()
|
||||
username.value = response?.username || ''
|
||||
accessToken.value = response?.token || ''
|
||||
username.value = response?.username || ""
|
||||
accessToken.value = response?.token || ""
|
||||
}
|
||||
|
||||
const saveCredentials = async (token: GithubToken): Promise<void> => {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { computed, watch } from 'vue'
|
||||
import { computed, watch } from "vue"
|
||||
|
||||
import { useFile } from '@/hooks/useFile.hook'
|
||||
import { resolvePath } from '@/modules/repo/services/resolvePath'
|
||||
import { useUserRepoStore } from '@/modules/repo/store/userRepo.store'
|
||||
import { useFile } from "@/hooks/useFile.hook"
|
||||
import { resolvePath } from "@/modules/repo/services/resolvePath"
|
||||
import { useUserRepoStore } from "@/modules/repo/store/userRepo.store"
|
||||
|
||||
const SRC_PREFIX = 'data:image/jpeg;charset=utf-8;base64,'
|
||||
const SRC_PREFIX = "data:image/jpeg;charset=utf-8;base64,"
|
||||
|
||||
export const useImages = (sha: string) => {
|
||||
const store = useUserRepoStore()
|
||||
@@ -23,14 +23,14 @@ export const useImages = (sha: string) => {
|
||||
const images = document.querySelectorAll(`.note-${sha} img`)
|
||||
|
||||
images.forEach(async (image) => {
|
||||
const src = image.getAttribute('src')
|
||||
const src = image.getAttribute("src")
|
||||
if (!src || src.startsWith(SRC_PREFIX)) {
|
||||
return
|
||||
}
|
||||
|
||||
const imageFilePath = resolvePath(
|
||||
filePath,
|
||||
image.getAttribute('src') ?? ''
|
||||
image.getAttribute("src") ?? ""
|
||||
)
|
||||
|
||||
const imageFile = store.files.find(
|
||||
@@ -43,7 +43,7 @@ export const useImages = (sha: string) => {
|
||||
const { getCachedFileContent } = useFile(imageFile.sha, false)
|
||||
|
||||
const fileContent = await getCachedFileContent()
|
||||
image.setAttribute('src', `${SRC_PREFIX} ${fileContent}`)
|
||||
image.setAttribute("src", `${SRC_PREFIX} ${fileContent}`)
|
||||
})
|
||||
},
|
||||
{ immediate: true }
|
||||
|
||||
@@ -6,7 +6,7 @@ import { isExternalLink } from "@/utils/link"
|
||||
|
||||
export const useLinks = (
|
||||
className: ComputedRef<string> | string,
|
||||
sha?: Ref<string> | string,
|
||||
sha?: Ref<string> | string
|
||||
) => {
|
||||
const store = useUserRepoStore()
|
||||
|
||||
@@ -34,7 +34,7 @@ export const useLinks = (
|
||||
path: href,
|
||||
currentNoteSHA: toValue(sha),
|
||||
user: store.user,
|
||||
repo: store.repo,
|
||||
repo: store.repo
|
||||
})
|
||||
}
|
||||
|
||||
@@ -74,6 +74,6 @@ export const useLinks = (
|
||||
})
|
||||
|
||||
return {
|
||||
listenToClick,
|
||||
listenToClick
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import markdownItKatex from "@vscode/markdown-it-katex"
|
||||
import MarkdownIt, { Options } from "markdown-it"
|
||||
import Renderer, { type RenderRuleRecord } from "markdown-it/lib/renderer.mjs"
|
||||
import type Token from "markdown-it/lib/token.mjs"
|
||||
import blockEmbedPlugin from "markdown-it-block-embed"
|
||||
import markdownItCheckbox from "markdown-it-checkbox"
|
||||
import MarkdownItGitHubAlerts from "markdown-it-github-alerts"
|
||||
import markdownItIframe from "markdown-it-iframe"
|
||||
import Shikiji from "markdown-it-shikiji"
|
||||
import mermaid from "mermaid"
|
||||
import { Ref, toValue } from "vue"
|
||||
|
||||
import { decodeBase64ToUTF8 } from "@/utils/decodeBase64ToUTF8"
|
||||
import { html5Media } from "@/utils/markdown/markdown-html5-media"
|
||||
import { markdownItTablerIcons } from "@/utils/markdown/markdown-it-tabler-icons"
|
||||
import mermaid from "mermaid"
|
||||
import type Token from "markdown-it/lib/token.mjs"
|
||||
import Renderer, { type RenderRuleRecord } from "markdown-it/lib/renderer.mjs"
|
||||
|
||||
const markdownItMermaidExtractor = (md: MarkdownIt) => {
|
||||
const defaultFence =
|
||||
@@ -22,7 +22,7 @@ const markdownItMermaidExtractor = (md: MarkdownIt) => {
|
||||
index: number,
|
||||
options: Options,
|
||||
_: unknown,
|
||||
self: Renderer,
|
||||
self: Renderer
|
||||
) {
|
||||
return self.renderToken(tokens, index, options)
|
||||
}
|
||||
@@ -32,7 +32,7 @@ const markdownItMermaidExtractor = (md: MarkdownIt) => {
|
||||
index: number,
|
||||
options: Options,
|
||||
env: unknown,
|
||||
self: Renderer,
|
||||
self: Renderer
|
||||
) {
|
||||
const token = tokens[index]
|
||||
|
||||
@@ -47,20 +47,20 @@ const markdownItMermaidExtractor = (md: MarkdownIt) => {
|
||||
|
||||
const md = new MarkdownIt({
|
||||
typographer: true,
|
||||
quotes: ["«\xA0", "\xA0»", "‹\xA0", "\xA0›"],
|
||||
quotes: ["«\xA0", "\xA0»", "‹\xA0", "\xA0›"]
|
||||
})
|
||||
.use(markdownItMermaidExtractor)
|
||||
.use(html5Media)
|
||||
.use(blockEmbedPlugin, {
|
||||
youtube: {
|
||||
width: "100%",
|
||||
height: 300,
|
||||
},
|
||||
height: 300
|
||||
}
|
||||
})
|
||||
.use(markdownItCheckbox)
|
||||
.use(markdownItKatex)
|
||||
.use(markdownItIframe, {
|
||||
width: "100%",
|
||||
width: "100%"
|
||||
})
|
||||
.use(MarkdownItGitHubAlerts)
|
||||
.use(markdownItTablerIcons)
|
||||
@@ -77,7 +77,7 @@ export const useShikiji = async () => {
|
||||
await Shikiji({
|
||||
themes: {
|
||||
light: "vitesse-light",
|
||||
dark: "vitesse-black",
|
||||
dark: "vitesse-black"
|
||||
},
|
||||
langs: [
|
||||
"bash",
|
||||
@@ -87,9 +87,9 @@ export const useShikiji = async () => {
|
||||
"mermaid",
|
||||
"html",
|
||||
"css",
|
||||
"json",
|
||||
],
|
||||
}),
|
||||
"json"
|
||||
]
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
@@ -101,19 +101,19 @@ export const runMermaid = (querySelector: string) => {
|
||||
mermaid.initialize({
|
||||
theme: "dark",
|
||||
startOnLoad: false,
|
||||
flowchart: { curve: "natural" },
|
||||
flowchart: { curve: "natural" }
|
||||
})
|
||||
}
|
||||
|
||||
mermaid.run({
|
||||
querySelector,
|
||||
querySelector
|
||||
})
|
||||
}
|
||||
|
||||
const rules: RenderRuleRecord = {
|
||||
table_open: () =>
|
||||
'<div class="overflow-x-auto"><table class="table table-zebra">',
|
||||
table_close: () => "</table></div>",
|
||||
table_close: () => "</table></div>"
|
||||
}
|
||||
|
||||
md.renderer.rules = { ...md.renderer.rules, ...rules }
|
||||
@@ -128,7 +128,7 @@ export const markdownBuilder = (defaultPrefix?: Ref<string> | string) => {
|
||||
const renderFromUTF8 = (content: string, prefix?: string) => {
|
||||
return content
|
||||
? md.render(stripFrontmatter(content), {
|
||||
docId: defaultPrefix ? toValue(defaultPrefix) : (prefix ?? ""),
|
||||
docId: defaultPrefix ? toValue(defaultPrefix) : (prefix ?? "")
|
||||
})
|
||||
: ""
|
||||
}
|
||||
@@ -139,6 +139,6 @@ export const markdownBuilder = (defaultPrefix?: Ref<string> | string) => {
|
||||
render: (content: string, prefix?: string) =>
|
||||
renderFromUTF8(decodeBase64ToUTF8(content), prefix),
|
||||
renderFromUTF8,
|
||||
getRawContent,
|
||||
getRawContent
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
import { computed, onMounted, Ref, ref, toValue } from "vue"
|
||||
|
||||
import { BOOKMARK_WIDTH_REM, getBookmarkWidthPx } from "@/constants/bookmark-width"
|
||||
import {
|
||||
BOOKMARK_WIDTH_REM,
|
||||
getBookmarkWidthPx
|
||||
} from "@/constants/bookmark-width"
|
||||
import { getNoteWidth } from "@/constants/note-width"
|
||||
import { useOverlay } from "@/hooks/useOverlay.hook"
|
||||
import { useRouteQueryStackedNotes } from "@/hooks/useRouteQueryStackedNotes.hook"
|
||||
|
||||
export const useNoteOverlay = (
|
||||
className: string,
|
||||
index: Ref<number> | number,
|
||||
index: Ref<number> | number
|
||||
) => {
|
||||
const { x, y, isMobile } = useOverlay()
|
||||
const noteHeight = ref(0)
|
||||
@@ -18,14 +21,17 @@ export const useNoteOverlay = (
|
||||
if (isMobile.value) {
|
||||
return y.value > valueIndex * noteHeight.value
|
||||
} else {
|
||||
return x.value > valueIndex * getNoteWidth() - valueIndex * getBookmarkWidthPx()
|
||||
return (
|
||||
x.value >
|
||||
valueIndex * getNoteWidth() - valueIndex * getBookmarkWidthPx()
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
const { stackedNotes } = useRouteQueryStackedNotes()
|
||||
const noteElement = document.querySelector(
|
||||
`.${className}`,
|
||||
`.${className}`
|
||||
) satisfies HTMLElement | null
|
||||
|
||||
if (!noteElement) {
|
||||
@@ -40,7 +46,7 @@ export const useNoteOverlay = (
|
||||
noteElement.style.left = `${(toValue(index) + 1) * BOOKMARK_WIDTH_REM}rem`
|
||||
|
||||
const stackedNoteContainers = document.querySelectorAll(
|
||||
".stacked-note",
|
||||
".stacked-note"
|
||||
) satisfies NodeListOf<HTMLElement>
|
||||
|
||||
stackedNoteContainers.forEach((stackedNote, ind) => {
|
||||
@@ -52,6 +58,6 @@ export const useNoteOverlay = (
|
||||
})
|
||||
|
||||
return {
|
||||
displayNoteOverlay,
|
||||
displayNoteOverlay
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,13 +21,13 @@ export const useNoteView = () => {
|
||||
obj[note] = pathToNotePathTitle(filePath)
|
||||
|
||||
return obj
|
||||
}, {}),
|
||||
}, {})
|
||||
)
|
||||
|
||||
const unsubscribeLink = noteEventBus.addEventBusListener(
|
||||
({ path, currentNoteSHA }) => {
|
||||
const currentFile = store.files.find(
|
||||
(file) => file.sha === currentNoteSHA,
|
||||
(file) => file.sha === currentNoteSHA
|
||||
)
|
||||
|
||||
const absolutePath = resolvePath(currentFile?.path ?? "", path)
|
||||
@@ -39,7 +39,7 @@ export const useNoteView = () => {
|
||||
}
|
||||
|
||||
addStackedNote(currentNoteSHA ?? "", file.sha)
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
onUnmounted(() => {
|
||||
@@ -47,6 +47,6 @@ export const useNoteView = () => {
|
||||
})
|
||||
|
||||
return {
|
||||
titles,
|
||||
titles
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { useAsyncState } from '@vueuse/core'
|
||||
import { computed, ref } from 'vue'
|
||||
import { useAsyncState } from "@vueuse/core"
|
||||
import { computed, ref } from "vue"
|
||||
|
||||
import { data } from '@/data/data'
|
||||
import { DataType } from '@/data/DataType.enum'
|
||||
import { prepareNoteCache } from '@/modules/note/cache/prepareNoteCache'
|
||||
import { Note } from '@/modules/note/models/Note'
|
||||
import { queryFileContent } from '@/modules/repo/services/repo'
|
||||
import { useUserRepoStore } from '@/modules/repo/store/userRepo.store'
|
||||
import { data } from "@/data/data"
|
||||
import { DataType } from "@/data/DataType.enum"
|
||||
import { prepareNoteCache } from "@/modules/note/cache/prepareNoteCache"
|
||||
import { Note } from "@/modules/note/models/Note"
|
||||
import { queryFileContent } from "@/modules/repo/services/repo"
|
||||
import { useUserRepoStore } from "@/modules/repo/store/userRepo.store"
|
||||
|
||||
export const useOfflineNotes = () => {
|
||||
const store = useUserRepoStore()
|
||||
|
||||
@@ -19,11 +19,11 @@ export const useOverlay = (listen = true) => {
|
||||
}
|
||||
useEventListener(window, "scroll", updateScroll, {
|
||||
passive: true,
|
||||
capture: false,
|
||||
capture: false
|
||||
})
|
||||
useEventListener(document.body, "scroll", updateScroll, {
|
||||
passive: true,
|
||||
capture: false,
|
||||
capture: false
|
||||
})
|
||||
}
|
||||
|
||||
@@ -47,6 +47,6 @@ export const useOverlay = (listen = true) => {
|
||||
x,
|
||||
y,
|
||||
isMobile,
|
||||
scrollToNote,
|
||||
scrollToNote
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { computedAsync } from "@vueuse/core"
|
||||
import { computed, Ref, ref } from "vue"
|
||||
|
||||
import { Author, getAuthors } from "@/modules/atproto/getAuthor"
|
||||
import { PublicNoteListItem } from "@/modules/note/models/Note"
|
||||
import { computedAsync } from "@vueuse/core"
|
||||
import { computed, ref, Ref } from "vue"
|
||||
|
||||
interface UsePublicNoteListOptions {
|
||||
did?: Ref<string | undefined>
|
||||
@@ -50,6 +51,6 @@ export function usePublicNoteList(options?: UsePublicNoteListOptions) {
|
||||
canLoadMore,
|
||||
onLoadMore,
|
||||
authors,
|
||||
getAuthor,
|
||||
getAuthor
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useAsyncState } from '@vueuse/core'
|
||||
import { useAsyncState } from "@vueuse/core"
|
||||
|
||||
import { useGitHubLogin } from '@/hooks/useGitHubLogin.hook'
|
||||
import { RepoBase } from '@/modules/repo/interfaces/RepoBase'
|
||||
import { getOctokit } from '@/modules/repo/services/octo'
|
||||
import { useGitHubLogin } from "@/hooks/useGitHubLogin.hook"
|
||||
import { RepoBase } from "@/modules/repo/interfaces/RepoBase"
|
||||
import { getOctokit } from "@/modules/repo/services/octo"
|
||||
|
||||
export const useRepos = () => {
|
||||
const { username, accessToken } = useGitHubLogin()
|
||||
@@ -13,7 +13,7 @@ export const useRepos = () => {
|
||||
|
||||
const octokit = await getOctokit()
|
||||
|
||||
const repoList = await octokit.request('GET /search/repositories', {
|
||||
const repoList = await octokit.request("GET /search/repositories", {
|
||||
q: `user:${username.value}`,
|
||||
per_page: 100
|
||||
})
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { onMounted, watch, type Ref } from "vue"
|
||||
import { onMounted, type Ref, watch } from "vue"
|
||||
|
||||
import { getNoteWidth } from "@/constants/note-width"
|
||||
import { useOverlay } from "@/hooks/useOverlay.hook"
|
||||
|
||||
export const useResizeContainer = (
|
||||
containerClass: string,
|
||||
stackedNotes: Readonly<Ref<readonly string[]>>,
|
||||
stackedNotes: Readonly<Ref<readonly string[]>>
|
||||
) => {
|
||||
const { isMobile } = useOverlay(false)
|
||||
|
||||
const resizeContainer = () => {
|
||||
const container = document.querySelector(
|
||||
`.${containerClass}`,
|
||||
`.${containerClass}`
|
||||
) as HTMLElement | null
|
||||
|
||||
if (!container) {
|
||||
@@ -32,6 +32,6 @@ export const useResizeContainer = (
|
||||
})
|
||||
|
||||
watch(stackedNotes, resizeContainer, {
|
||||
immediate: true,
|
||||
immediate: true
|
||||
})
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ export const useRouteQueryStackedNotes = () => {
|
||||
}
|
||||
|
||||
return Array.isArray(value) ? value : [value]
|
||||
},
|
||||
}
|
||||
})
|
||||
const { height } = useWindowSize()
|
||||
|
||||
@@ -22,7 +22,7 @@ export const useRouteQueryStackedNotes = () => {
|
||||
|
||||
const scrollToFocusedNote = (
|
||||
noteId: string | null = null,
|
||||
notes: string[] = stackedNotes.value,
|
||||
notes: string[] = stackedNotes.value
|
||||
) => {
|
||||
nextTick(() => {
|
||||
const index = noteId ? notes.findIndex((nid) => nid === noteId) : 0
|
||||
@@ -31,7 +31,7 @@ export const useRouteQueryStackedNotes = () => {
|
||||
if (noteId) {
|
||||
const cleanNoteId = noteId.replaceAll(":", "-")
|
||||
const element = document.querySelector(
|
||||
`.note-${cleanNoteId}`,
|
||||
`.note-${cleanNoteId}`
|
||||
) as HTMLElement
|
||||
|
||||
const top = (index + 1) * (element?.clientHeight ?? height.value)
|
||||
@@ -53,7 +53,7 @@ export const useRouteQueryStackedNotes = () => {
|
||||
const addStackedNote = (
|
||||
currentSha: string,
|
||||
sha: string,
|
||||
selector?: string,
|
||||
selector?: string
|
||||
) => {
|
||||
if (stackedNotes.value.includes(sha)) {
|
||||
scrollToFocusedNote(selector ?? sha)
|
||||
@@ -70,7 +70,7 @@ export const useRouteQueryStackedNotes = () => {
|
||||
const newStackedNotes = [
|
||||
...splittedStackedNotes.replaceAll(";;", ";").split(";"),
|
||||
currentSha,
|
||||
sha,
|
||||
sha
|
||||
].filter((sha) => !!sha)
|
||||
|
||||
stackedNotes.value = newStackedNotes
|
||||
@@ -82,6 +82,6 @@ export const useRouteQueryStackedNotes = () => {
|
||||
return {
|
||||
stackedNotes: readonly(stackedNotes),
|
||||
addStackedNote,
|
||||
scrollToFocusedNote,
|
||||
scrollToFocusedNote
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import { useTitle } from '@vueuse/core'
|
||||
import { computed, Ref, toValue, watch } from 'vue'
|
||||
import { useTitle } from "@vueuse/core"
|
||||
import { computed, Ref, toValue, watch } from "vue"
|
||||
|
||||
import { useRouteQueryStackedNotes } from '@/hooks/useRouteQueryStackedNotes.hook'
|
||||
import { useNotes } from '@/modules/note/hooks/useNotes'
|
||||
import { pathToNoteTitle } from '@/utils/noteTitle'
|
||||
import { useRouteQueryStackedNotes } from "@/hooks/useRouteQueryStackedNotes.hook"
|
||||
import { useNotes } from "@/modules/note/hooks/useNotes"
|
||||
import { pathToNoteTitle } from "@/utils/noteTitle"
|
||||
|
||||
export const generateTitle = (titles: string[]) => titles.join(' | ')
|
||||
export const generateTitle = (titles: string[]) => titles.join(" | ")
|
||||
|
||||
export const useTitleNotes = (prefix: Ref<string> | string) => {
|
||||
const { stackedNotes } = useRouteQueryStackedNotes()
|
||||
const { notes } = useNotes()
|
||||
const titleNotes = computed(() =>
|
||||
notes.value
|
||||
.filter((note) => stackedNotes.value.includes(note.sha ?? ''))
|
||||
.map((note) => pathToNoteTitle(note.path ?? ''))
|
||||
.filter((note) => stackedNotes.value.includes(note.sha ?? ""))
|
||||
.map((note) => pathToNoteTitle(note.path ?? ""))
|
||||
)
|
||||
|
||||
const title = useTitle(generateTitle([toValue(prefix), ...titleNotes.value]))
|
||||
|
||||
Reference in New Issue
Block a user