Skip to content

Commit

Permalink
Merge pull request #6400 from davidwatkins73/waltz-6297-rm-ng-md3
Browse files Browse the repository at this point in the history
Remove angular markdown support
  • Loading branch information
jessica-woodland-scott-db authored Jan 27, 2023
2 parents 8368cd6 + 91de022 commit 717efc3
Show file tree
Hide file tree
Showing 6 changed files with 12,011 additions and 376 deletions.
9 changes: 7 additions & 2 deletions waltz-ng/client/common/svelte/Markdown.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
const converter = new showdown.Converter({extensions: ["bootstrap-tables"]});
converter.setFlavor("github");
converter.setOption("ghCodeBlocks", true);
converter.setOption("simplifiedAutoLink", true);
converter.setOption("simpleLineBreaks", true);
converter.setOption("strikethrough", true);
converter.setOption("tasklists", true);
</script>


Expand All @@ -33,12 +38,12 @@
}
}
$: html = mkHtml(text, context);
$: convertedHtml = mkHtml(text, context);
</script>


<span class:inline-markdown={inline}>
{@html html}
{@html convertedHtml}
</span>


Expand Down
3 changes: 0 additions & 3 deletions waltz-ng/client/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ import "angular-tree-control";
import "angular-ui-grid/ui-grid";
import "angular-ui-bootstrap";
import "ng-tags-input";
import "ng-showdown";
import "satellizer";
import "ui-select";

import "@uirouter/angularjs";

import AngularFormly from "angular-formly";
Expand Down Expand Up @@ -135,7 +133,6 @@ const dependencies = [
"ngAnimate",
"ngSanitize",
"ngTagsInput",
"ng-showdown",
"satellizer",
"LocalStorageModule",
AngularFormly,
Expand Down
33 changes: 1 addition & 32 deletions waltz-ng/client/thirdparty-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,43 +49,12 @@ authProviderSetup.$inject = [
];


function showdownSetup($showdownProvider) {
const customExtensions = () => {
const tableStyle = {
type: "output",
regex: /<table>/g,
replace: "<table class=\"table table-condensed table-striped table-bordered\">"
};

return [tableStyle];
};

$showdownProvider.loadExtension(customExtensions);

$showdownProvider.setOption("excludeTrailingPunctuationFromURLs", true);
$showdownProvider.setOption("sanitize", true);
$showdownProvider.setOption("simplifiedAutoLink", true);
$showdownProvider.setOption("simpleLineBreaks", true);
$showdownProvider.setOption("strikethrough", true);
$showdownProvider.setOption("tables", true);
$showdownProvider.setOption("tasklists", true);
}

showdownSetup.$inject = [
"$showdownProvider"
];




function setup(module) {
module
.config(uiSelectSetup)
.config(authProviderSetup)
.config(showdownSetup);
.config(authProviderSetup);

// for formly setup see: `formly/index.js`

}


Expand Down
37 changes: 11 additions & 26 deletions waltz-ng/client/widgets/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*
*/

import _ from "lodash";
import {initialiseData} from "../common";
import Markdown from "../common/svelte/Markdown.svelte";


const bindings = {
Expand All @@ -27,35 +27,22 @@ const bindings = {


const initialState = {
variables: {}
Markdown,
context: null,
text: ""
};


const template = `
<span ng-if="$ctrl.text"
class="waltz-markdown"
markdown-to-html="$ctrl.markdown">
</span>`;


function interpolate(templateFn, context = {}, templateStr = "") {
try {
return templateFn(context);
} catch (e) {
console.log("Failed to interpolate template with context", { context, templateStr, e })
}
}
<waltz-svelte-component ng-if="$ctrl.text"
component="$ctrl.Markdown"
context="$ctrl.context"
text="$ctrl.text">
</waltz-svelte-component>`;


function controller() {
const vm = initialiseData(this, initialState);

let templateFn = () => "";

vm.$onChanges = (c) => {
templateFn = _.template(vm.text, { variable: "ctx"});
vm.markdown = _.isEmpty(vm.context) ? vm.text : interpolate(templateFn, vm.context, vm.text);
};
initialiseData(this, initialState);
}


Expand All @@ -80,6 +67,4 @@ const component = {
};


export default component;


export default component;
Loading

0 comments on commit 717efc3

Please sign in to comment.