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 @@ -35,26 +35,18 @@ import { LiveCollaborationManager } from 'core-stimulus/helpers/live-collaborati
export default class extends Controller {
static values = {
hocuspocusUrl: String,
openProjectUrl: String,
oauthToken: String,
documentName: String,
documentId: String,
};

declare readonly hocuspocusUrlValue:string;
declare readonly openProjectUrlValue:string;
declare readonly oauthTokenValue:string;
declare readonly documentNameValue:string;
declare readonly documentIdValue:string;

connect():void {
const url = new URL(this.hocuspocusUrlValue);
url.searchParams.set('document_id', this.documentIdValue);
url.searchParams.set('openproject_base_path', this.openProjectUrlValue);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's so nice how this turned out 🤩


LiveCollaborationManager.initializeYjsProvider(
new HocuspocusProvider({
url: url.toString(),
url: this.hocuspocusUrlValue,
name: this.documentNameValue,
token: this.oauthTokenValue,
document: LiveCollaborationManager.ydoc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@
helpers.content_controller(
"documents--init-yjs-provider",
"documents--init-yjs-provider-hocuspocus-url-value": Setting.collaborative_editing_hocuspocus_url,
"documents--init-yjs-provider-open-project-url-value": root_url,
"documents--init-yjs-provider-oauth-token-value": oauth_token,
"documents--init-yjs-provider-document-name-value": document.title,
"documents--init-yjs-provider-document-id-value": document.id
"documents--init-yjs-provider-document-name-value": resource_url
)
%>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ class BlockNoteEditorComponent < ApplicationComponent
alias_method :document, :model

options :project, :oauth_token, :state

private

def resource_url
URI.join(
root_url,
API::V3::Utilities::PathHelper::ApiV3Path.document(document.id)
).to_s
end
end
end
end
Loading