Skip to content

Commit

Permalink
Remove unused parts
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry.levkovskiy committed Aug 31, 2020
1 parent 1811d5c commit 0e9f239
Show file tree
Hide file tree
Showing 19 changed files with 10 additions and 992 deletions.
17 changes: 1 addition & 16 deletions _develop/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ const source = [
'formats',
'modules',
'test',
'themes',
'ui',
].map(file => {
return path.resolve(__dirname, '..', file);
});
Expand All @@ -54,19 +52,6 @@ const jsRules = {
use: [babelLoader],
};

const svgRules = {
test: /\.svg$/,
include: [path.resolve(__dirname, '../assets/icons')],
use: [
{
loader: 'html-loader',
options: {
minimize: true,
},
},
],
};

const stylRules = {
test: /\.styl$/,
include: [path.resolve(__dirname, '../assets')],
Expand Down Expand Up @@ -120,7 +105,7 @@ const baseConfig = {
extensions: ['.js', '.styl', '.ts'],
},
module: {
rules: [jsRules, stylRules, svgRules, tsRules],
rules: [jsRules, stylRules, tsRules],
noParse: [
/\/node_modules\/clone\/clone\.js$/,
/\/node_modules\/eventemitter3\/index\.js$/,
Expand Down
2 changes: 1 addition & 1 deletion core/quill.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Quill {
}
this.imports[path] = target;
if (
(path.startsWith('blots/') || path.startsWith('formats/')) &&
(path.indexOf('blots/') === 0 || path.indexOf('formats/') === 0) &&
target.blotName !== 'abstract'
) {
globalRegistry.register(target);
Expand Down
2 changes: 1 addition & 1 deletion formats/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ClassAttributor, Scope, StyleAttributor } from 'parchment';
class ColorAttributor extends StyleAttributor {
value(domNode) {
let value = super.value(domNode);
if (!value.startsWith('rgb(')) return value;
if (value.indexOf('rgb(') !== 0) return value;
value = value.replace(/^[^\d]+/, '').replace(/[^\d]+$/, '');
const hex = value
.split(',')
Expand Down
2 changes: 1 addition & 1 deletion modules/clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ function matchStyles(node, delta) {
formats.strike = true;
}
if (
style.fontWeight.startsWith('bold') ||
style.fontWeight.indexOf('bold') === 0 ||
parseInt(style.fontWeight, 10) >= 700
) {
formats.bold = true;
Expand Down
2 changes: 1 addition & 1 deletion modules/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ function makeCodeBlockHandler(indent) {
} else {
length += CodeBlock.TAB.length;
}
} else if (line.domNode.textContent.startsWith(CodeBlock.TAB)) {
} else if (line.domNode.textContent.indexOf(CodeBlock.TAB) === 0) {
line.deleteAt(0, CodeBlock.TAB.length);
if (i === 0) {
index -= CodeBlock.TAB.length;
Expand Down
9 changes: 2 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,16 @@
"homepage": "https://js.devexpress.com/",
"main": "dist/quill.js",
"files": [
"assets",
"blots",
"core",
"formats",
"modules",
"themes",
"ui",
"dist/quill.bubble.css",
"dist/quill.snow.css",
"dist/quill.core.css",
"dist/quill.js",
"dist/quill.core.js",
"dist/quill.min.js.map",
"dist/quill.min.js",
"core.js",
"polyfills.js",
"quill.js"
],
"config": {
Expand Down Expand Up @@ -157,7 +152,7 @@
"build:webpack-min": "webpack --config _develop/webpack.config.js --env.minimize && rimraf dist/quill.core dist/quill.bubble dist/quill.snow",
"build:release": "./_develop/scripts/release.sh",
"develop": "npm run start",
"lint": "eslint blots core formats modules themes ui test",
"lint": "eslint blots core formats modules test",
"start": "npm run build:webpack && bundle exec foreman start -f _develop/procfile",
"test": "npm run test:unit",
"test:all": "npm run test:unit && npm run test:functional",
Expand Down
1 change: 0 additions & 1 deletion polyfills.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// IE11 support
import 'core-js/features/array/from';
import 'core-js/features/string/starts-with';
import 'core-js/features/string/ends-with';
20 changes: 0 additions & 20 deletions quill.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@ import CodeBlock, { Code as InlineCode } from './formats/code';

import Syntax from './modules/syntax';
import Table from './modules/table';
import Toolbar from './modules/toolbar';

import Icons from './ui/icons';
import Picker from './ui/picker';
import ColorPicker from './ui/color-picker';
import IconPicker from './ui/icon-picker';
import Tooltip from './ui/tooltip';

import BubbleTheme from './themes/bubble';
import SnowTheme from './themes/snow';

Quill.register(
{
Expand Down Expand Up @@ -95,16 +85,6 @@ Quill.register(

'modules/syntax': Syntax,
'modules/table': Table,
'modules/toolbar': Toolbar,

'themes/bubble': BubbleTheme,
'themes/snow': SnowTheme,

'ui/icons': Icons,
'ui/picker': Picker,
'ui/icon-picker': IconPicker,
'ui/color-picker': ColorPicker,
'ui/tooltip': Tooltip,
},
true,
);
Expand Down
4 changes: 0 additions & 4 deletions test/unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ import './unit/modules/history';
import './unit/modules/keyboard';
import './unit/modules/syntax';
import './unit/modules/table';
import './unit/modules/toolbar';

import './unit/ui/picker';
import './unit/theme/base/tooltip';

// Syntax version will otherwise be registered
Quill.register(CodeBlockContainer, true);
Expand Down
144 changes: 0 additions & 144 deletions test/unit/core/quill.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import Delta from 'quill-delta';
import Quill, { expandConfig, overload } from '../../../core/quill';
import Theme from '../../../core/theme';
import Emitter from '../../../core/emitter';
import Toolbar from '../../../modules/toolbar';
import Snow from '../../../themes/snow';
import { Range } from '../../../core/selection';

describe('Quill', function() {
Expand Down Expand Up @@ -526,148 +524,6 @@ describe('Quill', function() {
});
Theme.DEFAULTS.modules = oldModules;
});

describe('theme defaults', function() {
it('for Snow', function() {
const config = expandConfig('#test-container', {
modules: {
toolbar: true,
},
theme: 'snow',
});
expect(config.theme).toEqual(Snow);
expect(config.modules.toolbar.handlers.image).toEqual(
Snow.DEFAULTS.modules.toolbar.handlers.image,
);
});

it('for false', function() {
const config = expandConfig('#test-container', {
theme: false,
});
expect(config.theme).toEqual(Theme);
});

it('for undefined', function() {
const config = expandConfig('#test-container', {
theme: undefined,
});
expect(config.theme).toEqual(Theme);
});

it('for null', function() {
const config = expandConfig('#test-container', {
theme: null,
});
expect(config.theme).toEqual(Theme);
});
});

it('quill < module < theme < user', function() {
const oldTheme = Theme.DEFAULTS.modules;
const oldToolbar = Toolbar.DEFAULTS;
Toolbar.DEFAULTS = {
option: 2,
module: true,
};
Theme.DEFAULTS.modules = {
toolbar: {
option: 1,
theme: true,
},
};
const config = expandConfig('#test-container', {
modules: {
toolbar: {
option: 0,
user: true,
},
},
});
expect(config.modules.toolbar).toEqual({
option: 0,
module: true,
theme: true,
user: true,
});
Theme.DEFAULTS.modules = oldTheme;
Toolbar.DEFAULTS = oldToolbar;
});

it('toolbar default', function() {
const config = expandConfig('#test-container', {
modules: {
toolbar: true,
},
});
expect(config.modules.toolbar).toEqual(Toolbar.DEFAULTS);
});

it('toolbar disabled', function() {
const config = expandConfig('#test-container', {
modules: {
toolbar: false,
},
theme: 'snow',
});
expect(config.modules.toolbar).toBe(undefined);
});

it('toolbar selector', function() {
const config = expandConfig('#test-container', {
modules: {
toolbar: {
container: '#test-container',
},
},
});
expect(config.modules.toolbar).toEqual({
container: '#test-container',
handlers: Toolbar.DEFAULTS.handlers,
});
});

it('toolbar container shorthand', function() {
const config = expandConfig('#test-container', {
modules: {
toolbar: document.querySelector('#test-container'),
},
});
expect(config.modules.toolbar).toEqual({
container: document.querySelector('#test-container'),
handlers: Toolbar.DEFAULTS.handlers,
});
});

it('toolbar format array', function() {
const config = expandConfig('#test-container', {
modules: {
toolbar: ['bold'],
},
});
expect(config.modules.toolbar).toEqual({
container: ['bold'],
handlers: Toolbar.DEFAULTS.handlers,
});
});

it('toolbar custom handler, default container', function() {
const handler = function() {}; // eslint-disable-line func-style
const config = expandConfig('#test-container', {
modules: {
toolbar: {
handlers: {
bold: handler,
},
},
},
});
expect(config.modules.toolbar.container).toEqual(null);
expect(config.modules.toolbar.handlers.bold).toEqual(handler);
expect(config.modules.toolbar.handlers.clean).toEqual(
Toolbar.DEFAULTS.handlers.clean,
);
});
});

describe('overload', function() {
Expand Down
Loading

0 comments on commit 0e9f239

Please sign in to comment.