Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Moor committed Oct 13, 2020
1 parent 6811a2e commit 7d1b470
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export const createNodeFromYElement = (el, schema, mapping, snapshot, prevSnapsh
// an error occured while creating the node. This is probably a result of a concurrent action.
/** @type {Y.Doc} */ (el.doc).transact(transaction => {
/** @type {Y.Item} */ (el._item).delete(transaction)
}, ySyncPluginKey)
}, ySyncPluginKey)
mapping.delete(el)
return null
}
Expand Down Expand Up @@ -285,7 +285,7 @@ export const createTextNodesFromYText = (text, schema, mapping, snapshot, prevSn
// an error occured while creating the node. This is probably a result of a concurrent action.
/** @type {Y.Doc} */ (text.doc).transact(transaction => {
/** @type {Y.Item} */ (text._item).delete(transaction)
}, ySyncPluginKey)
}, ySyncPluginKey)
return null
}
// @ts-ignore
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/cursor-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ export const createDecorations = (state, awareness, createCursor) => {
export const yCursorPlugin = (awareness, { cursorBuilder = defaultCursorBuilder, getSelection = state => state.selection } = {}, cursorStateField = 'cursor') => new Plugin({
key: yCursorPluginKey,
state: {
init(_, state) {
init (_, state) {
return createDecorations(state, awareness, cursorBuilder)
},
apply(tr, prevState, oldState, newState) {
apply (tr, prevState, oldState, newState) {
const ystate = ySyncPluginKey.getState(newState)
const yCursorState = tr.getMeta(yCursorPluginKey)
if ((ystate && ystate.isChangeOrigin) || (yCursorState && yCursorState.awarenessUpdated)) {
Expand Down
24 changes: 12 additions & 12 deletions src/plugins/sync-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export class ProsemirrorBinding {
* @param {Y.XmlFragment} yXmlFragment The bind source
* @param {any} prosemirrorView The target binding
*/
constructor(yXmlFragment, prosemirrorView) {
constructor (yXmlFragment, prosemirrorView) {
this.type = yXmlFragment
this.prosemirrorView = prosemirrorView
this.mux = createMutex()
Expand Down Expand Up @@ -205,7 +205,7 @@ export class ProsemirrorBinding {
this._domSelectionInView = null
}

_isLocalCursorInView() {
_isLocalCursorInView () {
if (!this.prosemirrorView.hasFocus()) return false
if (environment.isBrowser && this._domSelectionInView === null) {
// Calculte the domSelectionInView and clear by next tick after all events are finished
Expand All @@ -217,7 +217,7 @@ export class ProsemirrorBinding {
return this._domSelectionInView
}

_isDomSelectionInView() {
_isDomSelectionInView () {
const selection = this.prosemirrorView._root.getSelection()

const range = this.prosemirrorView._root.createRange()
Expand All @@ -232,14 +232,14 @@ export class ProsemirrorBinding {
bounding.top <= (window.innerHeight || documentElement.clientHeight || 0)
}

renderSnapshot(snapshot, prevSnapshot) {
renderSnapshot (snapshot, prevSnapshot) {
if (!prevSnapshot) {
prevSnapshot = Y.createSnapshot(Y.createDeleteSet(), new Map())
}
this.prosemirrorView.dispatch(this.prosemirrorView.state.tr.setMeta(ySyncPluginKey, { snapshot, prevSnapshot }))
}

unrenderSnapshot() {
unrenderSnapshot () {
this.mapping = new Map()
this.mux(() => {
const fragmentContent = this.type.toArray().map(t => createNodeFromYElement(/** @type {Y.XmlElement} */(t), this.prosemirrorView.state.schema, this.mapping)).filter(n => n !== null)
Expand All @@ -250,7 +250,7 @@ export class ProsemirrorBinding {
})
}

_forceRerender() {
_forceRerender () {
this.mapping = new Map()
this.mux(() => {
const fragmentContent = this.type.toArray().map(t => createNodeFromYElement(/** @type {Y.XmlElement} */(t), this.prosemirrorView.state.schema, this.mapping)).filter(n => n !== null)
Expand All @@ -265,7 +265,7 @@ export class ProsemirrorBinding {
* @param {Y.Snapshot} prevSnapshot
* @param {Object} pluginState
*/
_renderSnapshot(snapshot, prevSnapshot, pluginState) {
_renderSnapshot (snapshot, prevSnapshot, pluginState) {
if (!snapshot) {
snapshot = Y.snapshot(this.doc)
}
Expand Down Expand Up @@ -310,7 +310,7 @@ export class ProsemirrorBinding {
* @param {Array<Y.YEvent>} events
* @param {Y.Transaction} transaction
*/
_typeChanged(events, transaction) {
_typeChanged (events, transaction) {
const syncState = ySyncPluginKey.getState(this.prosemirrorView.state)
if (events.length === 0 || syncState.snapshot != null || syncState.prevSnapshot != null) {
// drop out if snapshot is active
Expand Down Expand Up @@ -338,7 +338,7 @@ export class ProsemirrorBinding {
})
}

_prosemirrorChanged(doc) {
_prosemirrorChanged (doc) {
this.mux(() => {
this.doc.transact(() => {
updateYFragment(this.doc, this.type, doc, this.mapping)
Expand All @@ -347,7 +347,7 @@ export class ProsemirrorBinding {
})
}

destroy() {
destroy () {
this.type.unobserveDeep(this._observeFunction)
}
}
Expand Down Expand Up @@ -402,7 +402,7 @@ export const createNodeFromYElement = (el, schema, mapping, snapshot, prevSnapsh
// an error occured while creating the node. This is probably a result of a concurrent action.
/** @type {Y.Doc} */ (el.doc).transact(transaction => {
/** @type {Y.Item} */ (el._item).delete(transaction)
}, ySyncPluginKey)
}, ySyncPluginKey)
mapping.delete(el)
return null
}
Expand Down Expand Up @@ -434,7 +434,7 @@ export const createTextNodesFromYText = (text, schema, mapping, snapshot, prevSn
// an error occured while creating the node. This is probably a result of a concurrent action.
/** @type {Y.Doc} */ (text.doc).transact(transaction => {
/** @type {Y.Item} */ (text._item).delete(transaction)
}, ySyncPluginKey)
}, ySyncPluginKey)
return null
}
// @ts-ignore
Expand Down

0 comments on commit 7d1b470

Please sign in to comment.