'use server';
-import { AppCardItem, CardItem, DocumentItem, EmbedItem, FrameItem, ImageItem, Item, ShapeItem, StickyNoteItem, TextItem } from '@mirohq/miro-api';
+import { AppCardItem, CardItem, Connector, DocumentItem, EmbedItem, FrameItem, ImageItem, Item, ShapeItem, StickyNoteItem, TextItem } from '@mirohq/miro-api';
import initMiroAPI from '../utils/initMiroAPI';
import { Path, Shape, Slide, Whiteboard, Image, neoboardWhiteboardWidth, neoboardWhiteboardHeight } from './neoboardTypes';
import { stripHtml } from 'string-strip-html';
const frames: {
frame: FrameItem;
children: (Item | AppCardItem | CardItem | DocumentItem | EmbedItem | ImageItem | ShapeItem | StickyNoteItem | TextItem)[];
+ connectors: Connector[];
}[] = [];
for await (const frame of framesGenerator) {
}
}
+ const connectors: Connector[] = [];
+ const connectorsRaw = board.getAllConnectors();
+ for await (const connector of connectorsRaw) {
+ // Check if the connector has start and end item IDs matching any of the items in the frame
+ if (connector.startItem && connector.endItem) {
+ if (children.some(c => c.id === connector.startItem?.id) && children.some(c => c.id === connector.endItem?.id)) {
+ connectors.push(connector);
+ }
+ }
+ }
+
frames.push({
- frame: frame as FrameItem, children
+ frame: frame as FrameItem,
+ children,
+ connectors
});
}
}
}
+ for (const connector of frameData.connectors) {
+ const startItem = frameData.children.find(c => c.id === connector.startItem?.id);
+ const endItem = frameData.children.find(c => c.id === connector.endItem?.id);
+ if (startItem && endItem) {
+ const path: Path = {
+ type: 'path',
+ kind: 'line',
+ position: {
+ x: startItem.position?.x ?? 0,
+ y: startItem.position?.y ?? 0,
+ },
+ // Relative to the position given above
+ points: [
+ // Start point
+ {
+ x: 0,
+ y: 0,
+ },
+ // End point
+ {
+ x: endItem.position?.x ? endItem.position.x - (startItem.position?.x ?? 0) : 0,
+ y: endItem.position?.y ? endItem.position.y - (startItem.position?.y ?? 0) : 0,
+ },
+ ],
+ strokeColor: connector.style?.color ?? '#1a1a1a',
+ endMarker: connector.style?.endStrokeCap === 'arrow' ? 'arrow-head-line' : undefined
+ };
+ slide.elements.push(path);
+ }
+ }
+
neoboard.whiteboard.slides.push(slide);
}