Opened 17 years ago
Last modified 17 years ago
#3367 closed New Feature
Introduce range iterator API — at Initial Version
| Reported by: | Garry Yao | Owned by: | Frederico Caldeira Knabben |
|---|---|---|---|
| Priority: | Normal | Milestone: | CKEditor 3.0 |
| Component: | General | Version: | |
| Keywords: | Confirmed Review+ | Cc: |
Description
There're many cases when we need to traverse the range from the start boundary node to the end boundary node, it's archiveable by the following codes:
var boundaryNodes = range.getBoundaryNodes();
var firstNode = boundaryNodes.startNode;
var lastNode = boundaryNodes.endNode.getNextSourceNode( true );
var node = firstNode.getNextSourceNode();
while( node )
{
if ( node.getName() == 'span' && currentNode.getAttribute( '_fck_bookmark' ) )
{
node = node.getNextSourceNode();
continue;
}
// Processing logic...
node = node.getNextSourceNode();
}
It's cumbersome due to at least two reasons:
- The collapsed range problem reported at #3292;
- It make code DUP at every plugin for the same logic;
It's necessary to introduce an API for this feature with dom iterator, which already holds a method for iterating over paragraphs. So after the API, other plugins should walking through the range as easy as using the iterator.
