Skip to content

Commit

Permalink
ELEMENTS-1124: switch nuxeo-html-editor to Quill
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonsilva committed Feb 27, 2020
1 parent 6d88732 commit 22f60d1
Show file tree
Hide file tree
Showing 46 changed files with 1,134 additions and 2,889 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
**/node_modules/
**/coverage/
ui/import-href.js
ui/widgets/alloy/
ui/widgets/nuxeo-selectivity.js
ui/viewers/pdfjs
ui/dataviz/randomColor.js
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
**/node_modules/
**/coverage/
ui/import-href.js
ui/widgets/alloy/
ui/widgets/nuxeo-selectivity.js
ui/viewers/pdfjs
ui/dataviz/randomColor.js
10 changes: 10 additions & 0 deletions storybook/.storybook/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ module.exports = ({ config }) => {
test: /layout.html$/,
use: 'raw-loader',
},
// expose Quill
{
test: require.resolve('@nuxeo/quill/dist/quill.js'),
use: [
{
loader: 'expose-loader',
options: 'Quill',
},
],
},
);
return config;
};
1 change: 1 addition & 0 deletions storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@storybook/polymer": "^5.1.11",
"babel-loader": "^8.0.5",
"highlight.js": "^9.18.0",
"expose-loader": "^0.7.5",
"lit-html": "^1.0.0",
"nuxeo": "^3.2.1",
"polymer-webpack-loader": "^2.0.3",
Expand Down
10 changes: 9 additions & 1 deletion storybook/src/elements/widgets/widgets.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import '@nuxeo/nuxeo-ui-elements/widgets/nuxeo-actions-menu';
import '@nuxeo/nuxeo-ui-elements/widgets/nuxeo-card';
import '@nuxeo/nuxeo-ui-elements/widgets/nuxeo-checkmark';
import '@nuxeo/nuxeo-ui-elements/widgets/nuxeo-date-picker';
import '@nuxeo/nuxeo-ui-elements/widgets/nuxeo-html-editor';
import { storiesOf } from '@storybook/polymer';
import { color, text, number } from '@storybook/addon-knobs';
import { html } from 'lit-html';
Expand Down Expand Up @@ -85,4 +86,11 @@ storiesOf('UI/Widgets', module)
return html`
<nuxeo-date-picker .value="${value}"></nuxeo-date-picker>
`;
});
})

.addElement(
'nuxeo-html-editor',
() => html`
<nuxeo-html-editor></nuxeo-html-editor>
`,
);
3 changes: 1 addition & 2 deletions ui/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"globals": {
"d3": false,
"AlloyEditor": false,
"CKEDITOR": false,
"Quill": false,
"Selectivity": false,
"saulis": false
},
Expand Down
2 changes: 1 addition & 1 deletion ui/demo/nuxeo-demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ window.nuxeo.I18n.loadLocale();
}
#content {
background-color: #efefef;
background-color: var(--nuxeo-demo-background-color, #efefef);
border-radius: 3px;
padding: 16px;
margin-bottom: 16px;
Expand Down
8 changes: 6 additions & 2 deletions ui/demo/nuxeo-html-editor/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@
import '../nuxeo-demo.js';
import '../../widgets/nuxeo-html-editor.js';
</script>
<script src="../../widgets/alloy/alloy-editor-all.js"></script>
<!-- NXP-23147: explicitly import alloy -->

<style include="nuxeo-demo-styles">
html {
--nuxeo-demo-background-color: white;
}
</style>
</head>

<body unresolved>
Expand Down
1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@nuxeo/moment": "^2.24.0",
"@nuxeo/nuxeo-elements": "3.0.0-SNAPSHOT",
"@nuxeo/paper-typeahead": "^0.6.0-SNAPSHOT",
"@nuxeo/quill": "^2.0.0-dev.3",
"@polymer/iron-autogrow-textarea": "^3.0.1",
"@polymer/iron-collapse": "^3.0.0",
"@polymer/iron-flex-layout": "^3.0.0",
Expand Down
52 changes: 52 additions & 0 deletions ui/test/nuxeo-html-editor.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
@license
(C) Copyright Nuxeo Corp. (http://nuxeo.com/)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { fixture, isElementVisible, html } from '@nuxeo/nuxeo-elements/test/test-helpers';
import '../widgets/nuxeo-html-editor.js';

/* eslint-disable no-unused-expressions */
suite('<nuxeo-html-editor>', () => {
test('should display the placeholder when empty', async () => {
const editor = await fixture(
html`
<nuxeo-html-editor></nuxeo-html-editor>
`,
);
expect(editor._editor.root.dataset.placeholder).to.equal('Type here...');
});

test('should sync the html value', async () => {
const editor = await fixture(
html`
<nuxeo-html-editor value="Hello"></nuxeo-html-editor>
`,
);
await new Promise((resolve) => {
editor.addEventListener('value-changed', () => resolve());
editor._editor.insertText(editor._editor.getLength() - 1, ' world!', 'user');
});
expect(editor.value).to.equal(`<p>Hello world!</p>`);
});

test('should hide the toolbar when readonly', async () => {
const editor = await fixture(
html`
<nuxeo-html-editor read-only></nuxeo-html-editor>
`,
);
expect(isElementVisible(editor._editor.getModule('toolbar').container)).to.be.false;
});
});
70 changes: 0 additions & 70 deletions ui/widgets/alloy/LICENSE.md

This file was deleted.

1 change: 0 additions & 1 deletion ui/widgets/alloy/alloy-editor-all.js

This file was deleted.

Loading

0 comments on commit 22f60d1

Please sign in to comment.