Hi. I've created a Flare plugin that displays a custom ribbon tab and a custom button coded in C#. What I'd like to do is:
- have the button add a CSS class from my style sheet to the selected text when the button is clicked. Sort of like similar functionality of the default bullet button on the Home tab.
- include Flare's default bullet button, but have it apply a style from my stylesheet in addition to adding a bullet.
I realize users could use the default Flare buttons for this, but I want to make it easier for my team members to follow our internal style guide. E.g., some are tempted to use the Fonts button group on the Home tab, but this inlines CSS and creates <span> tags that I do not want in our documentation.
I've read the API documentation Flare provides, but it's not detailed enough to help me.
Does anyone have any advice or can point me in the right direction? I've also read Flare for Programmers, but that doesn't give me examples of this.
Jim
Create Custom Style Button on Ribbon
-
jimgilliam
- Propeller Head
- Posts: 96
- Joined: Tue Jun 04, 2013 9:49 am
- Location: Arkansas, U.S.A.
Re: Create Custom Style Button on Ribbon
Hi Jim,
did you already solve your problem?
I'm not exactly sure what you want to obtain--set a custom style for a bullet list?
But here are some hints:
You will have to add the corresponding attributes to the tag. As the API does not support custom attributes, as far as I understand, you will have to work on the XmlDocument.
You can get a reference xmlDoc to the XmlDocument with the method IDocument.GetXmlDocument() of the API and create an XmlAttribute with something like
You have to select the node where you want to insert the attribute. The API method ISelection.GetXmlNodeList() will give you a IList<XmlNode> which you can cast to a XmlNodeList nodeList.
If you have selected an inserted li element,
will insert the attribute to the ul or ol element.
If you want to insert a whole new button list if not in a paragraph, you can create a new ul XmlElement and add the attribute and a li child with
The XmlNode to insert into you will again have to obtain with the ISelection.
Then, you will have to call the API method IDocument.UpdateView() of the document reference to make the changes visible immediately.
Hope that helps...
Markus
did you already solve your problem?
I'm not exactly sure what you want to obtain--set a custom style for a bullet list?
But here are some hints:
You will have to add the corresponding attributes to the tag. As the API does not support custom attributes, as far as I understand, you will have to work on the XmlDocument.
You can get a reference xmlDoc to the XmlDocument with the method IDocument.GetXmlDocument() of the API and create an XmlAttribute with something like
Code: Select all
XmlAttribute att = xmlDoc.CreateAttribute(name);
att.Value = value;If you have selected an inserted li element,
Code: Select all
nodeList[0].ParentNode.Attributes.Append(att);If you want to insert a whole new button list if not in a paragraph, you can create a new ul XmlElement and add the attribute and a li child with
Code: Select all
XmlNode newNode = xmlDoc.CreateElement("ul");
newNode.Attributes.Append(att);
newNode.AppendChild(xmlDoc.CreateElement("li"));
newNode.ChildNodes[0].InnerText = " ";Then, you will have to call the API method IDocument.UpdateView() of the document reference to make the changes visible immediately.
Hope that helps...
Markus