-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathsync_navigation.ts
133 lines (121 loc) · 4.31 KB
/
sync_navigation.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/**
* @license
* Copyright 2024 The Model Explorer Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ==============================================================================
*/
import {TaskData, TaskType} from './task';
/** The data for navigation syncing. */
export declare interface SyncNavigationData extends TaskData {
type: TaskType.SYNC_NAVIGATION;
/**
* Specifies the mapping for navigation syncing.
*
* When user selects a node on one side, Model Explorer will try to find the
* mapped node on the other side and select it automacitally. If the mapped
* node is not found, Model Explorer will try to find the node with the same
* node id on the other side. This fallback behavior can be disabled by
* setting `disableMappingFallback` below to true.
*/
mapping?: SyncNavigationMapping;
/**
* The more flexible mapping specification for navigation syncing that
* supports one to many, many to many, and many to one mapping.
*
* Model Explorer assumes that a node id from either side will only appear in
* one SyncNavigationMappingEntry. For example, the following mapping is not
* recommended because 'a' appears in two SyncNavigationMappingEntries:
*
* ```
* {
* mappingEntries: [
* {
* leftNodeIds: ['a'],
* rightNodeIds: ['b', 'c'],
* },
* {
* leftNodeIds: ['a', 'd'],
* rightNodeIds: ['x'],
* },
* ],
* }
* ```
*
* This field supersedes the `mapping` field above.
*/
mappingEntries?: SyncNavigationMappingEntry[];
/**
* Whether to disable the fallback behavior (find the node with the same id)
* when the mapped node is not found from the `mapping` field above.
*/
disableMappingFallback?: boolean;
/**
* The border color used to highlight "related nodes". Default to #ff00be
* (pink). The highlight is rendered as a colored border around the node.
*
* == What are "related nodes"?
*
* Assume we have a mapping from 'a' to ['b', 'c', 'd']. In this case, 'b',
* 'c' and 'd' are "related nodes".
*
* == When are related nodes highlighted?
*
* - When 'a' is selected in the left pane, 'b', 'c', and 'd' in the right
* pane will be highlighted.
* - When 'b', 'c', OR 'd' is selected in the right pane, all of 'b', 'c', and
* 'd' in the right pane will be highlighted.
*/
relatedNodesBorderColor?: string;
/**
* The border width used to highlight "related nodes". Default to 2.
*
* See comments above for "related nodes".
*/
relatedNodesBorderWidth?: number;
}
/**
* The mapping for navigation syncing, from node id from left side to node id
* from right side.
*/
export type SyncNavigationMapping = Record<string, string>;
/**
* The mapping entry for navigation syncing, used for more flexible mapping
* specification, such as one to many, many to many, and many to one mapping.
*/
export declare interface SyncNavigationMappingEntry {
leftNodeIds: string[];
rightNodeIds: string[];
}
/** The mode of navigation syncing. */
export enum SyncNavigationMode {
DISABLED = 'disabled',
MATCH_NODE_ID = 'match_node_id',
VISUALIZER_CONFIG = 'visualizer_config',
UPLOAD_MAPPING_FROM_COMPUTER = 'from_computer',
LOAD_MAPPING_FROM_CNS = 'from_cns',
}
/** The labels for sync navigation modes. */
export const SYNC_NAVIGATION_MODE_LABELS = {
[SyncNavigationMode.DISABLED]: 'Disabled',
[SyncNavigationMode.MATCH_NODE_ID]: 'Match node id',
[SyncNavigationMode.UPLOAD_MAPPING_FROM_COMPUTER]:
'Upload mapping from computer',
[SyncNavigationMode.LOAD_MAPPING_FROM_CNS]: 'Load mapping from CNS',
[SyncNavigationMode.VISUALIZER_CONFIG]: 'From Visualizer Config',
};
/** Information about the source of navigation. */
export interface NavigationSourceInfo {
paneIndex: number;
nodeId: string;
}