Skip to content

Commit

Permalink
Updated tsconfig to make it stricker and fixed given errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nozer committed Aug 14, 2018
1 parent 72bd3a8 commit 30c2b34
Show file tree
Hide file tree
Showing 37 changed files with 128 additions and 327 deletions.
26 changes: 15 additions & 11 deletions dist/browser/QuillDeltaToHtmlConverter.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var DeltaInsertOp = (function () {
attrs.header || attrs.align || attrs.direction || attrs.indent);
};
DeltaInsertOp.prototype.isBlockquote = function () {
return this.attributes.blockquote;
return !!this.attributes.blockquote;
};
DeltaInsertOp.prototype.isHeader = function () {
return !!this.attributes.header;
Expand Down Expand Up @@ -343,7 +343,7 @@ var OpToHtmlConverter = (function () {
var tag = tags_1[_i];
beginTags.push(funcs_html_1.makeStartTag(tag, attrs));
endTags.push(tag === 'img' ? '' : funcs_html_1.makeEndTag(tag));
attrs = null;
attrs = [];
}
endTags.reverse();
return {
Expand Down Expand Up @@ -396,13 +396,13 @@ var OpToHtmlConverter = (function () {
var tagAttrs = classes.length ? [makeAttr('class', classes.join(' '))] : [];
if (this.op.isImage()) {
this.op.attributes.width && (tagAttrs = tagAttrs.concat(makeAttr('width', this.op.attributes.width)));
return tagAttrs.concat(makeAttr('src', (this.op.insert.value + '')._sanitizeUrl()));
return tagAttrs.concat(makeAttr('src', (this.op.insert.value + '')._sanitizeUrl() + ''));
}
if (this.op.isFormula() || this.op.isContainerBlock()) {
return tagAttrs;
}
if (this.op.isVideo()) {
return tagAttrs.concat(makeAttr('frameborder', '0'), makeAttr('allowfullscreen', 'true'), makeAttr('src', (this.op.insert.value + '')._sanitizeUrl()));
return tagAttrs.concat(makeAttr('frameborder', '0'), makeAttr('allowfullscreen', 'true'), makeAttr('src', (this.op.insert.value + '')._sanitizeUrl() + ''));
}
if (this.op.isMentions()) {
var mention = this.op.attributes.mention;
Expand Down Expand Up @@ -452,8 +452,9 @@ var OpToHtmlConverter = (function () {
['indent', positionTag]];
for (var _i = 0, blocks_1 = blocks; _i < blocks_1.length; _i++) {
var item = blocks_1[_i];
if (attrs[item[0]]) {
return item[0] === 'header' ? ['h' + attrs[item[0]]] : [item._preferSecond()];
var firstItem = item[0];
if (attrs[firstItem]) {
return firstItem === 'header' ? ['h' + attrs[firstItem]] : [item._preferSecond()];
}
}
return [['link', 'a'], ['script'],
Expand Down Expand Up @@ -648,6 +649,7 @@ var QuillDeltaToHtmlConverter = (function () {
exports.QuillDeltaToHtmlConverter = QuillDeltaToHtmlConverter;

},{"./InsertOpsConverter":4,"./OpToHtmlConverter":6,"./extensions/Object":9,"./funcs-html":11,"./grouper/Grouper":12,"./grouper/ListNester":13,"./grouper/group-types":14,"./value-types":16}],8:[function(require,module,exports){
"use strict";
Array.prototype._preferSecond = function () {
if (this.length === 0) {
return null;
Expand Down Expand Up @@ -700,6 +702,7 @@ Array.prototype._intersperse = function (item) {
};

},{}],9:[function(require,module,exports){
"use strict";
Object._assign = function (target, varArg1, varArg2) {
if (varArg2 === void 0) { varArg2 = null; }
if (target == null) {
Expand All @@ -720,6 +723,7 @@ Object._assign = function (target, varArg1, varArg2) {
};

},{}],10:[function(require,module,exports){
"use strict";
String.prototype._tokenizeWithNewLines = function () {
var NewLine = "\n";
var this_ = this.toString();
Expand Down Expand Up @@ -750,7 +754,7 @@ String.prototype._sanitizeUrl = function () {
var val = this;
val = val.replace(/^\s*/gm, '');
var whiteList = /^\s*((https?|s?ftp|file|blob|mailto|tel):|data:image\/)/;
if (whiteList.test(val)) {
if (whiteList.test(String(val))) {
return val;
}
return 'unsafe:' + val;
Expand All @@ -765,14 +769,14 @@ var EncodeTarget;
EncodeTarget[EncodeTarget["Url"] = 1] = "Url";
})(EncodeTarget || (EncodeTarget = {}));
function makeStartTag(tag, attrs) {
if (attrs === void 0) { attrs = null; }
if (attrs === void 0) { attrs = undefined; }
if (!tag) {
return '';
}
var attrsStr = '';
if (attrs) {
attrs = [].concat(attrs);
attrsStr = attrs.map(function (attr) {
var arrAttrs = [].concat(attrs);
attrsStr = arrAttrs.map(function (attr) {
return attr.key + (attr.value ? '="' + attr.value + '"' : '');
}).join(' ');
}
Expand Down Expand Up @@ -1078,7 +1082,7 @@ var MentionSanitizer = (function () {
if (dirtyObj.id && MentionSanitizer.IsValidId(dirtyObj.id)) {
cleanObj.id = dirtyObj.id;
}
if (MentionSanitizer.IsValidTarget(dirtyObj.target)) {
if (MentionSanitizer.IsValidTarget(dirtyObj.target + '')) {
cleanObj.target = dirtyObj.target;
}
if (dirtyObj.avatar) {
Expand Down
2 changes: 1 addition & 1 deletion dist/commonjs/DeltaInsertOp.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var DeltaInsertOp = (function () {
attrs.header || attrs.align || attrs.direction || attrs.indent);
};
DeltaInsertOp.prototype.isBlockquote = function () {
return this.attributes.blockquote;
return !!this.attributes.blockquote;
};
DeltaInsertOp.prototype.isHeader = function () {
return !!this.attributes.header;
Expand Down
2 changes: 0 additions & 2 deletions dist/commonjs/IOpAttributes.js

This file was deleted.

2 changes: 1 addition & 1 deletion dist/commonjs/InsertOpsConverter.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DeltaInsertOp } from './DeltaInsertOp';
import { InsertData } from './InsertData';
declare class InsertOpsConverter {
static convert(deltaOps: any[]): DeltaInsertOp[];
static convert(deltaOps: null | any[]): DeltaInsertOp[];
static convertInsertVal(insertPropVal: any): InsertData | null;
}
export { InsertOpsConverter };
36 changes: 18 additions & 18 deletions dist/commonjs/OpAttributeSanitizer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@ import { ListType, AlignType, DirectionType, ScriptType } from './value-types';
import './extensions/String';
import { IMention } from "./mentions/MentionSanitizer";
interface IOpAttributes {
background?: string;
color?: string;
font?: string;
size?: string;
width?: string;
link?: string;
bold?: boolean;
italic?: boolean;
underline?: boolean;
strike?: boolean;
background?: string | undefined;
color?: string | undefined;
font?: string | undefined;
size?: string | undefined;
width?: string | undefined;
link?: string | undefined;
bold?: boolean | undefined;
italic?: boolean | undefined;
underline?: boolean | undefined;
strike?: boolean | undefined;
script?: ScriptType;
code?: boolean;
code?: boolean | undefined;
list?: ListType;
blockquote?: boolean;
'code-block'?: boolean;
header?: number;
blockquote?: boolean | undefined;
'code-block'?: boolean | undefined;
header?: number | undefined;
align?: AlignType;
direction?: DirectionType;
indent?: number;
mentions?: boolean;
mention?: IMention;
target?: string;
indent?: number | undefined;
mentions?: boolean | undefined;
mention?: IMention | undefined;
target?: string | undefined;
}
declare class OpAttributeSanitizer {
static sanitize(dirtyAttrs: IOpAttributes): IOpAttributes;
Expand Down
79 changes: 0 additions & 79 deletions dist/commonjs/OpGroup.js

This file was deleted.

11 changes: 6 additions & 5 deletions dist/commonjs/OpToHtmlConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var OpToHtmlConverter = (function () {
var tag = tags_1[_i];
beginTags.push(funcs_html_1.makeStartTag(tag, attrs));
endTags.push(tag === 'img' ? '' : funcs_html_1.makeEndTag(tag));
attrs = null;
attrs = [];
}
endTags.reverse();
return {
Expand Down Expand Up @@ -92,13 +92,13 @@ var OpToHtmlConverter = (function () {
var tagAttrs = classes.length ? [makeAttr('class', classes.join(' '))] : [];
if (this.op.isImage()) {
this.op.attributes.width && (tagAttrs = tagAttrs.concat(makeAttr('width', this.op.attributes.width)));
return tagAttrs.concat(makeAttr('src', (this.op.insert.value + '')._sanitizeUrl()));
return tagAttrs.concat(makeAttr('src', (this.op.insert.value + '')._sanitizeUrl() + ''));
}
if (this.op.isFormula() || this.op.isContainerBlock()) {
return tagAttrs;
}
if (this.op.isVideo()) {
return tagAttrs.concat(makeAttr('frameborder', '0'), makeAttr('allowfullscreen', 'true'), makeAttr('src', (this.op.insert.value + '')._sanitizeUrl()));
return tagAttrs.concat(makeAttr('frameborder', '0'), makeAttr('allowfullscreen', 'true'), makeAttr('src', (this.op.insert.value + '')._sanitizeUrl() + ''));
}
if (this.op.isMentions()) {
var mention = this.op.attributes.mention;
Expand Down Expand Up @@ -148,8 +148,9 @@ var OpToHtmlConverter = (function () {
['indent', positionTag]];
for (var _i = 0, blocks_1 = blocks; _i < blocks_1.length; _i++) {
var item = blocks_1[_i];
if (attrs[item[0]]) {
return item[0] === 'header' ? ['h' + attrs[item[0]]] : [item._preferSecond()];
var firstItem = item[0];
if (attrs[firstItem]) {
return firstItem === 'header' ? ['h' + attrs[firstItem]] : [item._preferSecond()];
}
}
return [['link', 'a'], ['script'],
Expand Down
4 changes: 2 additions & 2 deletions dist/commonjs/QuillDeltaToHtmlConverter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ declare class QuillDeltaToHtmlConverter {
_renderListItem(li: ListItem, isOuterMost: boolean): string;
_renderBlock(bop: DeltaInsertOp, ops: DeltaInsertOp[]): string;
_renderInlines(ops: DeltaInsertOp[], wrapInParagraphTag?: boolean): string;
_renderInline(op: DeltaInsertOp, contextOp: DeltaInsertOp): any;
_renderCustom(op: DeltaInsertOp, contextOp: DeltaInsertOp): any;
_renderInline(op: DeltaInsertOp, contextOp: DeltaInsertOp | null): any;
_renderCustom(op: DeltaInsertOp, contextOp: DeltaInsertOp | null): any;
beforeRender(cb: (group: GroupType, data: TDataGroup) => string): void;
afterRender(cb: (group: GroupType, html: string) => string): void;
renderCustomWith(cb: (op: DeltaInsertOp, contextOp: DeltaInsertOp) => string): void;
Expand Down
1 change: 1 addition & 0 deletions dist/commonjs/extensions/Array.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use strict";
Array.prototype._preferSecond = function () {
if (this.length === 0) {
return null;
Expand Down
1 change: 1 addition & 0 deletions dist/commonjs/extensions/Object.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use strict";
Object._assign = function (target, varArg1, varArg2) {
if (varArg2 === void 0) { varArg2 = null; }
if (target == null) {
Expand Down
2 changes: 1 addition & 1 deletion dist/commonjs/extensions/String.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
interface String {
_tokenizeWithNewLines(): string[];
_sanitizeUrl(): string;
_sanitizeUrl(): String;
}
3 changes: 2 additions & 1 deletion dist/commonjs/extensions/String.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use strict";
String.prototype._tokenizeWithNewLines = function () {
var NewLine = "\n";
var this_ = this.toString();
Expand Down Expand Up @@ -28,7 +29,7 @@ String.prototype._sanitizeUrl = function () {
var val = this;
val = val.replace(/^\s*/gm, '');
var whiteList = /^\s*((https?|s?ftp|file|blob|mailto|tel):|data:image\/)/;
if (whiteList.test(val)) {
if (whiteList.test(String(val))) {
return val;
}
return 'unsafe:' + val;
Expand Down
2 changes: 1 addition & 1 deletion dist/commonjs/funcs-html.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ interface ITagKeyValue {
key: string;
value?: string;
}
declare function makeStartTag(tag: any, attrs?: ITagKeyValue | ITagKeyValue[]): string;
declare function makeStartTag(tag: any, attrs?: ITagKeyValue | ITagKeyValue[] | undefined): string;
declare function makeEndTag(tag?: any): string;
declare function decodeHtml(str: string): string;
declare function encodeHtml(str: string, preventDoubleEncoding?: boolean): string;
Expand Down
6 changes: 3 additions & 3 deletions dist/commonjs/funcs-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ var EncodeTarget;
EncodeTarget[EncodeTarget["Url"] = 1] = "Url";
})(EncodeTarget || (EncodeTarget = {}));
function makeStartTag(tag, attrs) {
if (attrs === void 0) { attrs = null; }
if (attrs === void 0) { attrs = undefined; }
if (!tag) {
return '';
}
var attrsStr = '';
if (attrs) {
attrs = [].concat(attrs);
attrsStr = attrs.map(function (attr) {
var arrAttrs = [].concat(attrs);
attrsStr = arrAttrs.map(function (attr) {
return attr.key + (attr.value ? '="' + attr.value + '"' : '');
}).join(' ');
}
Expand Down
Loading

0 comments on commit 30c2b34

Please sign in to comment.