diff --git a/dist/browser/QuillDeltaToHtmlConverter.bundle.js b/dist/browser/QuillDeltaToHtmlConverter.bundle.js index 34f7b74..f38d7bc 100644 --- a/dist/browser/QuillDeltaToHtmlConverter.bundle.js +++ b/dist/browser/QuillDeltaToHtmlConverter.bundle.js @@ -569,22 +569,20 @@ var QuillDeltaToHtmlConverter = (function () { html = typeof afterCb === 'function' ? afterCb.apply(null, [groupType, html]) : html; return html; }; - QuillDeltaToHtmlConverter.prototype._renderList = function (list, isOuterMost) { + QuillDeltaToHtmlConverter.prototype._renderList = function (list) { var _this = this; - if (isOuterMost === void 0) { isOuterMost = true; } var firstItem = list.items[0]; return funcs_html_1.makeStartTag(this._getListTag(firstItem.item.op)) - + list.items.map(function (li) { return _this._renderListItem(li, isOuterMost); }).join('') + + list.items.map(function (li) { return _this._renderListItem(li); }).join('') + funcs_html_1.makeEndTag(this._getListTag(firstItem.item.op)); }; - QuillDeltaToHtmlConverter.prototype._renderListItem = function (li, isOuterMost) { - var converterOptions = Object._assign({}, this.converterOptions); + QuillDeltaToHtmlConverter.prototype._renderListItem = function (li) { li.item.op.attributes.indent = 0; var converter = new OpToHtmlConverter_1.OpToHtmlConverter(li.item.op, this.converterOptions); var parts = converter.getHtmlParts(); var liElementsHtml = this._renderInlines(li.item.ops, false); return parts.openingTag + (liElementsHtml) + - (li.innerList ? this._renderList(li.innerList, false) : '') + (li.innerList ? this._renderList(li.innerList) : '') + parts.closingTag; }; QuillDeltaToHtmlConverter.prototype._renderBlock = function (bop, ops) { @@ -703,8 +701,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; } +Object._assign = function (target) { if (target == null) { throw new TypeError('Cannot convert undefined or null to object'); } @@ -934,7 +931,6 @@ var ListNester = (function () { } ListNester.prototype.nest = function (groups) { var _this = this; - var result = []; var listBlocked = this.convertListBlocksToListGroups(groups); var groupedByListGroups = this.groupConsecutiveListGroups(listBlocked); var nested = groupedByListGroups.map(function (group) { diff --git a/dist/commonjs/QuillDeltaToHtmlConverter.d.ts b/dist/commonjs/QuillDeltaToHtmlConverter.d.ts index 911c87b..16a0f3a 100644 --- a/dist/commonjs/QuillDeltaToHtmlConverter.d.ts +++ b/dist/commonjs/QuillDeltaToHtmlConverter.d.ts @@ -26,8 +26,8 @@ declare class QuillDeltaToHtmlConverter { getGroupedOps(): TDataGroup[]; convert(): string; _renderWithCallbacks(groupType: GroupType, group: TDataGroup, myRenderFn: () => string): string; - _renderList(list: ListGroup, isOuterMost?: boolean): string; - _renderListItem(li: ListItem, isOuterMost: boolean): string; + _renderList(list: ListGroup): string; + _renderListItem(li: ListItem): string; _renderBlock(bop: DeltaInsertOp, ops: DeltaInsertOp[]): string; _renderInlines(ops: DeltaInsertOp[], wrapInParagraphTag?: boolean): string; _renderInline(op: DeltaInsertOp, contextOp: DeltaInsertOp | null): any; diff --git a/dist/commonjs/QuillDeltaToHtmlConverter.js b/dist/commonjs/QuillDeltaToHtmlConverter.js index 1528acd..04bea73 100644 --- a/dist/commonjs/QuillDeltaToHtmlConverter.js +++ b/dist/commonjs/QuillDeltaToHtmlConverter.js @@ -92,22 +92,20 @@ var QuillDeltaToHtmlConverter = (function () { html = typeof afterCb === 'function' ? afterCb.apply(null, [groupType, html]) : html; return html; }; - QuillDeltaToHtmlConverter.prototype._renderList = function (list, isOuterMost) { + QuillDeltaToHtmlConverter.prototype._renderList = function (list) { var _this = this; - if (isOuterMost === void 0) { isOuterMost = true; } var firstItem = list.items[0]; return funcs_html_1.makeStartTag(this._getListTag(firstItem.item.op)) - + list.items.map(function (li) { return _this._renderListItem(li, isOuterMost); }).join('') + + list.items.map(function (li) { return _this._renderListItem(li); }).join('') + funcs_html_1.makeEndTag(this._getListTag(firstItem.item.op)); }; - QuillDeltaToHtmlConverter.prototype._renderListItem = function (li, isOuterMost) { - var converterOptions = Object._assign({}, this.converterOptions); + QuillDeltaToHtmlConverter.prototype._renderListItem = function (li) { li.item.op.attributes.indent = 0; var converter = new OpToHtmlConverter_1.OpToHtmlConverter(li.item.op, this.converterOptions); var parts = converter.getHtmlParts(); var liElementsHtml = this._renderInlines(li.item.ops, false); return parts.openingTag + (liElementsHtml) + - (li.innerList ? this._renderList(li.innerList, false) : '') + (li.innerList ? this._renderList(li.innerList) : '') + parts.closingTag; }; QuillDeltaToHtmlConverter.prototype._renderBlock = function (bop, ops) { diff --git a/dist/commonjs/extensions/Object.js b/dist/commonjs/extensions/Object.js index d621201..f6a76ca 100644 --- a/dist/commonjs/extensions/Object.js +++ b/dist/commonjs/extensions/Object.js @@ -1,6 +1,5 @@ "use strict"; -Object._assign = function (target, varArg1, varArg2) { - if (varArg2 === void 0) { varArg2 = null; } +Object._assign = function (target) { if (target == null) { throw new TypeError('Cannot convert undefined or null to object'); } diff --git a/dist/commonjs/grouper/ListNester.js b/dist/commonjs/grouper/ListNester.js index de813ee..b24b725 100644 --- a/dist/commonjs/grouper/ListNester.js +++ b/dist/commonjs/grouper/ListNester.js @@ -6,7 +6,6 @@ var ListNester = (function () { } ListNester.prototype.nest = function (groups) { var _this = this; - var result = []; var listBlocked = this.convertListBlocksToListGroups(groups); var groupedByListGroups = this.groupConsecutiveListGroups(listBlocked); var nested = groupedByListGroups.map(function (group) { diff --git a/package.json b/package.json index ac69804..ddff8bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "quill-delta-to-html", - "version": "0.9.2", + "version": "0.9.3", "description": "Converts Quill's delta ops to HTML", "main": "./dist/commonjs/main.js", "types":"./dist/commonjs/main.d.ts", diff --git a/src/OpToHtmlConverter.ts b/src/OpToHtmlConverter.ts index 8df33cb..a46f8b4 100644 --- a/src/OpToHtmlConverter.ts +++ b/src/OpToHtmlConverter.ts @@ -5,7 +5,7 @@ import './extensions/String'; import './extensions/Object'; import { IMention } from "./mentions/MentionSanitizer"; import './extensions/Array'; -import { OpAttributeSanitizer, IOpAttributes } from "./OpAttributeSanitizer"; +import { OpAttributeSanitizer } from "./OpAttributeSanitizer"; interface IOpToHtmlConverterOptions { diff --git a/src/QuillDeltaToHtmlConverter.ts b/src/QuillDeltaToHtmlConverter.ts index 37a73d3..08ea584 100644 --- a/src/QuillDeltaToHtmlConverter.ts +++ b/src/QuillDeltaToHtmlConverter.ts @@ -1,6 +1,6 @@ import { InsertOpsConverter } from './InsertOpsConverter'; -import { OpToHtmlConverter, IOpToHtmlConverterOptions, IHtmlParts } from './OpToHtmlConverter'; +import { OpToHtmlConverter, IOpToHtmlConverterOptions } from './OpToHtmlConverter'; import { DeltaInsertOp } from './DeltaInsertOp'; import { Grouper } from './grouper/Grouper'; import { @@ -9,7 +9,7 @@ import { import { ListNester } from './grouper/ListNester'; import { makeStartTag, makeEndTag, encodeHtml } from './funcs-html'; import './extensions/Object'; -import { NewLine, GroupType } from './value-types'; +import { GroupType } from './value-types'; interface IQuillDeltaToHtmlConverterOptions { @@ -142,16 +142,16 @@ class QuillDeltaToHtmlConverter { return html; } - _renderList(list: ListGroup, isOuterMost = true): string { + _renderList(list: ListGroup): string { var firstItem = list.items[0]; return makeStartTag(this._getListTag(firstItem.item.op)) - + list.items.map((li: ListItem) => this._renderListItem(li, isOuterMost)).join('') + + list.items.map((li: ListItem) => this._renderListItem(li)).join('') + makeEndTag(this._getListTag(firstItem.item.op)); } - _renderListItem(li: ListItem, isOuterMost: boolean): string { - var converterOptions = Object._assign({}, this.converterOptions); + _renderListItem(li: ListItem ): string { + //if (!isOuterMost) { li.item.op.attributes.indent = 0; //} @@ -159,7 +159,7 @@ class QuillDeltaToHtmlConverter { var parts = converter.getHtmlParts(); var liElementsHtml = this._renderInlines(li.item.ops, false); return parts.openingTag + (liElementsHtml) + - (li.innerList ? this._renderList(li.innerList, false) : '') + (li.innerList ? this._renderList(li.innerList) : '') + parts.closingTag; } diff --git a/src/extensions/Object.ts b/src/extensions/Object.ts index 49927f1..129121b 100644 --- a/src/extensions/Object.ts +++ b/src/extensions/Object.ts @@ -5,7 +5,7 @@ interface ObjectConstructor { // Copied from mdn's Object.assign -Object._assign = function (target: any, varArg1: any, varArg2: any = null) { +Object._assign = function (target: any) { // TypeError if undefined or null if (target == null) { diff --git a/src/grouper/Grouper.ts b/src/grouper/Grouper.ts index 5291484..db8dea5 100644 --- a/src/grouper/Grouper.ts +++ b/src/grouper/Grouper.ts @@ -1,12 +1,10 @@ import { DeltaInsertOp } from './../DeltaInsertOp'; -import { NewLine } from './../value-types'; import './../extensions/Array'; import { - VideoItem, InlineGroup, BlockGroup, ListGroup, ListItem, TDataGroup + VideoItem, InlineGroup, BlockGroup, TDataGroup } from './group-types'; -import { ListNester } from './ListNester'; class Grouper { diff --git a/src/grouper/ListNester.ts b/src/grouper/ListNester.ts index d46b09d..640d181 100644 --- a/src/grouper/ListNester.ts +++ b/src/grouper/ListNester.ts @@ -1,12 +1,11 @@ import { - ListGroup, ListItem, BlockGroup, VideoItem, InlineGroup, TDataGroup + ListGroup, ListItem, BlockGroup, TDataGroup } from './group-types'; class ListNester { nest(groups: TDataGroup[]): TDataGroup[] { - var result: TDataGroup[] = []; var listBlocked = this.convertListBlocksToListGroups(groups); var groupedByListGroups = this.groupConsecutiveListGroups(listBlocked); diff --git a/test/DeltaInsertOp.test.ts b/test/DeltaInsertOp.test.ts index 4a22860..55e1d6d 100644 --- a/test/DeltaInsertOp.test.ts +++ b/test/DeltaInsertOp.test.ts @@ -2,7 +2,7 @@ import 'mocha'; import * as assert from "assert"; -import {InsertData, InsertDataQuill} from './../src/InsertData'; +import {InsertDataQuill} from './../src/InsertData'; import {DeltaInsertOp} from './../src/DeltaInsertOp'; import {DataType, AlignType, ListType} from './../src/value-types'; diff --git a/test/InsertData.test.ts b/test/InsertData.test.ts index be26d8b..cbe0477 100644 --- a/test/InsertData.test.ts +++ b/test/InsertData.test.ts @@ -2,7 +2,7 @@ import 'mocha'; import * as assert from "assert"; -import { InsertData, InsertDataQuill, InsertDataCustom } from './../src/InsertData'; +import {InsertDataQuill, InsertDataCustom } from './../src/InsertData'; import {DataType} from './../src/value-types'; describe('InsertData', function () { diff --git a/test/InsertOpDenormalizer.test.ts b/test/InsertOpDenormalizer.test.ts index 47ffb8f..7cabc51 100644 --- a/test/InsertOpDenormalizer.test.ts +++ b/test/InsertOpDenormalizer.test.ts @@ -2,8 +2,6 @@ import 'mocha'; import * as assert from 'assert'; -import {DeltaInsertOp} from './../src/DeltaInsertOp'; - import { InsertOpDenormalizer } from "./../src/InsertOpDenormalizer"; diff --git a/test/InsertOpsConverter.test.ts b/test/InsertOpsConverter.test.ts index d0827f8..a99c79b 100644 --- a/test/InsertOpsConverter.test.ts +++ b/test/InsertOpsConverter.test.ts @@ -3,7 +3,7 @@ import 'mocha'; import * as assert from 'assert'; import {DeltaInsertOp} from './../src/DeltaInsertOp'; -import {InsertData, InsertDataCustom, InsertDataQuill} from './../src/InsertData'; +import {InsertDataQuill} from './../src/InsertData'; import { InsertOpsConverter } from "./../src/InsertOpsConverter"; var data = [ @@ -69,7 +69,7 @@ describe('InsertOpsConverter', function () { assert.equal(act, null); }); - ["fdsf", {image: 'ff'}, {video: ''}, {formula: ''}].forEach((v, i) => { + ["fdsf", {image: 'ff'}, {video: ''}, {formula: ''}].forEach((v) => { var act = InsertOpsConverter.convertInsertVal(v); assert.notEqual(act, null); assert.ok(act instanceof InsertDataQuill); diff --git a/test/OpToHtmlConverter.test.ts b/test/OpToHtmlConverter.test.ts index 36020fa..7a90e79 100644 --- a/test/OpToHtmlConverter.test.ts +++ b/test/OpToHtmlConverter.test.ts @@ -1,8 +1,8 @@ import { OpToHtmlConverter } from "./../src/OpToHtmlConverter"; import { DeltaInsertOp } from './../src/DeltaInsertOp'; -import { InsertData, InsertDataQuill, InsertDataCustom } from './../src/InsertData'; -import { ListType, ScriptType, DirectionType, AlignType, DataType } from './../src/value-types'; +import { InsertDataQuill } from './../src/InsertData'; +import { ScriptType, DirectionType, AlignType, DataType } from './../src/value-types'; let assert = require('assert'); diff --git a/test/QuillDeltaToHtmlConverter.test.ts b/test/QuillDeltaToHtmlConverter.test.ts index 577200e..c0a908d 100644 --- a/test/QuillDeltaToHtmlConverter.test.ts +++ b/test/QuillDeltaToHtmlConverter.test.ts @@ -3,9 +3,8 @@ import 'mocha'; import * as assert from 'assert'; import { DeltaInsertOp } from './../src/DeltaInsertOp'; -import { OpToHtmlConverter } from './../src/OpToHtmlConverter'; import { QuillDeltaToHtmlConverter } from "./../src/QuillDeltaToHtmlConverter"; -import { callWhenAlltrue, callWhenXEqualY } from './_helper'; +import { callWhenXEqualY } from './_helper'; import { delta1 } from './data/delta1'; import { GroupType, ListType } from './../src/value-types'; @@ -154,7 +153,7 @@ describe('QuillDeltaToHtmlConverter', function () { { insert: { blah: 1 } } ]; let qdc = new QuillDeltaToHtmlConverter(ops); - qdc.renderCustomWith((op, ctx) => { + qdc.renderCustomWith((op) => { if (op.insert.type === 'bolditalic') { return '' + op.insert.value + ''; } @@ -173,7 +172,7 @@ describe('QuillDeltaToHtmlConverter', function () { { insert: { colonizer: ':' }}, { insert: "\n", attributes: { 'code-block': true } } ]; - let renderer = (op: DeltaInsertOp, ctx: DeltaInsertOp) => { + let renderer = (op: DeltaInsertOp) => { if (op.insert.type === 'colonizer') { return op.insert.value; } @@ -197,7 +196,7 @@ describe('QuillDeltaToHtmlConverter', function () { { insert: { colonizer: ':' }}, { insert: "\n", attributes: { header: 1 } } ]; - let renderer = (op: DeltaInsertOp, ctx: DeltaInsertOp) => { + let renderer = (op: DeltaInsertOp) => { if (op.insert.type === 'colonizer') { return op.insert.value; } @@ -444,7 +443,7 @@ describe('QuillDeltaToHtmlConverter', function () { ]; let status = {x:0, y: 3}; let qdc = new QuillDeltaToHtmlConverter(ops); - qdc.beforeRender((gtype: any, data: any) => { + qdc.beforeRender((gtype: any) => { gtype === 'block' && status.x++; return ''; }); @@ -464,7 +463,6 @@ describe('QuillDeltaToHtmlConverter', function () { }); it('should register and use callbacks if they are functions', function () { - var jobstatus = [false, false]; var c = new QuillDeltaToHtmlConverter([ { insert: { video: "http" } }, { insert: 'aa' }]); var dummy = (): any => ''; diff --git a/test/grouper/Grouper.test.ts b/test/grouper/Grouper.test.ts index c2b5c14..e4e2dfe 100644 --- a/test/grouper/Grouper.test.ts +++ b/test/grouper/Grouper.test.ts @@ -4,8 +4,8 @@ import * as assert from "assert"; import { Grouper } from './../../src/grouper/Grouper'; import { DeltaInsertOp } from './../../src/DeltaInsertOp'; -import { InsertData, InsertDataQuill } from './../../src/InsertData'; -import { ListGroup, ListItem, VideoItem, InlineGroup, BlockGroup, TDataGroup +import { InsertDataQuill } from './../../src/InsertData'; +import { VideoItem, InlineGroup, BlockGroup } from './../../src/grouper/group-types'; import {DataType} from './../../src/value-types'; describe('Grouper', function () { diff --git a/test/grouper/ListNester.test.ts b/test/grouper/ListNester.test.ts index 0f044b8..44b8264 100644 --- a/test/grouper/ListNester.test.ts +++ b/test/grouper/ListNester.test.ts @@ -5,8 +5,7 @@ import * as assert from "assert"; import { Grouper } from './../../src/grouper/Grouper'; import { ListNester } from './../../src/grouper/ListNester'; import { DeltaInsertOp } from './../../src/DeltaInsertOp'; -import { InsertData } from './../../src/InsertData'; -import { ListGroup, ListItem, VideoItem, InlineGroup, BlockGroup, TDataGroup +import { ListGroup, ListItem, InlineGroup, BlockGroup } from './../../src/grouper/group-types'; import {ListType} from './../../src/value-types'; diff --git a/test/mentions/MentionSanitizer.test.ts b/test/mentions/MentionSanitizer.test.ts index 9326389..fb7509d 100644 --- a/test/mentions/MentionSanitizer.test.ts +++ b/test/mentions/MentionSanitizer.test.ts @@ -2,7 +2,6 @@ import 'mocha'; import * as assert from 'assert'; import {MentionSanitizer} from "./../../src/mentions/MentionSanitizer"; -import { IMention } from '../../src/mentions/MentionSanitizer'; describe('MentionSanitizer', function () { diff --git a/tsconfig.json b/tsconfig.json index eb57d92..8374814 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,6 @@ { "compilerOptions": { "module": "commonjs", - "noImplicitAny": true, "removeComments": true, "preserveConstEnums": true, "sourceMap": false, @@ -16,8 +15,12 @@ ], "declaration": true, "noImplicitThis": true, + "noImplicitAny": true, "strictNullChecks": true, - "alwaysStrict": true + "alwaysStrict": true, + "noUnusedParameters": true, + "noUnusedLocals": true, + "noFallthroughCasesInSwitch": true }, "include": [ "src/**/*.ts"