Skip to content
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

Stop using default export #2471

Merged
merged 4 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import formatImageWithContentModel from 'roosterjs-content-model-api/lib/publicApi/utils/formatImageWithContentModel';
import { createContextMenuProvider } from '../utils/createContextMenuProvider';
import { EditorPlugin, IEditor, ImageEditor } from 'roosterjs-content-model-types';
import { formatImageWithContentModel } from 'roosterjs-content-model-api';
import { iterateSelections, updateImageMetadata } from 'roosterjs-content-model-core';
import { setImageAltText } from 'roosterjs-content-model-api';
import { showInputDialog } from '../../inputDialog/utils/showInputDialog';
Expand Down
88 changes: 46 additions & 42 deletions packages/roosterjs-content-model-api/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,53 @@
export { default as insertTable } from './publicApi/table/insertTable';
export { default as formatTable } from './publicApi/table/formatTable';
export { default as setTableCellShade } from './publicApi/table/setTableCellShade';
export { default as editTable } from './publicApi/table/editTable';
export { default as applyTableBorderFormat } from './publicApi/table/applyTableBorderFormat';
export { default as toggleBullet } from './publicApi/list/toggleBullet';
export { default as toggleNumbering } from './publicApi/list/toggleNumbering';
export { default as toggleBold } from './publicApi/segment/toggleBold';
export { default as toggleItalic } from './publicApi/segment/toggleItalic';
export { default as toggleUnderline } from './publicApi/segment/toggleUnderline';
export { default as toggleStrikethrough } from './publicApi/segment/toggleStrikethrough';
export { default as toggleSubscript } from './publicApi/segment/toggleSubscript';
export { default as toggleSuperscript } from './publicApi/segment/toggleSuperscript';
export { default as setBackgroundColor } from './publicApi/segment/setBackgroundColor';
export { default as setFontName } from './publicApi/segment/setFontName';
export { default as setFontSize } from './publicApi/segment/setFontSize';
export { default as setTextColor } from './publicApi/segment/setTextColor';
export { default as changeFontSize } from './publicApi/segment/changeFontSize';
export { default as applySegmentFormat } from './publicApi/segment/applySegmentFormat';
export { default as changeCapitalization } from './publicApi/segment/changeCapitalization';
export { default as insertImage } from './publicApi/image/insertImage';
export { default as setListStyle } from './publicApi/list/setListStyle';
export { default as setListStartNumber } from './publicApi/list/setListStartNumber';
export { default as setIndentation } from './publicApi/block/setIndentation';
export { default as setAlignment } from './publicApi/block/setAlignment';
export { default as setDirection } from './publicApi/block/setDirection';
export { default as setHeadingLevel } from './publicApi/block/setHeadingLevel';
export { default as toggleBlockQuote } from './publicApi/block/toggleBlockQuote';
export { default as setSpacing } from './publicApi/block/setSpacing';
export { default as setImageBorder } from './publicApi/image/setImageBorder';
export { default as setImageBoxShadow } from './publicApi/image/setImageBoxShadow';
export { default as changeImage } from './publicApi/image/changeImage';
export { default as getFormatState } from './publicApi/format/getFormatState';
export { default as clearFormat } from './publicApi/format/clearFormat';
export { default as insertLink } from './publicApi/link/insertLink';
export { default as removeLink } from './publicApi/link/removeLink';
export { default as adjustLinkSelection } from './publicApi/link/adjustLinkSelection';
export { default as setImageAltText } from './publicApi/image/setImageAltText';
export { default as adjustImageSelection } from './publicApi/image/adjustImageSelection';
export { default as setParagraphMargin } from './publicApi/block/setParagraphMargin';
export { default as toggleCode } from './publicApi/segment/toggleCode';
export { default as insertEntity } from './publicApi/entity/insertEntity';
export { insertTable } from './publicApi/table/insertTable';
export { formatTable } from './publicApi/table/formatTable';
export { setTableCellShade } from './publicApi/table/setTableCellShade';
export { editTable } from './publicApi/table/editTable';
export { applyTableBorderFormat } from './publicApi/table/applyTableBorderFormat';
export { toggleBullet } from './publicApi/list/toggleBullet';
export { toggleNumbering } from './publicApi/list/toggleNumbering';
export { toggleBold } from './publicApi/segment/toggleBold';
export { toggleItalic } from './publicApi/segment/toggleItalic';
export { toggleUnderline } from './publicApi/segment/toggleUnderline';
export { toggleStrikethrough } from './publicApi/segment/toggleStrikethrough';
export { toggleSubscript } from './publicApi/segment/toggleSubscript';
export { toggleSuperscript } from './publicApi/segment/toggleSuperscript';
export { setBackgroundColor } from './publicApi/segment/setBackgroundColor';
export { setFontName } from './publicApi/segment/setFontName';
export { setFontSize } from './publicApi/segment/setFontSize';
export { setTextColor } from './publicApi/segment/setTextColor';
export { changeFontSize } from './publicApi/segment/changeFontSize';
export { applySegmentFormat } from './publicApi/segment/applySegmentFormat';
export { changeCapitalization } from './publicApi/segment/changeCapitalization';
export { insertImage } from './publicApi/image/insertImage';
export { setListStyle } from './publicApi/list/setListStyle';
export { setListStartNumber } from './publicApi/list/setListStartNumber';
export { setIndentation } from './publicApi/block/setIndentation';
export { setAlignment } from './publicApi/block/setAlignment';
export { setDirection } from './publicApi/block/setDirection';
export { setHeadingLevel } from './publicApi/block/setHeadingLevel';
export { toggleBlockQuote } from './publicApi/block/toggleBlockQuote';
export { setSpacing } from './publicApi/block/setSpacing';
export { setImageBorder } from './publicApi/image/setImageBorder';
export { setImageBoxShadow } from './publicApi/image/setImageBoxShadow';
export { changeImage } from './publicApi/image/changeImage';
export { getFormatState } from './publicApi/format/getFormatState';
export { clearFormat } from './publicApi/format/clearFormat';
export { insertLink } from './publicApi/link/insertLink';
export { removeLink } from './publicApi/link/removeLink';
export { adjustLinkSelection } from './publicApi/link/adjustLinkSelection';
export { setImageAltText } from './publicApi/image/setImageAltText';
export { adjustImageSelection } from './publicApi/image/adjustImageSelection';
export { setParagraphMargin } from './publicApi/block/setParagraphMargin';
export { toggleCode } from './publicApi/segment/toggleCode';
export { insertEntity } from './publicApi/entity/insertEntity';
export { insertTableRow } from './modelApi/table/insertTableRow';
export { insertTableColumn } from './modelApi/table/insertTableColumn';

export { formatTableWithContentModel } from './publicApi/utils/formatTableWithContentModel';
export { formatImageWithContentModel } from './publicApi/utils/formatImageWithContentModel';
export { formatParagraphWithContentModel } from './publicApi/utils/formatParagraphWithContentModel';
export { formatSegmentWithContentModel } from './publicApi/utils/formatSegmentWithContentModel';

export { setListType } from './modelApi/list/setListType';
export { findListItemsInSameThread } from './modelApi/list/findListItemsInSameThread';
export { setModelIndentation } from './modelApi/block/setModelIndentation';
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { Border, ContentModelImage } from 'roosterjs-content-model-types';
/**
* @internal
*/
export default function applyImageBorderFormat(
export function applyImageBorderFormat(
image: ContentModelImage,
border: Border | null,
borderRadius?: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import type { IEditor } from 'roosterjs-content-model-types';
* @param editor The editor to set alignment
* @param alignment Alignment value: left, center or right
*/
export default function setAlignment(
editor: IEditor,
alignment: 'left' | 'center' | 'right' | 'justify'
) {
export function setAlignment(editor: IEditor, alignment: 'left' | 'center' | 'right' | 'justify') {
editor.focus();

editor.formatContentModel(model => setModelAlignment(model, alignment), {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { IEditor } from 'roosterjs-content-model-types';
* @param editor The editor to set alignment
* @param direction Direction value: ltr (Left to right) or rtl (Right to left)
*/
export default function setDirection(editor: IEditor, direction: 'ltr' | 'rtl') {
export function setDirection(editor: IEditor, direction: 'ltr' | 'rtl') {
editor.focus();

editor.formatContentModel(model => setModelDirection(model, direction), {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const HeaderFontSizes: Record<HeadingLevelTags, string> = {
* @param editor The editor to set heading level to
* @param headingLevel Level of heading, from 1 to 6. Set to 0 means set it back to a regular paragraph
*/
export default function setHeadingLevel(editor: IEditor, headingLevel: 0 | 1 | 2 | 3 | 4 | 5 | 6) {
export function setHeadingLevel(editor: IEditor, headingLevel: 0 | 1 | 2 | 3 | 4 | 5 | 6) {
editor.focus();

formatParagraphWithContentModel(editor, 'setHeadingLevel', para => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { IEditor } from 'roosterjs-content-model-types';
* @param indentation Whether indent or outdent
* @param length The length of pixel to indent/outdent @default 40
*/
export default function setIndentation(
export function setIndentation(
editor: IEditor,
indentation: 'indent' | 'outdent',
length?: number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { IEditor } from 'roosterjs-content-model-types';
* @param marginTop value for top margin
* @param marginBottom value for bottom margin
*/
export default function setParagraphMargin(
export function setParagraphMargin(
editor: IEditor,
marginTop?: string | null,
marginBottom?: string | null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { IEditor } from 'roosterjs-content-model-types';
* @param editor The editor to operate on
* @param spacing Unitless/px value to set line height
*/
export default function setSpacing(editor: IEditor, spacing: number | string) {
export function setSpacing(editor: IEditor, spacing: number | string) {
editor.focus();

formatParagraphWithContentModel(editor, 'setSpacing', paragraph => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const BuildInQuoteFormat: ContentModelFormatContainerFormat = {
* @param editor The editor object to toggle BLOCKQUOTE onto
* @param quoteFormat @optional Block format for the new quote object
*/
export default function toggleBlockQuote(
export function toggleBlockQuote(
editor: IEditor,
quoteFormat?: ContentModelFormatContainerFormat,
quoteFormatRtl?: ContentModelFormatContainerFormat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const InlineEntityTag = 'span';
* the beginning of this range (when focusAfterEntity is not set to true) or after the new entity (when focusAfterEntity is set to true)
* @param options Move options to insert. See InsertEntityOptions
*/
export default function insertEntity(
export function insertEntity(
editor: IEditor,
type: string,
isBlock: boolean,
Expand All @@ -47,15 +47,15 @@ export default function insertEntity(
* the beginning of this range (when focusAfterEntity is not set to true) or after the new entity (when focusAfterEntity is set to true)
* @param options Move options to insert. See InsertEntityOptions
*/
export default function insertEntity(
export function insertEntity(
editor: IEditor,
type: string,
isBlock: true,
position: InsertEntityPosition | DOMSelection,
options?: InsertEntityOptions
): ContentModelEntity | null;

export default function insertEntity(
export function insertEntity(
editor: IEditor,
type: string,
isBlock: boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type {
* Clear format of selection
* @param editor The editor to clear format from
*/
export default function clearFormat(editor: IEditor) {
export function clearFormat(editor: IEditor) {
editor.focus();

editor.formatContentModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { IEditor, ContentModelFormatState } from 'roosterjs-content-model-t
* Get current format state
* @param editor The editor to get format from
*/
export default function getFormatState(editor: IEditor): ContentModelFormatState {
export function getFormatState(editor: IEditor): ContentModelFormatState {
const pendingFormat = editor.getPendingFormat();
const model = editor.getContentModelCopy('reduced');
const manager = editor.getSnapshotsManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { ContentModelImage, IEditor } from 'roosterjs-content-model-types';
* Adjust selection to make sure select an image if any
* @return Content Model Image object if an image is select, or null
*/
export default function adjustImageSelection(editor: IEditor): ContentModelImage | null {
export function adjustImageSelection(editor: IEditor): ContentModelImage | null {
let image: ContentModelImage | null = null;

editor.formatContentModel(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import formatImageWithContentModel from '../utils/formatImageWithContentModel';
import { formatImageWithContentModel } from '../utils/formatImageWithContentModel';
import { readFile, updateImageMetadata } from 'roosterjs-content-model-core';
import type { ContentModelImage, IEditor } from 'roosterjs-content-model-types';

Expand All @@ -7,7 +7,7 @@ import type { ContentModelImage, IEditor } from 'roosterjs-content-model-types';
* @param editor The editor instance
* @param file The image file
*/
export default function changeImage(editor: IEditor, file: File) {
export function changeImage(editor: IEditor, file: File) {
editor.focus();

const selection = editor.getDOMSelection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { IEditor } from 'roosterjs-content-model-types';
* @param editor The editor to operate on
* @param file Image Blob file or source string
*/
export default function insertImage(editor: IEditor, imageFileOrSrc: File | string) {
export function insertImage(editor: IEditor, imageFileOrSrc: File | string) {
editor.focus();

if (typeof imageFileOrSrc == 'string') {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import formatImageWithContentModel from '../utils/formatImageWithContentModel';
import { formatImageWithContentModel } from '../utils/formatImageWithContentModel';
import type { ContentModelImage, IEditor } from 'roosterjs-content-model-types';

/**
Expand All @@ -7,7 +7,7 @@ import type { ContentModelImage, IEditor } from 'roosterjs-content-model-types';
* @param editor The editor instance
* @param altText The image alt text
*/
export default function setImageAltText(editor: IEditor, altText: string) {
export function setImageAltText(editor: IEditor, altText: string) {
editor.focus();

formatImageWithContentModel(editor, 'setImageAltText', (image: ContentModelImage) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import applyImageBorderFormat from '../../modelApi/image/applyImageBorderFormat';
import formatImageWithContentModel from '../utils/formatImageWithContentModel';
import { applyImageBorderFormat } from '../../modelApi/image/applyImageBorderFormat';
import { formatImageWithContentModel } from '../utils/formatImageWithContentModel';
import type { Border, ContentModelImage, IEditor } from 'roosterjs-content-model-types';

/**
Expand All @@ -9,11 +9,7 @@ import type { Border, ContentModelImage, IEditor } from 'roosterjs-content-model
* its value will not be changed. Passing null instead of an object will remove the border
* @param borderRadius the border radius value, if undefined, the border radius will keep the actual value
*/
export default function setImageBorder(
editor: IEditor,
border: Border | null,
borderRadius?: string
) {
export function setImageBorder(editor: IEditor, border: Border | null, borderRadius?: string) {
editor.focus();

formatImageWithContentModel(editor, 'setImageBorder', (image: ContentModelImage) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import formatImageWithContentModel from '../utils/formatImageWithContentModel';
import { formatImageWithContentModel } from '../utils/formatImageWithContentModel';
import type { ContentModelImage, IEditor } from 'roosterjs-content-model-types';

/**
Expand All @@ -7,11 +7,7 @@ import type { ContentModelImage, IEditor } from 'roosterjs-content-model-types';
* @param boxShadow The image box boxShadow
* @param margin The image margin for all sides (eg. "4px"), null to remove margin
*/
export default function setImageBoxShadow(
editor: IEditor,
boxShadow: string,
margin?: string | null
) {
export function setImageBoxShadow(editor: IEditor, boxShadow: string, margin?: string | null) {
editor.focus();

formatImageWithContentModel(editor, 'setImageBoxShadow', (image: ContentModelImage) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { IEditor } from 'roosterjs-content-model-types';
* Adjust selection to make sure select a hyperlink if any, or a word if original selection is collapsed
* @return A combination of existing link display text and url if any. If there is no existing link, return selected text and null
*/
export default function adjustLinkSelection(editor: IEditor): [string, string | null] {
export function adjustLinkSelection(editor: IEditor): [string, string | null] {
let text = '';
let url: string | null = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const FTP_REGEX = /^ftp\./i;
* If specified, the display text of link will be replaced with this text.
* If not specified and there wasn't a link, the link url will be used as display text.
*/
export default function insertLink(
export function insertLink(
editor: IEditor,
link: string,
anchorTitle?: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { IEditor } from 'roosterjs-content-model-types';
* If only part of a link is selected, the whole link style will be removed.
* @param editor The editor instance
*/
export default function removeLink(editor: IEditor) {
export function removeLink(editor: IEditor) {
editor.focus();

editor.formatContentModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { IEditor } from 'roosterjs-content-model-types';
* @param editor The editor to operate on
* @param value The number to set to, must be equal or greater than 1
*/
export default function setListStartNumber(editor: IEditor, value: number) {
export function setListStartNumber(editor: IEditor, value: number) {
editor.focus();

editor.formatContentModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { IEditor, ListMetadataFormat } from 'roosterjs-content-model-types'
* @param editor The editor to operate on
* @param style The target list item style to set
*/
export default function setListStyle(editor: IEditor, style: ListMetadataFormat) {
export function setListStyle(editor: IEditor, style: ListMetadataFormat) {
editor.focus();

editor.formatContentModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { IEditor } from 'roosterjs-content-model-types';
* @param editor The editor to operate on
* @param removeMargins true to remove margins, false to keep margins @default false
*/
export default function toggleBullet(editor: IEditor, removeMargins: boolean = false) {
export function toggleBullet(editor: IEditor, removeMargins: boolean = false) {
editor.focus();

editor.formatContentModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { IEditor } from 'roosterjs-content-model-types';
* @param editor The editor to operate on
* @param removeMargins true to remove margins, false to keep margins @default false
*/
export default function toggleNumbering(editor: IEditor, removeMargins: boolean = false) {
export function toggleNumbering(editor: IEditor, removeMargins: boolean = false) {
editor.focus();

editor.formatContentModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { ContentModelSegmentFormat, IEditor } from 'roosterjs-content-model
* @param editor The editor to operate on
* @param newFormat The segment format to apply
*/
export default function applySegmentFormat(editor: IEditor, newFormat: ContentModelSegmentFormat) {
export function applySegmentFormat(editor: IEditor, newFormat: ContentModelSegmentFormat) {
formatSegmentWithContentModel(
editor,
'applySegmentFormat',
Expand Down
Loading
Loading