Apuzzo, T wrote:
> 
> The requirement I’m wanting to implement is to make it possible to drag
> and drop HTML elements from a web browser into the XXE editor. We don’t
> want the drop-target to directly add content, but rather we want to
> update attributes on the drop target based on some attributes on the
> HTML drag source.
> 

This is certainly possible. We do that all the time. See simple example,
actually used in production, below.

Note that you'll have to use the very latest release (v4.8) for that.
Moreover next release (v4.9 or v5) will provide the author with a visual
feedback (the element, which is the drop target, is highlighted) during
the drop.



> 
> I expect that we would need to write some Java code using your Java APIs
> in order to register a custom event handler.

[1] There is no need to write Java code to register a ``custom event
handler''. A declaration in the DITA topic configuration file (in XML)
suffices to *bind* a *command* to a *drop event*.

[2] In most cases, you don't need to write a custom command in Java.
Writing a macro-command (in XML) suffices.

DITA Topic example: dragging an URL from a Web browser onto a <xref> or
<link> elements updates the @href attribute of this element.

Excerpts from XXE_install_dir/addon/config/dita/topic.xxe:
---
<!-- An easy way to specify the href attribute of a link or xref. -->

<binding>
  <appEvent name="drop" />
  <command name="dita.drop" parameter="%{value}" />
</binding>

<command name="dita.drop">
  <macro>
    <choice>
      <sequence>
        <match context="$clickedElement"
               pattern="xref[@href]|xref[@href]//*|
                        link[@href]|link[@href]//*|
                        longdescref[@href]|
                        longquoteref[@href]" />
        <set variable="selectedElement" context="$clickedElement"
             expression="(ancestor-or-self::*[@href])[last()]" />

        <set variable="dropped" context="$selectedElement"
             expression="relativize-uri(uri-or-file-name('%*'))" />
        <get expression="$dropped" />
        <command name="putAttribute" parameter="href '%_'" />

        <get expression="$dropped" />
        <command name="status" parameter="href='%_'" />
      </sequence>

      <!-- Default drop action. -->
      <command name="drop" parameter="%*" />
    </choice>
  </macro>
</command>
---


References:

* <binding> configuration element:
http://www.xmlmind.com/xmleditor/_distrib/doc/configure/binding.html

* Writing macro commands:
http://www.xmlmind.com/xmleditor/_distrib/doc/commands/writing_macros.html

* XPath extension functions (e.g. relativize-uri()):
http://www.xmlmind.com/xmleditor/_distrib/doc/commands/xpathfunc.html

* putAttribute is a predefined command written in Java:
http://www.xmlmind.com/xmleditor/_distrib/doc/commands/putAttribute.html

* Writing commands in Java is explained here:
http://www.xmlmind.com/xmleditor/_distrib/doc/dev/command.html



>  
> 
> We’re using XXXX with YUI as our source but we could use
> JQuery or some other javascript library if you require it.
> 

Depends on what you want to drop. In all cases, XMLmind XML Editor
expects a string. However this string could be anything (e.g. JSON)
understood and consumed by your custom drop command.



> 
> Does this sound feasible to you?  Can you give any pointers to how this
> might be done?
> 

See above.


 
--
XMLmind XML Editor Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/xmleditor-support

Reply via email to