client/src/components/SlateEditor/AnnotationPlugin.js
changeset 173 0e6703cd0968
parent 172 4b780ebbedc6
child 174 ac1a026edd58
--- a/client/src/components/SlateEditor/AnnotationPlugin.js	Tue Nov 13 16:46:15 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-function AnnotationPlugin(options) {
-
-  const { onChange } = options
-
-  return {
-    onSelect(event, editor, next) {
-      event.preventDefault()
-
-      const { value } = editor
-      const { selection } = value
-      const { start, end} = selection
-
-      if (selection.isCollapsed) {
-        return next();
-      }
-
-      const nodes = [];
-      let hasStarted = false;
-      let hasEnded = false;
-
-      // Keep only the relevant nodes,
-      // i.e. nodes which are contained within selection
-      value.document.nodes.forEach((node) => {
-        if (start.isInNode(node)) {
-          hasStarted = true;
-        }
-        if (hasStarted && !hasEnded) {
-          nodes.push(node);
-        }
-        if (end.isAtEndOfNode(node)) {
-          hasEnded = true;
-        }
-      });
-
-      // Concatenate the nodes text
-      const text = nodes.map((node) => {
-        let textStart = start.isInNode(node) ? start.offset : 0;
-        let textEnd = end.isAtEndOfNode(node) ? end.offset : node.text.length;
-        return node.text.substring(textStart,textEnd);
-      }).join('\n');
-
-      if (onChange) {
-        onChange(text, start.offset, end.offset);
-      }
-
-      return next();
-
-    }
-
-  };
-}
-
-export default AnnotationPlugin;