Working with Spans
QXML for spans
Span is represented by <qx-span> node. It contains following attributes:
|
Attribute |
Value |
Description |
|
|
id |
Unique Element ID to create anchor |
|
|
text |
Name of Character style sheet and space separated text shading style |
Create new span
To create a new span:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>and<qx-p>element. -
Create new
<qx-span>element. -
Append the
<qx-span>element as child of<qx-p>node.
Sample JavaScript:
var layout=app.activeLayoutDOM();
var boxes=layout.getElementsByTagName('qx-box')[0];
var paras=boxes.getElementsByTagName('qx-p')[0];
var newSpan=document.createElement('qx-span');
newSpan.innerText='NEW SPAN';
paras.appendChild(newSpan);
Delete existing span
To delete an existing span:
-
Get the DOM of the active layout.
-
Get the
<qx-box>,<qx-p>,<qx-span>node corresponding to the span to be deleted. -
Remove the
<qx-span>child node from<qx-p>node.
Sample JavaScript:
var layout=app.activeLayoutDOM();
var boxes=layout.getElementsByTagName('qx-box')[0];
var paras=boxes.getElementsByTagName('qx-p')[0];
var spans=paras.getElementsByTagName('qx-span')[0];
paras.removeChild(spans);
Apply font size
To apply font size:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>node and<qx-p>node . -
Get the desired
<qx-span>node inside the<qx-p>node. -
Set the
styling property toqxFontSize'18pt'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; var span=para.getElementsByTagName('qx-span')[0]; span.style.qxFontSize='18pt';
Apply color
To apply color:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>node and<qx-p>node . -
Get the desired
<qx-span>node inside the<qx-p>node. -
Set the
qxColorstyling property to'magenta'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; var span=para.getElementsByTagName('qx-span')[0]; span.style.qxColor='magenta';
Apply baseline shift
To apply baseline shift:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>node and<qx-p>node . -
Get the desired
<qx-span>node inside the<qx-p>node. -
Set the
qxBaselineShiftstyling property to'3pt'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; var span=para.getElementsByTagName('qx-span')[0]; span.style.qxBaselineShift='3pt';
Apply font weight
To apply font weight:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>node and<qx-p>node . -
Get the desired
<qx-span>node inside the<qx-p>node. -
Set the
qxFontWeightstyling property to'bold'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; var span=para.getElementsByTagName('qx-span')[0]; span.style.qxFontWeight='bold';
Apply font style
To apply font style:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>node and<qx-p>node . -
Get the desired
<qx-span>node inside the<qx-p>node. -
Set the
qxFontStylestyling property to'italic'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; var span=para.getElementsByTagName('qx-span')[0]; span.style.qxFontStyle='italic';
Apply font family
To apply font family:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>node and<qx-p>node . -
Get the desired
<qx-span>node inside the<qx-p>node. -
Set the
qxFontFamilystyling property to'arial'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; var span=para.getElementsByTagName('qx-span')[0]; span.style.qxFontFamily='arial';
Apply shade
To apply shade:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>node and<qx-p>node . -
Get the desired
<qx-span>node inside the<qx-p>node. -
Set the
qxShadestyling property to'0.6'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; var span=para.getElementsByTagName('qx-span')[0]; span.style.qxShade='0.6';Can be specified in the 0 - 1 range (0=0% and 1 = 100%).
Example values: 0 = 0%, 0.25 = 25%, 0.50 = 50% and 1 = 100%.
Apply opacity
To apply opacity:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>node and<qx-p>node . -
Get the desired
<qx-span>node inside the<qx-p>node. -
Set the
qxOpacitystyling property to'0.4'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; var span=para.getElementsByTagName('qx-span')[0]; span.style.qxOpacity='0.4';Can be specified in the 0 - 1 range (0=0% and 1 = 100%).
Example values: 0 = 0%, 0.25 = 25%, 0.50 = 50% and 1 = 100%.
Apply letter spacing
To apply letter spacing:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>node and<qx-p>node . -
Get the desired
<qx-span>node inside the<qx-p>node. -
Set the
qxLetterSpacingstyling property to'25'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; var span=para.getElementsByTagName('qx-span')[0]; span.style.qxLetterSpacing='25';
Apply text properties
Text shadow
To apply text shadow:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>node and<qx-p>node . -
Get the desired
<qx-span>node inside the<qx-p>node. -
Set the
qxTextShadowstyling property to'true'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; var span=para.getElementsByTagName('qx-span')[0]; span.style.qxTextShadow='true';
Text caps
To apply text caps:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>node and<qx-p>node . -
Get the desired
<qx-span>node inside the<qx-p>node. -
Set the
qxTextCapsstyling property to'all-caps'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; var span=para.getElementsByTagName('qx-span')[0]; span.style.qxTextCaps='all-caps';
Text decoration line
To apply text decoration line:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>node and<qx-p>node . -
Get the desired
<qx-span>node inside the<qx-p>node. -
Set the
qxTextDecorationLinestyling property to'line-through'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; var span=para.getElementsByTagName('qx-span')[0]; span.style.qxTextDecorationLine='line-through';
Text position
To apply text position:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>node and<qx-p>node . -
Get the desired
<qx-span>node inside the<qx-p>node. -
Set the
qxTextPositionstyling property to'super'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; var span=para.getElementsByTagName('qx-span')[0]; span.style.qxTextPosition='super';
Text superior
To apply text superior:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>node and<qx-p>node . -
Get the desired
<qx-span>node inside the<qx-p>node. -
Set the
qxTextPositionstyling property to'super'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; var span=para.getElementsByTagName('qx-span')[0]; span.style.qxTextSuperior='super';
Text outline
Toapply text outline:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>node and<qx-p>node . -
Get the desired
<qx-span>node inside the<qx-p>node. -
Set the
qxTextOutlinestyling property to'true'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; var span=para.getElementsByTagName('qx-span')[0]; span.style.qxTextOutline='true';
Apply text stroke
Stroke color
To apply stroke color:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>node and<qx-p>node . -
Get the desired
<qx-span>node inside the<qx-p>node. -
Set the
qxStrokeColorstyling property to'yellow'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; var span=para.getElementsByTagName('qx-span')[0]; span.style.qxStrokeColor='yellow';
Stroke width
To apply stroke width:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>node and<qx-p>node . -
Get the desired
<qx-span>node inside the<qx-p>node. -
Set the
qxStrokeWidthstyling property to'0.25pt'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; var span=para.getElementsByTagName('qx-span')[0]; span.style.qxStrokeWidth='0.25pt';
Stroke shade
To apply stroke shade:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>node and<qx-p>node . -
Get the desired
<qx-span>node inside the<qx-p>node. -
Set the
qxStrokeShadestyling property to'0.4'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; var span=para.getElementsByTagName('qx-span')[0]; span.style.qxStrokeShade='0.4';Can be specified in the 0 - 1 range (0=0% and 1 = 100%).
Example values: 0 = 0%, 0.25 = 25%, 0.50 = 50% and 1 = 100%.
Stroke linejoin
To apply stroke linejoin:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>node and<qx-p>node . -
Get the desired
<qx-span>node inside the<qx-p>node. -
Set the
qxStrokeLinejoinstyling property to'round'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; var span=para.getElementsByTagName('qx-span')[0]; span.style.qxStrokeLinejoin='round';
Stroke miterlimit
To apply stroke miterlimit:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>node and<qx-p>node . -
Get the desired
<qx-span>node inside the<qx-p>node. -
Set the
qxStrokeLinejoinstyling property to'miter'. -
Set the
qxStrokeMiterlimitstyling property to'7'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; var span=para.getElementsByTagName('qx-span')[0]; span.style.qxStrokeLinejoin='miter'; span.style.qxStrokeMiterlimit='7';
Apply language
To apply language:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>node and<qx-p>node . -
Get the desired
<qx-span>node inside the<qx-p>node. -
Set the
qxLanguagestyling property to'zh-Hans'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; var span=para.getElementsByTagName('qx-span')[0]; span.style.qxLanguage='zh-Hans';