This repository has been archived by the owner on Oct 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'alpha' of github.com:withspectrum/spectrum into 2.8.4
- Loading branch information
Showing
24 changed files
with
327 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// flow-typed signature: 8f063755e65f032485439ac4cefffded | ||
// flow-typed version: <<STUB>>/snarkdown_vx.x.x/flow_v0.66.0 | ||
|
||
/** | ||
* This is an autogenerated libdef stub for: | ||
* | ||
* 'snarkdown' | ||
* | ||
* 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 'snarkdown' { | ||
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 'snarkdown/dist/snarkdown.es' { | ||
declare module.exports: any; | ||
} | ||
|
||
declare module 'snarkdown/dist/snarkdown' { | ||
declare module.exports: any; | ||
} | ||
|
||
declare module 'snarkdown/dist/snarkdown.umd' { | ||
declare module.exports: any; | ||
} | ||
|
||
declare module 'snarkdown/src/index' { | ||
declare module.exports: any; | ||
} | ||
|
||
// Filename aliases | ||
declare module 'snarkdown/dist/snarkdown.es.js' { | ||
declare module.exports: $Exports<'snarkdown/dist/snarkdown.es'>; | ||
} | ||
declare module 'snarkdown/dist/snarkdown.js' { | ||
declare module.exports: $Exports<'snarkdown/dist/snarkdown'>; | ||
} | ||
declare module 'snarkdown/dist/snarkdown.umd.js' { | ||
declare module.exports: $Exports<'snarkdown/dist/snarkdown.umd'>; | ||
} | ||
declare module 'snarkdown/src/index.js' { | ||
declare module.exports: $Exports<'snarkdown/src/index'>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,9 @@ | ||
// @flow | ||
// Determine whether a DraftJS message is short | ||
import { toPlainText, toState } from '../../../draft-utils'; | ||
|
||
import type { RawDraftContentState } from 'draft-js'; | ||
import { toPlainText } from './plaintext'; | ||
import type { MessageInfoType } from '../../../graphql/fragments/message/messageInfo'; | ||
|
||
export const isShort = (message: MessageInfoType): boolean => { | ||
if (message.messageType === 'media') return false; | ||
const jsonBody = JSON.parse(message.content.body); | ||
return ( | ||
jsonBody.blocks.length <= 1 && toPlainText(toState(jsonBody)).length <= 170 | ||
); | ||
return jsonBody.blocks.length <= 1 && toPlainText(jsonBody).length <= 170; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// @flow | ||
import type { RawContentState } from 'draft-js'; | ||
|
||
export const toPlainText = (raw: RawContentState) => { | ||
return raw.blocks | ||
.filter(block => block.type === 'unstyled') | ||
.map(block => block.text) | ||
.join('\n'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// @flow | ||
|
||
export const messageTypeObj = { | ||
text: 'text', | ||
media: 'media', | ||
draftjs: 'draftjs', | ||
}; | ||
export type MessageType = $Keys<typeof messageTypeObj>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
shared/draft-utils/test/__snapshots__/add-embeds-to-draft-js.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`should add embeds 1`] = ` | ||
Object { | ||
"blocks": Array [ | ||
Object { | ||
"data": Object {}, | ||
"depth": 0, | ||
"entityRanges": Array [], | ||
"inlineStyleRanges": Array [], | ||
"key": "g0000", | ||
"text": "https://simplecast.com/s/a1f11d11", | ||
"type": "unstyled", | ||
}, | ||
Object { | ||
"data": Object {}, | ||
"depth": 0, | ||
"entityRanges": Array [ | ||
Object { | ||
"key": -Infinity, | ||
"length": 1, | ||
"offset": 0, | ||
}, | ||
], | ||
"inlineStyleRanges": Array [], | ||
"key": "0", | ||
"text": " ", | ||
"type": "atomic", | ||
}, | ||
], | ||
"entityMap": Object { | ||
"-Infinity": Object { | ||
"data": Object { | ||
"height": 200, | ||
"src": "https://embed.simplecast.com/a1f11d11", | ||
"url": "https://embed.simplecast.com/a1f11d11", | ||
}, | ||
"mutability": "MUTABLE", | ||
"type": "embed", | ||
}, | ||
}, | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.