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

Updates Angular Renderer referenced to Renderer2 #623

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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);
}
}