Skip to content

Commit

Permalink
Revert "feat(showdown): Remove all"
Browse files Browse the repository at this point in the history
This reverts commit 9772af5.
  • Loading branch information
marker dao ® committed Oct 7, 2024
1 parent 49f021d commit aed1e54
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 198 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getWindow } from '@js/core/utils/window';
import Errors from '@js/ui/widget/ui.errors';
import ShowDown from 'showdown';
import TurnDown from 'turndown';

import converterController from '../m_converterController';
Expand All @@ -14,7 +15,7 @@ class MarkdownConverter {
// @ts-expect-error
const turndown = window && window.TurndownService || TurnDown;
// @ts-expect-error
const showdown = window && window.showdown;
const showdown = window && window.showdown || ShowDown;

if (!turndown) {
throw Errors.Error('E1041', 'Turndown');
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"inferno-hydrate": "^7.4.9",
"jszip": "^3.10.1",
"rrule": "^2.7.1",
"showdown": "^2.1.0",
"turndown": "~7.1.0"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
window.showdown = module.exports = null;
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@
'jspdf': '@Url.Content("~/packages/devextreme/node_modules/jspdf/dist/jspdf.umd.js")',
'jspdf-autotable': '@Url.Content("~/packages/devextreme/node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js")',
'turndown': '@Url.Content("~/packages/devextreme/node_modules/turndown/lib/turndown.browser.umd.js")',
'showdown': '@Url.Content("~/packages/devextreme/node_modules/showdown/dist/showdown.js")',
'rrule': '@Url.Content("~/packages/devextreme/node_modules/rrule/dist/es5/rrule.js")',
// Inferno
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
require('../../helpers/ignoreQuillTimers.js');
require('./htmlEditorParts/importQuill.tests.js');
require('./htmlEditorParts/importShowdown.tests.js');
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
SystemJS.config({
map: {
'showdown': '/packages/devextreme/testing/helpers/quillDependencies/noShowdown.js'
}
});

define(function(require) {
const MarkdownConverter = require('ui/html_editor/converters/markdown');

QUnit.module('Import 3rd party', function() {
QUnit.test('it throw an error if the markdown -> html converter script isn\'t referenced', function(assert) {
assert.throws(
function() { new MarkdownConverter(); },
function(e) {
return /(E1041)[\s\S]*(Showdown)/.test(e.message);
},
'The showdown script isn\'t referenced'
);
});

QUnit.test('initialize showdown from window', function(assert) {
const prevWinShowdown = window.showdown;

window.showdown = {
Converter: function() {
this.initialized = true;
}
};

const converter = new MarkdownConverter();

assert.ok(converter._markdown2Html.initialized);

window.showdown = prevWinShowdown;
});
});
});
1 change: 1 addition & 0 deletions packages/devextreme/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = {
'globalize/message': 'window.Globalize',
'devextreme-quill': 'window.DevExpress.Quill',
'turndown': 'window.TurndownService',
'showdown': 'window.showdown',
'exceljs': 'window.ExcelJS',
'jspdf': 'window.jspdf.jsPDF',
'devexpress-diagram': 'window.DevExpress.diagram',
Expand Down
271 changes: 74 additions & 197 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

0 comments on commit aed1e54

Please sign in to comment.