mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-22 15:02:51 +02:00
tagName returns capitalized name now (#985)
This commit is contained in:
committed by
Ian Storm Taylor
parent
979dadf2d6
commit
17cd478fad
@@ -54,7 +54,7 @@ const rules = [
|
|||||||
// Add our first rule with a deserializing function.
|
// Add our first rule with a deserializing function.
|
||||||
{
|
{
|
||||||
deserialize(el, next) {
|
deserialize(el, next) {
|
||||||
if (el.tagName == 'p') {
|
if (el.tagName == 'P') {
|
||||||
return {
|
return {
|
||||||
kind: 'block',
|
kind: 'block',
|
||||||
type: 'paragraph',
|
type: 'paragraph',
|
||||||
@@ -76,7 +76,7 @@ Okay, that's `deserialize`, now let's define the `serialize` property of the par
|
|||||||
const rules = [
|
const rules = [
|
||||||
{
|
{
|
||||||
deserialize(el, next) {
|
deserialize(el, next) {
|
||||||
if (el.tagName == 'p') {
|
if (el.tagName == 'P') {
|
||||||
return {
|
return {
|
||||||
kind: 'block',
|
kind: 'block',
|
||||||
type: 'paragraph',
|
type: 'paragraph',
|
||||||
@@ -105,9 +105,9 @@ Let's add the other types of blocks we want:
|
|||||||
```js
|
```js
|
||||||
// Refactor block tags into a dictionary for cleanliness.
|
// Refactor block tags into a dictionary for cleanliness.
|
||||||
const BLOCK_TAGS = {
|
const BLOCK_TAGS = {
|
||||||
p: 'paragraph',
|
P: 'paragraph',
|
||||||
blockquote: 'quote',
|
BLOCKQUOTE: 'quote',
|
||||||
pre: 'code'
|
PRE: 'code'
|
||||||
}
|
}
|
||||||
|
|
||||||
const rules = [
|
const rules = [
|
||||||
@@ -144,16 +144,16 @@ Okay. So now our serializer can handle blocks, but we need to add our marks to i
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
const BLOCK_TAGS = {
|
const BLOCK_TAGS = {
|
||||||
blockquote: 'quote',
|
BLOCKQUOTE: 'quote',
|
||||||
p: 'paragraph',
|
P: 'paragraph',
|
||||||
pre: 'code'
|
PRE: 'code'
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a dictionary of mark tags.
|
// Add a dictionary of mark tags.
|
||||||
const MARK_TAGS = {
|
const MARK_TAGS = {
|
||||||
em: 'italic',
|
EM: 'italic',
|
||||||
strong: 'bold',
|
STRONG: 'bold',
|
||||||
u: 'underline',
|
U: 'underline',
|
||||||
}
|
}
|
||||||
|
|
||||||
const rules = [
|
const rules = [
|
||||||
|
Reference in New Issue
Block a user