-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
add soft line breaks #4565
Open
DeanWay
wants to merge
3
commits into
slab:main
Choose a base branch
from
DeanWay:soft-breaks
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
add soft line breaks #4565
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { EmbedBlot } from 'parchment'; | ||
|
||
export const SOFT_BREAK_CHARACTER = '\u2028'; | ||
|
||
export default class SoftBreak extends EmbedBlot { | ||
static tagName = 'BR'; | ||
static blotName: string = 'soft-break'; | ||
static className: string = 'soft-break'; | ||
|
||
length(): number { | ||
return 1; | ||
} | ||
|
||
value(): string { | ||
return SOFT_BREAK_CHARACTER; | ||
} | ||
|
||
optimize(): void { | ||
return; | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,74 +1,75 @@ | ||
<!DOCTYPE html> | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta | ||
name="viewport" | ||
content="width=device-width, initial-scale=1, user-scalable=no" | ||
/> | ||
<title>Quill E2E Tests</title> | ||
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script> | ||
<link href="/quill.core.css" rel="stylesheet" /> | ||
<link href="/quill.snow.css" rel="stylesheet" /> | ||
</head> | ||
|
||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" /> | ||
<title>Quill E2E Tests</title> | ||
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script> | ||
<link href="/quill.core.css" rel="stylesheet"> | ||
<link href="/quill.snow.css" rel="stylesheet"> | ||
</head> | ||
|
||
<body> | ||
<div id="root"> | ||
<div id="standalone-container"> | ||
<div id="toolbar-container"> | ||
<span class="ql-formats"> | ||
<select class="ql-font"></select> | ||
<select class="ql-size"></select> | ||
</span> | ||
<span class="ql-formats"> | ||
<button class="ql-bold"></button> | ||
<button class="ql-italic"></button> | ||
<button class="ql-underline"></button> | ||
<button class="ql-strike"></button> | ||
</span> | ||
<span class="ql-formats"> | ||
<select class="ql-color"></select> | ||
<select class="ql-background"></select> | ||
</span> | ||
<span class="ql-formats"> | ||
<button class="ql-script" value="sub"></button> | ||
<button class="ql-script" value="super"></button> | ||
</span> | ||
<span class="ql-formats"> | ||
<button class="ql-header" value="1"></button> | ||
<button class="ql-header" value="2"></button> | ||
<button class="ql-blockquote"></button> | ||
<button class="ql-code-block"></button> | ||
</span> | ||
<span class="ql-formats"> | ||
<button class="ql-list" value="ordered"></button> | ||
<button class="ql-list" value="bullet"></button> | ||
<button class="ql-indent" value="-1"></button> | ||
<button class="ql-indent" value="+1"></button> | ||
</span> | ||
<span class="ql-formats"> | ||
<button class="ql-direction" value="rtl"></button> | ||
<select class="ql-align"></select> | ||
</span> | ||
<span class="ql-formats"> | ||
<button class="ql-link"></button> | ||
<button class="ql-image"></button> | ||
<button class="ql-video"></button> | ||
<button class="ql-formula"></button> | ||
</span> | ||
<span class="ql-formats"> | ||
<button class="ql-clean"></button> | ||
</span> | ||
</div> | ||
<div id="editor" style="height: 350px;"> | ||
<body> | ||
<div id="root"> | ||
<div id="standalone-container"> | ||
<div id="toolbar-container"> | ||
<span class="ql-formats"> | ||
<select class="ql-font"></select> | ||
<select class="ql-size"></select> | ||
</span> | ||
<span class="ql-formats"> | ||
<button class="ql-bold"></button> | ||
<button class="ql-italic"></button> | ||
<button class="ql-underline"></button> | ||
<button class="ql-strike"></button> | ||
</span> | ||
<span class="ql-formats"> | ||
<select class="ql-color"></select> | ||
<select class="ql-background"></select> | ||
</span> | ||
<span class="ql-formats"> | ||
<button class="ql-script" value="sub"></button> | ||
<button class="ql-script" value="super"></button> | ||
</span> | ||
<span class="ql-formats"> | ||
<button class="ql-header" value="1"></button> | ||
<button class="ql-header" value="2"></button> | ||
<button class="ql-blockquote"></button> | ||
<button class="ql-code-block"></button> | ||
</span> | ||
<span class="ql-formats"> | ||
<button class="ql-list" value="ordered"></button> | ||
<button class="ql-list" value="bullet"></button> | ||
<button class="ql-indent" value="-1"></button> | ||
<button class="ql-indent" value="+1"></button> | ||
</span> | ||
<span class="ql-formats"> | ||
<button class="ql-direction" value="rtl"></button> | ||
<select class="ql-align"></select> | ||
</span> | ||
<span class="ql-formats"> | ||
<button class="ql-link"></button> | ||
<button class="ql-image"></button> | ||
<button class="ql-video"></button> | ||
<button class="ql-formula"></button> | ||
</span> | ||
<span class="ql-formats"> | ||
<button class="ql-clean"></button> | ||
</span> | ||
</div> | ||
<div id="editor" style="height: 350px"></div> | ||
<script> | ||
window.quill = new Quill(document.getElementById('editor'), { | ||
modules: { syntax: true, toolbar: '#toolbar-container' }, | ||
placeholder: 'Compose an epic...', | ||
theme: 'snow', | ||
}); | ||
</script> | ||
</div> | ||
<script> | ||
window.quill = new Quill(document.getElementById('editor'), { | ||
modules: { syntax: true, toolbar: '#toolbar-container', }, | ||
placeholder: 'Compose an epic...', theme: 'snow', | ||
}) | ||
</script> | ||
</div> | ||
</div> | ||
</body> | ||
|
||
</html> | ||
</body> | ||
</html> |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found it was necessary to add these calls to
optimize
here since it seems that optimize is not called when using the editor methods to modify text (i.e.applyDelta
,insertText
, etc.). This appears to be the case because the existing call tooptimize
inScrollBlot
depends on there being 1 or more mutations causing the change, which only happens when the editor contents is changed through some user action in the browser.If there is some better way of accomplishing this than what I've done here, please let me know.