@type32/codemirror-rich-obsidian-editor 0.0.11 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.json +1 -1
- package/dist/runtime/assets/css/editor.css +1 -1
- package/dist/runtime/components/Editor/ImageEmbedComponent.vue +5 -3
- package/dist/runtime/components/Editor/ImageEmbedComponent.vue.d.ts +1 -0
- package/dist/runtime/components/Editor.client.vue +1 -1
- package/dist/runtime/composables/useEditorFrontmatter.d.ts +11 -0
- package/dist/runtime/composables/useEditorFrontmatter.js +78 -0
- package/dist/runtime/editor/plugins/codemirror-plugin-proses/proseInternalLinkCodemirrorViewPlugin.js +3 -0
- package/dist/runtime/editor/plugins/codemirror-plugin-proses/proseLinkCodemirrorViewPlugin.js +2 -1
- package/dist/runtime/editor/plugins/lezerStylesHighlightingPlugin.js +1 -0
- package/dist/runtime/editor/types/editor-types.d.ts +18 -0
- package/dist/runtime/utils/frontmatter.d.ts +3 -2
- package/dist/runtime/utils/frontmatter.js +17 -11
- package/dist/runtime/utils/internalLinks.d.ts +2 -0
- package/dist/runtime/utils/internalLinks.js +32 -0
- package/package.json +4 -4
package/dist/module.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@import url("https://fonts.cdnfonts.com/css/segoe-ui-variable-static-display");@import url("https://fonts.cdnfonts.com/css/sf-pro-display");@import "katex/dist/katex.min.css";@import "tailwindcss";@import "@nuxt/ui";@theme{--font-sans:"Public Sans","Inter","SF Pro Display","Segoe UI Variable Static Display",sans-serif;--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--font-editor:"Inter","SF Pro Display","Segoe UI Variable Static Display",var(--font-sans,sans-serif);--font-editor-code:"Google Sans Code","JetBrains Mono","Consolas",var(--font-mono,ui-monospace);--list-indent:1.5rem;--indent-level:0}.cm-content{@apply font-editor}.cm-content .cm-meta{@apply text-dimmed! no-underline!}.cm-content .cm-heading{text-decoration:none!important}.cm-content .cm-mono{@apply font-editor-code bg-muted px-1 rounded-lg border border-default text-toned!}.cm-content .cm-hashtag{@apply bg-primary/20! ring ring-primary/70! px-1.5 text-sm rounded-4xl text-primary! inline-flex}.cm-content .cm-hashtag .cm-heading{@apply text-primary!}.cm-content .cm-highlighted{@apply bg-primary/20 text-primary px-0.5 rounded-sm}.cm-content .cm-internal-link-display,.cm-content .cm-internal-link-path,.cm-content .cm-internal-link-subpath,.cm-content .cm-link{@apply text-primary! underline}.cm-content .cm-internal-link-display[data-type=internal-link],.cm-content .cm-internal-link-path[data-type=internal-link],.cm-content .cm-internal-link-subpath[data-type=internal-link],.cm-content .cm-link[data-type=internal-link]{@apply cursor-pointer}.cm-content .cm-clickable-link{@apply cursor-pointer}.cm-content .cm-unresolved-link .cm-internal-link-display,.cm-content .cm-unresolved-link .cm-internal-link-path,.cm-content .cm-unresolved-link .cm-internal-link-subpath,.cm-content .cm-unresolved-link .cm-link{@apply text-error/75! cursor-not-allowed}.cm-content .cm-codeblock,.cm-content .cm-line-codeblock-begin,.cm-content .cm-line-codeblock-end{@apply font-editor-code py-0 my-0 text-sm! font-semibold border-x border-x-default mx-2 px-3 bg-muted relative}.cm-content .cm-codeblock .cm-codeblock-flair-container,.cm-content .cm-line-codeblock-begin .cm-codeblock-flair-container,.cm-content .cm-line-codeblock-end .cm-codeblock-flair-container{@apply absolute top-2 right-2 overflow-visible z-10}.cm-content .cm-codeblock .cm-codeblock-flair-container .cm-codeblock-copy-button,.cm-content .cm-line-codeblock-begin .cm-codeblock-flair-container .cm-codeblock-copy-button,.cm-content .cm-line-codeblock-end .cm-codeblock-flair-container .cm-codeblock-copy-button{@apply rounded hover:bg-accented transition duration-200 cursor-pointer py-1.5 px-2 font-sans text-dimmed z-10}.cm-content .cm-codeblock .cm-mono,.cm-content .cm-line-codeblock-begin .cm-mono,.cm-content .cm-line-codeblock-end .cm-mono{@apply border-none bg-none text-default}.cm-content .cm-line-codeblock-content{@apply border-x border-x-accented}.cm-content .cm-line-codeblock-begin{@apply rounded-t-lg border-t border-x border-t-accented border-x-accented pt-1 px-1}.cm-content .cm-line-codeblock-end{@apply rounded-b-lg border-b border-x border-b-accented border-x-accented pb-1 px-1}.cm-content .cm-task-checkbox-wrapper{@apply size-4 mb-0.5 rounded-xl border border-default bg-default inline-flex items-center justify-center align-middle cursor-pointer}.cm-content .cm-task-checkbox-wrapper[data-checked=true]{@apply bg-primary border border-primary}.cm-content .cm-task-checkbox-wrapper[data-checked=true]:before{content:"✔";@apply text-xs text-inverted}.cm-content .cm-task-checkbox-wrapper[data-special]{@apply font-editor-code text-xs text-highlighted}.cm-content .cm-task-checked{@apply line-through text-dimmed}.cm-content .cm-tooltip{@apply rounded-lg bg-default/70 shadow-lg backdrop-blur-sm border border-default font-sans p-2}.cm-content .cm-tooltip ul{@apply grid grid-cols-1 font-sans}.cm-content .cm-tooltip ul li{@apply grid grid-cols-1 rounded font-sans gap-1}.cm-content .cm-tooltip ul li .cm-completionLabel{@apply mx-1 mt-1 text-toned}.cm-content .cm-tooltip ul li .cm-completionDetail{@apply text-xs font-editor-code bg-elevated w-fit rounded text-muted px-1 mb-1}.cm-content .cm-tooltip ul li[aria-selected=true]{@apply bg-accented/70 backdrop-blur-sm border border-accented}.cm-content .cm-fold-widget{@apply absolute -left-0.5 pt-1}.cm-content .cm-gutter,.cm-content .cm-gutters{@apply bg-transparent! border-none}.cm-content .cm-foldPlaceholder{@apply bg-accented! text-dimmed! border border-none ml-0.5 h-fit inline-flex items-center justify-center align-middle}.cm-content .cm-gutterElement{@apply inline-flex justify-center items-center}.cm-content .cm-heading-1{@apply text-4xl! text-highlighted scroll-mt-[calc(45px+var(--ui-header-height))]}.cm-content .cm-heading-2{@apply text-2xl! text-highlighted scroll-mt-[calc(45px+var(--ui-header-height))]}.cm-content .cm-heading-3{@apply text-xl! text-highlighted scroll-mt-[calc(45px+var(--ui-header-height))]}.cm-content .cm-heading-4{@apply text-lg! text-highlighted scroll-mt-[calc(45px+var(--ui-header-height))]}.cm-content .cm-quoteblock,.cm-content blockquote{@apply border-l-6 bg-muted border-accented ps-2 mx-2}.cm-content .cm-quoteblock.cm-quoteblock-single,.cm-content blockquote.cm-quoteblock-single{@apply rounded py-2}.cm-content .cm-quoteblock.cm-quoteblock-start,.cm-content blockquote.cm-quoteblock-start{@apply rounded-t pt-2}.cm-content .cm-quoteblock.cm-quoteblock-end,.cm-content blockquote.cm-quoteblock-end{@apply rounded-b pb-2}.cm-content .cm-quoteblock .cm-formatting-quote.cm-meta,.cm-content blockquote .cm-formatting-quote.cm-meta{@apply invisible}.cm-content .cm-quoteblock .cm-formatting-quote-active.cm-meta,.cm-content blockquote .cm-formatting-quote-active.cm-meta{@apply visible!}.cm-content .cm-obsidian-bullet{@apply text-transparent}.cm-content .cm-obsidian-bullet .cm-meta{@apply invisible}.cm-content .cm-obsidian-bullet:before{content:"•";@apply text-dimmed absolute}.cm-content .callout,.cm-content .cm-callout-widget{@apply p-3 relative flex flex-col h-fit mx-2 my-2 rounded-lg border border-primary/20 bg-primary/20}.cm-content .callout summary,.cm-content .cm-callout-widget summary{@apply inline-flex}.cm-content .callout .callout-title,.cm-content .cm-callout-widget .callout-title{@apply flex gap-1.5 items-center}.cm-content .callout .callout-title .callout-title-icon,.cm-content .cm-callout-widget .callout-title .callout-title-icon{@apply flex size-4 items-center justify-center fill-primary text-primary}.cm-content .callout .callout-title .callout-title-inner,.cm-content .cm-callout-widget .callout-title .callout-title-inner{@apply text-primary text-lg font-bold flex-grow}.cm-content .callout .callout-title .edit-block-button,.cm-content .cm-callout-widget .callout-title .edit-block-button{@apply rounded hover:bg-elevated transition duration-200 cursor-pointer p-1 font-sans right-0 top-0 text-dimmed}.cm-content .callout .callout-content,.cm-content .cm-callout-widget .callout-content{@apply flex flex-col gap-1}.cm-content .callout[data-callout=info],.cm-content .cm-callout-widget[data-callout=info]{@apply bg-info/20 border-info/20}.cm-content .callout[data-callout=info] .callout-fold,.cm-content .cm-callout-widget[data-callout=info] .callout-fold{@apply text-info-400}.cm-content .callout[data-callout=info] .callout-title .callout-title-icon,.cm-content .callout[data-callout=info] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=info] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=info] .callout-title .callout-title-inner{@apply text-info}.cm-content .callout[data-callout=check],.cm-content .callout[data-callout=done],.cm-content .callout[data-callout=success],.cm-content .cm-callout-widget[data-callout=check],.cm-content .cm-callout-widget[data-callout=done],.cm-content .cm-callout-widget[data-callout=success]{@apply bg-success/20 border-success/20}.cm-content .callout[data-callout=check] .callout-fold,.cm-content .callout[data-callout=done] .callout-fold,.cm-content .callout[data-callout=success] .callout-fold,.cm-content .cm-callout-widget[data-callout=check] .callout-fold,.cm-content .cm-callout-widget[data-callout=done] .callout-fold,.cm-content .cm-callout-widget[data-callout=success] .callout-fold{@apply text-success-400}.cm-content .callout[data-callout=check] .callout-title .callout-title-icon,.cm-content .callout[data-callout=check] .callout-title .callout-title-inner,.cm-content .callout[data-callout=done] .callout-title .callout-title-icon,.cm-content .callout[data-callout=done] .callout-title .callout-title-inner,.cm-content .callout[data-callout=success] .callout-title .callout-title-icon,.cm-content .callout[data-callout=success] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=check] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=check] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=done] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=done] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=success] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=success] .callout-title .callout-title-inner{@apply text-success}.cm-content .callout[data-callout=faq],.cm-content .callout[data-callout=help],.cm-content .callout[data-callout=question],.cm-content .callout[data-callout=warning],.cm-content .cm-callout-widget[data-callout=faq],.cm-content .cm-callout-widget[data-callout=help],.cm-content .cm-callout-widget[data-callout=question],.cm-content .cm-callout-widget[data-callout=warning]{@apply bg-warning/20 border-warning/20}.cm-content .callout[data-callout=faq] .callout-fold,.cm-content .callout[data-callout=help] .callout-fold,.cm-content .callout[data-callout=question] .callout-fold,.cm-content .callout[data-callout=warning] .callout-fold,.cm-content .cm-callout-widget[data-callout=faq] .callout-fold,.cm-content .cm-callout-widget[data-callout=help] .callout-fold,.cm-content .cm-callout-widget[data-callout=question] .callout-fold,.cm-content .cm-callout-widget[data-callout=warning] .callout-fold{@apply text-warning-400}.cm-content .callout[data-callout=faq] .callout-title .callout-title-icon,.cm-content .callout[data-callout=faq] .callout-title .callout-title-inner,.cm-content .callout[data-callout=help] .callout-title .callout-title-icon,.cm-content .callout[data-callout=help] .callout-title .callout-title-inner,.cm-content .callout[data-callout=question] .callout-title .callout-title-icon,.cm-content .callout[data-callout=question] .callout-title .callout-title-inner,.cm-content .callout[data-callout=warning] .callout-title .callout-title-icon,.cm-content .callout[data-callout=warning] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=faq] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=faq] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=help] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=help] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=question] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=question] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=warning] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=warning] .callout-title .callout-title-inner{@apply text-warning}.cm-content .callout[data-callout=bug],.cm-content .callout[data-callout=error],.cm-content .callout[data-callout=failure],.cm-content .cm-callout-widget[data-callout=bug],.cm-content .cm-callout-widget[data-callout=error],.cm-content .cm-callout-widget[data-callout=failure]{@apply bg-error/20 border-error/20}.cm-content .callout[data-callout=bug] .callout-fold,.cm-content .callout[data-callout=error] .callout-fold,.cm-content .callout[data-callout=failure] .callout-fold,.cm-content .cm-callout-widget[data-callout=bug] .callout-fold,.cm-content .cm-callout-widget[data-callout=error] .callout-fold,.cm-content .cm-callout-widget[data-callout=failure] .callout-fold{@apply text-error-400}.cm-content .callout[data-callout=bug] .callout-title .callout-title-icon,.cm-content .callout[data-callout=bug] .callout-title .callout-title-inner,.cm-content .callout[data-callout=error] .callout-title .callout-title-icon,.cm-content .callout[data-callout=error] .callout-title .callout-title-inner,.cm-content .callout[data-callout=failure] .callout-title .callout-title-icon,.cm-content .callout[data-callout=failure] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=bug] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=bug] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=error] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=error] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=failure] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=failure] .callout-title .callout-title-inner{@apply text-error}.cm-content .callout[data-callout=example],.cm-content .callout[data-callout=highlight],.cm-content .callout[data-callout=tip],.cm-content .cm-callout-widget[data-callout=example],.cm-content .cm-callout-widget[data-callout=highlight],.cm-content .cm-callout-widget[data-callout=tip]{@apply bg-secondary/20 border-secondary/20}.cm-content .callout[data-callout=example] .callout-fold,.cm-content .callout[data-callout=highlight] .callout-fold,.cm-content .callout[data-callout=tip] .callout-fold,.cm-content .cm-callout-widget[data-callout=example] .callout-fold,.cm-content .cm-callout-widget[data-callout=highlight] .callout-fold,.cm-content .cm-callout-widget[data-callout=tip] .callout-fold{@apply text-secondary}.cm-content .callout[data-callout=example] .callout-title .callout-title-icon,.cm-content .callout[data-callout=example] .callout-title .callout-title-inner,.cm-content .callout[data-callout=highlight] .callout-title .callout-title-icon,.cm-content .callout[data-callout=highlight] .callout-title .callout-title-inner,.cm-content .callout[data-callout=tip] .callout-title .callout-title-icon,.cm-content .callout[data-callout=tip] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=example] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=example] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=highlight] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=highlight] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=tip] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=tip] .callout-title .callout-title-inner{@apply text-secondary}.cm-content .callout[data-callout=neutral],.cm-content .callout[data-callout=quote],.cm-content .cm-callout-widget[data-callout=neutral],.cm-content .cm-callout-widget[data-callout=quote]{@apply bg-accented/30 border-accented/30}.cm-content .callout[data-callout=neutral] .callout-fold,.cm-content .callout[data-callout=quote] .callout-fold,.cm-content .cm-callout-widget[data-callout=neutral] .callout-fold,.cm-content .cm-callout-widget[data-callout=quote] .callout-fold{@apply text-highlighted}.cm-content .callout[data-callout=neutral] .callout-title .callout-title-icon,.cm-content .callout[data-callout=neutral] .callout-title .callout-title-inner,.cm-content .callout[data-callout=quote] .callout-title .callout-title-icon,.cm-content .callout[data-callout=quote] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=neutral] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=neutral] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=quote] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=quote] .callout-title .callout-title-inner{@apply text-highlighted}.cm-content .callout .callout-fold,.cm-content .cm-callout-widget .callout-fold{@apply rounded hover:bg-elevated transition duration-200 cursor-pointer text-primary font-sans text-center align-middle p-1 size-6}.cm-content .callout .callout-fold svg,.cm-content .cm-callout-widget .callout-fold svg{@apply transition-transform duration-300 ease-in-out w-full h-full}.cm-content .callout[open] .callout-fold svg,.cm-content .cm-callout-widget[open] .callout-fold svg{@apply transition-transform duration-300 ease-in-out rotate-90 w-full h-full}.cm-content .callout[data-fold-state=closed] .callout-content,.cm-content .cm-callout-widget[data-fold-state=closed] .callout-content{@apply max-h-0 opacity-0 p-0}.cm-content .callout[data-fold-state=open] .callout-content,.cm-content .cm-callout-widget[data-fold-state=open] .callout-content{@apply max-h-none opacity-100 py-1 mt-1}.cm-content .callout .edit-block-button,.cm-content .cm-callout-widget .edit-block-button{@apply rounded hover:bg-elevated transition duration-200 cursor-pointer p-1 font-sans text-dimmed}.cm-content .callout .editing-utils-container,.cm-content .cm-callout-widget .editing-utils-container{@apply top-2 right-2 font-sans text-dimmed absolute flex items-center justify-center gap-1 p-1}.cm-content details .callout-content{@apply -mt-11}.cm-content .cm-indent{min-width:var(--list-indent,1.5rem);@apply relative inline-block}.cm-content .cm-indent:before{@apply content-["\200B"] absolute top-0 bottom-0 w-1;@apply border-r border-r-muted;@apply left-[var(--indentation-guide-source-indent)]}.cm-content .cm-indent-group .cm-active-indent:before{@apply border-primary}.cm-content .cm-list-line .cm-indent:before{@apply top-0}.cm-content .cm-list-internal[style*="--indent-level"]{@apply border-primary;padding-inline-start:calc(var(--indent-level)*var(--list-indent));text-indent:calc(var(--indent-level)*var(--list-indent))}.cm-content .cm-indent-list-bullet:before{content:"•";@apply text-dimmed border-none absolute;left:1rem}.cm-content .cm-indent-list-bullet+.cm-obsidian-bullet{@apply hidden}.cm-content .cm-obsidian-hidden{@apply hidden}.cm-content .cm-hidden-latex{@apply hidden}.cm-content .cm-yaml-content,.cm-content .cm-yaml-marker{@apply font-editor-code text-muted px-1}.cm-content .cm-line.hr{@apply h-8 flex items-center}.cm-content .cm-line.hr:after{content:"";@apply block w-full h-px bg-accented}
|
|
1
|
+
@import url("https://fonts.cdnfonts.com/css/segoe-ui-variable-static-display");@import url("https://fonts.cdnfonts.com/css/sf-pro-display");@import "katex/dist/katex.min.css";@import "tailwindcss";@import "@nuxt/ui";@theme{--font-sans:"Public Sans","Inter","SF Pro Display","Segoe UI Variable Static Display",sans-serif;--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--font-editor:"Inter","SF Pro Display","Segoe UI Variable Static Display",var(--font-sans,sans-serif);--font-editor-code:"Google Sans Code","JetBrains Mono","Consolas",var(--font-mono,ui-monospace);--list-indent:1.5rem;--indent-level:0}.cm-content{@apply font-editor}.cm-content .cm-escape,.cm-content .cm-meta{@apply text-dimmed! no-underline!}.cm-content .cm-heading{text-decoration:none!important}.cm-content .cm-mono{@apply font-editor-code bg-muted px-1 rounded-lg border border-default text-toned!}.cm-content .cm-hashtag{@apply bg-gradient-to-t from-primary/20! to-primary/10! ring ring-primary/50! px-1.5 text-sm rounded-4xl text-primary! inline-flex}.cm-content .cm-hashtag .cm-heading{@apply text-primary!}.cm-content .cm-highlighted{@apply bg-primary/20 text-primary px-0.5 rounded-sm}.cm-content .cm-internal-link-display,.cm-content .cm-internal-link-path,.cm-content .cm-internal-link-subpath,.cm-content .cm-link{@apply text-primary! underline}.cm-content .cm-internal-link-display[data-type=internal-link],.cm-content .cm-internal-link-path[data-type=internal-link],.cm-content .cm-internal-link-subpath[data-type=internal-link],.cm-content .cm-link[data-type=internal-link]{@apply cursor-pointer}.cm-content .cm-clickable-link{@apply cursor-pointer}.cm-content .cm-unresolved-link .cm-internal-link-display,.cm-content .cm-unresolved-link .cm-internal-link-path,.cm-content .cm-unresolved-link .cm-internal-link-subpath,.cm-content .cm-unresolved-link .cm-link{@apply text-error/75! cursor-not-allowed}.cm-content .cm-codeblock,.cm-content .cm-line-codeblock-begin,.cm-content .cm-line-codeblock-end{@apply font-editor-code py-0 my-0 text-sm! font-semibold border-x border-x-default mx-2 px-3 bg-muted relative}.cm-content .cm-codeblock .cm-codeblock-flair-container,.cm-content .cm-line-codeblock-begin .cm-codeblock-flair-container,.cm-content .cm-line-codeblock-end .cm-codeblock-flair-container{@apply absolute top-2 right-2 overflow-visible z-10}.cm-content .cm-codeblock .cm-codeblock-flair-container .cm-codeblock-copy-button,.cm-content .cm-line-codeblock-begin .cm-codeblock-flair-container .cm-codeblock-copy-button,.cm-content .cm-line-codeblock-end .cm-codeblock-flair-container .cm-codeblock-copy-button{@apply rounded hover:bg-accented transition duration-200 cursor-pointer py-1.5 px-2 font-sans text-dimmed z-10}.cm-content .cm-codeblock .cm-mono,.cm-content .cm-line-codeblock-begin .cm-mono,.cm-content .cm-line-codeblock-end .cm-mono{@apply border-none bg-none text-default}.cm-content .cm-line-codeblock-content{@apply border-x border-x-accented}.cm-content .cm-line-codeblock-begin{@apply rounded-t-lg border-t border-x border-t-accented border-x-accented pt-1 px-1}.cm-content .cm-line-codeblock-end{@apply rounded-b-lg border-b border-x border-b-accented border-x-accented pb-1 px-1}.cm-content .cm-task-checkbox-wrapper{@apply size-4 mb-0.5 rounded-xl border border-default bg-default inline-flex items-center justify-center align-middle cursor-pointer}.cm-content .cm-task-checkbox-wrapper[data-checked=true]{@apply bg-primary border border-primary}.cm-content .cm-task-checkbox-wrapper[data-checked=true]:before{content:"✔";@apply text-xs text-inverted}.cm-content .cm-task-checkbox-wrapper[data-special]{@apply font-editor-code text-xs text-highlighted}.cm-content .cm-task-checked{@apply line-through text-dimmed}.cm-content .cm-tooltip{@apply rounded-lg bg-default/70 shadow-lg backdrop-blur-sm border border-default font-sans p-2}.cm-content .cm-tooltip ul{@apply grid grid-cols-1 font-sans}.cm-content .cm-tooltip ul li{@apply grid grid-cols-1 rounded font-sans gap-1}.cm-content .cm-tooltip ul li .cm-completionLabel{@apply mx-1 mt-1 text-toned}.cm-content .cm-tooltip ul li .cm-completionDetail{@apply text-xs font-editor-code bg-elevated w-fit rounded text-muted px-1 mb-1}.cm-content .cm-tooltip ul li[aria-selected=true]{@apply bg-accented/70 backdrop-blur-sm border border-accented}.cm-content .cm-fold-widget{@apply absolute -left-0.5 pt-1}.cm-content .cm-gutter,.cm-content .cm-gutters{@apply bg-transparent! border-none}.cm-content .cm-foldPlaceholder{@apply bg-accented! text-dimmed! border border-none ml-0.5 h-fit inline-flex items-center justify-center align-middle}.cm-content .cm-gutterElement{@apply inline-flex justify-center items-center}.cm-content .cm-heading-1{@apply text-4xl! text-highlighted scroll-mt-[calc(45px+var(--ui-header-height))]}.cm-content .cm-heading-2{@apply text-2xl! text-highlighted scroll-mt-[calc(45px+var(--ui-header-height))]}.cm-content .cm-heading-3{@apply text-xl! text-highlighted scroll-mt-[calc(45px+var(--ui-header-height))]}.cm-content .cm-heading-4{@apply text-lg! text-highlighted scroll-mt-[calc(45px+var(--ui-header-height))]}.cm-content .cm-quoteblock,.cm-content blockquote{@apply bg-muted border-accented ps-2 mx-2 before:ml-0.5 before:rounded-lg before:px-0.5 before:bg-accented before:py-1}.cm-content .cm-quoteblock.cm-quoteblock-single,.cm-content blockquote.cm-quoteblock-single{@apply rounded-lg py-2 before:py-0.5}.cm-content .cm-quoteblock.cm-quoteblock-start,.cm-content blockquote.cm-quoteblock-start{@apply rounded-t-lg pt-2 before:pt-0}.cm-content .cm-quoteblock.cm-quoteblock-end,.cm-content blockquote.cm-quoteblock-end{@apply rounded-b-lg pb-2 before:pb-0}.cm-content .cm-quoteblock .cm-formatting-quote.cm-meta,.cm-content blockquote .cm-formatting-quote.cm-meta{@apply invisible}.cm-content .cm-quoteblock .cm-formatting-quote-active.cm-meta,.cm-content blockquote .cm-formatting-quote-active.cm-meta{@apply visible!}.cm-content .cm-obsidian-bullet{@apply text-transparent}.cm-content .cm-obsidian-bullet .cm-meta{@apply invisible}.cm-content .cm-obsidian-bullet:before{content:"•";@apply text-dimmed absolute}.cm-content .callout,.cm-content .cm-callout-widget{@apply p-3 relative flex flex-col h-fit mx-2 my-2 rounded-xl border border-primary/20 from-primary/10 to-primary/20 bg-gradient-to-b}.cm-content .callout summary,.cm-content .cm-callout-widget summary{@apply inline-flex}.cm-content .callout .callout-title,.cm-content .cm-callout-widget .callout-title{@apply flex gap-1.5 items-center}.cm-content .callout .callout-title .callout-title-icon,.cm-content .cm-callout-widget .callout-title .callout-title-icon{@apply flex size-4 items-center justify-center fill-primary text-primary}.cm-content .callout .callout-title .callout-title-inner,.cm-content .cm-callout-widget .callout-title .callout-title-inner{@apply text-primary text-lg font-bold flex-grow}.cm-content .callout .callout-title .edit-block-button,.cm-content .cm-callout-widget .callout-title .edit-block-button{@apply rounded hover:bg-elevated transition duration-200 cursor-pointer p-1 font-sans right-0 top-0 text-dimmed}.cm-content .callout .callout-content,.cm-content .cm-callout-widget .callout-content{@apply flex flex-col gap-1}.cm-content .callout[data-callout=info],.cm-content .cm-callout-widget[data-callout=info]{@apply from-info/10 to-info/20 bg-gradient-to-b border-info/20}.cm-content .callout[data-callout=info] .callout-fold,.cm-content .cm-callout-widget[data-callout=info] .callout-fold{@apply text-info-400}.cm-content .callout[data-callout=info] .callout-title .callout-title-icon,.cm-content .callout[data-callout=info] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=info] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=info] .callout-title .callout-title-inner{@apply text-info}.cm-content .callout[data-callout=check],.cm-content .callout[data-callout=done],.cm-content .callout[data-callout=success],.cm-content .cm-callout-widget[data-callout=check],.cm-content .cm-callout-widget[data-callout=done],.cm-content .cm-callout-widget[data-callout=success]{@apply from-success/10 to-success/20 bg-gradient-to-b border-success/20}.cm-content .callout[data-callout=check] .callout-fold,.cm-content .callout[data-callout=done] .callout-fold,.cm-content .callout[data-callout=success] .callout-fold,.cm-content .cm-callout-widget[data-callout=check] .callout-fold,.cm-content .cm-callout-widget[data-callout=done] .callout-fold,.cm-content .cm-callout-widget[data-callout=success] .callout-fold{@apply text-success-400}.cm-content .callout[data-callout=check] .callout-title .callout-title-icon,.cm-content .callout[data-callout=check] .callout-title .callout-title-inner,.cm-content .callout[data-callout=done] .callout-title .callout-title-icon,.cm-content .callout[data-callout=done] .callout-title .callout-title-inner,.cm-content .callout[data-callout=success] .callout-title .callout-title-icon,.cm-content .callout[data-callout=success] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=check] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=check] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=done] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=done] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=success] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=success] .callout-title .callout-title-inner{@apply text-success}.cm-content .callout[data-callout=faq],.cm-content .callout[data-callout=help],.cm-content .callout[data-callout=question],.cm-content .callout[data-callout=warning],.cm-content .cm-callout-widget[data-callout=faq],.cm-content .cm-callout-widget[data-callout=help],.cm-content .cm-callout-widget[data-callout=question],.cm-content .cm-callout-widget[data-callout=warning]{@apply from-warning/10 to-warning/20 bg-gradient-to-b border-warning/20}.cm-content .callout[data-callout=faq] .callout-fold,.cm-content .callout[data-callout=help] .callout-fold,.cm-content .callout[data-callout=question] .callout-fold,.cm-content .callout[data-callout=warning] .callout-fold,.cm-content .cm-callout-widget[data-callout=faq] .callout-fold,.cm-content .cm-callout-widget[data-callout=help] .callout-fold,.cm-content .cm-callout-widget[data-callout=question] .callout-fold,.cm-content .cm-callout-widget[data-callout=warning] .callout-fold{@apply text-warning-400}.cm-content .callout[data-callout=faq] .callout-title .callout-title-icon,.cm-content .callout[data-callout=faq] .callout-title .callout-title-inner,.cm-content .callout[data-callout=help] .callout-title .callout-title-icon,.cm-content .callout[data-callout=help] .callout-title .callout-title-inner,.cm-content .callout[data-callout=question] .callout-title .callout-title-icon,.cm-content .callout[data-callout=question] .callout-title .callout-title-inner,.cm-content .callout[data-callout=warning] .callout-title .callout-title-icon,.cm-content .callout[data-callout=warning] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=faq] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=faq] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=help] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=help] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=question] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=question] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=warning] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=warning] .callout-title .callout-title-inner{@apply text-warning}.cm-content .callout[data-callout=bug],.cm-content .callout[data-callout=error],.cm-content .callout[data-callout=failure],.cm-content .cm-callout-widget[data-callout=bug],.cm-content .cm-callout-widget[data-callout=error],.cm-content .cm-callout-widget[data-callout=failure]{@apply from-error/10 to-error/20 bg-gradient-to-b border-error/20}.cm-content .callout[data-callout=bug] .callout-fold,.cm-content .callout[data-callout=error] .callout-fold,.cm-content .callout[data-callout=failure] .callout-fold,.cm-content .cm-callout-widget[data-callout=bug] .callout-fold,.cm-content .cm-callout-widget[data-callout=error] .callout-fold,.cm-content .cm-callout-widget[data-callout=failure] .callout-fold{@apply text-error-400}.cm-content .callout[data-callout=bug] .callout-title .callout-title-icon,.cm-content .callout[data-callout=bug] .callout-title .callout-title-inner,.cm-content .callout[data-callout=error] .callout-title .callout-title-icon,.cm-content .callout[data-callout=error] .callout-title .callout-title-inner,.cm-content .callout[data-callout=failure] .callout-title .callout-title-icon,.cm-content .callout[data-callout=failure] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=bug] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=bug] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=error] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=error] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=failure] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=failure] .callout-title .callout-title-inner{@apply text-error}.cm-content .callout[data-callout=example],.cm-content .callout[data-callout=highlight],.cm-content .callout[data-callout=tip],.cm-content .cm-callout-widget[data-callout=example],.cm-content .cm-callout-widget[data-callout=highlight],.cm-content .cm-callout-widget[data-callout=tip]{@apply from-secondary/10 to-secondary/20 bg-gradient-to-b border-secondary/20}.cm-content .callout[data-callout=example] .callout-fold,.cm-content .callout[data-callout=highlight] .callout-fold,.cm-content .callout[data-callout=tip] .callout-fold,.cm-content .cm-callout-widget[data-callout=example] .callout-fold,.cm-content .cm-callout-widget[data-callout=highlight] .callout-fold,.cm-content .cm-callout-widget[data-callout=tip] .callout-fold{@apply text-secondary}.cm-content .callout[data-callout=example] .callout-title .callout-title-icon,.cm-content .callout[data-callout=example] .callout-title .callout-title-inner,.cm-content .callout[data-callout=highlight] .callout-title .callout-title-icon,.cm-content .callout[data-callout=highlight] .callout-title .callout-title-inner,.cm-content .callout[data-callout=tip] .callout-title .callout-title-icon,.cm-content .callout[data-callout=tip] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=example] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=example] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=highlight] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=highlight] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=tip] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=tip] .callout-title .callout-title-inner{@apply text-secondary}.cm-content .callout[data-callout=neutral],.cm-content .callout[data-callout=quote],.cm-content .cm-callout-widget[data-callout=neutral],.cm-content .cm-callout-widget[data-callout=quote]{@apply from-accented/20 to-accented/30 bg-gradient-to-b border-accented/30}.cm-content .callout[data-callout=neutral] .callout-fold,.cm-content .callout[data-callout=quote] .callout-fold,.cm-content .cm-callout-widget[data-callout=neutral] .callout-fold,.cm-content .cm-callout-widget[data-callout=quote] .callout-fold{@apply text-highlighted}.cm-content .callout[data-callout=neutral] .callout-title .callout-title-icon,.cm-content .callout[data-callout=neutral] .callout-title .callout-title-inner,.cm-content .callout[data-callout=quote] .callout-title .callout-title-icon,.cm-content .callout[data-callout=quote] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=neutral] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=neutral] .callout-title .callout-title-inner,.cm-content .cm-callout-widget[data-callout=quote] .callout-title .callout-title-icon,.cm-content .cm-callout-widget[data-callout=quote] .callout-title .callout-title-inner{@apply text-highlighted}.cm-content .callout .callout-fold,.cm-content .cm-callout-widget .callout-fold{@apply rounded hover:bg-elevated transition duration-200 cursor-pointer text-primary font-sans text-center align-middle p-1 size-6}.cm-content .callout .callout-fold svg,.cm-content .cm-callout-widget .callout-fold svg{@apply transition-transform duration-300 ease-in-out w-full h-full}.cm-content .callout[open] .callout-fold svg,.cm-content .cm-callout-widget[open] .callout-fold svg{@apply transition-transform duration-300 ease-in-out rotate-90 w-full h-full}.cm-content .callout[data-fold-state=closed] .callout-content,.cm-content .cm-callout-widget[data-fold-state=closed] .callout-content{@apply max-h-0 opacity-0 p-0}.cm-content .callout[data-fold-state=open] .callout-content,.cm-content .cm-callout-widget[data-fold-state=open] .callout-content{@apply max-h-none opacity-100 py-1 mt-1}.cm-content .callout .edit-block-button,.cm-content .cm-callout-widget .edit-block-button{@apply rounded hover:bg-elevated transition duration-200 cursor-pointer p-1 font-sans text-dimmed}.cm-content .callout .editing-utils-container,.cm-content .cm-callout-widget .editing-utils-container{@apply top-2 right-2 font-sans text-dimmed absolute flex items-center justify-center gap-1 p-1}.cm-content details .callout-content{@apply -mt-11}.cm-content .cm-indent{min-width:var(--list-indent,1.5rem);@apply relative inline-block}.cm-content .cm-indent:before{@apply content-["\200B"] absolute top-0 bottom-0 w-1;@apply border-r border-r-muted;@apply left-[var(--indentation-guide-source-indent)]}.cm-content .cm-indent-group .cm-active-indent:before{@apply border-primary}.cm-content .cm-list-line .cm-indent:before{@apply top-0}.cm-content .cm-list-internal[style*="--indent-level"]{@apply border-primary;padding-inline-start:calc(var(--indent-level)*var(--list-indent));text-indent:calc(var(--indent-level)*var(--list-indent))}.cm-content .cm-indent-list-bullet:before{content:"•";@apply text-dimmed border-none absolute;left:1rem}.cm-content .cm-indent-list-bullet+.cm-obsidian-bullet{@apply hidden}.cm-content .cm-obsidian-hidden{@apply hidden}.cm-content .cm-hidden-latex{@apply hidden}.cm-content .cm-yaml-content,.cm-content .cm-yaml-marker{@apply font-editor-code text-muted px-1}.cm-content .cm-line.hr{@apply h-8 flex items-center}.cm-content .cm-line.hr:after{content:"";@apply block w-full h-px bg-accented}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
defineProps({
|
|
3
|
-
filePath: { type: String, required: true }
|
|
3
|
+
filePath: { type: String, required: true },
|
|
4
|
+
display: { type: String, required: false }
|
|
4
5
|
});
|
|
5
6
|
</script>
|
|
6
7
|
|
|
7
8
|
<template>
|
|
8
|
-
<div class="p-3">
|
|
9
|
-
<NuxtImg :src="filePath" class="w-full h-auto object-cover rounded-lg" format="jpeg" :quality="
|
|
9
|
+
<div class="p-3 grid grid-cols-1">
|
|
10
|
+
<NuxtImg :src="filePath" class="w-full h-auto max-h-96 object-cover rounded-lg" format="jpeg" :quality="90" :alt="display"/>
|
|
11
|
+
<div class="text-muted text-left text-xs select-none mt-1.5 text-pretty">{{ display }}</div>
|
|
10
12
|
</div>
|
|
11
13
|
</template>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
type __VLS_Props = {
|
|
2
2
|
filePath: string;
|
|
3
|
+
display?: string;
|
|
3
4
|
};
|
|
4
5
|
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
5
6
|
export default _default;
|
|
@@ -191,5 +191,5 @@ defineExpose({
|
|
|
191
191
|
</template>
|
|
192
192
|
|
|
193
193
|
<style>
|
|
194
|
-
@reference "../assets/css/editor.css";.cm-cursor{@apply border-l-primary! border-l-[1.
|
|
194
|
+
@reference "../assets/css/editor.css";.cm-cursor{@apply border-l-primary! border-l-[1.8px]! rounded-lg!}.cm-selectionBackground{@apply bg-primary/30! z-[150]}.cm-selectionLayer{@apply z-[150]!;pointer-events:none}div[contenteditable=true]:focus{@apply outline-none border-none h-full shadow-none}.cm-focused{@apply outline-none!}.cm-placeholder{@apply font-editor text-muted}.cm-activeLine{@apply bg-none! border-l-primary border-l-4 relative -left-1 content-[""] mask-no-clip overflow-visible}
|
|
195
195
|
</style>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
import type { Frontmatter } from '../editor/types/editor-types.js';
|
|
3
|
+
export declare function useEditorFrontmatter<T extends object = {}>(editor: Ref<any>): {
|
|
4
|
+
getFrontmatter: () => {
|
|
5
|
+
data?: Frontmatter<T>;
|
|
6
|
+
error?: Error;
|
|
7
|
+
};
|
|
8
|
+
setFrontmatterProperties: (properties: Partial<Frontmatter<T>>) => void;
|
|
9
|
+
addFrontmatterProperty: (key: string, value: any) => void;
|
|
10
|
+
removeFrontmatterProperty: (key: string) => void;
|
|
11
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { load, dump } from "js-yaml";
|
|
2
|
+
import { useEditorUtils } from "./useEditorUtils.js";
|
|
3
|
+
export function useEditorFrontmatter(editor) {
|
|
4
|
+
const editorUtils = useEditorUtils(editor);
|
|
5
|
+
function getFrontmatter() {
|
|
6
|
+
const doc = editorUtils.getDoc();
|
|
7
|
+
if (!doc) {
|
|
8
|
+
return {};
|
|
9
|
+
}
|
|
10
|
+
const ast = editorUtils.parseMarkdownToAST(doc);
|
|
11
|
+
const firstNode = ast.topNode.firstChild;
|
|
12
|
+
if (!firstNode || firstNode.name !== "YAMLFrontMatter") {
|
|
13
|
+
return {};
|
|
14
|
+
}
|
|
15
|
+
const contentNode = firstNode.getChild("YAMLContent");
|
|
16
|
+
const yamlContent = contentNode ? doc.slice(contentNode.from, contentNode.to) : "";
|
|
17
|
+
try {
|
|
18
|
+
const data = load(yamlContent);
|
|
19
|
+
if (data === null || data === void 0) {
|
|
20
|
+
return { data: {} };
|
|
21
|
+
}
|
|
22
|
+
if (typeof data === "object") {
|
|
23
|
+
return { data };
|
|
24
|
+
}
|
|
25
|
+
return { error: new Error("Frontmatter is not a valid object.") };
|
|
26
|
+
} catch (e) {
|
|
27
|
+
return { error: e };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function setFrontmatterProperties(properties) {
|
|
31
|
+
const doc = editorUtils.getDoc() || "";
|
|
32
|
+
const ast = editorUtils.parseMarkdownToAST(doc);
|
|
33
|
+
const firstNode = ast.topNode.firstChild;
|
|
34
|
+
let existingData = {};
|
|
35
|
+
let frontmatterNodeRange = { from: -1, to: -1 };
|
|
36
|
+
if (firstNode && firstNode.name === "YAMLFrontMatter") {
|
|
37
|
+
frontmatterNodeRange = { from: firstNode.from, to: firstNode.to };
|
|
38
|
+
const { data, error } = getFrontmatter();
|
|
39
|
+
if (data && !error) {
|
|
40
|
+
existingData = data;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const newData = { ...existingData, ...properties };
|
|
44
|
+
Object.keys(newData).forEach((key) => {
|
|
45
|
+
if (newData[key] === void 0) {
|
|
46
|
+
delete newData[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
const newYamlContent = Object.keys(newData).length > 0 ? dump(newData, { skipInvalid: true }).trim() : "";
|
|
50
|
+
const newFrontmatterBlock = `---
|
|
51
|
+
${newYamlContent}
|
|
52
|
+
---`;
|
|
53
|
+
if (frontmatterNodeRange.from !== -1) {
|
|
54
|
+
editorUtils.dispatch({
|
|
55
|
+
changes: { from: frontmatterNodeRange.from, to: frontmatterNodeRange.to, insert: newFrontmatterBlock }
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
const insertText = doc.trim().length > 0 ? `${newFrontmatterBlock}
|
|
59
|
+
|
|
60
|
+
` : newFrontmatterBlock;
|
|
61
|
+
editorUtils.dispatch({
|
|
62
|
+
changes: { from: 0, to: 0, insert: insertText }
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function addFrontmatterProperty(key, value) {
|
|
67
|
+
setFrontmatterProperties({ [key]: value });
|
|
68
|
+
}
|
|
69
|
+
function removeFrontmatterProperty(key) {
|
|
70
|
+
setFrontmatterProperties({ [key]: void 0 });
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
getFrontmatter,
|
|
74
|
+
setFrontmatterProperties,
|
|
75
|
+
addFrontmatterProperty,
|
|
76
|
+
removeFrontmatterProperty
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -27,7 +27,10 @@ function buildInternalLinkDecorations(state) {
|
|
|
27
27
|
const line = state.doc.lineAt(node.from);
|
|
28
28
|
const props = { linkData: linkInfo };
|
|
29
29
|
if (linkInfo.filePath) {
|
|
30
|
+
const displayNode = node.node.getChild("InternalLink")?.getChild("InternalDisplay");
|
|
30
31
|
props.filePath = linkInfo.filePath;
|
|
32
|
+
if (displayNode?.from && displayNode?.to)
|
|
33
|
+
props.display = state.doc.sliceString(displayNode.from, displayNode.to);
|
|
31
34
|
}
|
|
32
35
|
widgets.push(Decoration.widget({
|
|
33
36
|
widget: new ProseVueComponentEmbedWidget(linkInfo.embedComponent, props, node.from),
|
package/dist/runtime/editor/plugins/codemirror-plugin-proses/proseLinkCodemirrorViewPlugin.js
CHANGED
|
@@ -16,8 +16,9 @@ function buildLinkDecorations(state) {
|
|
|
16
16
|
const urlNode = node.getChild("URL");
|
|
17
17
|
if (urlNode) {
|
|
18
18
|
const url = state.doc.sliceString(urlNode.from, urlNode.to);
|
|
19
|
+
const displayString = state.doc.sliceString(2, urlNode.from - 2);
|
|
19
20
|
decorations.push(Decoration.replace({
|
|
20
|
-
widget: new ProseVueComponentEmbedWidget(ImageEmbedComponent, { filePath: url }, node.from),
|
|
21
|
+
widget: new ProseVueComponentEmbedWidget(ImageEmbedComponent, { filePath: url, display: displayString }, node.from),
|
|
21
22
|
block: true
|
|
22
23
|
}).range(node.from, node.to));
|
|
23
24
|
}
|
|
@@ -34,6 +34,7 @@ export default HighlightStyle.define([
|
|
|
34
34
|
{ tag: t.meta, class: "cm-meta" },
|
|
35
35
|
{ tag: t.strikethrough, class: "cm-strikethrough" },
|
|
36
36
|
{ tag: t.contentSeparator, class: "cm-horizontal-rule" },
|
|
37
|
+
{ tag: t.escape, class: "cm-escape" },
|
|
37
38
|
// { tag: lezerHighlightHashtagTag, class: 'cm-hashtag' },
|
|
38
39
|
{ tag: lezerHighlightEmbed, class: "cm-embed" },
|
|
39
40
|
{ tag: lezerHighlightEmbedMark, class: "cm-embed-mark cm-meta" },
|
|
@@ -8,6 +8,12 @@ export interface InternalLink {
|
|
|
8
8
|
embedComponent?: Component;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
export interface InternalLinkNode {
|
|
12
|
+
path: string
|
|
13
|
+
subpath?: string
|
|
14
|
+
display?: string
|
|
15
|
+
}
|
|
16
|
+
|
|
11
17
|
export interface InternalLinkClickDetail {
|
|
12
18
|
path: string;
|
|
13
19
|
subpath?: string;
|
|
@@ -32,3 +38,15 @@ export type WysiwygPlugin = {
|
|
|
32
38
|
[key: string]: any
|
|
33
39
|
}
|
|
34
40
|
}
|
|
41
|
+
|
|
42
|
+
export type Frontmatter<T extends object = {}> = {
|
|
43
|
+
title?: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
date?: Date;
|
|
46
|
+
draft?: boolean;
|
|
47
|
+
tags?: string[];
|
|
48
|
+
categories?: string[];
|
|
49
|
+
image?: string;
|
|
50
|
+
slug?: string;
|
|
51
|
+
[key: string]: any;
|
|
52
|
+
} & T
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { Frontmatter } from '../editor/types/editor-types.js';
|
|
2
|
+
export declare function parseFrontmatter(markdownText: string): {
|
|
3
|
+
data?: Frontmatter;
|
|
3
4
|
error?: Error;
|
|
4
5
|
};
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import { load } from "js-yaml";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { markdown } from "@codemirror/lang-markdown";
|
|
3
|
+
import { GFM } from "@lezer/markdown";
|
|
4
|
+
import { CustomOFM } from "../editor/lezer-parsers/customOFMParsers.js";
|
|
5
|
+
export function parseFrontmatter(markdownText) {
|
|
6
|
+
if (!markdownText) {
|
|
5
7
|
return {};
|
|
6
8
|
}
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const tree = markdown({
|
|
10
|
+
extensions: [GFM, CustomOFM, { remove: ["SetextHeading"] }]
|
|
11
|
+
}).language.parser.parse(markdownText);
|
|
12
|
+
const firstNode = tree.topNode.firstChild;
|
|
13
|
+
if (!firstNode || firstNode.name !== "YAMLFrontMatter") {
|
|
12
14
|
return {};
|
|
13
15
|
}
|
|
14
|
-
const
|
|
16
|
+
const contentNode = firstNode.getChild("YAMLContent");
|
|
17
|
+
const yamlContent = contentNode ? markdownText.slice(contentNode.from, contentNode.to) : "";
|
|
15
18
|
try {
|
|
16
|
-
const data = load(yamlContent
|
|
17
|
-
if (
|
|
19
|
+
const data = load(yamlContent);
|
|
20
|
+
if (data === null || data === void 0) {
|
|
21
|
+
return { data: {} };
|
|
22
|
+
}
|
|
23
|
+
if (typeof data === "object") {
|
|
18
24
|
return { data };
|
|
19
25
|
}
|
|
20
26
|
return { error: new Error("Frontmatter is not a valid object.") };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { markdown } from "@codemirror/lang-markdown";
|
|
2
|
+
import { GFM } from "@lezer/markdown";
|
|
3
|
+
import { CustomOFM } from "../editor/lezer-parsers/customOFMParsers.js";
|
|
4
|
+
export function getInternalLinks(markdownText) {
|
|
5
|
+
const links = [];
|
|
6
|
+
const tree = markdown({
|
|
7
|
+
extensions: [GFM, CustomOFM, { remove: ["SetextHeading"] }]
|
|
8
|
+
}).language.parser.parse(markdownText);
|
|
9
|
+
tree.iterate({
|
|
10
|
+
enter: (node) => {
|
|
11
|
+
if (node.name === "InternalLink") {
|
|
12
|
+
const link = { path: "" };
|
|
13
|
+
const pathNode = node.node.getChild("InternalPath");
|
|
14
|
+
if (pathNode) {
|
|
15
|
+
link.path = markdownText.slice(pathNode.from, pathNode.to);
|
|
16
|
+
}
|
|
17
|
+
const subpathNode = node.node.getChild("InternalSubpath");
|
|
18
|
+
if (subpathNode) {
|
|
19
|
+
link.subpath = markdownText.slice(subpathNode.from, subpathNode.to);
|
|
20
|
+
}
|
|
21
|
+
const displayNode = node.node.getChild("InternalDisplay");
|
|
22
|
+
if (displayNode) {
|
|
23
|
+
link.display = markdownText.slice(displayNode.from, displayNode.to);
|
|
24
|
+
}
|
|
25
|
+
if (link.path) {
|
|
26
|
+
links.push(link);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return links;
|
|
32
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@type32/codemirror-rich-obsidian-editor",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"description": "OFM Editor Component for Nuxt.",
|
|
5
5
|
"repository": "Type-32/codemirror-rich-obsidian",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@lezer/markdown": "^1.4.3",
|
|
46
46
|
"@nuxt/image": "1.10.0",
|
|
47
47
|
"@nuxt/kit": "^4.1.2",
|
|
48
|
-
"@nuxt/ui": "^4.0.0-alpha.
|
|
48
|
+
"@nuxt/ui": "^4.0.0-alpha.2",
|
|
49
49
|
"alfaaz": "^1.1.0",
|
|
50
50
|
"codemirror": "^6.0.2",
|
|
51
51
|
"js-yaml": "^4.1.0",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"vue-codemirror6": "^1.3.22"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@iconify-json/lucide": "^1.2.
|
|
60
|
-
"@iconify-json/simple-icons": "^1.2.
|
|
59
|
+
"@iconify-json/lucide": "^1.2.68",
|
|
60
|
+
"@iconify-json/simple-icons": "^1.2.52",
|
|
61
61
|
"@nuxt/devtools": "^2.6.3",
|
|
62
62
|
"@nuxt/eslint-config": "^1.9.0",
|
|
63
63
|
"@nuxt/fonts": "0.11.4",
|