From 7f26bed1c9549ab29b9015fbab104f171a7abdd1 Mon Sep 17 00:00:00 2001 From: Paola De Bartolo Date: Wed, 30 Jul 2025 16:27:05 -0300 Subject: [PATCH 1/2] fix: add missing encoding for media links Close #18 --- .../frontend/src/fc-sharee-connector.js | 44 +++++++++++++------ 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/src/main/resources/META-INF/resources/frontend/src/fc-sharee-connector.js b/src/main/resources/META-INF/resources/frontend/src/fc-sharee-connector.js index 2fc0f6d..6b6fb56 100644 --- a/src/main/resources/META-INF/resources/frontend/src/fc-sharee-connector.js +++ b/src/main/resources/META-INF/resources/frontend/src/fc-sharee-connector.js @@ -21,22 +21,24 @@ import Sharee from 'sharee'; window.fcShareeConnector = { - create: function (container, optionsJson) { + create: function(container, optionsJson) { this._updateXButtonLabel(); - this._updateCopyDriverOnClick(); - let parsedOptions = JSON.parse(optionsJson); - const sharee = new Sharee(container, parsedOptions); - }, + this._updateSocialShareLinks(); + this._updateCopyDriverOnClick(); + let parsedOptions = JSON.parse(optionsJson); + const sharee = new Sharee(container, parsedOptions); + }, - createWithCustomDrivers: function (container, optionsJson) { + createWithCustomDrivers: function(container, optionsJson) { this._updateXButtonLabel(); - this._updateCopyDriverOnClick(); - let parsedOptions = JSON.parse(optionsJson); - // add the custom drivers to the list of drivers - let drivers = parsedOptions.drivers.concat(container.customDrivers); - parsedOptions.drivers = drivers; - const sharee = new Sharee(container, parsedOptions); - }, + this._updateSocialShareLinks(); + this._updateCopyDriverOnClick(); + let parsedOptions = JSON.parse(optionsJson); + // add the custom drivers to the list of drivers + let drivers = parsedOptions.drivers.concat(container.customDrivers); + parsedOptions.drivers = drivers; + const sharee = new Sharee(container, parsedOptions); + }, addCustomDriver(container, customDriverJson) { if (container.customDrivers == null) { @@ -88,6 +90,22 @@ window.fcShareeConnector = { Sharee.addDriver(name, f); }, + + /* + * Workaround because of issue https://github.com/parsagholipour/sharee/issues/8 + * (to be removed when issue is fixed) + */ + _updateSocialShareLinks() { + Sharee.drivers['facebook'].prototype.getLink = function() { + return `https://facebook.com/sharer/sharer.php?u=${encodeURIComponent(this.options?.shareLink)}&t=${encodeURIComponent(this.options?.shareText)}` + } + Sharee.drivers['whatsapp'].prototype.getLink = function() { + return `https://wa.me?text=${encodeURIComponent(this.options?.shareText)} \n ${encodeURIComponent(this.options?.shareLink)}` + } + Sharee.drivers['linkedin'].prototype.getLink = function() { + return `https://www.linkedin.com/shareArticle?url=${encodeURIComponent(this.options?.shareLink)}` + } + }, /** * Replaces onClick function on CopyDriver to take in consideration shareLink option From 643494ca3e50bedd9eb09b2fded61ede13796a42 Mon Sep 17 00:00:00 2001 From: Paola De Bartolo Date: Wed, 30 Jul 2025 16:57:51 -0300 Subject: [PATCH 2/2] refactor: extract driver configuration into _configureDrivers helper --- .../frontend/src/fc-sharee-connector.js | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/resources/META-INF/resources/frontend/src/fc-sharee-connector.js b/src/main/resources/META-INF/resources/frontend/src/fc-sharee-connector.js index 6b6fb56..0c24c07 100644 --- a/src/main/resources/META-INF/resources/frontend/src/fc-sharee-connector.js +++ b/src/main/resources/META-INF/resources/frontend/src/fc-sharee-connector.js @@ -22,17 +22,13 @@ import Sharee from 'sharee'; window.fcShareeConnector = { create: function(container, optionsJson) { - this._updateXButtonLabel(); - this._updateSocialShareLinks(); - this._updateCopyDriverOnClick(); + this._configureDrivers(); let parsedOptions = JSON.parse(optionsJson); const sharee = new Sharee(container, parsedOptions); }, createWithCustomDrivers: function(container, optionsJson) { - this._updateXButtonLabel(); - this._updateSocialShareLinks(); - this._updateCopyDriverOnClick(); + this._configureDrivers(); let parsedOptions = JSON.parse(optionsJson); // add the custom drivers to the list of drivers let drivers = parsedOptions.drivers.concat(container.customDrivers); @@ -91,6 +87,18 @@ window.fcShareeConnector = { Sharee.addDriver(name, f); }, + /** + * Configures Sharee drivers by applying required overrides and fixes. + * + * Includes workarounds for missing features and/or known issues in the base library. + * To be revisited if upstream issues are resolved. + */ + _configureDrivers() { + this._updateXButtonLabel(); + this._updateSocialShareLinks(); + this._updateCopyDriverOnClick(); + }, + /* * Workaround because of issue https://github.com/parsagholipour/sharee/issues/8 * (to be removed when issue is fixed)