From 08eff5a7141c743599ebe313b49811ab0e5f0144 Mon Sep 17 00:00:00 2001 From: Rainer Simon Date: Sat, 4 Apr 2020 10:45:53 +0200 Subject: [PATCH] Refactoring --- .gitignore | 1 + src/editor/Editor.jsx | 4 ++-- src/editor/index.js | 12 ++++++++---- src/editor/widgets/{comments => comment}/Comment.jsx | 0 .../widgets/{comments => comment}/CommentWidget.jsx | 0 .../widgets/{comments => comment}/DropdownMenu.jsx | 0 .../widgets/{comments => comment}/TextEntryField.jsx | 0 src/{text-highlighter => highlighter}/Highlighter.js | 2 +- src/{text-highlighter => highlighter}/index.js | 0 src/index.js | 7 ++++++- src/{text-relations => relations}/Bounds.js | 0 src/{text-relations => relations}/Connection.js | 0 src/{text-relations => relations}/Handle.js | 0 src/{text-relations => relations}/RelationUtils.js | 0 src/{text-relations => relations}/RelationsLayer.js | 0 .../RelationsLayer.scss | 0 src/{text-relations => relations}/SVGConst.js | 0 .../drawing/DrawingTool.js | 4 ++-- .../drawing/HoverEmphasis.js | 0 .../editor/RelationEditor.jsx | 0 src/{text-relations => relations}/index.js | 0 src/{ => selection}/Selection.js | 2 +- .../SelectionHandler.js | 0 src/{text-selection => selection}/SelectionUtils.js | 0 src/{text-selection => selection}/index.js | 1 + themes/default/index.js | 1 + 26 files changed, 23 insertions(+), 11 deletions(-) rename src/editor/widgets/{comments => comment}/Comment.jsx (100%) rename src/editor/widgets/{comments => comment}/CommentWidget.jsx (100%) rename src/editor/widgets/{comments => comment}/DropdownMenu.jsx (100%) rename src/editor/widgets/{comments => comment}/TextEntryField.jsx (100%) rename src/{text-highlighter => highlighter}/Highlighter.js (99%) rename src/{text-highlighter => highlighter}/index.js (100%) rename src/{text-relations => relations}/Bounds.js (100%) rename src/{text-relations => relations}/Connection.js (100%) rename src/{text-relations => relations}/Handle.js (100%) rename src/{text-relations => relations}/RelationUtils.js (100%) rename src/{text-relations => relations}/RelationsLayer.js (100%) rename src/{text-relations => relations}/RelationsLayer.scss (100%) rename src/{text-relations => relations}/SVGConst.js (100%) rename src/{text-relations => relations}/drawing/DrawingTool.js (98%) rename src/{text-relations => relations}/drawing/HoverEmphasis.js (100%) rename src/{text-relations => relations}/editor/RelationEditor.jsx (100%) rename src/{text-relations => relations}/index.js (100%) rename src/{ => selection}/Selection.js (97%) rename src/{text-selection => selection}/SelectionHandler.js (100%) rename src/{text-selection => selection}/SelectionUtils.js (100%) rename src/{text-selection => selection}/index.js (55%) create mode 100644 themes/default/index.js diff --git a/.gitignore b/.gitignore index b512c09..db4c6d9 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +dist node_modules \ No newline at end of file diff --git a/src/editor/Editor.jsx b/src/editor/Editor.jsx index 9506cd5..0aa2cac 100644 --- a/src/editor/Editor.jsx +++ b/src/editor/Editor.jsx @@ -1,8 +1,8 @@ import React, { useState, useRef, useEffect } from 'react'; import setPosition from './setPosition'; -import TagWidget from './widgets/tags/TagWidget'; +import TagWidget from './widgets/tag/TagWidget'; import TypeSelectorWidget from './widgets/type/TypeSelectorWidget'; -import CommentWidget from './widgets/comments/CommentWidget'; +import CommentWidget from './widgets/comment/CommentWidget'; /** * The popup editor component. diff --git a/src/editor/index.js b/src/editor/index.js index beafd4f..2620410 100644 --- a/src/editor/index.js +++ b/src/editor/index.js @@ -1,7 +1,11 @@ import Editor from './Editor'; -export { default as CommentWidget } from './widgets/comment/CommentWidget'; -export { default as TagWidget } from './widgets/tag/TagWidget'; -export { default as TagSelectorWidget } from './widgets/type/TypeSelectorWidget'; +import CommentWidget from './widgets/comment/CommentWidget'; +import TagWidget from './widgets/tag/TagWidget'; +import TypeSelectorWidget from './widgets/type/TypeSelectorWidget'; -export default Editor; +Editor.CommentWidget = CommentWidget; +Editor.TagWidget = TagWidget; +Editor.TypeSelectorWidget = TypeSelectorWidget; + +export { Editor }; diff --git a/src/editor/widgets/comments/Comment.jsx b/src/editor/widgets/comment/Comment.jsx similarity index 100% rename from src/editor/widgets/comments/Comment.jsx rename to src/editor/widgets/comment/Comment.jsx diff --git a/src/editor/widgets/comments/CommentWidget.jsx b/src/editor/widgets/comment/CommentWidget.jsx similarity index 100% rename from src/editor/widgets/comments/CommentWidget.jsx rename to src/editor/widgets/comment/CommentWidget.jsx diff --git a/src/editor/widgets/comments/DropdownMenu.jsx b/src/editor/widgets/comment/DropdownMenu.jsx similarity index 100% rename from src/editor/widgets/comments/DropdownMenu.jsx rename to src/editor/widgets/comment/DropdownMenu.jsx diff --git a/src/editor/widgets/comments/TextEntryField.jsx b/src/editor/widgets/comment/TextEntryField.jsx similarity index 100% rename from src/editor/widgets/comments/TextEntryField.jsx rename to src/editor/widgets/comment/TextEntryField.jsx diff --git a/src/text-highlighter/Highlighter.js b/src/highlighter/Highlighter.js similarity index 99% rename from src/text-highlighter/Highlighter.js rename to src/highlighter/Highlighter.js index c7c822b..b312ff6 100644 --- a/src/text-highlighter/Highlighter.js +++ b/src/highlighter/Highlighter.js @@ -1,4 +1,4 @@ -import WebAnnotation from '../annotation/WebAnnotation'; +import WebAnnotation from '../WebAnnotation'; const TEXT = 3; // HTML DOM node type for text nodes diff --git a/src/text-highlighter/index.js b/src/highlighter/index.js similarity index 100% rename from src/text-highlighter/index.js rename to src/highlighter/index.js diff --git a/src/index.js b/src/index.js index e455e12..7996f0c 100644 --- a/src/index.js +++ b/src/index.js @@ -1,2 +1,7 @@ export { default as WebAnnotation } from './WebAnnotation'; -export { default as Selection } from './Selection'; + +export * from './editor'; +export * from './highlighter'; +export * from './relations'; +export * from './selection'; +export * from './utils'; diff --git a/src/text-relations/Bounds.js b/src/relations/Bounds.js similarity index 100% rename from src/text-relations/Bounds.js rename to src/relations/Bounds.js diff --git a/src/text-relations/Connection.js b/src/relations/Connection.js similarity index 100% rename from src/text-relations/Connection.js rename to src/relations/Connection.js diff --git a/src/text-relations/Handle.js b/src/relations/Handle.js similarity index 100% rename from src/text-relations/Handle.js rename to src/relations/Handle.js diff --git a/src/text-relations/RelationUtils.js b/src/relations/RelationUtils.js similarity index 100% rename from src/text-relations/RelationUtils.js rename to src/relations/RelationUtils.js diff --git a/src/text-relations/RelationsLayer.js b/src/relations/RelationsLayer.js similarity index 100% rename from src/text-relations/RelationsLayer.js rename to src/relations/RelationsLayer.js diff --git a/src/text-relations/RelationsLayer.scss b/src/relations/RelationsLayer.scss similarity index 100% rename from src/text-relations/RelationsLayer.scss rename to src/relations/RelationsLayer.scss diff --git a/src/text-relations/SVGConst.js b/src/relations/SVGConst.js similarity index 100% rename from src/text-relations/SVGConst.js rename to src/relations/SVGConst.js diff --git a/src/text-relations/drawing/DrawingTool.js b/src/relations/drawing/DrawingTool.js similarity index 98% rename from src/text-relations/drawing/DrawingTool.js rename to src/relations/drawing/DrawingTool.js index a1b2cbb..399f85f 100644 --- a/src/text-relations/drawing/DrawingTool.js +++ b/src/relations/drawing/DrawingTool.js @@ -1,8 +1,8 @@ +import EventEmitter from 'tiny-emitter'; import Connection from '../Connection'; import HoverEmphasis from './HoverEmphasis'; import { getNodeForEvent } from '../RelationUtils'; -import EventEmitter from 'tiny-emitter'; -import { WebAnnotation } from 'recogito-client-common'; +import WebAnnotation from '../../WebAnnotation'; /** * Wraps an event handler for event delegation. This way, we diff --git a/src/text-relations/drawing/HoverEmphasis.js b/src/relations/drawing/HoverEmphasis.js similarity index 100% rename from src/text-relations/drawing/HoverEmphasis.js rename to src/relations/drawing/HoverEmphasis.js diff --git a/src/text-relations/editor/RelationEditor.jsx b/src/relations/editor/RelationEditor.jsx similarity index 100% rename from src/text-relations/editor/RelationEditor.jsx rename to src/relations/editor/RelationEditor.jsx diff --git a/src/text-relations/index.js b/src/relations/index.js similarity index 100% rename from src/text-relations/index.js rename to src/relations/index.js diff --git a/src/Selection.js b/src/selection/Selection.js similarity index 97% rename from src/Selection.js rename to src/selection/Selection.js index ffdd96b..5264d06 100644 --- a/src/Selection.js +++ b/src/selection/Selection.js @@ -1,4 +1,4 @@ -import WebAnnotation from './WebAnnotation'; +import WebAnnotation from '../WebAnnotation'; import uuid from 'uuid/v1'; /** diff --git a/src/text-selection/SelectionHandler.js b/src/selection/SelectionHandler.js similarity index 100% rename from src/text-selection/SelectionHandler.js rename to src/selection/SelectionHandler.js diff --git a/src/text-selection/SelectionUtils.js b/src/selection/SelectionUtils.js similarity index 100% rename from src/text-selection/SelectionUtils.js rename to src/selection/SelectionUtils.js diff --git a/src/text-selection/index.js b/src/selection/index.js similarity index 55% rename from src/text-selection/index.js rename to src/selection/index.js index 3dd09a5..bb26bf9 100644 --- a/src/text-selection/index.js +++ b/src/selection/index.js @@ -1 +1,2 @@ +export { default as Selection } from './Selection'; export { default as SelectionHandler } from './SelectionHandler'; diff --git a/themes/default/index.js b/themes/default/index.js new file mode 100644 index 0000000..f4aa9d2 --- /dev/null +++ b/themes/default/index.js @@ -0,0 +1 @@ +import './theme.scss'; \ No newline at end of file