aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/TooltipTextMenu.tsx
diff options
context:
space:
mode:
authorab <abdullah_ahmed@brown.edu>2019-06-11 12:02:00 -0400
committerab <abdullah_ahmed@brown.edu>2019-06-11 12:02:00 -0400
commitbf73b629c78d0db0b8d4bcf6aadd6609b3fe1689 (patch)
treebfb3aeaf6eecb7abb90b2213f2f5bce80dcdc2fe /src/client/util/TooltipTextMenu.tsx
parentef24cc445aa466cae3b6c40029f7d7bc9baa81b7 (diff)
star node, trying to set selection as its attribute for copy/paste like behavior
Diffstat (limited to 'src/client/util/TooltipTextMenu.tsx')
-rw-r--r--src/client/util/TooltipTextMenu.tsx23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/client/util/TooltipTextMenu.tsx b/src/client/util/TooltipTextMenu.tsx
index 366105ad9..c5d016547 100644
--- a/src/client/util/TooltipTextMenu.tsx
+++ b/src/client/util/TooltipTextMenu.tsx
@@ -1,6 +1,6 @@
import { action, IReactionDisposer, reaction } from "mobx";
import { Dropdown, DropdownSubmenu, MenuItem, MenuItemSpec, renderGrouped, icons, } from "prosemirror-menu"; //no import css
-import { baseKeymap, lift } from "prosemirror-commands";
+import { baseKeymap, lift, deleteSelection } from "prosemirror-commands";
import { history, redo, undo } from "prosemirror-history";
import { keymap } from "prosemirror-keymap";
import { EditorState, Transaction, NodeSelection, TextSelection } from "prosemirror-state";
@@ -28,6 +28,7 @@ import { CollectionDockingView } from "../views/collections/CollectionDockingVie
import { DocumentManager } from "./DocumentManager";
import { Id } from "../../new_fields/FieldSymbols";
import { Utils } from "../../Utils";
+// import { wrap } from "module";
const SVG = "http://www.w3.org/2000/svg";
@@ -74,7 +75,7 @@ export class TooltipTextMenu {
{ command: toggleMark(schema.marks.strikethrough), dom: this.icon("S", "strikethrough", "Strikethrough") },
{ command: toggleMark(schema.marks.superscript), dom: this.icon("s", "superscript", "Superscript") },
{ command: toggleMark(schema.marks.subscript), dom: this.icon("s", "subscript", "Subscript") },
- { command: toggleMark(schema.marks.collapse), dom: this.icon("C", 'collapse', 'Collapse') }
+ { command: deleteSelection, dom: this.icon("C", 'collapse', 'Collapse') }
// { command: wrapInList(schema.nodes.bullet_list), dom: this.icon(":", "bullets") },
// { command: wrapInList(schema.nodes.ordered_list), dom: this.icon("1)", "bullets") },
// { command: lift, dom: this.icon("<", "lift") },
@@ -274,18 +275,18 @@ export class TooltipTextMenu {
insertStar(state: EditorState<any>, dispatch: any) {
console.log("creating star...");
let type = schema.nodes.star;
- //let {$from} = state.selection;
let select = state.selection;
+ let node = select.$from.nodeAfter;
+ if (node) {
+ console.log("node");
+ console.log(node.type.name);
+ if (node.type.name === "star") {
+ console.log(node.attrs.oldtext);
+ }
+ }
if (dispatch) {
- dispatch(state.tr.setMeta('select.visible', false));
+ dispatch(state.tr.replaceSelectionWith(type.create({ attrs: { oldtext: select } })));
}
- // console.log($from);
- // if (!$from.parent.canReplaceWith($from.index(), $from.index(), type)) {
- // return false;
- // }
- // if (dispatch) {
- // dispatch(state.tr.replaceSelectionWith(type.create()));
- // }
return true;
}