File tree Expand file tree Collapse file tree 4 files changed +28
-1
lines changed Expand file tree Collapse file tree 4 files changed +28
-1
lines changed Original file line number Diff line number Diff line change
1
+ import { onMounted } from 'vue'
2
+ import { ErrorCode , VueFlowError , isDev } from '../utils'
3
+ import { useVueFlow } from './useVueFlow'
4
+
5
+ export function useStylesLoadedWarning ( ) {
6
+ const { emits } = useVueFlow ( )
7
+
8
+ onMounted ( ( ) => {
9
+ if ( isDev ( ) ) {
10
+ const pane = document . querySelector ( '.vue-flow__pane' )
11
+
12
+ if ( pane && ! ( window . getComputedStyle ( pane ) . zIndex === '1' ) ) {
13
+ emits . error ( new VueFlowError ( ErrorCode . MISSING_STYLES ) )
14
+ }
15
+ }
16
+ } )
17
+ }
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import { useVueFlow } from '../../composables/useVueFlow'
11
11
import { useHooks } from ' ../../store/hooks'
12
12
import EdgeRenderer from ' ../EdgeRenderer/EdgeRenderer.vue'
13
13
import NodeRenderer from ' ../NodeRenderer/NodeRenderer.vue'
14
+ import { useStylesLoadedWarning } from ' ../../composables/useStylesLoadedWarning'
14
15
15
16
const props = withDefaults (defineProps <FlowProps >(), {
16
17
snapToGrid: undefined ,
@@ -70,6 +71,8 @@ useHooks(emit, hooks)
70
71
71
72
useOnInitHandler ()
72
73
74
+ useStylesLoadedWarning ()
75
+
73
76
// slots will be passed via provide
74
77
// this is to avoid having to pass them down through all the components
75
78
// as that would require a lot of boilerplate and causes significant performance drops
Original file line number Diff line number Diff line change 1
1
export enum ErrorCode {
2
+ MISSING_STYLES = 'MISSING_STYLES' ,
2
3
MISSING_VIEWPORT_DIMENSIONS = 'MISSING_VIEWPORT_DIMENSIONS' ,
3
4
NODE_INVALID = 'NODE_INVALID' ,
4
5
NODE_NOT_FOUND = 'NODE_NOT_FOUND' ,
@@ -16,6 +17,8 @@ export enum ErrorCode {
16
17
}
17
18
18
19
const messages = {
20
+ [ ErrorCode . MISSING_STYLES ] : ( ) =>
21
+ `It seems that you haven't loaded the necessary styles. Please import '@vue-flow/core/dist/style.css' to ensure that the graph is rendered correctly` ,
19
22
[ ErrorCode . MISSING_VIEWPORT_DIMENSIONS ] : ( ) => 'The Vue Flow parent container needs a width and a height to render the graph' ,
20
23
[ ErrorCode . NODE_INVALID ] : ( id ?: string ) => `Node is invalid\nNode: ${ id } ` ,
21
24
[ ErrorCode . NODE_NOT_FOUND ] : ( id : string | null ) => `Node not found\nNode: ${ id } ` ,
Original file line number Diff line number Diff line change 1
1
const productionEnvs = [ 'production' , 'prod' ]
2
2
3
3
export function warn ( message : string , ...args : any [ ] ) {
4
- if ( ! productionEnvs . includes ( __ENV__ || '' ) ) {
4
+ if ( isDev ( ) ) {
5
5
console . warn ( `[Vue Flow]: ${ message } ` , ...args )
6
6
}
7
7
}
8
+
9
+ export function isDev ( ) {
10
+ return ! productionEnvs . includes ( __ENV__ || '' )
11
+ }
You can’t perform that action at this time.
0 commit comments