Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List configurable options #591

Closed
wants to merge 33 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e9d82d7
Default options for my own needs
4project-co-il Nov 24, 2017
38a81b2
Workaround to accept font sizes in percentage values,
4project-co-il Nov 24, 2017
6fed9a1
Remove a space addition to innerHTML in _createMarker function,
4project-co-il Nov 24, 2017
984789f
Move youtube parameters to configurable options, so everybody could
4project-co-il Nov 24, 2017
fa5f6be
Revert "Remove a space addition to innerHTML in _createMarker function,"
4project-co-il Nov 24, 2017
ab0292f
Revert "Default options for my own needs"
4project-co-il Nov 24, 2017
607ccbe
Revert "Workaround to accept font sizes in percentage values,"
4project-co-il Nov 24, 2017
99479f8
Pass global options to the parser
4project-co-il Nov 24, 2017
64c7ad5
YouTube template
4project-co-il Nov 24, 2017
f40ce3d
Editor options to formatter.
4project-co-il Nov 25, 2017
8924a10
Passing templates to formatter.
4project-co-il Nov 25, 2017
e5288c8
YouTube start time processing
4project-co-il Nov 25, 2017
6930725
Merge branch 'master' of https://github.com/samclarke/SCEditor
4project-co-il Nov 25, 2017
d2e4f36
Updating xhtml formatter
4project-co-il Nov 26, 2017
bb6e2b6
Drop downs for bullets and numbered lists.
4project-co-il Nov 26, 2017
4378d5d
bbcode UL parsing
4project-co-il Nov 27, 2017
9c6140d
xhtml UL changes
4project-co-il Nov 27, 2017
9c126f2
Adding UL type "none"
4project-co-il Nov 27, 2017
87813e6
bbcode OL parsing
4project-co-il Nov 27, 2017
02e4911
xhtml OL changes
4project-co-il Nov 27, 2017
36e6ec2
OL type changed to style="list-style-type:xxx"
4project-co-il Nov 27, 2017
9b79661
OL type changed to style="list-style-type:xxx"
4project-co-il Nov 27, 2017
13c5bfb
Merge branch 'list-enhancements' of https://github.com/abetis/SCEdito…
4project-co-il Nov 27, 2017
7e2754e
Typo fix
4project-co-il Nov 27, 2017
e2588c3
Fix UL dropdown styling, it didn't show well in RTL mode.
4project-co-il Nov 27, 2017
692a4c7
Merge branch 'youtube-tag-enhancements'
4project-co-il Nov 29, 2017
23675c1
Merge branch 'video-size-options'
4project-co-il Nov 29, 2017
41c8bd9
Merge fixes
4project-co-il Nov 29, 2017
8d77509
Merge branch 'list-enhancements'
4project-co-il Nov 29, 2017
605cdbd
Configurable UL options.
4project-co-il Nov 30, 2017
749b405
Configurable OL options.
4project-co-il Nov 30, 2017
30e16fa
Configurable OL options.
4project-co-il Nov 30, 2017
29e6181
Merge branch 'list-configurable-options' of https://github.com/abetis…
4project-co-il Nov 30, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
bbcode UL parsing
4project-co-il committed Nov 27, 2017
commit 4378d5d7bf92d87623eed1a841f7b9d17a3b2c44
48 changes: 39 additions & 9 deletions src/formats/bbcode.js
Original file line number Diff line number Diff line change
@@ -137,14 +137,23 @@
},
bulletlist: {
txtExec: function (caller, selected) {
var editor = this;
var content = '';

each(selected.split(/\r?\n/), function () {
content += (content ? '\n' : '') +
'[li]' + this + '[/li]';
});
getEditorCommand('bulletlist')._dropDown(
editor,
caller,
function (listType) {
selected.split(/\r?\n/).forEach(function (item) {
content += (content ? '\n' : '') +
'[li]' + item + '[/li]';
});

this.insertText('[ul]\n' + content + '\n[/ul]');
editor.insertText(
'[ul=' + listType + ']\n' + content + '\n[/ul]'
);
}
);
}
},
orderedlist: {
@@ -436,14 +445,35 @@

// START_COMMAND: Lists
ul: {
tags: {
ul: null
styles: {
'list-style-type': null
},
breakStart: true,
isInline: false,
skipLastLineBreak: true,
format: '[ul]{0}[/ul]',
html: '<ul>{0}</ul>'
format: function (element, content) {
var listType = element.style['list-style-type'];
var validTypes = ['disc', 'circle', 'square'];

if (listType && listType !== 'disc' &&
validTypes.indexOf(listType) > -1) {
return '[ul=' + listType + ']' + content + '[/ul]';
} else {
return '[ul]' + content + '[/ul]';
}
},
html: function (token, attrs, content) {
var listType = 'disc';
var validTypes = ['disc', 'circle', 'square'];
var attr = attrs.defaultattr;

if (attr && validTypes.indexOf(attr) > -1) {
listType = attr;
}

return '<ul style="list-style-type:' + listType + '">' +
content + '</ul>';
}
},
list: {
breakStart: true,
28 changes: 20 additions & 8 deletions tests/unit/formats/bbcode.js
Original file line number Diff line number Diff line change
@@ -253,7 +253,7 @@ QUnit.test('New line handling', function (assert) {
this.htmlToBBCode(
'<div>text</div>' +
'<div>' + IE_BR_STR + '</div>' +
'<ul><li>text</li></ul>'
'<ul style="list-style-type:disc"><li>text</li></ul>'
),
'text\n\n[ul]\n[li]text[/li]\n[/ul]\n',
'Div siblings with a list'
@@ -264,7 +264,7 @@ QUnit.test('New line handling', function (assert) {
'<div>text</div>' +
'<div>' + IE_BR_STR + '</div>' +
'<div>' + IE_BR_STR + '</div>' +
'<ul><li>text</li></ul>'
'<ul style="list-style-type:disc"><li>text</li></ul>'
),
'text\n\n\n[ul]\n[li]text[/li]\n[/ul]\n',
'Multiple div siblings with a list'
@@ -284,7 +284,7 @@ QUnit.test('New line handling', function (assert) {

assert.equal(
this.htmlToBBCode(
'<ul><li>newline<br />' + IE_BR_STR + '</li></ul>'
'<ul style="list-style-type:disc"><li>newline<br />' + IE_BR_STR + '</li></ul>'
),
'[ul]\n[li]newline\n[/li]\n[/ul]\n',
'List item last child block level'
@@ -571,9 +571,21 @@ QUnit.test('colour', function (assert) {

QUnit.test('List', function (assert) {
assert.equal(
this.htmlToBBCode('<ul><li>test' + IE_BR_STR + '</li></ul>'),
this.htmlToBBCode('<ul style="list-style-type:disc"><li>test' + IE_BR_STR + '</li></ul>'),
'[ul]\n[li]test[/li]\n[/ul]\n',
'UL tag'
'UL tag, disc type'
);

assert.equal(
this.htmlToBBCode('<ul style="list-style-type:circle"><li>test' + IE_BR_STR + '</li></ul>'),
'[ul=circle]\n[li]test[/li]\n[/ul]\n',
'UL tag, circle type'
);

assert.equal(
this.htmlToBBCode('<ul style="list-style-type:square"><li>test' + IE_BR_STR + '</li></ul>'),
'[ul=square]\n[li]test[/li]\n[/ul]\n',
'UL tag, square type'
);

assert.equal(
@@ -584,15 +596,15 @@ QUnit.test('List', function (assert) {

assert.equal(
this.htmlToBBCode(
'<ul>' +
'<ul style="list-style-type:disc">' +
'<li>test' +
'<ul>' +
'<ul style="list-style-type:circle">' +
'<li>sub' + IE_BR_STR + '</li>' +
'</ul>' +
'</li>' +
'</ul>'
),
'[ul]\n[li]test\n[ul]\n[li]sub[/li]\n[/ul]\n[/li]\n[/ul]\n',
'[ul]\n[li]test\n[ul=circle]\n[li]sub[/li]\n[/ul]\n[/li]\n[/ul]\n',
'Nested UL tag'
);
});
34 changes: 30 additions & 4 deletions tests/unit/formats/bbcode.parser.js
Original file line number Diff line number Diff line change
@@ -729,8 +729,32 @@ QUnit.test('Font colour', function (assert) {
QUnit.test('List', function (assert) {
assert.htmlEqual(
this.parser.toHTML('[ul][li]test[/li][/ul]'),
'<ul><li>test' + IE_BR_STR + '</li></ul>',
'UL'
'<ul style="list-style-type:disc"><li>test' + IE_BR_STR + '</li></ul>',
'UL, no type'
);

assert.htmlEqual(
this.parser.toHTML('[ul=disc][li]test[/li][/ul]'),
'<ul style="list-style-type:disc"><li>test' + IE_BR_STR + '</li></ul>',
'UL, disc type'
);

assert.htmlEqual(
this.parser.toHTML('[ul=circle][li]test[/li][/ul]'),
'<ul style="list-style-type:circle"><li>test' + IE_BR_STR + '</li></ul>',
'UL, circle type'
);

assert.htmlEqual(
this.parser.toHTML('[ul=square][li]test[/li][/ul]'),
'<ul style="list-style-type:square"><li>test' + IE_BR_STR + '</li></ul>',
'UL, square type'
);

assert.htmlEqual(
this.parser.toHTML('[ul=zzz][li]test[/li][/ul]'),
'<ul style="list-style-type:disc"><li>test' + IE_BR_STR + '</li></ul>',
'UL, unknown type'
);

assert.htmlEqual(
@@ -740,8 +764,10 @@ QUnit.test('List', function (assert) {
);

assert.htmlEqual(
this.parser.toHTML('[ul][li]test[ul][li]sub[/li][/ul][/li][/ul]'),
'<ul><li>test<ul><li>sub' + IE_BR_STR + '</li></ul></li></ul>',
this.parser.toHTML('[ul][li]test[ul=circle][li]sub[/li][/ul][/li][/ul]'),
'<ul style="list-style-type:disc"><li>test' +
'<ul style="list-style-type:circle"><li>sub' + IE_BR_STR +
'</li></ul></li></ul>',
'Nested UL'
);
});