@logicflow/core 2.2.1 → 2.2.3-alpha.0
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/README.md +32 -0
- package/es/model/GraphModel.js +3 -1
- package/lib/model/GraphModel.js +3 -1
- package/package.json +10 -8
- package/scripts/postinstall-ai-prompt.js +67 -0
- package/dist/index.css +0 -214
- package/dist/index.min.js +0 -2
- package/dist/index.min.js.map +0 -1
package/README.md
CHANGED
|
@@ -102,6 +102,38 @@ const lf = new LogicFlow({
|
|
|
102
102
|
lf.render(data);
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
+
## AI 编程支持
|
|
106
|
+
|
|
107
|
+
LogicFlow 为 AI 编程工具提供了随 npm 包发布的本地文档。`@logicflow/core@2.2.2` 及以上版本会包含这些文档。安装或升级后,可以把下面这段提示词复制给你的 AI Agent,让它在实现 LogicFlow 功能前先查官方文档。
|
|
108
|
+
|
|
109
|
+
更多说明请查看 [AI 编程支持](https://site.logic-flow.cn/tutorial/ai)。
|
|
110
|
+
|
|
111
|
+
升级 `@logicflow/core` 后,请将最新版提示词再次提供给 Agent。
|
|
112
|
+
|
|
113
|
+
```md
|
|
114
|
+
<!-- BEGIN:logicflow-agent-rules -->
|
|
115
|
+
# LogicFlow Agent Rules
|
|
116
|
+
|
|
117
|
+
LogicFlow documentation is available at:
|
|
118
|
+
|
|
119
|
+
- `node_modules/@logicflow/core/dist/docs/`
|
|
120
|
+
|
|
121
|
+
Package roles:
|
|
122
|
+
|
|
123
|
+
- `@logicflow/core`: core graph editor runtime, including canvas, nodes, edges, models, events, rendering, themes, and basic interactions.
|
|
124
|
+
- `@logicflow/extension`: official plugins for common product features.
|
|
125
|
+
- `@logicflow/layout`: official layout plugins for automatic graph layout.
|
|
126
|
+
|
|
127
|
+
The docs for `@logicflow/extension` and `@logicflow/layout` are included under:
|
|
128
|
+
|
|
129
|
+
- `node_modules/@logicflow/core/dist/docs/tutorial/extension/`
|
|
130
|
+
|
|
131
|
+
Before implementing any LogicFlow feature, check the local docs first to see whether LogicFlow already provides a built-in, extension, or layout capability. If it does, prefer the documented official capability instead of reimplementing it from scratch.
|
|
132
|
+
|
|
133
|
+
If an official package is needed but not installed, ask the user before installing it.
|
|
134
|
+
<!-- END:logicflow-agent-rules -->
|
|
135
|
+
```
|
|
136
|
+
|
|
105
137
|
## 文档
|
|
106
138
|
|
|
107
139
|
[官方文档](https://docs.logic-flow.cn)
|
package/es/model/GraphModel.js
CHANGED
|
@@ -111,7 +111,9 @@ var GraphModel = /** @class */ (function () {
|
|
|
111
111
|
}
|
|
112
112
|
this.customStyles = (options.style || {});
|
|
113
113
|
this.theme = setupTheme(options.style, options.themeMode);
|
|
114
|
-
this.grid = Grid.getGridOptions(
|
|
114
|
+
this.grid = Grid.getGridOptions(typeof grid === 'object' && grid !== null
|
|
115
|
+
? assign({}, initialGrid, grid)
|
|
116
|
+
: (grid !== null && grid !== void 0 ? grid : false));
|
|
115
117
|
this.theme.grid = cloneDeep(this.grid);
|
|
116
118
|
if (background) {
|
|
117
119
|
this.background = cloneDeep(assign({}, initialBackground, background));
|
package/lib/model/GraphModel.js
CHANGED
|
@@ -117,7 +117,9 @@ var GraphModel = /** @class */ (function () {
|
|
|
117
117
|
}
|
|
118
118
|
this.customStyles = (options.style || {});
|
|
119
119
|
this.theme = (0, util_1.setupTheme)(options.style, options.themeMode);
|
|
120
|
-
this.grid = overlay_1.Grid.getGridOptions(
|
|
120
|
+
this.grid = overlay_1.Grid.getGridOptions(typeof grid === 'object' && grid !== null
|
|
121
|
+
? (0, lodash_es_1.assign)({}, initialGrid, grid)
|
|
122
|
+
: (grid !== null && grid !== void 0 ? grid : false));
|
|
121
123
|
this.theme.grid = (0, lodash_es_1.cloneDeep)(this.grid);
|
|
122
124
|
if (background) {
|
|
123
125
|
this.background = (0, lodash_es_1.cloneDeep)((0, lodash_es_1.assign)({}, initialBackground, background));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logicflow/core",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.3-alpha.0",
|
|
4
4
|
"description": "LogicFlow, help you quickly create flowcharts",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
"files": [
|
|
41
41
|
"dist",
|
|
42
42
|
"es",
|
|
43
|
-
"lib"
|
|
43
|
+
"lib",
|
|
44
|
+
"scripts"
|
|
44
45
|
],
|
|
45
46
|
"scripts": {
|
|
46
47
|
"clean:turbo": "rss",
|
|
@@ -49,13 +50,14 @@
|
|
|
49
50
|
"build:less": "rss",
|
|
50
51
|
"build:esm": "tsc --module esnext --target es5 --outDir ./es",
|
|
51
52
|
"build:cjs": "tsc --module commonjs --target es5 --outDir ./lib",
|
|
52
|
-
"build:umd": "
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"build:watch:cjs": "rss",
|
|
53
|
+
"build:umd": "rollup -c ./rollup.config.js --bundleConfigAsCjs",
|
|
54
|
+
"dev": "rss",
|
|
55
|
+
"dev:esm": "rss",
|
|
56
|
+
"dev:cjs": "rss",
|
|
57
57
|
"build": "rss",
|
|
58
|
+
"build:all": "rss",
|
|
58
59
|
"prebuild": "rss",
|
|
59
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
60
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
61
|
+
"postinstall": "node scripts/postinstall-ai-prompt.js"
|
|
60
62
|
}
|
|
61
63
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const RESET = '\x1b[0m'
|
|
4
|
+
const REMINDER_STYLE = '\x1b[1m\x1b[43m\x1b[30m' // bold, yellow bg, black fg
|
|
5
|
+
|
|
6
|
+
const AGENT_RULES = `<!-- BEGIN:logicflow-agent-rules -->
|
|
7
|
+
# LogicFlow Agent Rules
|
|
8
|
+
|
|
9
|
+
LogicFlow documentation is available at:
|
|
10
|
+
|
|
11
|
+
- \`node_modules/@logicflow/core/dist/docs/\`
|
|
12
|
+
|
|
13
|
+
Package roles:
|
|
14
|
+
|
|
15
|
+
- \`@logicflow/core\`: core graph editor runtime, including canvas, nodes, edges, models, events, rendering, themes, and basic interactions.
|
|
16
|
+
- \`@logicflow/extension\`: official plugins for common product features.
|
|
17
|
+
- \`@logicflow/layout\`: official layout plugins for automatic graph layout.
|
|
18
|
+
|
|
19
|
+
The docs for \`@logicflow/extension\` and \`@logicflow/layout\` are included under:
|
|
20
|
+
|
|
21
|
+
- \`node_modules/@logicflow/core/dist/docs/tutorial/extension/\`
|
|
22
|
+
|
|
23
|
+
Before implementing any LogicFlow feature, check the local docs first to see whether LogicFlow already provides a built-in, extension, or layout capability. If it does, prefer the documented official capability instead of reimplementing it from scratch.
|
|
24
|
+
|
|
25
|
+
If an official package is needed but not installed, ask the user before installing it.
|
|
26
|
+
<!-- END:logicflow-agent-rules -->`
|
|
27
|
+
|
|
28
|
+
const REMINDER_LINES = [
|
|
29
|
+
'请将下方的规则复制给你的 AI Agent,让 AI Agent 可以更了解 LogicFlow。',
|
|
30
|
+
'您还可以在 README 和官网的 AI 编程章节找到此规则',
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
function shouldUseAnsi() {
|
|
34
|
+
if (!process.stdout.isTTY) return false
|
|
35
|
+
if (process.env.NO_COLOR !== undefined && process.env.NO_COLOR !== '')
|
|
36
|
+
return false
|
|
37
|
+
if (process.env.TERM === 'dumb') return false
|
|
38
|
+
if (process.env.CI === 'true' && !process.env.FORCE_COLOR) return false
|
|
39
|
+
return true
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function dividerWidth() {
|
|
43
|
+
const c = process.stdout.columns
|
|
44
|
+
if (typeof c === 'number' && Number.isFinite(c) && c > 0) {
|
|
45
|
+
return Math.min(c, 120)
|
|
46
|
+
}
|
|
47
|
+
return 80
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function dividerLine() {
|
|
51
|
+
return '─'.repeat(dividerWidth())
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function printReminder() {
|
|
55
|
+
const useAnsi = shouldUseAnsi()
|
|
56
|
+
for (const line of REMINDER_LINES) {
|
|
57
|
+
if (useAnsi) {
|
|
58
|
+
process.stdout.write(`${REMINDER_STYLE}${line}${RESET}\n`)
|
|
59
|
+
} else {
|
|
60
|
+
process.stdout.write(`${line}\n`)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
printReminder()
|
|
66
|
+
console.log(dividerLine())
|
|
67
|
+
console.log(AGENT_RULES)
|
package/dist/index.css
DELETED
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
.lf-graph {
|
|
2
|
-
position: relative;
|
|
3
|
-
z-index: 0;
|
|
4
|
-
width: 100%;
|
|
5
|
-
height: 100%;
|
|
6
|
-
background: #fff;
|
|
7
|
-
user-select: none;
|
|
8
|
-
}
|
|
9
|
-
.lf-element-text {
|
|
10
|
-
cursor: text;
|
|
11
|
-
}
|
|
12
|
-
.lf-text-disabled {
|
|
13
|
-
pointer-events: none;
|
|
14
|
-
}
|
|
15
|
-
.lf-text-draggable {
|
|
16
|
-
cursor: move;
|
|
17
|
-
}
|
|
18
|
-
*:focus {
|
|
19
|
-
outline: none;
|
|
20
|
-
}
|
|
21
|
-
.lf-node-anchor {
|
|
22
|
-
cursor: crosshair;
|
|
23
|
-
}
|
|
24
|
-
.lf-node-anchor-hover {
|
|
25
|
-
visibility: hidden;
|
|
26
|
-
}
|
|
27
|
-
.lf-anchor:hover .lf-node-anchor-hover {
|
|
28
|
-
visibility: visible;
|
|
29
|
-
}
|
|
30
|
-
.lf-edge.pointer-none {
|
|
31
|
-
pointer-events: none;
|
|
32
|
-
}
|
|
33
|
-
.lf-edge-append {
|
|
34
|
-
cursor: pointer;
|
|
35
|
-
}
|
|
36
|
-
.lf-edge-animation {
|
|
37
|
-
stroke-dashoffset: 100%;
|
|
38
|
-
animation: lf_animate_dash 5s linear infinite;
|
|
39
|
-
}
|
|
40
|
-
@keyframes lf_animate_dash {
|
|
41
|
-
to {
|
|
42
|
-
stroke-dashoffset: 0;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
/* node */
|
|
46
|
-
.lf-node-not-allow {
|
|
47
|
-
cursor: not-allowed;
|
|
48
|
-
}
|
|
49
|
-
.lf-polyline-append-ns-resize {
|
|
50
|
-
cursor: ns-resize;
|
|
51
|
-
}
|
|
52
|
-
.lf-polyline-append-ew-resize {
|
|
53
|
-
cursor: ew-resize;
|
|
54
|
-
}
|
|
55
|
-
.lf-dragging {
|
|
56
|
-
cursor: move;
|
|
57
|
-
}
|
|
58
|
-
.lf-dragging .lf-element-text {
|
|
59
|
-
cursor: move;
|
|
60
|
-
}
|
|
61
|
-
.lf-draggable {
|
|
62
|
-
cursor: default;
|
|
63
|
-
}
|
|
64
|
-
.lf-bezier-adjust-anchor {
|
|
65
|
-
cursor: pointer;
|
|
66
|
-
}
|
|
67
|
-
/* background */
|
|
68
|
-
.lf-background,
|
|
69
|
-
.lf-grid {
|
|
70
|
-
position: absolute;
|
|
71
|
-
inset: 0;
|
|
72
|
-
z-index: -1;
|
|
73
|
-
}
|
|
74
|
-
.lf-background-area {
|
|
75
|
-
width: 100%;
|
|
76
|
-
height: 100%;
|
|
77
|
-
}
|
|
78
|
-
/* html-overlay */
|
|
79
|
-
.lf-html-overlay {
|
|
80
|
-
position: absolute;
|
|
81
|
-
inset: 0;
|
|
82
|
-
z-index: 1;
|
|
83
|
-
overflow: hidden;
|
|
84
|
-
user-select: none;
|
|
85
|
-
pointer-events: none;
|
|
86
|
-
}
|
|
87
|
-
.lf-html-overlay__transform > * {
|
|
88
|
-
pointer-events: all;
|
|
89
|
-
}
|
|
90
|
-
.lf-text-editable {
|
|
91
|
-
pointer-events: all;
|
|
92
|
-
}
|
|
93
|
-
.lf-text-input {
|
|
94
|
-
position: absolute;
|
|
95
|
-
box-sizing: border-box;
|
|
96
|
-
min-width: 100px;
|
|
97
|
-
min-height: 20px;
|
|
98
|
-
padding: 5px;
|
|
99
|
-
line-height: 1.2;
|
|
100
|
-
white-space: pre;
|
|
101
|
-
text-align: center;
|
|
102
|
-
background: #fff;
|
|
103
|
-
border: 1px solid #edefed;
|
|
104
|
-
border-radius: 3px;
|
|
105
|
-
outline: none;
|
|
106
|
-
transform: translate(-50%, -50%);
|
|
107
|
-
resize: none;
|
|
108
|
-
}
|
|
109
|
-
.lf-get-text-height {
|
|
110
|
-
display: inline-block;
|
|
111
|
-
box-sizing: border-box;
|
|
112
|
-
word-break: break-all;
|
|
113
|
-
/* 为了跟输入效果保持一致,设置透明边框占位 */
|
|
114
|
-
border: 1px solid transparent;
|
|
115
|
-
}
|
|
116
|
-
.lf-node-text-auto-wrap {
|
|
117
|
-
display: flex;
|
|
118
|
-
align-items: center;
|
|
119
|
-
justify-content: center;
|
|
120
|
-
box-sizing: border-box;
|
|
121
|
-
/* border: 1px solid transparent; */
|
|
122
|
-
}
|
|
123
|
-
.lf-node-text-auto-wrap-content {
|
|
124
|
-
width: 100%;
|
|
125
|
-
line-height: 1.2;
|
|
126
|
-
text-align: center;
|
|
127
|
-
word-break: break-all;
|
|
128
|
-
background: transparent;
|
|
129
|
-
}
|
|
130
|
-
.lf-node-text-ellipsis-content {
|
|
131
|
-
width: 100%;
|
|
132
|
-
line-height: 1.2;
|
|
133
|
-
white-space: nowrap;
|
|
134
|
-
text-align: center;
|
|
135
|
-
background: transparent;
|
|
136
|
-
/* overflow: hidden;
|
|
137
|
-
text-overflow: ellipsis; */
|
|
138
|
-
}
|
|
139
|
-
.lf-node-text-ellipsis-content > div {
|
|
140
|
-
overflow: hidden;
|
|
141
|
-
text-overflow: ellipsis;
|
|
142
|
-
}
|
|
143
|
-
/* tool-overlay */
|
|
144
|
-
.lf-tool-overlay {
|
|
145
|
-
position: absolute;
|
|
146
|
-
inset: 0;
|
|
147
|
-
z-index: 2;
|
|
148
|
-
overflow: hidden;
|
|
149
|
-
pointer-events: none;
|
|
150
|
-
}
|
|
151
|
-
.lf-tool-overlay > * {
|
|
152
|
-
pointer-events: all;
|
|
153
|
-
}
|
|
154
|
-
/* modification-overlay */
|
|
155
|
-
.modification-overlay {
|
|
156
|
-
position: absolute;
|
|
157
|
-
inset: 0;
|
|
158
|
-
z-index: 1;
|
|
159
|
-
overflow: hidden;
|
|
160
|
-
pointer-events: none;
|
|
161
|
-
}
|
|
162
|
-
.modification-overlay > * {
|
|
163
|
-
pointer-events: all;
|
|
164
|
-
}
|
|
165
|
-
.lf-outline,
|
|
166
|
-
.lf-snapline {
|
|
167
|
-
pointer-events: none;
|
|
168
|
-
}
|
|
169
|
-
.lf-keyboard-tips {
|
|
170
|
-
float: right;
|
|
171
|
-
}
|
|
172
|
-
.lf-node-select-decorate {
|
|
173
|
-
position: absolute;
|
|
174
|
-
border: 1px dashed #343435;
|
|
175
|
-
transform: translate(-50%, -50%);
|
|
176
|
-
pointer-events: none;
|
|
177
|
-
}
|
|
178
|
-
.lf-multiple-select {
|
|
179
|
-
position: absolute;
|
|
180
|
-
border: 2px dashed #4271dfcc;
|
|
181
|
-
border-radius: 12px;
|
|
182
|
-
box-shadow: 0 0 3px 0 #4271df80;
|
|
183
|
-
cursor: move;
|
|
184
|
-
}
|
|
185
|
-
.lf-edge-adjust-point {
|
|
186
|
-
cursor: move;
|
|
187
|
-
}
|
|
188
|
-
.lf-rotate-control {
|
|
189
|
-
cursor: grabbing;
|
|
190
|
-
}
|
|
191
|
-
.lf-resize-control-nw {
|
|
192
|
-
cursor: nw-resize;
|
|
193
|
-
}
|
|
194
|
-
.lf-resize-control-n {
|
|
195
|
-
cursor: n-resize;
|
|
196
|
-
}
|
|
197
|
-
.lf-resize-control-ne {
|
|
198
|
-
cursor: ne-resize;
|
|
199
|
-
}
|
|
200
|
-
.lf-resize-control-e {
|
|
201
|
-
cursor: e-resize;
|
|
202
|
-
}
|
|
203
|
-
.lf-resize-control-se {
|
|
204
|
-
cursor: se-resize;
|
|
205
|
-
}
|
|
206
|
-
.lf-resize-control-s {
|
|
207
|
-
cursor: s-resize;
|
|
208
|
-
}
|
|
209
|
-
.lf-resize-control-sw {
|
|
210
|
-
cursor: sw-resize;
|
|
211
|
-
}
|
|
212
|
-
.lf-resize-control-w {
|
|
213
|
-
cursor: w-resize;
|
|
214
|
-
}
|