Skip to content

Commit

Permalink
Move some options in advanced settings
Browse files Browse the repository at this point in the history
  • Loading branch information
DegrangeM committed Apr 15, 2021
1 parent 4d2116d commit 956df58
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 70 deletions.
22 changes: 12 additions & 10 deletions h5p-code-highlighter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ H5P.CodeHighlighter = (function ($) {
'code': '',
'lineNumbers': true,
'readOnly': true,
'lineWrapping': true,
'foldGutter': true,
'matchTags': false,
'tabSize': 2,
'firstLineNumber': 1,
'advancedOptions': {
'lineWrapping': true,
'foldGutter': true,
'matchTags': false,
'tabSize': 2,
'firstLineNumber': 1
},
'maxHeight': 0,
'highlightLines': ''
}, options);
Expand All @@ -36,19 +38,19 @@ H5P.CodeHighlighter = (function ($) {
$container.addClass('h5p-code-highlighter');

this.editor = CodeMirror($container[0], {
value: CodeMirror.H5P.decode(this.options.code || '' ),
value: CodeMirror.H5P.decode(this.options.code || ''),
keyMap: 'sublime',
tabSize: this.options.tabSize,
indentWithTabs: true,
lineNumbers: this.options.lineNumbers,
firstLineNumber: this.options.firstLineNumber,
firstLineNumber: this.options.advancedOptions.firstLineNumber,
readOnly: this.options.readOnly,
lineWrapping: this.options.lineWrapping,
lineWrapping: this.options.advancedOptions.lineWrapping,
matchBrackets: true,
matchTags: this.options.matchTags ? {
matchTags: this.options.advancedOptions.matchTags ? {
bothTags: true
} : false,
foldGutter: this.options.foldGutter,
foldGutter: this.options.advancedOptions.foldGutter,
gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter'],
styleActiveLine: {
nonEmpty: true
Expand Down
48 changes: 27 additions & 21 deletions language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -489,33 +489,39 @@
"label": "Read only",
"description": "If checked, it will not be possible to edit the code. The code will still be selectable. This does not affect this authoring view."
},
{
"label": "Automatic Line Wrapping",
"description": "If a line is too long, display it on multiple line instead of showing an horizontal scrollbar. This does not affect this authoring view."
},
{
"label": "Allow to fold block",
"description": "Display an icon at the left allowing to fold some portion of the code. This does not affect this authoring view."
},
{
"label": "Match Tags",
"description": "Enable this to highlight the tag your cursor is over and it's matching tag in language like html."
},
{
"label": "Tab Size",
"description": "Size of tabs on the display page. This does not affect this authoring view."
},
{
"label": "First line number",
"description": "Change this if you want your line numbering to start from an other number than 1."
},
{
"label": "Max height",
"description": "Max height (in pixels) of the editor. Set it to 0 if you don't want to put a max height."
},
{
"label": "Highlight Lines",
"description": "Use this option to highlight some lines of the code. Use syntax 1,3,5-7 to highlight lines 1, 3, and 5 to 7."
"description": "Use this option to highlight some lines of the code. Use syntax 1,3,5-7 to highlight lines 1, 3, and 5 to 7.",
"default": ""
},
{
"label": "Avanced Options",
"fields": [
{
"label": "Automatic Line Wrapping",
"description": "If a line is too long, display it on multiple line instead of showing an horizontal scrollbar. This does not affect this authoring view."
},
{
"label": "Allow to fold block",
"description": "Display an icon at the left allowing to fold some portion of the code. This does not affect this authoring view."
},
{
"label": "Match Tags",
"description": "Enable this to highlight the tag your cursor is over and it's matching tag in language like html."
},
{
"label": "Tab Size",
"description": "Size of tabs on the display page. This does not affect this authoring view."
},
{
"label": "First line number",
"description": "Change this if you want your line numbering to start from an other number than 1."
}
]
}
]
}
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Display code from various language (html, javascript, python, etc.) with syntax highlighting",
"majorVersion": 1,
"minorVersion": 0,
"patchVersion": 0,
"patchVersion": 1,
"runnable": 1,
"embedTypes": [
"iframe"
Expand Down
84 changes: 46 additions & 38 deletions semantics.json
Original file line number Diff line number Diff line change
Expand Up @@ -658,44 +658,6 @@
"label": "Read only",
"description": "If checked, it will not be possible to edit the code. The code will still be selectable. This does not affect this authoring view."
},
{
"name": "lineWrapping",
"type": "boolean",
"default": true,
"label": "Automatic Line Wrapping",
"description": "If a line is too long, display it on multiple line instead of showing an horizontal scrollbar. This does not affect this authoring view."
},
{
"name": "foldGutter",
"type": "boolean",
"default": true,
"label": "Allow to fold block",
"description": "Display an icon at the left allowing to fold some portion of the code. This does not affect this authoring view."
},
{
"name": "matchTags",
"type": "boolean",
"default": false,
"label": "Match Tags",
"description": "Enable this to highlight the tag your cursor is over and it's matching tag in language like html."
},
{
"name": "tabSize",
"type": "number",
"label": "Tab Size",
"description": "Size of tabs on the display page. This does not affect this authoring view.",
"min": 1,
"max": 8,
"step": 1,
"default": 2
},
{
"name": "firstLineNumber",
"type": "number",
"label": "First line number",
"description": "Change this if you want your line numbering to start from an other number than 1.",
"default": 1
},
{
"name": "maxHeight",
"type": "number",
Expand All @@ -711,5 +673,51 @@
"description": "Use this option to highlight some lines of the code. Use syntax 1,3,5-7 to highlight lines 1, 3, and 5 to 7.",
"default": "",
"optionnal": true
},
{
"name": "advancedOptions",
"type": "group",
"label": "Avanced Options",
"importance": "low",
"fields": [
{
"name": "lineWrapping",
"type": "boolean",
"default": true,
"label": "Automatic Line Wrapping",
"description": "If a line is too long, display it on multiple line instead of showing an horizontal scrollbar. This does not affect this authoring view."
},
{
"name": "foldGutter",
"type": "boolean",
"default": true,
"label": "Allow to fold block",
"description": "Display an icon at the left allowing to fold some portion of the code. This does not affect this authoring view."
},
{
"name": "matchTags",
"type": "boolean",
"default": false,
"label": "Match Tags",
"description": "Enable this to highlight the tag your cursor is over and it's matching tag in language like html."
},
{
"name": "tabSize",
"type": "number",
"label": "Tab Size",
"description": "Size of tabs on the display page. This does not affect this authoring view.",
"min": 1,
"max": 8,
"step": 1,
"default": 2
},
{
"name": "firstLineNumber",
"type": "number",
"label": "First line number",
"description": "Change this if you want your line numbering to start from an other number than 1.",
"default": 1
}
]
}
]

0 comments on commit 956df58

Please sign in to comment.