Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hocuspocus/provider

Package Overview
Dependencies
Maintainers
5
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hocuspocus/provider - npm Package Compare versions

Comparing version 2.11.0 to 2.11.1

10

dist/packages/provider/src/TiptapCollabProvider.d.ts

@@ -48,12 +48,12 @@ import type { AbstractType, YArrayEvent } from 'yjs';

private getYThread;
createThread(data: Omit<TCollabThread, 'id' | 'createdAt' | 'updatedAt' | 'comments'>): TCollabThread | null;
updateThread(id: TCollabThread['id'], data: Partial<Pick<TCollabThread, 'data' | 'resolvedAt'>>): TCollabThread | null;
createThread(data: Omit<TCollabThread, 'id' | 'createdAt' | 'updatedAt' | 'comments'>): TCollabThread;
updateThread(id: TCollabThread['id'], data: Partial<Pick<TCollabThread, 'data' | 'resolvedAt'>>): TCollabThread;
deleteThread(id: TCollabThread['id']): void;
getThreadComments(threadId: TCollabThread['id']): TCollabComment[] | null;
getThreadComment(threadId: TCollabThread['id'], commentId: TCollabComment['id']): TCollabComment | null;
addComment(threadId: TCollabThread['id'], data: Omit<TCollabComment, 'id' | 'updatedAt' | 'createdAt'>): TCollabThread | null;
updateComment(threadId: TCollabThread['id'], commentId: TCollabComment['id'], data: Partial<Pick<TCollabComment, 'data' | 'content'>>): TCollabThread | null;
deleteComment(threadId: TCollabThread['id'], commentId: TCollabComment['id']): TCollabThread | null;
addComment(threadId: TCollabThread['id'], data: Omit<TCollabComment, 'id' | 'updatedAt' | 'createdAt'>): TCollabThread;
updateComment(threadId: TCollabThread['id'], commentId: TCollabComment['id'], data: Partial<Pick<TCollabComment, 'data' | 'content'>>): TCollabThread;
deleteComment(threadId: TCollabThread['id'], commentId: TCollabComment['id']): TCollabThread | null | undefined;
watchThreads(callback: () => void): void;
unwatchThreads(callback: () => void): void;
}
{
"name": "@hocuspocus/provider",
"version": "2.11.0",
"version": "2.11.1",
"description": "hocuspocus provider",

@@ -32,3 +32,3 @@ "homepage": "https://hocuspocus.dev",

"dependencies": {
"@hocuspocus/common": "^2.11.0",
"@hocuspocus/common": "^2.11.1",
"@lifeomic/attempt": "^3.0.2",

@@ -35,0 +35,0 @@ "lib0": "^0.2.87",

@@ -145,29 +145,41 @@ import type { AbstractType, YArrayEvent } from 'yjs'

createThread(data: Omit<TCollabThread, 'id' | 'createdAt' | 'updatedAt' | 'comments'>) {
const thread = new Y.Map()
thread.set('id', uuidv4())
thread.set('createdAt', (new Date()).toISOString())
thread.set('comments', new Y.Array())
let createdThread: TCollabThread = {} as TCollabThread
this.getYThreads().push([thread])
return this.updateThread(String(thread.get('id')), data)
this.document.transact(() => {
const thread = new Y.Map()
thread.set('id', uuidv4())
thread.set('createdAt', (new Date()).toISOString())
thread.set('comments', new Y.Array())
this.getYThreads().push([thread])
createdThread = this.updateThread(String(thread.get('id')), data)
})
return createdThread
}
updateThread(id: TCollabThread['id'], data: Partial<Pick<TCollabThread, 'data' | 'resolvedAt'>>) {
const thread = this.getYThread(id)
let updatedThread: TCollabThread = {} as TCollabThread
if (thread === null) {
return null
}
this.document.transact(() => {
const thread = this.getYThread(id)
thread.set('updatedAt', (new Date()).toISOString())
if (thread === null) {
return null
}
if (data.data) {
thread.set('data', data.data)
}
thread.set('updatedAt', (new Date()).toISOString())
if (data.resolvedAt || data.resolvedAt === null) {
thread.set('resolvedAt', data.resolvedAt)
}
if (data.data) {
thread.set('data', data.data)
}
return thread.toJSON() as TCollabThread
if (data.resolvedAt || data.resolvedAt === null) {
thread.set('resolvedAt', data.resolvedAt)
}
updatedThread = thread.toJSON() as TCollabThread
})
return updatedThread
}

@@ -206,43 +218,55 @@

addComment(threadId: TCollabThread['id'], data: Omit<TCollabComment, 'id' | 'updatedAt' | 'createdAt'>) {
const thread = this.getYThread(threadId)
let updatedThread: TCollabThread = {} as TCollabThread
if (thread === null) return null
this.document.transact(() => {
const thread = this.getYThread(threadId)
const commentMap = new Y.Map()
commentMap.set('id', uuidv4())
commentMap.set('createdAt', (new Date()).toISOString())
thread.get('comments').push([commentMap])
if (thread === null) return null
this.updateComment(threadId, String(commentMap.get('id')), data)
const commentMap = new Y.Map()
commentMap.set('id', uuidv4())
commentMap.set('createdAt', (new Date()).toISOString())
thread.get('comments').push([commentMap])
return thread.toJSON() as TCollabThread
this.updateComment(threadId, String(commentMap.get('id')), data)
updatedThread = thread.toJSON() as TCollabThread
})
return updatedThread
}
updateComment(threadId: TCollabThread['id'], commentId: TCollabComment['id'], data: Partial<Pick<TCollabComment, 'data' | 'content'>>) {
const thread = this.getYThread(threadId)
let updatedThread: TCollabThread = {} as TCollabThread
if (thread === null) return null
this.document.transact(() => {
const thread = this.getYThread(threadId)
let comment = null
// eslint-disable-next-line no-restricted-syntax
for (const c of thread.get('comments')) {
if (c.get('id') === commentId) {
comment = c
break
if (thread === null) return null
let comment = null
// eslint-disable-next-line no-restricted-syntax
for (const c of thread.get('comments')) {
if (c.get('id') === commentId) {
comment = c
break
}
}
}
if (comment === null) return null
if (comment === null) return null
comment.set('updatedAt', (new Date()).toISOString())
comment.set('updatedAt', (new Date()).toISOString())
if (data.data) {
comment.set('data', data.data)
}
if (data.data) {
comment.set('data', data.data)
}
if (data.content) {
comment.set('content', data.content)
}
if (data.content) {
comment.set('content', data.content)
}
return thread.toJSON() as TCollabThread
updatedThread = thread.toJSON() as TCollabThread
})
return updatedThread
}

@@ -264,3 +288,10 @@

if (commentIndex >= 0) {
// if the first comment of a thread is deleted we also
// delete the thread itself as the source comment is gone
if (commentIndex === 0) {
this.deleteThread(threadId)
return
}
if (commentIndex > 0) {
thread.get('comments').delete(commentIndex)

@@ -267,0 +298,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc