Merge remote-tracking branch 'upstream/master'

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

View File

@ -21,9 +21,9 @@ export default class DragItem extends Node {
get view() { get view() {
return { return {
template: ` template: `
<div data-type="drag_item"> <div data-type="drag_item" contenteditable="false">
<div ref="content" contenteditable="true"></div> <div ref="content" contenteditable="true"></div>
<div data-drag-handle contenteditable="false"></div> <div data-drag-handle></div>
</div> </div>
`, `,
} }

View File

@ -23,15 +23,15 @@
"last 2 versions" "last 2 versions"
], ],
"devDependencies": { "devDependencies": {
"@babel/core": "^7.6.2", "@babel/core": "^7.6.4",
"@babel/node": "^7.6.2", "@babel/node": "^7.6.3",
"@babel/plugin-syntax-dynamic-import": "^7.2.0", "@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/plugin-transform-runtime": "^7.6.2", "@babel/plugin-transform-runtime": "^7.6.2",
"@babel/preset-env": "^7.6.2", "@babel/preset-env": "^7.6.3",
"@babel/preset-stage-2": "^7.0.0", "@babel/preset-stage-2": "^7.0.0",
"@babel/runtime": "^7.6.2", "@babel/runtime": "^7.6.3",
"audit-ci": "^2.3.0", "audit-ci": "^2.3.0",
"autoprefixer": "^9.6.1", "autoprefixer": "^9.6.5",
"babel-core": "^7.0.0-bridge.0", "babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.3", "babel-eslint": "^10.0.3",
"babel-jest": "^24.9.0", "babel-jest": "^24.9.0",
@ -55,7 +55,7 @@
"identity-obj-proxy": "^3.0.0", "identity-obj-proxy": "^3.0.0",
"imagemin-webpack-plugin": "^2.4.2", "imagemin-webpack-plugin": "^2.4.2",
"jest": "^24.9.0", "jest": "^24.9.0",
"lerna": "^3.16.4", "lerna": "^3.18.1",
"mini-css-extract-plugin": "^0.8.0", "mini-css-extract-plugin": "^0.8.0",
"minimist": "^1.2.0", "minimist": "^1.2.0",
"mutation-observer": "^1.0.3", "mutation-observer": "^1.0.3",
@ -65,7 +65,7 @@
"postcss-loader": "^3.0.0", "postcss-loader": "^3.0.0",
"postcss-scss": "^2.0.0", "postcss-scss": "^2.0.0",
"regenerator-runtime": "^0.13.3", "regenerator-runtime": "^0.13.3",
"rollup": "^1.21.4", "rollup": "^1.24.0",
"rollup-plugin-babel": "^4.3.3", "rollup-plugin-babel": "^4.3.3",
"rollup-plugin-commonjs": "^10.1.0", "rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-css-only": "^1.0.0", "rollup-plugin-css-only": "^1.0.0",
@ -75,14 +75,14 @@
"rollup-plugin-vue": "^5.0.1", "rollup-plugin-vue": "^5.0.1",
"sass-loader": "^8.0.0", "sass-loader": "^8.0.0",
"style-loader": "^1.0.0", "style-loader": "^1.0.0",
"terser": "^4.3.3", "terser": "^4.3.9",
"tippy.js": "^4.3.5", "tippy.js": "^4.3.5",
"vue": "^2.6.10", "vue": "^2.6.10",
"vue-loader": "^15.7.1", "vue-loader": "^15.7.1",
"vue-router": "^3.1.3", "vue-router": "^3.1.3",
"vue-style-loader": "^4.1.0", "vue-style-loader": "^4.1.0",
"vue-template-compiler": "^2.6.10", "vue-template-compiler": "^2.6.10",
"webpack": "^4.41.0", "webpack": "^4.41.2",
"webpack-dev-middleware": "^3.7.1", "webpack-dev-middleware": "^3.7.1",
"webpack-hot-middleware": "^2.25.0", "webpack-hot-middleware": "^2.25.0",
"webpack-manifest-plugin": "^2.1.2", "webpack-manifest-plugin": "^2.1.2",
@ -91,6 +91,6 @@
}, },
"dependencies": { "dependencies": {
"socket.io-client": "^2.3.0", "socket.io-client": "^2.3.0",
"vue-github-button": "^1.0.8" "vue-github-button": "^1.1.2"
} }
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "tiptap-commands", "name": "tiptap-commands",
"version": "1.12.0", "version": "1.12.3",
"description": "Commands for tiptap", "description": "Commands for tiptap",
"homepage": "https://tiptap.scrumpy.io", "homepage": "https://tiptap.scrumpy.io",
"license": "MIT", "license": "MIT",
@ -22,11 +22,11 @@
"dependencies": { "dependencies": {
"prosemirror-commands": "^1.0.8", "prosemirror-commands": "^1.0.8",
"prosemirror-inputrules": "^1.0.4", "prosemirror-inputrules": "^1.0.4",
"prosemirror-model": "^1.7.2", "prosemirror-model": "^1.7.4",
"prosemirror-schema-list": "^1.0.3", "prosemirror-schema-list": "^1.0.4",
"prosemirror-state": "^1.2.4", "prosemirror-state": "^1.2.4",
"prosemirror-tables": "^0.9.5", "prosemirror-tables": "^0.9.5",
"prosemirror-utils": "^0.9.6", "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) { export default function (type) {
return (state, dispatch) => { return (state, dispatch) => {
const { from, to } = state.selection const { tr, selection } = state
return dispatch(state.tr.removeMark(from, to, type)) 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) { export default function (type, attrs) {
return (state, dispatch) => { return (state, dispatch) => {
const { from, to } = state.selection const { tr, selection, doc } = state
return dispatch(state.tr.addMark(from, to, type.create(attrs))) 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", "name": "tiptap-extensions",
"version": "1.28.1", "version": "1.28.4",
"description": "Extensions for tiptap", "description": "Extensions for tiptap",
"homepage": "https://tiptap.scrumpy.io", "homepage": "https://tiptap.scrumpy.io",
"license": "MIT", "license": "MIT",
@ -24,14 +24,14 @@
"lowlight": "^1.12.1", "lowlight": "^1.12.1",
"prosemirror-collab": "^1.1.2", "prosemirror-collab": "^1.1.2",
"prosemirror-history": "^1.0.4", "prosemirror-history": "^1.0.4",
"prosemirror-model": "^1.7.2", "prosemirror-model": "^1.7.4",
"prosemirror-state": "^1.2.4", "prosemirror-state": "^1.2.4",
"prosemirror-tables": "^0.9.5", "prosemirror-tables": "^0.9.5",
"prosemirror-transform": "^1.1.4", "prosemirror-transform": "^1.1.5",
"prosemirror-utils": "^0.9.6", "prosemirror-utils": "^0.9.6",
"prosemirror-view": "^1.11.4", "prosemirror-view": "^1.11.7",
"tiptap": "^1.26.1", "tiptap": "^1.26.4",
"tiptap-commands": "^1.12.0" "tiptap-commands": "^1.12.3"
}, },
"peerDependencies": { "peerDependencies": {
"vue": "^2.5.17", "vue": "^2.5.17",

View File

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

View File

@ -42,11 +42,12 @@ export default class Table extends Node {
return { return {
createTable: ({ rowsCount, colsCount, withHeaderRow }) => ( createTable: ({ rowsCount, colsCount, withHeaderRow }) => (
(state, dispatch) => { (state, dispatch) => {
const offset = state.tr.selection.anchor + 1
const nodes = createTable(schema, rowsCount, colsCount, withHeaderRow) const nodes = createTable(schema, rowsCount, colsCount, withHeaderRow)
const tr = state.tr.replaceSelectionWith(nodes).scrollIntoView() 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)) tr.setSelection(TextSelection.near(resolvedPos))
dispatch(tr) dispatch(tr)

View File

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

View File

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

View File

@ -29,6 +29,12 @@ export default {
editor, editor,
element: this.$el, element: this.$el,
onUpdate: menu => { 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 this.menu = menu
}, },
})) }))

View File

@ -9,6 +9,12 @@ export default {
}, },
}, },
data() {
return {
focused: false,
}
},
watch: { watch: {
editor: { editor: {
immediate: true, immediate: true,
@ -19,6 +25,16 @@ export default {
editor, editor,
element: this.$el, 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({ return this.$scopedSlots.default({
focused: this.editor.view.focused, focused: this.focused,
focus: this.editor.focus, focus: this.editor.focus,
commands: this.editor.commands, commands: this.editor.commands,
isActive: this.editor.isActive, isActive: this.editor.isActive,

View File

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

View File

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

1148
yarn.lock

File diff suppressed because it is too large Load Diff