feat: convert TypstDocument to enum (#1256)

* feat: convert `TypstDocument` to enum

* fix: errors

* build: update cargo.lock

* fix: warnings

* fix: error

* html changes

* Revert "html changes"

This reverts commit f9fc0e4872.

* Revert "Revert "html changes""

This reverts commit 7dc554a9e4.

* use std typst docs

* span

* paged

* paged

* html change

* paged

* html change

* bytes

* paged

* paged

* paged

* html changes

* paged

* html changes

* paged
This commit is contained in:
Myriad-Dreamin 2025-02-03 11:17:58 +08:00 committed by GitHub
parent 30a08e79ab
commit 3bc5f19cf5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 237 additions and 123 deletions

View file

@ -13,6 +13,7 @@ rust-version.workspace = true
[dependencies]
typst.workspace = true
tinymist-assets.workspace = true
tinymist-std.workspace = true
typst-assets.workspace = true
comemo.workspace = true

View file

@ -4,8 +4,8 @@ use std::sync::Arc;
use reflexo_typst::debug_loc::{
CharPosition, DocumentPosition, ElementPoint, SourceLocation, SourceSpanOffset,
};
use reflexo_typst::TypstDocument;
use reflexo_vec2svg::IncrSvgDocServer;
use tinymist_std::typst::TypstDocument;
use tokio::sync::{broadcast, mpsc};
use super::{editor::EditorActorRequest, webview::WebviewActorRequest};
@ -138,6 +138,9 @@ impl RenderActor {
log::info!("RenderActor: document is not ready");
continue;
};
let TypstDocument::Paged(document) = document;
let data = if has_full_render {
if let Some(data) = self.renderer.pack_current() {
data

View file

@ -15,8 +15,8 @@ use futures::sink::SinkExt;
use once_cell::sync::OnceCell;
use reflexo_typst::debug_loc::SourceSpanOffset;
use reflexo_typst::Error;
use reflexo_typst::TypstDocument as Document;
use serde::{Deserialize, Serialize};
use tinymist_std::typst::TypstDocument;
use tokio::sync::{broadcast, mpsc};
use typst::{layout::Position, syntax::Span};
@ -355,7 +355,7 @@ pub struct MemoryFilesShort {
pub trait CompileView: Send + Sync {
/// Get the compiled document.
fn doc(&self) -> Option<Arc<Document>>;
fn doc(&self) -> Option<TypstDocument>;
/// Get the compile status.
fn status(&self) -> CompileStatus;

View file

@ -1,8 +1,8 @@
use std::num::NonZeroUsize;
use reflexo_typst::debug_loc::DocumentPosition;
use reflexo_typst::TypstDocument;
use serde::{Deserialize, Serialize};
use tinymist_std::typst::TypstDocument;
use typst::foundations::{Content, NativeElement, Packed, StyleChain};
use typst::introspection::Introspector;
use typst::model::HeadingElem;
@ -140,7 +140,7 @@ struct OutlineItem {
}
pub fn outline(interner: &mut SpanInternerImpl, document: &TypstDocument) -> Outline {
let outline = get_outline(&document.introspector);
let outline = get_outline(document.introspector());
let mut items = Vec::with_capacity(outline.as_ref().map_or(0, Vec::len));
for heading in outline.iter().flatten() {