add mooore content

This commit is contained in:
Hans Pagel
2020-10-05 14:56:45 +02:00
parent a52f95a770
commit 2d82e4e1a7
13 changed files with 80 additions and 40 deletions

View File

@@ -1,6 +1,5 @@
<template>
<div>
BUG: Headings cant be transformed to a bullet or ordered list.
<div v-if="editor">
<button @click="editor.chain().focus().bold().run()" :class="{ 'is-active': editor.isActive('bold') }">
bold
@@ -89,25 +88,24 @@ export default {
Hi there,
</h2>
<p>
this is a basic <em>basic</em> example of <strong>tiptap</strong>. Sure, there are all kind of basic text styles youd probably expect from a text editor. But wait until you see the bullet lists:
this is a basic <em>basic</em> example of <strong>tiptap</strong>. Sure, there are all kind of basic text styles youd probably expect from a text editor. But wait until you see the lists:
</p>
<ul>
<li>
With one …
Thats a bullet list with one …
</li>
<li>
… or two list items.
</li>
<li>
And yes, even more.
</li>
</ul>
<p>
Isnt that great? But wait, theres more. Lets try a code block:
Isnt that great? And all of that is editable. But wait, theres more. Lets try a code block:
</p>
<pre><code class="language-css">body { display: none; }</code></pre>
<pre><code class="language-css">body {
display: none;
}</code></pre>
<p>
I know, I know, its impressive. Give it a try and click a little bit around. But dont forget to check the other examples too.
I know, I know, this is impressive. Its only the tip of the iceberg though. Give it a try and click a little bit around. Dont forget to check the other examples too.
</p>
<blockquote>
Wow, thats amazing. Good work, boy! 👏

View File

@@ -1,12 +1,12 @@
<template>
<div>
<div class="actions">
<button class="button" @click="clearContent">
Clear Content
</button>
<button class="button" @click="setContent">
Set Content
</button>
<button class="button" @click="clearContent">
Clear Content
</button>
</div>
<editor-content :editor="editor" />
@@ -61,11 +61,6 @@ export default {
},
methods: {
clearContent() {
this.editor.clearContent(true)
this.editor.focus()
},
setContent() {
// You can pass a JSON document …
this.editor.setContent({
@@ -87,6 +82,11 @@ export default {
// Its likely that youd like to focus the Editor after most commands.
this.editor.focus()
},
clearContent() {
this.editor.clearContent(true)
this.editor.focus()
},
},
beforeDestroy() {

View File

@@ -10,6 +10,8 @@ import Document from '@tiptap/extension-document'
import Paragraph from '@tiptap/extension-paragraph'
import Text from '@tiptap/extension-text'
import Code from '@tiptap/extension-code'
import BulletList from '@tiptap/extension-bullet-list'
import ListItem from '@tiptap/extension-list-item'
import Focus from '@tiptap/extension-focus'
export default {
@@ -30,6 +32,8 @@ export default {
Paragraph(),
Text(),
Code(),
BulletList(),
ListItem(),
Focus({
className: 'has-focus',
nested: true,
@@ -38,12 +42,11 @@ export default {
autoFocus: true,
content: `
<p>
The focus extension adds custom classes to focused nodes. By default, itll add a <code>has-focus</code> class, even to nested nodes:
The focus extension adds a class to the focused node only. That enables you to add a custom styling to just that node. By default, itll add <code>.has-focus</code>, even to nested nodes.
</p>
<pre><code>{ className: 'has-focus', nested: true }</code></pre>
<ul>
<li>With <code>nested: true</code> nested elements like this list item will be focused.</li>
<li>Otherwise the whole list will get the focus class, even if only a single list item is selected.</li>
<li>Nested elements (like this list item) will be focused with the default setting of <code>nested: true</code>.</li>
<li>Otherwise the whole list will get the focus class, even when just a single list item is selected.</li>
</ul>
`,
})

View File

@@ -39,10 +39,13 @@ export default {
],
content: `
<p>
Wow, this editor has support for links to the whole <a href="https://en.wikipedia.org/wiki/World_Wide_Web" target="_self">world wide web</a>. We tested a lot of URLs and I think you can add *every URL* you want. Isnt that cool? Lets try <a href="https://statamic.com/" target="_self">another one!</a> Yep, seems to work.
Wow, this editor has support for links to the whole <a href="https://en.wikipedia.org/wiki/World_Wide_Web">world wide web</a>. We tested a lot of URLs and I think you can add *every URL* you want. Isnt that cool? Lets try <a href="https://statamic.com/">another one!</a> Yep, seems to work.
</p>
<p>
By default every link will get a \`rel="noopener noreferrer nofollow"\` attribute. Its configurable though.
By default every link will get a [rel="noopener noreferrer nofollow"] attribute <a href="https://web.dev/external-anchors-use-rel-noopener/">for security reasons</a>. Its configurable though.
</p>
<p>
Ah, and links open in a new tab by default, but thats also - yes, youve guessed it - configurable.
</p>
`,
})

View File

@@ -21,19 +21,19 @@ export default {
mounted() {
this.editor = new Editor({
content: `
<p>
This is a radically reduced version of tiptap. It has only support for a document, paragraphs and text. Thats it. Its probably too much for real minimalists though.
</p>
<p>
The paragraph extension is not literally required, but you need at least one node. That node can be something different, for example to render a task list and only that task list.
</p>
`,
extensions: [
Document(),
Paragraph(),
Text(),
],
content: `
<p>
This is a radically reduced version of tiptap. It has only support for a document, paragraphs and text. Thats it. Its probably too much for real minimalists though.
</p>
<p>
The paragraph extension is not really required, but you need at least one node. Sure, that node can be something different. Youll mostly likely want to add a paragraph though.
</p>
`,
})
},

View File

@@ -28,7 +28,10 @@ export default {
editable: this.editable,
content: `
<p>
This text is <strong>read-only</strong>. You are not able to edit something. <a href="https://ueber.io/">Links to fancy websites</a> are still working.
This text is <strong>read-only</strong>. No matter what you try, you are not able to edit something. Okay, if you toggle the checkbox above youll be able to edit the text.
</p>
<p>
If you want to check the state, you can call <code>editor.isEditable()</code>.
</p>
`,
extensions: defaultExtensions(),
@@ -60,5 +63,6 @@ export default {
[contenteditable=false] {
color: #999;
cursor: not-allowed;
}
</style>