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
21 changes: 16 additions & 5 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion plugins/text-editor-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"rfc6902": "^5.0.1",
"diff": "^5.1.0",
"slugify": "^1.6.6",
"lib0": "^0.2.88"
"lib0": "^0.2.88",
"y-indexeddb": "^9.0.12"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import { deleteAttachment } from '../command/deleteAttachment'
import { textEditorCommandHandler } from '../commands'
import { EditorKitOptions, getEditorKit } from '../../src/kits/editor-kit'
import { DirectStorageProvider } from '../provider/storage'
import { IndexeddbProvider } from '../provider/indexeddb'
import { TiptapCollabProvider } from '../provider/tiptap'
import { formatCollaborativeDocumentId, formatPlatformDocumentId } from '../provider/utils'
import textEditor, {
Expand Down Expand Up @@ -121,7 +121,7 @@
const ydoc = getContext<YDoc>(CollaborationIds.Doc) ?? new YDoc()
const contextProvider = getContext<TiptapCollabProvider>(CollaborationIds.Provider)

const localProvider = contextProvider === undefined ? new DirectStorageProvider(collaborativeDoc, ydoc) : undefined
const localProvider = new IndexeddbProvider(collaborativeDoc, ydoc)

const remoteProvider: TiptapCollabProvider =
contextProvider ??
Expand All @@ -142,7 +142,7 @@
$: loading = !localSynced && !remoteSynced
$: editable = !readonly && remoteSynced

void localProvider?.loaded.then(() => (localSynced = true))
void localProvider.loaded.then(() => (localSynced = true))
void remoteProvider.loaded.then(() => (remoteSynced = true))

let editor: Editor
Expand Down Expand Up @@ -480,7 +480,7 @@
if (contextProvider === undefined) {
remoteProvider.destroy()
}
localProvider?.destroy()
void localProvider.destroy()
})
</script>

Expand Down
32 changes: 32 additions & 0 deletions plugins/text-editor-resources/src/provider/indexeddb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// Copyright © 2024 Hardcore Engineering Inc.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
//
import { collaborativeDocParse, type CollaborativeDoc } from '@hcengineering/core'
import { type Doc as YDoc } from 'yjs'
import { IndexeddbPersistence } from 'y-indexeddb'

export class IndexeddbProvider extends IndexeddbPersistence {
loaded: Promise<void>

constructor (collaborativeDoc: CollaborativeDoc, doc: YDoc) {
const { documentId, versionId } = collaborativeDocParse(collaborativeDoc)
const name = `${documentId}/${versionId}`

super(name, doc)

this.loaded = new Promise((resolve) => {
this.on('synced', resolve)
})
}
}
71 changes: 0 additions & 71 deletions plugins/text-editor-resources/src/provider/storage.ts

This file was deleted.