Migrate notifications to new API

This commit is contained in:
confused-Techie 2023-10-18 11:58:24 -07:00
parent c9c9f1ab4b
commit e7c14be227
4 changed files with 39 additions and 14 deletions

View File

@ -8,18 +8,14 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/
let NotificationElement;
const createDOMPurify = require('dompurify');
const fs = require('fs-plus');
const path = require('path');
const marked = require('marked');
const {shell} = require('electron');
const NotificationIssue = require('./notification-issue');
const TemplateHelper = require('./template-helper');
const UserUtilities = require('./user-utilities');
let DOMPurify = null;
const NotificationTemplate = `\
<div class="content">
<div class="message item"></div>
@ -110,12 +106,7 @@ module.exports =
const notificationContainer = this.element.querySelector('.message');
if (DOMPurify === null) {
DOMPurify = createDOMPurify();
}
notificationContainer.innerHTML = DOMPurify.sanitize(
marked.parse(this.model.getMessage())
);
notificationContainer.innerHTML = atom.ui.markdown.render(this.model.getMessage());
if (detail = this.model.getDetail()) {
let stack;
@ -137,7 +128,7 @@ module.exports =
metaContainer = this.element.querySelector('.meta');
metaContainer.appendChild(TemplateHelper.render(this.metaTemplate));
const description = this.element.querySelector('.description');
description.innerHTML = marked.parse(metaContent);
description.innerHTML = atom.ui.markdown.render(metaContent);
}
if (options.buttons && (options.buttons.length > 0)) {

View File

@ -9,9 +9,7 @@
"atom": ">0.50.0"
},
"dependencies": {
"dompurify": "3.0.3",
"fs-plus": "^3.0.0",
"marked": "5.0.3",
"moment": "^2.19.3",
"semver": "^7.0.0",
"stacktrace-parser": "^0.1.3",

36
spec/ui-spec.js Normal file
View File

@ -0,0 +1,36 @@
const UI = require("../src/ui.js");
describe("Just testing for now", async () => {
console.log("here0");
const content =
`
# Hello World
My friends
\`\`\`javascript
const hello = "world";
\`\`\`
`;
console.log("here4");
try {
const html = UI.markdown.renderMarkdown(content);
console.log("here3");
console.log(html);
const htmlDom = UI.markdown.convertToDOM(html);
console.log("here1");
await UI.markdown.applySyntaxHighlighting(htmlDom);
console.log("here2");
console.log(htmlDom.innerHTML);
} catch(er) {
console.log("we errored");
console.error(er);
}
});

View File

@ -305,7 +305,7 @@ function convertAtomEditorToStandardElement(editorElement, preElement) {
// Markdown Exported Object
const markdown = {
renderMarkdown: renderMarkdown,
render: renderMarkdown,
applySyntaxHighlighting: applySyntaxHighlighting,
convertToDOM: convertToDOM
};