PageRenderTime 53ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/jangaroo/lsystem/joo/classes/flashx/textLayout/edit/IEditManager.js

https://github.com/mohlendo/mohlendo.github.com
JavaScript | 1008 lines | 33 code | 1 blank | 974 comment | 0 complexity | 516f12a7196593aa839065a9888e741d MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. joo.classLoader.prepare("package flashx.textLayout.edit",/* {
  2. import flashx.textLayout.elements.FlowElement;
  3. import flashx.textLayout.formats.ITextLayoutFormat;
  4. import flashx.textLayout.operations.FlowOperation;
  5. import flashx.undo.IUndoManager;*/
  6. /**
  7. * IEditManager defines the interface for handling edit operations of a text flow.
  8. * <p>To enable text flow editing, assign an IEditManager instance to the <code>interactionManager</code> property of the TextFlow object. The edit manager handles changes to the text (such as insertions, deletions, and format changes). Changes are reversible if the edit manager has an undo manager. The edit manager triggers the recomposition and display of the text flow, as necessary.</p>
  9. * @see EditManager
  10. * @see flashx.textLayout.elements.TextFlow
  11. * @see flashx.undo.UndoManager
  12. *
  13. */
  14. "public interface IEditManager extends flashx.textLayout.edit.ISelectionManager, flashx.textLayout.edit.IInteractionEventHandler",1,function($$private){;return[ /*
  15. /**
  16. * The UndoManager object assigned to this EditManager instance, if there is one.
  17. * <p>An undo manager handles undo and redo operations.</p>
  18. * /
  19. function undoManager():IUndoManager*/,/*
  20. /**
  21. * Applies container styles to any containers in the selection.
  22. * <p>Any style properties in the format object that are <code>null</code> are left unchanged.</p>
  23. * @param format the format to apply to the containers in the range
  24. * @param operationState specifies the text to which this operation applies; if <code>null</code>, the operation applies to the current selection.
  25. *
  26. * @example The following example changes the format of the containers holding a selection to display two columns:
  27. * <listing>
  28. * package flashx.textLayout.edit.examples
  29. * {
  30. * import flashx.textLayout.edit.IEditManager;
  31. * import flashx.textLayout.edit.SelectionState;
  32. * import flashx.textLayout.elements.TextFlow;
  33. * import flashx.textLayout.formats.TextLayoutFormat;
  34. *
  35. * public class EditManager_applyContainerFormat
  36. * {
  37. * public function EditManager_applyContainerFormat( selection:SelectionState ):void
  38. * {
  39. * var textFlow:TextFlow = selection.textFlow;
  40. * var editManager:IEditManager = textFlow.interactionManager as IEditManager;
  41. *
  42. * var containerStyle:TextLayoutFormat = new TextLayoutFormat();
  43. * containerStyle.columnCount = 2;
  44. *
  45. * editManager.applyContainerFormat( containerStyle );
  46. * }
  47. * }
  48. * }
  49. * </listing>
  50. * /
  51. function applyContainerFormat(format:ITextLayoutFormat, operationState:SelectionState = null):void*/,/*
  52. /**
  53. * Changes the formats of the specified (or current) selection.
  54. * <p>Executes an undoable operation that applies the new formats. Only style attributes set for the TextLayoutFormat objects are applied. Undefined attributes in the format objects are not changed.</p>
  55. * @param leafFormat the format to apply to leaf elements such as spans and inline graphics
  56. * @param paragraphFormat format to apply to paragraph elements
  57. * @param containerFormat format to apply to the containers
  58. * @param operationState specifies the text to which this operation applies; if <code>null</code>, the operation applies to the current selection.
  59. *
  60. * @example The following example applies a container, paragraph, and a character format to a selection.
  61. * <listing>
  62. *
  63. * package flashx.textLayout.edit.examples
  64. * {
  65. * import flashx.textLayout.edit.IEditManager;
  66. * import flashx.textLayout.edit.SelectionState;
  67. * import flashx.textLayout.elements.TextFlow;
  68. * import flashx.textLayout.formats.TextAlign;
  69. * import flashx.textLayout.formats.TextLayoutFormat;
  70. *
  71. * public class EditManager_applyFormat
  72. * {
  73. * public function EditManager_applyFormat( selection:SelectionState ):void
  74. * {
  75. * var textFlow:TextFlow = selection.textFlow;
  76. * var editManager:IEditManager = textFlow.interactionManager as IEditManager;
  77. *
  78. * var containerStyle:TextLayoutFormat = new TextLayoutFormat();
  79. * containerStyle.columnCount = 2;
  80. *
  81. * var paraStyle:TextLayoutFormat = new TextLayoutFormat();
  82. * paraStyle.textAlign = TextAlign.JUSTIFY;
  83. *
  84. * var charStyle:TextLayoutFormat = new TextLayoutFormat();
  85. * charStyle.color = 0xff0000;
  86. *
  87. * editManager.applyFormat( charStyle, paraStyle, containerStyle );
  88. * }
  89. * }
  90. * }
  91. * </listing>
  92. * /
  93. function applyFormat(leafFormat:ITextLayoutFormat, paragraphFormat:ITextLayoutFormat, containerFormat:ITextLayoutFormat, operationState:SelectionState = null):void*/,/*
  94. /**
  95. * Applies styles to the specified element.
  96. * <p>Any style properties in the format object that are <code>null</code> are left unchanged. Only styles that are relevant to the specified element are applied.</p>
  97. * @param targetElement the element to which the styles are applied.
  98. * @param format the format containing the styles to apply
  99. * @param operationState specifies the text to which this operation applies; if <code>null</code>, the operation applies to the current selection.
  100. *
  101. * @example The following example applies a format to a <div> element in the mid-level of the flow element hierarchy.
  102. * <listing>
  103. * package flashx.textLayout.edit.examples
  104. * {
  105. * import flashx.textLayout.conversion.TextConverter;
  106. * import flashx.textLayout.edit.IEditManager;
  107. * import flashx.textLayout.edit.SelectionState;
  108. * import flashx.textLayout.elements.FlowElement;
  109. * import flashx.textLayout.elements.TextFlow;
  110. * import flashx.textLayout.formats.TextLayoutFormat;
  111. *
  112. * public class EditManager_applyFormatToElement
  113. * {
  114. * public function EditManager_applyFormatToElement( selection:SelectionState ):void
  115. * {
  116. * var textFlow:TextFlow = TextConverter.importToFlow("<TextFlow><div><p><span>Hello World</span></p></div><p>No indent</p></TextFlow>", TextConverter.TEXT_LAYOUT_FORMAT);
  117. * var editManager:IEditManager = textFlow.interactionManager as IEditManager;
  118. * var divElement:FlowElement = textFlow.getChildAt(0);
  119. *
  120. * var format:TextLayoutFormat = new TextLayoutFormat();
  121. * format.textIndent = 15;
  122. *
  123. *
  124. * editManager.applyFormatToElement( divElement, format );
  125. * }
  126. * }
  127. * }
  128. * </listing>
  129. * /
  130. function applyFormatToElement(targetElement:FlowElement, format:ITextLayoutFormat, operationState:SelectionState = null):void*/,/*
  131. /**
  132. * Changes the format applied to the leaf elements in the specified (or current) selection.
  133. * <p>Executes an undoable operation that applies the new format to leaf elements such as SpanElement and InlineGraphicElement objects. Only style attributes set for the TextLayoutFormat objects are applied. Undefined attributes in the format object are changed.</p>
  134. * @param format the format to apply.
  135. * @param operationState specifies the text to which this operation applies; if <code>null</code>, the operation applies to the current selection.
  136. *
  137. * @example The following example changes the color of text in a selection to red.
  138. * <listing>
  139. * package flashx.textLayout.edit.examples
  140. * {
  141. * import flashx.textLayout.edit.IEditManager;
  142. * import flashx.textLayout.edit.SelectionState;
  143. * import flashx.textLayout.elements.TextFlow;
  144. * import flashx.textLayout.formats.TextLayoutFormat;
  145. *
  146. * public class EditManager_applyLeafFormat
  147. * {
  148. * public function EditManager_applyLeafFormat(selection:SelectionState)
  149. * {
  150. * var textFlow:TextFlow = selection.textFlow;
  151. * var editManager:IEditManager = textFlow.interactionManager as IEditManager;
  152. *
  153. * var charStyle:TextLayoutFormat = new TextLayoutFormat();
  154. * charStyle.color = 0xff0000;
  155. *
  156. * editManager.applyLeafFormat( charStyle );
  157. * }
  158. * }
  159. * }
  160. * </listing>
  161. * /
  162. function applyLeafFormat(format:ITextLayoutFormat, operationState:SelectionState = null):void*/,/*
  163. /**
  164. * Transforms a selection into a link, or a link into normal text.
  165. * <p>Executes an undoable operation that creates or removes the link.</p>
  166. * <p>If a <code>target</code> parameter is specified, it must be one of the following values:</p>
  167. * <ul>
  168. * <li>"_self"</li>
  169. * <li>"_blank"</li>
  170. * <li>"_parent"</li>
  171. * <li>"_top"</li></ul>
  172. * <p>In browser-hosted runtimes, a target of "_self" replaces the current html page. So, if the SWF content containing the link is in a page within a frame or frameset, the linked content loads within that frame. If the page is at the top level, the linked content opens to replace the original page. A target of "_blank" opens a new browser window with no name. A target of "_parent" replaces the parent of the html page containing the SWF content. A target of "_top" replaces the top-level page in the current browser window.</p>
  173. * <p>In other runtimes, such as Adobe AIR, the link opens in the user's default browser and the <code>target</code> parameter is ignored.</p>
  174. * <p>The <code>extendToLinkBoundary</code> parameter determines how the edit manager treats a selection that intersects with one or more existing links. If the parameter is <code>true</code>, then the operation is applied as a unit to the selection and the whole text of the existing links. Thus, a single link is created that spans from the beginning of the first link intersected to the end of the last link intersected. In contrast, if <code>extendToLinkBoundary</code> were <code>false</code> in this situation, the existing partially selected links would be split into two links.</p>
  175. * @param href The uri referenced by the link.
  176. * @param target The target browser window of the link.
  177. * @param extendToLinkBoundary Specifies whether to consolidate selection with any overlapping existing links, and then apply the change.
  178. * @param operationState specifies the text to which this operation applies; if <code>null</code>, the operation applies to the current selection.
  179. *
  180. * @see flashx.textLayout.elements.LinkElement
  181. *
  182. * @example The following example defines two functions. The first transforms a selection into a link. The second removes the URL from a link.
  183. * <listing>
  184. * package flashx.textLayout.edit.examples
  185. * {
  186. * import flash.display.Sprite;
  187. *
  188. * import flashx.textLayout.container.ContainerController;
  189. * import flashx.textLayout.conversion.TextConverter;
  190. * import flashx.textLayout.edit.IEditManager;
  191. * import flashx.textLayout.edit.SelectionState;
  192. * import flashx.textLayout.elements.TextFlow;
  193. *
  194. * public class EditManager_applyLink
  195. * {
  196. *
  197. * static public function makeLink( selection:SelectionState ):void
  198. * {
  199. * var textFlow:TextFlow = selection.textFlow;
  200. * var editManager:IEditManager = textFlow.interactionManager as IEditManager;
  201. *
  202. * editManager.applyLink( "http://www.adobe.com" );
  203. * }
  204. *
  205. * static public function removeLink( selection:SelectionState ):void
  206. * {
  207. * var textFlow:TextFlow = selection.textFlow;
  208. * var editManager:IEditManager = textFlow.interactionManager as IEditManager;
  209. *
  210. * editManager.applyLink( null, null, true );
  211. * }
  212. * }
  213. * }
  214. * </listing>
  215. * /
  216. function applyLink(href:String, target:String = null, extendToLinkBoundary:Boolean = false, operationState:SelectionState = null):void*/,/*
  217. /**
  218. * Applies paragraph styles to any paragraphs in the selection.
  219. * <p>Any style properties in the format object that are <code>null</code> are left unchanged.</p>
  220. * @param format the format to apply to the selected paragraphs.
  221. * @param operationState specifies the text to which this operation applies; if <code>null</code>, the operation applies to the current selection.
  222. *
  223. * @example The following example defines a function to change the format of any paragraphs included in a current selection to justify the text.
  224. * <listing>
  225. * package flashx.textLayout.edit.examples
  226. * {
  227. * import flashx.textLayout.edit.IEditManager;
  228. * import flashx.textLayout.edit.SelectionState;
  229. * import flashx.textLayout.elements.TextFlow;
  230. * import flashx.textLayout.formats.TextAlign;
  231. * import flashx.textLayout.formats.TextLayoutFormat;
  232. *
  233. * public class EditManager_applyParagraphFormat
  234. * {
  235. * static public function justifyParagraph( selection:SelectionState ):void
  236. * {
  237. * var textFlow:TextFlow = selection.textFlow;
  238. * var editManager:IEditManager = textFlow.interactionManager as IEditManager;
  239. *
  240. * var paraStyle:TextLayoutFormat = new TextLayoutFormat();
  241. * paraStyle.textAlign = TextAlign.JUSTIFY;
  242. *
  243. * editManager.applyParagraphFormat( paraStyle );
  244. * }
  245. * }
  246. * }
  247. * </listing>
  248. * /
  249. function applyParagraphFormat(format:ITextLayoutFormat, operationState:SelectionState = null):void*/,/*
  250. /**
  251. * Transforms text into a TCY run, or a TCY run into non-TCY text.
  252. * <p>TCY, or tate-chu-yoko, causes text to draw horizontally within a vertical line, and is used to make small blocks of non-Japanese text or numbers, such as dates, more readable in vertical text.</p>
  253. * @param tcyOn specify <code>true</code> to apply TCY to a text range, <code>false</code> to remove TCY.
  254. * @param operationState specifies the text to which this operation applies; if <code>null</code>, the operation applies to the current selection.
  255. *
  256. * @see flashx.textLayout.elements.TCYElement
  257. *
  258. * @example The following example defines two functions. The first applies TCY formatting to the current selection. The second removes TCY formatting.
  259. * <listing>
  260. * package flashx.textLayout.edit.examples
  261. * {
  262. * import flashx.textLayout.edit.IEditManager;
  263. * import flashx.textLayout.edit.SelectionState;
  264. * import flashx.textLayout.elements.TextFlow;
  265. *
  266. * public class EditManager_applyTCY
  267. * {
  268. * static public function tcyOn( selection:SelectionState ):void
  269. * {
  270. * var textFlow:TextFlow = selection.textFlow;
  271. * var editManager:IEditManager = textFlow.interactionManager as IEditManager;
  272. *
  273. * editManager.applyTCY( true );
  274. * }
  275. *
  276. * static public function tcyOff( selection:SelectionState ):void
  277. * {
  278. *
  279. * var textFlow:TextFlow = selection.textFlow;
  280. * var editManager:IEditManager = textFlow.interactionManager as IEditManager;
  281. *
  282. * editManager.applyTCY( false );
  283. * }
  284. * }
  285. * }
  286. * </listing>
  287. * /
  288. function applyTCY(tcyOn:Boolean, operationState:SelectionState = null):void*/,/*
  289. /**
  290. * Begins a new group of operations.
  291. * <p>All operations executed after the call to <code>beginCompositeOperation()</code>, and before the matching call to <code>endCompositeOperation()</code> are executed and grouped together as a single operation that can be undone as a unit.</p>
  292. * <p>A <code>beginCompositeOperation</code>/<code>endCompositeOperation</code> block can be nested inside another <code>beginCompositeOperation</code>/<code>endCompositeOperation</code> block.</p>
  293. *
  294. * @example The following example defines a function that inserts a graphic object in its own paragraph. If the <code>beginCompositeOperation()</code> and <code>endCompositeOperation()</code> functions were not used, then each of the suboperations would have to be undone separately rather than as a group.
  295. * <listing>
  296. * package flashx.textLayout.edit.examples
  297. * {
  298. * import flashx.textLayout.edit.IEditManager;
  299. * import flashx.textLayout.edit.SelectionState;
  300. * import flashx.textLayout.elements.TextFlow;
  301. *
  302. * public class EditManager_beginCompositeOperation
  303. * {
  304. * static public function insertGraphic( source:Object, width:Object, height:Object, float:String, selection:SelectionState ):void
  305. * {
  306. * var editManager:IEditManager = selection.textFlow.interactionManager as IEditManager;
  307. *
  308. * editManager.beginCompositeOperation();
  309. *
  310. * editManager.deleteText( selection );
  311. * var changedSelection:SelectionState =
  312. * new SelectionState( selection.textFlow, selection.anchorPosition, selection.anchorPosition );
  313. * editManager.splitParagraph( changedSelection );
  314. * changedSelection =
  315. * new SelectionState( changedSelection.textFlow, changedSelection.anchorPosition + 1, changedSelection.anchorPosition + 1);
  316. * editManager.insertInlineGraphic( source, width, height, float, changedSelection );
  317. * changedSelection =
  318. * new SelectionState( changedSelection.textFlow, changedSelection.anchorPosition + 1, changedSelection.anchorPosition + 1);
  319. * editManager.splitParagraph( changedSelection );
  320. *
  321. * editManager.endCompositeOperation();
  322. * }
  323. * }
  324. * }
  325. * </listing>
  326. * /
  327. function beginCompositeOperation():void*/,/*
  328. /**
  329. * Changes the ID of an element.
  330. * <p>If the <code>relativeStart</code> or <code>relativeEnd</code> parameters are set (to anything other than the default values), then the element is split. The parts of the element outside this range retain the original ID. Setting both the <code>relativeStart</code> and <code>relativeEnd</code> parameters creates elements with duplicate IDs.</p>
  331. * @param newID the new ID value
  332. * @param targetElement the element to modify
  333. * @param relativeStart an offset from the beginning of the element at which to split the element when assigning the new ID
  334. * @param relativeEnd an offset from the end of the element at which to split the element when assigning the new ID
  335. * @param operationState specifies the selection to restore when undoing this operation; if <code>null</code>, the operation saves the current selection.
  336. *
  337. * @example The following example defines a function that changes the ID of the first paragraph in a selection:
  338. * <listing>
  339. * package flashx.textLayout.edit.examples
  340. * {
  341. * import flashx.textLayout.edit.ElementRange;
  342. * import flashx.textLayout.edit.IEditManager;
  343. * import flashx.textLayout.edit.SelectionState;
  344. * import flashx.textLayout.elements.TextFlow;
  345. *
  346. * public class EditManager_changeElementID
  347. * {
  348. * static public function changeParagraphID( id:String, selection:SelectionState ):void
  349. * {
  350. * var textFlow:TextFlow = selection.textFlow;
  351. * var editManager:IEditManager = textFlow.interactionManager as IEditManager;
  352. * var selectedRange:ElementRange = ElementRange.createElementRange( selection.textFlow, selection.absoluteStart, selection.absoluteEnd );
  353. *
  354. * editManager.changeElementID( id, selectedRange.firstParagraph, 0, -1, selection );
  355. * }
  356. * }
  357. * }
  358. *
  359. *
  360. * </listing>
  361. * /
  362. function changeElementID(newID:String, targetElement:FlowElement, relativeStart:int = 0, relativeEnd:int = -1, operationState:SelectionState = null):void*/,/*
  363. /**
  364. * Changes the styleName of an element or part of an element.
  365. * <p>If the <code>relativeStart</code> or <code>relativeEnd</code> parameters are set (to anything other than the default values), then the element is split. The parts of the element outside this range retain the original style.</p>
  366. * @param newName the name of the new style.
  367. * @param targetElement specifies the element to change.
  368. * @param relativeStart an offset from the beginning of the element at which to split the element when assigning the new style
  369. * @param relativeEnd an offset from the end of the element at which to split the element when assigning the new style
  370. * @param operationState specifies the selection to restore when undoing this operation; if <code>null</code>, the operation saves the current selection.
  371. *
  372. * @example The following example defines a functions that changes the style name of the first paragraph in a selection:
  373. * <listing>
  374. * package flashx.textLayout.edit.examples
  375. * {
  376. * import flashx.textLayout.edit.ElementRange;
  377. * import flashx.textLayout.edit.IEditManager;
  378. * import flashx.textLayout.edit.SelectionState;
  379. * import flashx.textLayout.elements.TextFlow;
  380. *
  381. * public class EditManager_changeStyleName
  382. * {
  383. * static public function changeParagraphStyle( styleName:String, selection:SelectionState ):void
  384. * {
  385. * var textFlow:TextFlow = selection.textFlow;
  386. * var editManager:IEditManager = textFlow.interactionManager as IEditManager;
  387. * var selectedRange:ElementRange = ElementRange.createElementRange( selection.textFlow, selection.absoluteStart, selection.absoluteEnd );
  388. *
  389. * editManager.changeElementID( styleName, selectedRange.firstParagraph, 0, -1, selection );
  390. * }
  391. * }
  392. * }
  393. * </listing>
  394. * /
  395. function changeStyleName(newName:String, targetElement:FlowElement, relativeStart:int = 0, relativeEnd:int = -1, operationState:SelectionState = null):void*/,/*
  396. /**
  397. * Undefines formats of the specified (or current) selection.
  398. * <p>Executes an undoable operation that undefines the specified formats. Only style attributes set for the TextLayoutFormat objects are applied. Undefined attributes in the format objects are not changed.</p>
  399. * @param leafFormat The format whose set values indicate properties to undefine to LeafFlowElement objects in the selected range.
  400. * @param paragraphFormat The format whose set values indicate properties to undefine to ParagraphElement objects in the selected range.
  401. * @param containerFormat The format whose set values indicate properties to undefine to ContainerController objects in the selected range.
  402. * @param operationState specifies the text to which this operation applies; if <code>null</code>, the operation applies to the current selection.
  403. *
  404. * /
  405. function clearFormat(leafFormat:ITextLayoutFormat, paragraphFormat:ITextLayoutFormat, containerFormat:ITextLayoutFormat, operationState:SelectionState = null):void*/,/*
  406. /**
  407. * Undefines styles to the specified element.
  408. * <p>Any style properties in the format object that are <code>undefined</code> are left unchanged. Any styles that are defined in the specififed format are undefined on the specified element.</p>
  409. * @param targetElement the element to which the styles are applied.
  410. * @param format the format containing the styles to undefine
  411. * @param operationState specifies the text to which this operation applies; if <code>null</code>, the operation applies to the current selection.
  412. *
  413. * /
  414. function clearFormatOnElement(targetElement:FlowElement, format:ITextLayoutFormat, operationState:SelectionState = null):void*/,/*
  415. /**
  416. * Deletes the selected area and returns the deleted area in a TextScrap object.
  417. * <p>The resulting TextScrap can be posted to the system clipboard or used in a subsequent <code>pasteTextOperation()</code> operation.</p>
  418. * @param operationState specifies the text to which this operation applies; if <code>null</code>, the operation applies to the current selection.
  419. *
  420. * @return the TextScrap that was cut
  421. *
  422. *
  423. * @example The following example creates a selection in a text flow cuts the selected range and creates a TextScrap object containing the deleted content.
  424. * <listing>
  425. * package flashx.textLayout.edit.examples
  426. * {
  427. * import flash.display.Sprite;
  428. *
  429. * import flashx.textLayout.container.ContainerController;
  430. * import flashx.textLayout.conversion.TextConverter;
  431. * import flashx.textLayout.edit.EditManager;
  432. * import flashx.textLayout.edit.TextScrap;
  433. * import flashx.undo.UndoManager;
  434. * import flashx.textLayout.elements.TextFlow;
  435. *
  436. * public class EditManager_cutTextScrap
  437. * {
  438. * static public function cutTextScrap():TextScrap
  439. * {
  440. * var textFlow:TextFlow = TextConverter.importToFlow( "How do now brown cow.", TextConverter.PLAIN_TEXT_FORMAT );
  441. * textFlow.flowComposer.addController( new ContainerController( new Sprite() ));
  442. * var editManager:EditManager = new EditManager( new UndoManager() );
  443. * textFlow.interactionManager = editManager;
  444. * textFlow.flowComposer.updateAllControllers();
  445. *
  446. * editManager.selectRange( 4, 7 );
  447. * var scrap:TextScrap = editManager.cutTextScrap(); //Displays: How now brown cow.
  448. * return scrap;
  449. * }
  450. * }
  451. * }
  452. * </listing>
  453. * /
  454. function cutTextScrap(operationState:SelectionState = null):TextScrap*/,/*
  455. /**
  456. * Deletes a range of text, or, if a point selection is given, deletes the next character.
  457. * @param operationState specifies the text to which this operation applies; if <code>null</code>, the operation applies to the current selection.
  458. *
  459. * @example The following example creates a point selection in a text flow and deletes the next character.
  460. * <listing>
  461. * package flashx.textLayout.edit.examples
  462. * {
  463. * import flash.display.Sprite;
  464. *
  465. * import flashx.textLayout.container.ContainerController;
  466. * import flashx.textLayout.conversion.TextConverter;
  467. * import flashx.textLayout.edit.EditManager;
  468. * import flashx.textLayout.elements.TextFlow;
  469. *
  470. * public class EditManager_deleteNextCharacter
  471. * {
  472. * static public function deleteNextCharacter():void
  473. * {
  474. * var textFlow:TextFlow = TextConverter.importToFlow( "How now brown crow.", TextConverter.PLAIN_TEXT_FORMAT );
  475. * textFlow.flowComposer.addController( new ContainerController( new Sprite() ));
  476. * var editManager:EditManager = new EditManager();
  477. * textFlow.interactionManager = editManager;
  478. * textFlow.flowComposer.updateAllControllers();
  479. *
  480. * editManager.selectRange( 15, 15 );
  481. * editManager.deleteNextCharacter(); //displays: How now brown cow.
  482. * }
  483. * }
  484. * }
  485. * </listing>
  486. * /
  487. function deleteNextCharacter(operationState:SelectionState = null):void*/,/*
  488. /**
  489. * Deletes the next word.
  490. * <p>If a range is selected, the first word of the range is deleted.</p>
  491. * @param operationState specifies the text to which this operation applies; if <code>null</code>, the operation applies to the current selection.
  492. *
  493. * @example The following example creates a point selection in a text flow and deletes the next word.
  494. * <listing>
  495. * package flashx.textLayout.edit.examples
  496. * {
  497. * import flash.display.Sprite;
  498. *
  499. * import flashx.textLayout.container.ContainerController;
  500. * import flashx.textLayout.conversion.TextConverter;
  501. * import flashx.textLayout.edit.EditManager;
  502. * import flashx.textLayout.elements.TextFlow;
  503. *
  504. * public class EditManager_deleteNextWord
  505. * {
  506. * static public function deleteNextWord():void
  507. * {
  508. * var textFlow:TextFlow = TextConverter.importToFlow( "How do now brown cow.", TextConverter.PLAIN_TEXT_FORMAT );
  509. * textFlow.flowComposer.addController( new ContainerController( new Sprite() ));
  510. * var editManager:EditManager = new EditManager();
  511. * textFlow.interactionManager = editManager;
  512. * textFlow.flowComposer.updateAllControllers();
  513. *
  514. * editManager.selectRange( 3, 3 );
  515. * editManager.deleteNextWord(); //displays: How now brown cow.
  516. * }
  517. * }
  518. * }
  519. * </listing>
  520. * /
  521. function deleteNextWord(operationState:SelectionState = null):void*/,/*
  522. /**
  523. * Deletes a range of text, or, if a point selection is given, deletes the previous character.
  524. * @param operationState specifies the text to which this operation applies; if <code>null</code>, the operation applies to the current selection.
  525. *
  526. * @example The following example creates a point selection in a text flow and deletes the previous character.
  527. * <listing>
  528. * package flashx.textLayout.edit.examples
  529. * {
  530. * import flash.display.Sprite;
  531. *
  532. * import flashx.textLayout.container.ContainerController;
  533. * import flashx.textLayout.conversion.TextConverter;
  534. * import flashx.textLayout.edit.EditManager;
  535. * import flashx.textLayout.elements.TextFlow;
  536. *
  537. * public class EditManager_deletePreviousCharacter
  538. * {
  539. *
  540. * static public function deletePreviousCharacter():void
  541. * {
  542. * var textFlow:TextFlow = TextConverter.importToFlow( "How now brown crow.", TextConverter.PLAIN_TEXT_FORMAT );
  543. * textFlow.flowComposer.addController( new ContainerController( new Sprite() ));
  544. * var editManager:EditManager = new EditManager();
  545. * textFlow.interactionManager = editManager;
  546. * textFlow.flowComposer.updateAllControllers();
  547. *
  548. * editManager.selectRange( 16, 16 );
  549. * editManager.deletePreviousCharacter(); //displays: How now brown cow.
  550. * }
  551. * }
  552. * }
  553. *
  554. * </listing>
  555. * /
  556. function deletePreviousCharacter(operationState:SelectionState = null):void*/,/*
  557. /**
  558. * Deletes the previous word.
  559. * <p>If a range is selected, the first word of the range is deleted.</p>
  560. * @param operationState specifies the text to which this operation applies; if <code>null</code>, the operation applies to the current selection.
  561. *
  562. * @example The following example creates a point selection in a text flow and deletes the previous word.
  563. * <listing>
  564. * var textFlow:TextFlow = TextConverter.importToFlow( "How do now brown cow.", TextConverter.PLAIN_TEXT_FORMAT );
  565. * textFlow.flowComposer = new StandardFlowComposer();
  566. * textFlow.flowComposer.addController( new ContainerController( this ));
  567. * var editManager:EditManager = new EditManager( new UndoManager() );
  568. * textFlow.interactionManager = editManager;
  569. * textFlow.flowComposer.updateAllControllers();
  570. *
  571. * editManager.setSelection( 7, 7 );
  572. * editManager.deletePreviousWord(); //displays: How now brown cow.
  573. *
  574. * </listing>
  575. * /
  576. function deletePreviousWord(operationState:SelectionState = null):void*/,/*
  577. /**
  578. * Deletes a range of text.
  579. * @param operationState specifies the text to which this operation applies; if <code>null</code>, the operation applies to the current selection.
  580. *
  581. * @example The following example creates a range selection in a text flow and deletes the selected characters.
  582. * <listing>
  583. * package flashx.textLayout.edit.examples
  584. * {
  585. * import flash.display.Sprite;
  586. *
  587. * import flashx.textLayout.container.ContainerController;
  588. * import flashx.textLayout.conversion.TextConverter;
  589. * import flashx.textLayout.edit.EditManager;
  590. * import flashx.textLayout.elements.TextFlow;
  591. *
  592. * public class EditManager_deleteText
  593. * {
  594. * static public function deleteText():void
  595. * {
  596. * var textFlow:TextFlow = TextConverter.importToFlow( "How do now brown cow.", TextConverter.PLAIN_TEXT_FORMAT );
  597. * textFlow.flowComposer.addController( new ContainerController( new Sprite() ));
  598. * var editManager:EditManager = new EditManager();
  599. * textFlow.interactionManager = editManager;
  600. * textFlow.flowComposer.updateAllControllers();
  601. *
  602. * editManager.selectRange( 4, 7 );
  603. * editManager.deleteText(); //displays: How now brown cow.
  604. * }
  605. * }
  606. * }
  607. * </listing>
  608. * /
  609. function deleteText(operationState:SelectionState = null):void*/,/*
  610. /**
  611. * Executes a FlowOperation.
  612. * <p>The <code>doOperation()</code> method is called by IEditManager functions that update the text flow. You do not typically need to call this function directly unless you create your own custom operations.</p>
  613. * <p>This function proceeds in the following steps:</p><ol>
  614. * <li>Flush any pending operations before performing this operation.</li>
  615. * <li>Send a cancelable flowOperationBegin event. If canceled this method returns immediately.</li>
  616. * <li>Execute the operation. The operation returns <code>true</code> or <code>false</code>. <code>False</code> indicates that no changes were made.</li>
  617. * <li>Push the operation onto the undo stack.</li>
  618. * <li>Clear the redo stack.</li>
  619. * <li>Update the display.</li>
  620. * <li>Send a cancelable flowOperationEnd event.</li></ol>
  621. * <p>Exception handling: If the operation throws an exception, it is caught and the error is attached to the flowOperationEnd event. If the event is not canceled the error is rethrown.</p>
  622. * @param operation a FlowOperation object
  623. *
  624. * @example The following example creates and executes an InsertTextOperation:
  625. * <listing>
  626. * package flashx.textLayout.edit.examples
  627. * {
  628. * import flash.display.Sprite;
  629. *
  630. * import flashx.textLayout.container.ContainerController;
  631. * import flashx.textLayout.conversion.TextConverter;
  632. * import flashx.textLayout.edit.EditManager;
  633. * import flashx.textLayout.edit.SelectionState;
  634. * import flashx.textLayout.elements.TextFlow;
  635. * import flashx.textLayout.operations.InsertTextOperation;
  636. *
  637. * public class EditManager_doOperation
  638. * {
  639. * static public function doOperation(sprite:Sprite):void
  640. * {
  641. * var textFlow:TextFlow = TextConverter.importToFlow( "How brown cow.", TextConverter.PLAIN_TEXT_FORMAT );
  642. * textFlow.flowComposer.addController( new ContainerController( sprite ));
  643. * var editManager:EditManager = new EditManager();
  644. * textFlow.interactionManager = editManager;
  645. * textFlow.flowComposer.updateAllControllers();
  646. *
  647. * var selectionState:SelectionState = new SelectionState(textFlow, 4, 4);
  648. * var insertOperation:InsertTextOperation = new InsertTextOperation( selectionState, "now " );
  649. * editManager.doOperation( insertOperation ); // displays: How now brown cow
  650. * }
  651. * }
  652. * }
  653. *
  654. * </listing>
  655. * /
  656. function doOperation(operation:FlowOperation):void*/,/*
  657. /**
  658. * Ends a group of operations.
  659. * <p>All operations executed since the last call to <code>beginCompositeOperation()</code> are grouped as a CompositeOperation that is then completed. This CompositeOperation object is added to the undo stack or, if this composite operation is nested inside another composite operation, added to the parent operation.</p>
  660. *
  661. * /
  662. function endCompositeOperation():void*/,/*
  663. /**
  664. * Inserts an image.
  665. * <p>The source of the image can be a string containing a URI, URLRequest object, a Class object representing an embedded asset, or a DisplayObject instance.</p>
  666. * <p>The width and height values can be the number of pixels, a percent, or the string, 'auto', in which case the actual dimension of the graphic is used.</p>
  667. * <p>Set the <code>float</code> to one of the constants defined in the Float class to specify whether the image should be displayed to the left or right of any text or inline with the text.</p>
  668. * @param source can be either a String interpreted as a uri, a Class interpreted as the class of an Embed DisplayObject, a DisplayObject instance or a URLRequest.
  669. * @param width width of the image to insert (number, percent, or 'auto')
  670. * @param height height of the image to insert (number, percent, or 'auto')
  671. * @param options none supported.
  672. * @param operationState specifies the text to which this operation applies; if <code>null</code>, the operation applies to the current selection.
  673. *
  674. * @see flashx.textLayout.elements.InlineGraphicElement
  675. *
  676. * @example The following example inserts a Shape object at the beginning of a text flow:
  677. * <listing>
  678. * package flashx.textLayout.edit.examples
  679. * {
  680. * import flash.display.Shape;
  681. * import flash.display.Sprite;
  682. *
  683. * import flashx.textLayout.container.ContainerController;
  684. * import flashx.textLayout.conversion.TextConverter;
  685. * import flashx.textLayout.edit.EditManager;
  686. * import flashx.textLayout.elements.TextFlow;
  687. * import flashx.undo.UndoManager;
  688. *
  689. * public class EditManager_insertInlineGraphic
  690. * {
  691. * static public function insertInlineGraphic(sprite:Sprite):void
  692. * {
  693. * var textFlow:TextFlow = TextConverter.importToFlow( "How now brown cow.", TextConverter.PLAIN_TEXT_FORMAT );
  694. * textFlow.flowComposer.addController( new ContainerController( sprite ));
  695. * var editManager:EditManager = new EditManager( new UndoManager() );
  696. * textFlow.interactionManager = editManager;
  697. * textFlow.flowComposer.updateAllControllers();
  698. *
  699. * editManager.selectRange( 0, 0 );
  700. * editManager.insertInlineGraphic( createGraphic(), 6, 6, "none" );
  701. *
  702. * }
  703. * static private function createGraphic():Shape
  704. * {
  705. * var shape:Shape = new Shape();
  706. * shape.graphics.beginFill( 0x993366 );
  707. * shape.graphics.drawCircle( 5, 4, 6 );
  708. * return shape;
  709. * }
  710. *
  711. * }
  712. * }
  713. * </listing>
  714. * /
  715. function insertInlineGraphic(source:Object, width:Object, height:Object, options:Object = null, operationState:SelectionState = null):void*/,/*
  716. /**
  717. * Inserts text.
  718. * <p>Inserts the text at a position or range in the text. If the location supplied in the <code>operationState</code> parameter is a range (or the parameter is <code>null</code> and the current selection is a range), then the text currently in the range is replaced by the inserted text.</p>
  719. * @param text the string to insert
  720. * @param operationState specifies the text in the flow to which this operation applies; if <code>null</code>, the operation applies to the current selection.
  721. *
  722. * @example The following example creates and executes an InsertTextOperation:
  723. * <listing>
  724. *
  725. * package flashx.textLayout.edit.examples
  726. * {
  727. * import flash.display.Sprite;
  728. *
  729. * import flashx.textLayout.container.ContainerController;
  730. * import flashx.textLayout.conversion.TextConverter;
  731. * import flashx.textLayout.edit.EditManager;
  732. * import flashx.textLayout.elements.TextFlow;
  733. * import flashx.undo.UndoManager;
  734. *
  735. * public class EditManager_insertText
  736. * {
  737. * static public function insertText(sprite:Sprite):void
  738. * {
  739. * var textFlow:TextFlow = TextConverter.importToFlow( "How brown cow.", TextConverter.PLAIN_TEXT_FORMAT );
  740. * textFlow.flowComposer.addController( new ContainerController( sprite ));
  741. * var editManager:EditManager = new EditManager( new UndoManager() );
  742. * textFlow.interactionManager = editManager;
  743. * textFlow.flowComposer.updateAllControllers();
  744. *
  745. * editManager.selectRange( 4, 4 );
  746. * editManager.insertText( "now " );
  747. * }
  748. * }
  749. * }
  750. * </listing>
  751. * /
  752. function insertText(text:String, operationState:SelectionState = null):void*/,/*
  753. /**
  754. * Modifies an existing inline graphic.
  755. * <p>Set unchanging properties to the values in the original graphic. (Modifying an existing graphic object is typically more efficient than deleting and recreating one.)</p>
  756. * @param source can be either a String interpreted as a uri, a Class interpreted as the class of an Embed DisplayObject, a DisplayObject instance or a URLRequest.
  757. * @param width new width for the image (number or percent)
  758. * @param height new height for the image (number or percent)
  759. * @param options none supported
  760. * @param operationState specifies the text to which this operation applies; if <code>null</code>, the operation applies to the current selection.
  761. *
  762. * @see flashx.textLayout.elements.InlineGraphicElement
  763. *
  764. * @example The following example inserts a circle at the beginning of a text flow, and then changes the <code>width</code> and <code>height</code> properties of the inline graphic to stretch it into an ellipse:
  765. * <listing>
  766. * package flashx.textLayout.edit.examples
  767. * {
  768. * import flash.display.Sprite;
  769. * import flash.display.Shape;
  770. *
  771. * import flashx.textLayout.container.ContainerController;
  772. * import flashx.textLayout.conversion.TextConverter;
  773. * import flashx.textLayout.edit.EditManager;
  774. * import flashx.textLayout.elements.TextFlow;
  775. * import flashx.undo.UndoManager;
  776. *
  777. * public class EditManager_modifyInlineGraphic
  778. * {
  779. * static public function modifyInlineGraphic(sprite:Sprite):void
  780. * {
  781. * var textFlow:TextFlow = TextConverter.importToFlow( "How now brown cow.", TextConverter.PLAIN_TEXT_FORMAT );
  782. * textFlow.flowComposer.addController( new ContainerController( sprite ));
  783. * var editManager:EditManager = new EditManager( new UndoManager() );
  784. * textFlow.interactionManager = editManager;
  785. * textFlow.flowComposer.updateAllControllers();
  786. * editManager.selectRange( 0, 0 );
  787. * editManager.insertInlineGraphic( createGraphic(), 6, 6, "none" );
  788. *
  789. * editManager.selectRange( 0, 1 );
  790. * editManager.modifyInlineGraphic( null, '12', '5', 'none' );
  791. * }
  792. *
  793. * static private function createGraphic():Shape
  794. * {
  795. * var shape:Shape = new Shape();
  796. * shape.graphics.beginFill( 0x993366 );
  797. * shape.graphics.drawCircle( 4, 4, 6 );
  798. * return shape;
  799. * }
  800. * }
  801. * }
  802. * </listing>
  803. * /
  804. function modifyInlineGraphic(source:Object, width:Object, height:Object, options:Object = null, operationState:SelectionState = null):void*/,/*
  805. /**
  806. * Overwrites the selected text.
  807. * <p>If the selection is a point selection, the first character is overwritten by the new text.</p>
  808. * @param text the string to insert
  809. * @param operationState specifies the text to which this operation applies; if <code>null</code>, the operation applies to the current selection.
  810. *
  811. * @example The following example overwrites a string of text in a text flow:
  812. * <listing>
  813. * package flashx.textLayout.edit.examples
  814. * {
  815. * import flash.display.Sprite;
  816. *
  817. * import flashx.textLayout.container.ContainerController;
  818. * import flashx.textLayout.conversion.TextConverter;
  819. * import flashx.textLayout.edit.EditManager;
  820. * import flashx.textLayout.elements.TextFlow;
  821. * import flashx.undo.UndoManager;
  822. *
  823. * public class EditManager_overwriteText
  824. * {
  825. * static public function overwriteText(sprite:Sprite):void
  826. * {
  827. * var textFlow:TextFlow = TextConverter.importToFlow( "How zzz brown cow.", TextConverter.PLAIN_TEXT_FORMAT );
  828. * textFlow.flowComposer.addController( new ContainerController( sprite ));
  829. * var editManager:EditManager = new EditManager( new UndoManager() );
  830. * textFlow.interactionManager = editManager;
  831. * textFlow.flowComposer.updateAllControllers();
  832. *
  833. * editManager.selectRange( 4, 6 );
  834. * editManager.overwriteText( "now" ); //Displays: How now brown cow.
  835. * }
  836. * }
  837. * }
  838. * </listing>
  839. * /
  840. function overwriteText(text:String, operationState:SelectionState = null):void*/,/*
  841. /**
  842. * Pastes the TextScrap into the selected area.
  843. * <p>If a range of text is specified, the text in the range is deleted.</p>
  844. * @param scrapToPaste the TextScrap to paste
  845. * @param operationState specifies the text to which this operation applies; if <code>null</code>, the operation applies to the current selection.
  846. *
  847. * @see TextScrap
  848. *
  849. * @example The following example cuts a text scrap and pastes it into a different location in a text flow:
  850. * <listing>
  851. * package flashx.textLayout.edit.examples
  852. * {
  853. * import flash.display.Sprite;
  854. *
  855. * import flashx.textLayout.container.ContainerController;
  856. * import flashx.textLayout.conversion.TextConverter;
  857. * import flashx.textLayout.edit.EditManager;
  858. * import flashx.textLayout.edit.TextScrap;
  859. * import flashx.textLayout.elements.TextFlow;
  860. * import flashx.undo.UndoManager;
  861. *
  862. * public class EditManager_pasteTextScrap
  863. * {
  864. * static public function pasteText(sprite:Sprite):void
  865. * {
  866. * var textFlow:TextFlow = TextConverter.importToFlow( "How brown cow now.", TextConverter.PLAIN_TEXT_FORMAT );
  867. * textFlow.flowComposer.addController( new ContainerController( sprite ));
  868. * var editManager:EditManager = new EditManager( new UndoManager() );
  869. * textFlow.interactionManager = editManager;
  870. * textFlow.flowComposer.updateAllControllers();
  871. *
  872. * editManager.selectRange( 13, 17 );
  873. * var scrap:TextScrap = editManager.cutTextScrap();
  874. *
  875. * editManager.selectRange( 3, 3 );
  876. * editManager.pasteTextScrap( scrap ); //Displays: How now brown cow.
  877. * }
  878. * }
  879. * }
  880. *
  881. * </listing>
  882. * /
  883. function pasteTextScrap(scrapToPaste:TextScrap, operationState:SelectionState = null):void*/,/*
  884. /**
  885. * Reperforms the previous undone operation.
  886. * <p><b>Note:</b> If the IUndoManager associated with this IEditManager is also associated with another IEditManager, then it is possible that the redo operation associated with the other IEditManager is the one redone. This can happen if the FlowOperation of another IEditManager is on top of the redo stack.</p>
  887. * <p>This function does nothing if undo is not turned on.</p>
  888. * @see flashx.undo.IUndoManager#redo()
  889. *
  890. * @example The following example defines a function that reperforms the last undone operation on a text flow:
  891. * <listing>
  892. * package flashx.textLayout.edit.examples
  893. * {
  894. * import flash.display.Sprite;
  895. *
  896. * import flashx.textLayout.edit.IEditManager;
  897. * import flashx.textLayout.elements.TextFlow;
  898. *
  899. * public class EditManager_redo
  900. * {
  901. * static public function redo( textFlow:TextFlow ):void
  902. * {
  903. * if( textFlow.interactionManager is IEditManager )
  904. * {
  905. * IEditManager( textFlow.interactionManager ).redo();
  906. * }
  907. * }
  908. * }
  909. * }
  910. * </listing>
  911. * /
  912. function redo():void*/,/*
  913. /**
  914. * Splits the paragraph at the current position.
  915. * <p>If a range of text is specified, the text in the range is deleted.</p>
  916. * @param operationState specifies the text to which this operation applies; if <code>null</code>, the operation applies to the current selection.
  917. *
  918. * @example The following example splits a paragraph into two:
  919. * <listing>
  920. * package flashx.textLayout.edit.examples
  921. * {
  922. * import flash.display.Sprite;
  923. *
  924. * import flashx.textLayout.container.ContainerController;
  925. * import flashx.textLayout.conversion.TextConverter;
  926. * import flashx.textLayout.edit.EditManager;
  927. * import flashx.textLayout.edit.TextScrap;
  928. * import flashx.textLayout.elements.TextFlow;
  929. * import flashx.undo.UndoManager;
  930. *
  931. * public class EditManager_splitParagraph
  932. * {
  933. * static public function splitParagraph(sprite:Sprite):void
  934. * {
  935. * var textFlow:TextFlow = TextConverter.importToFlow( "How now brown cow.", TextConverter.PLAIN_TEXT_FORMAT );
  936. * textFlow.flowComposer.addController( new ContainerController( sprite ));
  937. * var editManager:EditManager = new EditManager( new UndoManager() );
  938. * textFlow.interactionManager = editManager;
  939. * textFlow.flowComposer.updateAllControllers();
  940. *
  941. * editManager.selectRange( 8, 8 );
  942. * editManager.splitParagraph(); //Displays: How now
  943. * // brown cow.
  944. * }
  945. * }
  946. * }
  947. *
  948. * </listing>
  949. * /
  950. function splitParagraph(operationState:SelectionState = null):void*/,/*
  951. /**
  952. * Reverses the previous operation.
  953. * <p><b>Note:</b> If the IUndoManager associated with this IEditManager is also associated with another IEditManager, then it is possible that the undo operation associated with the other IEditManager is the one undone. This can happen if the FlowOperation of another IEditManager is on top of the undo stack.</p>
  954. * <p>This function does nothing if undo is not turned on.</p>
  955. * @see flashx.undo.IUndoManager#undo()
  956. *
  957. * @example The following …

Large files files are truncated, but you can click here to view the full file