Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/core/__tests__/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ limitations under the License.
*/

import { Cell, type CellStateStyle, Graph } from '../src';
import { jest } from '@jest/globals';

/**
* Creates a new {@link Graph} without `container` (use the default value of the parameters).
Expand Down
4 changes: 2 additions & 2 deletions packages/core/__tests__/view/mixins/ConnectionsMixin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ describe('getAllConnectionConstraints', () => {
super(null!);
this.constraints = constraints;
}
parseDescription() {
override parseDescription() {
// do nothing
}
parseConstraints() {
override parseConstraints() {
// do nothing, constraints passed in constructor
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/serialization/codecs/CellCodec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ export class CellCodec extends ObjectCodec {
/**
* Overridden to disable conversion of value to number.
*/
isNumericAttribute(dec: Codec, attr: Element, obj: Cell) {
override isNumericAttribute(dec: Codec, attr: Element, obj: Cell) {
return attr.nodeName !== 'value' && super.isNumericAttribute(dec, attr, obj);
}

/**
* Excludes user objects that are XML nodes.
*/
isExcluded(obj: Cell, attr: string, value: Element, isWrite: boolean) {
override isExcluded(obj: Cell, attr: string, value: Element, isWrite: boolean) {
return (
super.isExcluded(obj, attr, value, isWrite) ||
(isWrite && attr === 'value' && isElement(value))
Expand All @@ -89,7 +89,7 @@ export class CellCodec extends ObjectCodec {
/**
* Encodes a {@link Cell} and wraps the XML up inside the XML of the user object (inversion).
*/
afterEncode(enc: Codec, obj: Cell, node: Element) {
override afterEncode(enc: Codec, obj: Cell, node: Element) {
if (isElement(obj.value)) {
// Wraps the graphical annotation up in the user object (inversion)
// by putting the result of the default encoding into a clone of the
Expand All @@ -111,7 +111,7 @@ export class CellCodec extends ObjectCodec {
/**
* Decodes an {@link Cell} and uses the enclosing XML node as the user object for the cell (inversion).
*/
beforeDecode(dec: Codec, node: Element, obj: Cell): Element | null {
override beforeDecode(dec: Codec, node: Element, obj: Cell): Element | null {
let inner: Element | null = <Element>node.cloneNode(true);
const classname = this.getName();

Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/serialization/codecs/ChildChangeCodec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class ChildChangeCodec extends ObjectCodec {
* Returns `true` for the child attribute if the child cell had a previous parent or if we're reading the
* child as an attribute rather than a child node, in which case it's always a reference.
*/
isReference(obj: any, attr: string | null, value: any, isWrite: boolean) {
override isReference(obj: any, attr: string | null, value: any, isWrite: boolean) {
if (attr === 'child' && (!isWrite || obj.model.contains(obj.previous))) {
return true;
}
Expand All @@ -61,7 +61,7 @@ export class ChildChangeCodec extends ObjectCodec {
/**
* Excludes references to parent or previous if not in the model.
*/
isExcluded(obj: any, attr: string, value: any, write: boolean) {
override isExcluded(obj: any, attr: string, value: any, write: boolean) {
return (
super.isExcluded(obj, attr, value, write) ||
(write &&
Expand All @@ -74,7 +74,7 @@ export class ChildChangeCodec extends ObjectCodec {
/**
* Encodes the child recursively and adds the result to the given node.
*/
afterEncode(enc: Codec, obj: any, node: Element) {
override afterEncode(enc: Codec, obj: any, node: Element) {
if (this.isReference(obj, 'child', obj.child, true)) {
// Encodes as reference (id)
node.setAttribute('child', enc.getId(obj.child));
Expand All @@ -92,7 +92,7 @@ export class ChildChangeCodec extends ObjectCodec {
/**
* Decodes any child nodes as using the respective codec from the registry.
*/
beforeDecode(dec: Codec, _node: Element, obj: any): any {
override beforeDecode(dec: Codec, _node: Element, obj: any): any {
if (isElement(_node.firstChild)) {
// Makes sure the original node isn't modified
const node = _node.cloneNode(true);
Expand Down Expand Up @@ -135,7 +135,7 @@ export class ChildChangeCodec extends ObjectCodec {
/**
* Restores object state in the child change.
*/
afterDecode(dec: Codec, node: Element, obj: any): any {
override afterDecode(dec: Codec, node: Element, obj: any): any {
// Cells are decoded here after a complete transaction so the previous
// parent must be restored on the cell for the case where the cell was
// added. This is needed for the local model to identify the cell as a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class GenericChangeCodec extends ObjectCodec {
/**
* Restores the state by assigning the previous value.
*/
afterDecode(dec: Codec, _node: Element, obj: any): any {
override afterDecode(dec: Codec, _node: Element, obj: any): any {
// Allows forward references in sessions. This is a workaround
// for the sequence of edits in mxGraph.moveCells and cellsAdded.
if (isNode(obj.cell)) {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/serialization/codecs/ModelCodec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class ModelCodec extends ObjectCodec {
* Encodes the given {@link GraphDataModel} by writing a (flat) XML sequence of cell nodes as produced by the {@link CellCodec}.
* The sequence is wrapped-up in a node with the name `root`.
*/
encodeObject(enc: Codec, obj: Cell, node: Element) {
override encodeObject(enc: Codec, obj: Cell, node: Element) {
const rootNode = enc.document.createElement('root');
enc.encodeCell(obj.getRoot(), rootNode);
node.appendChild(rootNode);
Expand All @@ -45,7 +45,7 @@ export class ModelCodec extends ObjectCodec {
/**
* Overrides decode child to handle special child nodes.
*/
decodeChild(dec: Codec, child: Element, obj: Cell | GraphDataModel) {
override decodeChild(dec: Codec, child: Element, obj: Cell | GraphDataModel) {
if (child.nodeName === 'root') {
this.decodeRoot(dec, child, <GraphDataModel>obj);
} else {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/serialization/codecs/RootChangeCodec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ export class RootChangeCodec extends ObjectCodec {
/**
* Encodes the child recursively.
*/
afterEncode(enc: Codec, obj: any, node: Element) {
override afterEncode(enc: Codec, obj: any, node: Element) {
enc.encodeCell(obj.root, node);
return node;
}

/**
* Decodes the optional children as cells using the respective decoder.
*/
beforeDecode(dec: Codec, node: Element, obj: any): any {
override beforeDecode(dec: Codec, node: Element, obj: any): any {
if (isElement(node.firstChild)) {
// Makes sure the original node isn't modified
node = <Element>node.cloneNode(true);
Expand All @@ -76,7 +76,7 @@ export class RootChangeCodec extends ObjectCodec {
/**
* Restores the state by assigning the previous value.
*/
afterDecode(_dec: Codec, _node: Element, obj: any): any {
override afterDecode(_dec: Codec, _node: Element, obj: any): any {
obj.previous = obj.root;

return obj;
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/serialization/codecs/StylesheetCodec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ export class StylesheetCodec extends ObjectCodec {
*
* @default false
*/
static allowEval = false;
static override allowEval = false;

/**
* Encodes a stylesheet. See {@link decode} for a description of the format.
*/
encode(enc: Codec, obj: Stylesheet): Element {
override encode(enc: Codec, obj: Stylesheet): Element {
const node = enc.document.createElement(this.getName());

for (const styleName of obj.styles.keys()) {
Expand Down Expand Up @@ -127,7 +127,7 @@ export class StylesheetCodec extends ObjectCodec {
* </Stylesheet>
* ```
*/
decode(dec: Codec, _node: Element, into: any): any {
override decode(dec: Codec, _node: Element, into: any): any {
const obj = into || new this.template.constructor();
const id = _node.getAttribute('id');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class TerminalChangeCodec extends ObjectCodec {
/**
* Restores the state by assigning the previous value.
*/
afterDecode(_dec: Codec, _node: Element, obj: any): any {
override afterDecode(_dec: Codec, _node: Element, obj: any): any {
obj.previous = obj.terminal;
return obj;
}
Expand Down
5 changes: 3 additions & 2 deletions packages/core/src/serialization/codecs/editor/EditorCodec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class EditorCodec extends ObjectCodec {
* </ui>
* ```
*/
afterDecode(_dec: Codec, node: Element, obj: Editor) {
override afterDecode(_dec: Codec, node: Element, obj: Editor) {
// Assigns the specified templates for edges
const defaultEdge = node.getAttribute('defaultEdge');

Expand All @@ -119,13 +119,14 @@ export class EditorCodec extends ObjectCodec {
node.removeAttribute('defaultGroup');
obj.defaultGroup = obj.templates[defaultGroup];
}

return obj;
}

/**
* Overrides decode child to handle special child nodes.
*/
decodeChild(dec: Codec, child: Element, obj: Editor) {
override decodeChild(dec: Codec, child: Element, obj: Editor) {
if (child.nodeName === 'Array') {
const role = child.getAttribute('as');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class EditorKeyHandlerCodec extends ObjectCodec {
/**
* Returns `null`.
*/
encode(_enc: Codec, _obj: EditorKeyHandler) {
override encode(_enc: Codec, _obj: EditorKeyHandler) {
return null;
}

Expand Down Expand Up @@ -67,7 +67,7 @@ export class EditorKeyHandlerCodec extends ObjectCodec {
*
* See also: <EditorKeyHandler.bindAction>, http://www.js-examples.com/page/tutorials__key_codes.html
*/
decode(dec: Codec, _node: Element, into: any) {
override decode(dec: Codec, _node: Element, into: any) {
if (into != null) {
const { editor } = into;
let node: Element | null = <Element | null>_node.firstChild;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ export class EditorPopupMenuCodec extends ObjectCodec {
/**
* Returns null.
*/
encode(_enc: Codec, _obj: Element): Element | null {
override encode(_enc: Codec, _obj: Element): Element | null {
return null;
}

/**
* Uses the given node as the config for {@link EditorPopupMenu}.
*/
decode(dec: Codec, node: Element, into: EditorPopupMenu) {
override decode(dec: Codec, node: Element, into: EditorPopupMenu) {
const inc = node.getElementsByTagName('include')[0];

if (inc != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class EditorToolbarCodec extends ObjectCodec {
/**
* Returns `null`.
*/
encode(_enc: any, _obj: any) {
override encode(_enc: any, _obj: any) {
return null;
}

Expand Down Expand Up @@ -130,7 +130,7 @@ export class EditorToolbarCodec extends ObjectCodec {
* </EditorToolbar>
* ```
*/
decode(dec: Codec, _node: Element, into: EditorToolbar) {
override decode(dec: Codec, _node: Element, into: EditorToolbar) {
if (into != null) {
const editor: Editor = into.editor!;
let node: Element | null = <Element | null>_node.firstChild;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/serialization/codecs/mxGraph/mxCellCodec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import type Codec from '../../Codec.js';
* @category Serialization with Codecs
*/
export class mxCellCodec extends CellCodec {
getName(): string {
override getName(): string {
return 'mxCell';
}

decodeAttribute(dec: Codec, attr: any, obj?: any) {
override decodeAttribute(dec: Codec, attr: any, obj?: any) {
const attributeNodeName = attr.nodeName;
if (obj && attributeNodeName == 'style') {
obj['style'] = convertStyleFromString(attr.value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ import Point from '../../../view/geometry/Point.js';
* @category Serialization with Codecs
*/
export class mxGeometryCodec extends ObjectCodec {
getName(): string {
override getName(): string {
return 'mxGeometry';
}

constructor() {
super(new Geometry());
}

afterDecode(dec: Codec, node: Element | null, obj?: any): any {
override afterDecode(dec: Codec, node: Element | null, obj?: any): any {
// Convert points to the right form
// input: [ { x: 420, y: 60 }, ... ]
// output: [ Point { _x: 420, _y: 60 }, ... ]
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/view/animate/Morphing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Morphing extends Animation {
/**
* Animation step.
*/
updateAnimation() {
override updateAnimation() {
super.updateAnimation();
const move = new CellStatePreview(this.graph);

Expand Down
14 changes: 7 additions & 7 deletions packages/core/src/view/canvas/SvgCanvas2D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class SvgCanvas2D extends AbstractCanvas2D {
* Default value for active pointer events.
* @default all
*/
pointerEventsValue = 'all';
override pointerEventsValue = 'all';

/**
* Padding to be added for text that is not wrapped to account for differences in font metrics on different platforms in pixels.
Expand Down Expand Up @@ -346,7 +346,7 @@ class SvgCanvas2D extends AbstractCanvas2D {
/**
* Rounds all numbers to 2 decimal points.
*/
format(value: number) {
override format(value: number) {
return parseFloat(value.toFixed(2));
}

Expand All @@ -370,7 +370,7 @@ class SvgCanvas2D extends AbstractCanvas2D {
/**
* Returns any offsets for rendering pixels.
*/
reset() {
override reset() {
super.reset();
this.gradients = {};
}
Expand Down Expand Up @@ -879,7 +879,7 @@ class SvgCanvas2D extends AbstractCanvas2D {
/**
* Experimental implementation for hyperlinks.
*/
setLink(link: string) {
override setLink(link: string) {
if (!link) {
this.root = this.originalRoot;
} else {
Expand All @@ -903,7 +903,7 @@ class SvgCanvas2D extends AbstractCanvas2D {
/**
* Sets the rotation of the canvas. Note that rotation cannot be concatenated.
*/
rotate(theta: number, flipH: boolean, flipV: boolean, cx: number, cy: number) {
override rotate(theta: number, flipH: boolean, flipV: boolean, cx: number, cy: number) {
if (theta !== 0 || flipH || flipV) {
const s = this.state;
cx += s.dx;
Expand Down Expand Up @@ -948,9 +948,9 @@ class SvgCanvas2D extends AbstractCanvas2D {
}

/**
* Extends superclass to create path.
* Begins a new path.
*/
begin() {
override begin() {
super.begin();
this.node = this.createElement('path');
}
Expand Down
Loading