Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fe update quill v2.0.1 #6441

Merged
merged 2 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 33 additions & 113 deletions node-services/cards-external-diffusion/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions node-services/cards-external-diffusion/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"jwt-decode": "4.0.0",
"mongodb": "6.6.1",
"nodemailer": "6.9.13",
"quill": "1.3.7",
"quill": "2.0.1",
"winston": "3.13.0",
"winston-daily-rotate-file": "5.0.0"
},
Expand All @@ -41,7 +41,6 @@
"@types/jsdom": "21.1.6",
"@types/node": "20.12.10",
"@types/nodemailer": "6.4.15",
"@types/quill": "2.0.14",
"@types/sinon": "17.0.3",
"@typescript-eslint/eslint-plugin": "6.21.0",
"eslint": "8.57.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

import * as Handlebars from 'handlebars';
import moment from 'moment';
import {JSDOM} from 'jsdom'
import {JSDOM} from 'jsdom';
import * as fs from 'fs';

/* eslint-disable @typescript-eslint/no-extraneous-class */
export class HandlebarsHelper {
Expand Down Expand Up @@ -337,15 +338,13 @@ export class HandlebarsHelper {
});
}

private static registerDeltaToHtml() {
Handlebars.registerHelper('deltaToHtml', (delta) => {
const fs = require('fs');
let quillFilePath = require.resolve('quill');
let quillMinFilePath = quillFilePath.replace('quill.js', 'quill.min.js');

let quillLibrary = fs.readFileSync(quillMinFilePath);
const TEMPLATE = `<div id="editor"></div>
<script>${quillLibrary}</script>
private static registerDeltaToHtml(): void {
Handlebars.registerHelper('deltaToHtml', (delta: string) => {
const quillFilePath = require.resolve('quill');

const quillLibrary = fs.readFileSync(quillFilePath);
const TEMPLATE = `<div id="editor"></div>
<script>${quillLibrary.toString()}</script>
<script>
document.getSelection = function() {
return {
Expand All @@ -358,12 +357,12 @@ export class HandlebarsHelper {
} catch(e) {}
return false;
};
</script>`
</script>`;

const DOM = new JSDOM(TEMPLATE, { runScripts: 'dangerously', resources: 'usable' });
const DOM = new JSDOM(TEMPLATE, {runScripts: 'dangerously', resources: 'usable'});
const quill = new DOM.window.Quill('#editor');
quill.setContents(JSON.parse(delta));

quill.setContents(JSON.parse(delta));
const html = quill.root.innerHTML;
return html;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@

import * as Handlebars from 'handlebars';
import {JSDOM} from 'jsdom';
import fs from 'fs';
import * as fs from 'fs';

// eslint-disable-next-line @typescript-eslint/no-extraneous-class
export class MailHandlebarsHelper {
private static quill: any;

public static init(): void {
const quillFilePath = require.resolve('quill');
const quillMinFilePath = quillFilePath.replace('quill.js', 'quill.min.js');
const quillDistFilePath = quillFilePath.replace('quill.js', 'dist/quill.js');

const quillLibrary = fs.readFileSync(quillMinFilePath);
const quillLibrary = fs.readFileSync(quillDistFilePath);

const TEMPLATE = `<div id="editor"></div>
<script>${quillLibrary.toString()}</script>
Expand Down
Loading