OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library trydart.decoration; | 5 library trydart.decoration; |
6 | 6 |
7 import 'dart:html'; | 7 import 'dart:html'; |
8 | 8 |
9 import 'shadow_root.dart' show | 9 import 'shadow_root.dart' show |
10 setShadowRoot; | 10 setShadowRoot; |
11 | 11 |
| 12 import 'editor.dart' show |
| 13 diagnostic; |
| 14 |
12 class Decoration { | 15 class Decoration { |
13 final String color; | 16 final String color; |
14 final bool bold; | 17 final bool bold; |
15 final bool italic; | 18 final bool italic; |
16 final bool stress; | 19 final bool stress; |
17 final bool important; | 20 final bool important; |
18 | 21 |
19 const Decoration({this.color: '#000000', | 22 const Decoration({this.color: '#000000', |
20 this.bold: false, | 23 this.bold: false, |
21 this.italic: false, | 24 this.italic: false, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 important: important); | 61 important: important); |
59 | 62 |
60 Element applyTo(text) { | 63 Element applyTo(text) { |
61 var element = super.applyTo(text); | 64 var element = super.applyTo(text); |
62 var nodes = new List.from(element.nodes); | 65 var nodes = new List.from(element.nodes); |
63 element.nodes.clear(); | 66 element.nodes.clear(); |
64 var tip = new Text(''); | 67 var tip = new Text(''); |
65 if (kind == 'error') { | 68 if (kind == 'error') { |
66 tip = error(message); | 69 tip = error(message); |
67 } | 70 } |
68 return element..append( | 71 return element..append(diagnostic(nodes, tip)); |
69 new AnchorElement() | |
70 ..classes.add('diagnostic') | |
71 ..nodes.addAll(nodes) | |
72 ..append(tip)); | |
73 } | 72 } |
74 } | 73 } |
75 | 74 |
76 createAlert(text, [String cls]) { | 75 createAlert(text, [String cls]) { |
77 var classes = ['alert']; | 76 var classes = ['alert']; |
78 if (cls != null) { | 77 if (cls != null) { |
79 classes.add(cls); | 78 classes.add(cls); |
80 } | 79 } |
81 SpanElement result = new SpanElement() | 80 SpanElement result = new SpanElement() |
82 ..classes.addAll(classes) | 81 ..classes.addAll(classes) |
(...skipping 29 matching lines...) Expand all Loading... |
112 | 111 |
113 Element applyTo(text) { | 112 Element applyTo(text) { |
114 var codeCompletion = new DivElement() | 113 var codeCompletion = new DivElement() |
115 ..contentEditable = 'false' | 114 ..contentEditable = 'false' |
116 ..classes.add('dart-code-completion'); | 115 ..classes.add('dart-code-completion'); |
117 return super.applyTo(text) | 116 return super.applyTo(text) |
118 ..classes.add('dart-code-completion-holder') | 117 ..classes.add('dart-code-completion-holder') |
119 ..nodes.add(codeCompletion); | 118 ..nodes.add(codeCompletion); |
120 } | 119 } |
121 } | 120 } |
OLD | NEW |