Coder Social home page Coder Social logo

bpmn-js-color-picker's People

Contributors

barmac avatar mojtaba-khallash avatar nikku avatar philippfromme avatar renovate[bot] avatar stanton avatar tk avatar vesper8 avatar vkatushenok avatar zxuanhong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bpmn-js-color-picker's Issues

color picker popup positioning only works when diagram is full screen or in the top left corner

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

pad = contextPad.getPad(elements).html;

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();
      });

Exclude color-picker

image

Can i exclude color-picker for different element types and how to do it ? (this is not written in the documentation) For example, I want to exclude color-picker for Participant

Custom colors

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 ?

eventBus.on is not a function

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

Is it possible to only have the color picker available on bpmn:Task elements? See my current solution

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';
        }
      });
    }
  });
}

TypeError: Object prototype may only be an Object or null: undefined

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

  • Host (Browser/Node version),[Macbook pro, Chrome 69, Node v14.4.0 LTS]
  • Library version: [e.g. 2.0.0]

Also mentioned in forum.

Example not working

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

  • Host (Browser/Node version), if applicable: [e.g. MS Edge 18, Chrome 69, Node 10 LTS] : browser not relevant, node v12.18.2
  • OS: [e.g. Windows 7] Linux Ubuntu 20.10
  • Library version: [e.g. 2.0.0] the current version on the repository

Prepare `bpmn-js-color-picker` to be included in camunda modeling

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.