Fix tiptap selection sync and toolbar event loop

This commit is contained in:
lix-2026
2026-04-19 21:03:25 +08:00
parent 111a87d4fd
commit 394e2a155c
87 changed files with 17415 additions and 527 deletions
@@ -7,7 +7,9 @@ use bridge_runtime::{
RuntimeExecutionPlan, RuntimeInput, RuntimeQueryEnvelopeWire, RuntimeQueryExecutionPlan,
RuntimeSourceWire,
};
use core_protocol::{GetPageMeta, QueryEnvelope};
use serde_json::Value;
use storage_convex_bridge::{build_query_request, BridgeContext};
pub fn resolve_effective_workspace_id(
context: &RequestContext,
@@ -77,6 +79,31 @@ pub fn runtime_context(
}
}
fn storage_context(
context: &RequestContext,
effective_workspace_id: Option<&str>,
) -> BridgeContext {
BridgeContext {
deployment_id: context.workspace.deployment_id.clone(),
project_id: context.workspace.project_id.clone(),
request_id: context.trace.request_id.clone(),
trace_id: context.trace.trace_id.clone(),
actor_type: context.auth.actor_type.clone(),
actor_id: context.auth.actor_id.clone(),
session_id: context.auth.session_id.clone(),
workspace_id: effective_workspace_id
.map(ToOwned::to_owned)
.or_else(|| context.workspace.workspace_id.clone()),
tenant_id: context.workspace.tenant_id.clone(),
auth_token: context.auth.authorization.clone(),
source_channel: context.source.channel.clone(),
source_client: context.source.client.clone(),
idempotency_key: context.source.idempotency_key.clone(),
validate_only: false,
dry_run: false,
}
}
pub fn build_runtime_query_plan(
context: &RequestContext,
effective_workspace_id: Option<&str>,
@@ -96,6 +123,34 @@ pub fn build_runtime_query_plan(
Ok(plan)
}
pub fn build_documents_meta_query_plan(
context: &RequestContext,
effective_workspace_id: Option<&str>,
document_id: &str,
) -> Result<RuntimeQueryExecutionPlan, WebError> {
let query = QueryEnvelope {
name: "documents.meta.get".into(),
payload: GetPageMeta {
page_id: document_id.to_string(),
workspace_id: effective_workspace_id.map(ToOwned::to_owned),
},
};
let request = build_query_request(&storage_context(context, effective_workspace_id), &query)
.map_err(|error| WebError::bad_request(error.message).with_context(context))?;
Ok(RuntimeQueryExecutionPlan {
query_name: query.name,
function_name: request.function_name,
workspace_id: request.workspace_id,
request_id: request.request_id,
trace_id: request.trace_id,
actor_id: request.actor_id,
payload_json: request.payload_json,
args_json: serde_json::json!({
"id": document_id,
}),
})
}
pub async fn fetch_query_data_via_convex(
config: &AppConfig,
context: &RequestContext,
@@ -106,6 +161,16 @@ pub async fn fetch_query_data_via_convex(
execute_convex_query_plan(config, context, &plan).await
}
pub async fn fetch_documents_meta_via_convex(
config: &AppConfig,
context: &RequestContext,
effective_workspace_id: Option<&str>,
document_id: &str,
) -> Result<Value, WebError> {
let plan = build_documents_meta_query_plan(context, effective_workspace_id, document_id)?;
execute_convex_query_plan(config, context, &plan).await
}
pub fn execute_runtime_query_against_data(
context: &RequestContext,
effective_workspace_id: Option<&str>,