Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
be43fe4
[WIP] Move thread editor to plaintext
Jan 23, 2019
9d55b1c
Fix composer padding
Jan 23, 2019
cc0a9a1
Start working on client-side image uploads
Jan 24, 2019
9d7211b
WIP: threadcomposer refactor first iteration
ThomasRoest Jan 24, 2019
76166c8
set styles based on isOpen prop
ThomasRoest Jan 25, 2019
7c442ab
update inserter icon design
ThomasRoest Jan 28, 2019
8f8c505
Fix dev:api:s3 script to not show logging
brianlovin Jan 29, 2019
0790a7b
Fix file uploads
brianlovin Jan 29, 2019
34c9326
Merge branch 'alpha' into plaintext-thread-editor
Jan 30, 2019
d0ed008
Nice client-side image uploads
Jan 30, 2019
4d10e89
Fix flow
Jan 30, 2019
97d3f97
Remove console.log
Jan 30, 2019
b5741a3
Only add newline on file drop if required
Jan 30, 2019
bfad38b
Add parseEmbedsFromText util to API
Jan 30, 2019
5e2e03b
Automatically add embeds to published threads
Jan 30, 2019
c6a69fc
Handle embeds in thread editing
Jan 30, 2019
2d9eb27
Add empty block below embed atomic block to make editing work
Jan 30, 2019
2b066cf
Only do automatic embeds from plain text
Jan 30, 2019
af355be
add/update composer toggle in inbox view
ThomasRoest Jan 31, 2019
7406b39
add composer toggle / placeholder to channel view
ThomasRoest Jan 31, 2019
cfde19f
update toggle / composer in empty threadfeed component / upsell
ThomasRoest Jan 31, 2019
dfa5558
Abstract draftjs auto embed parsing
Jan 31, 2019
50d9f65
Move thread body processing to shared/
Jan 31, 2019
ca398f2
Add preview tab to new plaintext editor
Jan 31, 2019
426da06
Add mention suggestions to thread composer
Jan 31, 2019
98f0a4a
Fix building web frontend
Jan 31, 2019
3d55eaa
Remove server Raven import from shared code
Jan 31, 2019
df3dfa6
Add data-cy to new composer
Jan 31, 2019
175524b
Fix /new/thread e2e tests
Jan 31, 2019
6f2ab27
Styling polish and markdown hint in thread composer
brianlovin Jan 31, 2019
def7374
Fix flow
brianlovin Jan 31, 2019
4d6d992
fix upsell for community view
ThomasRoest Feb 1, 2019
fd5a295
Resolve unknown prop warning
mxstbr Feb 4, 2019
a6caaeb
Support rendering alt for images in threads
mxstbr Feb 4, 2019
2e02893
Potentially work around draftjs plugins issue in preview
mxstbr Feb 4, 2019
8e569ec
Fix flow typings
mxstbr Feb 4, 2019
8f21a0f
Upgrade draft-js-import-markdown
mxstbr Feb 6, 2019
2ac0117
Fix image previews in thread content
mxstbr Feb 6, 2019
ebd97e6
Fix persisting drafts to localstorage
mxstbr Feb 6, 2019
c2e3637
Insert client-side uploaded images at cursor position
mxstbr Feb 6, 2019
e16e71d
Add "Drop image to upload" overlay to thread composer
mxstbr Feb 6, 2019
b594ef4
Fix e2e test with new data-cy attr
mxstbr Feb 6, 2019
ef9cd69
Merge branch 'alpha' into plaintext-thread-editor
mxstbr Feb 6, 2019
1727de2
Clean up drop image overlay styling
mxstbr Feb 6, 2019
d2cfe3f
Fix code block styling
mxstbr Feb 6, 2019
5a15944
Make code syntax highlighting work from markdown
mxstbr Feb 6, 2019
3e7743d
Add flow type annotations to customStyleFn
mxstbr Feb 6, 2019
145041b
Add "Upload Image" button to plaintext thread editor
mxstbr Feb 7, 2019
338310c
add updated composer to community index view
ThomasRoest Feb 7, 2019
6e62dee
Merge branch 'alpha' into plaintext-thread-editor
Feb 7, 2019
28ad82c
add updated composer slider to inbox / dashboard view
ThomasRoest Feb 7, 2019
521ae30
Clean up mobile upload image button placement
Feb 7, 2019
c51add4
add updated composer to channel view
ThomasRoest Feb 8, 2019
f9b22b1
Merge branch 'feature/refactor-threadcomposer' into plaintext-thread-…
Feb 8, 2019
cc72707
Fix layout on /new/thread
Feb 8, 2019
c5f85a3
Fix thread-composer data-cy attribute
Feb 8, 2019
a3979c5
Fix e2e tests
Feb 8, 2019
9172f1a
Delete unused composer
Feb 8, 2019
6fd1a45
Fix actions padding
brianlovin Feb 8, 2019
a424337
Change placeholders
brianlovin Feb 8, 2019
9e769c2
Return signed images so image previews work
brianlovin Feb 8, 2019
a03f4b8
remove active overlay / focus state from image in composer
ThomasRoest Feb 10, 2019
e966920
Merge pull request #4619 from ThomasRoest/plaintext-thread-editor
mxstbr Feb 11, 2019
979034a
Add support for link entites to links decorator
Feb 11, 2019
c2ba637
Fix markdown links in thread bodies
Feb 11, 2019
aaefe6f
Fix rendering messages
Feb 11, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions api/mutations/files/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// @flow
import uploadImage from './uploadImage';

module.exports = {
Mutation: {
uploadImage,
},
};
23 changes: 23 additions & 0 deletions api/mutations/files/uploadImage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// @flow
import { isAuthedResolver } from '../../utils/permissions';
import { uploadImage } from '../../utils/file-storage';
import type { EntityTypes } from 'shared/types';
import type { GraphQLContext } from '../../';
import type { FileUpload } from 'shared/types';
import { signImageUrl } from 'shared/imgix';

type Args = {
input: {
image: FileUpload,
type: EntityTypes,
id?: string,
},
};

export default isAuthedResolver(
async (_: void, { input }: Args, { loaders }: GraphQLContext) => {
const { image, type, id } = input;
const url = await uploadImage(image, type, id || 'draft');
return await signImageUrl(url);
}
);
25 changes: 10 additions & 15 deletions api/mutations/thread/publishThread.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
// @flow
const debug = require('debug')('api:mutations:thread:publish-thread');
import stringSimilarity from 'string-similarity';
import { convertToRaw } from 'draft-js';
import {
convertToRaw,
convertFromRaw,
EditorState,
SelectionState,
} from 'draft-js';
import { stateFromMarkdown } from 'draft-js-import-markdown';
import type { GraphQLContext } from '../../';
import UserError from '../../utils/UserError';
import { uploadImage } from '../../utils/file-storage';
import processThreadContent from 'shared/draft-utils/process-thread-content';
import {
publishThread,
editThread,
Expand Down Expand Up @@ -68,22 +74,11 @@ export default requireAuth(
);
}

if (type === 'TEXT') {
type = 'DRAFTJS';
if (thread.content.body) {
thread.content.body = JSON.stringify(
convertToRaw(
stateFromMarkdown(thread.content.body, {
parserOptions: {
breaks: true,
},
})
)
);
}
if (thread.content.body) {
thread.content.body = processThreadContent(type, thread.content.body);
}

thread.type = type;
thread.type = 'DRAFTJS';

const [
currentUserChannelPermissions,
Expand Down
2 changes: 2 additions & 0 deletions api/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const notificationMutations = require('./mutations/notification');
const userMutations = require('./mutations/user');
const metaMutations = require('./mutations/meta');
const communityMemberMutations = require('./mutations/communityMember');
const fileMutations = require('./mutations/files');

const messageSubscriptions = require('./subscriptions/message');
const notificationSubscriptions = require('./subscriptions/notification');
Expand Down Expand Up @@ -125,6 +126,7 @@ const resolvers = merge(
userMutations,
metaMutations,
communityMemberMutations,
fileMutations,
// subscriptions
messageSubscriptions,
notificationSubscriptions,
Expand Down
18 changes: 18 additions & 0 deletions api/types/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,24 @@ const general = /* GraphQL */ `
createdAt: String
status: String
}

enum EntityTypes {
communities
channels
users
threads
}

input UploadImageInput {
image: Upload!
type: EntityTypes!
id: String
}

extend type Mutation {
uploadImage(input: UploadImageInput!): String
@rateLimit(max: 20, window: "20m")
}
`;

module.exports = general;
2 changes: 1 addition & 1 deletion cypress/integration/channel/view/composer_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('renders composer for logged in members', () => {

cy.get('[data-cy="thread-composer-placeholder"]').click();

cy.get('[data-cy="thread-composer"]').should('be.visible');
cy.get('[data-cy="rich-text-editor"]').should('be.visible');
});
});

Expand Down
3 changes: 2 additions & 1 deletion cypress/integration/community/view/profile_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ describe('private community signed in with permissions', () => {
.filter(channel => !channel.isPrivate)
.filter(channel => !channel.deletedAt)
.forEach(channel => {
cy.contains(channel.name)
cy.get('[data-cy="channel-list"]')
.contains(channel.name)
.scrollIntoView()
.should('be.visible');
});
Expand Down
4 changes: 2 additions & 2 deletions cypress/integration/thread/action_bar_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ describe('action bar renders', () => {
cy.get('[data-cy="thread-dropdown-edit"]').click();
cy.get('[data-cy="save-thread-edit-button"]').should('be.visible');
const title = 'Some new thread';
cy.get('[data-cy="rich-text-editor"]').should('be.visible');
cy.get('[data-cy="rich-text-editor"].markdown').should('be.visible');
cy.get('[data-cy="thread-editor-title-input"]')
.clear()
.type(title);
Expand All @@ -201,7 +201,7 @@ describe('action bar renders', () => {
cy.get('[data-cy="thread-dropdown-edit"]').click();
cy.get('[data-cy="save-thread-edit-button"]').should('be.visible');
const originalTitle = 'The first thread! 🎉';
cy.get('[data-cy="rich-text-editor"]').should('be.visible');
cy.get('[data-cy="rich-text-editor"].markdown').should('be.visible');
cy.get('[data-cy="thread-editor-title-input"]')
.clear()
.type(originalTitle);
Expand Down
6 changes: 3 additions & 3 deletions cypress/integration/thread_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ describe('/new/thread', () => {
cy.get('[data-cy="composer-channel-selector"]').should('be.visible');
// Type title and body
cy.get('[data-cy="composer-title-input"]').type(title);
cy.get('[contenteditable="true"]').type(body);
cy.get('[data-cy="rich-text-editor"]').type(body);
cy.get('[data-cy="composer-publish-button"]').click();
cy.location('pathname').should('contain', 'thread');
cy.get('[data-cy="thread-view"]');
Expand All @@ -472,12 +472,12 @@ describe('/new/thread', () => {
cy.get('[data-cy="composer-channel-selector"]').should('be.visible');
// Type title and body
cy.get('[data-cy="composer-title-input"]').type(title);
cy.get('[contenteditable="true"]').type(body);
cy.get('[data-cy="rich-text-editor"]').type(body);
/////need time as our localstorage is not set
cy.wait(1000);
cy.reload();

cy.get('[data-cy="composer-title-input"]').contains(title);
cy.get('[contenteditable="true"]').contains(body);
cy.get('[data-cy="rich-text-editor"]').contains(body);
});
});
116 changes: 116 additions & 0 deletions flow-typed/npm/react-dropzone_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// flow-typed signature: a5a6c5ef2495cde307215470bb3dd2b5
// flow-typed version: <<STUB>>/react-dropzone_v8.0.3/flow_v0.66.0

/**
* This is an autogenerated libdef stub for:
*
* 'react-dropzone'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/

declare module 'react-dropzone' {
declare module.exports: any;
}

/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module 'react-dropzone/commitlint.config' {
declare module.exports: any;
}

declare module 'react-dropzone/dist/es/index' {
declare module.exports: any;
}

declare module 'react-dropzone/dist/es/utils/index' {
declare module.exports: any;
}

declare module 'react-dropzone/dist/es/utils/styles' {
declare module.exports: any;
}

declare module 'react-dropzone/dist/index' {
declare module.exports: any;
}

declare module 'react-dropzone/rollup.config' {
declare module.exports: any;
}

declare module 'react-dropzone/src/index' {
declare module.exports: any;
}

declare module 'react-dropzone/src/index.spec' {
declare module.exports: any;
}

declare module 'react-dropzone/src/utils/index' {
declare module.exports: any;
}

declare module 'react-dropzone/src/utils/index.spec' {
declare module.exports: any;
}

declare module 'react-dropzone/src/utils/styles' {
declare module.exports: any;
}

declare module 'react-dropzone/styleguide.config' {
declare module.exports: any;
}

declare module 'react-dropzone/testSetup' {
declare module.exports: any;
}

// Filename aliases
declare module 'react-dropzone/commitlint.config.js' {
declare module.exports: $Exports<'react-dropzone/commitlint.config'>;
}
declare module 'react-dropzone/dist/es/index.js' {
declare module.exports: $Exports<'react-dropzone/dist/es/index'>;
}
declare module 'react-dropzone/dist/es/utils/index.js' {
declare module.exports: $Exports<'react-dropzone/dist/es/utils/index'>;
}
declare module 'react-dropzone/dist/es/utils/styles.js' {
declare module.exports: $Exports<'react-dropzone/dist/es/utils/styles'>;
}
declare module 'react-dropzone/dist/index.js' {
declare module.exports: $Exports<'react-dropzone/dist/index'>;
}
declare module 'react-dropzone/rollup.config.js' {
declare module.exports: $Exports<'react-dropzone/rollup.config'>;
}
declare module 'react-dropzone/src/index.js' {
declare module.exports: $Exports<'react-dropzone/src/index'>;
}
declare module 'react-dropzone/src/index.spec.js' {
declare module.exports: $Exports<'react-dropzone/src/index.spec'>;
}
declare module 'react-dropzone/src/utils/index.js' {
declare module.exports: $Exports<'react-dropzone/src/utils/index'>;
}
declare module 'react-dropzone/src/utils/index.spec.js' {
declare module.exports: $Exports<'react-dropzone/src/utils/index.spec'>;
}
declare module 'react-dropzone/src/utils/styles.js' {
declare module.exports: $Exports<'react-dropzone/src/utils/styles'>;
}
declare module 'react-dropzone/styleguide.config.js' {
declare module.exports: $Exports<'react-dropzone/styleguide.config'>;
}
declare module 'react-dropzone/testSetup.js' {
declare module.exports: $Exports<'react-dropzone/testSetup'>;
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"draft-js-export-markdown": "^1.3.0",
"draft-js-focus-plugin": "^2.2.0",
"draft-js-image-plugin": "^2.0.6",
"draft-js-import-markdown": "^1.3.0",
"draft-js-import-markdown": "^1.3.1",
"draft-js-linkify-plugin": "^2.0.0-beta1",
"draft-js-markdown-plugin": "^3.0.5",
"draft-js-plugins-editor": "^2.1.1",
Expand Down Expand Up @@ -156,6 +156,7 @@
"react-app-rewired": "^1.6.2",
"react-clipboard.js": "^2.0.1",
"react-dom": "^16.7.0-alpha.2",
"react-dropzone": "^8.0.3",
"react-flip-move": "^3.0.2",
"react-helmet-async": "^0.1.0",
"react-image": "^1.5.1",
Expand Down Expand Up @@ -220,7 +221,7 @@
"start:api": "cross-env NODE_ENV=production node build-api/main.js",
"dev:web": "cross-env NODE_PATH=./ react-app-rewired start",
"dev:api": "cross-env FILE_STORAGE=local cross-env NODE_PATH=./ cross-env NODE_ENV=development cross-env DEBUG=build*,api*,shared:rethinkdb:db-query-cache,-api:resolvers cross-env DIR=api backpack",
"dev:api:s3": "cross-env FILE_STORAGE=s3 cross-env NODE_PATH=./ cross-env NODE_ENV=development cross-env DEBUG=build*,api*,shared:middlewares*,shared:rethinkdb:db-query-cache,-api:resolvers cross-env DIR=api backpack",
"dev:api:s3": "cross-env FILE_STORAGE=s3 cross-env NODE_PATH=./ cross-env NODE_ENV=development cross-env DEBUG=build*,api*,shared:rethinkdb:db-query-cache,-api:resolvers cross-env DIR=api backpack",
"dev:athena": "cross-env NODE_PATH=./ cross-env NODE_ENV=development cross-env DEBUG=build*,athena*,shared:middlewares*,-athena:resolvers cross-env DIR=athena backpack",
"dev:hermes": "cross-env NODE_PATH=./ cross-env NODE_ENV=development cross-env DEBUG=build*,hermes*,shared:middlewares*,-hermes:resolvers cross-env DIR=hermes backpack",
"dev:chronos": "cross-env NODE_PATH=./ cross-env NODE_ENV=development cross-env DEBUG=build*,chronos*,shared:middlewares*,-chronos:resolvers cross-env DIR=chronos backpack",
Expand Down
28 changes: 25 additions & 3 deletions shared/clients/draft-js/links-decorator/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import React from 'react';
import linkStrategy from 'draft-js-linkify-plugin/lib/linkStrategy';
import normalizeUrl from '../../../normalize-url';
import type { ContentBlock } from 'draft-js/lib/ContentBlock';
import type { ContentState } from 'draft-js/lib/ContentState';
import type { ComponentType, Node } from 'react';

type DecoratorComponentProps = {
decoratedText: string,
contentState: ContentState,
entityKey?: string,
children?: Node,
};

Expand All @@ -21,15 +24,34 @@ const createLinksDecorator = (
) => ({
strategy: (
contentBlock: ContentBlock,
callback: (...args?: Array<any>) => any
callback: (...args?: Array<any>) => any,
contentState: ContentState
) => {
if (contentBlock.type === 'code-block') return;

if (contentBlock.findEntityRanges) {
contentBlock.findEntityRanges(char => {
const entityKey = char.getEntity();
return (
entityKey !== null &&
contentState.getEntity(entityKey).getType() === 'LINK'
);
}, callback);
}
linkStrategy(contentBlock, callback);
},
component: ({ decoratedText, children }: DecoratorComponentProps) => (
component: ({
decoratedText,
children,
entityKey,
contentState,
}: DecoratorComponentProps) => (
<Component
href={normalizeUrl(decoratedText)}
href={
entityKey
? contentState.getEntity(entityKey).getData().url
: normalizeUrl(decoratedText)
}
children={children}
/* NOTE(@mxstbr): This is super hacky, but I couldn't find a way to give two URLs in the same message a different key. (i.e. "I am on https://github.com https://github.com is great" would only show the link once) */
key={`link-${i++}`}
Expand Down
Loading