Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Billy Lam
2019-10-21 09:46:13 +13:00
16 changed files with 727 additions and 613 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "tiptap-commands",
"version": "1.12.0",
"version": "1.12.3",
"description": "Commands for tiptap",
"homepage": "https://tiptap.scrumpy.io",
"license": "MIT",
@@ -22,11 +22,11 @@
"dependencies": {
"prosemirror-commands": "^1.0.8",
"prosemirror-inputrules": "^1.0.4",
"prosemirror-model": "^1.7.2",
"prosemirror-schema-list": "^1.0.3",
"prosemirror-model": "^1.7.4",
"prosemirror-schema-list": "^1.0.4",
"prosemirror-state": "^1.2.4",
"prosemirror-tables": "^0.9.5",
"prosemirror-utils": "^0.9.6",
"tiptap-utils": "^1.8.0"
"tiptap-utils": "^1.8.2"
}
}

View File

@@ -1,6 +1,20 @@
import { getMarkRange } from 'tiptap-utils'
export default function (type) {
return (state, dispatch) => {
const { from, to } = state.selection
return dispatch(state.tr.removeMark(from, to, type))
const { tr, selection } = state
let { from, to } = selection
const { $from, empty } = selection
if (empty) {
const range = getMarkRange($from, type)
from = range.from
to = range.to
}
tr.removeMark(from, to, type)
return dispatch(tr)
}
}

View File

@@ -1,6 +1,26 @@
import { getMarkRange } from 'tiptap-utils'
export default function (type, attrs) {
return (state, dispatch) => {
const { from, to } = state.selection
return dispatch(state.tr.addMark(from, to, type.create(attrs)))
const { tr, selection, doc } = state
let { from, to } = selection
const { $from, empty } = selection
if (empty) {
const range = getMarkRange($from, type)
from = range.from
to = range.to
}
const hasMark = doc.rangeHasMark(from, to, type)
if (hasMark) {
tr.removeMark(from, to, type)
}
tr.addMark(from, to, type.create(attrs))
return dispatch(tr)
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "tiptap-extensions",
"version": "1.28.1",
"version": "1.28.4",
"description": "Extensions for tiptap",
"homepage": "https://tiptap.scrumpy.io",
"license": "MIT",
@@ -24,14 +24,14 @@
"lowlight": "^1.12.1",
"prosemirror-collab": "^1.1.2",
"prosemirror-history": "^1.0.4",
"prosemirror-model": "^1.7.2",
"prosemirror-model": "^1.7.4",
"prosemirror-state": "^1.2.4",
"prosemirror-tables": "^0.9.5",
"prosemirror-transform": "^1.1.4",
"prosemirror-transform": "^1.1.5",
"prosemirror-utils": "^0.9.6",
"prosemirror-view": "^1.11.4",
"tiptap": "^1.26.1",
"tiptap-commands": "^1.12.0"
"prosemirror-view": "^1.11.7",
"tiptap": "^1.26.4",
"tiptap-commands": "^1.12.3"
},
"peerDependencies": {
"vue": "^2.5.17",

View File

@@ -8,6 +8,12 @@ export default class Link extends Mark {
return 'link'
}
get defaultOptions() {
return {
openOnClick: true,
}
}
get schema() {
return {
attrs: {
@@ -52,6 +58,10 @@ export default class Link extends Mark {
}
get plugins() {
if (!this.options.openOnClick) {
return []
}
return [
new Plugin({
props: {

View File

@@ -42,11 +42,12 @@ export default class Table extends Node {
return {
createTable: ({ rowsCount, colsCount, withHeaderRow }) => (
(state, dispatch) => {
const offset = state.tr.selection.anchor + 1
const nodes = createTable(schema, rowsCount, colsCount, withHeaderRow)
const tr = state.tr.replaceSelectionWith(nodes).scrollIntoView()
const resolvedPos = tr.doc.resolve(offset)
// get selection for first cell
const resolvedPos = tr.doc.resolve(tr.selection.anchor - nodes.content.size)
tr.setSelection(TextSelection.near(resolvedPos))
dispatch(tr)

View File

@@ -1,6 +1,6 @@
{
"name": "tiptap-utils",
"version": "1.8.0",
"version": "1.8.2",
"description": "Utility functions for tiptap",
"homepage": "https://tiptap.scrumpy.io",
"license": "MIT",
@@ -20,7 +20,7 @@
"url": "https://github.com/scrumpy/tiptap/issues"
},
"dependencies": {
"prosemirror-model": "^1.7.2",
"prosemirror-model": "^1.7.4",
"prosemirror-state": "^1.2.4",
"prosemirror-tables": "^0.9.5",
"prosemirror-utils": "^0.9.6"

View File

@@ -1,6 +1,6 @@
{
"name": "tiptap",
"version": "1.26.1",
"version": "1.26.4",
"description": "A rich-text editor for Vue.js",
"homepage": "https://tiptap.scrumpy.io",
"license": "MIT",
@@ -21,15 +21,15 @@
},
"dependencies": {
"prosemirror-commands": "^1.0.8",
"prosemirror-dropcursor": "^1.1.2",
"prosemirror-dropcursor": "^1.2.0",
"prosemirror-gapcursor": "^1.0.4",
"prosemirror-inputrules": "^1.0.4",
"prosemirror-keymap": "^1.0.1",
"prosemirror-model": "^1.7.2",
"prosemirror-keymap": "^1.0.2",
"prosemirror-model": "^1.7.4",
"prosemirror-state": "^1.2.4",
"prosemirror-view": "^1.11.4",
"tiptap-commands": "^1.12.0",
"tiptap-utils": "^1.8.0"
"prosemirror-view": "^1.11.7",
"tiptap-commands": "^1.12.3",
"tiptap-utils": "^1.8.2"
},
"peerDependencies": {
"vue": "^2.5.17",

View File

@@ -29,6 +29,12 @@ export default {
editor,
element: this.$el,
onUpdate: menu => {
// the second check ensures event is fired only once
if (menu.isActive && this.menu.isActive === false) {
this.$emit('show', menu)
} else if (!menu.isActive && this.menu.isActive === true) {
this.$emit('hide', menu)
}
this.menu = menu
},
}))

View File

@@ -9,6 +9,12 @@ export default {
},
},
data() {
return {
focused: false,
}
},
watch: {
editor: {
immediate: true,
@@ -19,6 +25,16 @@ export default {
editor,
element: this.$el,
}))
this.focused = editor.focused
editor.on('focus', () => {
this.focused = true
})
editor.on('menubar:focusUpdate', focused => {
this.focused = focused
})
})
}
},
@@ -31,7 +47,7 @@ export default {
}
return this.$scopedSlots.default({
focused: this.editor.view.focused,
focused: this.focused,
focus: this.editor.focus,
commands: this.editor.commands,
isActive: this.editor.isActive,

View File

@@ -11,18 +11,25 @@ class Menu {
},
...options,
}
this.preventHide = false
this.editorView = editorView
this.isActive = false
this.top = 0
// the mousedown event is fired before blur so we can prevent it
this.options.element.addEventListener('mousedown', this.handleClick)
this.mousedownHandler = this.handleClick.bind(this)
this.options.element.addEventListener('mousedown', this.mousedownHandler)
this.options.editor.on('focus', ({ view }) => {
this.update(view)
})
this.options.editor.on('blur', ({ event }) => {
if (this.preventHide) {
this.preventHide = false
return
}
this.hide(event)
})
@@ -38,8 +45,8 @@ class Menu {
}
}
handleClick(event) {
event.preventDefault()
handleClick() {
this.preventHide = true
}
update(view, lastState) {
@@ -103,7 +110,7 @@ class Menu {
}
destroy() {
this.options.element.removeEventListener('mousedown', this.handleClick)
this.options.element.removeEventListener('mousedown', this.mousedownHandler)
if (this.resizeObserver) {
this.resizeObserver.unobserve(this.editorView.dom)

View File

@@ -4,17 +4,28 @@ class Menu {
constructor({ options }) {
this.options = options
this.preventHide = false
// the mousedown event is fired before blur so we can prevent it
this.options.element.addEventListener('mousedown', this.handleClick)
this.mousedownHandler = this.handleClick.bind(this)
this.options.element.addEventListener('mousedown', this.mousedownHandler)
this.options.editor.on('blur', () => {
if (this.preventHide) {
this.preventHide = false
return
}
this.options.editor.emit('menubar:focusUpdate', false)
})
}
handleClick(event) {
event.preventDefault()
handleClick() {
this.preventHide = true
}
destroy() {
this.options.element.removeEventListener('mousedown', this.handleClick)
this.options.element.removeEventListener('mousedown', this.mousedownHandler)
}
}

View File

@@ -67,21 +67,28 @@ class Menu {
this.left = 0
this.bottom = 0
this.top = 0
this.preventHide = false
// the mousedown event is fired before blur so we can prevent it
this.options.element.addEventListener('mousedown', this.handleClick)
this.mousedownHandler = this.handleClick.bind(this)
this.options.element.addEventListener('mousedown', this.mousedownHandler)
this.options.editor.on('focus', ({ view }) => {
this.update(view)
})
this.options.editor.on('blur', ({ event }) => {
if (this.preventHide) {
this.preventHide = false
return
}
this.hide(event)
})
}
handleClick(event) {
event.preventDefault()
handleClick() {
this.preventHide = true
}
update(view, lastState) {
@@ -158,7 +165,7 @@ class Menu {
}
destroy() {
this.options.element.removeEventListener('mousedown', this.handleClick)
this.options.element.removeEventListener('mousedown', this.mousedownHandler)
}
}