rename HTML function names

This commit is contained in:
Hans Pagel 2020-10-28 17:20:38 +01:00
parent 4af6049792
commit 4dad818f7d
9 changed files with 21 additions and 21 deletions

View File

@ -6,8 +6,8 @@
</template>
<script>
import { generateHtml } from '@tiptap/core'
import { generateHtml as generateHtmlWithoutEditor } from '@tiptap/html'
import { generateHTML } from '@tiptap/core'
import { generateHTML as generateHTMLWithoutEditor } from '@tiptap/html'
import Document from '@tiptap/extension-document'
import Paragraph from '@tiptap/extension-paragraph'
import Text from '@tiptap/extension-text'
@ -31,13 +31,13 @@ export default {
},
mounted() {
this.html = generateHtml(this.json, [
this.html = generateHTML(this.json, [
Document(),
Paragraph(),
Text(),
])
this.otherHtml = generateHtmlWithoutEditor(this.json, [
this.otherHtml = generateHTMLWithoutEditor(this.json, [
Document(),
Paragraph(),
Text(),

View File

@ -15,7 +15,7 @@ export { default as markPasteRule } from './src/pasteRules/markPasteRule'
export { default as capitalize } from './src/utils/capitalize'
export { default as getSchema } from './src/utils/getSchema'
export { default as generateHtml } from './src/utils/generateHtml'
export { default as getHtmlFromFragment } from './src/utils/getHtmlFromFragment'
export { default as generateHTML } from './src/utils/generateHTML'
export { default as getHTMLFromFragment } from './src/utils/getHTMLFromFragment'
export { default as getMarkAttrs } from './src/utils/getMarkAttrs'
export { default as mergeAttributes } from './src/utils/mergeAttributes'

View File

@ -9,7 +9,7 @@ import getNodeAttrs from './utils/getNodeAttrs'
import getMarkAttrs from './utils/getMarkAttrs'
import removeElement from './utils/removeElement'
import getSchemaTypeNameByName from './utils/getSchemaTypeNameByName'
import getHtmlFromFragment from './utils/getHtmlFromFragment'
import getHTMLFromFragment from './utils/getHTMLFromFragment'
import createStyleTag from './utils/createStyleTag'
import CommandManager from './CommandManager'
import ExtensionManager from './ExtensionManager'
@ -384,7 +384,7 @@ export class Editor extends EventEmitter {
* Get the document as HTML.
*/
public getHTML() {
return getHtmlFromFragment(this.state.doc, this.schema)
return getHTMLFromFragment(this.state.doc, this.schema)
}
/**

View File

@ -1,11 +1,11 @@
import { Node } from 'prosemirror-model'
import getSchema from './getSchema'
import getHtmlFromFragment from './getHtmlFromFragment'
import getHTMLFromFragment from './getHTMLFromFragment'
import { Extensions } from '../types'
export default function generateHtml(doc: object, extensions: Extensions): string {
export default function generateHTML(doc: object, extensions: Extensions): string {
const schema = getSchema(extensions)
const contentNode = Node.fromJSON(schema, doc)
return getHtmlFromFragment(contentNode, schema)
return getHTMLFromFragment(contentNode, schema)
}

View File

@ -1,6 +1,6 @@
import { Node, DOMSerializer, Schema } from 'prosemirror-model'
export default function getHtmlFromFragment(doc: Node, schema: Schema): string {
export default function getHTMLFromFragment(doc: Node, schema: Schema): string {
const fragment = DOMSerializer
.fromSchema(schema)
.serializeFragment(doc.content)

View File

@ -1,11 +1,11 @@
import { generateHtml } from '@tiptap/html'
import { generateHTML } from '@tiptap/html'
import Document from '@tiptap/extension-document'
import Paragraph from '@tiptap/extension-paragraph'
import Text from '@tiptap/extension-text'
// eslint-disable-next-line
const html = generateHtml({
const html = generateHTML({
type: 'document',
content: [{
type: 'paragraph',

View File

@ -2,7 +2,7 @@ import { Node, DOMSerializer, Schema } from 'prosemirror-model'
// @ts-ignore
import { createHTMLDocument } from 'hostic-dom'
export default function getHtmlFromFragment(doc: Node, schema: Schema): string {
export default function getHTMLFromFragment(doc: Node, schema: Schema): string {
return DOMSerializer
.fromSchema(schema)
.serializeFragment(doc.content, {

View File

@ -1,10 +1,10 @@
import { Extensions, getSchema } from '@tiptap/core'
import { Node } from 'prosemirror-model'
import getHtmlFromFragment from './getHtmlFromFragment'
import getHTMLFromFragment from './getHTMLFromFragment'
export function generateHtml(doc: object, extensions: Extensions): string {
export function generateHTML(doc: object, extensions: Extensions): string {
const schema = getSchema(extensions)
const contentNode = Node.fromJSON(schema, doc)
return getHtmlFromFragment(contentNode, schema)
return getHTMLFromFragment(contentNode, schema)
}

View File

@ -1,11 +1,11 @@
/// <reference types="cypress" />
import generateHtml from '@tiptap/html'
import { generateHTML } from '@tiptap/html'
import Document from '@tiptap/extension-document'
import Paragraph from '@tiptap/extension-paragraph'
import Text from '@tiptap/extension-text'
describe('generateHtml', () => {
describe('generateHTML', () => {
it('generate HTML from JSON without an editor instance', () => {
const json = {
type: 'document',
@ -18,7 +18,7 @@ describe('generateHtml', () => {
}],
}
const html = generateHtml(json, [
const html = generateHTML(json, [
Document(),
Paragraph(),
Text(),