|
@@ -10,16 +10,18 @@ to insert new content into it.
|
|
So I play both the role of a container that inserts
|
|
So I play both the role of a container that inserts
|
|
as well as the role of an element being inserted.
|
|
as well as the role of an element being inserted.
|
|
|
|
|
|
|
|
+I inherit from `ProtoStream`.
|
|
|
|
+
|
|
Creation API:
|
|
Creation API:
|
|
|
|
|
|
- `Domite new` creates an insertion point at the bottom of `<body>`.
|
|
- `Domite new` creates an insertion point at the bottom of `<body>`.
|
|
- - `Domite open` is unique way to create pieces of content. It creates an instance "floating in thin air" (wrapper around DOM DocumentFragment) that can be filled with any contents and then inserted in a page.
|
|
+ - `Domite newStream` is unique way to create pieces of content. It creates an instance "floating in thin air" (wrapper around DOM DocumentFragment) that can be filled with any contents and then inserted in a page.
|
|
- `Domite fromElement: aDomElement` wraps an element and set the cursor to its end.
|
|
- `Domite fromElement: aDomElement` wraps an element and set the cursor to its end.
|
|
|
|
|
|
Manipulation API:
|
|
Manipulation API:
|
|
|
|
|
|
- - `aDomite insertDomite:` and `aDomite insertString:` insert either a Domite or a text content at the insertion point.
|
|
+ - `aDomite << obj` inserts obj at the insertion point.
|
|
- - `aDomite clearHere` deletes contents of the wrapped element.
|
|
+ - `aDomite resetContents` deletes contents of the wrapped element.
|
|
|
|
|
|
Cursor moving API:
|
|
Cursor moving API:
|
|
|
|
|
|
@@ -35,16 +37,16 @@ Take this sample HTML, where `[n]` are just markers, not real content:
|
|
|
|
|
|
If `d` is a `Domite` representing `[1]`, then:
|
|
If `d` is a `Domite` representing `[1]`, then:
|
|
|
|
|
|
- - `d seekHereStart` would move `d` to be at `[2]`,
|
|
+ - `d setToStart` would move `d` to be at `[2]`,
|
|
- - `d seekHereEnd` would move `d` to be at `[3]`,
|
|
+ - `d setToEnd` would move `d` to be at `[3]`,
|
|
- - `d seekBeforeHere` would move `d` to be at `[4]`, and
|
|
+ - `d setToBefore` would move `d` to be at `[4]`, and
|
|
- - `d seekAfterHere` would move `d` to be at `[5]`.
|
|
+ - `d setToAfter` would move `d` to be at `[5]`.
|
|
|
|
|
|
-It is not presumed one would use `seekXxx`
|
|
+It is not presumed one would use `setToXxx`
|
|
to actually move around in a single instance.
|
|
to actually move around in a single instance.
|
|
It is envisioned this API will be used mostly
|
|
It is envisioned this API will be used mostly
|
|
in combination with `copy`, like
|
|
in combination with `copy`, like
|
|
-`afterMe := self copy seekAfterHere`.!
|
|
+`afterMe := self copy setToAfter`.!
|
|
|
|
|
|
!Domite methodsFor: 'accessing'!
|
|
!Domite methodsFor: 'accessing'!
|
|
|
|
|
|
@@ -157,6 +159,14 @@ putOn: aStream
|
|
|
|
|
|
!Domite methodsFor: 'testing'!
|
|
!Domite methodsFor: 'testing'!
|
|
|
|
|
|
|
|
+atEnd
|
|
|
|
+ ^ self reference isNil
|
|
|
|
+!
|
|
|
|
+
|
|
|
|
+atStart
|
|
|
|
+ ^ self reference = self element firstChild
|
|
|
|
+!
|
|
|
|
+
|
|
canSetToUpperLevel
|
|
canSetToUpperLevel
|
|
^ self element parentNode notNil
|
|
^ self element parentNode notNil
|
|
!
|
|
!
|