diff --git a/h5p-code-highlighter.js b/h5p-code-highlighter.js index 3516f71..4e90b7e 100644 --- a/h5p-code-highlighter.js +++ b/h5p-code-highlighter.js @@ -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); @@ -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 diff --git a/language/en.json b/language/en.json index 7cae516..3ea025e 100644 --- a/language/en.json +++ b/language/en.json @@ -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." + } + ] } ] } \ No newline at end of file diff --git a/library.json b/library.json index 2913eee..84cb3c0 100644 --- a/library.json +++ b/library.json @@ -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" diff --git a/semantics.json b/semantics.json index 9aaa3ae..66cfb0e 100644 --- a/semantics.json +++ b/semantics.json @@ -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", @@ -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 + } + ] } ] \ No newline at end of file