Skip to content

Commit

Permalink
Merge pull request #14 from iliyaZelenko/prepare_to_new_version
Browse files Browse the repository at this point in the history
New version release
  • Loading branch information
iliyaZelenko authored Jun 1, 2019
2 parents c53dd16 + 1d66665 commit 16b2ec3
Show file tree
Hide file tree
Showing 21 changed files with 2,021 additions and 1,223 deletions.
3 changes: 3 additions & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
> 1%
last 2 versions
not ie <= 8
8 changes: 5 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@ module.exports = {
'@typescript-eslint/no-var-requires': OFF,
// allows 'any' type
'@typescript-eslint/no-explicit-any': OFF,
// allows non null assertion
'@typescript-eslint/no-non-null-assertion': OFF,
// tslint config integration for eslint
// '@typescript-eslint/tslint/config': [WARNING, {
// 'lintFile': './tslint.json', // path to tslint.json of your project
// }]
}
}

function isTruthy (value) {
return value && ['1', 'true'].includes(value.toLowerCase())
}
// function isTruthy (value) {
// return value && ['1', 'true'].includes(value.toLowerCase())
// }
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/node_modules/
/dist/
/.yalc/

yalc.lock

# Log files
*.log*
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ import { TiptapVuetifyPlugin } from 'tiptap-vuetify'
// don't forget to import styles
import 'tiptap-vuetify/dist/main.css'

// first it
Vue.use(Vuetify)
// AFTER Vue.use(Vuetify) !!!
Vue.use(TiptapVuetifyPlugin, {
// optional, default to 'md' (default vuetify icons before v2.0.0)
iconsGroup: 'md'
Expand Down Expand Up @@ -145,6 +148,18 @@ Or

## Props

### placeholder

Placeholder is displayed when there is no content in the editor.

How to use:

```vue
<tiptap-vuetify
placeholder="Write something …"
/>
```

### extensions

You can use the necessary extensions. The corresponding buttons are added automatically
Expand Down Expand Up @@ -281,3 +296,5 @@ You can add content after the toolbar.
- images uploading (free hosting by default)
- emoticons
- tests
- custom content for bubble menu
- choose where the extension buttons should be displayed: in the toolbar or in the bubble menu
2 changes: 2 additions & 0 deletions demo/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const MAIN_MODULE = import('~/main') // '../dist/bundle-cjs'
// export const MAIN_MODULE = import('../dist/bundle-esm') // '../dist/bundle-cjs'
26 changes: 14 additions & 12 deletions demo/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,22 @@ import '@fortawesome/fontawesome-free/css/all.css'
import App from './App'
import router from './router'

import { TiptapVuetifyPlugin } from '../dist/bundle-cjs'
import '../dist/main.css'
import { MAIN_MODULE } from './config'

Vue.use(TiptapVuetifyPlugin, {
iconsGroup: 'md'
})
Vue.use(Vuetify)
Vue.use(Router)
MAIN_MODULE.then(({ TiptapVuetifyPlugin }) => {
Vue.use(Vuetify)
Vue.use(TiptapVuetifyPlugin, {
iconsGroup: 'fa'
})
Vue.use(Router)

Vue.config.productionTip = false
Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
el: '#app',
router,
render: h => h(App)
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
render: h => h(App)
})
})
32 changes: 20 additions & 12 deletions demo/pages/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
v-model="content"
:extensions="extensions"
:toolbar-attributes="{ color: 'yellow' }"
placeholder="Write something …"
/>

<br><br>
<h1>Preview {{ $vuetify.lang.current }}</h1>
<h1>Preview</h1>
<hr>

<div
Expand All @@ -18,14 +19,25 @@
</template>

<script>
import { TiptapVuetify, Heading, Bold, Italic, Strike, Underline, Code, CodeBlock, Paragraph, BulletList, OrderedList,
ListItem, Link, Blockquote, HardBreak, HorizontalRule, History
} from '../../dist/bundle-cjs' // // '../../dist/bundle-umd'
import { MAIN_MODULE } from '../config'
export default {
components: { TiptapVuetify },
components: {
TiptapVuetify: () => MAIN_MODULE.then(({ TiptapVuetify }) => TiptapVuetify)
},
data: () => ({
extensions: [
extensions: null,
content: `
<h1>Yay Headlines!</h1>
<p>All these <strong>cool tags</strong> are working now.</p>
`
}),
async created () {
const { Heading, Bold, Italic, Strike, Underline, Code, CodeBlock, Paragraph, BulletList, OrderedList, ListItem,
Link, Blockquote, HardBreak, HorizontalRule, History
} = await MAIN_MODULE
this.extensions = [
new Heading({
levels: [1, 2, 3]
}),
Expand All @@ -44,11 +56,7 @@ export default {
new HardBreak(),
new HorizontalRule(),
new History()
],
content: `
<h1>Yay Headlines!</h1>
<p>All these <strong>cool tags</strong> are working now.</p>
`
})
]
}
}
</script>
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^5.2.2",
"postcss-preset-env": "^6.6.0",
"rollup": "^1.7.0",
"rollup-plugin-alias": "^1.5.1",
"rollup-plugin-commonjs": "^9.2.1",
Expand Down Expand Up @@ -91,6 +92,7 @@
"typings": "dist/main.d.ts",
"files": [
"dist/*",
"types/*"
"types/*",
"src/*"
]
}
10 changes: 8 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import postcss from 'rollup-plugin-postcss'
import resolve from 'rollup-plugin-node-resolve'
import ttypescript from 'ttypescript'
import { join } from 'path'
import postcssPresetEnv from 'postcss-preset-env'

const isProduction = process.env.BUILD === 'production'
const srtDir = join(__dirname, 'src')
Expand Down Expand Up @@ -91,17 +92,22 @@ async function getConfig ({
resolve: ['.ts', '.js', '.vue'],
'~': srtDir
}),
commonjs(),
// TODO раньшн resolve был после commonjs (но в github я видел в таком порядке)
resolve({
extensions: ['.ts', '.js', '.json'],
customResolveOptions: {
moduleDirectory: 'node_modules'
}
}),
commonjs(),
// TODO autoprefixer
postcss({
// TODO для каждого конфига генерируется свой main.css (одинаковый файл), исправить
extract: join(distDir, 'main.css'),
minimize: true
minimize: true,
plugins: [
postcssPresetEnv
]
}),
typescript({
// это фиксит Unknown object type "asyncfunction"
Expand Down
50 changes: 29 additions & 21 deletions src/components/Main.vue → src/components/TiptapVuetify.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ import AbstractExtensionAdapter from '~/extensionAdapters/AbstractExtensionAdapt
import { PROPS, EVENTS } from '~/const'
import Bubble from '~/components/Bubble.vue'
import { Link } from '~/main'
import {
Placeholder
} from 'tiptap-extensions'
@Component({
components: {
Expand All @@ -57,13 +60,16 @@ import { Link } from '~/main'
Toolbar
}
})
export default class Main extends Vue {
export default class TiptapVuetify extends Vue {
@Prop({ type: String, default: '' })
readonly [PROPS.VALUE]: string
@Prop({ type: Array, default: () => [] })
readonly [PROPS.EXTENSIONS]: any
@Prop({ type: String })
readonly [PROPS.PLACEHOLDER]: string
@Prop({
type: [Array, Object],
default: () => ({})
Expand Down Expand Up @@ -100,7 +106,7 @@ export default class Main extends Vue {
return
}
this.editor.setContent(val)
if (this.editor) this.editor.setContent(val)
}
mounted () {
Expand All @@ -115,24 +121,14 @@ export default class Main extends Vue {
})
const extensions = [
...this[PROPS.NATIVE_EXTENSIONS],
// new Blockquote(),
// new CodeBlock(),
// new HardBreak(),
// new Heading({ levels: [1, 2, 3] }),
// new BulletList(),
// new OrderedList(),
// new ListItem(),
/// / new TodoItem(),
/// / new TodoList(),
// new Bold(),
// new Code(),
// new Italic(),
// new Link(),
// new Strike(),
// new Underline(),
// new History(),
// new HorizontalRule(),
...extensionsInstances
...extensionsInstances,
// TODO ONLY FOR TEST
new Placeholder({
emptyNodeClass: 'tiptap-vuetify-editor__paragraph--is-empty',
emptyNodeText: this[PROPS.PLACEHOLDER],
showOnlyWhenEditable: true
})
]
this.editor = new Editor({
Expand All @@ -146,13 +142,14 @@ export default class Main extends Vue {
editor: this.editor
})
}
onUpdate (info) {
this.emitAfterOnUpdate = true
this.$emit(EVENTS.INPUT, info.getHTML(), info)
}
beforeDestroy () {
this.editor.destroy()
if (this.editor) this.editor.destroy()
}
}
</script>
Expand All @@ -166,6 +163,7 @@ export default class Main extends Vue {
/* Элемент не обязательно содрежится в .tiptap-vuetify-editor, может использоваться для отображения результата
редактора в не редактора */
.tiptap-vuetify-editor__content
transition: all 2s;
overflow: auto !important;
padding: 5px;
Expand Down Expand Up @@ -195,4 +193,14 @@ export default class Main extends Vue {
margin-bottom: 16px !important;
/* без этого пустой <p> в превью не будет занимать пространство (чтобы был вид пустой строки) как он это делает в редакторе */
min-height: 1rem;
// placeholder
&.tiptap-vuetify-editor__paragraph--is-empty
&:first-child::before
content: attr(data-empty-text);
float: left;
color: #aaa;
pointer-events: none;
height: 0;
font-style: italic;
</style>
7 changes: 6 additions & 1 deletion src/const.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
export const PACKAGE_NAME = 'tiptap-vuetify'

export const VuetifyVuePrototypeProperty = '$vuetify'

export const EVENTS = {
INPUT: 'input' as const,
INIT: 'init' as const
Expand All @@ -8,5 +12,6 @@ export const PROPS = {
EXTENSIONS: 'extensions' as const,
TOOLBAR_ATTRIBUTES: 'toolbarAttributes' as const,
EDITOR_PROPERTIES: 'editorProperties' as const,
NATIVE_EXTENSIONS: 'nativeExtensions' as const
NATIVE_EXTENSIONS: 'nativeExtensions' as const,
PLACEHOLDER: 'placeholder' as const
}
3 changes: 2 additions & 1 deletion src/extensionAdapters/AbstractExtensionAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export default abstract class AbstractExtensionAdapter {
return undefined
}

protected constructor (protected options, protected extensionClass: Extension | null) {
// extensionClass: Extension | null
protected constructor (protected options, protected extensionClass) {
if (extensionClass) {
// eslint-disable-next-line
this.extensionInstance = new extensionClass(options)
Expand Down
4 changes: 2 additions & 2 deletions src/extensionAdapters/Link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import VuetifyIcon from '~/extensionAdapters/icons/VuetifyIcon'
export const icons = {
save: {
[VuetifyIconsGropus.md]: new VuetifyIcon('check'),
[VuetifyIconsGropus.fa]: new VuetifyIcon('fas fa-strikethrough ' + faIconsSize),
[VuetifyIconsGropus.fa]: new VuetifyIcon('fas fa-check ' + faIconsSize),
[VuetifyIconsGropus.mdi]: new VuetifyIcon('mdi-check')
},
cancel: {
Expand All @@ -21,7 +21,7 @@ export const icons = {
},
linkAdd: {
[VuetifyIconsGropus.md]: new VuetifyIcon('link'),
[VuetifyIconsGropus.fa]: new VuetifyIcon('fas fa-strikethrough ' + faIconsSize),
[VuetifyIconsGropus.fa]: new VuetifyIcon('fas fa-link ' + faIconsSize),
[VuetifyIconsGropus.mdi]: new VuetifyIcon('mdi-link-plus')
}
}
Expand Down
Loading

0 comments on commit 16b2ec3

Please sign in to comment.