Commit Graph

4950 Commits

Author SHA1 Message Date
Théo Poizat b36b89cd04 Update Scribe mobile custom prompt bar UI 2026-03-25 11:52:35 +07:00
Théo Poizat 1e43ac510b Increase Scribe mobile inline button size 2026-03-25 11:52:35 +07:00
Théo Poizat ee546ef744 Fix Scribe mobile inline never showing modal
- The context.mounted check was placed after onTapFallback?.call()
- The onTapFallback function calls controller.saveAndUnfocusForModal() which unfocuses the editor
- This caused the context to become unmounted so the context.mounted check would return early
- As a result the modal would never be show
2026-03-25 11:52:35 +07:00
Théo Poizat 83452277b7 Use own Dio instance for prompt service 2026-03-25 11:52:35 +07:00
Théo Poizat 32cf606aea Cache Linagora Ecosystem in controller for Scribe 2026-03-25 11:52:35 +07:00
Théo Poizat 3ebb9113bc Revert "Cache LinagoraEcosystem to avoid multiple network calls"
This reverts commit 252f34f914fa21f8acf2ef2b5de9ac0ab28a8b4c.
2026-03-25 11:52:35 +07:00
Théo Poizat 1982f199ac Rework PromptService
- Use dependency injection and Get.find instead of manual singleton pattern
- Move from domain to data layer
- Prevents multiple API calls if the previous request hasn't finished
2026-03-25 11:52:35 +07:00
Théo Poizat 6d8d10cf26 Cache LinagoraEcosystem to avoid multiple network calls 2026-03-25 11:52:35 +07:00
Théo Poizat 71901b2640 Create and use an enum for AIRole in Scribe 2026-03-25 11:52:35 +07:00
Théo Poizat b84b2ce703 Fetch prompts from scribePromptUrl
First, we try to fetch prompts from scribePromptUrl. At fallback, we
use local prompts.
2026-03-25 11:52:35 +07:00
Théo Poizat a98368e6a6 Allow to get scribePromptUrl from LinagoraEcosystem 2026-03-25 11:52:35 +07:00
Théo Poizat 04696eecd7 Get and build prompt from local JSON file
Here we map our AI actions to the prompt from the JSON file
to be able to use them.
2026-03-25 11:52:35 +07:00
Théo Poizat 11fd808080 Add prompts.json in Scribe package
This is a default prompts.json used when no other will be available.
2026-03-25 11:52:35 +07:00
Théo Poizat fabf3ec54f Manage prompts as a "messages" object during prompt lifecycle
Before, our prompts were just a string like "Translate this text:
user text" and just before being sent to the backend, it was
converted to an "messages" object compatible with OpenAI API like [{
"role": "user", "content": "Translate this text: user text"}].

Now, we use "messages" object directly when building the prompt
because in the near future we will create more complex prompts with
system content and user content so we will need "messages" object
dirrectly.
2026-03-25 11:52:35 +07:00
Théo Poizat 2ab6e0df02 [Scribe] Add Improve button (#4335) 2026-03-25 11:52:35 +07:00
Théo Poizat c8253551b1 Add a toolbar to execute quick actions to Scribe suggestion
Actions :
 - copy
- regenerate
2026-03-25 11:52:35 +07:00
Théo Poizat 4ba6184a69 Rename bottomsheetIcon to secondaryIcon
To be able to reuse this color without loosing a correct semantic name.
2026-03-25 11:52:35 +07:00
dab246 b64aa4e4c7 feat(scribe-mobile):Fix sometimes the top part is cut off 2026-03-25 11:52:35 +07:00
dab246 5937055789 feat(scribe-mobile): Display the result prompt modal in the correct position relative to the inline scribe button on tablet 2026-03-25 11:52:35 +07:00
Théo Poizat 170bdd28c9 Autofocus Scribe input bar
Help user use the Scribe input bar. Also solves issues where Scribe bar is not well positioned when focused is removed from "To" field.
2026-03-25 11:52:35 +07:00
Théo Poizat d035e40853 fixup! Display Scribe modals correctly when a keyboard is opened
Manage multiline content in scribe bar and spacing between keyboard and scribe bar
2026-03-25 11:52:35 +07:00
Théo Poizat 13f81a9bee Include spacer in tablet bottom bar Scribe button 2026-03-25 11:52:35 +07:00
Théo Poizat 269ca7116c Display Scribe modals correctly when a keyboard is opened 2026-03-25 11:52:35 +07:00
Théo Poizat 7b3e3e1b16 Do not focus composer when clicking on tablet bottom bar button 2026-03-25 11:52:35 +07:00
Théo Poizat 0d7813c368 Display AI Scribe toggle in preferences in mobile
It has been forgotten when enabling AI Scribe in mobile.
2026-03-25 11:52:35 +07:00
Théo Poizat ed53929323 fixup! Display Scribe mobile (bottomsheet) only when responsive mobile 2026-03-25 11:52:35 +07:00
Théo Poizat 03a03b9088 Fix Scribe on responsive mobile
- Button was not added in MobileResponsiveAppBar
- Mobile behavior related scripts were not correctly added for web composer
- Mobile behavior related scripts return value was not properly handled for web composer
- In responsive web, bottomsheet modal clicks were intercepted by iframe behind
2026-03-25 11:52:35 +07:00
Théo Poizat 46a12745a5 Ensure replace function respect new lines in every editor 2026-03-25 11:52:35 +07:00
Théo Poizat 17b9d97284 Adjust Scribe context menu to support tablet screens
- Support tap in addition to hover for context menu
- Improve clamping for greater screen sizes to avoid Scribe getting off screen
- Set a padding to 0 to avoid random padding depending on screen sizes
2026-03-25 11:52:35 +07:00
Théo Poizat 7a6a49fc7b Display Scribe mobile (bottomsheet) only when responsive mobile
Previosuly, we display Scribe mobile (bottomsheet) if platform was mobile, so also Android or iOS tablet.

Now we choose to display Scribe mobile relatively to display screens instead of platform to display the desktop Scribe (context menu) for tablets.
2026-03-25 11:52:35 +07:00
Théo Poizat 6540ed29d1 Add current text in a card in Scribe mobile
Because the Scribe mobile is a full screen modal, we do not see the
current content (so either the selected text or entire composer text)
when selecting our AI actions.

That's why we add here a scrollable card that displays the current
content.
2026-03-25 11:52:35 +07:00
Théo Poizat 26393c038b Upgrade enough_html_editor
To enjoy the fix from the following PR https://github.com/linagora/enough_html_editor/pull/40
2026-03-25 11:52:35 +07:00
Théo Poizat 40030fe88e Properly escape HTML in every Scribe actions
In recent commits I separated how we could add text in the editor. So
we need to escape HTML in both method that add text:
insertTextInEditor and setTextInEditor.

I had to extract the HTML escape part of
convertTextContentToHtmlContent because when using setTextInEditor we
do not need to convert \n to <br>.
2026-03-25 11:52:35 +07:00
Théo Poizat cf8ed16ed0 Use warning logs instead of error logs for Scribe 2026-03-25 11:52:35 +07:00
Théo Poizat c05a01d92a Move Scribe icon in tablet at left of icons 2026-03-25 11:52:35 +07:00
Théo Poizat b5606626f4 Fix more Scribe mobile issues
- Add getSavedSelection to check saved selection without consuming it
- Distinguish between setText (replace all) and insertText (at cursor) operations
- Fix replace callback to use setText when no selection exists
- Clean up saved selection state after restoration in HTML utils
- Move mobile editor focus and selection restore to appropriate callbacks
2026-03-25 11:52:35 +07:00
Théo Poizat be7f28f270 Fix Scribe mobile issues
- Fix Scribe replace on mobile when opened from menu bar (to be complete
this fix needs this PR https://github.com/Enough-Software/enough_html_editor/pull/37)
- Ensure all mobile editor call are awaited
- Do not clear text if a selection has been restored (which mean we replace a selection)
- Avoid collapseToEnd crash
2026-03-25 11:52:35 +07:00
Théo Poizat abd2453511 Do not display Scribe actions if no content in composer in mobile 2026-03-25 11:52:35 +07:00
Théo Poizat 752f42dc7d Ensure editor is focused before calling insert HTML
enough_html_editor uses execCommand to insert HTML. However
execCommand only works if the contenteditable element is focused. So
inserting or replacing Scribe result do not work if the user did not
click before in the composer.

Here we manually focus the contenteditable element to fix this before
inserting content.
2026-03-25 11:52:35 +07:00
Théo Poizat 84176cb113 Hide keyboard and selection icons when Scribe mobile modal opened
When opening Scribe mobile modal, we now unfocus the composer to hide the keyboard and the selection start and end icons from the OS.

Add new methods to save, restore, and clear text selection in HTML editor. These methods allow preserving and restoring user selection state when opening the Scribe mobile modal so that the "replace" action still works.
2026-03-25 11:52:35 +07:00
Théo Poizat 09fe002d3c Use proper icons and styles for bottomsheet icons in Scribe 2026-03-25 11:52:35 +07:00
Théo Poizat 14f2e557fa Add Scribe mobile
Same features than Scribe desktop but as a full screen modal instead of  a context menu.

Reuse menu and submenu components.
Reuse suggestion components.
Reuse 99% of Scribe desktop style.
2026-03-25 11:52:35 +07:00
Théo Poizat 245dfc714d Display sparkle button in mobile app bar to launch AI Scribe
- Same icon than for desktop
- Displayed only if AI Scribe is enabled
2026-03-25 11:52:35 +07:00
Théo Poizat 089eb7b75f Fix correct grammar icon not present in submenu getIcon 2026-03-25 11:52:35 +07:00
Théo Poizat b28dea732a Fix AI Scribe overlay button display in iOS
The button was never displayed because the selectionchange event listener was loaded when the WebView was not entirely loaded so selectionchange event were never fired.

Now we setup selection listener when the WebView is loaded instead of created.
2026-03-25 11:52:35 +07:00
Théo Poizat 03c70922a0 Fix selection coordinates in mobile
Because the HTML editor is different, we need a different selector to get the editable element.

We also need to add a small offset to the coordinates to avoid positionning the overlay icon above native selection UI in mobile. For example, Android adds a marker at the beginning and the end of the selection and we do not want to display the Scribe overlay icon above this marker.
2026-03-25 11:52:35 +07:00
Théo Poizat 9e601caa86 Enable AI scribe in mobile 2026-03-25 11:52:35 +07:00
Théo Poizat 0f4ed4537e Remove unused localizations arguments in Scribe suggestion 2026-03-25 11:52:35 +07:00
Théo Poizat 5abce414d4 Guard Scribe suggestion loading if interactor is null 2026-03-25 11:52:35 +07:00
Théo Poizat 5bdcff5aba Extract Scribe menu item text and icons in components 2026-03-25 11:52:35 +07:00