+ );
+});
diff --git a/packages/commonwealth/client/scripts/views/components/Editor/README. md b/packages/commonwealth/client/scripts/views/components/Editor/README. md
new file mode 100644
index 00000000000..57df7f53e58
--- /dev/null
+++ b/packages/commonwealth/client/scripts/views/components/Editor/README. md
@@ -0,0 +1,61 @@
+# Overview
+
+Markdown Editor based on MDXEditor customized for our usage.
+
+It supports desktop and mobile mode.
+
+In desktop mode the UI is responsive and uses a static layout so it can
+operate within the flow of a regular document.
+
+In mobile mode it docks the toolbar above the keyboard.
+
+# Fork
+
+This is currently using the commonwealth-mdxeditor, which is a fork of the
+mdx-editor package.
+
+This is just temporary as I plan on merging this into the main MDXEditor when
+we are done.
+
+Right now the only change is a 'location' property added to the toolbar code
+so that we can place the toolbar below the editor.
+
+# Testing
+
+## Desktop
+
+- success: copy a .md file to the clipboard, try to paste it into the editor. It
+ should insert the content at the editor's cursor
+
+ - this works via a File object (not text) so it's important to test this path.
+
+- success: drag a .md file on top of the editor. The drag indicator should show
+ up and cover the editor while you're dragging. Then the file should be inserted
+ at the cursor.
+
+- success: use the 'Import markdown' button to upload a file.
+
+- success: right click and copy an image in the browser, this should upload it
+to the editor and insert it at the current point (I use msnbc.com for this as
+their images are copyable and not CSS background images)
+
+- success: take a screenshot, try to paste it into the editor. The upload
+ indicator should show up.
+
+- success: use the image button at the top to manually upload an image. The
+ upload indicator should show up while this is happening.
+
+- success: drop an image file. Should upload it for us and not handle it as
+ markdown.
+
+- failure: copy multiple .md files ot the clipboard, try to paste into the editor.
+ It should fail because we can't handle multiple .md files
+
+## Mobile
+
+It's probably best to test this on a REAL mobile browser (not on a desktop).
+
+- The toolbar should be present at the bottom of the UI.
+
+- They keyboard should stay on top of the keyboard.
+
diff --git a/packages/commonwealth/client/scripts/views/pages/Editor/index.tsx b/packages/commonwealth/client/scripts/views/components/Editor/index.tsx
similarity index 100%
rename from packages/commonwealth/client/scripts/views/pages/Editor/index.tsx
rename to packages/commonwealth/client/scripts/views/components/Editor/index.tsx
diff --git a/packages/commonwealth/client/scripts/views/components/Editor/indicators/DragIndicator.tsx b/packages/commonwealth/client/scripts/views/components/Editor/indicators/DragIndicator.tsx
new file mode 100644
index 00000000000..6267c56ac2a
--- /dev/null
+++ b/packages/commonwealth/client/scripts/views/components/Editor/indicators/DragIndicator.tsx
@@ -0,0 +1,12 @@
+import React from 'react';
+
+import { Indicator } from 'views/components/Editor/indicators/Indicator';
+import { CWIcon } from 'views/components/component_kit/cw_icons/cw_icon';
+
+export const DragIndicator = () => {
+ return (
+
+
+
+ );
+};
diff --git a/packages/commonwealth/client/scripts/views/components/Editor/indicators/Indicator.scss b/packages/commonwealth/client/scripts/views/components/Editor/indicators/Indicator.scss
new file mode 100644
index 00000000000..6cb8ec9ba0b
--- /dev/null
+++ b/packages/commonwealth/client/scripts/views/components/Editor/indicators/Indicator.scss
@@ -0,0 +1,30 @@
+@import '../../../../../styles/shared';
+
+.Indicator {
+ // cover the parent
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+
+ // needed so that drag operations don't get hijacked by the indicator which
+ // would prevent dropping images and markdown files into the editor.
+ pointer-events: none;
+
+ // the z-index is needed because the 'select' in MDXEditor has its own z-index
+ // which we have to sit on top of.
+ z-index: 10;
+
+ // set the background color to grey-ish so that we can indicate something
+ // is 'muted' here.
+ background-color: rgba(128, 128, 128, 0.2);
+
+ // needed so that the .inner progress indicator can be centered
+ display: flex;
+
+ .inner {
+ // center the contnts
+ margin: auto auto;
+ }
+}
diff --git a/packages/commonwealth/client/scripts/views/components/Editor/indicators/Indicator.tsx b/packages/commonwealth/client/scripts/views/components/Editor/indicators/Indicator.tsx
new file mode 100644
index 00000000000..6a4ef4f3f19
--- /dev/null
+++ b/packages/commonwealth/client/scripts/views/components/Editor/indicators/Indicator.tsx
@@ -0,0 +1,16 @@
+import React, { ReactNode } from 'react';
+
+import './Indicator.scss';
+
+export type IndicatorProps = Readonly<{
+ children: ReactNode;
+}>;
+
+export const Indicator = (props: IndicatorProps) => {
+ const { children } = props;
+ return (
+
+
{children}
+
+ );
+};
diff --git a/packages/commonwealth/client/scripts/views/components/Editor/indicators/UploadIndicator.tsx b/packages/commonwealth/client/scripts/views/components/Editor/indicators/UploadIndicator.tsx
new file mode 100644
index 00000000000..af8d2fe42f5
--- /dev/null
+++ b/packages/commonwealth/client/scripts/views/components/Editor/indicators/UploadIndicator.tsx
@@ -0,0 +1,12 @@
+import React from 'react';
+
+import CWCircleRingSpinner from 'views/components/component_kit/new_designs/CWCircleRingSpinner';
+import { Indicator } from 'views/components/Editor/indicators/Indicator';
+
+export const UploadIndicator = () => {
+ return (
+
+
+
+ );
+};
diff --git a/packages/commonwealth/client/scripts/views/pages/Editor/markdown/gfm.md b/packages/commonwealth/client/scripts/views/components/Editor/markdown/gfm.md
similarity index 100%
rename from packages/commonwealth/client/scripts/views/pages/Editor/markdown/gfm.md
rename to packages/commonwealth/client/scripts/views/components/Editor/markdown/gfm.md
diff --git a/packages/commonwealth/client/scripts/views/pages/Editor/markdown/markdown.md b/packages/commonwealth/client/scripts/views/components/Editor/markdown/markdown.md
similarity index 100%
rename from packages/commonwealth/client/scripts/views/pages/Editor/markdown/markdown.md
rename to packages/commonwealth/client/scripts/views/components/Editor/markdown/markdown.md
diff --git a/packages/commonwealth/client/scripts/views/pages/Editor/markdown/supported.md b/packages/commonwealth/client/scripts/views/components/Editor/markdown/supported.md
similarity index 83%
rename from packages/commonwealth/client/scripts/views/pages/Editor/markdown/supported.md
rename to packages/commonwealth/client/scripts/views/components/Editor/markdown/supported.md
index 61f35ced46b..89772fe41fc 100644
--- a/packages/commonwealth/client/scripts/views/pages/Editor/markdown/supported.md
+++ b/packages/commonwealth/client/scripts/views/components/Editor/markdown/supported.md
@@ -1,5 +1,17 @@
# Example of all supported markdown features
+This is a basic demo of the markdown editor.
+
+You can append to the URL ```?mode=desktop``` or ```?mode=mobile``` to test out a specific mode.
+
+The mobile version works in a desktop browser but should really only be run inside a real mobile browser when verifying functionality.
+
+When you hit submit, it will print the markdown to the console.
+
+Image uploads are local and do not go to S3 to avoid polluting our S3 bucket.
+
+# Markdown Rendering Tests
+
This just tests all the major markdown features we want to support.
# Header 1
diff --git a/packages/commonwealth/client/scripts/views/components/Editor/toolbars/ToolbarForDesktop.scss b/packages/commonwealth/client/scripts/views/components/Editor/toolbars/ToolbarForDesktop.scss
new file mode 100644
index 00000000000..5b33f4e618b
--- /dev/null
+++ b/packages/commonwealth/client/scripts/views/components/Editor/toolbars/ToolbarForDesktop.scss
@@ -0,0 +1,5 @@
+.ToolbarForDesktop {
+ display: flex;
+ flex-grow: 1;
+ user-select: none;
+}
diff --git a/packages/commonwealth/client/scripts/views/components/Editor/toolbars/ToolbarForDesktop.tsx b/packages/commonwealth/client/scripts/views/components/Editor/toolbars/ToolbarForDesktop.tsx
new file mode 100644
index 00000000000..bb19185ce35
--- /dev/null
+++ b/packages/commonwealth/client/scripts/views/components/Editor/toolbars/ToolbarForDesktop.tsx
@@ -0,0 +1,50 @@
+import {
+ BlockTypeSelect,
+ BoldItalicUnderlineToggles,
+ ChangeCodeMirrorLanguage,
+ ConditionalContents,
+ CreateLink,
+ InsertCodeBlock,
+ InsertImage,
+ InsertTable,
+ ListsToggle,
+ Separator,
+ StrikeThroughSupSubToggles,
+} from 'commonwealth-mdxeditor';
+import React from 'react';
+
+import './ToolbarForDesktop.scss';
+
+export const ToolbarForDesktop = () => {
+ return (
+
- );
-});
diff --git a/packages/commonwealth/client/scripts/views/pages/Editor/README. md b/packages/commonwealth/client/scripts/views/pages/Editor/README. md
deleted file mode 100644
index ca438343107..00000000000
--- a/packages/commonwealth/client/scripts/views/pages/Editor/README. md
+++ /dev/null
@@ -1,7 +0,0 @@
-This is currently using the commonwealth-mdxeditor which is a fork of the
-mdeditor package.
-
-This is just temporary as I plan on merging this into the main MDXEditor when
-we are done.
-
-Then we can switch over to the real one.
diff --git a/packages/commonwealth/client/scripts/views/pages/Editor/toolbars/ToolbarForDesktop.tsx b/packages/commonwealth/client/scripts/views/pages/Editor/toolbars/ToolbarForDesktop.tsx
deleted file mode 100644
index aa050c0b208..00000000000
--- a/packages/commonwealth/client/scripts/views/pages/Editor/toolbars/ToolbarForDesktop.tsx
+++ /dev/null
@@ -1,33 +0,0 @@
-import {
- BlockTypeSelect,
- BoldItalicUnderlineToggles,
- CreateLink,
- InsertCodeBlock,
- InsertImage,
- InsertTable,
- ListsToggle,
- Separator,
- StrikeThroughSupSubToggles,
-} from 'commonwealth-mdxeditor';
-import React from 'react';
-
-export const ToolbarForDesktop = () => {
- return (
- <>
-
-
-
- {/**/}
-
-
-
-
-
-
-
-
-
-
- >
- );
-};
diff --git a/packages/commonwealth/client/scripts/views/pages/Editor/useImageUploadHandler.ts b/packages/commonwealth/client/scripts/views/pages/Editor/useImageUploadHandler.ts
deleted file mode 100644
index 8b781ec9a4b..00000000000
--- a/packages/commonwealth/client/scripts/views/pages/Editor/useImageUploadHandler.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import { useCallback } from 'react';
-import { ImageHandler, ImageURL } from 'views/pages/Editor/Editor';
-import { useImageUploadHandlerLocal } from 'views/pages/Editor/useImageUploadHandlerLocal';
-import { useImageUploadHandlerS3 } from 'views/pages/Editor/useImageUploadHandlerS3';
-
-/**
- * Handles supporting either of our image handlers.
- */
-export function useImageUploadHandler(imageHandler: ImageHandler) {
- const imageUploadHandlerDelegateLocal = useImageUploadHandlerLocal();
- const imageUploadHandlerDelegateS3 = useImageUploadHandlerS3();
-
- return useCallback(
- async (file: File): Promise => {
- switch (imageHandler) {
- case 'S3':
- return await imageUploadHandlerDelegateS3(file);
- case 'local':
- return await imageUploadHandlerDelegateLocal(file);
- }
-
- throw new Error('Unknown image handler: ' + imageHandler);
- },
- [
- imageHandler,
- imageUploadHandlerDelegateLocal,
- imageUploadHandlerDelegateS3,
- ],
- );
-}
diff --git a/packages/commonwealth/client/scripts/views/pages/EditorPage/EditorPage.tsx b/packages/commonwealth/client/scripts/views/pages/EditorPage/EditorPage.tsx
new file mode 100644
index 00000000000..52a97ba21db
--- /dev/null
+++ b/packages/commonwealth/client/scripts/views/pages/EditorPage/EditorPage.tsx
@@ -0,0 +1,30 @@
+import React from 'react';
+import { useSearchParams } from 'react-router-dom';
+import Editor from 'views/components/Editor';
+import { EditorMode } from 'views/components/Editor/Editor';
+
+import supported from 'views/components/Editor/markdown/supported.md?raw';
+
+function useParams() {
+ const [searchParams] = useSearchParams();
+ const mode = searchParams.get('mode') ?? 'desktop';
+ return {
+ mode: mode as EditorMode,
+ };
+}
+
+/**
+ * Basic demo page that allows us to use either mode and to log the markdown.
+ */
+export const EditorPage = () => {
+ const { mode } = useParams();
+
+ return (
+ console.log('markdown: \n' + markdown)}
+ />
+ );
+};
diff --git a/packages/commonwealth/client/scripts/views/pages/EditorPage/index.tsx b/packages/commonwealth/client/scripts/views/pages/EditorPage/index.tsx
new file mode 100644
index 00000000000..60e184225bd
--- /dev/null
+++ b/packages/commonwealth/client/scripts/views/pages/EditorPage/index.tsx
@@ -0,0 +1,3 @@
+import { EditorPage } from 'views/pages/EditorPage/EditorPage';
+
+export default EditorPage;
diff --git a/packages/commonwealth/client/vite.config.ts b/packages/commonwealth/client/vite.config.ts
index ec66df0cb12..772e09ba80e 100644
--- a/packages/commonwealth/client/vite.config.ts
+++ b/packages/commonwealth/client/vite.config.ts
@@ -32,6 +32,7 @@ export default defineConfig(({ mode }) => {
// WARN: only used locally never in remote (Heroku) apps
const featureFlags = {
+ 'process.env.FLAG_NEW_EDITOR': JSON.stringify(env.FLAG_NEW_EDITOR),
'process.env.FLAG_CONTEST': JSON.stringify(env.FLAG_CONTEST),
'process.env.FLAG_CONTEST_DEV': JSON.stringify(env.FLAG_CONTEST_DEV),
'process.env.FLAG_KNOCK_PUSH_NOTIFICATIONS_ENABLED': JSON.stringify(