Skip to content

Commit

Permalink
Add word-wrap to messageActivity (#1832)
Browse files Browse the repository at this point in the history
* Add word-wrap to messageActivity

* Update CHANGELOG.md

* Add test for break-all

* Add keep-all test
  • Loading branch information
Corina authored Mar 21, 2019
1 parent 1512fe6 commit 1fc6ab4
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Fixed
- Fix [#1423](https://github.com/Microsoft/BotFramework-WebChat/issues/1423). Added sample for hosting WebChat in Angular, by [@omarsourour](https://github.com/omarsourour) in PR [#1813](https://github.com/Microsoft/BotFramework-WebChat/pull/1813)
- Fix [#1767](https://github.com/Microsoft/BotFramework-WebChat/issues/1767). Remove `cursor: pointer` from buttons, by [@corinagum](https://github.com/corinagum) in PR [#1819](https://github.com/Microsoft/BotFramework-WebChat/pull/1819)
- Fix [#1774](https://github.com/Microsoft/BotFramework-WebChat/issues/1774). Add `styleSetOption` to allow word break. Default to `break-word`, by [@corinagum](https://github.com/corinagum) in PR [#1832](https://github.com/Microsoft/BotFramework-WebChat/pull/1832)

## [4.3.0] - 2019-03-04

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions __tests__/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,46 @@ test('setup', async () => {

expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions);
});

test('long URLs with break-word', async () => {
const { driver, pageObjects} = await setupWebDriver();

await pageObjects.sendMessageViaSendBox('https://subdomain.domain.com/pathname0/pathname1/pathname2/pathname3/pathname4/')

await driver.wait(minNumActivitiesShown(2), 2000);
await driver.wait(allImagesLoaded(), 2000);

const base64PNG = await driver.takeScreenshot();

expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions);
});

test('long URLs with break-all', async () => {
const WEB_CHAT_PROPS = { styleOptions: { messageActivityWordBreak: 'break-all' } };

const { driver, pageObjects} = await setupWebDriver({ props: WEB_CHAT_PROPS });

await pageObjects.sendMessageViaSendBox('https://subdomain.domain.com/pathname0/pathname1/pathname2/pathname3/pathname4/')

await driver.wait(minNumActivitiesShown(2), 2000);
await driver.wait(allImagesLoaded(), 2000);

const base64PNG = await driver.takeScreenshot();

expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions);
});

test('long URLs with keep-all', async () => {
const WEB_CHAT_PROPS = { styleOptions: { messageActivityWordBreak: 'keep-all' } };

const { driver, pageObjects} = await setupWebDriver({ props: WEB_CHAT_PROPS });

await pageObjects.sendMessageViaSendBox('箸より重いものを持ったことがない箸より重いものを持ったことがない')

await driver.wait(minNumActivitiesShown(2), 2000);
await driver.wait(allImagesLoaded(), 2000);

const base64PNG = await driver.takeScreenshot();

expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions);
});
4 changes: 3 additions & 1 deletion packages/component/src/Styles/StyleSet/Bubble.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ export default function createBubbleStyle({
bubbleFromUserTextColor,
bubbleMaxWidth,
bubbleMinHeight,
bubbleTextColor
bubbleTextColor,
messageActivityWordBreak
}) {
return {
maxWidth: bubbleMaxWidth,
minHeight: bubbleMinHeight,
wordBreak: messageActivityWordBreak,

'&:not(.from-user)': {
background: bubbleBackground,
Expand Down
5 changes: 4 additions & 1 deletion packages/component/src/Styles/defaultStyleSetOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ const DEFAULT_OPTIONS = {
paddingWide: 20,
subtle: DEFAULT_SUBTLE,

// Word break
messageActivityWordBreak: 'break-word', // 'normal' || 'break-all' || 'break-word' || 'keep-all'

// fonts
primaryFont: fontFamily(['Calibri', 'Helvetica Neue', 'Arial', 'sans-serif']),
monospaceFont: fontFamily(['Consolas', 'Courier New', 'monospace']),
Expand Down Expand Up @@ -43,7 +46,7 @@ const DEFAULT_OPTIONS = {
// Root
rootHeight: '100%',
rootWidth: '100%',

// Send box
hideSendBox: false,
hideUploadButton: false,
Expand Down

0 comments on commit 1fc6ab4

Please sign in to comment.