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
2470d679
Commit
2470d679
authored
Jan 12, 2024
by
ramdayalmunda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
indentation handled
parent
8b4d6816
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
11 deletions
+14
-11
a-doc-editor2.js
dist/assets/a-doc-editor2.js
+14
-11
No files found.
dist/assets/a-doc-editor2.js
View file @
2470d679
...
...
@@ -253,7 +253,6 @@ var ADocEditor = function (customConfig) {
let
tempLineWidth
=
0
;
let
maxLineWidth
=
config
.
pageSetup
.
pxWidth
-
(
config
.
format
.
margin
*
pxMmRatio
*
2
)
let
tabWidth
=
(
(
dataBlock
.
type
==
1
?
1
:
0
)
+
dataBlock
.
tabCount
)
*
config
.
format
.
tabWidth
*
pxMmRatio
console
.
log
(
'tabWidth'
,
tabWidth
)
lineObj
.
tabWidth
=
tabWidth
maxLineWidth
-=
tabWidth
lineObj
.
dataType
=
dataBlock
.
type
...
...
@@ -307,7 +306,6 @@ var ADocEditor = function (customConfig) {
let
ctx
=
pageList
[
0
].
el
.
getContext
(
'2d'
,
{
willReadFrequently
:
true
})
x
=
config
.
format
.
margin
*
pxMmRatio
x
+=
lines
[
l
].
tabWidth
console
.
log
(
'line'
,
l
,
lines
[
l
])
y
=
y
+
(
lines
[
l
].
maxFontSize
*
pxMmRatio
)
lines
[
l
].
y
=
y
ctx
.
save
()
...
...
@@ -356,7 +354,6 @@ var ADocEditor = function (customConfig) {
let dataIndex = dataList.findIndex(item => item.id == caretData.activeData.id)
let lineObj = lines.find(item => item.dataIndex == dataIndex && caretData.index >= item.charStartIndex)
if (lineObj) {
console.log('line', lineObj)
x += lineObj.tabWidth
y = lineObj.y - lineObj.maxFontSize * pxMmRatio
}
...
...
@@ -364,7 +361,6 @@ var ADocEditor = function (customConfig) {
let width = height / 10
console.log(x,y,width,height)
const imageData = ctx.getImageData(x, y, width, height);
const data = imageData.data;
caretData.previousCaret = { imageData: structuredClone(imageData), x, y }
...
...
@@ -431,12 +427,14 @@ var ADocEditor = function (customConfig) {
}
function keydownHandler(e) {
if (e.key=='Tab'){
if (e.altKey) return
else if (e.key=='Tab'){
e.preventDefault()
caretData.activeData.tabCount += e.shiftKey?(-1):1
caretData.activeData.tabCount = (caretData.activeData.tabCount<0)?0:(caretData.activeData.tabCount>5?5:caretData.activeData.tabCount)
manageIndentation(e.shiftKey?-1:1)
}else if ([']','['].includes(e.key) && e.ctrlKey){
manageIndentation( e.key=='['?-1:1 )
}
if (e.altKey) return
else if (e.key == 'Backspace') {
if (caretData.index == 0) {
let activeDataIndex = dataList.findIndex(item => item.id == caretData.activeData.id)
...
...
@@ -475,7 +473,6 @@ var ADocEditor = function (customConfig) {
}
else if (e.key.length == 1 && !e.ctrlKey && !e.metaKey) { // displayable text
// ***** DISPLAYABLE TEXT **** //
e.preventDefault()
caretData.activeData.plainContent = caretData.activeData.plainContent.slice(0, caretData.index) + e.key + caretData.activeData.plainContent.slice(caretData.index)
caretData.activeData.formatedText.splice(caretData.index, 0, caretData.style)
...
...
@@ -509,6 +506,14 @@ var ADocEditor = function (customConfig) {
else if (e.key == 'ArrowDown') {
console.log('Down')
}
function manageIndentation(value){
caretData.activeData.tabCount += value
if (caretData.activeData.tabCount<0) caretData.activeData.tabCount = 0
else if (caretData.activeData.tabCount>5 ) caretData.activeData.tabCount = 5
return true
}
caretData.blink = false
caretData.previousCaret = null
reRenderCanvas()
...
...
@@ -565,10 +570,8 @@ var ADocEditor = function (customConfig) {
reRenderCanvas()
}
function onBlurHandler(e) {
// console.log('blur')
caretData.blink = true
focussedPage = null
// renderCaret()
}
}
...
...
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