if you are a human please do not click here
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
Username :
Password :
Home
Help
Calendar
Register
Login
XMetaL Community Forums
»
General
»
DITA and XMetaL Discussion
»
OnInsert scripting when wrapping a selection
Pages:
1
« previous
next »
Print
Author
Topic: OnInsert scripting when wrapping a selection (Read 165 times)
paul_cpwr
Member
Posts: 14
OnInsert scripting when wrapping a selection
«
on:
November 17, 2011, 01:19:48 PM »
I've edited the CTM file such that the insertion of a draft-comment element runs a JScript function to automatically populate the author and time attributes. I did this using a JScript function loaded with the application and not an XMetaL macro (via Application.Run).
When the selection is an insertion point, the function fires and I get a draft-comment with the attributes populated. However, when the selection is a range (text within a paragraph or a collection of multiple paragraphs), I get the element inserted, wrapping the selection like I want, but none of the attributes get populated. It's as if the OnInsert script is being ignored and the insert falls back to default behavior.
I seem to remember that there is something I can do to handle the "wrap" case, but I can't remember it or find it in the doc.
Here's the function being called, which handles the insertion of draft-comment elements and our specialized beta-comment element. For draft-comment, the OnInsert script is:
codexInsertCommentElement("draft");
The code for the actual function is:
function codexInsertCommentElement(type) {
var newElem = type + "-comment";
Selection.InsertElement(newElem);
var author = getCodexAuthor();
var d = new Date();
if (author != "UNKNOWN") Selection.ElementAttribute("author",newElem) = author;
Selection.ElementAttribute("time",newElem) = d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate();
Selection.InsertElement("p");
}
Please ignore the getCodexAuthor() function call; that code is working.
Any suggestions are welcome.
Best regards,
Paul Anderson
Compuware Corporation
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member
Posts: 1548
Re: OnInsert scripting when wrapping a selection
«
Reply #1 on:
November 17, 2011, 01:53:57 PM »
Strictly speaking, making this type of mod to the DITA functionality is not supported (so you'll have to support your clients that are using this on your own). The approach I would take here is to insert a debugger statement into your code and then step through it. Hopefully you have Visual Studio or similar. If not you can try using Windows Script Debugger.
I suspect that your code is attempting to do something that the DITA authoring code already does. If you step through your code you will likely see that eventually the debugger jumps out of your file into one of our scripts. At that point I'm not sure what your strategy should be. I don't recommend changing the code we ship but perhaps it will help you understand what is happening so you can modify yours.
Another option would be to write up a feature request and submit it to XMetaL Support. This just needs to describe your goals (not design the feature) in the broadest possible terms. You might think the script is self explanatory, but there must be some background to this. The basic question to answer is "who is this for" (the type of user) and "why". If it makes sense for the general population to have a feature that helps you (not necessarily the feature you think you want) then it would be considered for a future release.
Logged
Pages:
1
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> Forum Information
=> General XMetaL Discussion
=> DITA and XMetaL Discussion
=> XMetaL Tips and Tricks
=> XMetaL Announcements and Events
Loading...
email us