Draft
Conversation
Signed-off-by: Hendrik Leidinger <hendrik.leidinger@nextcloud.com>
Signed-off-by: Hendrik Leidinger <hendrik.leidinger@nextcloud.com>
Signed-off-by: Hendrik Leidinger <hendrik.leidinger@nextcloud.com>
Signed-off-by: Hendrik Leidinger <hendrik.leidinger@nextcloud.com>
Signed-off-by: Hendrik Leidinger <hendrik.leidinger@nextcloud.com>
…tation editors api.PastePlainText only exists in cell/api.js (spreadsheet). Calling it on the documenteditor / presentationeditor api throws and triggers OnlyOffice's generic 'An error occurred during the work with the document' dialog, leaving the document in an unrecoverable state. Route the insertPlainText gateway command through asc_PasteData with c_oAscClipboardDataFormat.Text instead. The spreadsheet handler keeps calling PastePlainText since it is supported natively there. Signed-off-by: Christoph Schaefer <christoph.schaefer@nextcloud.com>
…to literal 1 Asc.c_oAscClipboardDataFormat is undefined in the documenteditor / presentationeditor runtime — the constant lives on AscCommon. Read it from AscCommon and fall back to the literal 1 (Text format from clipboard_base.js) so insertPlainText keeps working even if the namespace shifts again. Signed-off-by: Christoph Schaefer <christoph.schaefer@nextcloud.com>
OnlyOffice already ships an AI/sparkles SVG symbol (btn-general-ai) in apps/common/main/resources/img/toolbar/icons.svg, used by the Macros 'AI Assistant' dialog. Same MDI 'creation' shape that NC's Assistant uses, so the Smart Picker toolbar entry now matches both OO's existing AI surfaces and NC's iconography. The icon lives in the small (24x24) common sprite, not the per-editor big (28x28) sprite. SVG scaling makes that visually fine for the x-huge button — it renders a touch thinner than the surrounding big-sprite icons but reads as the right symbol. A dedicated btn-big-general-ai variant can land later if needed. Signed-off-by: Christoph Schaefer <christoph.schaefer@nextcloud.com>
Closure Compiler advanced-mode renames any prototype property assigned
with dotted notation, so asc_docs_api.prototype.asc_PasteData = ... is
unreachable from outside the bundle (the runtime property name is
mangled). Only methods registered via window['asc_docs_api'].
prototype['<name>'] = ... survive minification.
In sdkjs/word/api.js the only such text-insertion entry is Add_Text
('cool api'), which calls TextBox_Put internally — that is the public
entry for typing characters at the current cursor regardless of
context (body / textbox / etc.).
Switch document and presentation editor insertPlainText handlers to
prefer Add_Text and only fall back to asc_PasteData if a build keeps
the dotted-notation method (it normally won't).
Signed-off-by: Christoph Schaefer <christoph.schaefer@nextcloud.com>
…sertion Previous attempts (Add_Text, asc_PasteData, PastePlainText) only worked in the documenteditor — Add_Text is exposed only on word's asc_docs_api, asc_PasteData is mangled by Closure Compiler advanced-mode in all three editors, and PastePlainText was removed from the spreadsheet api. Result: smart-picker silently no-op'd in slide and cell editors. Switch all three editors' insertPlainText handlers to this.api['pluginMethod_PasteText'], which is registered in sdkjs/common/apiBase_plugins.js as Api.prototype['pluginMethod_PasteText'] — bracket notation survives minification, the JSDoc declares it valid for ["CDE", "CSE", "CPE"], and internally it calls asc_PasteData with c_oAscClipboardDataFormat.Text wrapped in executeGroupActions for clean undo. This is the same entry point OnlyOffice's own AI plugin uses. Signed-off-by: Christoph Schaefer <christoph.schaefer@nextcloud.com>
Step (4) of the deeper Assistant integration plan: when the user has
text selected and clicks Smart Picker, the AI's reply should replace
the selected text in place rather than appending at the cursor.
Three changes:
1. Read the active selection via api['asc_GetSelectedText']() at click
time and forward it through the postMessage payload so NC's
Assistant can seed its input with it.
2. In documenteditor, drop a hidden bookmark on the selected range
('eurooffice_smartpicker_anchor') via the bracket-exposed
asc_GetBookmarksManager / asc_AddBookmark. The toolbar click would
otherwise collapse the selection (focus shifts to the button), so
the range needs to be anchored to survive the modal round-trip.
3. In insertPlainText, restore the selection by SelectBookmark, drop
the bookmark, then call pluginMethod_PasteText. With the selection
re-established, asc_PasteData replaces it.
For presentationeditor and spreadsheeteditor we capture selection text
but cannot anchor (no bookmark manager). Inline replacement there is
best-effort: if the editor preserves selection across the toolbar
click, paste replaces; otherwise the AI reply lands at the cursor
(matching the previous behaviour).
Signed-off-by: Christoph Schaefer <christoph.schaefer@nextcloud.com>
…isable Rename the Smart Picker toolbar entry to 'Nextcloud Assistant' across the document, spreadsheet and presentation editors (caption + tooltip) and switch the icon to the bundled Material Design 'creation' sparkles that NC's own Assistant uses (apps/settings/img/ai.svg, MIT-equivalent license). The SVG is embedded as a new symbol id='btn-nc-assistant' in apps/common/main/resources/img/toolbar/icons.svg, so the icon ships with the bundle and does not depend on Nextcloud serving ai.svg. Add a host->editor command setSmartPickerEnabled(boolean) so the host (Nextcloud integration) can disable the toolbar entry at runtime when the Assistant app isn't loaded. The command travels through the existing api.js / Gateway.js plumbing and resolves to btnSmartPicker.setDisabled in each editor controller. Signed-off-by: Christoph Schaefer <christoph.schaefer@nextcloud.com>
The previous commit edited the assembled apps/common/main/resources/img/toolbar/icons.svg directly, but the grunt prebuild-svg-sprites task regenerates that file from individual SVGs in apps/common/main/resources/img/toolbar/v2/2.5x/ on every build, dropping the new symbol on the floor. Add the icon as a source file (btn-nc-assistant.svg) so the sprite picks it up by filename — the symbol id matches the basename. Revert the manual edit of icons.svg. Signed-off-by: Christoph Schaefer <christoph.schaefer@nextcloud.com>
The Smart Picker now opens the NC Assistant form seeded with the editor selection and stops there — the user reads or copies the AI result manually. We do not try to paste back into the document because plain-text paste loses formatting on round-trip; until that preserves at least basic styling the feature is intentionally read-only. Drop the bookmark anchor / select / remove dance from onBtnSmartPickerClick (no replacement happens, so no anchor needed). Simplify documenteditor's insertPlainText handler to plain pluginMethod_PasteText — still useful for other host integrations that paste plain text via the gateway. Spreadsheet and presentation editors already only captured selection and forwarded it; no change needed there. All three editors now follow the same minimal flow. Signed-off-by: Christoph Schaefer <christoph.schaefer@nextcloud.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The web-app counter part for feat(smartpicker): wire NC Assistant Smart Picker bridge
Euro-Office/eurooffice-nextcloud#17
This PR is based on the preparation work for Smart Picker by @rikled