Skip to content

Commit

Permalink
fiddling
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Sep 12, 2023
1 parent 2ee3299 commit 76b1a31
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mergeAttributes, Node, NodeViewProps } from '@tiptap/core'
import { NodeViewWrapper, ReactNodeViewRenderer } from '@tiptap/react'
import { callOrReturn, getExtensionField, NodeViewWrapper, ReactNodeViewRenderer } from '@tiptap/react'
import { NotebookNodeType, NotebookTarget } from '~/types'
import {
sessionRecordingPlayerLogic,
Expand Down Expand Up @@ -75,6 +75,25 @@ export const NotebookNodeReplayTimestamp = Node.create({
group: 'inline',
atom: true,

serializedText:
() =>
(attrs: { playbackTime: number }): string => {
// timestamp is not a block so `getText` does not add a separator.
// we need to add it manually
return `${formatTimestamp(attrs.playbackTime) || '00:00'}:\n`
},

extendNodeSchema(extension) {
const context = {
name: extension.name,
options: extension.options,
storage: extension.storage,
}
return {
serializedText: callOrReturn(getExtensionField(extension, 'serializedText', context)),
}
},

addAttributes() {
return {
playbackTime: { default: null, keepOnSplit: false },
Expand Down
7 changes: 1 addition & 6 deletions frontend/src/scenes/notebooks/Notebook/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
import { Node as PMNode } from '@tiptap/pm/model'
import { NodeViewProps } from '@tiptap/react'
import { NotebookNodeType } from '~/types'
import { formatTimestamp } from 'scenes/notebooks/Nodes/NotebookNodeReplayTimestamp'

export interface Node extends PMNode {}
export interface JSONContent extends TTJSONContent {}
Expand Down Expand Up @@ -114,11 +113,7 @@ export const textContent = (node: any): string => {
'ph-query': customOrTitleSerializer,
'ph-recording': customOrTitleSerializer,
'ph-recording-playlist': customOrTitleSerializer,
'ph-replay-timestamp': (props): string => {
// timestamp is not a block so `getText` does not add a separator.
// we need to add it manually
return `${formatTimestamp(props.node.attrs.playbackTime) || '00:00'}:\n`
},
'ph-replay-timestamp': customOrTitleSerializer,
'ph-survey': customOrTitleSerializer,
}

Expand Down

0 comments on commit 76b1a31

Please sign in to comment.