Skip to content

Commit

Permalink
register dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
jhchen committed Apr 24, 2018
1 parent 608fd58 commit a307ad1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 22 deletions.
28 changes: 17 additions & 11 deletions formats/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,21 @@ import Cursor from '../blots/cursor';
import Inline from '../blots/inline';
import TextBlot from '../blots/text';
import Container from '../blots/container';
import Quill from '../core/quill';

class Code extends Inline {}
Code.blotName = 'code';
Code.tagName = 'CODE';
class CodeBlockContainer extends Container {
static create(value) {
const domNode = super.create(value);
domNode.setAttribute('spellcheck', false);
return domNode;
}
}

class CodeBlock extends Block {
static register() {
Quill.register(CodeBlockContainer);
}

delta() {
if (this.cache.delta == null) {
this.cache.delta = new Delta()
Expand All @@ -20,17 +29,14 @@ class CodeBlock extends Block {
return this.cache.delta;
}
}

class Code extends Inline {}
Code.blotName = 'code';
Code.tagName = 'CODE';

CodeBlock.blotName = 'code-block';
CodeBlock.className = 'ql-code-block';
CodeBlock.tagName = 'DIV';

class CodeBlockContainer extends Container {
static create(value) {
const domNode = super.create(value);
domNode.setAttribute('spellcheck', false);
return domNode;
}
}
CodeBlockContainer.blotName = 'code-block-container';
CodeBlockContainer.className = 'ql-code-block-container';
CodeBlockContainer.tagName = 'DIV';
Expand Down
13 changes: 9 additions & 4 deletions formats/list.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import Block from '../blots/block';
import Container from '../blots/container';
import Quill from '../core/quill';

class ListContainer extends Container {}
ListContainer.blotName = 'list-container';
ListContainer.tagName = 'OL';

class ListItem extends Block {
static create(value) {
Expand All @@ -12,6 +17,10 @@ class ListItem extends Block {
return domNode.getAttribute('data-list') || undefined;
}

static register() {
Quill.register(ListContainer);
}

constructor(domNode) {
super(domNode);
const listEventHandler = e => {
Expand All @@ -38,10 +47,6 @@ class ListItem extends Block {
ListItem.blotName = 'list';
ListItem.tagName = 'LI';

class ListContainer extends Container {}
ListContainer.blotName = 'list-container';
ListContainer.tagName = 'OL';

ListContainer.allowedChildren = [ListItem];
ListItem.requiredContainer = ListContainer;

Expand Down
2 changes: 2 additions & 0 deletions modules/syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class SyntaxCodeBlock extends CodeBlock {
return domNode.getAttribute('data-language') || 'plain';
}

static register() {} // Syntax module will register

format(name, value) {
if (name !== this.statics.blotName) return;
if (value) {
Expand Down
9 changes: 2 additions & 7 deletions quill.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import Indent from './formats/indent';

import Blockquote from './formats/blockquote';
import Header from './formats/header';
import List, { ListContainer } from './formats/list';
import {
TableContainer,
TableBody,
TableRow,
TableCell,
} from './formats/table';
import List from './formats/list';

import { BackgroundClass, BackgroundStyle } from './formats/background';
import { ColorClass, ColorStyle } from './formats/color';
Expand All @@ -34,10 +34,7 @@ import Formula from './formats/formula';
import Image from './formats/image';
import Video from './formats/video';

import CodeBlock, {
CodeBlockContainer,
Code as InlineCode,
} from './formats/code';
import CodeBlock, { Code as InlineCode } from './formats/code';

import Syntax from './modules/syntax';
import Toolbar from './modules/toolbar';
Expand Down Expand Up @@ -74,8 +71,6 @@ Quill.register(

Quill.register(
{
'blots/code-block-container': CodeBlockContainer,
'blots/list-container': ListContainer,
'blots/table-container': TableContainer,
'blots/table-body': TableBody,
'blots/table-row': TableRow,
Expand Down

0 comments on commit a307ad1

Please sign in to comment.