Merge pull request #179 from garth/text-tojson
basic Y.Text toJSON returns {unformatted:string}
			
			
This commit is contained in:
		
						commit
						ac8dab1e88
					
				| @ -668,6 +668,17 @@ export class YText extends AbstractType { | ||||
|     return str | ||||
|   } | ||||
| 
 | ||||
|   /** | ||||
|    * Returns the unformatted string representation of this YText type. | ||||
|    * | ||||
|    * Avoids undefined being returned when called as a nested type. | ||||
|    * | ||||
|    * @public | ||||
|    */ | ||||
|   toJSON () { | ||||
|     return this.toString() | ||||
|   } | ||||
| 
 | ||||
|   /** | ||||
|    * Apply a {@link Delta} on this shared YText type. | ||||
|    * | ||||
|  | ||||
| @ -149,3 +149,12 @@ export const testSnapshotDeleteAfter = tc => { | ||||
|   const state1 = text0.toDelta(snapshot1) | ||||
|   t.compare(state1, [{ insert: 'abcd' }]) | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * @param {t.TestCase} tc | ||||
|  */ | ||||
| export const testToJson = tc => { | ||||
|   const {text0 } = init(tc, { users: 1 }) | ||||
|   text0.insert(0, 'abc', { bold: true }) | ||||
|   t.assert(text0.toJSON() === 'abc', 'toJSON returns the unformatted text') | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user