GithubHelp home page GithubHelp logo

Adding New Buttons about dante HOT 7 CLOSED

michelson avatar michelson commented on July 17, 2024
Adding New Buttons

from dante.

Comments (7)

michelson avatar michelson commented on July 17, 2024

Hi @AdamOstrove ,

that's a very interesting approach. I will look forward of any progress on this.
Tomorrow I will play with your branch to see how it works

thanks!

from dante.

butsjoh avatar butsjoh commented on July 17, 2024

+1 Any idea when this is coming to the main branch?

from dante.

michelson avatar michelson commented on July 17, 2024

Hi @AdamOstrove.

Please check branch modular-tooltip I've came up with the following solution based on your concept design. I've decoupled the Tooltip view in widgets (image , extract & embed) which are inherited from a Dante.View.TooltipWidget object.

So now you can inherit from the new Dante.View.TooltipWidget. and create new instances of tooltip button with a custom behavior.

window.MyCustomTooltip = Dante.View.TooltipWidget.extend({
  initialize: function(opts) {
    if (opts == null) {
      opts = {};
    }
    this.icon = opts.icon || "icon-video";
    this.title = opts.title || "Add a Custom Thing!";
    this.action = opts.action || "custom-embed-simple";
    return this.current_editor = opts.current_editor;
  },
  handleClick: function(ev) {
    return alert("This is custom button with extend style");
  }
});

Then just add it as an option with the new extra_tooltip_widgets initialization attribute. It will accept an array of tooltip button objects, so you can add as many as you want without the register hassle, it will just work.

  var btn1 = new window.MyCustomTooltip

  editor = new Dante.Editor(
    {
      el: "#editor",
      upload_url: "/uploads/new.json",
      debug:  true ,
      extra_tooltip_widgets: [btn1, ...]
    }
  )
  editor.start()

I think this solution is very neat , what do you think about it ? maybe you could take this as an starting point in order to improve this solution

Best

from dante.

AdamOstrove avatar AdamOstrove commented on July 17, 2024

@michelson

I really like this idea! It is very neat, and certainly a step in the right direction. My main concern with it is a small legacy connection between the base widgets (embeds and extracts specifically) and the Dante Core.

#embeds or extracts
if parent.hasClass("is-embedable")
  @embed_widget.getEmbedFromNode($(anchor_node))
else if parent.hasClass("is-extractable")
  @embed_extract_widget.getExtractFromNode($(anchor_node))

This check is made in Dante, so turning embeds or extracts from placeholders into realized structures and what to do with those structures is still controlled by the Dante core. As far as I can tell, this makes it impossible to make a new widget with similar behavior to the first three (placeholder followed by a complete structure) without modifying Dante code directly. Have you given any thought to removing that last legacy tie somehow?

Thanks

from dante.

michelson avatar michelson commented on July 17, 2024

Hi @AdamOstrove , I've noted that too.

I guess we could call each embed object for specific function so when program executes handleKeyDown (checking keycode 13) , Dante core will call each embed handleKeyDown() like you have done it in your prototype. that way we will ensure that core embeds and custom embeds will be handle that events too.

how it that sounds ?

from dante.

AdamOstrove avatar AdamOstrove commented on July 17, 2024

@michelson

That sounds good to me. I cant really think of a much better way of doing it.

from dante.

michelson avatar michelson commented on July 17, 2024

Hi @AdamOstrove , it's finally merged and released as version 0.0.11

best!

from dante.

Related Issues (20)

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.