schema.js 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. import Schema from '../../src/model/schema';
  6. import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
  7. import Element from '../../src/model/element';
  8. import Position from '../../src/model/position';
  9. import Text from '../../src/model/text';
  10. describe( 'Schema', () => {
  11. let schema, root1, r1p1, r1p2, r1bQ, r1bQp, root2;
  12. beforeEach( () => {
  13. schema = new Schema();
  14. root1 = new Element( '$root', null, [
  15. new Element( 'paragraph', null, 'foo' ),
  16. new Element( 'paragraph', { align: 'right' }, 'bar' ),
  17. new Element( 'blockQuote', null, [
  18. new Element( 'paragraph', null, 'foo' )
  19. ] )
  20. ] );
  21. r1p1 = root1.getChild( 0 );
  22. r1p2 = root1.getChild( 1 );
  23. r1bQ = root1.getChild( 2 );
  24. r1bQp = r1bQ.getChild( 0 );
  25. root2 = new Element( '$root2' );
  26. } );
  27. describe( 'register()', () => {
  28. it( 'allows registering an item', () => {
  29. schema.register( 'foo' );
  30. expect( schema.getRule( 'foo' ) ).to.be.an( 'object' );
  31. } );
  32. it( 'copies rules', () => {
  33. const rules = {};
  34. schema.register( 'foo', rules );
  35. rules.isBlock = true;
  36. expect( schema.getRules().foo ).to.not.have.property( 'isBlock' );
  37. } );
  38. it( 'throws when trying to register for a single item twice', () => {
  39. schema.register( 'foo' );
  40. expect( () => {
  41. schema.register( 'foo' );
  42. } ).to.throw( CKEditorError, /^schema-cannot-register-item-twice:/ );
  43. } );
  44. } );
  45. describe( 'extend()', () => {
  46. it( 'allows extending item\'s rules', () => {
  47. schema.register( 'foo' );
  48. schema.extend( 'foo', {
  49. isBlock: true
  50. } );
  51. expect( schema.getRule( 'foo' ) ).to.have.property( 'isBlock', true );
  52. } );
  53. it( 'copies rules', () => {
  54. schema.register( 'foo', {} );
  55. const rules = {};
  56. schema.extend( 'foo', rules );
  57. rules.isBlock = true;
  58. expect( schema.getRules().foo ).to.not.have.property( 'isBlock' );
  59. } );
  60. it( 'throws when trying to extend a not yet registered item', () => {
  61. expect( () => {
  62. schema.extend( 'foo' );
  63. } ).to.throw( CKEditorError, /^schema-cannot-extend-missing-item:/ );
  64. } );
  65. } );
  66. describe( 'getRules()', () => {
  67. it( 'returns compiled rules', () => {
  68. schema.register( '$root' );
  69. schema.register( 'foo', {
  70. allowIn: '$root'
  71. } );
  72. schema.extend( 'foo', {
  73. isBlock: true
  74. } );
  75. const rules = schema.getRules();
  76. expect( rules.foo ).to.deep.equal( {
  77. name: 'foo',
  78. allowIn: [ '$root' ],
  79. allowAttributes: [],
  80. isBlock: true
  81. } );
  82. } );
  83. it( 'copies all is* types', () => {
  84. schema.register( 'foo', {
  85. isBlock: true,
  86. isFoo: true
  87. } );
  88. schema.extend( 'foo', {
  89. isBar: true,
  90. isFoo: false // Just to check that the last one wins.
  91. } );
  92. const rules = schema.getRules();
  93. expect( rules.foo ).to.have.property( 'isBlock', true );
  94. expect( rules.foo ).to.have.property( 'isFoo', false );
  95. expect( rules.foo ).to.have.property( 'isBar', true );
  96. } );
  97. it( 'does not recompile rules if not needed', () => {
  98. schema.register( 'foo' );
  99. expect( schema.getRules() ).to.equal( schema.getRules() );
  100. } );
  101. it( 'ensures no duplicates in allowIn', () => {
  102. schema.register( '$root' );
  103. schema.register( 'foo', {
  104. allowIn: '$root'
  105. } );
  106. schema.extend( 'foo', {
  107. allowIn: '$root'
  108. } );
  109. const rules = schema.getRules();
  110. expect( rules.foo ).to.deep.equal( {
  111. name: 'foo',
  112. allowIn: [ '$root' ],
  113. allowAttributes: []
  114. } );
  115. } );
  116. it( 'ensures no unregistered items in allowIn', () => {
  117. schema.register( 'foo', {
  118. allowIn: '$root'
  119. } );
  120. const rules = schema.getRules();
  121. expect( rules.foo ).to.deep.equal( {
  122. name: 'foo',
  123. allowIn: [],
  124. allowAttributes: []
  125. } );
  126. } );
  127. it( 'ensures no duplicates in allowAttributes', () => {
  128. schema.register( 'paragraph', {
  129. allowAttributes: 'foo'
  130. } );
  131. schema.extend( 'paragraph', {
  132. allowAttributes: 'foo'
  133. } );
  134. const rules = schema.getRules();
  135. expect( rules.paragraph ).to.deep.equal( {
  136. name: 'paragraph',
  137. allowIn: [],
  138. allowAttributes: [ 'foo' ]
  139. } );
  140. } );
  141. it( 'ensures no duplicates in allowAttributes duplicated by allowAttributesOf', () => {
  142. schema.register( 'paragraph', {
  143. allowAttributes: 'foo',
  144. allowAttributesOf: '$block'
  145. } );
  146. schema.register( '$block', {
  147. allowAttributes: 'foo'
  148. } );
  149. const rules = schema.getRules();
  150. expect( rules.paragraph ).to.deep.equal( {
  151. name: 'paragraph',
  152. allowIn: [],
  153. allowAttributes: [ 'foo' ]
  154. } );
  155. } );
  156. } );
  157. describe( 'getRule()', () => {
  158. // TODO
  159. } );
  160. describe( 'isRegistered()', () => {
  161. it( 'returns true if an item was registered', () => {
  162. schema.register( 'foo' );
  163. expect( schema.isRegistered( 'foo' ) ).to.be.true;
  164. } );
  165. it( 'returns false if an item was not registered', () => {
  166. expect( schema.isRegistered( 'foo' ) ).to.be.false;
  167. } );
  168. } );
  169. describe( 'isBlock()', () => {
  170. it( 'returns true if an item was registered as a block', () => {
  171. schema.register( 'foo', {
  172. isBlock: true
  173. } );
  174. expect( schema.isBlock( 'foo' ) ).to.be.true;
  175. } );
  176. it( 'returns false if an item was not registered as a block', () => {
  177. schema.register( 'foo' );
  178. expect( schema.isBlock( 'foo' ) ).to.be.false;
  179. } );
  180. it( 'returns false if an item was not registered at all', () => {
  181. expect( schema.isBlock( 'foo' ) ).to.be.false;
  182. } );
  183. } );
  184. describe( 'isLimit()', () => {
  185. it( 'returns true if an item was registered as a limit element', () => {
  186. schema.register( 'foo', {
  187. isLimit: true
  188. } );
  189. expect( schema.isLimit( 'foo' ) ).to.be.true;
  190. } );
  191. it( 'returns false if an item was not registered as a limit element', () => {
  192. schema.register( 'foo' );
  193. expect( schema.isLimit( 'foo' ) ).to.be.false;
  194. } );
  195. it( 'returns false if an item was not registered at all', () => {
  196. expect( schema.isLimit( 'foo' ) ).to.be.false;
  197. } );
  198. } );
  199. describe( 'isObject()', () => {
  200. it( 'returns true if an item was registered as an object', () => {
  201. schema.register( 'foo', {
  202. isObject: true
  203. } );
  204. expect( schema.isObject( 'foo' ) ).to.be.true;
  205. } );
  206. it( 'returns false if an item was not registered as an object', () => {
  207. schema.register( 'foo' );
  208. expect( schema.isObject( 'foo' ) ).to.be.false;
  209. } );
  210. it( 'returns false if an item was not registered at all', () => {
  211. expect( schema.isObject( 'foo' ) ).to.be.false;
  212. } );
  213. } );
  214. describe( 'checkChild()', () => {
  215. beforeEach( () => {
  216. schema.register( '$root' );
  217. schema.register( 'paragraph', {
  218. allowIn: '$root'
  219. } );
  220. schema.register( '$text', {
  221. allowIn: 'paragraph'
  222. } );
  223. } );
  224. it( 'accepts an element as a context and a node name as a child', () => {
  225. expect( schema.checkChild( root1, 'paragraph' ) ).to.be.true;
  226. expect( schema.checkChild( root1, '$text' ) ).to.be.false;
  227. } );
  228. it( 'accepts a position as a context', () => {
  229. const posInRoot = Position.createAt( root1 );
  230. const posInParagraph = Position.createAt( r1p1 );
  231. expect( schema.checkChild( posInRoot, 'paragraph' ) ).to.be.true;
  232. expect( schema.checkChild( posInRoot, '$text' ) ).to.be.false;
  233. expect( schema.checkChild( posInParagraph, '$text' ) ).to.be.true;
  234. expect( schema.checkChild( posInParagraph, 'paragraph' ) ).to.be.false;
  235. } );
  236. // This is a temporary feature which is needed to make the current V->M conversion works.
  237. // It should be removed once V->M conversion uses real positions.
  238. // Of course, real positions have this advantage that we know element attributes at this point.
  239. it( 'accepts an array of element names as a context', () => {
  240. const contextInRoot = [ '$root' ];
  241. const contextInParagraph = [ '$root', 'paragraph' ];
  242. expect( schema.checkChild( contextInRoot, 'paragraph' ) ).to.be.true;
  243. expect( schema.checkChild( contextInRoot, '$text' ) ).to.be.false;
  244. expect( schema.checkChild( contextInParagraph, '$text' ) ).to.be.true;
  245. expect( schema.checkChild( contextInParagraph, 'paragraph' ) ).to.be.false;
  246. } );
  247. it( 'accepts a node as a child', () => {
  248. expect( schema.checkChild( root1, r1p1 ) ).to.be.true;
  249. expect( schema.checkChild( root1, new Text( 'foo' ) ) ).to.be.false;
  250. } );
  251. // TODO checks fires event
  252. // TODO checks with a custom context array
  253. } );
  254. describe( 'checkAttribute()', () => {
  255. beforeEach( () => {
  256. schema.register( 'paragraph', {
  257. allowAttributes: 'align'
  258. } );
  259. schema.register( '$text', {
  260. allowAttributes: 'bold'
  261. } );
  262. } );
  263. it( 'accepts an element as a context', () => {
  264. expect( schema.checkAttribute( r1p1, 'align' ) ).to.be.true;
  265. expect( schema.checkAttribute( r1p1, 'bold' ) ).to.be.false;
  266. } );
  267. it( 'accepts a text as a context', () => {
  268. expect( schema.checkAttribute( new Text( 'foo' ), 'bold' ) ).to.be.true;
  269. expect( schema.checkAttribute( new Text( 'foo' ), 'align' ) ).to.be.false;
  270. } );
  271. // TODO checks fires event
  272. // TODO checks with a custom context array
  273. } );
  274. describe( 'rules compilation', () => {
  275. describe( 'allowIn cases', () => {
  276. it( 'passes $root>paragraph', () => {
  277. schema.register( '$root' );
  278. schema.register( 'paragraph', {
  279. allowIn: '$root'
  280. } );
  281. expect( schema.checkChild( root1, r1p1 ) ).to.be.true;
  282. } );
  283. it( 'passes $root>paragraph and $root2>paragraph – support for array values', () => {
  284. schema.register( '$root' );
  285. schema.register( '$root2' );
  286. schema.register( 'paragraph', {
  287. allowIn: [ '$root', '$root2' ]
  288. } );
  289. expect( schema.checkChild( root1, r1p1 ) ).to.be.true;
  290. expect( schema.checkChild( root2, r1p1 ) ).to.be.true;
  291. } );
  292. it( 'passes $root>paragraph[align] – attributes does not matter', () => {
  293. schema.register( '$root' );
  294. schema.register( 'paragraph', {
  295. allowIn: '$root'
  296. } );
  297. expect( schema.checkChild( root1, r1p2 ) ).to.be.true;
  298. } );
  299. it( 'passes $root>div>div – in case of circular refs', () => {
  300. schema.register( '$root' );
  301. schema.register( 'div', {
  302. allowIn: [ '$root', 'div' ]
  303. } );
  304. const div = new Element( 'div' );
  305. root1.appendChildren( div );
  306. const div2 = new Element( 'div' );
  307. expect( schema.checkChild( div, div2 ) ).to.be.true;
  308. } );
  309. it( 'passes $root>div>div – in case of circular refs, when div1==div2', () => {
  310. schema.register( '$root' );
  311. schema.register( 'div', {
  312. allowIn: [ '$root', 'div' ]
  313. } );
  314. const div = new Element( 'div' );
  315. root1.appendChildren( div );
  316. expect( schema.checkChild( div, div ) ).to.be.true;
  317. } );
  318. it( 'rejects $root>paragraph – unregistered paragraph', () => {
  319. schema.register( '$root' );
  320. expect( schema.checkChild( root1, r1p1 ) ).to.be.false;
  321. } );
  322. it( 'rejects $root>paragraph – registered different item', () => {
  323. schema.register( '$root' );
  324. schema.register( 'paragraph' );
  325. schema.register( 'listItem', {
  326. allowIn: '$root'
  327. } );
  328. expect( schema.checkChild( root1, r1p1 ) ).to.be.false;
  329. } );
  330. it( 'rejects $root>paragraph – paragraph allowed in different context', () => {
  331. schema.register( '$root' );
  332. schema.register( '$fancyRoot' );
  333. schema.register( 'paragraph', {
  334. allowIn: '$fancyRoot'
  335. } );
  336. expect( schema.checkChild( root1, r1p1 ) ).to.be.false;
  337. } );
  338. it( 'rejects $root>blockQuote>paragraph – since paragraph is only allowed in $root', () => {
  339. schema.register( '$root' );
  340. schema.register( 'paragraph', {
  341. allowIn: '$root'
  342. } );
  343. expect( schema.checkChild( r1bQ, r1bQp ) ).to.be.false;
  344. } );
  345. it( 'rejects $root>blockQuote>paragraph – since paragraph is only allowed in $root v2', () => {
  346. schema.register( '$root' );
  347. schema.register( 'blockQuote', {
  348. allowIn: '$root'
  349. } );
  350. schema.register( 'paragraph', {
  351. allowIn: '$root'
  352. } );
  353. expect( schema.checkChild( r1bQ, r1bQp ) ).to.be.false;
  354. } );
  355. it( 'rejects $root>blockQuote>paragraph>$text - since paragraph is not allowed in blockQuote', () => {
  356. schema.register( '$root' );
  357. schema.register( 'paragraph', {
  358. allowIn: '$root'
  359. } );
  360. schema.register( '$text', {
  361. allowIn: 'paragraph'
  362. } );
  363. expect( schema.checkChild( root1, r1bQp.getChild( 0 ) ) ).to.be.false;
  364. } );
  365. it( 'rejects $root>blockQuote>paragraph>$text - since blockQuote is not allowed in $root', () => {
  366. schema.register( '$root' );
  367. schema.register( 'blockQuote' );
  368. schema.register( 'paragraph', {
  369. allowIn: [ 'blockQuote', '$root' ]
  370. } );
  371. schema.register( '$text', {
  372. allowIn: 'paragraph'
  373. } );
  374. expect( schema.checkChild( root1, r1bQp.getChild( 0 ) ) ).to.be.false;
  375. } );
  376. } );
  377. describe( 'allowWhere cases', () => {
  378. it( 'passes $root>paragraph – paragraph inherits from $block', () => {
  379. schema.register( '$root' );
  380. schema.register( '$block', {
  381. allowIn: '$root'
  382. } );
  383. schema.register( 'paragraph', {
  384. allowWhere: '$block'
  385. } );
  386. expect( schema.checkChild( root1, r1p1 ) ).to.be.true;
  387. } );
  388. it( 'supports the array syntax', () => {
  389. schema.register( '$root' );
  390. schema.register( '$root2' );
  391. schema.register( '$block', {
  392. allowIn: '$root'
  393. } );
  394. schema.register( '$block2', {
  395. allowIn: '$root2'
  396. } );
  397. schema.register( 'paragraph', {
  398. allowWhere: [ '$block', '$block2' ]
  399. } );
  400. expect( schema.checkChild( root1, r1p1 ), '$root' ).to.be.true;
  401. expect( schema.checkChild( root2, r1p1 ), '$root2' ).to.be.true;
  402. } );
  403. // This checks if some inapropriate caching or preprocessing isn't applied by register().
  404. it( 'passes $root>paragraph – paragraph inherits from $block, order of rules does not matter', () => {
  405. schema.register( '$root' );
  406. schema.register( 'paragraph', {
  407. allowWhere: '$block'
  408. } );
  409. schema.register( '$block', {
  410. allowIn: '$root'
  411. } );
  412. expect( schema.checkChild( root1, r1p1 ) ).to.be.true;
  413. } );
  414. it( 'passes $root>paragraph – paragraph inherits from $specialBlock which inherits from $block', () => {
  415. schema.register( '$root' );
  416. schema.register( '$block', {
  417. allowIn: '$root'
  418. } );
  419. schema.register( '$specialBlock', {
  420. allowWhere: '$block'
  421. } );
  422. schema.register( 'paragraph', {
  423. allowWhere: '$specialBlock'
  424. } );
  425. expect( schema.checkChild( root1, r1p1 ) ).to.be.true;
  426. } );
  427. it( 'rejects $root>paragraph – paragraph inherits from $block but $block is not allowed in $root', () => {
  428. schema.register( '$root' );
  429. schema.register( '$block' );
  430. schema.register( 'paragraph', {
  431. allowWhere: '$block'
  432. } );
  433. expect( schema.checkChild( root1, r1p1 ) ).to.be.false;
  434. } );
  435. it( 'rejects $root>paragraph>$text – paragraph inherits from $block but $block is not allowed in $root', () => {
  436. schema.register( '$root' );
  437. schema.register( '$block' );
  438. schema.register( 'paragraph', {
  439. allowWhere: '$block'
  440. } );
  441. schema.register( '$text', {
  442. allowIn: 'paragraph'
  443. } );
  444. expect( schema.checkChild( root1, r1p1.getChild( 0 ) ) ).to.be.false;
  445. } );
  446. } );
  447. describe( 'allowContentOf cases', () => {
  448. it( 'passes $root2>paragraph – $root2 inherits from $root', () => {
  449. schema.register( '$root' );
  450. schema.register( 'paragraph', {
  451. allowIn: '$root'
  452. } );
  453. schema.register( '$root2', {
  454. allowContentOf: '$root'
  455. } );
  456. expect( schema.checkChild( root2, r1p1 ) ).to.be.true;
  457. } );
  458. it( 'supports the array syntax', () => {
  459. schema.register( '$root' );
  460. schema.register( '$root2' );
  461. schema.register( 'paragraph', {
  462. allowIn: '$root'
  463. } );
  464. schema.register( 'heading1', {
  465. allowIn: '$root2'
  466. } );
  467. schema.register( '$root3', {
  468. allowContentOf: [ '$root', '$root2' ]
  469. } );
  470. const root3 = new Element( '$root3' );
  471. const heading1 = new Element( 'heading1' );
  472. expect( schema.checkChild( root3, r1p1 ), 'paragraph' ).to.be.true;
  473. expect( schema.checkChild( root3, heading1 ), 'heading1' ).to.be.true;
  474. } );
  475. it( 'passes $root2>paragraph – $root2 inherits from $root, order of rules does not matter', () => {
  476. schema.register( '$root' );
  477. schema.register( '$root2', {
  478. allowContentOf: '$root'
  479. } );
  480. schema.register( 'paragraph', {
  481. allowIn: '$root'
  482. } );
  483. expect( schema.checkChild( root2, r1p1 ) ).to.be.true;
  484. } );
  485. it( 'passes $root>paragraph>$text – paragraph inherits content of $block', () => {
  486. schema.register( '$root' );
  487. schema.register( '$block' );
  488. schema.register( 'paragraph', {
  489. allowIn: '$root',
  490. allowContentOf: '$block'
  491. } );
  492. schema.register( '$text', {
  493. allowIn: '$block'
  494. } );
  495. expect( schema.checkChild( r1p1, r1p1.getChild( 0 ) ) ).to.be.true;
  496. } );
  497. // TODO we need to make it possible to disallow bQ in bQ.
  498. it( 'passes $root>blockQuote>paragraph – blockQuote inherits content of $root', () => {
  499. schema.register( '$root' );
  500. schema.register( 'blockQuote', {
  501. allowIn: '$root',
  502. allowContentOf: '$root'
  503. } );
  504. schema.register( 'paragraph', {
  505. allowIn: '$root'
  506. } );
  507. expect( schema.checkChild( r1bQ, r1bQp ) ).to.be.true;
  508. } );
  509. it( 'rejects $root2>paragraph – $root2 inherits from $root, but paragraph is not allowed there anyway', () => {
  510. schema.register( '$root' );
  511. schema.register( 'paragraph' );
  512. schema.register( '$root2', {
  513. allowContentOf: '$root'
  514. } );
  515. expect( schema.checkChild( root2, r1p1 ) ).to.be.false;
  516. } );
  517. } );
  518. describe( 'mix of allowContentOf and allowWhere', () => {
  519. it( 'passes $root>paragraph>$text – paragraph inherits all from $block', () => {
  520. schema.register( '$root' );
  521. schema.register( '$block', {
  522. allowIn: '$root'
  523. } );
  524. schema.register( 'paragraph', {
  525. allowContentOf: '$block',
  526. allowWhere: '$block'
  527. } );
  528. schema.register( '$text', {
  529. allowIn: '$block'
  530. } );
  531. expect( schema.checkChild( r1p1, r1p1.getChild( 0 ) ) ).to.be.true;
  532. } );
  533. it( 'passes $root>paragraph and $root2>paragraph – where $root2 inherits content of $root' +
  534. 'and paragraph inherits allowWhere from $block', () => {
  535. schema.register( '$root' );
  536. schema.register( '$root2', {
  537. allowContentOf: '$root'
  538. } );
  539. schema.register( '$block', {
  540. allowIn: '$root'
  541. } );
  542. schema.register( 'paragraph', {
  543. allowWhere: '$block'
  544. } );
  545. expect( schema.checkChild( root1, 'paragraph' ), 'root1' ).to.be.true;
  546. expect( schema.checkChild( root2, 'paragraph' ), 'root2' ).to.be.true;
  547. } );
  548. it( 'passes d>a where d inherits content of c which inherits content of b', () => {
  549. schema.register( 'b' );
  550. schema.register( 'a', { allowIn: 'b' } );
  551. schema.register( 'c', { allowContentOf: 'b' } );
  552. schema.register( 'd', { allowContentOf: 'c' } );
  553. const d = new Element( 'd' );
  554. expect( schema.checkChild( d, 'a' ) ).to.be.true;
  555. } );
  556. // This case won't pass becuase we compile the rules in a pretty naive way.
  557. // To make chains like this work we'd need to repeat compilation of allowContentOf rules
  558. // as long as the previous iteration found something to compile.
  559. // This way, even though we'd not compile d<-c in the first run, we'd still find b<-c
  560. // and since we've found something, we'd now try d<-c which would work.
  561. //
  562. // We ignore those situations for now as they are very unlikely to happen and would
  563. // significantly raised the complexity of rule compilation.
  564. //
  565. // it( 'passes d>a where d inherits content of c which inherits content of b', () => {
  566. // schema.register( 'b' );
  567. // schema.register( 'a', { allowIn: 'b' } );
  568. // schema.register( 'd', { allowContentOf: 'c' } );
  569. // schema.register( 'c', { allowContentOf: 'b' } );
  570. //
  571. // const d = new Element( 'd' );
  572. //
  573. // expect( schema.checkChild( d, 'a' ) ).to.be.true;
  574. // } );
  575. } );
  576. describe( 'inheritAllFrom', () => {
  577. it( 'passes $root>paragraph – paragraph inherits allowIn from $block', () => {
  578. schema.register( '$root' );
  579. schema.register( '$block', {
  580. allowIn: '$root'
  581. } );
  582. schema.register( 'paragraph', {
  583. inheritAllFrom: '$block'
  584. } );
  585. expect( schema.checkChild( root1, r1p1 ) ).to.be.true;
  586. } );
  587. it( 'passes $root>paragraph>$text – paragraph inherits allowed content of $block', () => {
  588. schema.register( '$root' );
  589. schema.register( '$block', {
  590. allowIn: '$root'
  591. } );
  592. schema.register( '$text', {
  593. allowIn: '$block'
  594. } );
  595. schema.register( 'paragraph', {
  596. inheritAllFrom: '$block'
  597. } );
  598. expect( schema.checkChild( r1p1, r1p1.getChild( 0 ) ) ).to.be.true;
  599. } );
  600. it( 'passes $root>paragraph>$text – paragraph inherits allowIn from $block through $block\'s allowWhere', () => {
  601. schema.register( '$root' );
  602. schema.register( '$blockProto', {
  603. allowIn: '$root'
  604. } );
  605. schema.register( '$block', {
  606. allowWhere: '$blockProto'
  607. } );
  608. schema.register( 'paragraph', {
  609. inheritAllFrom: '$block'
  610. } );
  611. expect( schema.checkChild( root1, r1p1 ) ).to.be.true;
  612. } );
  613. it( 'passes $root>paragraph>$text – paragraph inherits allowIn from $block through $block\'s allowWhere', () => {
  614. schema.register( '$root' );
  615. schema.register( '$blockProto' );
  616. schema.register( '$block', {
  617. allowContentOf: '$blockProto',
  618. allowIn: '$root'
  619. } );
  620. schema.register( '$text', {
  621. allowIn: '$blockProto'
  622. } );
  623. schema.register( 'paragraph', {
  624. inheritAllFrom: '$block'
  625. } );
  626. expect( schema.checkChild( r1p1, r1p1.getChild( 0 ) ) ).to.be.true;
  627. } );
  628. } );
  629. // We need to handle cases where some independent features registered rules which might use
  630. // optional elements (elements which might not have been registered).
  631. describe( 'missing structure rules', () => {
  632. it( 'does not break when trying to check a child which is not registered', () => {
  633. schema.register( '$root' );
  634. expect( schema.checkChild( root1, 'foo404' ) ).to.be.false;
  635. } );
  636. it( 'does not break when trying to check registered child in a context which contains unregistered elements', () => {
  637. const foo404 = new Element( 'foo404' );
  638. root1.appendChildren( foo404 );
  639. schema.register( '$root' );
  640. schema.register( '$text', {
  641. allowIn: '$root'
  642. } );
  643. expect( schema.checkChild( foo404, '$text' ) ).to.be.false;
  644. } );
  645. it( 'does not break when used allowedIn pointing to an unregistered element', () => {
  646. schema.register( '$root' );
  647. schema.register( '$text', {
  648. allowIn: 'foo404'
  649. } );
  650. expect( schema.checkChild( root1, '$text' ) ).to.be.false;
  651. } );
  652. it( 'does not break when used allowWhere pointing to an unregistered element', () => {
  653. schema.register( '$root' );
  654. schema.register( '$text', {
  655. allowWhere: 'foo404'
  656. } );
  657. expect( schema.checkChild( root1, '$text' ) ).to.be.false;
  658. } );
  659. it( 'does not break when used allowContentOf pointing to an unregistered element', () => {
  660. schema.register( '$root', {
  661. allowContentOf: 'foo404'
  662. } );
  663. schema.register( '$text', {
  664. allowIn: '$root'
  665. } );
  666. expect( schema.checkChild( root1, '$text' ) ).to.be.true;
  667. } );
  668. it( 'checks whether allowIn uses a registered element', () => {
  669. schema.register( 'paragraph', {
  670. allowIn: '$root'
  671. } );
  672. // $root isn't registered!
  673. expect( schema.checkChild( root1, 'paragraph' ) ).to.be.false;
  674. } );
  675. it( 'does not break when inheriting all from an unregistered element', () => {
  676. schema.register( 'paragraph', {
  677. inheritAllFrom: '$block'
  678. } );
  679. expect( schema.checkChild( root1, r1p1 ) ).to.be.false;
  680. } );
  681. } );
  682. describe( 'allowAttributes', () => {
  683. it( 'passes paragraph[align]', () => {
  684. schema.register( 'paragraph', {
  685. allowAttributes: 'align'
  686. } );
  687. expect( schema.checkAttribute( r1p1, 'align' ) ).to.be.true;
  688. } );
  689. it( 'passes paragraph[align] and paragraph[dir] – support for array values', () => {
  690. schema.register( 'paragraph', {
  691. allowAttributes: [ 'align', 'dir' ]
  692. } );
  693. expect( schema.checkAttribute( r1p1, 'align' ), 'align' ).to.be.true;
  694. expect( schema.checkAttribute( r1p1, 'dir' ), 'dir' ).to.be.true;
  695. } );
  696. it( 'passes paragraph>$text[bold]', () => {
  697. schema.register( 'paragraph' );
  698. schema.register( '$text', {
  699. allowIn: 'paragraph',
  700. allowAttributes: 'bold'
  701. } );
  702. expect( schema.checkAttribute( r1p1.getChild( 0 ), 'bold' ) ).to.be.true;
  703. } );
  704. } );
  705. describe( 'allowAttributesOf', () => {
  706. it( 'passes paragraph[align] – paragraph inherits from $block', () => {
  707. schema.register( '$block', {
  708. allowAttributes: 'align'
  709. } );
  710. schema.register( 'paragraph', {
  711. allowAttributesOf: '$block'
  712. } );
  713. expect( schema.checkAttribute( r1p1, 'align' ) ).to.be.true;
  714. } );
  715. it( 'passes paragraph[align] and paragraph[dir] – support for array values', () => {
  716. schema.register( '$block', {
  717. allowAttributes: 'align'
  718. } );
  719. schema.register( '$block2', {
  720. allowAttributes: 'dir'
  721. } );
  722. schema.register( 'paragraph', {
  723. allowAttributesOf: [ '$block', '$block2' ]
  724. } );
  725. expect( schema.checkAttribute( r1p1, 'align' ), 'align' ).to.be.true;
  726. expect( schema.checkAttribute( r1p1, 'dir' ), 'dir' ).to.be.true;
  727. } );
  728. it( 'passes paragraph[align] and paragraph[dir] – support for combined allowAttributes and allowAttributesOf', () => {
  729. schema.register( '$block', {
  730. allowAttributes: 'align'
  731. } );
  732. schema.register( 'paragraph', {
  733. allowAttributes: 'dir',
  734. allowAttributesOf: '$block'
  735. } );
  736. expect( schema.checkAttribute( r1p1, 'align' ), 'align' ).to.be.true;
  737. expect( schema.checkAttribute( r1p1, 'dir' ), 'dir' ).to.be.true;
  738. } );
  739. // The support for allowAttributesOf is broken in the similar way as for allowContentOf (see the comment above).
  740. // However, those situations are rather theoretical, so we're not going to waste time on them now.
  741. } );
  742. describe( 'inheritAllFrom', () => {
  743. it( 'passes paragraph[align] – paragraph inherits attributes of $block', () => {
  744. schema.register( '$block', {
  745. allowAttributes: 'align'
  746. } );
  747. schema.register( 'paragraph', {
  748. inheritAllFrom: '$block'
  749. } );
  750. expect( schema.checkAttribute( r1p1, 'align' ) ).to.be.true;
  751. } );
  752. it( 'passes paragraph[align] – paragraph inherits attributes of $block through allowAttributesOf', () => {
  753. schema.register( '$blockProto', {
  754. allowAttributes: 'align'
  755. } );
  756. schema.register( '$block', {
  757. allowAttributesOf: '$blockProto'
  758. } );
  759. schema.register( 'paragraph', {
  760. inheritAllFrom: '$block'
  761. } );
  762. expect( schema.checkAttribute( r1p1, 'align' ) ).to.be.true;
  763. } );
  764. } );
  765. describe( 'missing attribute rules', () => {
  766. it( 'does not crash when checking an attribute of a unregistered element', () => {
  767. expect( schema.checkAttribute( r1p1, 'align' ) ).to.be.false;
  768. } );
  769. it( 'does not crash when inheriting attributes of a unregistered element', () => {
  770. schema.register( 'paragraph', {
  771. allowAttributesOf: '$block'
  772. } );
  773. expect( schema.checkAttribute( r1p1, 'whatever' ) ).to.be.false;
  774. } );
  775. it( 'does not crash when inheriting all from a unregistered element', () => {
  776. schema.register( 'paragraph', {
  777. allowAttributesOf: '$block'
  778. } );
  779. expect( schema.checkAttribute( r1p1, 'whatever' ) ).to.be.false;
  780. } );
  781. } );
  782. } );
  783. describe( 'real scenarios', () => {
  784. let r1bQi, r1i, r1lI, r1h, r1bQlI;
  785. const rules = [
  786. () => {
  787. schema.register( 'paragraph', {
  788. allowWhere: '$block',
  789. allowContentOf: '$block',
  790. allowAttributesOf: '$block'
  791. } );
  792. },
  793. () => {
  794. schema.register( 'heading1', {
  795. allowWhere: '$block',
  796. allowContentOf: '$block',
  797. allowAttributesOf: '$block'
  798. } );
  799. },
  800. () => {
  801. schema.register( 'listItem', {
  802. allowWhere: '$block',
  803. allowContentOf: '$block',
  804. allowAttributes: [ 'indent', 'type' ],
  805. allowAttributesOf: '$block'
  806. } );
  807. },
  808. () => {
  809. schema.register( 'blockQuote', {
  810. allowWhere: '$block',
  811. allowContentOf: '$root'
  812. } );
  813. // Disallow blockQuote in blockQuote.
  814. schema.on( 'checkChild', ( evt, args ) => {
  815. const context = args[ 0 ];
  816. const child = args[ 1 ];
  817. const childRule = schema.getRule( child );
  818. if ( childRule.name == 'blockQuote' && context[ context.length - 1 ].name == 'blockQuote' ) {
  819. evt.stop();
  820. evt.return = false;
  821. }
  822. }, { priority: 'high' } );
  823. },
  824. () => {
  825. schema.register( 'image', {
  826. allowWhere: '$block',
  827. allowAttributes: [ 'src', 'alt' ]
  828. } );
  829. },
  830. () => {
  831. schema.register( 'caption', {
  832. allowIn: 'image',
  833. allowContentOf: '$block'
  834. } );
  835. },
  836. () => {
  837. schema.extend( '$text', {
  838. allowAttributes: [ 'bold', 'italic' ]
  839. } );
  840. // Disallow bold in heading1.
  841. schema.on( 'checkAttribute', ( evt, args ) => {
  842. const context = args[ 0 ];
  843. const contextLast = context[ context.length - 1 ];
  844. const contextSecondToLast = context[ context.length - 2 ];
  845. const attributeName = args[ 1 ];
  846. if ( contextLast.name == '$text' && contextSecondToLast.name == 'heading1' && attributeName == 'bold' ) {
  847. evt.stop();
  848. evt.return = false;
  849. }
  850. }, { priority: 'high' } );
  851. },
  852. () => {
  853. schema.extend( '$block', {
  854. allowAttributes: 'alignment'
  855. } );
  856. }
  857. ];
  858. beforeEach( () => {
  859. schema.register( '$root' );
  860. schema.register( '$block', {
  861. allowIn: '$root'
  862. } );
  863. schema.register( '$text', {
  864. allowIn: '$block'
  865. } );
  866. for ( const rule of rules ) {
  867. rule();
  868. }
  869. // or...
  870. //
  871. // Use the below code to shuffle the rules.
  872. // Don't look here, Szymon!
  873. //
  874. // const rulesCopy = rules.slice();
  875. //
  876. // while ( rulesCopy.length ) {
  877. // const r = Math.floor( Math.random() * rulesCopy.length );
  878. // rulesCopy.splice( r, 1 )[ 0 ]();
  879. // }
  880. root1 = new Element( '$root', null, [
  881. new Element( 'paragraph', null, 'foo' ),
  882. new Element( 'paragraph', { alignment: 'right' }, 'bar' ),
  883. new Element( 'listItem', { type: 'x', indent: 0 }, 'foo' ),
  884. new Element( 'heading1', null, 'foo' ),
  885. new Element( 'blockQuote', null, [
  886. new Element( 'paragraph', null, 'foo' ),
  887. new Element( 'listItem', { type: 'x', indent: 0 }, 'foo' ),
  888. new Element( 'image', null, [
  889. new Element( 'caption', null, 'foo' )
  890. ] )
  891. ] ),
  892. new Element( 'image', null, [
  893. new Element( 'caption', null, 'foo' )
  894. ] )
  895. ] );
  896. r1p1 = root1.getChild( 0 );
  897. r1p2 = root1.getChild( 1 );
  898. r1lI = root1.getChild( 2 );
  899. r1h = root1.getChild( 3 );
  900. r1bQ = root1.getChild( 4 );
  901. r1i = root1.getChild( 5 );
  902. r1bQp = r1bQ.getChild( 0 );
  903. r1bQlI = r1bQ.getChild( 1 );
  904. r1bQi = r1bQ.getChild( 2 );
  905. } );
  906. it( 'passes $root>paragraph', () => {
  907. expect( schema.checkChild( root1, 'paragraph' ) ).to.be.true;
  908. } );
  909. it( 'passes $root>paragraph>$text', () => {
  910. expect( schema.checkChild( r1p1, '$text' ), 'paragraph' ).to.be.true;
  911. expect( schema.checkChild( r1p2, '$text' ), 'paragraph[alignment]' ).to.be.true;
  912. } );
  913. it( 'passes $root>listItem', () => {
  914. expect( schema.checkChild( root1, 'listItem' ) ).to.be.true;
  915. } );
  916. it( 'passes $root>listItem>$text', () => {
  917. expect( schema.checkChild( r1lI, '$text' ) ).to.be.true;
  918. } );
  919. it( 'passes $root>blockQuote>paragraph', () => {
  920. expect( schema.checkChild( r1bQ, 'paragraph' ) ).to.be.true;
  921. } );
  922. it( 'passes $root>blockQuote>paragraph>$text', () => {
  923. expect( schema.checkChild( r1bQp, '$text' ) ).to.be.true;
  924. } );
  925. it( 'passes $root>blockQuote>listItem', () => {
  926. expect( schema.checkChild( r1bQ, 'listItem' ) ).to.be.true;
  927. } );
  928. it( 'passes $root>blockQuote>listItem>$text', () => {
  929. expect( schema.checkChild( r1bQlI, '$text' ) ).to.be.true;
  930. } );
  931. it( 'passes $root>blockQuote>image', () => {
  932. expect( schema.checkChild( r1bQ, 'image' ) ).to.be.true;
  933. } );
  934. it( 'passes $root>blockQuote>image>caption', () => {
  935. expect( schema.checkChild( r1bQi, 'caption' ) ).to.be.true;
  936. } );
  937. it( 'passes $root>blockQuote>image>caption>$text', () => {
  938. expect( schema.checkChild( r1bQi.getChild( 0 ), '$text' ) ).to.be.true;
  939. } );
  940. it( 'passes $root>image', () => {
  941. expect( schema.checkChild( root1, 'image' ) ).to.be.true;
  942. } );
  943. it( 'passes $root>image>caption', () => {
  944. expect( schema.checkChild( r1i, 'caption' ) ).to.be.true;
  945. } );
  946. it( 'passes $root>image>caption>$text', () => {
  947. expect( schema.checkChild( r1i.getChild( 0 ), '$text' ) ).to.be.true;
  948. } );
  949. it( 'rejects $root>$root', () => {
  950. expect( schema.checkChild( root1, '$root' ) ).to.be.false;
  951. } );
  952. it( 'rejects $root>$text', () => {
  953. expect( schema.checkChild( root1, '$text' ) ).to.be.false;
  954. } );
  955. it( 'rejects $root>caption', () => {
  956. expect( schema.checkChild( root1, 'caption' ) ).to.be.false;
  957. } );
  958. it( 'rejects $root>paragraph>paragraph', () => {
  959. expect( schema.checkChild( r1p1, 'paragraph' ) ).to.be.false;
  960. } );
  961. it( 'rejects $root>paragraph>paragraph>$text', () => {
  962. // Edge case because p>p should not exist in the first place.
  963. // But it's good to know that it blocks also this.
  964. const p = new Element( 'p' );
  965. r1p1.appendChildren( p );
  966. expect( schema.checkChild( p, '$text' ) ).to.be.false;
  967. } );
  968. it( 'rejects $root>paragraph>$block', () => {
  969. expect( schema.checkChild( r1p1, '$block' ) ).to.be.false;
  970. } );
  971. it( 'rejects $root>paragraph>blockQuote', () => {
  972. expect( schema.checkChild( r1p1, 'blockQuote' ) ).to.be.false;
  973. } );
  974. it( 'rejects $root>paragraph>image', () => {
  975. expect( schema.checkChild( r1p1, 'image' ) ).to.be.false;
  976. } );
  977. it( 'rejects $root>paragraph>caption', () => {
  978. expect( schema.checkChild( r1p1, 'caption' ) ).to.be.false;
  979. } );
  980. it( 'rejects $root>blockQuote>blockQuote', () => {
  981. expect( schema.checkChild( r1bQ, 'blockQuote' ) ).to.be.false;
  982. } );
  983. it( 'rejects $root>blockQuote>caption', () => {
  984. expect( schema.checkChild( r1p1, 'image' ) ).to.be.false;
  985. } );
  986. it( 'rejects $root>blockQuote>$text', () => {
  987. expect( schema.checkChild( r1bQ, '$text' ) ).to.be.false;
  988. } );
  989. it( 'rejects $root>image>$text', () => {
  990. expect( schema.checkChild( r1i, '$text' ) ).to.be.false;
  991. } );
  992. it( 'rejects $root>image>paragraph', () => {
  993. expect( schema.checkChild( r1i, 'paragraph' ) ).to.be.false;
  994. } );
  995. it( 'rejects $root>image>caption>paragraph', () => {
  996. expect( schema.checkChild( r1i.getChild( 0 ), 'paragraph' ) ).to.be.false;
  997. } );
  998. it( 'rejects $root>image>caption>blockQuote', () => {
  999. expect( schema.checkChild( r1i.getChild( 0 ), 'blockQuote' ) ).to.be.false;
  1000. } );
  1001. it( 'accepts attribute $root>paragraph[alignment]', () => {
  1002. expect( schema.checkAttribute( r1p1, 'alignment' ) ).to.be.true;
  1003. } );
  1004. it( 'accepts attribute $root>paragraph>$text[bold]', () => {
  1005. expect( schema.checkAttribute( r1p1.getChild( 0 ), 'bold' ) ).to.be.true;
  1006. } );
  1007. it( 'accepts attribute $root>heading1>$text[italic]', () => {
  1008. expect( schema.checkAttribute( r1h.getChild( 0 ), 'italic' ) ).to.be.true;
  1009. } );
  1010. it( 'accepts attribute $root>blockQuote>paragraph>$text[bold]', () => {
  1011. expect( schema.checkAttribute( r1bQp.getChild( 0 ), 'bold' ) ).to.be.true;
  1012. } );
  1013. it( 'accepts attribute $root>listItem[alignment]', () => {
  1014. expect( schema.checkAttribute( r1lI, 'alignment' ) ).to.be.true;
  1015. } );
  1016. it( 'accepts attribute $root>listItem[indent]', () => {
  1017. expect( schema.checkAttribute( r1lI, 'indent' ) ).to.be.true;
  1018. } );
  1019. it( 'accepts attribute $root>listItem[type]', () => {
  1020. expect( schema.checkAttribute( r1lI, 'type' ) ).to.be.true;
  1021. } );
  1022. it( 'accepts attribute $root>image[src]', () => {
  1023. expect( schema.checkAttribute( r1i, 'src' ) ).to.be.true;
  1024. } );
  1025. it( 'accepts attribute $root>image[alt]', () => {
  1026. expect( schema.checkAttribute( r1i, 'alt' ) ).to.be.true;
  1027. } );
  1028. it( 'accepts attribute $root>image>caption>$text[bold]', () => {
  1029. expect( schema.checkAttribute( r1i.getChild( 0 ).getChild( 0 ), 'bold' ) ).to.be.true;
  1030. } );
  1031. it( 'rejects attribute $root[indent]', () => {
  1032. expect( schema.checkAttribute( root1, 'indent' ) ).to.be.false;
  1033. } );
  1034. it( 'rejects attribute $root>paragraph[indent]', () => {
  1035. expect( schema.checkAttribute( r1p1, 'indent' ) ).to.be.false;
  1036. } );
  1037. it( 'accepts attribute $root>heading1>$text[bold]', () => {
  1038. expect( schema.checkAttribute( r1h.getChild( 0 ), 'bold' ) ).to.be.false;
  1039. } );
  1040. it( 'rejects attribute $root>paragraph>$text[alignment]', () => {
  1041. expect( schema.checkAttribute( r1p1.getChild( 0 ), 'alignment' ) ).to.be.false;
  1042. } );
  1043. it( 'rejects attribute $root>blockQuote[indent]', () => {
  1044. expect( schema.checkAttribute( r1bQ, 'indent' ) ).to.be.false;
  1045. } );
  1046. it( 'rejects attribute $root>blockQuote[alignment]', () => {
  1047. expect( schema.checkAttribute( r1bQ, 'alignment' ) ).to.be.false;
  1048. } );
  1049. it( 'rejects attribute $root>image[indent]', () => {
  1050. expect( schema.checkAttribute( r1i, 'indent' ) ).to.be.false;
  1051. } );
  1052. it( 'rejects attribute $root>image[alignment]', () => {
  1053. expect( schema.checkAttribute( r1i, 'alignment' ) ).to.be.false;
  1054. } );
  1055. } );
  1056. // TODO:
  1057. // * getValidRanges
  1058. // * checkAttributeInSelection
  1059. // * getLimitElement
  1060. // * removeDisallowedAttributes
  1061. // * test checkChild()'s both params normalization
  1062. // * and see insertContent's _checkIsObject()
  1063. // * add normalization to isObject(), isLimit(), isBlock(), isRegistered() and improve the existing code
  1064. // * inheritAllFrom should also inherit is* props (see tests documentselection getNearestSelectionRange())
  1065. // * test the default abstract entities (in model.js)
  1066. // * see clipboardHolder definition (and rename it to the pastebin)
  1067. } );