improve the drawing example
This commit is contained in:
@@ -9,6 +9,9 @@
|
|||||||
border-bottom-width: 0;
|
border-bottom-width: 0;
|
||||||
color: $colorBlack;
|
color: $colorBlack;
|
||||||
background-color: $colorWhite;
|
background-color: $colorWhite;
|
||||||
|
max-height: 50rem;
|
||||||
|
overflow: auto;
|
||||||
|
scroll-behavior: smooth;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__source {
|
&__source {
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ import { v4 as uuid } from 'uuid'
|
|||||||
import * as d3 from 'd3'
|
import * as d3 from 'd3'
|
||||||
import simplify from 'simplify-js'
|
import simplify from 'simplify-js'
|
||||||
|
|
||||||
|
const getRandomElement = list => {
|
||||||
|
return list[Math.floor(Math.random() * list.length)]
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Paper',
|
name: 'Paper',
|
||||||
|
|
||||||
@@ -47,8 +51,16 @@ export default {
|
|||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
color: '#000000',
|
color: getRandomElement([
|
||||||
size: 2,
|
'#A975FF',
|
||||||
|
'#FB5151',
|
||||||
|
'#FD9170',
|
||||||
|
'#FFCB6B',
|
||||||
|
'#68CEF8',
|
||||||
|
'#80CBC4',
|
||||||
|
'#9DEF8F',
|
||||||
|
]),
|
||||||
|
size: Math.floor(Math.random() * Math.floor(20)),
|
||||||
svg: null,
|
svg: null,
|
||||||
path: null,
|
path: null,
|
||||||
points: [],
|
points: [],
|
||||||
@@ -148,7 +160,7 @@ export default {
|
|||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.draw {
|
.draw {
|
||||||
svg {
|
svg {
|
||||||
background: #EEE;
|
background: #f1f3f5;
|
||||||
cursor: crosshair;
|
cursor: crosshair;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,13 @@
|
|||||||
# Drawing
|
# Drawing
|
||||||
|
|
||||||
<demo name="Examples/Drawing" inline />
|
Did you ever wanted to draw in a text editor? Me neither. Anyway, here is an example how that could work with tiptap. If you want to build something like that, [learn more about node views](/guide/node-views).
|
||||||
|
|
||||||
|
:::warning Shared Document
|
||||||
|
Be nice! The content of this editor is shared with other users from the Internet.
|
||||||
|
:::
|
||||||
|
|
||||||
|
<demo name="Examples/Drawing" :show-source="false" />
|
||||||
|
|
||||||
|
Here is another instance of that demo, to illustrate how changes can be synced. Be nice, those changes are synced to all users on this page. Open another tab to test that out!
|
||||||
|
|
||||||
<demo name="Examples/Drawing" />
|
<demo name="Examples/Drawing" />
|
||||||
|
|||||||
@@ -28,12 +28,10 @@
|
|||||||
link: /examples/todo-app
|
link: /examples/todo-app
|
||||||
- title: Write a book
|
- title: Write a book
|
||||||
link: /examples/book
|
link: /examples/book
|
||||||
draft: true
|
|
||||||
- title: For minimalists
|
- title: For minimalists
|
||||||
link: /examples/minimalist
|
link: /examples/minimalist
|
||||||
- title: Drawing
|
- title: Drawing
|
||||||
link: /examples/drawing
|
link: /examples/drawing
|
||||||
draft: true
|
|
||||||
- title: Multiple editors
|
- title: Multiple editors
|
||||||
link: /examples/multiple-editors
|
link: /examples/multiple-editors
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user