-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* change image * Content Model: Better hide cursor for table and image selection (#2270) * Standalone Editor: CreateStandaloneEditorCore * Standalone Editor: Port LifecyclePlugin * fix build * fix test * improve * fix test * Standalone Editor: Support keyboard input (init step) * Standalone Editor: Port EntityPlugin * improve * Add test * improve * port selection api * improve * improve * fix build * fix build * fix build * improve * Improve * improve * improve * fix test * improve * add test * remove unused code * Standalone Editor: port ImageSelection plugin * add test * Standalone Editor: Port UndoPlugin * improve * Port undo api * fix test * improve * improve * fix build * Improve * Improve * Improve * fix build * Improve * Add test * fix test * Add undo/redo API * Standalone Editor: Port event core API * fix build * fix build * Standalone Editor: Port transformColor API * Improve * Content Model: Better hide cursor for table and image selection * fix build --------- Co-authored-by: Bryan Valverde U <bvalverde@microsoft.com> * gif treatment * Move Paste from publicApi to coreApi to leverage the same domToModelOptions #2275 * selection * WIP * fix mac image selection * constant * Standalone Editor: Port paste API step 1 (#2279) * Standalone Editor: Port paste API step 2 (#2280) * Standalone Editor: Port paste API step 1 * Standalone Editor: Port paste API step 2 * improve * improve * Table Fidelity improvement: Width Attribute and Cellpadding attribute (#2284) * init * add test * update name of test * adjust link selection * Standalone Editor: Port paste API step 3 (#2281) * Standalone Editor: Port paste API step 1 * Standalone Editor: Port paste API step 2 * Standalone Editor: Port paste API step 3 * improve * improve * Improve * Improve * Adjust Selection on Cut/Copy first table cell (#2287) * init * fix * address comments * address additional scenario * adjust space for underline * adjust space for underline * fix multiple blocks * fixes * Standalone Editor: Port paste API step 4 (#2282) * Standalone Editor: Port paste API step 1 * Standalone Editor: Port paste API step 2 * Standalone Editor: Port paste API step 3 * Standalone Editor: Port paste API step 4 * improve * improve * fix test * Standalone Editor: Decouple core package from roosterjs-editor-dom (#2283) * Standalone Editor: Port paste API step 1 * Standalone Editor: Port paste API step 2 * Standalone Editor: Port paste API step 3 * Standalone Editor: Port paste API step 4 * Standalone Editor: Decouple core package from roosterjs-editor-dom * Set Deprecated font color to black instead of undefined (#2290) * init * use jasmine anything * Remove negative margins from Word (#2277) * Remove negative margins from Word * remove * Standalone Editor step 1 (#2291) * Fix GetFormatState not returning Font size after paste (#2299) * init * fix build * Standalone Editor step 2 (#2292) * keyboard input on mac * fix test * change isMac for isIME * iscomposing * Support rem unit (#2300) * Support rem unit * Use already existing case * justify-content-api * aligment list item * add justify to map * Content Model: Improve paste and sanitization behavior (#2304) * Fix couple of issues in Word Desktop Paste (#2311) * init * fix build * try fix build * fix again * Add a test * Re-activate tested without model check * Change borderLeft/Right to borderInlineStart/End (#2286) * fix RTL border application * fix table direction change * add tests * Update versions --------- Co-authored-by: Júlia Roldi <juliaroldi@microsoft.com> Co-authored-by: Jiuqing Song <jisong@microsoft.com> Co-authored-by: Bryan Valverde U <bvalverde@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>
- Loading branch information
1 parent
b333ded
commit 5d48fd9
Showing
157 changed files
with
10,451 additions
and
3,247 deletions.
There are no files selected for viewing
This file contains 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
19 changes: 19 additions & 0 deletions
19
demo/scripts/controls/ribbonButtons/contentModel/alignJustifyButton.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { isContentModelEditor } from 'roosterjs-content-model-editor'; | ||
import { RibbonButton } from 'roosterjs-react'; | ||
import { setAlignment } from 'roosterjs-content-model-api'; | ||
|
||
/** | ||
* @internal | ||
* "Align justify" button on the format ribbon | ||
*/ | ||
export const alignJustifyButton: RibbonButton<'buttonNameAlignJustify'> = { | ||
key: 'buttonNameAlignJustify', | ||
unlocalizedText: 'Align justify', | ||
iconName: 'AlignJustify', | ||
onClick: editor => { | ||
if (isContentModelEditor(editor)) { | ||
setAlignment(editor, 'justify'); | ||
} | ||
return true; | ||
}, | ||
}; |
This file contains 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
This file contains 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
This file contains 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
76 changes: 76 additions & 0 deletions
76
...-model/roosterjs-content-model-api/lib/modelApi/selection/adjustTrailingSpaceSelection.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { createText } from 'roosterjs-content-model-dom'; | ||
import { iterateSelections } from 'roosterjs-content-model-core'; | ||
import type { | ||
ContentModelDocument, | ||
ContentModelParagraph, | ||
ContentModelText, | ||
} from 'roosterjs-content-model-types'; | ||
|
||
/** | ||
* If a format cannot be applied to be applied to a trailing space, split the trailing space into a separate segment | ||
* @internal | ||
*/ | ||
export function adjustTrailingSpaceSelection(model: ContentModelDocument) { | ||
iterateSelections(model, (_, __, block, segments) => { | ||
if (block?.blockType === 'Paragraph' && segments && segments.length > 0) { | ||
if ( | ||
segments.length === 1 && | ||
segments[0].segmentType === 'Text' && | ||
shouldSplitTrailingSpace(segments[0]) | ||
) { | ||
splitTextSegment(block, segments[0]); | ||
} else { | ||
const lastTextSegment = | ||
segments[segments.length - 1].segmentType === 'SelectionMarker' | ||
? segments[segments.length - 2] | ||
: segments[segments.length - 1]; | ||
if ( | ||
lastTextSegment && | ||
lastTextSegment.segmentType === 'Text' && | ||
shouldSplitTrailingSpace(lastTextSegment) | ||
) { | ||
splitTextSegment(block, lastTextSegment); | ||
} | ||
} | ||
} | ||
|
||
return false; | ||
}); | ||
} | ||
|
||
function shouldSplitTrailingSpace(segment: ContentModelText) { | ||
return segment.isSelected && hasTrailingSpace(segment.text) && !isTrailingSpace(segment.text); | ||
} | ||
|
||
function hasTrailingSpace(text: string) { | ||
return text.trimRight() !== text; | ||
} | ||
|
||
function isTrailingSpace(text: string) { | ||
return text.trimRight().length == 0; | ||
} | ||
|
||
function splitTextSegment(block: ContentModelParagraph, textSegment: Readonly<ContentModelText>) { | ||
const text = textSegment.text.trimRight(); | ||
const trailingSpace = textSegment.text.substring(text.length); | ||
const newText = createText(text, textSegment.format, textSegment.link, textSegment.code); | ||
newText.isSelected = true; | ||
const trailingSpaceLink = textSegment.link | ||
? { | ||
...textSegment.link, | ||
format: { | ||
...textSegment.link?.format, | ||
underline: false, // Remove underline for trailing space link | ||
}, | ||
} | ||
: undefined; | ||
const trailingSpaceSegment = createText( | ||
trailingSpace, | ||
undefined, | ||
trailingSpaceLink, | ||
textSegment.code | ||
); | ||
trailingSpaceSegment.isSelected = true; | ||
const index = block.segments.indexOf(textSegment); | ||
block.segments.splice(index, 1, newText, trailingSpaceSegment); | ||
} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.