-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0fcdfe4
commit 3c46874
Showing
6 changed files
with
58 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 31 additions & 24 deletions
55
projects/swimlane/ngx-ui/src/lib/components/code-editor/mustache.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,34 @@ | ||
import * as CodeMirror from 'codemirror'; | ||
export default null; | ||
|
||
// Adds mustache as an overlay to text/html | ||
CodeMirror.defineMode( | ||
'mustache', | ||
/* istanbul ignore next */ function (config: any, parserConfig: any) { | ||
const mustacheOverlay = { | ||
token(stream: any, _: any) { | ||
let ch: any; | ||
if (stream.match('{{')) { | ||
// eslint-disable-next-line no-cond-assign | ||
while ((ch = stream.next()) != null) | ||
if (ch === '}' && stream.next() === '}') { | ||
stream.eat('}'); | ||
return 'mustache'; | ||
} | ||
} | ||
while (stream.next() != null && !stream.match('{{', false)) { | ||
continue; | ||
} | ||
|
||
return null; | ||
} | ||
}; | ||
return CodeMirror.overlayMode(CodeMirror.getMode(config, parserConfig.backdrop || 'text/html'), mustacheOverlay); | ||
// @ts-ignore | ||
(function (mod) { | ||
if (typeof window !== 'undefined') { | ||
import('codemirror').then(e => mod(e.default ?? e)); | ||
} | ||
); | ||
})(function (CodeMirror) { | ||
CodeMirror.defineMode( | ||
'mustache', | ||
/* istanbul ignore next */ function (config: any, parserConfig: any) { | ||
const mustacheOverlay = { | ||
token(stream: any, _: any) { | ||
let ch: any; | ||
if (stream.match('{{')) { | ||
// eslint-disable-next-line no-cond-assign | ||
while ((ch = stream.next()) != null) | ||
if (ch === '}' && stream.next() === '}') { | ||
stream.eat('}'); | ||
return 'mustache'; | ||
} | ||
} | ||
while (stream.next() != null && !stream.match('{{', false)) { | ||
continue; | ||
} | ||
|
||
return null; | ||
} | ||
}; | ||
return CodeMirror.overlayMode(CodeMirror.getMode(config, parserConfig.backdrop || 'text/html'), mustacheOverlay); | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters