diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/util/ProsemirrorKeymap.ts | 19 | ||||
-rw-r--r-- | src/client/util/RichTextSchema.tsx | 17 | ||||
-rw-r--r-- | src/client/util/TooltipTextMenu.scss | 6 | ||||
-rw-r--r-- | src/client/util/TooltipTextMenu.tsx | 31 | ||||
-rw-r--r-- | src/client/views/MainOverlayTextBox.tsx | 2 | ||||
-rw-r--r-- | src/client/views/collections/collectionFreeForm/MarqueeView.tsx | 9 |
6 files changed, 76 insertions, 8 deletions
diff --git a/src/client/util/ProsemirrorKeymap.ts b/src/client/util/ProsemirrorKeymap.ts index 71644cd88..89d01486e 100644 --- a/src/client/util/ProsemirrorKeymap.ts +++ b/src/client/util/ProsemirrorKeymap.ts @@ -1,4 +1,4 @@ -import { Schema } from "prosemirror-model"; +import { Schema, NodeType } from "prosemirror-model"; import { wrapIn, setBlockType, chainCommands, toggleMark, exitCode, joinUp, joinDown, lift, selectParentNode @@ -24,6 +24,22 @@ export default function buildKeymap<S extends Schema<any>>(schema: S, mapKeys?: keys[key] = cmd; } + function insertStar(state: EditorState<S>, dispatch: ((tr: Transaction<S>) => void)) { + console.log("creating star..."); + let type = schema.nodes.star as NodeType<S>; + let { $from } = state.selection; + if (!$from.parent.canReplaceWith($from.index(), $from.index(), type)) { + return false; + } + if (dispatch) { + dispatch(state.tr.replaceSelectionWith(type.create())); + } + return true; + } + + console.log("star? hullo"); + bind("Mod-space", insertStar); + bind("Mod-z", undo); bind("Shift-Mod-z", redo); bind("Backspace", undoInputRule); @@ -79,6 +95,7 @@ export default function buildKeymap<S extends Schema<any>>(schema: S, mapKeys?: } if (type = schema.nodes.paragraph) { bind("Shift-Ctrl-0", setBlockType(type)); + bind("Mod-space", insertStar); } if (type = schema.nodes.code_block) { bind("Shift-Ctrl-\\", setBlockType(type)); diff --git a/src/client/util/RichTextSchema.tsx b/src/client/util/RichTextSchema.tsx index 3e3e98206..8fae821a5 100644 --- a/src/client/util/RichTextSchema.tsx +++ b/src/client/util/RichTextSchema.tsx @@ -26,6 +26,13 @@ export const nodes: { [index: string]: NodeSpec } = { toDOM() { return pDOM; } }, + star: { + inline: true, + group: "inline", + toDOM() { return ["star", "🟊"]; }, + parseDOM: [{ tag: "star" }] + }, + // :: NodeSpec A blockquote (`<blockquote>`) wrapping one or more blocks. blockquote: { content: "block+", @@ -222,6 +229,15 @@ export const marks: { [index: string]: MarkSpec } = { toDOM: () => ['sup'] }, + collapse: { + parseDOM: [{ style: 'color: blue' }], + toDOM() { + return ['span', { + style: 'color: blue' + }] + } + }, + // :: MarkSpec Code font mark. Represented as a `<code>` element. code: { @@ -280,6 +296,7 @@ export const marks: { [index: string]: MarkSpec } = { }] }, + /** FONT SIZES */ p10: { diff --git a/src/client/util/TooltipTextMenu.scss b/src/client/util/TooltipTextMenu.scss index e2862f093..0720a73a3 100644 --- a/src/client/util/TooltipTextMenu.scss +++ b/src/client/util/TooltipTextMenu.scss @@ -133,7 +133,7 @@ position: relative; min-height: 1em; color: white; - padding: 1px 6px; + padding: 10px 10px; top: 0; left: 0; right: 0; border-bottom: 1px solid silver; background:$dark-color; @@ -239,10 +239,12 @@ border: 1px solid silver; border-radius: 15px; padding: 2px 10px; - margin-bottom: 15px; + margin-bottom: 60px; -webkit-transform: translateX(-50%); transform: translateX(-50%); pointer-events: all; + height: 100px; + width:500px; .ProseMirror-example-setup-style hr { padding: 2px 10px; border: none; diff --git a/src/client/util/TooltipTextMenu.tsx b/src/client/util/TooltipTextMenu.tsx index 7c5437510..1f1ad9cd4 100644 --- a/src/client/util/TooltipTextMenu.tsx +++ b/src/client/util/TooltipTextMenu.tsx @@ -22,12 +22,12 @@ import { throwStatement } from "babel-types"; import { View } from "@react-pdf/renderer"; import { DragManager } from "./DragManager"; import { Doc, Opt, Field } from "../../new_fields/Doc"; -import { Utils } from "../northstar/utils/Utils"; import { DocServer } from "../DocServer"; import { CollectionFreeFormDocumentView } from "../views/nodes/CollectionFreeFormDocumentView"; import { CollectionDockingView } from "../views/collections/CollectionDockingView"; import { DocumentManager } from "./DocumentManager"; import { Id } from "../../new_fields/FieldSymbols"; +import { Utils } from "../../Utils"; const SVG = "http://www.w3.org/2000/svg"; @@ -74,6 +74,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: 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") }, @@ -231,6 +232,15 @@ export class TooltipTextMenu { this.linkEditor.appendChild(this.linkText); this.linkEditor.appendChild(linkBtn); this.tooltip.appendChild(this.linkEditor); + + let starButton = document.createElement("button"); + starButton.textContent = "ST"; + starButton.onclick = () => { + let state = this.view.state; + this.insertStar(state, this.view.dispatch); + } + + this.tooltip.appendChild(starButton); } let node = this.view.state.selection.$from.nodeAfter; @@ -256,6 +266,19 @@ export class TooltipTextMenu { link = node && node.marks.find(m => m.type.name === "link"); } + insertStar(state: any, dispatch: any) { + console.log("creating star..."); + let type = schema.nodes.star; + let { $from } = state.selection; + if (!$from.parent.canReplaceWith($from.index(), $from.index(), type)) { + return false; + } + if (dispatch) { + dispatch(state.tr.replaceSelectionWith(type.create())); + } + return true; + } + //will display a remove-list-type button if selection is in list, otherwise will show list type dropdown updateListItemDropdown(label: string, listTypeBtn: Node) { //remove old btn @@ -426,6 +449,12 @@ export class TooltipTextMenu { this.tooltip.style.width = 225 + "px"; this.tooltip.style.bottom = (box.bottom - start.top) * this.editorProps.ScreenToLocalTransform().Scale + "px"; + this.tooltip.style.top = "-100px"; + //this.tooltip.style.height = "100px"; + + // let transform = this.editorProps.ScreenToLocalTransform(); + // this.tooltip.style.width = `${225 / transform.Scale}px`; + // Utils //UPDATE LIST ITEM DROPDOWN this.listTypeBtnDom = this.updateListItemDropdown(":", this.listTypeBtnDom!); diff --git a/src/client/views/MainOverlayTextBox.tsx b/src/client/views/MainOverlayTextBox.tsx index 24327b995..d1224febe 100644 --- a/src/client/views/MainOverlayTextBox.tsx +++ b/src/client/views/MainOverlayTextBox.tsx @@ -102,6 +102,6 @@ export class MainOverlayTextBox extends React.Component<MainOverlayTextBoxProps> </div> </ div>; } - else return (null); Z + else return (null); } }
\ No newline at end of file diff --git a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx index 9ec941eff..563fbb186 100644 --- a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx +++ b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx @@ -45,12 +45,14 @@ export class MarqueeView extends React.Component<MarqueeViewProps> _commandExecuted = false; @action - cleanupInteractions = (all: boolean = false) => { + cleanupInteractions = (all: boolean = false, rem_keydown: boolean = true) => { if (all) { document.removeEventListener("pointerup", this.onPointerUp, true); document.removeEventListener("pointermove", this.onPointerMove, true); } - document.removeEventListener("keydown", this.marqueeCommand, true); + if (rem_keydown) { + document.removeEventListener("keydown", this.marqueeCommand, true); + } this._visible = false; } @@ -180,6 +182,7 @@ export class MarqueeView extends React.Component<MarqueeViewProps> @action onPointerUp = (e: PointerEvent): void => { + console.log("pointer up!"); if (this._visible) { let mselect = this.marqueeSelect(); if (!e.shiftKey) { @@ -187,7 +190,7 @@ export class MarqueeView extends React.Component<MarqueeViewProps> } this.props.selectDocuments(mselect.length ? mselect : [this.props.container.props.Document]); } - this.cleanupInteractions(true); + this.cleanupInteractions(true, false); if (e.altKey) { e.preventDefault(); } |