Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
a-doc-editor
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ramdayal Munda
a-doc-editor
Commits
5ce24a3b
Commit
5ce24a3b
authored
Jan 12, 2024
by
ramdayalmunda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wrapping long words
parent
e1d0ff89
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
7 deletions
+18
-7
a-doc-editor2.js
dist/assets/a-doc-editor2.js
+18
-7
No files found.
dist/assets/a-doc-editor2.js
View file @
5ce24a3b
...
...
@@ -225,7 +225,6 @@ var ADocEditor = function (customConfig) {
renderCaret
(
true
)
function
calculateTextSizeAndPosition
()
{
let
d
=
0
,
c
=
0
;
function
getLineObj
()
{
...
...
@@ -257,21 +256,28 @@ var ADocEditor = function (customConfig) {
maxLineWidth
-=
tabWidth
lineObj
.
dataType
=
dataBlock
.
type
let
wordEndIndex
=
0
;
// this stores the index of the word which can fit in the line;
let
tempWordWidth
=
0
for
(
c
=
0
;
c
<
dataBlock
.
plainContent
.
length
;
c
++
)
{
let
style
=
dataBlock
?.
formatedText
?.[
c
]
if
(
/
\s
/
.
test
(
dataBlock
.
plainContent
[
c
]))
{
wordEndIndex
=
c
lineObj
.
charEndIndex
=
c
tempWordWidth
=
0
}
let
charWidth
=
getCharacterWidth
(
dataBlock
.
plainContent
[
c
],
style
)
dataBlock
.
formatedText
[
c
]
=
{
...
config
.
style
,
...
style
,
width
:
charWidth
}
if
(
tempLineWidth
+
charWidth
>
maxLineWidth
)
{
if
(
tempLineWidth
+
charWidth
>
maxLineWidth
){
// cannot add this// new line should be added//
i
=
wordEndIndex
;
if
(
tempWordWidth
+
charWidth
>=
maxLineWidth
){
wordEndIndex
=
c
lineObj
.
charEndIndex
=
c
tempWordWidth
=
0
}
lineObj
.
plainContent
=
dataBlock
.
plainContent
.
slice
(
lineObj
.
charStartIndex
,
lineObj
.
charEndIndex
+
1
)
lines
.
push
(
lineObj
)
lineObj
=
new
getLineObj
()
...
...
@@ -282,10 +288,15 @@ var ADocEditor = function (customConfig) {
lineObj
.
listIndex
=
dataBlock
.
listIndex
if
(
dataBlock
.
type
==
1
)
lineObj
.
tabCount
=
dataBlock
.
tabCount
else
lineObj
.
tabCount
=
0
lineObj
.
charStartIndex
=
i
+
1
lineObj
.
charEndIndex
=
i
+
1
tempLineWidth
=
0
}
else
tempLineWidth
+=
charWidth
lineObj
.
charStartIndex
=
wordEndIndex
+
1
lineObj
.
charEndIndex
=
wordEndIndex
+
1
tempLineWidth
=
tempWordWidth
}
else
{
tempLineWidth
+=
charWidth
tempWordWidth
+=
charWidth
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment