-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable selecting image when the only element in the range is an Image #2554
Conversation
Restore the snapshot below, press Shift+Right, it should select image and the next character, but it actually only select the image. <div>aa<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAqSURBVDhPYzyT1vGfgYqACUpTDYwaSDkYNZByMGog5WDUQMrBYDeQgQEAuWsC4QyQdEYAAAAASUVORK5CYII=" id="image_0" style="max-width: 3390px;">bb</div><!--{"type":"image","imageId":"image_0","isDarkMode":false}--> |
Good catch taking a look. |
What about Ctrl+Home and Ctrl+End? |
Actually, because there is a hidden selection before/after the image, those Up/Down/Left/Right/Home/End/... key will update this hidden selection. Can we rely on selectionchange event to detect if the real selection need to be changed, then unselect image? So we don't need to handle all keys. Similarly, I remember @juliaroldi has a bug to deal with Ctrl+A for image selection, it can also be fixed by this way.
|
What other keys can modify selection other than Ctrl + A, and shift + (Arrows/End/Home/PageUp/PageDown)? I guess another solution is that when we have ImageSelection always add a Range selecting the image + Adding a style to the editor to hide :selection. Because right now when we select the image we also collapse the selection and would also trigger a selectionchanged event |
I think that is a good idea. |
…microsoft/roosterjs into u/bvalverde/selectImageWithKeys
* code suport * markdown * adjust * demo site * WIP * fix code pen * fix demo site * Handle Tab key on whole table selection or last cell on Edit Plugin (#2536) * Implement indent whole table * implement tab on last cell new row * add Table selection and single cell handling * export clearSelectedCells * undefined check, simplify * add tests * add test for list in table edge case * Fix seelection on void element (#2551) * port hyphen * Implement movement with Tab key inside Table (#2529) * implement tab movement, tests * remove unused variable * fix name, normalisation, add test * fix wrong parethesis * restore normalizePos * fix tests * add formatTextSegmentBeforeSelectionMarker * Improve backspace on list (#2555) * fix selection with ctrl+a * refactor code using formatTextSegmentBeforeSelectionMarkerTest * remove getLinkSegment * Set default format in demo site (#2559) * clean demo site * clean * Enable selecting image when the only element in the range is an Image (#2554) * init * Address comment * Reuse isReverted from Range Selection * Fix build * Fix build * Unselect image when Up or Down, or it remains selected * remove unneeded changes and improve name of tests * Update --------- Co-authored-by: Julia Roldi <87443959+juliaroldi@users.noreply.github.com> * fix markdown plugin * Port Hyperlink plugin (#2560) * Port Hyperlink plugin * improve --------- Co-authored-by: Bryan Valverde U <bvalverde@microsoft.com> * export formatTextSegmentBeforeSelectionMarker * fix build * Prevent ScrollTop to be lost when the focus is done to the editor (#2564) * init * init --------- Co-authored-by: Julia Roldi <87443959+juliaroldi@users.noreply.github.com> * Fix 265959: extra empty line generated when get plain text (#2566) Co-authored-by: Bryan Valverde U <bvalverde@microsoft.com> * Fix #2500 Hyperlink misses color (#2570) * Fix #2500 * fix test * Update version.json * mac shortcuts * fix test --------- Co-authored-by: Júlia Roldi <juliaroldi@microsoft.com> Co-authored-by: Julia Roldi <87443959+juliaroldi@users.noreply.github.com> Co-authored-by: Andres-CT98 <107568016+Andres-CT98@users.noreply.github.com> Co-authored-by: Jiuqing Song <jisong@microsoft.com>
* code suport * markdown * adjust * demo site * WIP * fix code pen * fix demo site * Handle Tab key on whole table selection or last cell on Edit Plugin (#2536) * Implement indent whole table * implement tab on last cell new row * add Table selection and single cell handling * export clearSelectedCells * undefined check, simplify * add tests * add test for list in table edge case * Fix seelection on void element (#2551) * port hyphen * Implement movement with Tab key inside Table (#2529) * implement tab movement, tests * remove unused variable * fix name, normalisation, add test * fix wrong parethesis * restore normalizePos * fix tests * add formatTextSegmentBeforeSelectionMarker * Improve backspace on list (#2555) * fix selection with ctrl+a * refactor code using formatTextSegmentBeforeSelectionMarkerTest * remove getLinkSegment * Set default format in demo site (#2559) * clean demo site * clean * Enable selecting image when the only element in the range is an Image (#2554) * init * Address comment * Reuse isReverted from Range Selection * Fix build * Fix build * Unselect image when Up or Down, or it remains selected * remove unneeded changes and improve name of tests * Update --------- Co-authored-by: Julia Roldi <87443959+juliaroldi@users.noreply.github.com> * fix markdown plugin * Port Hyperlink plugin (#2560) * Port Hyperlink plugin * improve --------- Co-authored-by: Bryan Valverde U <bvalverde@microsoft.com> * export formatTextSegmentBeforeSelectionMarker * fix build * Prevent ScrollTop to be lost when the focus is done to the editor (#2564) * init * init --------- Co-authored-by: Julia Roldi <87443959+juliaroldi@users.noreply.github.com> * Fix 265959: extra empty line generated when get plain text (#2566) Co-authored-by: Bryan Valverde U <bvalverde@microsoft.com> * Fix #2500 Hyperlink misses color (#2570) * Fix #2500 * fix test * mac shortcuts * fix test * restore selection (#2577) * fix: on webkit-based applications, when the selection is empty, focus will cause the window to scroll to the top (#2571) Co-authored-by: Julia Roldi <87443959+juliaroldi@users.noreply.github.com> Co-authored-by: Jiuqing Song <jisong@microsoft.com> * Port PickerPlugin (#2569) * Port PickerPlugin * fix buid * Improve * fix build * Improve * Improve * add test * Improve * adjust image * fix test * fixes * remove * Preserve reverted selection info in Content Model (#2580) * Preserve reverted selection info in Content Model * improve * fix empty text * trigger Events * Allow Shift+Delete to Cut (#2585) * Allow Shift+Delete to Cut * improve * change source * fix build * Fix #2584: Safari context menu event causes selection to be expanded (#2588) * Fix #2584: Safari context menu event causes selection to be expanded * fix test * Port AnnouncePlugin step 1: refactor list number code (#2589) * test * refactor * fix demo site * Select image after inserting it (#2593) * Focus image after insertion * Revert "Focus image after insertion" This reverts commit 887c9e5. * Use setSelection * Port AnnouncePlugin Step 2: Add announce core API (#2591) * Port AnnouncePlugin step 1: refactor list number code * Port AnnouncePlugin step 2 --------- Co-authored-by: Bryan Valverde U <bvalverde@microsoft.com> * WIP * custom replace * Fix table mover selector (#2596) * fix edge case tables and trigger contentchanged * revert event * trigger autolink * wip * Port AnnouncePlugin step 3: Add announce features for list and table (#2592) * Port AnnouncePlugin step 1: refactor list number code * Port AnnouncePlugin step 2 * Port AnnouncePlugin ste 3 * add test * Fix #2575 Entity delimiter cursor moving (#2581) * Preserve reverted selection info in Content Model * Entity delimiter cursor moving (#2575) * improve * Add test * add test * update main version * Fix difference with master * Allow customizability for table editors (#2603) * init * Simplify type callback * Also allow using Ctrl-Shift-Z on Windows (#2607) * Also allow using Ctrl-Shift-Z on Windows * Fix failing test * Fix broken test * Fix failing test * Keep and deprecate old ShortcutRedoMacOS * Remove test not needed anymore * Fix test * Try fix setFormatTest * Fix merge issues --------- Co-authored-by: Júlia Roldi <juliaroldi@microsoft.com> Co-authored-by: Julia Roldi <87443959+juliaroldi@users.noreply.github.com> Co-authored-by: Andres-CT98 <107568016+Andres-CT98@users.noreply.github.com> Co-authored-by: Jiuqing Song <jisong@microsoft.com> Co-authored-by: Bryan Valverde U <bvalverde@microsoft.com> Co-authored-by: Rain-Zheng <67583056+Rain-Zheng@users.noreply.github.com> Co-authored-by: 庄黛淳华 <miku1958@users.noreply.github.com> Co-authored-by: florian-msft <87671048+florian-msft@users.noreply.github.com>
* code suport * markdown * adjust * demo site * WIP * fix code pen * fix demo site * Handle Tab key on whole table selection or last cell on Edit Plugin (#2536) * Implement indent whole table * implement tab on last cell new row * add Table selection and single cell handling * export clearSelectedCells * undefined check, simplify * add tests * add test for list in table edge case * Fix seelection on void element (#2551) * port hyphen * Implement movement with Tab key inside Table (#2529) * implement tab movement, tests * remove unused variable * fix name, normalisation, add test * fix wrong parethesis * restore normalizePos * fix tests * add formatTextSegmentBeforeSelectionMarker * Improve backspace on list (#2555) * fix selection with ctrl+a * refactor code using formatTextSegmentBeforeSelectionMarkerTest * remove getLinkSegment * Set default format in demo site (#2559) * clean demo site * clean * Enable selecting image when the only element in the range is an Image (#2554) * init * Address comment * Reuse isReverted from Range Selection * Fix build * Fix build * Unselect image when Up or Down, or it remains selected * remove unneeded changes and improve name of tests * Update --------- Co-authored-by: Julia Roldi <87443959+juliaroldi@users.noreply.github.com> * fix markdown plugin * Port Hyperlink plugin (#2560) * Port Hyperlink plugin * improve --------- Co-authored-by: Bryan Valverde U <bvalverde@microsoft.com> * export formatTextSegmentBeforeSelectionMarker * fix build * Prevent ScrollTop to be lost when the focus is done to the editor (#2564) * init * init --------- Co-authored-by: Julia Roldi <87443959+juliaroldi@users.noreply.github.com> * Fix 265959: extra empty line generated when get plain text (#2566) Co-authored-by: Bryan Valverde U <bvalverde@microsoft.com> * Fix #2500 Hyperlink misses color (#2570) * Fix #2500 * fix test * mac shortcuts * fix test * restore selection (#2577) * fix: on webkit-based applications, when the selection is empty, focus will cause the window to scroll to the top (#2571) Co-authored-by: Julia Roldi <87443959+juliaroldi@users.noreply.github.com> Co-authored-by: Jiuqing Song <jisong@microsoft.com> * Port PickerPlugin (#2569) * Port PickerPlugin * fix buid * Improve * fix build * Improve * Improve * add test * Improve * adjust image * fix test * fixes * remove * Preserve reverted selection info in Content Model (#2580) * Preserve reverted selection info in Content Model * improve * fix empty text * trigger Events * Allow Shift+Delete to Cut (#2585) * Allow Shift+Delete to Cut * improve * change source * fix build * Fix #2584: Safari context menu event causes selection to be expanded (#2588) * Fix #2584: Safari context menu event causes selection to be expanded * fix test * Port AnnouncePlugin step 1: refactor list number code (#2589) * test * refactor * fix demo site * Select image after inserting it (#2593) * Focus image after insertion * Revert "Focus image after insertion" This reverts commit 887c9e5. * Use setSelection * Port AnnouncePlugin Step 2: Add announce core API (#2591) * Port AnnouncePlugin step 1: refactor list number code * Port AnnouncePlugin step 2 --------- Co-authored-by: Bryan Valverde U <bvalverde@microsoft.com> * WIP * custom replace * Fix table mover selector (#2596) * fix edge case tables and trigger contentchanged * revert event * trigger autolink * wip * Port AnnouncePlugin step 3: Add announce features for list and table (#2592) * Port AnnouncePlugin step 1: refactor list number code * Port AnnouncePlugin step 2 * Port AnnouncePlugin ste 3 * add test * Fix #2575 Entity delimiter cursor moving (#2581) * Preserve reverted selection info in Content Model * Entity delimiter cursor moving (#2575) * improve * Add test * add test * Allow customizability for table editors (#2603) * init * Simplify type callback * Also allow using Ctrl-Shift-Z on Windows (#2607) * Also allow using Ctrl-Shift-Z on Windows * Fix failing test * Fix broken test * Fix failing test * Keep and deprecate old ShortcutRedoMacOS * Remove test not needed anymore * Wip * add span * fix test * changes * remove code * fixes * fixes * Hide watermark when input with IME (#2611) * Updated watermark property access modifier to protected (#2614) * Move Content Model type files into contentModel folder (#2602) * Fix 262779 (#2600) * Add undo snapshot when mouse down if there is new content after last undo snapshot (#2604) * Fix #2601 allow customization when convert from content model to plain text (#2605) * Fix #2601 allow customization when convert from content model to plain text * Improve * fix test * fix build * Scroll caret into view when call formatContentModel (#2617) * Perf step 0: Do not allow getting connected model (#2615) * Perf: Do not allow getting connected model * fix build * fix build * debug firefox options (#2620) * Updated isModelEmptyFast to consider changed indentation as not empty string (#2625) * Updated isModelEmptyFast * Tests fix * Add parameter to Disable table edit features (#2624) * disableFeatures, renaming * Export Table Feature Ids * Modify and create tests * move Id to respective feature, add tests, cleanup * export feature names * TableEditFeatureName * Implement Table Movement (#2599) * isNodeEditor * domHelper test * implementation and test fix * fix undefined * isNodeEditor * implement live focus, restore initial selection on cancel * broswer drag and drop attempt * use getNodePositionFromEvent, add move cursor while dragging * restore class * fix import * restore DOMHelper * remove unneeded snapshots and checks, add copy feature * cleanup * fix merge * cursor change on copy, remove onEditorCreated * fix disposal issue * removed unused forEach, * export formatInsertPointWithContentModel * use formatInsertPointWithContentModel for table movement * reorder function * Add tests for table movement * optimisations and exports for testing * restore final table selection after move * added test * fix and add more tests * comments, remove copy feature, fix tests * fix test * fix test * implement disable movement * Do not apply Table selection if table is not editable (#2628) * Fix #2633 `scrollCaretIntoView` causes unexpected scroll (#2634) * Fix #2633 * add comment * Added tableCellSelectionBackgroundColor option (#2640) * Added tableCellSelectionBackgroundColor option * Fixed a test * Tests fix * Tests fix * Add dark color handling for table and image selection (#2647) * Added tableCellSelectionBackgroundColor option * Fixed a test * Tests fix * Tests fix * Add dark color check * Add more tests * Updated login and tests * Functionality update * Update checks * Added transparent options test * Code review fixes * Fix cursor jump issue when applying Gboard suggestions (#2638) * fix cursor issue * resolve comment --------- Co-authored-by: Jiuqing Song <jisong@microsoft.com> * Content Model Cache improvement - Step 1: Introduce Readonly types and mutate utility (#2629) * Readonly types (3rd try * Improve * fix build * Improve * improve * Improve * Add shallow mutable type * improve * Improve * improve * improve * add test * improve * improve * improve * test * test * link preview * remove auto format plugin code * Content Model Cache improvement - Step 2: Prepare utility functions (#2641) * Readonly types (3rd try * Improve * fix build * Improve * improve * Improve * Add shallow mutable type * improve * Improve * improve * improve * add test * Readonly types step 2 * add test * Improve * improve * improve * improve * Improve * fix test * improve * Content Model Cache improvement - Step 3: Let creators accept readonly types (#2642) * Readonly types (3rd try * Improve * fix build * Improve * improve * Improve * Add shallow mutable type * improve * Improve * improve * improve * add test * Readonly types step 3 * improve * improve * improve * Content Model Cache improvement - Step 4: Port "readonly" functions (#2643) * Readonly types (3rd try * Improve * fix build * Improve * improve * Improve * Add shallow mutable type * improve * Improve * improve * improve * add test * Readonly types step 2 * Readonly types step 3 * Readonly type step 4 * add test * Improve * improve * improve * improve * improve * Improve * improve * fix test * improve * Fix Table first column (#2652) * create Table Options button for demo * fix setFirstColumnFormat * fix dependency * restore background color check for first column * remove logs, move TableOptionsMenuItemStringKey, isHeader * remove import * Content Model Cache improvement - Step 5: Port roosterjs-content-model-dom package (#2648) * Readonly types (3rd try * Improve * fix build * Improve * improve * Improve * Add shallow mutable type * improve * Improve * improve * improve * add test * Readonly types step 2 * Readonly types step 3 * Readonly type step 4 * add test * Improve * improve * improve * Readonly types step 5: dom package * add change * improve * improve * Improve * improve * fix test * Improve * fix build * improve * Optimise content model table fetching for Table Edit Plugins (#2656) * optimise cmTable fetching * create getCMTableFromTable * Fix normalisation and First Column issues (#2657) * optimise cmTable fetching * First Column not apply to very first cell * fix normalisation * fix first cell color for First Column * fix and add test * fix test * fix tests * fix test and hasHeaderRow case * reorder rows * bump * bump --------- Co-authored-by: Júlia Roldi <juliaroldi@microsoft.com> Co-authored-by: Julia Roldi <87443959+juliaroldi@users.noreply.github.com> Co-authored-by: Jiuqing Song <jisong@microsoft.com> Co-authored-by: Bryan Valverde U <bvalverde@microsoft.com> Co-authored-by: Rain-Zheng <67583056+Rain-Zheng@users.noreply.github.com> Co-authored-by: 庄黛淳华 <miku1958@users.noreply.github.com> Co-authored-by: florian-msft <87671048+florian-msft@users.noreply.github.com> Co-authored-by: vhuseinova-msft <98852890+vhuseinova-msft@users.noreply.github.com>
For users that are only able to use Keyboard, they are not able to select image to set alternate text,
To fix when the range selection is only surrounding a single image change the DOMSelection to Image