Skip to content

Commit

Permalink
Pro extension docs changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisDavidRichard committed Jun 27, 2024
1 parent 8fea3e9 commit 5c9466d
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/content/collaboration/documents/history.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ This should automatically happen if you are using NPM (as it automatically resol
| status | `string` | The status of the provider - can be `connecting`, `connected` or `disconnected` |
| synced | `boolean` | Is the version history synced with the server |
| versioningEnabled | `boolean` | Is versioning enabled |
| versions | `array` | The array of versions that are stored in the history. |
| versions | `array<Version>` | The array of versions that are stored in the history. |

## Commands

Expand Down Expand Up @@ -115,7 +115,7 @@ const editor = new Editor({
provider,
onUpdate(payload) {
currentVersion = payload.currentVersion
latestVersion = payload.latestVersion
latestVersion = payload.version
versions = payload.versions
autoversioningEnabled = payload.autoVersioning
},
Expand Down Expand Up @@ -190,12 +190,12 @@ Start by attaching a listener to the provider:
```js

// Import the getPreviewContentFromVersionPayload helper function (refer to details below)
import { watchContent } from '@tiptap-pro/extension-collaboration-history'
import { watchPreviewContent } from '@tiptap-pro/extension-collaboration-history'

// Configure the provider
const provider = new TiptapCollabProvider({ ... })

// use the watchContent util function to watch for content changes on the provider
// use the watchPreviewContent util function to watch for content changes on the provider
const unbindWatchContent = watchPreviewContent(provider, content => {
// set your editors content
editor.commands.setContent(content)
Expand Down
51 changes: 51 additions & 0 deletions src/content/editor/extensions/functionality/mathematics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,39 @@ import 'katex/dist/katex.min.css'
}
```

### Control when to render LaTeX decorations

By default LaTeX decorations for mathematical expressions are rendered when said expression is not inside a code block. If you want to customize this behavior, you can do so by passing a function to the `shouldRender` option. This function should return a boolean value indicating whether the LaTeX decorations should be rendered or not.

```js
import Mathematics from '@tiptap-pro/extension-mathematics'

// [...]

Mathematics.configure({
shouldRender: (state, pos, node) => {
const $pos = state.doc.resolve(pos)
return node.type.name === 'text' && $pos.parent.type.name !== 'codeBlock'
}
})
```

You can also import the default `shouldRender` function to extend the default behavior:

```js

import Mathematics, { shouldRender } from '@tiptap-pro/extension-mathematics'

// [...]

Mathematics.configure({
shouldRender: (state, pos, node) => {
// this will disable rendering for headings & code blocks
return shouldRender(state, pos, node) && node.type.name !== 'heading'
}
})
```

## Settings

### regex
Expand All @@ -82,3 +115,21 @@ Mathematics.configure({
},
})
```
### shouldRender

By default LaTeX decorations for mathematical expressions are rendered when said expression is not inside a code block. If you want to customize this behavior, you can do so by passing a function to the `shouldRender` option. This function should return a boolean value indicating whether the LaTeX decorations should be rendered or not.

Default: `() => true`

```js
import Mathematics from '@tiptap-pro/extension-mathematics'

// [...]

Mathematics.configure({
shouldRender: (state, pos, node) => {
const $pos = state.doc.resolve(pos)
return node.type.name === 'text' && $pos.parent.type.name !== 'codeBlock'
}
})
```

0 comments on commit 5c9466d

Please sign in to comment.