I think regarding the dialog, you just want to add some HTML that gets
displayed/hidden with a button, and add both the HTML and the button
stuff into .kupu files for the XSL make system. Then when the user
chooses a symbol to add, do something like (assuming you have the
character is ‘mychar’):

var sel = kupu.getSelection();
var tnode = kupu.getInnerDocument().createTextNode(mychar);
sel.replaceWithNode(tnode, true);

This should replace the current selection with a text node, and select
the added node.

I hope this helps (and indeed works, didn’t actually try)… ;)

7 Responses to “Add charmap to kupu”
  1. would like to add a button to the toolbar. If you click on it I need a
    dialog box with the list of phonetics symbols. The user click on every
    symbol he/she needs and they appear in a text box he/she could edit

    When finish to add symbols click on the ok button and the text in the
    text box is inserted in the document

    Similar how windows charmap works but only for phonetics symbols

    Cheers!

  2. I forget to mention it will be useful to have a clear step-by-step tutorial

    Thanks!

  3. codecraft says:

    Yes, I understood that, see my previous mail… :)

    Longer answer:

    The first step is to create a layer (called ‘Implementation’ in Kupu)
    that glues HTML snippets into the toolbar and body of the Kupu HTML
    file. To do this, you create a directory with .kupu (XSLT) files, which
    contain information about what XSL files to include (include.kupu), what
    parts to include (wire.kupu) and snippets of HTML (other .kupu files). I
    guess in your case you will want to copy and adjust include.kupu,
    wire.kupu, head.kupu and toolbar.kupu from the plone layer to make them
    include your custom .js files and the button, and create a file called
    something like ‘charmap.kupu’ for the dialog box, which you add to
    include.kupu and wire.kupu. For more information about the .kupu files,
    see doc/TEMPLATE-SYSTEM.txt and check out a simple layer such as
    ‘widgeteer’ to see how it’s built up.

    Then you write JS code that gets triggered by the user selecting, or
    clicking or whatnot, a character in your charmap. This could be written
    as a Kupu plugin (known as ‘Tools’ in Kupu), but I guess you could just
    add a function to your dialog box too, since you won’t really use the
    plugin framework. This should contain the code I wrote in my previous
    script, and some more code to close the dialog, etc.

    Then you copy the Kupu init file, in Plone’s case
    plone/kupu_plone_layer/kupuinit.js, to your layer directory and adjust
    it so that your dialog pops up if the button gets clicked. There’s
    plenty of examples of how to write a simple button in the init file
    already, it’s a two liner that says ‘create a button, register to Kupu’,
    basically. Make sure to copy the plone layer’s head.kupu file to your
    layer, and adjust it so it uses your init code instead of Plone’s.

    When those steps are taken, you can add your layer to the root make file
    , or create a local make file, and run it so it builds the template (see
    info in the docs). This should overwrite (if done well) the default
    Plone HTML with your customized version.

    I understand the current make situation isn’t very easy to work with,
    though it’s rather flexible it’s relatively cumbersome to create a new
    layer. Hopefully, though, this information, along with the docs, is
    enough to get you started…

  4. Joh Stahl says:

    Wow! I only could understand the words but not the concept
    If you try to put in the place of someone who never try to do what I
    need to do you could understand that this sounds chinese

    I know that to do good documentation it’s the hardest part of our job
    but when a process is so difficult like this if you don’t have a
    reasonable help you are lost

    Thanks for the help but to solve my problem first I need to translate
    your words to something understandable to a newbie
    I don’t want to seem ungrateful I only want to help kupu developers to
    improve the support and step-by-step helps more than 3 documents with a
    lot of words and deep discussion of concepts (like kupu documentation)

    If we think in child to write the help we write better documentation. A
    newbie is like a child and if you use steps (ol or ul), graphics, etc
    then the newbie could do the job. Deep discussions are useful when you
    are experienced and want to make things better

    Thanks a lot!

  5. Did you understand the Guido’s instructions? I’m short?
    I’m very frustrated because I can’t lose all the day with this task

    Can you understand me or I’m crazy?

  6. I understand that fully, but unfortunately writing such documentation
    takes _huge_ amounts of time, and I barely have time to work on Kupu
    itself (and I guess that’s the same with the other developers). It’s a
    common scenario in open-source: stuff gets developed/written when it’s
    needed, by the people who need it… Of course, that does mean that it
    would be _highly_ appreciated by others like you if you’d take the step
    of trying to bring it to a good end, documenting each step in the way,
    yourself… Of course you can ask if you get stuck, I’d be happy to help
    you out answering (shorter ;) questions here.

    If your understanding of the techniques used in Kupu is very limited,
    however, I can imagine you don’t want to go through all the trouble…
    There’s a lot of things involved here. I guess this is a general problem
    with programming: complex systems are hard to understand and develop
    for. Having said that, I do think Kupu can be improved here and there,
    hopefully we can think of easier ways to extend it and such at some point.

    Sorry for not being able to help you out all the way, I hope you do
    understand my situation though…

  7. No problem, Guido!
    I write code like you and I understand perfectly the situation
    But if you try to understand my situation you could understand that I
    can’t say we can’t implement the feature
    If I can’t do it with kupu I need to change the editor and do the job
    even if it take longer

    If you make a first step-by-step description perhaps I could complete
    the help recipe with the next iterations

    But I need an initial draft that could follow, something I could follow

Leave a Reply