Working with Paragraphs
QXML for paragraph
Paragraph is represented by <qx-p> node. It contains following attributes:
|
Attribute |
Value |
Description |
|
|
text |
Name of paragraph style sheet and space separated H&J Style, Bullet and Numbering Style, Para Shading Style, Hanging Character Set |
Create new paragraph
To create a new paragraph:
-
Get the DOM of the active layout.
-
Get the desired
<qx-box>,<qx-p>and<qx-span>tags. -
Create a new
<qx-p>element. -
Create a new
<qx-span>element. -
Append the
<qx-span>element as child of<qx-p>element. -
Append the
<qx-p>element as child of<qx-story>node.
Sample JavaScript:
var layout=app.activeLayoutDOM();
var boxes=layout.getElementsByTagName('qx-box')[0];
var paras=boxes.getElementsByTagName('qx-p')[0];
var span=paras.getElementsByTagName('qx-span')[0];
var newPara=document.createElement('qx-p');
var newSpan=document.createElement('qx-span');
newSpan.innerText='NEW';
newPara.appendChild(newSpan);
paras.parentNode.appendChild(newPara);
Delete existing paragraph
To delete an existing paragraph:
-
Get the DOM of the active layout.
-
Get the
<qx-box>, <qx-story>and<qx-p>node corresponding to the paragraph to be deleted. -
Remove the desired
<qx-p>child node from<qx-story>node.
Sample JavaScript:
var layout=app.activeLayoutDOM();
var boxes=layout.getElementsByTagName('qx-box')[0];
var story=boxes.getElementsByTagName('qx-story')[0];
var paras=story.getElementsByTagName('qx-p')[0];
story.removeChild(paras);
Apply margin
Margin top
To apply margin top:
-
Get the DOM of the active layout.
-
Get the
<qx-p>node inside the<qx-box>node . -
Set the
qxMarginTopstyling property to'0.069in'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[1]; para.style.qxMarginTop='0.069in';
Margin bottom
To apply margin bottom:
-
Get the DOM of the active layout.
-
Get the
<qx-p>node inside the<qx-box>node . -
Set the
qxMarginBottomstyling property to'0.042in'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; para.style.qxMarginBottom='0.042in';
Margin left
To apply margin left:
-
Get the DOM of the active layout.
-
Get the
<qx-p>node inside the<qx-box>node . -
Set the
qxMarginLeftstyling property to'0.111in'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; para.style.qxMarginLeft='0.111in';
Margin right
To apply margin right:
-
Get the DOM of the active layout.
-
Get the
<qx-p>node inside the<qx-box>node . -
Set the
qxMarginRightstyling property to'0.222in'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; para.style.qxMarginRight='0.222in';
Apply text indent
To apply text indent:
-
Get the DOM of the active layout.
-
Get the
<qx-p>node inside the<qx-box>node . -
Set the
qxTextIndentstyling property to'0.208in'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; para.style.qxTextIndent='0.208in';
Apply line height
To apply line height:
-
Get the DOM of the active layout.
-
Get the
<qx-p>node inside the<qx-box>node . -
Set the
qxLineHeightstyling property to'17.4pt'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; para.style.qxLineHeight='17.4pt';
Apply text align
To apply text align:
-
Get the DOM of the active layout.
-
Get the
<qx-p>node inside the<qx-box>node . -
Set the
qxTextAlignstyling property to'justify'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; para.style.qxTextAlign='justify';
Apply initial letter and initial letter count
To apply initial letter and initial letter count:
-
Get the DOM of the active layout.
-
Get the
<qx-p>node inside the<qx-box>node . -
Set the
qxInitialLetterCountstyling property to'2'. -
Set the
qxInitialLetterstyling property to'4'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; para.style.qxInitialLetterCount='2'; para.style.qxInitialLetter='4';
Apply orphans and widows
Orphans
To apply orphans:
-
Get the DOM of the active layout.
-
Get the
<qx-p>node inside the<qx-box>node . -
Set the
qxOrphansstyling property to'2'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; para.style.qxOrphans='2';
Widows
To apply widows:
-
Get the DOM of the active layout.
-
Get the
<qx-p>node inside the<qx-box>node . -
Set the
qxWidowsstyling property to'3'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; para.style.qxWidows='3';
Break inside
To apply break inside:
-
Get the DOM of the active layout.
-
Get the
<qx-p>node inside the<qx-box>node . -
Set the
qxBreakInsidestyling property to'auto'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; para.style.qxBreakInside='auto';
Break after
To apply break after:
-
Get the DOM of the active layout.
-
Get the
<qx-p>node inside the<qx-box>node . -
Set the
qxBreakAfterstyling property to'avoid'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; para.style.qxBreakAfter='avoid';
Apply grid properties
Lock text to grid
To apply lock text to grid:
-
Get the DOM of the active layout.
-
Get the
<qx-p>node inside the<qx-box>node . -
Set the
qxLockTextToGridstyling property to'textbox'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; para.style.qxLockTextToGrid='textbox';
Text grid alignment
To apply text grid alignment:
-
Get the DOM of the active layout.
-
Get the
<qx-p>node inside the<qx-box>node . -
Set the
qxTextGridAlignmentstyling property to'topline'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; para.style.qxTextGridAlignment='topline';
Specify minimum distance between bullet and text
To specify the minimum distance between a bullet and text:
-
et the DOM of the active layout.
-
Get the
<qx-p>node inside the<qx-box>node . -
Set the
qxBnMinGapstyling property to'0.2in'.var layout=app.activeLayoutDOM(); var boxes=layout.getElementsByTagName('qx-box')[0]; var para=boxes.getElementsByTagName('qx-p')[0]; para.style.qxBnMinGap='0.2in';