Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions src/editor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
import { applyAwarenessUpdate, removeAwarenessStates } from 'y-protocols/awareness';
import * as encoding from 'lib0/encoding';

import { createShareFormattingBar } from './share-formatting-bar';
import { proofMarkPlugins } from './schema/proof-marks';
import { codeBlockExtPlugins } from './schema/code-block-ext';
import { frontmatterSchema } from './schema/frontmatter';
Expand Down Expand Up @@ -1004,6 +1005,7 @@ class ProofEditorImpl implements ProofEditor {
private isReadOnly: boolean = false;
private shareAllowLocalEdits: boolean = true;
private shareContentFilterEnabled: boolean = false;
private shareFormattingBar: HTMLElement | null = null;
private readOnlyBanner: HTMLElement | null = null;
private reviewLockCount: number = 0;
private reviewLockReason: string | null = null;
Expand Down Expand Up @@ -1272,6 +1274,16 @@ class ProofEditorImpl implements ProofEditor {
// If in share mode, load from share server
if (this.isShareMode) {
await this.initFromShare();

// Formatting bar — right rail (desktop) / bottom dock (mobile).
const bar = createShareFormattingBar(
() => this.editor?.ctx.get(editorViewCtx) ?? null,
);
const container = document.getElementById('editor-container');
if (container) {
container.appendChild(bar);
}
this.shareFormattingBar = bar;
}
}

Expand Down Expand Up @@ -4758,10 +4770,7 @@ class ProofEditorImpl implements ProofEditor {
}
}

if (this.isShareMode) {
document.documentElement.style.background = '#fff';
document.body.style.background = '#fff';
}
document.body.dataset.shareMode = this.isShareMode ? 'true' : 'false';
}

private updateBannerLayout(): void {
Expand Down Expand Up @@ -4795,6 +4804,16 @@ class ProofEditorImpl implements ProofEditor {
&& this.reviewLockCount === 0
&& (!this.isShareMode || this.shareAllowLocalEdits);

if (this.shareFormattingBar) {
this.shareFormattingBar.classList.toggle('visible', isEditable);
if (typeof (this.shareFormattingBar as any).__fmtSetEditable === 'function') {
(this.shareFormattingBar as any).__fmtSetEditable(isEditable);
}
if (!isEditable) {
delete document.body.dataset.shareContextualToolbarVisible;
}
}

const applyEditableState = (view: EditorView) => {
view.setProps({
editable: () => isEditable,
Expand Down
Loading