aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-12-10 11:22:58 -0500
committerbob <bcz@cs.brown.edu>2019-12-10 11:22:58 -0500
commit1c7c38868978b0f68dbad8a9e07d3d30967c23e1 (patch)
treeee7fba8c493fc76a278e3f926c8fd19de1e6f488
parent65c7ce1c6be70f28e1be57e369cf15bc2df7d729 (diff)
fixes to text box inlines for selection.
-rw-r--r--src/client/util/RichTextSchema.tsx14
-rw-r--r--src/client/views/nodes/FormattedTextBox.tsx7
-rw-r--r--src/client/views/nodes/FormattedTextBoxComment.tsx1
3 files changed, 9 insertions, 13 deletions
diff --git a/src/client/util/RichTextSchema.tsx b/src/client/util/RichTextSchema.tsx
index 7cb8448ca..4a75d6e49 100644
--- a/src/client/util/RichTextSchema.tsx
+++ b/src/client/util/RichTextSchema.tsx
@@ -177,18 +177,7 @@ export const nodes: { [index: string]: NodeSpec } = {
docid: { default: "" },
},
group: "inline",
- draggable: true,
- // parseDOM: [{
- // tag: "img[src]", getAttrs(dom: any) {
- // return {
- // src: dom.getAttribute("src"),
- // title: dom.getAttribute("title"),
- // alt: dom.getAttribute("alt"),
- // width: Math.min(100, Number(dom.getAttribute("width"))),
- // };
- // }
- // }],
- // TODO if we don't define toDom, dragging the image crashes. Why?
+ draggable: false,
toDOM(node) {
const attrs = { style: `width: ${node.attrs.width}, height: ${node.attrs.height}` };
return ["div", { ...node.attrs, ...attrs }];
@@ -704,6 +693,7 @@ export class DashDocView {
this._dashSpan = document.createElement("div");
this._outer = document.createElement("span");
this._outer.style.position = "relative";
+ this._outer.style.textIndent = "0";
this._outer.style.width = node.attrs.width;
this._outer.style.height = node.attrs.height;
this._outer.style.display = node.attrs.hidden ? "none" : "inline-block";
diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx
index 6d3c1434a..42723b44b 100644
--- a/src/client/views/nodes/FormattedTextBox.tsx
+++ b/src/client/views/nodes/FormattedTextBox.tsx
@@ -828,7 +828,7 @@ export class FormattedTextBox extends DocAnnotatableComponent<(FieldViewProps &
clipboardTextSerializer: this.clipboardTextSerializer,
handlePaste: this.handlePaste,
});
- if (startup) {
+ if (startup && this._editorView) {
Doc.GetProto(doc).documentText = undefined;
this._editorView.dispatch(this._editorView.state.tr.insertText(startup));
}
@@ -869,7 +869,10 @@ export class FormattedTextBox extends DocAnnotatableComponent<(FieldViewProps &
this._buttonBarReactionDisposer && this._buttonBarReactionDisposer();
this._editorView && this._editorView.destroy();
}
+
+ static _downEvent: any;
onPointerDown = (e: React.PointerEvent): void => {
+ FormattedTextBox._downEvent = true;
FormattedTextBoxComment.textBox = this;
const pos = this._editorView!.posAtCoords({ left: e.clientX, top: e.clientY });
pos && (this._nodeClicked = this._editorView!.state.doc.nodeAt(pos.pos));
@@ -885,6 +888,8 @@ export class FormattedTextBox extends DocAnnotatableComponent<(FieldViewProps &
}
onPointerUp = (e: React.PointerEvent): void => {
+ if (!FormattedTextBox._downEvent) return;
+ FormattedTextBox._downEvent = false;
if (!(e.nativeEvent as any).formattedHandled) {
FormattedTextBoxComment.textBox = this;
FormattedTextBoxComment.update(this._editorView!);
diff --git a/src/client/views/nodes/FormattedTextBoxComment.tsx b/src/client/views/nodes/FormattedTextBoxComment.tsx
index 9f1dd4aec..ed98d9db6 100644
--- a/src/client/views/nodes/FormattedTextBoxComment.tsx
+++ b/src/client/views/nodes/FormattedTextBoxComment.tsx
@@ -94,6 +94,7 @@ export class FormattedTextBoxComment {
FormattedTextBoxComment.start, FormattedTextBoxComment.end, FormattedTextBoxComment.mark,
FormattedTextBoxComment.opened, keep);
e.stopPropagation();
+ e.preventDefault();
};
root && root.appendChild(FormattedTextBoxComment.tooltip);
}