-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
506 additions
and
24 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
apps/meteor/app/ui-message/client/messageBox/createQuillComposerAPI.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,35 @@ | ||
import type { QuillComposerAPI } from '../../../../client/lib/chats/ChatAPI'; | ||
|
||
const attributesMap = { | ||
bold: '*', | ||
italic: '_', | ||
strike: '~', | ||
}; | ||
|
||
export const createQuillComposerAPI = (): QuillComposerAPI => { | ||
let text = ''; | ||
|
||
const setQuillDeltaToText = (getDelta: any) => { | ||
const delta = getDelta(); | ||
delta.ops.forEach((op: any) => { | ||
const mdStack: string[] = []; | ||
if (op.attributes) { | ||
Object.keys(op.attributes).forEach((attribute: string) => { | ||
mdStack.push(attribute); | ||
text += attributesMap[attribute as keyof typeof attributesMap]; | ||
}); | ||
} | ||
text += op.insert; | ||
while (mdStack.length) { | ||
text += attributesMap[mdStack.pop() as keyof typeof attributesMap]; | ||
} | ||
}); | ||
}; | ||
|
||
return { | ||
get text(): string { | ||
return text; | ||
}, | ||
setQuillDeltaToText, | ||
}; | ||
}; |
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
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.