feat(docs): Initial commit for docs in nuxt 3

This commit is contained in:
Braks
2021-11-06 08:54:35 +01:00
parent 6ec8258f33
commit 64df75d405
33 changed files with 6452 additions and 955 deletions
@@ -41,7 +41,8 @@ const nodeStrokeColorFunc: StringFunc =
const nodeClassNameFunc = props.nodeClassName instanceof Function ? props.nodeClassName : () => props.nodeClassName as StringFunc
const shapeRendering: ShapeRendering = typeof window === 'undefined' || !!window.chrome ? 'crispEdges' : 'geometricPrecision'
const shapeRendering: ShapeRendering =
(window && typeof window === 'undefined') || !!window.chrome ? 'crispEdges' : 'geometricPrecision'
const viewBox = computed(() => {
const bb = getRectOfNodes(store.nodes)
+1 -1
View File
@@ -1,5 +1,5 @@
<script lang="ts" setup>
import { DraggableEventListener } from '@braks/revue-draggable'
import { DraggableEventListener, DraggableCore } from '@braks/revue-draggable'
import { Node, NodeType, SnapGrid } from '~/types'
import { NodeIdContextKey } from '~/context'
import { useHooks, useStore } from '~/composables'
+5 -3
View File
@@ -37,9 +37,11 @@ export default (keyCode: KeyCode, onChange?: (keyPressed: boolean) => void): Ref
},
)
useEventListener(window, 'blur', () => {
isPressed.value = false
})
if (window && typeof window !== 'undefined') {
useEventListener(window, 'blur', () => {
isPressed.value = false
})
}
if (onChange && typeof onChange === 'function') onChange(isPressed.value)
+3 -2
View File
@@ -1,6 +1,7 @@
// @ts-nocheck
import { zoomIdentity } from 'd3-zoom'
import { getRectOfNodes, pointToRendererPoint, getTransformForBounds } from '~/utils/graph'
import { FitViewParams, FlowTransform, Rect, UseZoomPanHelper, XYPosition } from '~/types'
import { FitViewParams, FlowTransform, Node, Rect, UseZoomPanHelper, XYPosition } from '~/types'
import useStore from '~/composables/useStore'
const DEFAULT_PADDING = 0.1
@@ -17,7 +18,7 @@ export default (store = useStore()): UseZoomPanHelper => {
fitView: (options: FitViewParams = { padding: DEFAULT_PADDING, includeHiddenNodes: false }) => {
if (!store.nodes.length) return
const bounds = getRectOfNodes(options.includeHiddenNodes ? store.nodes : store.nodes.filter((node) => !node.isHidden))
const bounds = getRectOfNodes(options.includeHiddenNodes ? store.nodes : store.nodes.filter((node: Node) => !node.isHidden))
const [x, y, zoom] = getTransformForBounds(
bounds,
store.dimensions.width,
+4 -1
View File
@@ -130,7 +130,10 @@ const init = (opts: typeof props) => {
onBeforeUnmount(() => store?.$dispose())
watch(props, (val) => init(val))
watch(
() => props,
(val) => init(val),
)
init(props)
const nodeTypes = controlledComputed(
+1
View File
@@ -1,3 +1,4 @@
// @ts-nocheck
import { InjectionKey } from 'vue'
import { ElementId, FlowHooks, FlowStore } from '~/types'
+1 -1
View File
@@ -17,7 +17,7 @@ export interface Node<T = any> {
| any
data?: T
style?: any
className?: string
class?: string
targetPosition?: Position
sourcePosition?: Position
isHidden?: boolean
+1
View File
@@ -1,3 +1,4 @@
// @ts-nocheck
import { CSSProperties, HTMLAttributes } from 'vue'
import { Edge, EdgeType } from './edge'
import { Node, NodeExtent, NodeType, TranslateExtent } from './node'
+1 -1
View File
@@ -34,7 +34,7 @@ export const clampPosition = (position: XYPosition, extent: NodeExtent): XYPosit
export const getHostForElement = (element: HTMLElement): Document => {
const doc = element.getRootNode() as Document
if ('getElementFromPoint' in doc) return doc
else return window.document
else return false as any
}
export const isEdge = (element: Node | Connection | Edge): element is Edge =>