diff --git a/README.md b/README.md index 5aa38f3adbf87e2c48d0d0fed707f60b7d513385..e5895830a0036fa22964fcfcfcb4f8f3218b434c 100644 --- a/README.md +++ b/README.md @@ -14,18 +14,22 @@ Wax Editor is build on top of the Prosemirror library. Check Prosemirror [websit Wax-prosemirror is under active development. The current roadmap is as follows: ### September 2020 + Alpha version, including comments and track changes. See the rest of this file for a full list of current functionality. ### November 2020 + Beta version, including some new features: -* Find and replace -* Spellchecker -* Special characters -* Transform cases -* Word counter -* Custom tags + +- Find and replace +- Spellchecker +- Special characters +- Transform cases +- Word counter +- Custom tags ### January 2021 + V1.0, freeze new feature development, focus on stability, testing and bug fixes ## Get up and running diff --git a/wax-prosemirror-components/package.json b/wax-prosemirror-components/package.json index 3a58227a19520890058a8da70c1581a46afe8c2c..974a7e4cea92e6236a141dd2e33186f8a3bdeaf2 100644 --- a/wax-prosemirror-components/package.json +++ b/wax-prosemirror-components/package.json @@ -4,7 +4,7 @@ "version": "0.0.16", "description": "Wax prosemirror UI components", "license": "MIT", - "main": "dist/index.js", + "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "build": "BABEL_ENV=production rollup -c" diff --git a/wax-prosemirror-components/src/components/link/LinkComponent.js b/wax-prosemirror-components/src/components/link/LinkComponent.js index 8c4b32a8d8699758e7ccd677c9af3cd225dd43df..da2b9e74c0d5b889951cf5c941dab50f94af4643 100644 --- a/wax-prosemirror-components/src/components/link/LinkComponent.js +++ b/wax-prosemirror-components/src/components/link/LinkComponent.js @@ -22,10 +22,7 @@ const Button = styled.button` const LinkComponent = ({ mark, setPosition, position }) => { const href = mark ? mark.attrs.href : null; const linkMark = mark ? mark : null; - const { - view: { main }, - activeView, - } = useContext(WaxContext); + const { activeView } = useContext(WaxContext); const { state, dispatch } = activeView; const ref = useRef(null); const linkInput = useRef(null); @@ -57,7 +54,8 @@ const LinkComponent = ({ mark, setPosition, position }) => { }; const removeLink = () => { - dispatch(state.tr.removeMark(mark.from, mark.to, state.schema.marks.link)); + const { tr } = state; + dispatch(tr.removeMark(mark.from, mark.to, state.schema.marks.link)); activeView.focus(); }; @@ -90,7 +88,7 @@ const LinkComponent = ({ mark, setPosition, position }) => { selection: { $from, $to }, } = state; const PMLinkMark = state.schema.marks['link']; - const actualMark = DocumentHelpers.getSelectionMark(state, PMLinkMark); + const actualMark = DocumentHelpers.findMark(state, PMLinkMark); setLLastLinkMark(actualMark); if ( diff --git a/wax-prosemirror-core/package.json b/wax-prosemirror-core/package.json index a8e57976fd75455641ba8780bf33b7d52b85c4f3..7829d1e707a4b879f3092c2be8e263315b006bea 100644 --- a/wax-prosemirror-core/package.json +++ b/wax-prosemirror-core/package.json @@ -4,7 +4,7 @@ "version": "0.0.16", "description": "Wax prosemirror core", "license": "MIT", - "main": "dist/index.js", + "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "build": "BABEL_ENV=production rollup -c" diff --git a/wax-prosemirror-layouts/package.json b/wax-prosemirror-layouts/package.json index 3b5d0f4c0ac4946cd6dd89f5bb6fe3064cc07228..89e05ab5a27798520683a984e45c0ba1b4e310c9 100644 --- a/wax-prosemirror-layouts/package.json +++ b/wax-prosemirror-layouts/package.json @@ -4,7 +4,7 @@ "version": "0.0.16", "description": "Wax prosemirror layouts", "license": "MIT", - "main": "dist/index.js", + "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "build": "BABEL_ENV=production rollup -c" diff --git a/wax-prosemirror-plugins/package.json b/wax-prosemirror-plugins/package.json index 6b89d1f3a4310c830023e7ad6fb6e6d286ebbdc0..03eff42cff0205ce115a88eb3fef0e92357f715f 100644 --- a/wax-prosemirror-plugins/package.json +++ b/wax-prosemirror-plugins/package.json @@ -4,7 +4,7 @@ "version": "0.0.16", "description": "Wax prosemirror plugins", "license": "MIT", - "main": "dist/index.js", + "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "build": "BABEL_ENV=production rollup -c" diff --git a/wax-prosemirror-schema/package.json b/wax-prosemirror-schema/package.json index 929c1e26dfd1c65e3f8b4d18bbf1a2b95a733497..4b64ae3a27c358d954f85372c896aa1d640b4be3 100644 --- a/wax-prosemirror-schema/package.json +++ b/wax-prosemirror-schema/package.json @@ -4,7 +4,7 @@ "version": "0.0.16", "description": "Wax prosemirror schema", "license": "MIT", - "main": "dist/index.js", + "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "build": "BABEL_ENV=production rollup -c" diff --git a/wax-prosemirror-services/package.json b/wax-prosemirror-services/package.json index b680d693cde3a047f659eabadfb6d27f9f0a2a3c..219a5a413cec3013ec5919b5e35caac41a92337f 100644 --- a/wax-prosemirror-services/package.json +++ b/wax-prosemirror-services/package.json @@ -4,7 +4,7 @@ "version": "0.0.16", "description": "Wax prosemirror services", "license": "MIT", - "main": "dist/index.js", + "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "build": "BABEL_ENV=production rollup -c" diff --git a/wax-prosemirror-services/src/OverlayService/usePosition.js b/wax-prosemirror-services/src/OverlayService/usePosition.js index dc2738477299a21895b39f42f481d2bd2f82e668..6d3b3a4667b319ddc01904b4b6385a1726cc3084 100644 --- a/wax-prosemirror-services/src/OverlayService/usePosition.js +++ b/wax-prosemirror-services/src/OverlayService/usePosition.js @@ -1,22 +1,25 @@ -import { useState, useContext, useLayoutEffect, useCallback } from "react"; -import { isObject } from "lodash"; -import { WaxContext } from "wax-prosemirror-core"; -import { DocumentHelpers } from "wax-prosemirror-utilities"; +import { useState, useContext, useLayoutEffect, useCallback } from 'react'; +import { isObject } from 'lodash'; +import { WaxContext } from 'wax-prosemirror-core'; +import { DocumentHelpers } from 'wax-prosemirror-utilities'; const defaultOverlay = { left: null, top: null, from: null, to: null, - mark: null + mark: null, }; export default options => { - const { view: { main }, activeView } = useContext(WaxContext); + const { + view: { main }, + activeView, + } = useContext(WaxContext); const [position, setPosition] = useState({ - position: "absolute", - ...defaultOverlay + position: 'absolute', + ...defaultOverlay, }); let mark = {}; @@ -34,7 +37,7 @@ export default options => { const top = end.top + 20; return { top, - left + left, }; }; @@ -48,14 +51,14 @@ export default options => { top, from, to, - selection + selection, }; }; const displayOnMark = (activeView, options) => { const { markType, followCursor } = options; const PMmark = activeView.state.schema.marks[markType]; - mark = DocumentHelpers.getSelectionMark(activeView.state, PMmark); + mark = DocumentHelpers.findMark(activeView.state, PMmark); if (!isObject(mark)) return defaultOverlay; const { from, to } = followCursor ? activeView.state.selection : mark; @@ -67,7 +70,7 @@ export default options => { top, from, to, - mark + mark, }; }; @@ -81,15 +84,12 @@ export default options => { return displayOnMark(activeView, options); }); - useLayoutEffect( - () => { - setPosition({ - position: "absolute", - ...updatePosition(options.followCursor) - }); - }, - [JSON.stringify(updatePosition(options.followCursor))] - ); + useLayoutEffect(() => { + setPosition({ + position: 'absolute', + ...updatePosition(options.followCursor), + }); + }, [JSON.stringify(updatePosition(options.followCursor))]); return [position, setPosition, mark]; }; diff --git a/wax-prosemirror-themes/package.json b/wax-prosemirror-themes/package.json index be313502711492f174e2a331e26660492fd20685..d76ccd548c6ec5eaf233613ac2a6e9d05ff45679 100644 --- a/wax-prosemirror-themes/package.json +++ b/wax-prosemirror-themes/package.json @@ -4,7 +4,7 @@ "version": "0.0.16", "description": "Wax prosemirror themes", "license": "MIT", - "main": "dist/index.js", + "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "build": "BABEL_ENV=production rollup -c" diff --git a/wax-prosemirror-utilities/package.json b/wax-prosemirror-utilities/package.json index 11c08b7315166b71632ed6871734fdccb8ea6a1f..7abc880664740b89321390ab11f4fc7ea8424da8 100644 --- a/wax-prosemirror-utilities/package.json +++ b/wax-prosemirror-utilities/package.json @@ -4,7 +4,7 @@ "version": "0.0.16", "description": "Wax prosemirror utilities", "license": "MIT", - "main": "dist/index.js", + "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "build": "BABEL_ENV=production rollup -c" diff --git a/wax-prosemirror-utilities/src/document/DocumentHelpers.js b/wax-prosemirror-utilities/src/document/DocumentHelpers.js index 3e2caffbbde97bf6c1d23bbaf723837b6d78b507..02d6cbfbd4f26eced8bcc24bfbe19ecce9efc770 100644 --- a/wax-prosemirror-utilities/src/document/DocumentHelpers.js +++ b/wax-prosemirror-utilities/src/document/DocumentHelpers.js @@ -25,27 +25,27 @@ const findMark = (state, PMmark, toArr = false) => { return markFound; }; -const getSelectionMark = (state, PMmark) => { - const { - selection: { $from, $to }, - doc, - } = state; - let markFound; - doc.nodesBetween($from.pos, $to.pos, (node, from) => { - if (node.marks) { - const actualMark = node.marks.find(mark => mark.type === PMmark); - if (actualMark) { - markFound = { - from: $from.pos, - to: $to.pos, - attrs: actualMark.attrs, - }; - } - } - }); - - return markFound; -}; +// const getSelectionMark = (state, PMmark) => { +// const { +// selection: { $from, $to }, +// doc, +// } = state; +// let markFound; +// doc.nodesBetween($from.pos, $to.pos, (node, from) => { +// if (node.marks) { +// const actualMark = node.marks.find(mark => mark.type === PMmark); +// if (actualMark) { +// markFound = { +// from, +// to: from + node.nodeSize, +// attrs: actualMark.attrs, +// }; +// } +// } +// }); +// +// return markFound; +// }; /* this is a workaround for now to find marks that are pm will break them. @@ -104,11 +104,17 @@ const findMarkPosition = (activeView, initialPos, markType) => { const actualMark = start.node.marks.find(mark => mark.type.name === markType); let startIndex = $pos.index(); let startPos = $pos.start() + start.offset; - while (startIndex > 0 && actualMark.isInSet(parent.child(startIndex - 1).marks)) + while ( + startIndex > 0 && + actualMark.isInSet(parent.child(startIndex - 1).marks) + ) startPos -= parent.child(--startIndex).nodeSize; let endIndex = $pos.indexAfter(); let endPos = startPos + start.node.nodeSize; - while (endPos < parent.childCount && actualMark.isInSet(parent.child(endIndex).marks)) + while ( + endPos < parent.childCount && + actualMark.isInSet(parent.child(endIndex).marks) + ) endPos += parent.child(endIndex++).nodeSize; return { from: startPos, to: endPos }; }; @@ -163,7 +169,6 @@ export default { findInlineNodes, findChildrenByMark, findChildrenByAttr, - getSelectionMark, findFragmentedMark, findAllMarksWithSameId, findMarkPosition,