From 7f320822fbb0a78e78548122f01ba9b22a5b2c53 Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Tue, 12 Nov 2019 20:03:14 +0200 Subject: [PATCH] remove prosemirror's link tooltip --- editors/editoria/src/EditorConfig.js | 1 - wax-prosemirror-components/index.js | 1 - .../src/linkToolTip/LinkToolTip.js | 18 ------ .../src/linkToolTip/linktooltip.css | 61 ------------------- wax-prosemirror-plugins/index.js | 1 - .../src/LinkToolTipPlugin.js | 58 ------------------ 6 files changed, 140 deletions(-) delete mode 100644 wax-prosemirror-components/src/linkToolTip/LinkToolTip.js delete mode 100644 wax-prosemirror-components/src/linkToolTip/linktooltip.css delete mode 100644 wax-prosemirror-plugins/src/LinkToolTipPlugin.js diff --git a/editors/editoria/src/EditorConfig.js b/editors/editoria/src/EditorConfig.js index e6f853818..1d0e24008 100644 --- a/editors/editoria/src/EditorConfig.js +++ b/editors/editoria/src/EditorConfig.js @@ -75,7 +75,6 @@ const keys = new CreateShortCuts({ schema, shortCuts }); const plugins = [ columnResizing(), tableEditing(), - // LinkToolTipPlugin, TrackChangePlugin({ options: {} }), invisibles([hardBreak()]) ]; diff --git a/wax-prosemirror-components/index.js b/wax-prosemirror-components/index.js index 6cf409f30..9b8a5e7d6 100644 --- a/wax-prosemirror-components/index.js +++ b/wax-prosemirror-components/index.js @@ -1,3 +1,2 @@ export { default as MainMenuBar } from "./src/mainMenuBar/MainMenuBar"; export { default as SideMenuBar } from "./src/sideMenuBar/SideMenuBar"; -export { default as LinkToolTip } from "./src/linkToolTip/LinkToolTip"; diff --git a/wax-prosemirror-components/src/linkToolTip/LinkToolTip.js b/wax-prosemirror-components/src/linkToolTip/LinkToolTip.js deleted file mode 100644 index fd14e3e71..000000000 --- a/wax-prosemirror-components/src/linkToolTip/LinkToolTip.js +++ /dev/null @@ -1,18 +0,0 @@ -import React, { Component } from "react"; -import { EditorView } from "prosemirror-view"; -import "./linktooltip.css"; - -class LinkToolTip extends React.Component { - render() { - const { href, onEdit, onRemove } = this.props; - return ( - <div className="wax-link-tooltip"> - <div className="wax-link-tooltip-body"> - <div className="wax-link-tooltip-row">Link tooltip</div> - </div> - </div> - ); - } -} - -export default LinkToolTip; diff --git a/wax-prosemirror-components/src/linkToolTip/linktooltip.css b/wax-prosemirror-components/src/linkToolTip/linktooltip.css deleted file mode 100644 index aff9aa60f..000000000 --- a/wax-prosemirror-components/src/linkToolTip/linktooltip.css +++ /dev/null @@ -1,61 +0,0 @@ -/*@import "./wax-custom-button.css";*/ -.wax-link-tooltip { - display: flex; - justify-content: center; - left: -150px; - pointer-events: none; - position: absolute; - top: -70px; - width: 400px; -} - -.wax-link-tooltip .wax-custom-button { - margin: 0 3px; -} - -.wax-link-tooltip-href { - border: none; - color: var(--wax-link-color); - display: inline-block; - flex: 1; - margin: 0 6px 0 0; - max-width: 200px; - overflow: hidden; - padding: 6px 0; - position: relative; - text-overflow: ellipsis; - vertical-align: middle; - white-space: nowrap; - z-index: 2; -} - -.wax-link-tooltip-row { - direction: row; - display: flex; -} - -.wax-link-tooltip-body { - background: #fff; - border-radius: var(--wax-overlay-radius); - box-shadow: var(--wax-overlay-shadow); - box-sizing: border-box; - display: inline-block; - font-family: var(--wax-font-family); - font-size: var(--wax-font-size); - max-width: 400px; - padding: 10px; - pointer-events: auto; -} - -.wax-link-tooltip-body::after { - background-color: #fff; - box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.26); - content: ""; - height: 20px; - left: 35%; - position: absolute; - top: 37px; - width: 20px; - transform: rotate(45deg); - z-index: 1; -} diff --git a/wax-prosemirror-plugins/index.js b/wax-prosemirror-plugins/index.js index e73e55f58..71af7e529 100644 --- a/wax-prosemirror-plugins/index.js +++ b/wax-prosemirror-plugins/index.js @@ -1,4 +1,3 @@ -export { default as LinkToolTipPlugin } from "./src/LinkToolTipPlugin"; export { default as TrackChangePlugin } from "./src/trackChanges/TrackChangePlugin"; diff --git a/wax-prosemirror-plugins/src/LinkToolTipPlugin.js b/wax-prosemirror-plugins/src/LinkToolTipPlugin.js deleted file mode 100644 index a311bc035..000000000 --- a/wax-prosemirror-plugins/src/LinkToolTipPlugin.js +++ /dev/null @@ -1,58 +0,0 @@ -import { EditorState, Plugin } from "prosemirror-state"; -import { TextSelection } from "prosemirror-state"; -import { EditorView } from "prosemirror-view"; - -const LinkToolTipPlugin = new Plugin({ - view(editorView) { - return new LinkToolTip(editorView); - } -}); - -class LinkToolTip { - constructor(view) { - this.tooltip = document.createElement("div"); - this.tooltip.className = "tooltip"; - - view.dom.appendChild(this.tooltip); - - this.update(view, null); - } - - update(view, lastState) { - let state = view.state; - // Don't do anything if the document/selection didn't change - if ( - lastState && - lastState.doc.eq(state.doc) && - lastState.selection.eq(state.selection) - ) - return; - - // Hide the tooltip if the selection is empty - if (state.selection.empty) { - this.tooltip.style.display = "none"; - return; - } - - // Otherwise, reposition it and update its content - this.tooltip.style.display = ""; - let { from, to } = state.selection; - // These are in screen coordinates - let start = view.coordsAtPos(from), - end = view.coordsAtPos(to); - // The box in which the tooltip is positioned, to use as base - let box = this.tooltip.offsetParent.getBoundingClientRect(); - // Find a center-ish x position from the selection endpoints (when - // crossing lines, end may be more to the left) - let left = Math.max((start.left + end.left) / 2, start.left + 3); - this.tooltip.style.left = left - box.left + "px"; - this.tooltip.style.bottom = box.bottom - start.top + "px"; - this.tooltip.textContent = to - from; - } - - destroy() { - this.tooltip.remove(); - } -} - -export default LinkToolTipPlugin; -- GitLab