prosemirror-view
Advanced tools
Comparing version 0.24.0 to 1.0.0
@@ -37,2 +37,6 @@ # How to contribute | ||
If you want to make a change that involves a significant overhaul of | ||
the code or introduces a user-visible new feature, create an | ||
[RFC](https://github.com/ProseMirror/rfcs/) first with your proposal. | ||
- Make sure you have a [GitHub Account](https://github.com/signup/free) | ||
@@ -39,0 +43,0 @@ |
{ | ||
"name": "prosemirror-view", | ||
"version": "0.24.0", | ||
"version": "1.0.0", | ||
"description": "ProseMirror's view component", | ||
@@ -20,5 +20,5 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"prosemirror-model": "^0.24.0", | ||
"prosemirror-state": "^0.24.0", | ||
"prosemirror-transform": "^0.24.0" | ||
"prosemirror-model": "^1.0.0", | ||
"prosemirror-state": "^1.0.0", | ||
"prosemirror-transform": "^1.0.0" | ||
}, | ||
@@ -29,3 +29,3 @@ "devDependencies": { | ||
"moduleserve": "^0.7.0", | ||
"prosemirror-test-builder": "^0.24.0", | ||
"prosemirror-test-builder": "^1.0.0", | ||
"rollup": "^0.49.0", | ||
@@ -32,0 +32,0 @@ "rollup-plugin-buble": "^0.15.0" |
@@ -5,2 +5,3 @@ # prosemirror-view | ||
This is a [core module](http://prosemirror.net/docs/ref/#view) of [ProseMirror](http://prosemirror.net). | ||
ProseMirror is a well-behaved rich semantic content editor based on | ||
@@ -24,1 +25,6 @@ contentEditable, with support for collaborative editing and custom | ||
is the place to report issues. | ||
We aim to be an inclusive, welcoming community. To make that explicit, | ||
we have a [code of | ||
conduct](http://contributor-covenant.org/version/1/1/0/) that applies | ||
to communication around the project. |
@@ -48,3 +48,3 @@ import {Selection, NodeSelection, TextSelection} from "prosemirror-state" | ||
let desc = dom.pmViewDesc | ||
return desc && desc.size == 0 | ||
return desc && desc.size == 0 && (dom.nextSibling || dom.nodeName != "BR") | ||
} | ||
@@ -51,0 +51,0 @@ |
@@ -361,3 +361,3 @@ function compareObjs(a, b) { | ||
if (local) { | ||
let localSet = new DecorationSet(local) | ||
let localSet = new DecorationSet(local.sort(byPos)) | ||
return child ? new DecorationGroup([localSet, child]) : localSet | ||
@@ -364,0 +364,0 @@ } |
@@ -127,10 +127,5 @@ import {textRange, parentNode} from "./dom" | ||
function targetKludge(dom, coords) { | ||
if (/^[uo]l$/i.test(dom.nodeName)) { | ||
for (let child = dom.firstChild; child; child = child.nextSibling) { | ||
if (!child.pmViewDesc || !/^li$/i.test(child.nodeName)) continue | ||
let childBox = child.getBoundingClientRect() | ||
if (coords.left > childBox.left - 2) break | ||
if (childBox.top <= coords.top && childBox.bottom >= coords.top) return child | ||
} | ||
} | ||
let parent = dom.parentNode | ||
if (parent && /^li$/i.test(parent.nodeName) && coords.left < dom.getBoundingClientRect().left) | ||
return parent | ||
return dom | ||
@@ -140,3 +135,2 @@ } | ||
function posFromElement(view, elt, coords) { | ||
elt = targetKludge(elt, coords) | ||
if (!view.dom.contains(elt.nodeType != 1 ? elt.parentNode : elt)) return null | ||
@@ -189,2 +183,3 @@ | ||
if (!elt) return null | ||
elt = targetKludge(elt, coords) | ||
if (node) { | ||
@@ -279,3 +274,3 @@ // Suspiciously specific kludge to work around caret*FromPoint | ||
let box = boxes[i] | ||
if (dir == "up" ? box.bottom < coords.top + 1 : box.top > coords.bottom - 1) | ||
if (box.bottom > box.top && (dir == "up" ? box.bottom < coords.top + 1 : box.top > coords.bottom - 1)) | ||
return false | ||
@@ -282,0 +277,0 @@ } |
@@ -52,2 +52,7 @@ import {Mark} from "prosemirror-model" | ||
this.lastSelectedViewDesc = null | ||
// :: ?{slice: Slice, move: bool} | ||
// When editor content is being dragged, this object contains | ||
// information about the dragged slice and whether it is being | ||
// copied or moved. At any other time, it is null. | ||
this.dragging = null | ||
initInput(this) // Must be done before creating a SelectionReader | ||
@@ -54,0 +59,0 @@ |
@@ -17,3 +17,2 @@ import {Selection, NodeSelection, TextSelection} from "prosemirror-state" | ||
view.mouseDown = null | ||
view.dragging = null | ||
view.inDOMChange = null | ||
@@ -255,11 +254,14 @@ view.domObserver = new DOMObserver(view) | ||
this.mightDrag = null | ||
this.target = flushed ? null : event.target | ||
if (targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false || | ||
view.state.selection instanceof NodeSelection && targetPos == view.state.selection.from) | ||
this.mightDrag = {node: targetNode, pos: targetPos} | ||
this.mightDrag = {node: targetNode, | ||
pos: targetPos, | ||
addAttr: this.target && !this.target.draggable, | ||
setUneditable: this.target && browser.gecko && !this.target.hasAttribute("contentEditable")} | ||
this.target = flushed ? null : event.target | ||
if (this.target && this.mightDrag) { | ||
if (this.target && this.mightDrag && (this.mightDrag.addAttr || this.mightDrag.setUneditable)) { | ||
this.view.domObserver.stop() | ||
this.target.draggable = true | ||
if (browser.gecko && (this.setContentEditable = !this.target.hasAttribute("contentEditable"))) | ||
if (this.mightDrag.addAttr) this.target.draggable = true | ||
if (this.mightDrag.setUneditable) | ||
setTimeout(() => this.target.setAttribute("contentEditable", "false"), 20) | ||
@@ -279,5 +281,4 @@ this.view.domObserver.start() | ||
this.view.domObserver.stop() | ||
this.target.draggable = false | ||
if (browser.gecko && this.setContentEditable) | ||
this.target.removeAttribute("contentEditable") | ||
if (this.mightDrag.addAttr) this.target.draggable = false | ||
if (this.mightDrag.setUneditable) this.target.removeAttribute("contentEditable") | ||
this.view.domObserver.start() | ||
@@ -365,2 +366,6 @@ } | ||
range.selectNodeContents(dom) | ||
// Done because IE will fire a selectionchange moving the selection | ||
// to its start when removeAllRanges is called and the editor still | ||
// has focus (which will mess up the editor's selection state). | ||
view.dom.blur() | ||
sel.removeAllRanges() | ||
@@ -377,5 +382,5 @@ sel.addRange(range) | ||
// there, they just don't work, and they are hard to test. | ||
// FIXME when Edge/Mobile Safari fixes this, change this to a version | ||
// FIXME when Mobile Safari fixes this, change this to a version | ||
// range test | ||
const brokenClipboardAPI = browser.ie || browser.ios | ||
const brokenClipboardAPI = (browser.ie && browser.ie_version < 15) || browser.ios | ||
@@ -459,2 +464,4 @@ handlers.copy = editHandlers.cut = (view, e) => { | ||
const dragCopyModifier = browser.mac ? "altKey" : "ctrlKey" | ||
handlers.dragstart = (view, e) => { | ||
@@ -471,4 +478,6 @@ let mouseDown = view.mouseDown | ||
view.dispatch(view.state.tr.setSelection(NodeSelection.create(view.state.doc, mouseDown.mightDrag.pos))) | ||
} else { | ||
return | ||
} else if (e.target && e.target.nodeType == 1) { | ||
let desc = view.docView.nearestDesc(e.target, true) | ||
if (!desc || !desc.node.type.spec.draggable || desc == view.docView) return | ||
view.dispatch(view.state.tr.setSelection(NodeSelection.create(view.state.doc, desc.posBefore))) | ||
} | ||
@@ -479,3 +488,3 @@ let slice = view.state.selection.content(), {dom, text} = serializeForClipboard(view, slice) | ||
e.dataTransfer.setData("text/plain", text) | ||
view.dragging = new Dragging(slice, !e.ctrlKey) | ||
view.dragging = new Dragging(slice, !e[dragCopyModifier]) | ||
} | ||
@@ -482,0 +491,0 @@ |
@@ -524,3 +524,6 @@ import {DOMSerializer, Fragment} from "prosemirror-model" | ||
} | ||
if (!contentDOM && !node.isText) dom.contentEditable = false | ||
if (!contentDOM && !node.isText) { | ||
dom.contentEditable = false | ||
if (node.type.spec.draggable) dom.draggable = true | ||
} | ||
@@ -527,0 +530,0 @@ let nodeDOM = dom |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
679465
8065
1
29
+ Addedorderedmap@2.1.1(transitive)
+ Addedprosemirror-model@1.24.1(transitive)
+ Addedprosemirror-state@1.4.3(transitive)
+ Addedprosemirror-transform@1.10.2(transitive)
+ Addedprosemirror-view@1.37.1(transitive)
- Removedorderedmap@1.1.8(transitive)
- Removedprosemirror-model@0.24.0(transitive)
- Removedprosemirror-state@0.24.0(transitive)
- Removedprosemirror-transform@0.24.0(transitive)
Updatedprosemirror-model@^1.0.0
Updatedprosemirror-state@^1.0.0
Updatedprosemirror-transform@^1.0.0