Skip to content

Commit

Permalink
feat: Implement publish note - EXO-73041 - Meeds-io/MIPs#161 (#1212)
Browse files Browse the repository at this point in the history
Implement publish note

feat: Add feature flag for publish note option - EXO-73041 - Meeds-io/MIPs#161 (#1219)

Add feature flag for publish note optio

fix: Fix enable condition of delete and import/export action menu options - EXO-73041 - Meeds-io/MIPs#161

fix enable condition of delete/import/export action menu options

feat: Refactor publish note option integration - EXO-73041 - Meeds-io/meeds#161 (#1220)

Refactor publish note option integration
  • Loading branch information
hakermi committed Nov 26, 2024
1 parent 9d01b29 commit 5e0b798
Show file tree
Hide file tree
Showing 19 changed files with 355 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ notes.publication.schedule.publish.now.tooltip=By scheduling only a end date you
notes.publication.advanced.option.label=Advanced options
notes.publication.hide.author.label=Hide author
notes.publication.hide.reaction.label=Hide reaction
notes.publication.success.message=Note successfully published
notes.schedule.success.message=Note scheduled successfully
notes.publication.externalPage.publish.cancel.label=Cancel publishing

popup.confirm=Confirm
popup.msg.confirmation=Confirmation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ notes.publication.schedule.publish.now.tooltip=En programmant uniquement une dat
notes.publication.advanced.option.label=Options avancées
notes.publication.hide.author.label=Masquer l'auteur
notes.publication.hide.reaction.label=Masquer la réaction
notes.publication.success.message=Note publi\u00E9e avec succ\u00E8s
notes.schedule.success.message=Note planifi\u00E9 avec succ\u00E8s
notes.publication.externalPage.publish.cancel.label=Annuler la publication

popup.confirm=Confirmer
popup.msg.confirmation=Confirmation
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* This file is part of the Meeds project (https://meeds.io/).
*
* Copyright (C) 2024 Meeds Association [email protected]
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-->
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.exoplatform.org/xml/ns/kernel_1_3.xsd http://www.exoplatform.org/xml/ns/kernel_1_3.xsd"
xmlns="http://www.exoplatform.org/xml/ns/kernel_1_3.xsd">
<component>
<key>NoteFeatureProperties</key>
<type>org.exoplatform.container.ExtendedPropertyConfigurator</type>
<init-params>
<properties-param>
<name>NoteFeatureProperties</name>
<description>Note Feature enablement flag</description>
<property name="exo.feature.insertImage.enabled"
value="${exo.feature.insertImage.enabled:false}"/>
<property name="exo.feature.notePublication.enabled"
value="${exo.feature.notePublication.enabled:false}"/>
</properties-param>
</init-params>
</component>
<external-component-plugins>
<target-component>org.exoplatform.groovyscript.text.TemplateService</target-component>
<component-plugin>
<name>UIPortalApplication-head</name>
<set-method>addTemplateExtension</set-method>
<type>org.exoplatform.groovyscript.text.TemplateExtensionPlugin</type>
<init-params>
<values-param>
<name>templates</name>
<description>The list of templates to include in HTML Page Header with UIPortalApplication.gtmpl</description>
<value>war:/groovy/webui/workspace/UINotesHeadTemplate.gtmpl</value>
</values-param>
</init-params>
</component-plugin>
</external-component-plugins>
</configuration>
6 changes: 6 additions & 0 deletions notes-webapp/src/main/webapp/WEB-INF/gatein-resources.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
<minify>false</minify>
<path>/javascript/notes.bundle.js</path>
</script>
<depends>
<module>NotesPublication</module>
</depends>
<depends>
<module>imageCropper</module>
</depends>
<depends>
<module>html2canvas</module>
</depends>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<%
import org.exoplatform.commons.api.settings.ExoFeatureService;
def rcontext = _ctx.getRequestContext();
ExoFeatureService featureService = uicomponent.getApplicationComponent(ExoFeatureService.class);
def userName = rcontext.getRemoteUser();
%>

<script type="text/javascript" id="NoteHeadScripts">
eXo.env.portal.insertImageOptionEnabled = <%=featureService.isFeatureActiveForUser("insertImage", userName)%>;
eXo.env.portal.notePublicationEnabled = <%=featureService.isFeatureActiveForUser("notePublication", userName)%>;
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ export default {
this.cloneScheduleSettings();
this.cloneAdvancedSettings();
this.clonePublicationSettings();
} else {
this.initSettings();
}
this.currentScheduleSettings = structuredClone(this.scheduleSettings);
this.currentAdvancedSettings = structuredClone(this.advancedSettings);
Expand Down Expand Up @@ -400,6 +402,11 @@ export default {
this.$refs?.scheduleOption?.cancelChanges();
this.$refs?.advancedOption?.cancelChanges();
},
initSettings() {
this.scheduleSettings = {};
this.advancedSettings = {};
this.publicationSettings = {post: true};
},
reset() {
setTimeout(() => {
this.cancelChanges();
Expand All @@ -422,7 +429,7 @@ export default {
return;
}
this.$emit('metadata-updated', this.noteObject.properties);
this.$emit('publish', this.noteObject, this.publicationSettings);
this.$emit('publish', this.publicationSettings, this.noteObject,);
},
updateCurrentNoteObjectProperties(properties) {
this.noteObject.properties.noteId = Number(properties.noteId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,18 @@ export default {
},
initSettings() {
if (!this.editMode) {
this.resetSettings();
return;
}
this.hideAuthor = this.savedAdvancedSettings?.hideAuthor;
this.hideReaction = this.savedAdvancedSettings?.hideReaction;
},
cancelChanges() {
this.initSettings();
},
resetSettings() {
this.hideAuthor = false;
this.hideReaction = false;
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,17 @@
:multiple="isMultipleSelectionOption"
class="d-flex ms-n1 mt-0 pt-0">
<v-radio
:label="cancelOption.label"
:value="cancelOption.value" />
v-if="fromExternalPage && !hasSavedUnpublishSchedule"
:label="$t('notes.publication.externalPage.publish.cancel.label')"
:value="CANCEL_SCHEDULE_OPTION" />
<v-radio
v-else-if="hasSavedUnpublishSchedule"
:label="$t('notes.publication.publish.cancel.label')"
:value="CANCEL_PUBLICATION_OPTION" />
<v-radio
v-else
:label="$t('notes.publication.schedule.cancel.label')"
:value="CANCEL_SCHEDULE_OPTION" />
<v-tooltip
v-if="canPublish"
:disabled="!isMultipleSelectionOption"
Expand Down Expand Up @@ -380,6 +389,7 @@ export default {
},
initSettings() {
if (!this.editMode) {
this.resetSettings();
return;
}
this.schedule = this.savedScheduleSettings.scheduled;
Expand Down Expand Up @@ -491,6 +501,17 @@ export default {
},
cancelChanges() {
this.initSettings();
},
resetSettings() {
this.schedule = false;
this.savedScheduleSettings = {};
const {startDate, minStartDate, endDate} = this.initDateValues();
this.startDate = startDate;
this.endDate = endDate;
this.minStartDate = minStartDate;
this.minEndDate = minStartDate;
this.endTime = '18:00';
this.startTime= '08:00';
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ export default {
}
this.postAndPublishNote();
},
postAndPublishNote(note, publicationSettings) {
postAndPublishNote(publicationSettings, note) {
if (this.newPublicationDrawerEnabled) {
this.noteObject = note;
this.updateData();
Expand Down
30 changes: 30 additions & 0 deletions notes-webapp/src/main/webapp/vue-app/notes-rich-editor/js/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,33 @@ export function isSameContent(content, originalContent) {
function getString(body) {
return new DOMParser().parseFromString(body, 'text/html').documentElement.textContent.replace(/&nbsp;/g, '').trim();
}

export function sanitizeSrcImageTags(content) {
if (!content) {
return content;
}
const regex = /(<img[^>]*?)(\s+src="data:image\/[^;]+;base64,[^"]*")/g;
content = content.replace(regex, '$1');
return content;
}

export function isHasImagesToBeProcessed(htmlStringContent, objectType) {
// Parse the HTML content
const parser = new DOMParser();
const document = parser.parseFromString(htmlStringContent, 'text/html');

const imgTags = document.querySelectorAll('img');
const prefix = '/portal/rest/v1/social/attachments/';

for (const imgTag of imgTags) {
const src = imgTag.getAttribute('src');
if (src?.startsWith?.(prefix)) {
const srcPart = src.substring(prefix.length);
const sourceObject = srcPart.substring(0, srcPart.indexOf('/'));
if (sourceObject !== objectType) {
return true;
}
}
}
return htmlStringContent.includes('cke_upload_id=');
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export default {
openNote(note) {
if (note.noteId !== this.actualNoteId ) {
this.$emit('open-note',note.id);
document.dispatchEvent(new CustomEvent('note-navigation-updated', {detail: note}));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ export default {
this.$root.$emit('open-note-by-name', noteName, note.draftPage);
this.$refs.breadcrumbDrawer.close();
}
document.dispatchEvent(new CustomEvent('note-navigation-updated', {detail: note}));
} else {
this.$refs.breadcrumbDrawer.close();
}
Expand Down
Loading

0 comments on commit 5e0b798

Please sign in to comment.