Skip to content

Commit

Permalink
Fixes valor-software#619: Renderer is no longer part of Angular compi…
Browse files Browse the repository at this point in the history
…lation. Substituted by Renderer2
  • Loading branch information
Narshe1412 committed Oct 26, 2022
1 parent 4da74de commit 5656659
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
8 changes: 4 additions & 4 deletions components/table/ng-table-filtering.directive.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Directive, EventEmitter, ElementRef, Renderer, HostListener, Input, Output } from '@angular/core';
import { Directive, EventEmitter, ElementRef, Renderer2, HostListener, Input, Output } from '@angular/core';

// import {setProperty} from 'angular2/ts/src/core/forms/directives/shared';
function setProperty(renderer:Renderer, elementRef:ElementRef, propName:string, propValue:any):void {
function setProperty(renderer:Renderer2, elementRef:ElementRef, propName:string, propValue:any):void {
renderer.setElementProperty(elementRef, propName, propValue);
}

Expand All @@ -24,15 +24,15 @@ export class NgTableFilteringDirective {
}

private element:ElementRef;
private renderer:Renderer;
private renderer:Renderer2;

@HostListener('input', ['$event.target.value'])
public onChangeFilter(event:any):void {
this.ngTableFiltering.filterString = event;
this.tableChanged.emit({filtering: this.ngTableFiltering});
}

public constructor(element:ElementRef, renderer:Renderer) {
public constructor(element:ElementRef, renderer:Renderer2) {
this.element = element;
this.renderer = renderer;
// Set default value for filter
Expand Down
44 changes: 27 additions & 17 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
/**
* @author: @AngularClass
*/
'use strict';
"use strict";

const reqPrism = require('prismjs');
const marked = require('marked');
const reqPrism = require("prismjs");
const marked = require("marked");

marked.Renderer.prototype.code = function renderCode(code, lang) {
const out = this.options.highlight(code, lang);
Expand All @@ -17,35 +17,45 @@ marked.Renderer.prototype.code = function renderCode(code, lang) {
return `<pre class="${classMap}"><code class="${classMap}">${out}\n</code></pre>\n`;
};

marked.Renderer2.prototype.code = function renderCode(code, lang) {
const out = this.options.highlight(code, lang);
const classMap = this.options.langPrefix + lang;

if (!lang) {
return `<pre><code>${out}\n</code></pre>`;
}
return `<pre class="${classMap}"><code class="${classMap}">${out}\n</code></pre>\n`;
};

// Look in ./config folder for webpack.dev.js
const conf = getWebpackConfig(process.env.NODE_ENV, require('./.ng2-config'));
const conf = getWebpackConfig(process.env.NODE_ENV, require("./.ng2-config"));

conf.markdownLoader = {
langPrefix: 'language-',
langPrefix: "language-",
highlight(code, lang) {
const language = !lang || lang === 'html' ? 'markup' : lang;
const language = !lang || lang === "html" ? "markup" : lang;
const Prism = global.Prism || reqPrism;

if (!Prism.languages[language]) {
require(`prismjs/components/prism-${language}.js`);
}
return Prism.highlight(code, Prism.languages[language]);
}
},
};

module.exports = conf;

function getWebpackConfig(env, config) {
switch (env) {
case 'prod':
case 'production':
return require('ng2-webpack-config').webpack.prod(config);
case 'test':
case 'testing':
return require('ng2-webpack-config').webpack.test(config);
case 'dev':
case 'development':
default:
return require('ng2-webpack-config').webpack.dev(config);
case "prod":
case "production":
return require("ng2-webpack-config").webpack.prod(config);
case "test":
case "testing":
return require("ng2-webpack-config").webpack.test(config);
case "dev":
case "development":
default:
return require("ng2-webpack-config").webpack.dev(config);
}
}

0 comments on commit 5656659

Please sign in to comment.