Skip to content
This repository was archived by the owner on Feb 28, 2023. It is now read-only.

Feature/rich text editor #312

Merged
merged 140 commits into from
Aug 1, 2018
Merged

Feature/rich text editor #312

merged 140 commits into from
Aug 1, 2018

Conversation

Mboulianne
Copy link
Contributor

@Mboulianne Mboulianne commented Jun 29, 2018

@ulaval/modul-components

PR Checklist

  • Provide a small description of the changes introduced by this PR
  • Include this section in the release notes
  • Other info

@Mboulianne Mboulianne added help wanted new feature New component, directive or filter labels Jun 29, 2018
}

private updateValue(): void {
if (JSON.stringify(this.oldModel) === JSON.stringify(this.model)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

personnellement, j'inverserais la condition du if et je mettrais le setContent a l’intérieur. Ça éviterait un return "vide".

@Prop()
public scrollableContainer: string;

protected id: string = `mTextarea-${uuid.generate()}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modifier l'id pour 'mRichTextEditor-${uuid.generate()}'

public getInput(): HTMLElement | null {
const selector: string = this.as<InputStateInputSelector>()!.selector || 'input, textarea, [contenteditable=true]';
const elements: NodeListOf<Element> = this.$el.querySelectorAll(selector);
if (elements.length > 1 || elements.length === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if(elements.length != 1)

}

export function replaceTags(tags: string[], replace: string, html: string): string {
tags.forEach((tag) => { html = replaceTag(tag, replace, html); });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

déjà fait mais pas encore pushé

@@ -0,0 +1,44 @@
/* tslint:disable:no-console */

export function filterNewLines(html: string): string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pas bête! je vais tester ça!

</m-icon><span class="m-validation-message__text">{{ errorMessage }}</span>
</p>
<p class="m-validation-message__valid" v-if="hasValidMessage && isValid">
<m-icon name="check" :svg-title="titleValidIcon" class="m-validation-message__valid__icon"></m-icon>
<m-icon name="m-svg__confirmation" :svg-title="titleValidIcon" class="m-validation-message__valid__icon"></m-icon>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D’après le git blame, ça fait parti de l’intégration

import { RICH_TEXT } from '../component-names';
import WithRender from './rich-text.html?style=./rich-text.scss';

require('froala-editor/css/froala_editor.pkgd.min.css');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si on le mets pas l'affichage "riche" se fait pas.


function cleanHtml(html: string): string {
// delete new lines so the regexps will work
html = filterNewLines(html);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

je vais regarder ca. Je pense que ca marchera pour les filters mais pas les replace et erase. Je pense que le comportement de la methode est le meme que l'option pasteDeniedTags : "Tags that are removed together with their content". Et on veut pas toujours effacer le contenu.


function cleanHtml(html: string): string {
// delete new lines so the regexps will work
html = filterNewLines(html);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

et j'utiliserai l'option si le comportement est le même

return html;
}

class PopupPlugin {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

je vais le faire!

@@ -116,6 +121,8 @@ const ComponentsPlugin: PluginObject<any> = {
Vue.use(RadioPlugin);
Vue.use(RadioGroupPlugin);
Vue.use(RadioStylePlugin);
Vue.use(RichTextLicensePlugin, { key: options.richTextOptions ? options.richTextOptions.key : undefined });
Vue.use(RichTextPlugin); // TODO : rich-text read-only mode will always be included. Are we all ok with that?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c’était bon pour Vincent, le lecteur est léger.

@@ -43,6 +43,8 @@ export const PROGRESS_NAME: string = 'm-progress';
export const RADIO_NAME: string = 'm-radio';
export const RADIO_GROUP_NAME: string = 'm-radio-group';
export const RADIO_STYLE_NAME: string = 'm-radio-style';
export const RICH_TEXT: string = 'm-rich-text';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ajouter le suffixe _NAME.

@@ -116,6 +121,8 @@ const ComponentsPlugin: PluginObject<any> = {
Vue.use(RadioPlugin);
Vue.use(RadioGroupPlugin);
Vue.use(RadioStylePlugin);
Vue.use(RichTextLicensePlugin, { key: options.richTextOptions ? options.richTextOptions.key : undefined });
Vue.use(RichTextPlugin); // TODO : rich-text read-only mode will always be included. Are we all ok with that?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ce fichier est destiné à mourir et le bundling des composantes sera à revoir. Donc je ne me casserais pas trop le becyk avec ça pour le moment.

min-height: 24px;
flex: 1 1 auto;
// overflow: hidden;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enlever les commentaires s'ils ne sont pas nécessaires. Sinon mettre un commentaire sur le pourquoi on veut le garder (ex: à tester dans telle cas particulier)

@@ -2,7 +2,7 @@ import { PluginObject } from 'vue';
import Component from 'vue-class-component';
import { Prop } from 'vue-property-decorator';

import { InputState } from '../../mixins/input-state/input-state';
import { InputState, InputStateMixin } from '../../mixins/input-state/input-state';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai mal à la tête avec tous ces input-style-state-management-mixin qui s'entremêlent!!!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

je remets InputState partout, je demanderai a @Mboulianne s'il y avait une raison particulière à utiliser InputStateMixin quand il rentrera de vacances.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'était un commentaire gratuit de ma part :) C'est juste qu'avec le temps, j'ai complètement perdu le contrôle de toutes ces input-* mixins/state/etc. Ça se peut que ça soit bien correct de même.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'apres mes tests, ca marche que l'on utilise InputState ou InputStateMixin dans les as, puisque InputState implemente InputStateMixin. Donc, autant utiliser InputState partout je pense. En tout cas c'est fait ;-)

@@ -0,0 +1,51 @@
export class PopupPlugin {
private editor: any;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

La déclaration des attributs ici n'est pas nécessaire si on utilise le constructeur comme ceci:

    constructor(private editor, private name: string, private pluginName: string, private buttonList: string[]) {
        // this.editor = editor; plus nécessaire 
        this.buttonName = `${name}Popup`;
        this.pluginName = `${name}Plugin`;
        // this.buttonList = buttonList; plus nécessaire
    }

Si on ne veut pas passer le pluginName en paramètre, on peut le premettre comme attribut. Au choix. Ça peut être laissé tel quel aussi, j'ai pas de préférences.

this.editor.popups.show(`${this.pluginName}.popup`, left, top, btn.outerHeight());
}

hidePopup(): void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mettre public

private pluginName: string;
private buttonList: string[];

constructor(editor, name: string, buttonList: string[]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

editor: any
Est-ce qu'on a envisagé faire un d.ts de l'éditeur? du moins pour les propriétés et méthodes utilisées? Ça devient beaucoup plus simple pour la personne qui a à maintenir le code, surtout si elle n'a pas vraiment contribué à la composante.


protected currentTag: string = 'div';
protected listeningEvents: any[] = [];
protected froalaEditor: any = undefined;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beaucoup de any. Est-ce que ça aurait été relativement simple de les typer selon la documentation qu'on a et l'utilisation qu'on en fait?

Copy link
Contributor

@gabra20 gabra20 Jul 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ce code a été en grande partie de https://github.com/froala/vue-froala-wysiwyg. On l'a pas encore trop optimisé. C'est un bon point, on créera tous les types que l'on peut créer, mais je pense qu'il restera quand même quelques any (froala est codé en javascript + jQuery).


}

export class RichTextLicensePlugin implements PluginObject<RichTextLicensePluginOptions | undefined> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ce code se retrouve à deux places. Ici et dans rich-text-license-plugin

@@ -82,7 +87,7 @@
"vue-class-component": "^6.1.1",
"vue-property-decorator": "^6.0.0",
"vue-template-compiler": "^2.5.9",
"vue-template-loader": "^0.3.1"
"vue-template-loader": "^1.0.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bien que ce soit une dev-dependency, je ne suis pas certain que c'est cette dépendance qui sera prise en compte dans Prisme si elle est redéfinie dans le package.json. C'était peut-être un bon cas de peer-dependency finalement!

}
},
"@mrmlnc/readdir-enhanced": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz",
"integrity": "sha512-bPHp6Ji8b41szTOcaP63VlnbbO5Ny6dwAATtY6JTjh5N2OLrb5Qk/Th5cRkRQhkWCt+EJsYrNB0MiL+Gpn6e3g==",
"resolved": "https://maven.ulaval.ca/api/npm/npm/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ne doit pas avoir de références Maven sur github. Si ça ne fonctionne pas de votre bord, je peux le regénérer avant de merger.

@@ -93,7 +93,7 @@ export class VueFroala extends Vue {
$.FroalaEditor.POPUP_TEMPLATES[`${pluginName}.popup`] = '[_BUTTONS_]';

// The custom popup is defined inside a plugin (new or existing).
$.FroalaEditor.PLUGINS[pluginName] = (editor) => { return new PopupPlugin(editor, name, buttonList); };
$.FroalaEditor.PLUGINS[pluginName] = (editor) => { return new PopupPlugin(name, editor, buttonList); };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Juste pour être certain... il y a eu ici une inversion des champs nom et editor dans le dernier commit. C'est voulu?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oublie ça... l'ordre a changé dans le constructeur!

@simardo simardo merged commit 8ab122f into develop Aug 1, 2018
@simardo simardo deleted the feature/rich-text-editor branch August 1, 2018 14:30
@simardo simardo added this to the 1.0.0-beta.44 milestone Aug 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new feature New component, directive or filter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants