Skip to content
Permalink
Browse files
added modular toolbar system; added dom-magic as externaö dependency
  • Loading branch information
AndiDittrich committed Apr 16, 2020
1 parent 1417635 commit 6cef6c783f3d8f5f6a2485478e76e85b0a3061f5
Show file tree
Hide file tree
Showing 32 changed files with 6,530 additions and 967 deletions.
@@ -6,7 +6,10 @@

* Added: verilog support - thanks to [t123yh on GitHub](https://github.com/EnlighterJS/EnlighterJS/pull/86)
* Added: `collapse` option to limit the maximal height
* Added: integer highlighting for sql
* Changed: updated gulp + plugins
* Bugfix: powershell commands can also expressed lowercase (camel-case not required) - thanks to [krysiekBP on GitHub](https://github.com/EnlighterJS/EnlighterJS/issues/88)
* Bugfix: sql `--` styles comments ignored due to invalid regex - thanks to [petr-hybler on GitHub](https://github.com/EnlighterJS/EnlighterJS/issues/97)

### Version 3.1.0 ###

@@ -88,6 +88,7 @@ Features
* **Typescript** (typescript)
* **VHDL** (vhdl)
* **VisualBasic** (visualbasic, vb)
* **Verilog** (verilog)
* **XML** (xml)
* **YAML** (yaml)

@@ -3,6 +3,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// --
// Copyright 2016-2019 Andi Dittrich <https://andidittrich.de>
// Copyright 2016-2020 Andi Dittrich <https://andidittrich.de>
// ----------------------------------------------------------------------

Large diffs are not rendered by default.

Large diffs are not rendered by default.

@@ -60,7 +60,7 @@ _gulp.task('library', _gulp.series('es6-transpile', function(){
.pipe(_prettyError())

// minify
.pipe(_uglify())
//.pipe(_uglify())
.pipe(_concat('enlighterjs.min.js'))

// add license header
@@ -44,33 +44,33 @@
"xml"
],
"devDependencies": {
"@babel/core": "^7.7.7",
"@babel/plugin-external-helpers": "^7.7.4",
"@babel/plugin-transform-react-jsx": "^7.7.4",
"@babel/plugin-transform-runtime": "^7.7.6",
"@babel/preset-env": "^7.7.7",
"@babel/preset-react": "^7.7.4",
"@rollup/plugin-node-resolve": "^7.1.1",
"clean-css": "~4.2.1",
"@babel/core": "^7.9.0",
"@babel/plugin-external-helpers": "^7.8.3",
"@babel/plugin-transform-react-jsx": "^7.9.4",
"@babel/plugin-transform-runtime": "^7.9.0",
"@babel/preset-env": "^7.9.5",
"@babel/preset-react": "^7.9.4",
"@rollup/plugin-node-resolve": "^7.1.3",
"clean-css": "~4.2.3",
"eslint": "^6.8.0",
"eslint-config-aenondynamics": "^0.2.0",
"eslint-plugin-react": "^7.17.0",
"eslint-plugin-react": "^7.19.0",
"express": "^4.16.2",
"fancy-log": "^1.3.2",
"fs-magic": "^2.1.1",
"gulp": "^4.0.2",
"gulp-clean-css": "^4.2.0",
"gulp-clean-css": "^4.3.0",
"gulp-concat": "^2.6.1",
"gulp-header": "^2.0.9",
"gulp-less": "^4.0.1",
"gulp-prettyerror": "^2.0.0",
"gulp-replace": "^1.0.0",
"gulp-uglify": "^3.0.0",
"rollup": "^1.27.14",
"rollup-plugin-babel": "^4.3.3",
"uglify-js": "~3.7.2"
"rollup": "^2.6.1",
"rollup-plugin-babel": "^4.4.0",
"uglify-js": "~3.9.1"
},
"dependencies": {
"dom-magic": "^0.1.0"
"dom-magic": "^1.0.0"
}
}
@@ -7,7 +7,7 @@
// ----------------------------------------------------------------------

import * as _engine from '../engine/engine';
import * as _dom from '../lib/dom';
import * as _dom from 'dom-magic';
import {setOptions} from '../engine/options';
import {getRawCodeFromElement} from '../engine/sourcecode-extractor';
import * as _codegroupMapper from '../engine/codegroup-mapper';
@@ -6,7 +6,7 @@
// Copyright 2016-2018 Andi Dittrich <https://andidittrich.de>
// ----------------------------------------------------------------------

import * as _dom from '../lib/dom';
import * as _dom from 'dom-magic';

// separate codegorups and single instances
export function map(elements){
@@ -6,7 +6,7 @@
// Copyright 2016-2018 Andi Dittrich <https://andidittrich.de>
// ----------------------------------------------------------------------

import * as _dom from '../lib/dom';
import * as _dom from 'dom-magic';

// global list of highlighted elements
const _highlightedElements = [];
@@ -6,7 +6,7 @@
// Copyright 2016-2018 Andi Dittrich <https://andidittrich.de>
// ----------------------------------------------------------------------

import * as _dom from '../lib/dom';
import * as _dom from 'dom-magic';
import {_options} from './options';

// merge multiple options
@@ -118,7 +118,10 @@ export function parse(element, elementOptions){
rawcodeDbclick: getOption('rawcodeDbclick'),
textOverflow: getOption('textOverflow'),
collapse: getOption('collapse'),
cssClasses: cssClassList
cssClasses: cssClassList,
toolbarTop: getOption('toolbarTop'),
toolbarBottom: getOption('toolbarBottom'),
toolbarHeader: getOption('toolbarHeader')
}
}

@@ -40,6 +40,15 @@ export const _options = {
// @scope SETTINGS
cssClasses: '',

// top outer toolbar
toolbarOuter: '{BTN_TABS}',

// header toolbar
toolbarTop: '{BTN_RAW}{BTN_COPY}{BTN_WINDOW}{BTN_WEBSITE}',

// footer toolbar
toolbarBottom: '{BTN_COLLAPSE}',

// show linenumbers
// @scope SETTINGS,ATTRIBUTE
linenumbers: true,
@@ -7,7 +7,7 @@
// ----------------------------------------------------------------------

// Internal "ReactDOM"
import * as DOM from './dom';
import * as DOM from 'dom-magic';

// copy content to clipboard
export function copy(content){
@@ -248,6 +248,10 @@
top: 10px;
z-index: 10;
});
.STYLE_TOOLBAR_BOTTOM({
top: unset;
bottom: 0px;
});

/* Enlighter textOverflow === scroll
----------------------------------------------------------------------------------- */
@@ -306,11 +310,6 @@
// scrollbar on y axis
overflow-y: auto;
max-height: 500px;

// override in case the full sourcecode should be displayed
&.enlighter-collapse-full{
max-height: none;
}
}

// tabbed layout - use inner container a scroll wrapper!
@@ -321,13 +320,16 @@
// scrollbar on y axis
overflow-y: auto;
max-height: 500px;

// override in case the full sourcecode should be displayed
&.enlighter-collapse-full{
max-height: none;
}
}
}

// override in case the full sourcecode should be displayed
&.enlighter-collapse-full.@{VIEW_STANDARD}{
max-height: none;
}
&.enlighter-collapse-full.@{VIEW_CODEGROUP} .enlighter-codegroup-wrapper{
max-height: none;
}
}

/* Object Wrapper Property: show raw code
@@ -119,6 +119,16 @@
@rules();
}
}
.STYLE_TOOLBAR_TOP(@rules){
.enlighter-toolbar-top{
@rules();
}
}
.STYLE_TOOLBAR_BOTTOM(@rules){
.enlighter-toolbar-bottom{
@rules();
}
}

// toolbar button
.STYLE_TOOLBAR_BUTTON(@rules){
@@ -3,11 +3,11 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// --
// Copyright 2016-2018 Andi Dittrich <https://andidittrich.de>
// Copyright 2016-2020 Andi Dittrich <https://andidittrich.de>
// ----------------------------------------------------------------------

// Internal "ReactDOM"
import * as React from '../../lib/dom';
import * as React from 'dom-magic';

export function Button(props){

@@ -23,6 +23,7 @@ export function Button(props){
return <div
className={classes.join(' ')}
onClick={props.onClick}
title={props.tooltip}
>
{props.text||null}
</div>
@@ -0,0 +1,21 @@
// ----------------------------------------------------------------------
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// --
// Copyright 2016-2020 Andi Dittrich <https://andidittrich.de>
// ----------------------------------------------------------------------

// Internal "ReactDOM"
import * as React from 'dom-magic';

import {Button} from './button.jsx';

export function collapse(props){
// trigger raw code toggle
function toggleCollapse(){
props.toggleClass('enlighter-collapse-full');
}

return <Button name="collapse" tooltip="Expand" onClick={toggleCollapse}></Button>
}
@@ -0,0 +1,23 @@
// ----------------------------------------------------------------------
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// --
// Copyright 2016-2020 Andi Dittrich <https://andidittrich.de>
// ----------------------------------------------------------------------

// Internal "ReactDOM"
import * as React from 'dom-magic';

import * as _clipboard from '../../../lib/clipboard';
import {Button} from './button.jsx';

export function copy(props){
// trigger clipboard copy
function copyToClipboard(){
// try to copy to clipboard
_clipboard.copy(props.getRawCode());
}

return <Button name="copy" tooltip="Copy to clipboard" onClick={copyToClipboard}></Button>
}
@@ -0,0 +1,14 @@
// ----------------------------------------------------------------------
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// --
// Copyright 2016-2020 Andi Dittrich <https://andidittrich.de>
// ----------------------------------------------------------------------

export {raw} from './raw.jsx';
export {copy} from './copy.jsx';
export {window} from './window.jsx';
export {website} from './website.jsx';
export {collapse} from './collapse.jsx';
//export {tabs} from './tabs.jsx';
@@ -0,0 +1,21 @@
// ----------------------------------------------------------------------
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// --
// Copyright 2016-2020 Andi Dittrich <https://andidittrich.de>
// ----------------------------------------------------------------------

// Internal "ReactDOM"
import * as React from 'dom-magic';

import {Button} from './button.jsx';

export function raw(props){
// trigger raw code toggle
function toggleRawCode(){
props.toggleClass('enlighter-show-rawcode');
}

return <Button name="raw" tooltip="Toggle RAW code" onClick={toggleRawCode}></Button>
}
@@ -0,0 +1,21 @@
// ----------------------------------------------------------------------
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// --
// Copyright 2016-2020 Andi Dittrich <https://andidittrich.de>
// ----------------------------------------------------------------------

// Internal "ReactDOM"
import * as React from 'dom-magic';

import {Button} from './button.jsx';

// open enlighterjs website
function openEnlighterLink(){
React.getWindow().open('https://enlighterjs.org');
}

export function website(){
return <Button name="website" tooltip="EnlighterJS 3 Syntax Highlighter" onClick={openEnlighterLink}></Button>
}
@@ -0,0 +1,33 @@
// ----------------------------------------------------------------------
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// --
// Copyright 2016-2020 Andi Dittrich <https://andidittrich.de>
// ----------------------------------------------------------------------

// Internal "ReactDOM"
import * as React from 'dom-magic';

import {Button} from './button.jsx';

export function window(props){
// optimization
const _window = React.getWindow();

// open raw code in new window
function openCodeWindow(){

// open new window
const w = _window.open('', '', 'width=' + (_window.screen.width/2) + ', height=' + (_window.screen.height/2) + ', menubar=no, titlebar=no, toolbar=no, top=100, left=100, scrollbars=yes, status=no');

// escape code
const code = props.getRawCode().replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');

// insert code
w.document.body.innerHTML = '<pre>' + code + '</pre>';
w.document.title = 'Sourcecode | EnlighterJS Syntax Highlighter';
}

return <Button name="window" tooltip="Open code in new window" onClick={openCodeWindow}></Button>
}
@@ -7,10 +7,10 @@
// ----------------------------------------------------------------------

// Internal "ReactDOM"
import * as React from '../../lib/dom';
import * as React from 'dom-magic';

import {Container} from './container.jsx';
import {Button} from './button.jsx';
import {Button} from './buttons/button.jsx';

export function CodegroupSwitch(props){

0 comments on commit 6cef6c7

Please sign in to comment.