mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-08-17 07:00:22 +03:00
Migrate notifications
to new API
This commit is contained in:
parent
c9c9f1ab4b
commit
e7c14be227
@ -8,18 +8,14 @@
|
|||||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||||
*/
|
*/
|
||||||
let NotificationElement;
|
let NotificationElement;
|
||||||
const createDOMPurify = require('dompurify');
|
|
||||||
const fs = require('fs-plus');
|
const fs = require('fs-plus');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const marked = require('marked');
|
|
||||||
const {shell} = require('electron');
|
const {shell} = require('electron');
|
||||||
|
|
||||||
const NotificationIssue = require('./notification-issue');
|
const NotificationIssue = require('./notification-issue');
|
||||||
const TemplateHelper = require('./template-helper');
|
const TemplateHelper = require('./template-helper');
|
||||||
const UserUtilities = require('./user-utilities');
|
const UserUtilities = require('./user-utilities');
|
||||||
|
|
||||||
let DOMPurify = null;
|
|
||||||
|
|
||||||
const NotificationTemplate = `\
|
const NotificationTemplate = `\
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="message item"></div>
|
<div class="message item"></div>
|
||||||
@ -110,12 +106,7 @@ module.exports =
|
|||||||
|
|
||||||
const notificationContainer = this.element.querySelector('.message');
|
const notificationContainer = this.element.querySelector('.message');
|
||||||
|
|
||||||
if (DOMPurify === null) {
|
notificationContainer.innerHTML = atom.ui.markdown.render(this.model.getMessage());
|
||||||
DOMPurify = createDOMPurify();
|
|
||||||
}
|
|
||||||
notificationContainer.innerHTML = DOMPurify.sanitize(
|
|
||||||
marked.parse(this.model.getMessage())
|
|
||||||
);
|
|
||||||
|
|
||||||
if (detail = this.model.getDetail()) {
|
if (detail = this.model.getDetail()) {
|
||||||
let stack;
|
let stack;
|
||||||
@ -137,7 +128,7 @@ module.exports =
|
|||||||
metaContainer = this.element.querySelector('.meta');
|
metaContainer = this.element.querySelector('.meta');
|
||||||
metaContainer.appendChild(TemplateHelper.render(this.metaTemplate));
|
metaContainer.appendChild(TemplateHelper.render(this.metaTemplate));
|
||||||
const description = this.element.querySelector('.description');
|
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)) {
|
if (options.buttons && (options.buttons.length > 0)) {
|
||||||
|
@ -9,9 +9,7 @@
|
|||||||
"atom": ">0.50.0"
|
"atom": ">0.50.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dompurify": "3.0.3",
|
|
||||||
"fs-plus": "^3.0.0",
|
"fs-plus": "^3.0.0",
|
||||||
"marked": "5.0.3",
|
|
||||||
"moment": "^2.19.3",
|
"moment": "^2.19.3",
|
||||||
"semver": "^7.0.0",
|
"semver": "^7.0.0",
|
||||||
"stacktrace-parser": "^0.1.3",
|
"stacktrace-parser": "^0.1.3",
|
||||||
|
36
spec/ui-spec.js
Normal file
36
spec/ui-spec.js
Normal 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
@ -305,7 +305,7 @@ function convertAtomEditorToStandardElement(editorElement, preElement) {
|
|||||||
|
|
||||||
// Markdown Exported Object
|
// Markdown Exported Object
|
||||||
const markdown = {
|
const markdown = {
|
||||||
renderMarkdown: renderMarkdown,
|
render: renderMarkdown,
|
||||||
applySyntaxHighlighting: applySyntaxHighlighting,
|
applySyntaxHighlighting: applySyntaxHighlighting,
|
||||||
convertToDOM: convertToDOM
|
convertToDOM: convertToDOM
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user