mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-11-22 20:35:20 +00:00
dev: adjust a bit
This commit is contained in:
parent
1b4abed41d
commit
62456fda01
13 changed files with 57 additions and 87 deletions
|
|
@ -72,6 +72,7 @@ pub fn query_main(mut cmds: QueryCommands) -> Result<()> {
|
|||
allow_overlapping_token: const_config.tokens_overlapping_token_support,
|
||||
allow_multiline_token: const_config.tokens_multiline_token_support,
|
||||
remove_html: !config.support_html_in_markdown,
|
||||
support_client_codelens: true,
|
||||
extended_code_action: config.extended_code_action,
|
||||
completion_feat: config.completion.clone(),
|
||||
color_theme: match config.color_theme.as_deref() {
|
||||
|
|
|
|||
|
|
@ -65,6 +65,8 @@ pub struct Analysis {
|
|||
pub allow_multiline_token: bool,
|
||||
/// Whether to remove html from markup content in responses.
|
||||
pub remove_html: bool,
|
||||
/// Whether to add client-side code lens.
|
||||
pub support_client_codelens: bool,
|
||||
/// Whether to utilize the extended `tinymist.resolveCodeAction` at client
|
||||
/// side.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -21,24 +21,29 @@ impl SemanticRequest for CodeLensRequest {
|
|||
let mut res = vec![];
|
||||
|
||||
let doc_start = ctx.to_lsp_range(0..0, &source);
|
||||
let doc_lens = |title: &str, args: Vec<JsonValue>| CodeLens {
|
||||
range: doc_start,
|
||||
command: Some(Command {
|
||||
title: title.to_string(),
|
||||
command: "tinymist.runCodeLens".to_string(),
|
||||
arguments: Some(args),
|
||||
}),
|
||||
data: None,
|
||||
let mut doc_lens = |title: &str, args: Vec<JsonValue>| {
|
||||
if !ctx.analysis.support_client_codelens {
|
||||
return;
|
||||
}
|
||||
res.push(CodeLens {
|
||||
range: doc_start,
|
||||
command: Some(Command {
|
||||
title: title.to_string(),
|
||||
command: "tinymist.runCodeLens".to_string(),
|
||||
arguments: Some(args),
|
||||
}),
|
||||
data: None,
|
||||
})
|
||||
};
|
||||
|
||||
res.push(doc_lens(
|
||||
doc_lens(
|
||||
&tinymist_l10n::t!("tinymist-query.code-action.profile", "Profile"),
|
||||
vec!["profile".into()],
|
||||
));
|
||||
res.push(doc_lens(
|
||||
);
|
||||
doc_lens(
|
||||
&tinymist_l10n::t!("tinymist-query.code-action.preview", "Preview"),
|
||||
vec!["preview".into()],
|
||||
));
|
||||
);
|
||||
|
||||
let is_html = ctx
|
||||
.world()
|
||||
|
|
@ -46,22 +51,20 @@ impl SemanticRequest for CodeLensRequest {
|
|||
.features
|
||||
.is_enabled(typst::Feature::Html);
|
||||
|
||||
doc_lens(
|
||||
&tinymist_l10n::t!("tinymist-query.code-action.export", "Export"),
|
||||
vec!["export".into()],
|
||||
);
|
||||
if is_html {
|
||||
res.push(doc_lens(
|
||||
&tinymist_l10n::t!("tinymist-query.code-action.exportHtml", "Export HTML"),
|
||||
vec!["export-html".into()],
|
||||
));
|
||||
doc_lens("HTML", vec!["export-html".into()]);
|
||||
} else {
|
||||
res.push(doc_lens(
|
||||
&tinymist_l10n::t!("tinymist-query.code-action.exportPdf", "Export PDF"),
|
||||
vec!["export-pdf".into()],
|
||||
));
|
||||
doc_lens("PDF", vec!["export-pdf".into()]);
|
||||
}
|
||||
|
||||
res.push(doc_lens(
|
||||
doc_lens(
|
||||
&tinymist_l10n::t!("tinymist-query.code-action.more", "More .."),
|
||||
vec!["more".into()],
|
||||
));
|
||||
);
|
||||
|
||||
Some(res)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -174,6 +174,7 @@ impl ServerState {
|
|||
allow_overlapping_token: const_config.tokens_overlapping_token_support,
|
||||
allow_multiline_token: const_config.tokens_multiline_token_support,
|
||||
remove_html: !config.support_html_in_markdown,
|
||||
support_client_codelens: true,
|
||||
extended_code_action: config.extended_code_action,
|
||||
completion_feat: config.completion.clone(),
|
||||
color_theme: match config.color_theme.as_deref() {
|
||||
|
|
|
|||
|
|
@ -202,8 +202,8 @@ async function languageActivate(context: IContext) {
|
|||
|
||||
const initTemplateCommand =
|
||||
(inPlace: boolean) =>
|
||||
(...args: string[]) =>
|
||||
initTemplate(context.context, inPlace, ...args);
|
||||
(...args: string[]) =>
|
||||
initTemplate(context.context, inPlace, ...args);
|
||||
|
||||
// prettier-ignore
|
||||
context.subscriptions.push(
|
||||
|
|
@ -556,6 +556,10 @@ async function commandRunCodeLens(...args: string[]): Promise<void> {
|
|||
void vscode.commands.executeCommand(`typst-preview.preview`);
|
||||
return;
|
||||
}
|
||||
case "export": {
|
||||
void vscode.commands.executeCommand(`tinymist.openExportTool`);
|
||||
break;
|
||||
}
|
||||
case "export-html": {
|
||||
await commandShow("Html");
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -5,13 +5,9 @@
|
|||
en = "rootPath or typstExtraArgs.root must be an absolute path: {root:?}"
|
||||
zh = "rootPath 或 typstExtraArgs.root 必须是绝对路径:{root:?}"
|
||||
|
||||
[tinymist-query.code-action.exportHtml]
|
||||
en = "Export HTML"
|
||||
zh = "导出 HTML"
|
||||
|
||||
[tinymist-query.code-action.exportPdf]
|
||||
en = "Export PDF"
|
||||
zh = "导出 PDF"
|
||||
[tinymist-query.code-action.export]
|
||||
en = "Export"
|
||||
zh = "导出"
|
||||
|
||||
[tinymist-query.code-action.more]
|
||||
en = "More .."
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import van from "vanjs-core";
|
||||
|
||||
const { div, h3, button } = van.tags;
|
||||
const { div, button } = van.tags;
|
||||
|
||||
interface ActionButtonsProps {
|
||||
onExport: () => void;
|
||||
|
|
@ -10,8 +10,6 @@ export const ActionButtons = ({ onExport }: ActionButtonsProps) => {
|
|||
return div(
|
||||
{ class: "flex flex-col gap-sm" },
|
||||
|
||||
h3("Export Actions"),
|
||||
|
||||
// Action Buttons
|
||||
div(
|
||||
{ class: "action-buttons flex items-center gap-md" },
|
||||
|
|
@ -23,7 +21,7 @@ export const ActionButtons = ({ onExport }: ActionButtonsProps) => {
|
|||
class: "btn action-button",
|
||||
onclick: onExport,
|
||||
},
|
||||
"📄 Export",
|
||||
"Export",
|
||||
),
|
||||
|
||||
// Create Task Button
|
||||
|
|
@ -33,7 +31,6 @@ export const ActionButtons = ({ onExport }: ActionButtonsProps) => {
|
|||
class: "btn btn-secondary action-button",
|
||||
onclick: handleCreateTask,
|
||||
},
|
||||
"⚙️",
|
||||
"Create Task",
|
||||
), */
|
||||
),
|
||||
|
|
|
|||
|
|
@ -26,11 +26,11 @@ const FormatCard = (format: ExportFormat, isSelected: boolean, onSelect: () => v
|
|||
return div(
|
||||
{
|
||||
class: `format-card ${isSelected ? "selected" : ""}`,
|
||||
title: format.label,
|
||||
onclick: onSelect,
|
||||
},
|
||||
div(
|
||||
{ class: "flex justify-between items-center" },
|
||||
span({ class: "font-semibold" }, format.label),
|
||||
span({ class: "badge font-mono" }, `.${format.fileExtension}`),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
import van, { type ChildDom } from "vanjs-core";
|
||||
|
||||
const { div, h1, p } = van.tags;
|
||||
|
||||
interface HeaderProps {
|
||||
title?: string;
|
||||
description?: string;
|
||||
actions?: ChildDom;
|
||||
}
|
||||
|
||||
export const Header =
|
||||
(props: HeaderProps = {}) =>
|
||||
() => {
|
||||
const {
|
||||
title = "Export Tool",
|
||||
description = "Configure and export your Typst documents to various formats",
|
||||
actions,
|
||||
} = props;
|
||||
|
||||
return div(
|
||||
{ class: "card flex flex-col gap-sm" },
|
||||
div(
|
||||
{ class: "flex flex-col sm:flex-row sm:justify-between sm:items-center gap-sm" },
|
||||
div(
|
||||
{ class: "flex flex-col gap-xs" },
|
||||
h1({ class: "text-xl font-semibold text-base-content" }, title),
|
||||
p({ class: "text-desc font-sm" }, description),
|
||||
),
|
||||
actions ? div({ class: "flex gap-xs" }, actions) : null,
|
||||
),
|
||||
);
|
||||
};
|
||||
|
|
@ -13,10 +13,13 @@ export const InputSection = ({ inputPath }: InputSectionProps) => {
|
|||
{ class: "flex flex-col gap-sm" },
|
||||
// Input Path Section
|
||||
div(
|
||||
{ class: "flex flex-col gap-xs" },
|
||||
h3({ class: "mb-xs" }, "Input Document"),
|
||||
{ class: "flex flex-row items-center gap-xs" },
|
||||
h3(
|
||||
{ class: "mb-xs", title: "Configure and export your Typst documents to various formats" },
|
||||
"Export Document",
|
||||
),
|
||||
input({
|
||||
class: "input",
|
||||
class: "input flex-1",
|
||||
type: "text",
|
||||
placeholder: () => lastFocusedTypstDoc.val || "Document Path",
|
||||
value: inputPath,
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ const PreviewEmpty = (onGenerate: () => void) => {
|
|||
class: "btn",
|
||||
onclick: onGenerate,
|
||||
},
|
||||
"Generate Preview",
|
||||
"Flush",
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import "./styles.css";
|
|||
|
||||
import { ActionButtons } from "./components/action-buttons";
|
||||
import { FormatSelector } from "./components/format-selector";
|
||||
import { Header } from "./components/header";
|
||||
import { InputSection } from "./components/inout";
|
||||
import { OptionsPanel } from "./components/options-panel";
|
||||
import { PreviewGrid } from "./components/preview-grid";
|
||||
|
|
@ -35,14 +34,14 @@ const ExportTool = () => {
|
|||
return div(
|
||||
{ class: "export-tool-container flex flex-col gap-lg text-base-content" },
|
||||
|
||||
Header({
|
||||
title: "Export Tool",
|
||||
description: "Configure and export your Typst documents to various formats",
|
||||
}),
|
||||
|
||||
// Input Document Section
|
||||
InputSection({ inputPath, outputPath }),
|
||||
|
||||
// Export Actions
|
||||
ActionButtons({
|
||||
onExport: exportDocument,
|
||||
}),
|
||||
|
||||
// Format Selection
|
||||
FormatSelector({ selectedFormat: format }),
|
||||
|
||||
|
|
@ -57,11 +56,6 @@ const ExportTool = () => {
|
|||
autoPreview,
|
||||
onPreview: generatePreview,
|
||||
}),
|
||||
|
||||
// Export Actions
|
||||
ActionButtons({
|
||||
onExport: exportDocument,
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -5,20 +5,21 @@
|
|||
max-width: 80rem;
|
||||
margin: auto;
|
||||
padding: 1rem;
|
||||
transition: padding 0.2s ease;
|
||||
}
|
||||
|
||||
/* Format Selector */
|
||||
.format-selector {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
grid-template-columns: repeat(auto-fit, 4rem);
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.format-card {
|
||||
padding: 1rem;
|
||||
padding: 0.5rem;
|
||||
background: var(--vscode-panel-background, #1e1e1e);
|
||||
border: 2px solid var(--vscode-panel-border, rgba(128, 128, 128, 0.35));
|
||||
border-radius: 0.5rem;
|
||||
border-radius: 0.3rem;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
position: relative;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue