mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-15 19:29:02 +08:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
3510b7ee72
@ -21,9 +21,9 @@ export default class DragItem extends Node {
|
||||
get view() {
|
||||
return {
|
||||
template: `
|
||||
<div data-type="drag_item">
|
||||
<div data-type="drag_item" contenteditable="false">
|
||||
<div ref="content" contenteditable="true"></div>
|
||||
<div data-drag-handle contenteditable="false"></div>
|
||||
<div data-drag-handle></div>
|
||||
</div>
|
||||
`,
|
||||
}
|
||||
|
20
package.json
20
package.json
@ -23,15 +23,15 @@
|
||||
"last 2 versions"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.6.2",
|
||||
"@babel/node": "^7.6.2",
|
||||
"@babel/core": "^7.6.4",
|
||||
"@babel/node": "^7.6.3",
|
||||
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
|
||||
"@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/runtime": "^7.6.2",
|
||||
"@babel/runtime": "^7.6.3",
|
||||
"audit-ci": "^2.3.0",
|
||||
"autoprefixer": "^9.6.1",
|
||||
"autoprefixer": "^9.6.5",
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
"babel-eslint": "^10.0.3",
|
||||
"babel-jest": "^24.9.0",
|
||||
@ -55,7 +55,7 @@
|
||||
"identity-obj-proxy": "^3.0.0",
|
||||
"imagemin-webpack-plugin": "^2.4.2",
|
||||
"jest": "^24.9.0",
|
||||
"lerna": "^3.16.4",
|
||||
"lerna": "^3.18.1",
|
||||
"mini-css-extract-plugin": "^0.8.0",
|
||||
"minimist": "^1.2.0",
|
||||
"mutation-observer": "^1.0.3",
|
||||
@ -65,7 +65,7 @@
|
||||
"postcss-loader": "^3.0.0",
|
||||
"postcss-scss": "^2.0.0",
|
||||
"regenerator-runtime": "^0.13.3",
|
||||
"rollup": "^1.21.4",
|
||||
"rollup": "^1.24.0",
|
||||
"rollup-plugin-babel": "^4.3.3",
|
||||
"rollup-plugin-commonjs": "^10.1.0",
|
||||
"rollup-plugin-css-only": "^1.0.0",
|
||||
@ -75,14 +75,14 @@
|
||||
"rollup-plugin-vue": "^5.0.1",
|
||||
"sass-loader": "^8.0.0",
|
||||
"style-loader": "^1.0.0",
|
||||
"terser": "^4.3.3",
|
||||
"terser": "^4.3.9",
|
||||
"tippy.js": "^4.3.5",
|
||||
"vue": "^2.6.10",
|
||||
"vue-loader": "^15.7.1",
|
||||
"vue-router": "^3.1.3",
|
||||
"vue-style-loader": "^4.1.0",
|
||||
"vue-template-compiler": "^2.6.10",
|
||||
"webpack": "^4.41.0",
|
||||
"webpack": "^4.41.2",
|
||||
"webpack-dev-middleware": "^3.7.1",
|
||||
"webpack-hot-middleware": "^2.25.0",
|
||||
"webpack-manifest-plugin": "^2.1.2",
|
||||
@ -91,6 +91,6 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"socket.io-client": "^2.3.0",
|
||||
"vue-github-button": "^1.0.8"
|
||||
"vue-github-button": "^1.1.2"
|
||||
}
|
||||
}
|
||||
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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",
|
||||
|
@ -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: {
|
||||
|
@ -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)
|
||||
|
@ -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"
|
||||
|
@ -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",
|
||||
|
@ -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
|
||||
},
|
||||
}))
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user