Skip to content

Commit 1c00734

Browse files
committed
Make ul/ol valid types, refs the-grid/ed#300
1 parent c9da4c6 commit 1c00734

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/schema.coffee

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ validTypes = [
88
'h6'
99
'text'
1010
'list'
11+
'ul'
12+
'ol'
1113
'table'
1214
'code'
1315
'image'
@@ -51,7 +53,10 @@ isSubtypeOf = (type, checkType) ->
5153
if checkType is 'headline'
5254
return type in ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']
5355
if checkType is 'data'
54-
return type in ['list', 'table']
56+
return true if type is 'table'
57+
return isSubtypeOf type, 'list'
58+
if checkType is 'list'
59+
return type in ['ul', 'ol']
5560
false
5661

5762
normalizeMetadata = (block, item) ->

spec/types.coffee

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ describe 'Type handling', ->
3838
it 'should recognize any data element as data', ->
3939
chai.expect(schema.isSubtypeOf('list', 'data')).to.equal true
4040
chai.expect(schema.isSubtypeOf('table', 'data')).to.equal true
41+
chai.expect(schema.isSubtypeOf('ol', 'data')).to.equal true
42+
chai.expect(schema.isSubtypeOf('ul', 'data')).to.equal true
4143
it 'should recognize CtA elements as cta', ->
4244
chai.expect(schema.isSubtypeOf('cta', 'cta')).to.equal true
4345
it 'should recognize hr elements as hr', ->
@@ -52,6 +54,8 @@ describe 'Type handling', ->
5254
chai.expect(schema.isValidType('grammarly-btn')).to.equal false
5355
it 'should work on accepted type', ->
5456
chai.expect(schema.isValidType('h1')).to.equal true
57+
it 'should work on accepted type in solving mode', ->
58+
chai.expect(schema.isValidType('h1', true)).to.equal true
5559
it 'should work on placeholder type', ->
5660
chai.expect(schema.isValidType('placeholder')).to.equal true
5761
it 'should fail on placeholder type in solving mode', ->

0 commit comments

Comments
 (0)