Skip to content
This repository was archived by the owner on Dec 8, 2025. It is now read-only.

Commit a036061

Browse files
committed
feat: extract rfced comments tool
1 parent 1fab150 commit a036061

File tree

5 files changed

+174
-8
lines changed

5 files changed

+174
-8
lines changed

src-electron/electron-preload.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ contextBridge.exposeInMainWorld('ipcBridge', {
4242
gitDiscardChanges: (files) => ipcRenderer.invoke('gitDiscardChanges', { files }),
4343
gitCommit: (message) => ipcRenderer.invoke('gitCommit', { message }),
4444
lspSendRequest: (method, params) => ipcRenderer.invoke('lspSendRequest', { method, params }),
45-
saveValidationResults: (output, filePath) => ipcRenderer.invoke('saveValidationResults', { output, filePath }),
45+
saveContentToFile: (output, filePath, title) => ipcRenderer.invoke('saveContentToFile', { output, filePath, title }),
4646
persistSession: (data) => ipcRenderer.invoke('persistSession', data),
4747
restoreSession: () => ipcRenderer.invoke('restoreSession')
4848
})

src-electron/handlers.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,12 @@ export function registerCallbacks (mainWindow, mainMenu, auth, git, lsp, tlm, te
364364
lsp.sendNotification(opts.method, opts.params)
365365
})
366366
// ----------------------------------------------------------
367-
// VALIDATION CHECKS
367+
// SAVE GENERIC CONTENT TO FILE
368368
// ----------------------------------------------------------
369-
ipcMain.handle('saveValidationResults', async (ev, opts) => {
369+
ipcMain.handle('saveContentToFile', async (ev, opts) => {
370370
const saveOpts = await dialog.showSaveDialog(mainWindow, {
371-
title: 'Save Validation Results As...',
372-
defaultPath: opts.filePath || path.join(app.getPath('desktop'), 'results.txt'),
371+
title: opts.title ?? 'Save As...',
372+
defaultPath: opts.filePath || path.join(app.getPath('desktop'), 'output.txt'),
373373
filters: [{
374374
name: 'Plain Text',
375375
extensions: ['txt']

src/components/DrawerChecks.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ async function saveResultsToFile (key) {
410410
}
411411
filePath = `${filePath}-${key}.txt`
412412
413-
if (await window.ipcBridge.saveValidationResults(editorStore.validationChecksDetails[key].getTextOutput(), filePath)) {
413+
if (await window.ipcBridge.saveContentToFile(editorStore.validationChecksDetails[key].getTextOutput(), filePath, 'Save Validation Results As...')) {
414414
$q.notify({
415415
message: 'Results saved!',
416416
caption: 'Results have been saved to file successfully.',

src/components/DrawerTools.vue

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
.text-caption.text-light-blue-3
55
strong Tools
66
q-list
7+
q-item(clickable v-if='currentMode === `review`' @click='extractRfcedComments')
8+
q-item-section(side)
9+
q-icon(name='mdi-comment-arrow-right-outline' size='xs' color='purple-2')
10+
q-item-section
11+
q-item-label Extract [rfced] comments
12+
q-item-label.text-purple-2(caption) List all comments for the RPC staff
713
q-item(clickable @click='reformat')
814
q-item-section(side)
915
q-icon(name='mdi-page-previous-outline' size='xs' color='purple-2')
@@ -19,13 +25,34 @@ q-list
1925
</template>
2026

2127
<script setup>
28+
import { computed, defineAsyncComponent } from 'vue'
29+
import { useRoute } from 'vue-router'
2230
import { useQuasar } from 'quasar'
2331
2432
const $q = useQuasar()
2533
34+
const route = useRoute()
35+
36+
const currentMode = computed(() => {
37+
if (route.name === 'editor') {
38+
if (route.query.mode === 'review') {
39+
return 'review'
40+
}
41+
return 'write'
42+
} else {
43+
return route.name
44+
}
45+
})
46+
2647
// METHODS
2748
28-
function reformat() {
49+
function extractRfcedComments () {
50+
$q.dialog({
51+
component: defineAsyncComponent(() => import('components/ExtractRfcedCommentsDialog.vue'))
52+
})
53+
}
54+
55+
function reformat () {
2956
EVENT_BUS.emit('editorAction', 'format')
3057
$q.notify({
3158
message: 'Document reformatted succesfully',
@@ -34,7 +61,7 @@ function reformat() {
3461
})
3562
}
3663
37-
function stripmchars() {
64+
function stripmchars () {
3865
EVENT_BUS.emit('editorAction', 'stripMChars')
3966
$q.notify({
4067
message: 'Document cleaned succesfully',
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
<template lang="pug">
2+
q-dialog(
3+
ref='dialogRef'
4+
@hide='onDialogHide'
5+
:transition-show='editorStore.animationEffects ? `jump-up` : `none`'
6+
:transition-hide='editorStore.animationEffects ? `jump-down` : `none`'
7+
)
8+
q-card.mica(style='min-width: 800px;')
9+
q-card-section.flex.items-center.bg-light-blue-10
10+
q-icon(name='mdi-comment-arrow-right-outline', left, size='sm')
11+
span Extract [rfced] Comments
12+
q-card-section.card-border
13+
q-card-section.q-pa-sm(style='max-height: 520px')
14+
q-input(
15+
autofocus
16+
color='light-blue-4'
17+
outlined
18+
v-model='state.output'
19+
tabindex='0'
20+
type='textarea'
21+
autogrow
22+
input-style='max-height: 500px;'
23+
)
24+
q-card-actions(align='right')
25+
q-btn(
26+
outline
27+
label='Close'
28+
color='grey-5'
29+
padding='xs md'
30+
@click='onDialogCancel'
31+
tabindex='3'
32+
)
33+
q-btn(
34+
unelevated
35+
label='Copy to Clipboard'
36+
color='primary'
37+
padding='xs md'
38+
@click='copyToClipboard'
39+
tabindex='2'
40+
)
41+
q-btn(
42+
unelevated
43+
label='Save to File'
44+
color='primary'
45+
padding='xs md'
46+
@click='saveToFile'
47+
tabindex='1'
48+
)
49+
50+
</template>
51+
52+
<script setup>
53+
import { useDialogPluginComponent, useQuasar } from 'quasar'
54+
import { onMounted, reactive } from 'vue'
55+
import { useDocsStore } from 'src/stores/docs'
56+
import { useEditorStore } from 'src/stores/editor'
57+
import { modelStore } from 'src/stores/models'
58+
59+
const commentsRgx = /<!-- \[rfced\]([^]+?)-->/gmi
60+
61+
const $q = useQuasar()
62+
63+
// EMITS
64+
65+
defineEmits([
66+
...useDialogPluginComponent.emits
67+
])
68+
69+
// STORES
70+
71+
const docsStore = useDocsStore()
72+
const editorStore = useEditorStore()
73+
74+
// QUASAR
75+
76+
const { dialogRef, onDialogCancel, onDialogHide } = useDialogPluginComponent()
77+
78+
// STATE
79+
80+
const state = reactive({
81+
output: ''
82+
})
83+
84+
// METHODS
85+
86+
function copyToClipboard () {
87+
window.ipcBridge.emit('writeToClipboard', {
88+
text: state.output
89+
})
90+
$q.notify({
91+
message: 'Comments copied!',
92+
caption: 'Comments have been copied to the clipboard successfully.',
93+
color: 'positive',
94+
icon: 'mdi-clipboard'
95+
})
96+
}
97+
98+
async function saveToFile () {
99+
let filePath = docsStore.activeDocument.path
100+
const extPosition = filePath.lastIndexOf('.')
101+
if (extPosition >= 0) {
102+
filePath = filePath.slice(0, extPosition)
103+
}
104+
filePath = `${filePath}-comments.txt`
105+
106+
if (await window.ipcBridge.saveContentToFile(state.output, filePath, 'Save Comments As...')) {
107+
$q.notify({
108+
message: 'Comments saved!',
109+
caption: 'Comments have been saved to file successfully.',
110+
color: 'positive',
111+
icon: 'mdi-comment-check-outline'
112+
})
113+
}
114+
}
115+
116+
// MOUNTED
117+
118+
onMounted(() => {
119+
const contents = modelStore[docsStore.activeDocument.id].getValue()
120+
const comments = []
121+
for (const match of contents.matchAll(commentsRgx)) {
122+
comments.push(match[1].trim())
123+
}
124+
if (comments.length > 0) {
125+
state.output = comments.join('\n\n============\n\n')
126+
} else {
127+
$q.notify({
128+
message: 'No comments found.',
129+
caption: 'No comments found in the active document.',
130+
color: 'negative',
131+
icon: 'mdi-alert'
132+
})
133+
setTimeout(() => {
134+
onDialogCancel()
135+
})
136+
}
137+
})
138+
139+
</script>

0 commit comments

Comments
 (0)