Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,13 @@ function calculateMarkerWidth(dom, numberingDOM, { withPadding = true } = {}) {

if (!markerText.trim()) return 0;

// Check if canvas is available (browser environment)
if (typeof document === 'undefined' || !document.createElement('canvas').getContext) {
// Simple estimation for server-side: ~8px per character
const textWidth = markerText.length * 8;
Comment thread
caio-pizzol marked this conversation as resolved.
return withPadding ? textWidth + MARKER_PADDING : textWidth;
}

try {
const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
Expand Down
7 changes: 6 additions & 1 deletion packages/superdoc/src/core/SuperDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@
/**
* Initialize telemetry service.
*/
#initTelemetry() {

Check warning on line 406 in packages/superdoc/src/core/SuperDoc.js

View workflow job for this annotation

GitHub Actions / Lint & Format Check

'#initTelemetry' is defined but never used
this.telemetry = new Telemetry({
enabled: this.config.telemetry?.enabled ?? true,
licenseKey: this.config.telemetry?.licenseKey,
Expand Down Expand Up @@ -807,10 +807,12 @@
async #triggerCollaborationSaves() {
this.#log('🦋 [superdoc] Triggering collaboration saves');
return new Promise((resolve) => {
this.superdocStore.documents.forEach((doc) => {
this.superdocStore.documents.forEach((doc, index) => {
this.#log(`Before reset - Doc ${index}: pending = ${this.pendingCollaborationSaves}`);
this.pendingCollaborationSaves = 0;
if (doc.ydoc) {
this.pendingCollaborationSaves++;
this.#log(`After increment - Doc ${index}: pending = ${this.pendingCollaborationSaves}`);
const metaMap = doc.ydoc.getMap('meta');
metaMap.observe((event) => {
if (event.changes.keys.has('immediate-save-finished')) {
Expand All @@ -823,6 +825,9 @@
metaMap.set('immediate-save', true);
}
});
this.#log(
`FINAL pending = ${this.pendingCollaborationSaves}, but we have ${this.superdocStore.documents.filter((d) => d.ydoc).length} docs!`,
);
});
}

Expand Down