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