sprotty
Advanced tools
Comparing version 0.15.0-next.771285d.18 to 0.15.0-next.781c032.25
@@ -16,2 +16,3 @@ /******************************************************************************** | ||
********************************************************************************/ | ||
import 'reflect-metadata'; | ||
import { Action } from "sprotty-protocol/lib/actions"; | ||
@@ -18,0 +19,0 @@ import { ILogger } from "../../utils/logging"; |
@@ -25,2 +25,3 @@ "use strict"; | ||
exports.ResetCommand = exports.SystemCommand = exports.PopupCommand = exports.HiddenCommand = exports.MergeableCommand = exports.Command = void 0; | ||
require("reflect-metadata"); | ||
const inversify_1 = require("inversify"); | ||
@@ -27,0 +28,0 @@ /** |
@@ -273,2 +273,21 @@ "use strict"; | ||
edge.index.remove(edge); | ||
if (edge.id === model_1.edgeInProgressID) { | ||
// create a proper edge id after connecting the edge in progress | ||
const idGen = (counter) => `${edge.sourceId}_to_${edge.targetId}_${counter}`; | ||
let idx = 0; | ||
let newId = idGen(idx); | ||
while (edge.index.getById(newId) !== undefined) { | ||
newId = idGen(++idx); | ||
} | ||
edge.id = newId; | ||
const progressTargetHandle = edge.children.find(child => child.id === model_1.edgeInProgressTargetHandleID); | ||
if (progressTargetHandle instanceof model_1.SRoutingHandleImpl) { | ||
// remove in progress target handle | ||
edge.remove(progressTargetHandle); | ||
if (progressTargetHandle.danglingAnchor) { | ||
// remove dangling anchor | ||
progressTargetHandle.danglingAnchor.parent.remove(progressTargetHandle.danglingAnchor); | ||
} | ||
} | ||
} | ||
edge.index.add(edge); | ||
@@ -275,0 +294,0 @@ if (this.getSelfEdgeIndex(edge) > -1) { |
@@ -49,2 +49,3 @@ /******************************************************************************** | ||
hasDragged: boolean; | ||
isMouseDown: boolean; | ||
mouseDown(target: SModelElementImpl, event: MouseEvent): (Action | Promise<Action>)[]; | ||
@@ -51,0 +52,0 @@ protected collectElementsToDeselect(target: SModelElementImpl, selectableTarget: (SModelElementImpl & Selectable) | undefined): SModelElementImpl[]; |
@@ -145,2 +145,3 @@ "use strict"; | ||
this.hasDragged = false; | ||
this.isMouseDown = false; | ||
} | ||
@@ -151,2 +152,3 @@ mouseDown(target, event) { | ||
} | ||
this.isMouseDown = true; | ||
const buttonHandled = this.handleButton(target, event); | ||
@@ -166,17 +168,12 @@ if (buttonHandled) { | ||
} | ||
if (selectableTarget !== undefined) { | ||
if (!selectableTarget.selected) { | ||
this.wasSelected = false; | ||
return this.handleSelectTarget(selectableTarget, deselectedElements, event); | ||
} | ||
else if ((0, browser_1.isCtrlOrCmd)(event)) { | ||
this.wasSelected = false; | ||
return this.handleDeselectTarget(selectableTarget, event); | ||
} | ||
else { | ||
this.wasSelected = true; | ||
} | ||
if (!selectableTarget.selected) { | ||
this.wasSelected = false; | ||
return this.handleSelectTarget(selectableTarget, deselectedElements, event); | ||
} | ||
else if ((0, browser_1.isCtrlOrCmd)(event)) { | ||
this.wasSelected = false; | ||
return this.handleDeselectTarget(selectableTarget, event); | ||
} | ||
else { | ||
return this.handleDeselectAll(deselectedElements, event); | ||
this.wasSelected = true; | ||
} | ||
@@ -231,3 +228,3 @@ } | ||
mouseMove(target, event) { | ||
this.hasDragged = true; | ||
this.hasDragged = this.isMouseDown; | ||
return []; | ||
@@ -244,4 +241,4 @@ } | ||
} | ||
else if (target instanceof smodel_1.SModelRootImpl && !(0, scroll_1.findViewportScrollbar)(event)) { | ||
// Mouse up on root but not over ViewPort's scroll bars > deselect all | ||
else if ((target instanceof smodel_1.SModelRootImpl && !(0, scroll_1.findViewportScrollbar)(event)) || !(target instanceof smodel_1.SModelRootImpl)) { | ||
// Mouse up on everything that's not root or root but not over ViewPort's scroll bars > deselect all | ||
return this.handleDeselectAll(this.collectElementsToDeselect(target, undefined), event); | ||
@@ -251,2 +248,3 @@ } | ||
} | ||
this.isMouseDown = false; | ||
this.hasDragged = false; | ||
@@ -253,0 +251,0 @@ return []; |
{ | ||
"name": "sprotty", | ||
"version": "0.15.0-next.771285d.18+771285d", | ||
"version": "0.15.0-next.781c032.25+781c032", | ||
"description": "A next-gen framework for graphical views", | ||
@@ -31,18 +31,15 @@ "license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)", | ||
"snabbdom": "^3.5.1", | ||
"sprotty-protocol": "0.15.0-next.771285d.18+771285d", | ||
"sprotty-protocol": "0.15.0-next.781c032.25+781c032", | ||
"tinyqueue": "^2.0.3" | ||
}, | ||
"devDependencies": { | ||
"@types/chai": "^4.3.6", | ||
"@types/file-saver": "^2.0.5", | ||
"@types/jsdom": "^21.1.3", | ||
"jsdom": "^22.1.0", | ||
"happy-dom": "^12.10.3", | ||
"snabbdom-to-html": "^7.1.0" | ||
}, | ||
"scripts": { | ||
"prepare": "yarn run clean && yarn run build", | ||
"clean": "rimraf lib artifacts", | ||
"build": "tsc -p ./tsconfig.json", | ||
"test": "vitest run --config ../../vite.config.ts", | ||
"watch": "tsc -w -p ./tsconfig.json" | ||
"clean": "shx rm -fr lib artifacts *.tsbuildinfo", | ||
"build": "tsc", | ||
"watch": "tsc --watch", | ||
"test": "vitest run --config ../../vite.config.ts" | ||
}, | ||
@@ -56,3 +53,3 @@ "files": [ | ||
"types": "lib/index", | ||
"gitHead": "771285d3f53ec404db33536eba800861ad20c5dd" | ||
"gitHead": "781c03256c6efb3e241de3d85d234b9cb954e075" | ||
} |
@@ -30,4 +30,4 @@ # Sprotty | ||
- [Example: DSL in the Cloud](http://github.com/TypeFox/theia-xtext-sprotty-example) – an example using Xtext, Theia and Sprotty to create a DSL workbench in the cloud | ||
- [Example: npm dependencies](https://github.com/TypeFox/npm-dependency-graph) – discover dependencies of npm packages | ||
- [Yangster](https://github.com/theia-ide/yang-vscode) a VS Code extension for the YANG language | ||
- [Example: view filtering](https://github.com/TypeFox/sprotty-view-filtering) – using filtering to efficiently navigate a large dataset of publications and citations | ||
- [Example: nested graphs](https://github.com/TypeFox/sprotty-nested-demo) – expanding nested subgraphs in-place to efficiently navigate a large project with TypeScript modules | ||
- [Yangster](https://github.com/TypeFox/yang-vscode) – a VS Code extension for the YANG language |
@@ -17,2 +17,3 @@ /******************************************************************************** | ||
import 'reflect-metadata'; | ||
import { injectable } from "inversify"; | ||
@@ -19,0 +20,0 @@ import { Action } from "sprotty-protocol/lib/actions"; |
@@ -110,3 +110,3 @@ /******************************************************************************** | ||
protected calculateSegment(edge: SRoutableElementImpl, t: number): { segmentStart: Point, segmentEnd: Point, lambda: number} | undefined { | ||
protected calculateSegment(edge: SRoutableElementImpl, t: number): { segmentStart: Point, segmentEnd: Point, lambda: number } | undefined { | ||
if (t < 0 || t > 1) | ||
@@ -168,3 +168,3 @@ return undefined; | ||
return edge.target.position; | ||
else { | ||
else { | ||
return route[route.length - 1]; | ||
@@ -213,3 +213,3 @@ } | ||
protected getAnchorComputer(connectable: SConnectableElementImpl): IAnchorComputer { | ||
return this.anchorRegistry.get(this.kind, connectable.anchorKind); | ||
return this.anchorRegistry.get(this.kind, connectable.anchorKind); | ||
} | ||
@@ -303,2 +303,21 @@ | ||
edge.index.remove(edge); | ||
if (edge.id === edgeInProgressID) { | ||
// create a proper edge id after connecting the edge in progress | ||
const idGen = (counter: number) => `${edge.sourceId}_to_${edge.targetId}_${counter}`; | ||
let idx = 0; | ||
let newId = idGen(idx); | ||
while (edge.index.getById(newId) !== undefined) { | ||
newId = idGen(++idx); | ||
} | ||
edge.id = newId; | ||
const progressTargetHandle = edge.children.find(child => child.id === edgeInProgressTargetHandleID); | ||
if (progressTargetHandle instanceof SRoutingHandleImpl) { | ||
// remove in progress target handle | ||
edge.remove(progressTargetHandle); | ||
if (progressTargetHandle.danglingAnchor) { | ||
// remove dangling anchor | ||
progressTargetHandle.danglingAnchor.parent.remove(progressTargetHandle.danglingAnchor); | ||
} | ||
} | ||
} | ||
edge.index.add(edge); | ||
@@ -355,3 +374,3 @@ if (this.getSelfEdgeIndex(edge) > -1) { | ||
{ x: sourceAnchors.get(Side.LEFT).x - standardDist, y: sourceAnchors.get(Side.BOTTOM).y + standardDist }, | ||
{ x: sourceAnchors.get(Side.LEFT).x - standardDist, y: sourceAnchors.get(Side.LEFT).y + delta}, | ||
{ x: sourceAnchors.get(Side.LEFT).x - standardDist, y: sourceAnchors.get(Side.LEFT).y + delta }, | ||
]; | ||
@@ -358,0 +377,0 @@ case 2: |
@@ -135,2 +135,3 @@ /******************************************************************************** | ||
hasDragged = false; | ||
isMouseDown = false; | ||
@@ -141,2 +142,3 @@ override mouseDown(target: SModelElementImpl, event: MouseEvent): (Action | Promise<Action>)[] { | ||
} | ||
this.isMouseDown = true; | ||
const buttonHandled = this.handleButton(target, event); | ||
@@ -156,14 +158,10 @@ if (buttonHandled) { | ||
} | ||
if (selectableTarget !== undefined) { | ||
if (!selectableTarget.selected) { | ||
this.wasSelected = false; | ||
return this.handleSelectTarget(selectableTarget, deselectedElements, event); | ||
} else if (isCtrlOrCmd(event)) { | ||
this.wasSelected = false; | ||
return this.handleDeselectTarget(selectableTarget, event); | ||
} else { | ||
this.wasSelected = true; | ||
} | ||
if (!selectableTarget.selected) { | ||
this.wasSelected = false; | ||
return this.handleSelectTarget(selectableTarget, deselectedElements, event); | ||
} else if (isCtrlOrCmd(event)) { | ||
this.wasSelected = false; | ||
return this.handleDeselectTarget(selectableTarget, event); | ||
} else { | ||
return this.handleDeselectAll(deselectedElements, event); | ||
this.wasSelected = true; | ||
} | ||
@@ -223,3 +221,3 @@ } | ||
override mouseMove(target: SModelElementImpl, event: MouseEvent): Action[] { | ||
this.hasDragged = true; | ||
this.hasDragged = this.isMouseDown; | ||
return []; | ||
@@ -234,6 +232,6 @@ } | ||
if (this.wasSelected) { | ||
return [SelectAction.create({selectedElementsIDs:[selectableTarget.id],deselectedElementsIDs:[]})]; | ||
return [SelectAction.create({ selectedElementsIDs: [selectableTarget.id], deselectedElementsIDs: [] })]; | ||
} | ||
} else if (target instanceof SModelRootImpl && !findViewportScrollbar(event)) { | ||
// Mouse up on root but not over ViewPort's scroll bars > deselect all | ||
} else if ((target instanceof SModelRootImpl && !findViewportScrollbar(event)) || !(target instanceof SModelRootImpl)) { | ||
// Mouse up on everything that's not root or root but not over ViewPort's scroll bars > deselect all | ||
return this.handleDeselectAll(this.collectElementsToDeselect(target, undefined), event); | ||
@@ -243,2 +241,3 @@ } | ||
} | ||
this.isMouseDown = false; | ||
this.hasDragged = false; | ||
@@ -245,0 +244,0 @@ return []; |
@@ -20,18 +20,16 @@ /******************************************************************************** | ||
import { beforeAll, describe, expect, it } from 'vitest'; | ||
import { h } from 'snabbdom'; | ||
import { VNode, h } from 'snabbdom'; | ||
import virtualize from './virtualize'; | ||
import setup from '../utils/test-helper'; | ||
/** | ||
* @vitest-environment happy-dom | ||
*/ | ||
describe("virtualize (happy path)", () => { | ||
beforeAll(() => { | ||
setup(); | ||
}); | ||
it("should convert a single node with no children", () => { | ||
expect(virtualize("<div />")).to.deep.equal(h("div")); | ||
expect(virtualizeHelper("<div />")).to.deep.equal(h("DIV")); | ||
}); | ||
it("should convert a node with text node", () => { | ||
expect(virtualize("<div> Test. </div>")).to.deep.equal( | ||
h("div", [" Test. "]) | ||
expect(virtualizeHelper("<div> Test. </div>")).to.deep.equal( | ||
h("DIV", [" Test. "]) | ||
); | ||
@@ -41,6 +39,6 @@ }); | ||
it("should convert nodes with children", () => { | ||
expect(virtualize("<div><span>a</span><span>b</span></div>")).to.deep.equal( | ||
h("div", [ | ||
h("span", ["a"]), | ||
h("span", ["b"]) | ||
expect(virtualizeHelper("<div><span>a</span><span>b</span></div>")).to.deep.equal( | ||
h("DIV", [ | ||
h("SPAN", ["a"]), | ||
h("SPAN", ["b"]) | ||
]) | ||
@@ -52,9 +50,9 @@ ); | ||
expect( | ||
virtualize( | ||
virtualizeHelper( | ||
"<book><title>The Three-Body Problem</title><author>Liu Cixin</author></book>" | ||
) | ||
).to.deep.equal( | ||
h("book", [ | ||
h("title", ["The Three-Body Problem"]), | ||
h("author", ["Liu Cixin"]), | ||
h("BOOK", [ | ||
h("TITLE", ["The Three-Body Problem"]), | ||
h("AUTHOR", ["Liu Cixin"]), | ||
]) | ||
@@ -67,4 +65,4 @@ ); | ||
'<div class="sprotty1 sprotty2" style="display: none !important; background-color: blue; font-weight: bold" data-test="test" />'; | ||
expect(virtualize(element)).to.deep.equal( | ||
h("div", { | ||
expect(virtualizeHelper(element)).to.deep.equal( | ||
h("DIV", { | ||
class: { | ||
@@ -87,4 +85,4 @@ sprotty1: true, | ||
it("should ignore empty attributes", () => { | ||
expect(virtualize("<span style='' />")).to.deep.equal(h("span")); | ||
expect(virtualize("<span class='' />")).to.deep.equal(h("span")); | ||
expect(virtualizeHelper("<span style='' />")).to.deep.equal(h("SPAN")); | ||
expect(virtualizeHelper("<span class='' />")).to.deep.equal(h("SPAN")); | ||
}); | ||
@@ -94,6 +92,6 @@ | ||
const input = "<textarea placeholder=' Test1, \n\n Test2 '></textarea>"; | ||
expect(virtualize(input)).to.deep.equal( | ||
h("textarea", { | ||
expect(virtualizeHelper(input)).to.deep.equal( | ||
h("TEXTAREA", { | ||
attrs: { | ||
placeholder: " Test1, Test2 ", | ||
placeholder: " Test1, \n\n Test2 ", | ||
}, | ||
@@ -107,4 +105,4 @@ }) | ||
"<textarea placeholder='& Test1, > Test2 '></textarea>"; | ||
expect(virtualize(input)).to.deep.equal( | ||
h("textarea", { | ||
expect(virtualizeHelper(input)).to.deep.equal( | ||
h("TEXTAREA", { | ||
attrs: { | ||
@@ -119,14 +117,13 @@ placeholder: "& Test1, > Test2 ", | ||
expect( | ||
virtualize( | ||
virtualizeHelper( | ||
"<div> <!-- comment A --> <span>Test1</span> <!-- Comment B --> Test2</div>" | ||
) | ||
).to.deep.equal(h("div", [" ", " ", h("span", ["Test1"]), " ", " Test2"])); | ||
).to.deep.equal(h("DIV", [" ", " ", h("SPAN", ["Test1"]), " ", " Test2"])); | ||
}); | ||
}); | ||
/** | ||
* @vitest-environment happy-dom | ||
*/ | ||
describe("virtualize (bad path)", () => { | ||
beforeAll(() => { | ||
setup(); | ||
}); | ||
it("should return null when given null or empty string", () => { | ||
@@ -138,12 +135,17 @@ expect(virtualize()).to.be.null; | ||
it("should return parser error when given a single text node", () => { | ||
const actual = virtualize("Text content!"); | ||
expect(actual?.sel).to.equal("parsererror"); | ||
const actual = virtualizeHelper("Text content!") as VNode; | ||
expect(actual?.sel).to.equal(undefined); | ||
}); | ||
}); | ||
it("should return parser error when gives multiple top-level nodes", () => { | ||
const actual = virtualize( | ||
"<div><h1>Something</h1></div><span>Something more</span>" | ||
); | ||
expect(actual?.sel).to.equal("parsererror"); | ||
}); | ||
}); | ||
function virtualizeHelper(html?: string) { | ||
const dom = virtualize(html); | ||
if (!dom) { | ||
return null; | ||
} | ||
const element = (dom.children![1] as VNode).children![0]; | ||
return element; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
2709946
3
44529
813