Skip to content

Commit

Permalink
Merge branch 'md-preview' into 'main'
Browse files Browse the repository at this point in the history
MDE preview

See merge request reportcreator/reportcreator!809
  • Loading branch information
MWedl committed Dec 20, 2024
2 parents 28e0e0c + cb0561d commit 8cdd59d
Show file tree
Hide file tree
Showing 12 changed files with 195 additions and 105 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* Add button to generate random password to password fields
* Shared notes: Default to markdown preview mode for readonly shares
* Shared notes: Autofocus root note
* UI: Hide markdown toolbar in preview mode
* UI: Update UI to switch markdown editor view mode


## v2024.96 - 2024-12-04
Expand Down
4 changes: 4 additions & 0 deletions packages/frontend/src/assets/mde-highlight.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
.cm-focused .cm-selectionBackground { display: initial; background-color: rgba(var(--v-theme-codemirror-selection), 1) !important; }
.cm-cursor { border-left-color: rgb(var(--v-theme-on-surface)); }

.cm-gutters {
background-color: rgba(var(--v-theme-on-surface), 0.05);
}


/* inline markdown styles */
.cm-content {
Expand Down
10 changes: 9 additions & 1 deletion packages/frontend/src/components/DynamicInputField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
v-if="props.collab?.comments"
density="comfortable"
v-bind="commentBtnAttrs"
v-show="!mobile"
/>
</template>
</v-card-item>
Expand Down Expand Up @@ -148,6 +149,7 @@
v-if="props.collab?.comments"
density="comfortable"
v-bind="commentBtnAttrs"
v-show="!mobile"
/>
<s-btn-icon
v-if="definition.items!.type === 'string'"
Expand Down Expand Up @@ -235,8 +237,9 @@
<v-icon
size="x-large"
class="draggable-handle"
:disabled="props.disabled || props.readonly"
icon="mdi-drag-horizontal"
:disabled="props.disabled || props.readonly"
v-show="!mobile"
/>
<btn-delete
:delete="() => emitInputList('delete', entryIdx as number)"
Expand Down Expand Up @@ -269,6 +272,7 @@
<comment-btn
v-if="props.collab?.comments && ![FieldDataType.MARKDOWN, FieldDataType.LIST, FieldDataType.OBJECT].includes(definition.type as any)"
v-bind="commentBtnAttrs"
v-show="!mobile"
/>
</div>
</template>
Expand Down Expand Up @@ -308,6 +312,10 @@ const emit = defineEmits<{
'update:markdownEditorMode': [value: MarkdownEditorMode];
}>();
const { mobile } = useDisplay();
function getInitialValue(fieldDef: FieldDefinition, useDefault = true): any {
if (fieldDef.default && useDefault) {
return fieldDef.default;
Expand Down
1 change: 0 additions & 1 deletion packages/frontend/src/components/Markdown/FieldContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
ref="editorRef"
v-intersect="onIntersect"
class="mde-editor"
:class="{'mde-editor-side': props.markdownEditorMode === MarkdownEditorMode.MARKDOWN_AND_PREVIEW}"
/>
</v-col>
<v-col
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/components/Markdown/Page.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<full-height-page class="mde">
<full-height-page class="mde" @click="focus()">
<template #header>
<markdown-toolbar v-if="editorView" v-bind="markdownToolbarAttrs" />
</template>
Expand Down
5 changes: 4 additions & 1 deletion packages/frontend/src/components/Markdown/Statusbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<input ref="fileInput" type="file" multiple @change="e => onUploadFiles(e as InputEvent)" @click.stop :disabled="props.disabled || props.fileUploadInProgress" class="d-none" />
</div>
<v-spacer />
<div class="status-items">
<div class="status-items" v-if="!mobile">
<span>lines: {{ lineCount }}</span>
<span>words: {{ wordCount }}</span>
<span>{{ currentLineNumber }}:{{ currentColNumber }}</span>
Expand All @@ -31,6 +31,8 @@ const props = defineProps<{
disabled?: boolean;
}>();
const { mobile } = useDisplay();
const currentLineNumber = computed(() => props.editorState.doc.lineAt(props.editorState.selection.main.head).number);
const currentColNumber = computed(() => {
const pos = props.editorState.selection.main.head
Expand Down Expand Up @@ -74,6 +76,7 @@ async function onUploadFiles(event: InputEvent) {
font-size: smaller;
padding: 0.3em 1em;
color: #959694;
overflow: hidden;
.status-items {
span {
Expand Down
Loading

0 comments on commit 8cdd59d

Please sign in to comment.