@codemirror/lint 0.20.2 → 0.20.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.20.3 (2022-05-25)
2
+
3
+ ### New features
4
+
5
+ Diagnostic objects may now have a `renderMessage` method to render their message to the DOM.
6
+
1
7
  ## 0.20.2 (2022-05-02)
2
8
 
3
9
  ### New features
package/dist/index.cjs CHANGED
@@ -290,7 +290,7 @@ function assignKeys(actions) {
290
290
  function renderDiagnostic(view, diagnostic, inPanel) {
291
291
  var _a;
292
292
  let keys = inPanel ? assignKeys(diagnostic.actions) : [];
293
- return elt__default["default"]("li", { class: "cm-diagnostic cm-diagnostic-" + diagnostic.severity }, elt__default["default"]("span", { class: "cm-diagnosticText" }, diagnostic.message), (_a = diagnostic.actions) === null || _a === void 0 ? void 0 : _a.map((action, i) => {
293
+ return elt__default["default"]("li", { class: "cm-diagnostic cm-diagnostic-" + diagnostic.severity }, elt__default["default"]("span", { class: "cm-diagnosticText" }, diagnostic.renderMessage ? diagnostic.renderMessage() : diagnostic.message), (_a = diagnostic.actions) === null || _a === void 0 ? void 0 : _a.map((action, i) => {
294
294
  let click = (e) => {
295
295
  e.preventDefault();
296
296
  let found = findDiagnostic(view.state.field(lintState).diagnostics, diagnostic);
package/dist/index.d.ts CHANGED
@@ -31,6 +31,11 @@ interface Diagnostic {
31
31
  */
32
32
  message: string;
33
33
  /**
34
+ An optional custom rendering function that displays the message
35
+ as a DOM node.
36
+ */
37
+ renderMessage?: () => Node;
38
+ /**
34
39
  An optional array of actions that can be taken on this
35
40
  diagnostic.
36
41
  */
package/dist/index.js CHANGED
@@ -282,7 +282,7 @@ function assignKeys(actions) {
282
282
  function renderDiagnostic(view, diagnostic, inPanel) {
283
283
  var _a;
284
284
  let keys = inPanel ? assignKeys(diagnostic.actions) : [];
285
- return elt("li", { class: "cm-diagnostic cm-diagnostic-" + diagnostic.severity }, elt("span", { class: "cm-diagnosticText" }, diagnostic.message), (_a = diagnostic.actions) === null || _a === void 0 ? void 0 : _a.map((action, i) => {
285
+ return elt("li", { class: "cm-diagnostic cm-diagnostic-" + diagnostic.severity }, elt("span", { class: "cm-diagnosticText" }, diagnostic.renderMessage ? diagnostic.renderMessage() : diagnostic.message), (_a = diagnostic.actions) === null || _a === void 0 ? void 0 : _a.map((action, i) => {
286
286
  let click = (e) => {
287
287
  e.preventDefault();
288
288
  let found = findDiagnostic(view.state.field(lintState).diagnostics, diagnostic);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/lint",
3
- "version": "0.20.2",
3
+ "version": "0.20.3",
4
4
  "description": "Linting support for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",