Add files via upload
This commit is contained in:
parent
392aebe0df
commit
a3243dd1ba
14 changed files with 871 additions and 0 deletions
62
CustomOutlineModule.ts
Normal file
62
CustomOutlineModule.ts
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
import { Element } from 'diagram-js/lib/model/Types';
|
||||
import { Outline } from 'diagram-js/lib/features/outline/OutlineProvider';
|
||||
import OutlineProvider from 'diagram-js/lib/features/outline/OutlineProvider';
|
||||
import {
|
||||
attr as svgAttr,
|
||||
create as svgCreate} from 'tiny-svg';
|
||||
|
||||
import Styles from 'diagram-js/lib/draw/Styles';
|
||||
|
||||
function CustomOutlineProvider(outline:OutlineProvider, styles:Styles) {
|
||||
this._styles = styles;
|
||||
outline.registerProvider(this);
|
||||
}
|
||||
|
||||
CustomOutlineProvider.$inject = [
|
||||
'outline',
|
||||
'styles'
|
||||
];
|
||||
|
||||
CustomOutlineProvider.prototype.getOutline = function(element:Element) {
|
||||
if (element.type === 'custom:circle') {
|
||||
const outline = svgCreate('circle');
|
||||
|
||||
svgAttr(outline , {
|
||||
x: `${element.x}`,
|
||||
y: `${element.y}`,
|
||||
cx: element.width / 2,
|
||||
cy: element.height / 2,
|
||||
r: 60,
|
||||
fill: "none",
|
||||
});
|
||||
|
||||
console.log(outline);
|
||||
return outline;
|
||||
}
|
||||
}
|
||||
|
||||
CustomOutlineProvider.prototype.updateOutline = function(element: Element, outline: Outline) {
|
||||
if (element.type === 'custom:circle') {
|
||||
outline = svgCreate('rect');
|
||||
|
||||
svgAttr(outline , {
|
||||
x: `${element.x}`,
|
||||
y: `${element.y}`,
|
||||
cx: element.width / 2,
|
||||
cy: element.height / 2,
|
||||
r: 60,
|
||||
fill: "none",
|
||||
});
|
||||
}
|
||||
console.log(outline);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const CustomOutlineModule = {
|
||||
__init__: ['outlineProvider'],
|
||||
__depends__: [ 'Outline' ],
|
||||
outlineProvider: ['type', CustomOutlineProvider]
|
||||
};
|
||||
|
||||
export default CustomOutlineModule;
|
||||
Loading…
Add table
Add a link
Reference in a new issue