add styles to examples, add content to the typescript page

This commit is contained in:
Hans Pagel 2020-11-13 15:46:55 +01:00
parent 1f30ea271b
commit 8f00a09b76
10 changed files with 298 additions and 37 deletions

View File

@ -124,3 +124,50 @@ export default {
}, },
} }
</script> </script>
<style lang="scss">
/* Basic editor styles */
.ProseMirror {
> * + * {
margin-top: 0.75em;
}
ul,
ol {
padding: 0 1rem;
}
code {
background-color: rgba(#616161, 0.1);
color: #616161;
}
pre {
background: #0D0D0D;
color: #FFF;
font-family: 'JetBrainsMono', monospace;
padding: 0.75rem 1rem;
border-radius: 0.5rem;
code {
color: inherit;
background: none;
font-size: 0.8rem;
}
}
img {
max-width: 100%;
height: auto;
}
hr {
margin: 1rem 0;
}
blockquote {
padding-left: 1rem;
border-left: 2px solid rgba(#0D0D0D, 0.1);
}
}
</style>

View File

@ -281,4 +281,49 @@ export default {
border-radius: 3px; border-radius: 3px;
white-space: nowrap; white-space: nowrap;
} }
/* Basic editor styles */
.ProseMirror {
> * + * {
margin-top: 0.75em;
}
ul,
ol {
padding: 0 1rem;
}
code {
background-color: rgba(#616161, 0.1);
color: #616161;
}
pre {
background: #0D0D0D;
color: #FFF;
font-family: 'JetBrainsMono', monospace;
padding: 0.75rem 1rem;
border-radius: 0.5rem;
code {
color: inherit;
background: none;
font-size: 0.8rem;
}
}
img {
max-width: 100%;
height: auto;
}
hr {
margin: 1rem 0;
}
blockquote {
padding-left: 1rem;
border-left: 2px solid rgba(#0D0D0D, 0.1);
}
}
</style> </style>

View File

@ -105,6 +105,7 @@ export default {
</script> </script>
<style lang="scss"> <style lang="scss">
/* Style the export */
.export { .export {
padding: 1rem 0 0; padding: 1rem 0 0;
@ -126,4 +127,49 @@ export default {
color: #495057; color: #495057;
} }
} }
/* Basic editor styles */
.ProseMirror {
> * + * {
margin-top: 0.75em;
}
ul,
ol {
padding: 0 1rem;
}
code {
background-color: rgba(#616161, 0.1);
color: #616161;
}
pre {
background: #0D0D0D;
color: #FFF;
font-family: 'JetBrainsMono', monospace;
padding: 0.75rem 1rem;
border-radius: 0.5rem;
code {
color: inherit;
background: none;
font-size: 0.8rem;
}
}
img {
max-width: 100%;
height: auto;
}
hr {
margin: 1rem 0;
}
blockquote {
padding-left: 1rem;
border-left: 2px solid rgba(#0D0D0D, 0.1);
}
}
</style> </style>

View File

@ -64,3 +64,17 @@ export default {
}, },
} }
</script> </script>
<style lang="scss">
/* Basic editor styles */
.ProseMirror {
> * + * {
margin-top: 0.75em;
}
a {
text-decoration: underline;
color: blue;
}
}
</style>

View File

@ -6,6 +6,8 @@
<script> <script>
import { Editor, EditorContent, defaultExtensions } from '@tiptap/vue-starter-kit' import { Editor, EditorContent, defaultExtensions } from '@tiptap/vue-starter-kit'
import Strike from '@tiptap/extension-strike'
import Highlight from '@tiptap/extension-highlight'
export default { export default {
components: { components: {
@ -28,10 +30,16 @@ export default {
To test that, start a new line and type <code>#</code> followed by a space to get a heading. Try <code>#</code>, <code>##</code>, <code>###</code>, <code>####</code>, <code>#####</code>, <code>######</code> for different levels. To test that, start a new line and type <code>#</code> followed by a space to get a heading. Try <code>#</code>, <code>##</code>, <code>###</code>, <code>####</code>, <code>#####</code>, <code>######</code> for different levels.
</p> </p>
<p> <p>
Those conventions are called input rules in tiptap. Some of them are enabled by default. Try <code>></code> for blockquotes, <code>*</code>, <code>-</code> or <code>+</code> for bullet lists, or <code>\`foobar\`</code> to highlight code. You can add your own input rules to existing extensions, and to your custom nodes and marks. Those conventions are called input rules in tiptap. Some of them are enabled by default. Try <code>></code> for blockquotes, <code>*</code>, <code>-</code> or <code>+</code> for bullet lists, or <code>\`foobar\`</code> to highlight code, <code>~~tildes~~</code> to strike text, or <code>==equal signs==</code> to highlight text.
</p>
<p>
You can overwrite existing input rules or add your own to new nodes and marks.
</p> </p>
`, `,
extensions: defaultExtensions(), extensions: [
...defaultExtensions(),
Highlight(),
],
}) })
}, },
@ -40,3 +48,50 @@ export default {
}, },
} }
</script> </script>
<style lang="scss">
/* Basic editor styles */
.ProseMirror {
> * + * {
margin-top: 0.75em;
}
ul,
ol {
padding: 0 1rem;
}
code {
background-color: rgba(#616161, 0.1);
color: #616161;
}
pre {
background: #0D0D0D;
color: #FFF;
font-family: 'JetBrainsMono', monospace;
padding: 0.75rem 1rem;
border-radius: 0.5rem;
code {
color: inherit;
background: none;
font-size: 0.8rem;
}
}
img {
max-width: 100%;
height: auto;
}
hr {
margin: 1rem 0;
}
blockquote {
padding-left: 1rem;
border-left: 2px solid rgba(#0D0D0D, 0.1);
}
}
</style>

View File

@ -42,3 +42,12 @@ export default {
}, },
} }
</script> </script>
<style lang="scss">
/* Basic editor styles */
.ProseMirror {
> * + * {
margin-top: 0.75em;
}
}
</style>

View File

@ -53,6 +53,13 @@ export default {
</script> </script>
<style lang="scss"> <style lang="scss">
/* Basic editor styles */
.ProseMirror {
> * + * {
margin-top: 0.75em;
}
}
.checkbox { .checkbox {
margin-bottom: 1rem; margin-bottom: 1rem;

View File

@ -3,10 +3,49 @@
## toc ## toc
## Introduction ## Introduction
The whole tiptap is code base is written in TypeScript. If you havent heard of it or never used it, no worries. You dont have to.
TypeScript extends JavaScript by adding types (hence the name). It adds new syntax, which doesnt exist in plain JavaScript. Its actually removed before running in the browser, but this step the compilation is important to find bugs early. It checks if you passe the right types of data to functions. For a big and complex project, thats very valuable. It means well get notified of lot of bugs, before shipping code to you.
Anyway, if you dont use TypeScript in your project, thats fine. Youll still be able to use tiptap and even get a really nice autocomplete for the tiptap API (if your editor supports it, but most do).
If youre using TypeScript in your project and want to extend tiptap, there are two things that are good to know.
## Options type ## Options type
To extend or create default options for an extension, youll need to define a custom type, here is an example:
```js
import { createExtension } from '@tiptap/core'
## Create a command export interface CustomExtensionOptions {
awesomeness: number,
}
const CustomExtension = createExtension({
defaultOptions: <CustomExtensionOptions>{
awesomeness: 100,
},
})
```
## Command type
The core package also exports a `Command` type, which needs to be added to all commands that you specify in your code. Here is an example:
```js
import { Command, createExtension } from '@tiptap/core'
const CustomExtension = createExtension({
addCommands() {
return {
/**
* Comments will be added to the autocomplete.
*/
yourCommand: (): Command => ({ commands }) => {
// …
},
}
},
})
```
Thats basically it. Were doing all the rest automatically.

View File

@ -90,45 +90,45 @@ code {
color: white; color: white;
} }
.ProseMirror { // TODO: Move to examples
// .ProseMirror {
// > * + * {
// margin-top: 0.75em;
// }
> * + * { // ul,
margin-top: 0.75em; // ol {
} // padding: 0 1rem;
// }
ul, // pre {
ol { // background: $colorBlack;
padding: 0 1rem; // color: $colorWhite;
} // font-family: 'JetBrainsMono', monospace;
// padding: 0.75rem 1rem;
// border-radius: 0.5rem;
pre { // code {
background: $colorBlack; // color: inherit;
color: $colorWhite; // background: none;
font-family: 'JetBrainsMono', monospace; // font-size: 0.8rem;
padding: 0.75rem 1rem; // }
border-radius: 0.5rem; // }
code { // img {
color: inherit; // max-width: 100%;
background: none; // height: auto;
font-size: 0.8rem; // }
}
}
img { // hr {
max-width: 100%; // margin: 1rem 0;
height: auto; // }
}
hr { // blockquote {
margin: 1rem 0; // padding-left: 1rem;
} // border-left: 2px solid rgba($colorBlack, 0.1);
// }
blockquote { // }
padding-left: 1rem;
border-left: 2px solid rgba($colorBlack, 0.1);
}
}
.DocSearch { .DocSearch {
filter: saturate(0); filter: saturate(0);

View File

@ -62,7 +62,6 @@
draft: true draft: true
- title: Working with TypeScript - title: Working with TypeScript
link: /guide/working-with-typescript link: /guide/working-with-typescript
draft: true
- title: API - title: API
items: items: