Add ydoc.getXmlElement
This commit is contained in:
parent
415a645874
commit
16d9638bc8
@ -739,6 +739,8 @@ type. Doesn't log types that have not been defined (using
|
|||||||
<dd>Define a shared Y.Map type. Is equivalent to <code>y.get(string, Y.Map)</code>.</dd>
|
<dd>Define a shared Y.Map type. Is equivalent to <code>y.get(string, Y.Map)</code>.</dd>
|
||||||
<b><code>getText(string):Y.Text</code></b>
|
<b><code>getText(string):Y.Text</code></b>
|
||||||
<dd>Define a shared Y.Text type. Is equivalent to <code>y.get(string, Y.Text)</code>.</dd>
|
<dd>Define a shared Y.Text type. Is equivalent to <code>y.get(string, Y.Text)</code>.</dd>
|
||||||
|
<b><code>getXmlElement(string, string):Y.XmlElement</code></b>
|
||||||
|
<dd>Define a shared Y.XmlElement type. Is equivalent to <code>y.get(string, Y.XmlElement)</code>.</dd>
|
||||||
<b><code>getXmlFragment(string):Y.XmlFragment</code></b>
|
<b><code>getXmlFragment(string):Y.XmlFragment</code></b>
|
||||||
<dd>Define a shared Y.XmlFragment type. Is equivalent to <code>y.get(string, Y.XmlFragment)</code>.</dd>
|
<dd>Define a shared Y.XmlFragment type. Is equivalent to <code>y.get(string, Y.XmlFragment)</code>.</dd>
|
||||||
<b><code>on(string, function)</code></b>
|
<b><code>on(string, function)</code></b>
|
||||||
|
@ -8,6 +8,7 @@ import {
|
|||||||
YArray,
|
YArray,
|
||||||
YText,
|
YText,
|
||||||
YMap,
|
YMap,
|
||||||
|
YXmlElement,
|
||||||
YXmlFragment,
|
YXmlFragment,
|
||||||
transact,
|
transact,
|
||||||
ContentDoc, Item, Transaction, YEvent // eslint-disable-line
|
ContentDoc, Item, Transaction, YEvent // eslint-disable-line
|
||||||
@ -262,6 +263,17 @@ export class Doc extends Observable {
|
|||||||
return this.get(name, YMap)
|
return this.get(name, YMap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} [name]
|
||||||
|
* @return {YXmlElement}
|
||||||
|
*
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
getXmlElement (name = '') {
|
||||||
|
// @ts-ignore
|
||||||
|
return this.get(name, YXmlElement)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} [name]
|
* @param {string} [name]
|
||||||
* @return {YXmlFragment}
|
* @return {YXmlFragment}
|
||||||
|
@ -210,3 +210,16 @@ export const testFormattingBug = _tc => {
|
|||||||
yxml.applyDelta(delta)
|
yxml.applyDelta(delta)
|
||||||
t.compare(yxml.toDelta(), delta)
|
t.compare(yxml.toDelta(), delta)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {t.TestCase} _tc
|
||||||
|
*/
|
||||||
|
export const testElement = _tc => {
|
||||||
|
const ydoc = new Y.Doc()
|
||||||
|
const yxmlel = ydoc.getXmlElement()
|
||||||
|
|
||||||
|
const text1 = new Y.XmlText('text1')
|
||||||
|
const text2 = new Y.XmlText('text2')
|
||||||
|
yxmlel.insert(0, [text1, text2])
|
||||||
|
t.compareArrays(yxmlel.toArray(), [text1, text2])
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user