Skip to content

Commit

Permalink
chore(webapps): adjust to 7.22
Browse files Browse the repository at this point in the history
  • Loading branch information
venetrius authored Oct 2, 2024
2 parents 3fc5012 + a519b9c commit f9332cf
Show file tree
Hide file tree
Showing 8 changed files with 5,733 additions and 12,416 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
var DEFAULT_RENDER_PRIORITY = 1000;

/**
* @typedef {import('../model').Base} Base
* @typedef {import('../model').Connection} Connection
* @typedef {import('../model').Shape} Shape
* @typedef {import('../core/Types').ElementLike} Element
* @typedef {import('../core/Types').ConnectionLike} Connection
* @typedef {import('../core/Types').ShapeLike} Shape
*
* @typedef {import('../core/EventBus').default} EventBus
*/
Expand Down Expand Up @@ -48,9 +48,9 @@ function BaseRenderer(eventBus, renderPriority) {
/**
* Checks whether an element can be rendered.
*
* @param {Base} element The element to be rendered.
* @param {Element} element The element to be rendered.
*
* @returns {boolean} Whether the element can be rendered.
* @return {boolean} Whether the element can be rendered.
*/
BaseRenderer.prototype.canRender = function(element) {};

Expand All @@ -60,7 +60,7 @@ BaseRenderer.prototype.canRender = function(element) {};
* @param {SVGElement} visuals The SVG element to draw the shape into.
* @param {Shape} shape The shape to be drawn.
*
* @returns {SVGElement} The SVG element of the shape drawn.
* @return {SVGElement} The SVG element of the shape drawn.
*/
BaseRenderer.prototype.drawShape = function(visuals, shape) {};

Expand All @@ -70,7 +70,7 @@ BaseRenderer.prototype.drawShape = function(visuals, shape) {};
* @param {SVGElement} visuals The SVG element to draw the connection into.
* @param {Connection} connection The connection to be drawn.
*
* @returns {SVGElement} The SVG element of the connection drawn.
* @return {SVGElement} The SVG element of the connection drawn.
*/
BaseRenderer.prototype.drawConnection = function(visuals, connection) {};

Expand Down Expand Up @@ -112,6 +112,7 @@ function ensureImported(element, target) {
* appendTo utility
*/


/**
* Append a node to a target element and return the appended node.
*
Expand All @@ -128,6 +129,7 @@ function appendTo(element, target) {
* append utility
*/


/**
* Append a node to an element
*
Expand Down Expand Up @@ -259,9 +261,7 @@ function setAttributes(node, attrs) {
*/
function attr(node, name, value) {
if (typeof name === 'string') {
if (value !== undefined) {
setAttribute(node, name, value);
} else {
{
return getAttribute(node, name);
}
} else {
Expand All @@ -271,16 +271,6 @@ function attr(node, name, value) {
return node;
}

function remove(element) {
var parent = element.parentNode;

if (parent) {
parent.removeChild(element);
}

return element;
}

var ns = {
svg: 'http://www.w3.org/2000/svg'
};
Expand All @@ -289,6 +279,7 @@ var ns = {
* DOM parsing utility
*/


var SVG_START = '<svg xmlns="' + ns.svg + '"';

function parse(svg) {
Expand Down Expand Up @@ -340,6 +331,7 @@ function parseDocument(svg) {
*/



/**
* Create a specific type from name or SVG markup.
*
Expand All @@ -351,15 +343,23 @@ function parseDocument(svg) {
function create(name, attrs) {
var element;

name = name.trim();

if (name.charAt(0) === '<') {
element = parse(name).firstChild;
element = document.importNode(element, true);
} else {
element = document.createElementNS(ns.svg, name);
}

if (attrs) {
attr(element, attrs);
return element;
}

function remove(element) {
var parent = element.parentNode;

if (parent) {
parent.removeChild(element);
}

return element;
Expand All @@ -370,7 +370,7 @@ function create(name, attrs) {
*
* @template T
*
* @param {T[][]} arr
* @param {T[][] | T[] | null} [arr]
*
* @return {T[]}
*/
Expand Down Expand Up @@ -566,10 +566,15 @@ function toNum(arg) {
return Number(arg);
}

/**
* @typedef { import('../model/Types').Element } Element
* @typedef { import('../model/Types').ModdleElement } ModdleElement
*/

/**
* Is an element of the given BPMN type?
*
* @param {djs.model.Base|ModdleElement} element
* @param {Element|ModdleElement} element
* @param {string} type
*
* @return {boolean}
Expand All @@ -584,8 +589,8 @@ function is(element, type) {
/**
* Return true if element has any of the given types.
*
* @param {djs.model.Base} element
* @param {Array<string>} types
* @param {Element|ModdleElement} element
* @param {string[]} types
*
* @return {boolean}
*/
Expand All @@ -598,7 +603,7 @@ function isAny(element, types) {
/**
* Return the business object for a given element.
*
* @param {djs.model.Base|ModdleElement} element
* @param {Element|ModdleElement} element
*
* @return {ModdleElement}
*/
Expand All @@ -613,14 +618,20 @@ function getBusinessObject(element) {
*/

/**
* @param {Component[]} elements
* @param {Component[] | Component[][]} elements
*
* @return {string}
*/
function componentsToPath(elements) {
return elements.flat().join(',').replace(/,?([A-z]),?/g, '$1');
}

/**
* @param {ShapeLike} shape
* @param {number} [borderRadius]
*
* @return {string} path
*/
function getRoundRectPath(shape, borderRadius) {

var x = shape.x,
Expand Down Expand Up @@ -735,7 +746,7 @@ function drawRect(parentNode, width, height, borderRadius, strokeColor) {

// copied from https://github.com/bpmn-io/diagram-js/blob/master/lib/core/GraphicsFactory.js
function prependTo(newNode, parentNode, siblingNode) {
parentNode.insertBefore(newNode, siblingNode || parentNode.firstChild);
parentNode.insertBefore(newNode, parentNode.firstChild);
}

/*
Expand Down
Loading

0 comments on commit f9332cf

Please sign in to comment.