Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ export function DefaultRichTextToolbarContent({
// todo: we could make this a prop
const actions = useMemo(() => {
function handleOp(name: string, op: string) {
// Check if the editor view is available before calling operations
if (!textEditor.view) return

trackEvent('rich-text', { operation: name as any, source })
// @ts-expect-error typing this is annoying at the moment.
textEditor.chain().focus()[op]().run()
Expand Down Expand Up @@ -109,7 +112,7 @@ export function DefaultRichTextToolbarContent({
}, [textEditor, trackEvent, onEditLinkStart])

return actions.map(({ name, attrs, onSelect }) => {
const isActive = textEditor.isActive(name, attrs)
const isActive = textEditor.view ? textEditor.isActive(name, attrs) : false
return (
<TldrawUiToolbarButton
key={name}
Expand Down
14 changes: 7 additions & 7 deletions templates/agent/shared/format/convertSimpleShapeToTldrawShape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function convertTextShapeToTldrawShape(
x: correctedTextCoords.x,
y: correctedTextCoords.y,
rotation: defaultTextShape.rotation ?? 0,
index: defaultTextShape.index ?? ('a1' as IndexKey),
index: defaultTextShape.index ?? editor.getHighestIndexForParent(editor.getCurrentPageId()),
parentId: defaultTextShape.parentId ?? editor.getCurrentPageId(),
isLocked: defaultTextShape.isLocked ?? false,
opacity: defaultTextShape.opacity ?? 1,
Expand Down Expand Up @@ -242,7 +242,7 @@ function convertLineShapeToTldrawShape(
x: minX,
y: minY,
rotation: defaultLineShape.rotation ?? 0,
index: defaultLineShape.index ?? ('a1' as IndexKey),
index: defaultLineShape.index ?? editor.getHighestIndexForParent(editor.getCurrentPageId()),
parentId: defaultLineShape.parentId ?? editor.getCurrentPageId(),
isLocked: defaultLineShape.isLocked ?? false,
opacity: defaultLineShape.opacity ?? 1,
Expand Down Expand Up @@ -306,7 +306,7 @@ function convertArrowShapeToTldrawShape(
x: minX,
y: minY,
rotation: defaultArrowShape.rotation ?? 0,
index: defaultArrowShape.index ?? ('a1' as IndexKey),
index: defaultArrowShape.index ?? editor.getHighestIndexForParent(editor.getCurrentPageId()),
parentId: defaultArrowShape.parentId ?? editor.getCurrentPageId(),
isLocked: defaultArrowShape.isLocked ?? false,
opacity: defaultArrowShape.opacity ?? 1,
Expand Down Expand Up @@ -423,7 +423,7 @@ function convertGeoShapeToTldrawShape(
x: simpleShape.x ?? defaultGeoShape.x ?? 0,
y: simpleShape.y ?? defaultGeoShape.y ?? 0,
rotation: defaultGeoShape.rotation ?? 0,
index: defaultGeoShape.index ?? ('a1' as IndexKey),
index: defaultGeoShape.index ?? editor.getHighestIndexForParent(editor.getCurrentPageId()),
parentId: defaultGeoShape.parentId ?? editor.getCurrentPageId(),
isLocked: defaultGeoShape.isLocked ?? false,
opacity: defaultGeoShape.opacity ?? 1,
Expand Down Expand Up @@ -478,7 +478,7 @@ function convertNoteShapeToTldrawShape(
x: simpleShape.x ?? defaultNoteShape.x ?? 0,
y: simpleShape.y ?? defaultNoteShape.y ?? 0,
rotation: defaultNoteShape.rotation ?? 0,
index: defaultNoteShape.index ?? ('a1' as IndexKey),
index: defaultNoteShape.index ?? editor.getHighestIndexForParent(editor.getCurrentPageId()),
parentId: defaultNoteShape.parentId ?? editor.getCurrentPageId(),
isLocked: defaultNoteShape.isLocked ?? false,
opacity: defaultNoteShape.opacity ?? 1,
Expand Down Expand Up @@ -528,7 +528,7 @@ function convertDrawShapeToTldrawShape(
x: defaultDrawShape.x ?? 0,
y: defaultDrawShape.y ?? 0,
rotation: defaultDrawShape.rotation ?? 0,
index: defaultDrawShape.index ?? ('a1' as IndexKey),
index: defaultDrawShape.index ?? editor.getHighestIndexForParent(editor.getCurrentPageId()),
parentId: defaultDrawShape.parentId ?? editor.getCurrentPageId(),
isLocked: defaultDrawShape.isLocked ?? false,
opacity: defaultDrawShape.opacity ?? 1,
Expand Down Expand Up @@ -558,7 +558,7 @@ function convertUnknownShapeToTldrawShape(
x: simpleShape.x ?? defaultShape.x ?? 0,
y: simpleShape.y ?? defaultShape.y ?? 0,
rotation: defaultShape.rotation ?? 0,
index: defaultShape.index ?? ('a1' as IndexKey),
index: defaultShape.index ?? editor.getHighestIndexForParent(editor.getCurrentPageId()),
parentId: defaultShape.parentId ?? editor.getCurrentPageId(),
isLocked: defaultShape.isLocked ?? false,
opacity: defaultShape.opacity ?? 1,
Expand Down
Loading