dsh-drawai 0.4.1 → 0.4.2

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.
@@ -152,9 +152,16 @@ var DASH_PRESETS = {
152
152
  /** 线型枚举顺序。 */
153
153
  var DASH_KINDS = ['solid', 'dashed', 'dotted']
154
154
 
155
- /** 箭头枚举 → style 键。none 是缺省(drawio 里键缺省就不画箭头),落盘即删键。 */
155
+ /**
156
+ * 箭头枚举 → style 键。
157
+ *
158
+ * `none` 必须**显式写 `endArrow=none`**:drawio 的 defaultEdge 自带
159
+ * `endArrow=classic`(`mxStylesheet.createDefaultEdgeStyle`),删键只会让这条边
160
+ * 回落到缺省,箭头反而又长出来。`=none` 才是在合并后的样式里把这个键删掉
161
+ * (`mxStylesheet.getCellStyle`:value 为 `none` 时 delete),从而真的不画。
162
+ */
156
163
  var ARROW_PRESETS = {
157
- none: null,
164
+ none: { endArrow: 'none' },
158
165
  end: { endArrow: 'classic' },
159
166
  both: { endArrow: 'classic', startArrow: 'classic' },
160
167
  start: { startArrow: 'classic' },
@@ -655,7 +662,10 @@ function arrowValueIsSet(value) {
655
662
 
656
663
  /** style → 箭头枚举。 */
657
664
  function arrowFromStyle(style) {
658
- var end = arrowValueIsSet(styleGet(style, 'endArrow', null))
665
+ // 按 drawio 的**有效样式**算:mxStylesheet.getCellStyle 会先把 defaultEdge 合进来,
666
+ // 而 defaultEdge 自带 endArrow=classic —— 所以缺键不是"没有箭头",是有 classic。
667
+ // startArrow 不在 defaultEdge 里,缺键才是真的没有。
668
+ var end = arrowValueIsSet(styleGet(style, 'endArrow', 'classic'))
659
669
  var start = arrowValueIsSet(styleGet(style, 'startArrow', null))
660
670
  if (end && start) return 'both'
661
671
  if (end) return 'end'
@@ -663,12 +673,12 @@ function arrowFromStyle(style) {
663
673
  return 'none'
664
674
  }
665
675
 
666
- /** 箭头枚举 → style。none 即删键(= drawio 缺省不画)。 */
676
+ /** 箭头枚举 → style。none 写 `endArrow=none`;null/undefined 才是"删键回落到 drawio 缺省"。 */
667
677
  function styleWithArrow(style, kind) {
668
678
  var cleared = stylePatch(style, { endArrow: null, startArrow: null })
669
- if (kind === null || kind === undefined || kind === 'none') return cleared
679
+ if (kind === null || kind === undefined) return cleared
670
680
  var preset = ARROW_PRESETS[kind]
671
- if (preset === undefined || preset === null) return cleared
681
+ if (preset === undefined) return cleared
672
682
  return stylePatch(cleared, preset)
673
683
  }
674
684
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-drawai",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "type": "module",
5
5
  "description": "DSH 右侧栏的可编辑画布 + AI 语义绘图工具(diagram_apply / diagram_read),直接读写原生 .drawio 文件",
6
6
  "license": "MIT",