bpmn-io / bpmn-js-color-picker Goto Github PK
View Code? Open in Web Editor NEWA simple color picker for your BPMN elements.
License: MIT License
A simple color picker for your BPMN elements.
License: MIT License
Am I missing something? Is this addon only meant to color the border around tasks/events?
Is it not also possible to fill the background itself too?
I know it's possible to do it using this prototype https://github.com/bpmn-io/bpmn-js-nyan/tree/master/lib/color-picker
Any plans to add this option to https://github.com/bpmn-io/bpmn-js-color-picker ?
Many thanks!
If the bpmn-js diagram is not in the top left corner, then the color picker popup positions itself as if it was in the top left corner regardless of where it actually is.
I believe this is because of this line
I was able to work around the problem with this hack
const correctPopupMenuPosition = () => {
const popup = document.querySelector('.djs-popup');
if (popup) {
const selection = modeler.get('selection');
const currentElement = selection.get();
if (currentElement.length) {
const element = currentElement[0];
const gfx = modeler.get('elementRegistry').getGraphics(element);
const elementBBox = gfx.getBoundingClientRect();
const offsetX = 30; // Adjust as needed
const offsetY = 5; // Adjust as needed
popup.style.left = `${elementBBox.right + offsetX}px`;
popup.style.top = `${elementBBox.top - offsetY}px`;
}
}
};
// Correct the popup position when it's opened
modeler.on('popupMenu.open', function () {
setTimeout(correctPopupMenuPosition, 0);
}, 1000);
// Reapply position corrections if the popup changes its style
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.attributeName === 'style') {
correctPopupMenuPosition();
}
});
});
// Observe the popup for style changes
document.addEventListener('mouseover', function (e) {
if (e.target.closest('.djs-popup')) {
observer.observe(document.querySelector('.djs-popup'), { attributes: true });
}
});
// Disconnect the observer when the popup is closed
modeler.on('popupMenu.close', function () {
observer.disconnect();
});
I am using bpmn-js. I want to add custom colors in palette. Can i add my own colors to this palette ? If you can add custom colors, you can show an example ?
Is your feature request related to a problem? Please describe
Currently, the colors are hardcoded, and I need to fork the project in order to introduce own sets. Let's make it configurable.
Describe the solution you'd like
Pass config.colors
to the Modeler to set my own color set based on https://github.com/bpmn-io/bpmn-js-color-picker/blob/master/colors/ColorPopupProvider.js#L20
Describe alternatives you've considered
Do nothing.
Additional context
when I run the example of bpmn-js-in-color, it can work successfuly.But when I try to import the color moduler into my project, it always appear this error
What should we do?
Update to [email protected]
and make the adjustments necessary for the new popup menu.
Why should we do it?
To ensure the look of the color picker works with the new popop menu UI.
This is the code I came up with that hides the color picker on all elements except bpmn:Task. But it causes a micro-flicker. Is there a better way? If you remove the setTimeout below then it does not work.
export default function SelectiveColorPicker(modeler) {
const eventBus = modeler.get('eventBus');
// Intercept the display of the context pad
eventBus.on('contextPad.create', function (event) {
if (event.target.type !== 'bpmn:Task') {
setTimeout(() => {
const colorPickerEntry = event.pad.html.querySelector('[data-action="set-color"]');
if (colorPickerEntry) {
colorPickerEntry.style.display = 'none';
}
});
}
});
}
Is your feature request related to a problem? Please describe
Describe the Bug
I created new reactJs project to apply BPMN.IO
I have this package.json file
"dependencies": {
"bpmn-font": "^0.10.0",
"bpmn-js": "^7.4.0",
"bpmn-js-in-color": "github:bpmn-io/bpmn-js-in-color",
"diagram-js-minimap": "^2.0.3",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.0",
"tiny-svg": "^2.2.2",
"web-vitals": "^0.2.4"
}
In my App.js
import React, { Fragment, Component } from "react";
import BpmnModeler from "bpmn-js/lib/Modeler";
import { emptyBpmn } from "./diagram.bpmn.jsx";
import bpmnJsInColor from "bpmn-js-in-color";
import minimapModule from "diagram-js-minimap";
import "./vendor/diagram-js.css";
import "bpmn-font/dist/css/bpmn-embedded.css";
import "diagram-js-minimap/assets/diagram-js-minimap.css";
class App extends Component {
modeler = null;
saveModelHandler = (event) => {
event.preventDefault();
};
componentDidMount = () => {
this.modeler = new BpmnModeler({
container: "#bpmnview",
additionalModules: [require("bpmn-js-in-color")],
keyboard: { bindTo: document },
});
this.newBpmnDiagram();
};
newBpmnDiagram = () => {
this.openBpmnDiagram(emptyBpmn);
};
openBpmnDiagram = async (xml) => {
await this.modeler.importXML(xml);
var canvas = this.modeler.get("canvas");
canvas.zoom("fit-viewport");
};
render = () => {
return (
<Fragment>
<div
id="bpmnview"
style={{ width: "100%", height: "100vh", float: "left" }}
></div>
</Fragment>
);
};
}
export default App;
When I enter npm start
. It throws error
**TypeError: Object prototype may only be an Object or null: undefined**
inherits
**node_modules/inherits/inherits_browser.js:6**
3 | module.exports = function inherits(ctor, superCtor) {
4 | if (superCtor) {
5 | ctor.super_ = superCtor
> 6 | ctor.prototype = Object.create(superCtor.prototype, {
| ^ 7 | constructor: {
8 | value: ctor,
9 | enumerable: false,
Environment
Also mentioned in forum.
What should we do?
Colors are currently hardcoded as CSS classes. Make it possible to generate (arbitrary) entries dynamically.
Why should we do it?
Required by #11
Describe the Bug
Following the instructions for running the example (one command), I get an error.
Steps to Reproduce
$ git clone <repository>
$ cd bpmn-js-in-color/example
$ npm run dev
> [email protected] dev /home/.../git/bpmn-js-in-color
> grunt auto-build
Loading "Gruntfile.js" tasks...ERROR
>> Error: Cannot find module 'load-grunt-tasks'
>> Require stack:
>> - /home/.../git/bpmn-js-in-color/Gruntfile.js
>> - /usr/share/nodejs/grunt/lib/grunt/task.js
>> - /usr/share/nodejs/grunt/lib/grunt.js
>> - /usr/share/nodejs/grunt-cli/bin/grunt
Warning: Task "auto-build" not found. Use --force to continue.
Aborted due to warnings.
npm ERR! code ELIFECYCLE
npm ERR! errno 3
npm ERR! [email protected] dev: `grunt auto-build`
npm ERR! Exit status 3
npm ERR!
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
Expected Behavior
I expect some sort of indication reporting that I can test the BPMN viewer/modeler with colors
Environment
Is your feature request related to a problem? Please describe
Make coloring multi-element aware, it is a grouping feature, at the core.
What should we do?
Do some refining and clean up:
To-Do:
Why should we do it?
Improve the color picker in order to include it in camunda-bpmn-js
.
Allow color extensibility for bpmn-js users.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.