@m3ui-vue/m3ui-vue 1.2.2 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/API.md +3010 -376
- package/dist/MButton-Bl_BSUep.js +172 -0
- package/dist/MButton-Bl_BSUep.js.map +1 -0
- package/dist/MDialog-D_Yik8ou.js +173 -0
- package/dist/MDialog-D_Yik8ou.js.map +1 -0
- package/dist/MIconButton-DoNotQ9v.js +282 -0
- package/dist/MIconButton-DoNotQ9v.js.map +1 -0
- package/dist/MListItem-BxifHJdU.js +824 -0
- package/dist/MListItem-BxifHJdU.js.map +1 -0
- package/dist/MLoadingIndicator-BxbFhSX6.js +115 -0
- package/dist/MLoadingIndicator-BxbFhSX6.js.map +1 -0
- package/dist/MMenuItem-Bih0h4-n.js +604 -0
- package/dist/MMenuItem-Bih0h4-n.js.map +1 -0
- package/dist/MProgressBar-BCoruxA-.js +184 -0
- package/dist/MProgressBar-BCoruxA-.js.map +1 -0
- package/dist/MSeekBar-BeN9QcB3.js +435 -0
- package/dist/MSeekBar-BeN9QcB3.js.map +1 -0
- package/dist/MSegmentedButton-DL9JtJFX.js +65 -0
- package/dist/MSegmentedButton-DL9JtJFX.js.map +1 -0
- package/dist/MSlider-BVSbJlGS.js +691 -0
- package/dist/MSlider-BVSbJlGS.js.map +1 -0
- package/dist/MSpinner-C2SUnWk4.js +65 -0
- package/dist/MSpinner-C2SUnWk4.js.map +1 -0
- package/dist/MTextField-CEkWSZ2v.js +296 -0
- package/dist/MTextField-CEkWSZ2v.js.map +1 -0
- package/dist/MTooltip-CodJGEO-.js +756 -0
- package/dist/MTooltip-CodJGEO-.js.map +1 -0
- package/dist/_storageKeys-CYXsUBwK.js +18 -0
- package/dist/_storageKeys-CYXsUBwK.js.map +1 -0
- package/dist/_useEscapeStack-CjndQhqg.js +19 -0
- package/dist/_useEscapeStack-CjndQhqg.js.map +1 -0
- package/dist/api.json +1 -1
- package/dist/chart.js +1 -1
- package/dist/code-editor.js +1 -1
- package/dist/components/MAudioPlayer.vue.d.ts +115 -0
- package/dist/components/MBadge.vue.d.ts +1 -1
- package/dist/components/MBottomSheetScaffold.vue.d.ts +1 -1
- package/dist/components/MBox.vue.d.ts +1 -1
- package/dist/components/MButton.vue.d.ts +1 -1
- package/dist/components/MConfirmDialog.vue.d.ts +1 -1
- package/dist/components/MCopyButton.vue.d.ts +2 -2
- package/dist/components/MDataTable.vue.d.ts +2 -2
- package/dist/components/MDialog.vue.d.ts +2 -2
- package/dist/components/MDivider.vue.d.ts +1 -1
- package/dist/components/MDragHandle.vue.d.ts +1 -1
- package/dist/components/MDrawCanvas.vue.d.ts +150 -0
- package/dist/components/MDrawLayers.vue.d.ts +3 -0
- package/dist/components/MDrawToolbar.vue.d.ts +34 -0
- package/dist/components/MExportButton.vue.d.ts +1 -1
- package/dist/components/MFab.vue.d.ts +2 -2
- package/dist/components/MFabMenu.vue.d.ts +2 -2
- package/dist/components/MFixed.vue.d.ts +1 -1
- package/dist/components/MFlex.vue.d.ts +2 -2
- package/dist/components/MFloorPlan.vue.d.ts +248 -0
- package/dist/components/MFloorPlanInspector.vue.d.ts +56 -0
- package/dist/components/MFloorPlanToolbar.vue.d.ts +51 -0
- package/dist/components/MFlow.vue.d.ts +318 -0
- package/dist/components/MFlowControls.vue.d.ts +33 -0
- package/dist/components/MFlowHandle.vue.d.ts +16 -0
- package/dist/components/MFlowMinimap.vue.d.ts +22 -0
- package/dist/components/MFlowNode.vue.d.ts +35 -0
- package/dist/components/MGantt.vue.d.ts +141 -0
- package/dist/components/MGanttControls.vue.d.ts +32 -0
- package/dist/components/MIconButton.vue.d.ts +3 -1
- package/dist/components/MImageCropper.vue.d.ts +110 -0
- package/dist/components/MInfiniteScroll.vue.d.ts +1 -1
- package/dist/components/MLightbox.vue.d.ts +2 -2
- package/dist/components/MList.vue.d.ts +1 -1
- package/dist/components/MLoadingOverlay.vue.d.ts +1 -1
- package/dist/components/MMapControl.vue.d.ts +1 -1
- package/dist/components/MMapSearch.vue.d.ts +1 -1
- package/dist/components/MMaskField.vue.d.ts +12 -1
- package/dist/components/MMenu.vue.d.ts +1 -1
- package/dist/components/MNavigationDrawer.vue.d.ts +1 -1
- package/dist/components/MNumberField.vue.d.ts +11 -2
- package/dist/components/MPdfViewer.vue.d.ts +174 -0
- package/dist/components/MPullToRefresh.vue.d.ts +1 -1
- package/dist/components/MResourceTimeline.vue.d.ts +149 -0
- package/dist/components/MScheduler.vue.d.ts +3 -3
- package/dist/components/MScheme.vue.d.ts +1 -1
- package/dist/components/MSearchField.vue.d.ts +1 -1
- package/dist/components/MSeekBar.vue.d.ts +1 -1
- package/dist/components/MSimpleCarousel.vue.d.ts +1 -1
- package/dist/components/MSkeleton.vue.d.ts +1 -1
- package/dist/components/MSlider.vue.d.ts +2 -2
- package/dist/components/MSparkline.vue.d.ts +1 -1
- package/dist/components/MSplitter.vue.d.ts +1 -1
- package/dist/components/MStack.vue.d.ts +2 -2
- package/dist/components/MSwipeToDismiss.vue.d.ts +1 -1
- package/dist/components/MSwitch.vue.d.ts +1 -1
- package/dist/components/MTable.vue.d.ts +1 -1
- package/dist/components/MTagInput.vue.d.ts +12 -1
- package/dist/components/MTextField.vue.d.ts +13 -2
- package/dist/components/MToolbar.vue.d.ts +1 -1
- package/dist/components/MTree.vue.d.ts +2 -2
- package/dist/components/MVideoPlayer.vue.d.ts +253 -0
- package/dist/components/MVirtualTable.vue.d.ts +1 -1
- package/dist/components/MWindow.vue.d.ts +3 -3
- package/dist/components/_MFlowEdge.vue.d.ts +9 -0
- package/dist/components/_MFlowEdgeLabel.vue.d.ts +9 -0
- package/dist/components/_MFlowNodeShell.vue.d.ts +9 -0
- package/dist/components/_MPdfPage.vue.d.ts +76 -0
- package/dist/components/_MTimeBackground.vue.d.ts +14 -0
- package/dist/components/_MTimeHeader.vue.d.ts +20 -0
- package/dist/composables/_flowPanel.d.ts +2 -0
- package/dist/composables/_flowSlot.d.ts +5 -0
- package/dist/composables/_ganttTime.d.ts +41 -0
- package/dist/composables/_useTimeAxis.d.ts +90 -0
- package/dist/composables/drawGeometry.d.ts +119 -0
- package/dist/composables/flowFormats.d.ts +79 -0
- package/dist/composables/flowLayout.d.ts +45 -0
- package/dist/composables/flowPaths.d.ts +53 -0
- package/dist/composables/ganttFormats.d.ts +52 -0
- package/dist/composables/ganttSchedule.d.ts +99 -0
- package/dist/composables/useDrawing.d.ts +44 -0
- package/dist/composables/useFloorPlan.d.ts +58 -0
- package/dist/composables/useFlow.d.ts +266 -0
- package/dist/composables/useGantt.d.ts +87 -0
- package/dist/composables/useLocale.d.ts +204 -0
- package/dist/composables/useMediaPlayer.d.ts +101 -0
- package/dist/composables/usePdf.d.ts +119 -0
- package/dist/composables/useResourceTimeline.d.ts +70 -0
- package/dist/draw.d.ts +7 -0
- package/dist/draw.js +1702 -0
- package/dist/draw.js.map +1 -0
- package/dist/flow.d.ts +14 -0
- package/dist/flow.js +3547 -0
- package/dist/flow.js.map +1 -0
- package/dist/flowPaths-CUc6X373.js +161 -0
- package/dist/flowPaths-CUc6X373.js.map +1 -0
- package/dist/gantt.d.ts +12 -0
- package/dist/gantt.js +3575 -0
- package/dist/gantt.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/locales/index.js +1435 -7
- package/dist/locales/index.js.map +1 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +8248 -7637
- package/dist/m3ui.js.map +1 -1
- package/dist/map.js +113 -108
- package/dist/map.js.map +1 -1
- package/dist/media.d.ts +5 -0
- package/dist/media.js +1311 -0
- package/dist/media.js.map +1 -0
- package/dist/pdf.d.ts +4 -0
- package/dist/pdf.js +1871 -0
- package/dist/pdf.js.map +1 -0
- package/dist/rich-text-editor.js +28 -26
- package/dist/rich-text-editor.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/{useLocale-JYxDDeXC.js → useLocale-CaWwi-b6.js} +206 -2
- package/dist/useLocale-CaWwi-b6.js.map +1 -0
- package/dist/{useThemeTokens-y0HZpyhL.js → useThemeTokens-DQQcaWbE.js} +40 -54
- package/dist/useThemeTokens-DQQcaWbE.js.map +1 -0
- package/package.json +29 -5
- package/src/__tests__/MAudioPlayer.test.ts +75 -0
- package/src/__tests__/MDrawCanvas.test.ts +118 -0
- package/src/__tests__/MFloorPlan.test.ts +299 -0
- package/src/__tests__/MFlow.test.ts +590 -0
- package/src/__tests__/MGantt.test.ts +130 -0
- package/src/__tests__/MImageCropper.test.ts +89 -0
- package/src/__tests__/MPdfViewer.test.ts +235 -0
- package/src/__tests__/MResourceTimeline.test.ts +102 -0
- package/src/__tests__/MVideoPlayer.test.ts +201 -0
- package/src/__tests__/drawGeometry.test.ts +58 -0
- package/src/__tests__/fieldExpose.test.ts +30 -0
- package/src/__tests__/flowFormats.test.ts +185 -0
- package/src/__tests__/flowLayout.test.ts +113 -0
- package/src/__tests__/ganttFormats.test.ts +76 -0
- package/src/__tests__/ganttSchedule.test.ts +136 -0
- package/src/__tests__/pdfMock.ts +83 -0
- package/src/__tests__/useMediaPlayer.test.ts +182 -0
- package/src/__tests__/usePdf.test.ts +102 -0
- package/src/components/MAudioPlayer.vue +319 -0
- package/src/components/MDrawCanvas.vue +819 -0
- package/src/components/MDrawLayers.vue +114 -0
- package/src/components/MDrawToolbar.vue +171 -0
- package/src/components/MFloorPlan.vue +1080 -0
- package/src/components/MFloorPlanInspector.vue +169 -0
- package/src/components/MFloorPlanToolbar.vue +128 -0
- package/src/components/MFlow.vue +2060 -0
- package/src/components/MFlowControls.vue +110 -0
- package/src/components/MFlowHandle.vue +60 -0
- package/src/components/MFlowMinimap.vue +134 -0
- package/src/components/MFlowNode.vue +98 -0
- package/src/components/MGantt.vue +1609 -0
- package/src/components/MGanttControls.vue +77 -0
- package/src/components/MIconButton.vue +3 -1
- package/src/components/MImageCropper.vue +507 -0
- package/src/components/MMaskField.vue +13 -0
- package/src/components/MNumberField.vue +13 -0
- package/src/components/MPdfViewer.vue +1270 -0
- package/src/components/MResourceTimeline.vue +1020 -0
- package/src/components/MTagInput.vue +13 -0
- package/src/components/MTextField.vue +16 -0
- package/src/components/MVideoPlayer.vue +839 -0
- package/src/components/_MFlowEdge.vue +100 -0
- package/src/components/_MFlowEdgeLabel.vue +56 -0
- package/src/components/_MFlowNodeShell.vue +111 -0
- package/src/components/_MPdfPage.vue +456 -0
- package/src/components/_MTimeBackground.vue +16 -0
- package/src/components/_MTimeHeader.vue +31 -0
- package/src/composables/_flowPanel.ts +13 -0
- package/src/composables/_flowSlot.ts +6 -0
- package/src/composables/_ganttTime.ts +200 -0
- package/src/composables/_useTimeAxis.ts +224 -0
- package/src/composables/drawGeometry.ts +405 -0
- package/src/composables/flowFormats.ts +916 -0
- package/src/composables/flowLayout.ts +297 -0
- package/src/composables/flowPaths.ts +239 -0
- package/src/composables/ganttFormats.ts +366 -0
- package/src/composables/ganttSchedule.ts +403 -0
- package/src/composables/useDrawing.ts +53 -0
- package/src/composables/useFloorPlan.ts +73 -0
- package/src/composables/useFlow.ts +250 -0
- package/src/composables/useGantt.ts +92 -0
- package/src/composables/useLocale.ts +410 -0
- package/src/composables/useMediaPlayer.ts +406 -0
- package/src/composables/usePdf.ts +456 -0
- package/src/composables/useResourceTimeline.ts +76 -0
- package/src/draw.ts +25 -0
- package/src/flow.ts +26 -0
- package/src/gantt.ts +12 -0
- package/src/index.ts +9 -0
- package/src/locales/de.ts +204 -0
- package/src/locales/es.ts +204 -0
- package/src/locales/fr.ts +204 -0
- package/src/locales/ja.ts +204 -0
- package/src/locales/ko.ts +204 -0
- package/src/locales/pt.ts +204 -0
- package/src/locales/zh.ts +204 -0
- package/src/media.ts +5 -0
- package/src/pdf.ts +15 -0
- package/dist/MMenuItem-D4Gx_l3F.js +0 -929
- package/dist/MMenuItem-D4Gx_l3F.js.map +0 -1
- package/dist/MSlider-Dx_S3vJ9.js +0 -1506
- package/dist/MSlider-Dx_S3vJ9.js.map +0 -1
- package/dist/MTextField-Bz8JIsnl.js +0 -633
- package/dist/MTextField-Bz8JIsnl.js.map +0 -1
- package/dist/useLocale-JYxDDeXC.js.map +0 -1
- package/dist/useThemeTokens-y0HZpyhL.js.map +0 -1
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// Internal to MPdfViewer: one page. The canvas renders only while `active` (near the viewport), at the device's
|
|
3
|
+
// pixel ratio, swapped in once ready so a zoom never flashes blank; meanwhile the old picture is stretched. Over it:
|
|
4
|
+
// pdf.js's text layer (selectable, with search hits marked in place), the page's links, and an SVG with the
|
|
5
|
+
// annotations, drawn from PDF points through the viewport so they follow zoom and rotation.
|
|
6
|
+
import { computed, onBeforeUnmount, ref, shallowRef, watch } from 'vue'
|
|
7
|
+
import type { PdfPage, PdfState } from '../composables/usePdf'
|
|
8
|
+
import type { PdfAnnotation, PdfTool } from './MPdfViewer.vue'
|
|
9
|
+
import MIcon from './MIcon.vue'
|
|
10
|
+
|
|
11
|
+
type Viewport = ReturnType<PdfPage['getViewport']>
|
|
12
|
+
|
|
13
|
+
const props = defineProps<{
|
|
14
|
+
pdf: PdfState
|
|
15
|
+
page: number
|
|
16
|
+
scale: number
|
|
17
|
+
/** Extra rotation from the viewer, on top of the page's own */
|
|
18
|
+
rotation: number
|
|
19
|
+
/** Near the viewport: render the canvas and the layers */
|
|
20
|
+
active: boolean
|
|
21
|
+
/** Search hits on this page, as offsets in its text; `current` is the focused one */
|
|
22
|
+
hits: { start: number; end: number; current: boolean }[]
|
|
23
|
+
annotations: PdfAnnotation[]
|
|
24
|
+
tool: PdfTool
|
|
25
|
+
color: string
|
|
26
|
+
inkWidth: number
|
|
27
|
+
selectedId: string | null
|
|
28
|
+
}>()
|
|
29
|
+
|
|
30
|
+
const emit = defineEmits<{
|
|
31
|
+
link: [{ url?: string; dest?: unknown }]
|
|
32
|
+
add: [PdfAnnotation]
|
|
33
|
+
select: [{ id: string; anchor: DOMRect } | null]
|
|
34
|
+
erase: [string]
|
|
35
|
+
'erase-start': []
|
|
36
|
+
'erase-at': [{ x: number; y: number; r: number }]
|
|
37
|
+
'text-selection': [{ page: number; rects: [number, number, number, number][]; quote: string; anchor: DOMRect } | null]
|
|
38
|
+
rendered: [number]
|
|
39
|
+
}>()
|
|
40
|
+
|
|
41
|
+
const root = ref<HTMLElement>()
|
|
42
|
+
const canvasHost = ref<HTMLElement>()
|
|
43
|
+
const textHost = ref<HTMLElement>()
|
|
44
|
+
const pageProxy = shallowRef<PdfPage | null>(null)
|
|
45
|
+
const viewport = shallowRef<Viewport | null>(null)
|
|
46
|
+
|
|
47
|
+
function makeViewport(p: PdfPage) {
|
|
48
|
+
return p.getViewport({ scale: props.scale, rotation: (p.rotate + props.rotation) % 360 })
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// ── Canvas ──────────────────────────────────────────────────────────────────────────────────────────────
|
|
52
|
+
let renderTask: { cancel(): void; promise: Promise<void> } | null = null
|
|
53
|
+
let renderedKey = ''
|
|
54
|
+
// Browsers cap a canvas's area; past it, render at a lower ratio
|
|
55
|
+
const MAX_PIXELS = 16_000_000
|
|
56
|
+
|
|
57
|
+
async function render() {
|
|
58
|
+
if (!props.active) return
|
|
59
|
+
const p = pageProxy.value ?? (pageProxy.value = await props.pdf.getPage(props.page).catch(() => null))
|
|
60
|
+
if (!p || !props.active) return
|
|
61
|
+
const vp = makeViewport(p)
|
|
62
|
+
viewport.value = vp
|
|
63
|
+
let ratio = Math.min(2, window.devicePixelRatio || 1)
|
|
64
|
+
if (vp.width * vp.height * ratio * ratio > MAX_PIXELS) ratio = Math.sqrt(MAX_PIXELS / (vp.width * vp.height))
|
|
65
|
+
const key = `${props.scale}|${props.rotation}|${ratio}`
|
|
66
|
+
if (key === renderedKey) return
|
|
67
|
+
renderTask?.cancel()
|
|
68
|
+
const canvas = document.createElement('canvas')
|
|
69
|
+
canvas.width = Math.floor(vp.width * ratio)
|
|
70
|
+
canvas.height = Math.floor(vp.height * ratio)
|
|
71
|
+
canvas.className = 'absolute inset-0 h-full w-full'
|
|
72
|
+
const task = p.render({ canvas, viewport: vp, transform: ratio !== 1 ? [ratio, 0, 0, ratio, 0, 0] : undefined })
|
|
73
|
+
renderTask = task
|
|
74
|
+
try {
|
|
75
|
+
await task.promise
|
|
76
|
+
} catch {
|
|
77
|
+
return // cancelled by a newer render
|
|
78
|
+
}
|
|
79
|
+
if (renderTask !== task) return
|
|
80
|
+
renderTask = null
|
|
81
|
+
renderedKey = key
|
|
82
|
+
const host = canvasHost.value
|
|
83
|
+
if (!host) return
|
|
84
|
+
host.replaceChildren(canvas)
|
|
85
|
+
emit('rendered', props.page)
|
|
86
|
+
renderText(p, vp)
|
|
87
|
+
readLinks(p, vp)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function release() {
|
|
91
|
+
renderTask?.cancel()
|
|
92
|
+
renderTask = null
|
|
93
|
+
renderedKey = ''
|
|
94
|
+
// Free the bitmap now rather than whenever the canvas gets collected
|
|
95
|
+
const c = canvasHost.value?.querySelector('canvas')
|
|
96
|
+
if (c) {
|
|
97
|
+
c.width = 0
|
|
98
|
+
c.height = 0
|
|
99
|
+
}
|
|
100
|
+
canvasHost.value?.replaceChildren()
|
|
101
|
+
textLayer?.cancel()
|
|
102
|
+
textLayer = null
|
|
103
|
+
textHost.value?.replaceChildren()
|
|
104
|
+
links.value = []
|
|
105
|
+
pageProxy.value?.cleanup()
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
let timer: ReturnType<typeof setTimeout> | undefined
|
|
109
|
+
|
|
110
|
+
// ── Text layer and search hits ──────────────────────────────────────────────────────────────────────────
|
|
111
|
+
let textLayer: { render(): Promise<unknown>; cancel(): void; textDivs: HTMLElement[]; textContentItemsStr: string[] } | null = null
|
|
112
|
+
let textContent: unknown = null
|
|
113
|
+
|
|
114
|
+
async function renderText(p: PdfPage, vp: Viewport) {
|
|
115
|
+
const lib = props.pdf.pdfjs.value
|
|
116
|
+
const host = textHost.value
|
|
117
|
+
if (!lib || !host) return
|
|
118
|
+
textLayer?.cancel()
|
|
119
|
+
textContent ??= await p.getTextContent()
|
|
120
|
+
const container = document.createElement('div')
|
|
121
|
+
container.className = 'textLayer'
|
|
122
|
+
const layer = new lib.TextLayer({ textContentSource: textContent as never, container, viewport: vp }) as unknown as typeof textLayer
|
|
123
|
+
textLayer = layer
|
|
124
|
+
try {
|
|
125
|
+
await layer!.render()
|
|
126
|
+
} catch {
|
|
127
|
+
return
|
|
128
|
+
}
|
|
129
|
+
if (textLayer !== layer) return
|
|
130
|
+
host.replaceChildren(container)
|
|
131
|
+
markHits()
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
let marked: number[] = []
|
|
135
|
+
const escape = (s: string) => s.replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' })[c]!)
|
|
136
|
+
|
|
137
|
+
async function markHits() {
|
|
138
|
+
const layer = textLayer
|
|
139
|
+
if (!layer) return
|
|
140
|
+
// Put back what the last marking changed
|
|
141
|
+
for (const i of marked) if (layer.textDivs[i]) layer.textDivs[i]!.textContent = layer.textContentItemsStr[i] ?? ''
|
|
142
|
+
marked = []
|
|
143
|
+
if (!props.hits.length) return
|
|
144
|
+
const { starts } = await props.pdf.pageText(props.page)
|
|
145
|
+
if (layer !== textLayer) return
|
|
146
|
+
const parts = new Map<number, { a: number; b: number; current: boolean }[]>()
|
|
147
|
+
for (const h of props.hits) {
|
|
148
|
+
for (let i = 0; i < starts.length; i++) {
|
|
149
|
+
const s = starts[i]!
|
|
150
|
+
const str = layer.textContentItemsStr[i] ?? ''
|
|
151
|
+
const a = Math.max(h.start, s)
|
|
152
|
+
const b = Math.min(h.end, s + str.length)
|
|
153
|
+
if (b > a) {
|
|
154
|
+
const list = parts.get(i) ?? []
|
|
155
|
+
list.push({ a: a - s, b: b - s, current: h.current })
|
|
156
|
+
parts.set(i, list)
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
let currentEl: HTMLElement | null = null
|
|
161
|
+
for (const [i, ranges] of parts) {
|
|
162
|
+
const div = layer.textDivs[i]
|
|
163
|
+
const str = layer.textContentItemsStr[i] ?? ''
|
|
164
|
+
if (!div) continue
|
|
165
|
+
ranges.sort((x, y) => x.a - y.a)
|
|
166
|
+
let html = ''
|
|
167
|
+
let at = 0
|
|
168
|
+
for (const r of ranges) {
|
|
169
|
+
html += escape(str.slice(at, r.a)) + `<span class="m3-pdf-hit${r.current ? ' m3-pdf-hit-current' : ''}">${escape(str.slice(r.a, r.b))}</span>`
|
|
170
|
+
at = r.b
|
|
171
|
+
}
|
|
172
|
+
div.innerHTML = html + escape(str.slice(at))
|
|
173
|
+
marked.push(i)
|
|
174
|
+
if (ranges.some((r) => r.current)) currentEl ??= div.querySelector<HTMLElement>('.m3-pdf-hit-current')
|
|
175
|
+
}
|
|
176
|
+
currentHit.value = currentEl
|
|
177
|
+
}
|
|
178
|
+
const currentHit = shallowRef<HTMLElement | null>(null)
|
|
179
|
+
watch(() => props.hits, markHits)
|
|
180
|
+
|
|
181
|
+
// ── Links ───────────────────────────────────────────────────────────────────────────────────────────────
|
|
182
|
+
interface Link { left: number; top: number; width: number; height: number; url?: string; dest?: unknown }
|
|
183
|
+
const links = ref<Link[]>([])
|
|
184
|
+
let rawLinks: { rect: number[]; url?: string; dest?: unknown }[] | null = null
|
|
185
|
+
|
|
186
|
+
async function readLinks(p: PdfPage, vp: Viewport) {
|
|
187
|
+
rawLinks ??= (await p.getAnnotations().catch(() => []))
|
|
188
|
+
.filter((a: { subtype?: string; url?: string; dest?: unknown }) => a.subtype === 'Link' && (a.url || a.dest))
|
|
189
|
+
.map((a: { rect: number[]; url?: string; dest?: unknown }) => ({ rect: a.rect, url: a.url, dest: a.dest }))
|
|
190
|
+
links.value = rawLinks!.map((l) => {
|
|
191
|
+
const [x1, y1] = vp.convertToViewportPoint(l.rect[0]!, l.rect[1]!) as [number, number]
|
|
192
|
+
const [x2, y2] = vp.convertToViewportPoint(l.rect[2]!, l.rect[3]!) as [number, number]
|
|
193
|
+
return { left: Math.min(x1, x2), top: Math.min(y1, y2), width: Math.abs(x2 - x1), height: Math.abs(y2 - y1), url: l.url, dest: l.dest }
|
|
194
|
+
})
|
|
195
|
+
}
|
|
196
|
+
// Links scale with the page between renders
|
|
197
|
+
const linkScale = computed(() => (viewport.value && renderedKey ? props.scale / Number(renderedKey.split('|')[0]) : 1))
|
|
198
|
+
|
|
199
|
+
// ── Annotations ─────────────────────────────────────────────────────────────────────────────────────────
|
|
200
|
+
const toView = (x: number, y: number): [number, number] => (viewport.value ? (viewport.value.convertToViewportPoint(x, y) as [number, number]) : [0, 0])
|
|
201
|
+
const toPdf = (x: number, y: number): [number, number] => (viewport.value ? (viewport.value.convertToPdfPoint(x, y) as [number, number]) : [0, 0])
|
|
202
|
+
|
|
203
|
+
const shapes = computed(() => {
|
|
204
|
+
void props.scale
|
|
205
|
+
void props.rotation
|
|
206
|
+
return props.annotations.map((a) => {
|
|
207
|
+
if (a.type === 'highlight') {
|
|
208
|
+
const rects = (a.rects ?? []).map(([x1, y1, x2, y2]) => {
|
|
209
|
+
const [ax, ay] = toView(x1, y1)
|
|
210
|
+
const [bx, by] = toView(x2, y2)
|
|
211
|
+
return { x: Math.min(ax, bx), y: Math.min(ay, by), w: Math.abs(bx - ax), h: Math.abs(by - ay) }
|
|
212
|
+
})
|
|
213
|
+
return { a, rects }
|
|
214
|
+
}
|
|
215
|
+
if (a.type === 'ink') {
|
|
216
|
+
const d = (a.paths ?? []).map((path) => path.map(([x, y], i) => {
|
|
217
|
+
const [vx, vy] = toView(x, y)
|
|
218
|
+
return `${i ? 'L' : 'M'}${vx.toFixed(1)},${vy.toFixed(1)}`
|
|
219
|
+
}).join('')).join('')
|
|
220
|
+
return { a, d, w: (a.width ?? 2) * props.scale }
|
|
221
|
+
}
|
|
222
|
+
const [x, y] = toView(a.at?.[0] ?? 0, a.at?.[1] ?? 0)
|
|
223
|
+
return { a, x, y }
|
|
224
|
+
})
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
function onAnnotationClick(e: MouseEvent, a: PdfAnnotation) {
|
|
228
|
+
// The eraser works by dragging (see onInkDown), a click included
|
|
229
|
+
if (props.tool !== 'select') return
|
|
230
|
+
e.stopPropagation()
|
|
231
|
+
emit('select', { id: a.id, anchor: (e.currentTarget as Element).getBoundingClientRect() })
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const uid = () => (typeof crypto !== 'undefined' && crypto.randomUUID ? crypto.randomUUID() : `a${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`)
|
|
235
|
+
const now = () => new Date().toISOString()
|
|
236
|
+
|
|
237
|
+
function local(e: { clientX: number; clientY: number }) {
|
|
238
|
+
const r = root.value!.getBoundingClientRect()
|
|
239
|
+
// The page may be stretched by a pending zoom: map into the viewport's pixels
|
|
240
|
+
const vp = viewport.value!
|
|
241
|
+
return [((e.clientX - r.left) / (r.width || 1)) * vp.width, ((e.clientY - r.top) / (r.height || 1)) * vp.height] as [number, number]
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Note: a click places one
|
|
245
|
+
function onPageClick(e: MouseEvent) {
|
|
246
|
+
if (props.tool !== 'note' || !viewport.value) return
|
|
247
|
+
const [x, y] = toPdf(...local(e))
|
|
248
|
+
emit('add', { id: uid(), type: 'note', page: props.page, color: props.color, at: [x, y], text: '', createdAt: now() })
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Ink: a drag draws, in viewport pixels while drawing, stored in PDF points. The eraser drags too: everything it
|
|
252
|
+
// passes over goes (strokes are cut where it passes); a stylus's eraser end erases whatever the tool
|
|
253
|
+
const drawing = ref<[number, number][] | null>(null)
|
|
254
|
+
const erasing = ref(false)
|
|
255
|
+
const eraserAt = ref<[number, number] | null>(null)
|
|
256
|
+
// The eraser's radius on screen, whatever the zoom
|
|
257
|
+
const ERASER_PX = 12
|
|
258
|
+
let drawId = -1
|
|
259
|
+
const isPenEraser = (e: PointerEvent) => e.pointerType === 'pen' && (e.button === 5 || (e.buttons & 32) !== 0)
|
|
260
|
+
function eraseAt(e: PointerEvent) {
|
|
261
|
+
const p = local(e)
|
|
262
|
+
eraserAt.value = p
|
|
263
|
+
const [x, y] = toPdf(p[0], p[1])
|
|
264
|
+
emit('erase-at', { x, y, r: ERASER_PX / props.scale })
|
|
265
|
+
}
|
|
266
|
+
function onInkDown(e: PointerEvent) {
|
|
267
|
+
const pen = isPenEraser(e)
|
|
268
|
+
if ((props.tool !== 'ink' && props.tool !== 'eraser' && !pen) || (e.button !== 0 && !pen) || !viewport.value) return
|
|
269
|
+
e.preventDefault()
|
|
270
|
+
drawId = e.pointerId
|
|
271
|
+
try {
|
|
272
|
+
;(e.currentTarget as Element).setPointerCapture(e.pointerId)
|
|
273
|
+
} catch { /* a pointer that's already gone */ }
|
|
274
|
+
if (props.tool === 'eraser' || pen) {
|
|
275
|
+
erasing.value = true
|
|
276
|
+
emit('erase-start')
|
|
277
|
+
eraseAt(e)
|
|
278
|
+
} else drawing.value = [local(e)]
|
|
279
|
+
}
|
|
280
|
+
function onInkMove(e: PointerEvent) {
|
|
281
|
+
if (props.tool === 'eraser' && !erasing.value && e.pointerType !== 'touch') eraserAt.value = local(e)
|
|
282
|
+
if (e.pointerId !== drawId) return
|
|
283
|
+
if (erasing.value) return eraseAt(e)
|
|
284
|
+
if (!drawing.value) return
|
|
285
|
+
const p = local(e)
|
|
286
|
+
const last = drawing.value[drawing.value.length - 1]!
|
|
287
|
+
if (Math.hypot(p[0] - last[0], p[1] - last[1]) >= 1.5) drawing.value = [...drawing.value, p]
|
|
288
|
+
}
|
|
289
|
+
function onInkUp(e: PointerEvent) {
|
|
290
|
+
if (e.pointerId !== drawId) return
|
|
291
|
+
drawId = -1
|
|
292
|
+
if (erasing.value) {
|
|
293
|
+
erasing.value = false
|
|
294
|
+
if (e.pointerType === 'touch') eraserAt.value = null
|
|
295
|
+
return
|
|
296
|
+
}
|
|
297
|
+
if (!drawing.value) return
|
|
298
|
+
const pts = drawing.value
|
|
299
|
+
drawing.value = null
|
|
300
|
+
if (pts.length < 2) return
|
|
301
|
+
emit('add', {
|
|
302
|
+
id: uid(), type: 'ink', page: props.page, color: props.color, width: props.inkWidth,
|
|
303
|
+
paths: [pts.map(([x, y]) => toPdf(x, y).map((v) => Math.round(v * 100) / 100) as [number, number])], createdAt: now(),
|
|
304
|
+
})
|
|
305
|
+
}
|
|
306
|
+
const drawingPath = computed(() => (drawing.value ?? []).map(([x, y], i) => `${i ? 'L' : 'M'}${x.toFixed(1)},${y.toFixed(1)}`).join(''))
|
|
307
|
+
|
|
308
|
+
function openHighlightAt(clientX: number, clientY: number): boolean {
|
|
309
|
+
const vp = viewport.value
|
|
310
|
+
if (!vp || !root.value) return false
|
|
311
|
+
const r = root.value.getBoundingClientRect()
|
|
312
|
+
const sx = vp.width / (r.width || 1)
|
|
313
|
+
const sy = vp.height / (r.height || 1)
|
|
314
|
+
const x = (clientX - r.left) * sx
|
|
315
|
+
const y = (clientY - r.top) * sy
|
|
316
|
+
const PAD = 2
|
|
317
|
+
// The last one drawn is on top
|
|
318
|
+
for (const s of [...shapes.value].reverse()) {
|
|
319
|
+
if (!('rects' in s) || !s.rects) continue
|
|
320
|
+
const hit = s.rects.find((b) => x >= b.x - PAD && x <= b.x + b.w + PAD && y >= b.y - PAD && y <= b.y + b.h + PAD)
|
|
321
|
+
if (!hit) continue
|
|
322
|
+
emit('select', { id: s.a.id, anchor: new DOMRect(r.left + hit.x / sx, r.top + hit.y / sy, hit.w / sx, hit.h / sy) })
|
|
323
|
+
return true
|
|
324
|
+
}
|
|
325
|
+
return false
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// Text selection: its rects, in PDF points, for a highlight (made at once with the highlight tool)
|
|
329
|
+
function onTextPointerUp(e?: PointerEvent) {
|
|
330
|
+
const at = e ? { x: e.clientX, y: e.clientY } : null
|
|
331
|
+
setTimeout(() => {
|
|
332
|
+
const sel = window.getSelection()
|
|
333
|
+
const host = textHost.value
|
|
334
|
+
if (!sel || sel.isCollapsed || !sel.rangeCount || !host || !viewport.value) {
|
|
335
|
+
// A tap on a highlight opens it (to comment on, recolor or delete): the text layer above it takes the tap
|
|
336
|
+
if (at && (props.tool === 'select' || props.tool === 'highlight') && openHighlightAt(at.x, at.y)) return
|
|
337
|
+
if (props.tool === 'select') emit('text-selection', null)
|
|
338
|
+
return
|
|
339
|
+
}
|
|
340
|
+
const range = sel.getRangeAt(0)
|
|
341
|
+
if (!host.contains(range.commonAncestorContainer)) return
|
|
342
|
+
const r = root.value!.getBoundingClientRect()
|
|
343
|
+
const vp = viewport.value
|
|
344
|
+
const sx = vp.width / (r.width || 1)
|
|
345
|
+
const sy = vp.height / (r.height || 1)
|
|
346
|
+
const rects: [number, number, number, number][] = []
|
|
347
|
+
for (const c of Array.from(range.getClientRects())) {
|
|
348
|
+
if (c.width < 1 || c.height < 1) continue
|
|
349
|
+
const [x1, y1] = toPdf((c.left - r.left) * sx, (c.top - r.top) * sy)
|
|
350
|
+
const [x2, y2] = toPdf((c.right - r.left) * sx, (c.bottom - r.top) * sy)
|
|
351
|
+
rects.push([x1, y1, x2, y2].map((v) => Math.round(v * 100) / 100) as [number, number, number, number])
|
|
352
|
+
}
|
|
353
|
+
if (!rects.length) return
|
|
354
|
+
const quote = sel.toString().replace(/\s+/g, ' ').trim()
|
|
355
|
+
if (props.tool === 'highlight') {
|
|
356
|
+
emit('add', { id: uid(), type: 'highlight', page: props.page, color: props.color, rects, quote, text: '', createdAt: now() })
|
|
357
|
+
sel.removeAllRanges()
|
|
358
|
+
} else {
|
|
359
|
+
emit('text-selection', { page: props.page, rects, quote, anchor: range.getBoundingClientRect() })
|
|
360
|
+
}
|
|
361
|
+
})
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// Last, so everything render() and release() touch is declared
|
|
365
|
+
watch(() => props.active, (on) => (on ? render() : release()), { immediate: true })
|
|
366
|
+
// A zoom re-renders shortly after it settles (the stretched picture stands in meanwhile)
|
|
367
|
+
watch(() => [props.scale, props.rotation], () => {
|
|
368
|
+
if (pageProxy.value) viewport.value = makeViewport(pageProxy.value)
|
|
369
|
+
clearTimeout(timer)
|
|
370
|
+
timer = setTimeout(render, 140)
|
|
371
|
+
})
|
|
372
|
+
|
|
373
|
+
onBeforeUnmount(() => {
|
|
374
|
+
clearTimeout(timer)
|
|
375
|
+
release()
|
|
376
|
+
})
|
|
377
|
+
|
|
378
|
+
defineExpose({ root, currentHit })
|
|
379
|
+
</script>
|
|
380
|
+
|
|
381
|
+
<template>
|
|
382
|
+
<div
|
|
383
|
+
ref="root"
|
|
384
|
+
class="m3-pdf-page relative bg-white shadow-elevation-1"
|
|
385
|
+
:data-page="page"
|
|
386
|
+
:style="{ '--scale-factor': scale, '--total-scale-factor': scale, '--user-unit': 1, '--scale-round-x': '1px', '--scale-round-y': '1px' }"
|
|
387
|
+
@click="onPageClick"
|
|
388
|
+
>
|
|
389
|
+
<div ref="canvasHost" class="absolute inset-0" />
|
|
390
|
+
<div
|
|
391
|
+
ref="textHost"
|
|
392
|
+
class="absolute inset-0 overflow-hidden"
|
|
393
|
+
:class="{ 'pointer-events-none': tool === 'ink' || tool === 'note' || tool === 'eraser' }"
|
|
394
|
+
@pointerup="onTextPointerUp"
|
|
395
|
+
/>
|
|
396
|
+
|
|
397
|
+
<a
|
|
398
|
+
v-for="(l, i) in links"
|
|
399
|
+
:key="i"
|
|
400
|
+
:href="l.url ?? '#'"
|
|
401
|
+
:target="l.url ? '_blank' : undefined"
|
|
402
|
+
:rel="l.url ? 'noopener noreferrer' : undefined"
|
|
403
|
+
class="absolute rounded-xs hover:bg-primary/12"
|
|
404
|
+
:class="{ 'pointer-events-none': tool !== 'select' }"
|
|
405
|
+
:style="{ left: `${l.left * linkScale}px`, top: `${l.top * linkScale}px`, width: `${l.width * linkScale}px`, height: `${l.height * linkScale}px` }"
|
|
406
|
+
@click="(e: MouseEvent) => { if (!l.url) { e.preventDefault(); emit('link', { dest: l.dest }) } else emit('link', { url: l.url }) }"
|
|
407
|
+
/>
|
|
408
|
+
|
|
409
|
+
<svg
|
|
410
|
+
class="absolute inset-0 h-full w-full overflow-visible"
|
|
411
|
+
:class="tool === 'ink' ? 'cursor-crosshair touch-none' : tool === 'eraser' ? 'cursor-none touch-none' : 'pointer-events-none'"
|
|
412
|
+
:viewBox="viewport ? `0 0 ${viewport.width} ${viewport.height}` : undefined"
|
|
413
|
+
preserveAspectRatio="none"
|
|
414
|
+
@pointerdown="onInkDown"
|
|
415
|
+
@pointermove="onInkMove"
|
|
416
|
+
@pointerup="onInkUp"
|
|
417
|
+
@pointercancel="onInkUp"
|
|
418
|
+
@pointerleave="eraserAt = erasing ? eraserAt : null"
|
|
419
|
+
>
|
|
420
|
+
<template v-for="s in shapes" :key="s.a.id">
|
|
421
|
+
<g v-if="'rects' in s" class="m3-pdf-highlight" :class="{ 'm3-pdf-selected': s.a.id === selectedId }" @click="(e: MouseEvent) => onAnnotationClick(e, s.a)">
|
|
422
|
+
<rect v-for="(r, i) in s.rects" :key="i" :x="r.x" :y="r.y" :width="r.w" :height="r.h" rx="2" :fill="s.a.color" />
|
|
423
|
+
</g>
|
|
424
|
+
<path
|
|
425
|
+
v-else-if="'d' in s"
|
|
426
|
+
:d="s.d"
|
|
427
|
+
fill="none"
|
|
428
|
+
:stroke="s.a.color"
|
|
429
|
+
:stroke-width="s.w"
|
|
430
|
+
stroke-linecap="round"
|
|
431
|
+
stroke-linejoin="round"
|
|
432
|
+
class="m3-pdf-ink"
|
|
433
|
+
:class="{ 'm3-pdf-selected': s.a.id === selectedId }"
|
|
434
|
+
@click="(e: MouseEvent) => onAnnotationClick(e, s.a)"
|
|
435
|
+
/>
|
|
436
|
+
</template>
|
|
437
|
+
<circle v-if="eraserAt && tool === 'eraser'" :cx="eraserAt[0]" :cy="eraserAt[1]" :r="ERASER_PX" class="pointer-events-none fill-surface/40 stroke-on-surface" stroke-width="1.5" />
|
|
438
|
+
<path v-if="drawing" :d="drawingPath" fill="none" :stroke="color" :stroke-width="inkWidth * scale" stroke-linecap="round" stroke-linejoin="round" />
|
|
439
|
+
</svg>
|
|
440
|
+
|
|
441
|
+
<!-- Notes: an icon at their point -->
|
|
442
|
+
<template v-for="s in shapes" :key="`n-${s.a.id}`">
|
|
443
|
+
<button
|
|
444
|
+
v-if="'x' in s"
|
|
445
|
+
type="button"
|
|
446
|
+
class="m3-pdf-note absolute flex size-7 -translate-x-1/2 -translate-y-1/2 cursor-pointer items-center justify-center rounded-full shadow-elevation-2 outline-none focus-visible:ring-2 focus-visible:ring-primary"
|
|
447
|
+
:class="{ 'ring-2 ring-primary': s.a.id === selectedId }"
|
|
448
|
+
:style="{ left: `${s.x}px`, top: `${s.y}px`, backgroundColor: s.a.color }"
|
|
449
|
+
:aria-label="s.a.text || 'Note'"
|
|
450
|
+
@click="(e: MouseEvent) => { e.stopPropagation(); if (tool === 'eraser') emit('erase', s.a.id); else emit('select', { id: s.a.id, anchor: (e.currentTarget as Element).getBoundingClientRect() }) }"
|
|
451
|
+
>
|
|
452
|
+
<MIcon name="sticky_note_2" :size="16" filled class="text-black/70" />
|
|
453
|
+
</button>
|
|
454
|
+
</template>
|
|
455
|
+
</div>
|
|
456
|
+
</template>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// The timeline's background (MGantt, MResourceTimeline): shaded time off, a line per header cell, today's line
|
|
3
|
+
defineProps<{
|
|
4
|
+
offTimes: { x: number; w: number }[]
|
|
5
|
+
cells: { key: number; x: number }[]
|
|
6
|
+
todayX: number | null
|
|
7
|
+
}>()
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<div class="pointer-events-none absolute inset-0">
|
|
12
|
+
<div v-for="d in offTimes" :key="`o${d.x}`" class="absolute inset-y-0 bg-on-surface/4" :style="{ left: `${d.x}px`, width: `${d.w}px` }" />
|
|
13
|
+
<div v-for="c in cells" :key="c.key" class="absolute inset-y-0 border-l border-outline-variant/40" :style="{ left: `${c.x}px` }" />
|
|
14
|
+
<div v-if="todayX !== null" class="absolute inset-y-0 z-[1] w-0.5 -translate-x-1/2 bg-primary" :style="{ left: `${todayX}px` }" />
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// The timeline's two header rows (MGantt, MResourceTimeline): the coarser unit above, the finer below, and a dot
|
|
3
|
+
// for today
|
|
4
|
+
defineProps<{
|
|
5
|
+
width: number
|
|
6
|
+
topCells: { key: number; x: number; w: number; label: string; labelX: number }[]
|
|
7
|
+
bottomCells: { key: number; x: number; w: number; label: string }[]
|
|
8
|
+
todayX: number | null
|
|
9
|
+
}>()
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<template>
|
|
13
|
+
<div class="relative shrink-0 border-b border-outline-variant bg-surface-container-low" :style="{ width: `${width}px` }" aria-hidden="true">
|
|
14
|
+
<div class="absolute inset-x-0 top-0 h-7">
|
|
15
|
+
<div v-for="c in topCells" :key="c.key" class="absolute inset-y-0 border-l border-outline-variant/60" :style="{ left: `${c.x}px`, width: `${c.w}px` }">
|
|
16
|
+
<span class="absolute top-1.5 truncate pl-2 text-label-medium whitespace-nowrap text-on-surface" :style="{ left: `${c.labelX}px` }">{{ c.label }}</span>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
<div class="absolute inset-x-0 bottom-0 h-7">
|
|
20
|
+
<div
|
|
21
|
+
v-for="c in bottomCells"
|
|
22
|
+
:key="c.key"
|
|
23
|
+
class="absolute inset-y-0 flex items-center justify-center overflow-hidden border-l border-outline-variant/60 text-label-small whitespace-nowrap text-on-surface-variant"
|
|
24
|
+
:style="{ left: `${c.x}px`, width: `${c.w}px` }"
|
|
25
|
+
>
|
|
26
|
+
{{ c.label }}
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
<div v-if="todayX !== null" class="absolute bottom-0 size-2 -translate-x-1/2 translate-y-1/2 rounded-full bg-primary" :style="{ left: `${todayX}px` }" />
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Where MFlowControls / MFlowMinimap (or a panel of yours) sit over MFlow's canvas
|
|
2
|
+
export type FlowPanelPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'center-left' | 'center-right'
|
|
3
|
+
|
|
4
|
+
export const panelPositionClass: Record<FlowPanelPosition, string> = {
|
|
5
|
+
'top-left': 'top-0 left-0',
|
|
6
|
+
'top-center': 'top-0 left-1/2 -translate-x-1/2',
|
|
7
|
+
'top-right': 'top-0 right-0',
|
|
8
|
+
'bottom-left': 'bottom-0 left-0',
|
|
9
|
+
'bottom-center': 'bottom-0 left-1/2 -translate-x-1/2',
|
|
10
|
+
'bottom-right': 'bottom-0 right-0',
|
|
11
|
+
'center-left': 'top-1/2 left-0 -translate-y-1/2',
|
|
12
|
+
'center-right': 'top-1/2 right-0 -translate-y-1/2',
|
|
13
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Renders a slot function handed down as a prop (MFlow passes its `#node-<type>`/`#edge-<type>` slots to the
|
|
2
|
+
// internal components that draw each node and edge)
|
|
3
|
+
import type { FunctionalComponent, Slot } from 'vue'
|
|
4
|
+
|
|
5
|
+
export const SlotOutlet: FunctionalComponent<{ fn: Slot; scope: Record<string, unknown> }> = (p) => p.fn(p.scope)
|
|
6
|
+
SlotOutlet.props = ['fn', 'scope']
|