Skip to content

Commit

Permalink
wip: add background of fenced code block
Browse files Browse the repository at this point in the history
  • Loading branch information
seonim-ryu committed Apr 20, 2020
1 parent 1bc97a8 commit 518742c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions apps/editor/src/css/md-syntax-highlighting.css
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@
background-color: #f9f2f4;
}

.tui-md-code-block.CodeMirror-linebackground {
left: 20px;
right: 20px;
background-color: #f5f7f8;
}

.tui-md-code.tui-md-marked-text,
.tui-md-code-block.tui-md-marked-text {
font-family: Consolas, Courier, 'Apple SD 산돌고딕 Neo', -apple-system, 'Lucida Grande',
Expand Down
7 changes: 7 additions & 0 deletions apps/editor/src/js/markdownEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,12 @@ class MarkdownEditor extends CodeMirrorExt {
this._markText(closeDelimStart, end, 'tui-md-delimiter');
}

_markCodeBlockLine(startLine, endLine) {
for (let index = startLine; index <= endLine; index += 1) {
this.cm.addLineClass(index, 'background', 'tui-md-code-block');
}
}

_markCodeBlock(node, start, end) {
const { fenceOffset, fenceLength, fenceChar, info } = node;
const { line: startLine, ch: startCh } = start;
Expand Down Expand Up @@ -404,6 +410,7 @@ class MarkdownEditor extends CodeMirrorExt {
}

this._markText(openDelimEnd, closeDelimStart, 'tui-md-marked-text');
this._markCodeBlockLine(startLine, endLine);
}

_markTextInListItemChildren(node, className) {
Expand Down

0 comments on commit 518742c

Please sign in to comment.