Skip to content

Commit

Permalink
rename onInitialApply to onFirstRender
Browse files Browse the repository at this point in the history
  • Loading branch information
dmonad committed May 13, 2022
1 parent d1f4055 commit f2f8365
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/plugins/sync-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const isVisible = (item, snapshot) => snapshot === undefined ? !item.dele
* @property {Array<ColorDef>} [YSyncOpts.colors]
* @property {Map<string,ColorDef>} [YSyncOpts.colorMapping]
* @property {Y.PermanentUserData|null} [YSyncOpts.permanentUserData]
* @property {() => void} [YSyncOpts.onInitialApply]
* @property {function} [YSyncOpts.onFirstRender] Fired when the content from Yjs is initially rendered to ProseMirror
*/

/**
Expand Down Expand Up @@ -75,7 +75,12 @@ const getUserColor = (colorMapping, colors, user) => {
* @param {YSyncOpts} opts
* @return {any} Returns a prosemirror plugin that binds to this type
*/
export const ySyncPlugin = (yXmlFragment, { colors = defaultColors, colorMapping = new Map(), permanentUserData = null, onInitialApply = () => {} } = {}) => {
export const ySyncPlugin = (yXmlFragment, {
colors = defaultColors,
colorMapping = new Map(),
permanentUserData = null,
onFirstRender = () => {}
} = {}) => {
let changedInitialContent = false
let rerenderTimeoutId
const plugin = new Plugin({
Expand Down Expand Up @@ -142,7 +147,7 @@ export const ySyncPlugin = (yXmlFragment, { colors = defaultColors, colorMapping
rerenderTimeoutId = eventloop.timeout(0, () => {
binding._forceRerender()
view.dispatch(view.state.tr.setMeta(ySyncPluginKey, { binding }))
onInitialApply()
onFirstRender()
})
return {
update: () => {
Expand Down

0 comments on commit f2f8365

Please sign in to comment.