Skip to content

Commit 3395a70

Browse files
committed
Updated the Table style to remove local conflicts
The previous CSS was using generic "table > ..." which could conflict with regular tables which might be unwanted. You now have to use the wrapper class of "markdown" or "marked" for your preview <div>
1 parent d6baf0a commit 3395a70

File tree

4 files changed

+71
-25
lines changed

4 files changed

+71
-25
lines changed

example/index.html

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
<head>
44
<meta charset="utf-8">
55
<title>Angular-Mardown-Editor (ghiscoding)</title>
6+
<!-- CSS Stylesheet -->
7+
<link rel="stylesheet" href="../styles/angular-markdown-editor.css">
68
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
79
<link rel="stylesheet" href="../node_modules/font-awesome/css/font-awesome.min.css">
810
<link rel="stylesheet" href="../node_modules/bootstrap-markdown/css/bootstrap-markdown.min.css">
911
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/styles/tomorrow.min.css">
10-
<link rel="stylesheet" href="../styles/angular-markdown-editor.css">
1112

12-
<!-- external librairies CDN -->
13+
<!-- Scripts -->
1314
<script type="text/javascript" src="../node_modules/jquery/dist/jquery.min.js"></script>
1415
<script type="text/javascript" src="../node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
1516
<script type="text/javascript" src="../node_modules/angular/angular.min.js"></script>
@@ -33,7 +34,7 @@ <h1>Angular Markdown Editor</h1>
3334

3435
<hr/>
3536

36-
<marked>
37+
<marked class="markdown">
3738
## Angular Markdown Editor Directive
3839
*It works!*
3940
#### Markdown [cheatsheet](//github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet)
@@ -51,15 +52,15 @@ <h1>Angular Markdown Editor</h1>
5152
<div class="col-md-12 col-lg-6 fill">
5253
<div class="form-group">
5354
<label for="comment">Preview Result:</label>
54-
<div marked="markdown" class="outline" style="padding: 20px">
55+
<div marked="markdown" class="markdown outline" style="padding: 20px">
5556
</div>
5657
</div>
5758
</div>
5859
</div>
5960

6061
<hr/>
6162

62-
<div class="outline" style="padding:20px; margin-bottom: 20px" marked src="'readme.md'">
63+
<div class="markdown outline" style="padding:20px; margin-bottom: 20px" marked src="'readme.md'">
6364
</div>
6465

6566
</div>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-markdown-editor",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"author": "Ghislain B.",
55
"description": "Angular Markdown Editor, all-in-one Markdown Editor and Preview",
66
"main": "app.js",

readme.md

+30-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Angular Markdown Editor (Directive)
2-
`1.0.1`
2+
`1.0.2`
33

44
## What do we have?
55
I have put together a few libraries and tools to make a convenient "all in one" WYSIWYG Markdown Editor and preview. All of that with a simple AngularJS Directive call. I plan to use this mainly for online documentation but it could be useful for many other reasons. Also planning to add a 1-click button for simple Copy+Paste to email.
@@ -21,11 +21,39 @@ _Some of the dependencies were added by hand to this package (because they don't
2121
PM> Install-Package Angular-Markdown-Editor
2222
```
2323

24+
### Include Styles &amp; Scripts
25+
_NOTE: Unfortunately, the "highlight.js" npm module doesn't seem to have proper bundles, so it's easier for us get the minified CSS and JS files directly from CDN where they are bundled correctly. As for the highlight style, if you want to use another style, then you can replace the "...xxx.min.css" by the name you want to use, for example if we want to use "github", that would be "highlight.js/.../github.min.css"_
26+
```html
27+
<!-- CSS Stylesheet -->
28+
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
29+
<link rel="stylesheet" href="../node_modules/font-awesome/css/font-awesome.min.css">
30+
<link rel="stylesheet" href="../node_modules/bootstrap-markdown/css/bootstrap-markdown.min.css">
31+
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/styles/github.min.css">
32+
<link rel="stylesheet" href="../node_modules/angular-markdown-editor/styles/angular-markdown-editor.css">
33+
34+
<!-- Scripts -->
35+
<script type="text/javascript" src="../node_modules/jquery/dist/jquery.min.js"></script>
36+
<script type="text/javascript" src="../node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
37+
<script type="text/javascript" src="../node_modules/angular/angular.min.js"></script>
38+
<script type="text/javascript" src="../node_modules/angular-sanitize/angular-sanitize.min.js"></script>
39+
<script type="text/javascript" src="../node_modules/marked/lib/marked.js"></script>
40+
<script type="text/javascript" src="../node_modules/angular-marked/dist/angular-marked.min.js"></script>
41+
<script type="text/javascript" src="../node_modules/bootstrap-markdown/js/bootstrap-markdown.js"></script>
42+
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/highlight.min.js"></script>
43+
<script type="text/javascript" src="../node_modules/angular-highlightjs/src/angular-highlightjs.js"></script>
44+
<script type="text/javascript" src="../node_modules/angular-markdown-editor/src/angular-markdown-editor.js"></script>
45+
```
46+
2447
### Inside the HTML
2548
Simply create a `<textarea>` with an `ngModel` and a call to the Directive.
2649
At the end, all you need is:
2750
```
51+
<!-- editor -->
2852
<textarea ng-model="markdown" markdown-editor="" rows="10"></textarea>
53+
54+
<-- preview... be sure to include the "angular-markdown-editor.css" style -->
55+
<!-- use "markdown" or "marked" on your <div> preview to show Tables correctly -->
56+
<div marked="markdown" class="markdown" style="padding: 20px"></div>
2957
```
3058

3159
### Editor extra options
@@ -37,7 +65,7 @@ or multiple options
3765
```
3866

3967
### Editor extra buttons
40-
I really thought that some buttons were missing to go a great job (~~Strikethrough~~ &amp; **Table**). So I added them within the directive as an option. They are not enabled by default, so you will need to enable them manually if you do want to use them with the option of `addExtraButtons`.
68+
I really thought that some buttons were missing to go a great job (~~Strikethrough~~ &amp; **Table**). So I added them within the directive as an option. They are not enabled by default, so you will need to enable them manually, that is if you do want to use them. The option argument is `addExtraButtons` to `true`.
4169
```
4270
<textarea markdown-editor="{addExtraButtons: true, 'iconlibrary': 'fa'}"...
4371
```

styles/angular-markdown-editor.css

+34-17
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,27 @@ textarea {
1414
}
1515

1616
/* http://johnsardine.com/freebies/dl-html-css/simple-little-tab/ */
17-
table a:link {
17+
.marked > table a:link,
18+
.markdown > table a:link {
1819
color: #666;
1920
font-weight: bold;
2021
text-decoration:none;
2122
}
22-
table a:visited {
23+
.marked > table a:visited,
24+
.markdown > table a:visited {
2325
color: #999999;
2426
font-weight:bold;
2527
text-decoration:none;
2628
}
27-
table a:active,
28-
table a:hover {
29+
.marked > table a:active,
30+
.marked > table a:hover,
31+
.markdown > table a:active,
32+
.markdown > table a:hover {
2933
color: #bd5a35;
3034
text-decoration:underline;
3135
}
32-
table {
36+
.marked > table,
37+
.markdown > table {
3338
font-family:Arial, Helvetica, sans-serif;
3439
color:#606060;
3540
font-size:15px;
@@ -41,36 +46,43 @@ table {
4146
-webkit-border-radius:3px;
4247
border-radius:3px;
4348
}
44-
table th {
49+
.marked > table th,
50+
.markdown > table th {
4551
padding:8px 15px;
4652
border-bottom:1px solid #e0e0e0;
4753
background: #f6f6f6;
4854
color:#333;
4955
}
50-
table th:first-child {
56+
.marked > table th:first-child,
57+
.markdown > table th:first-child {
5158
text-align: left;
5259
padding-left:10px;
5360
}
54-
table tr:first-child th:first-child {
61+
.marked > table tr:first-child th:first-child,
62+
.markdown > table tr:first-child th:first-child {
5563
-moz-border-radius-topleft:3px;
5664
-webkit-border-top-left-radius:3px;
5765
border-top-left-radius:3px;
5866
}
59-
table tr:first-child th:last-child {
67+
.marked > table tr:first-child th:last-child,
68+
.markdown > table tr:first-child th:last-child {
6069
-moz-border-radius-topright:3px;
6170
-webkit-border-top-right-radius:3px;
6271
border-top-right-radius:3px;
6372
}
64-
table tr {
73+
.marked > table tr,
74+
.markdown > table tr {
6575
text-align: center;
6676
padding-left:10px;
6777
}
68-
table td:first-child {
78+
.marked > table td:first-child,
79+
.markdown > table td:first-child {
6980
text-align: left;
7081
padding-left:10px;
7182
border-left: 0;
7283
}
73-
table td {
84+
.marked > table td,
85+
.markdown > table td {
7486
padding:8px;
7587
border-top: 1px solid #ffffff;
7688
border-bottom:1px solid #e0e0e0;
@@ -79,23 +91,28 @@ table td {
7991
background: #fff;
8092
}
8193

82-
table tr:nth-child(2n) td {
94+
.marked > table tr:nth-child(2n) td,
95+
.markdown > table tr:nth-child(2n) td {
8396
background: #f8f8f8;
8497
}
85-
table tr:last-child td {
98+
.marked > table tr:last-child td,
99+
.markdown > table tr:last-child td {
86100
border-bottom:0;
87101
}
88-
table tr:last-child td:first-child {
102+
.marked > table tr:last-child td:first-child,
103+
.markdown > table tr:last-child td:first-child {
89104
-moz-border-radius-bottomleft:3px;
90105
-webkit-border-bottom-left-radius:3px;
91106
border-bottom-left-radius:3px;
92107
}
93-
table tr:last-child td:last-child {
108+
.marked > table tr:last-child td:last-child,
109+
.markdown > table tr:last-child td:last-child {
94110
-moz-border-radius-bottomright:3px;
95111
-webkit-border-bottom-right-radius:3px;
96112
border-bottom-right-radius:3px;
97113
}
98-
table tr:hover td {
114+
.marked > table tr:hover td,
115+
.markdown > table tr:hover td {
99116
background: #f4f4f4;
100117
background: -webkit-gradient(linear, left top, left bottom, from(#f4f4f4), to(#f2f2f2));
101118
background: -moz-linear-gradient(top, #f4f4f4, #f2f2f2);

0 commit comments

Comments
 (0)