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
6398a96e
Commit
6398a96e
authored
Dec 19, 2023
by
ramdayalmunda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
font color option added on toolbar
parent
35ca9764
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
7 deletions
+51
-7
a-doc-editor.css
dist/assets/a-doc-editor.css
+17
-1
a-doc-editor.js
dist/assets/a-doc-editor.js
+34
-6
No files found.
dist/assets/a-doc-editor.css
View file @
6398a96e
...
@@ -53,7 +53,23 @@
...
@@ -53,7 +53,23 @@
.a-doc-editor
.header
.option
input
{
.a-doc-editor
.header
.option
input
{
width
:
25px
;
width
:
25px
;
}
}
.a-doc-editor
.header
.option
.font-color
{
display
:
flex
;
flex-direction
:
column
;
text-align
:
center
;
}
.a-doc-editor
.header
.option
.color-bar
{
display
:
block
;
width
:
20px
;
height
:
8px
;
background-color
:
green
;
}
.a-doc-editor
.header
.option
.font-color
input
{
position
:
absolute
;
width
:
100%
;
height
:
100%
;
opacity
:
0
;
}
.a-doc-editor
.header
.option
:hover
{
.a-doc-editor
.header
.option
:hover
{
padding
:
1px
;
padding
:
1px
;
background-color
:
white
;
background-color
:
white
;
...
...
dist/assets/a-doc-editor.js
View file @
6398a96e
...
@@ -22,6 +22,8 @@ var ADocEditor = function (customConfig) {
...
@@ -22,6 +22,8 @@ var ADocEditor = function (customConfig) {
var
fontFamilyDropdown
=
null
var
fontFamilyDropdown
=
null
var
fontList
=
[]
var
fontList
=
[]
var
fontSize
;
var
fontSize
;
var
fontColor
;
var
fontColorLabel
;
var
fullScreenLoadingOverlay
;
var
fullScreenLoadingOverlay
;
var
defaultConfig
=
{
var
defaultConfig
=
{
...
@@ -121,6 +123,14 @@ var ADocEditor = function (customConfig) {
...
@@ -121,6 +123,14 @@ var ADocEditor = function (customConfig) {
<button adc-action="font-size-plus">+</button>
<button adc-action="font-size-plus">+</button>
</div>
</div>
<div class="option">
<div class="font-color">
<span>A</span>
<span class="color-bar" adc-label="font-color"></span>
<input type="color" adc-action="font-color">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="body">
<div class="body">
...
@@ -210,6 +220,9 @@ var ADocEditor = function (customConfig) {
...
@@ -210,6 +220,9 @@ var ADocEditor = function (customConfig) {
reRenderFontDropdown
()
reRenderFontDropdown
()
fontSize
=
container
.
querySelector
(
'[adc-action="font-size-set"]'
)
fontSize
=
container
.
querySelector
(
'[adc-action="font-size-set"]'
)
fontColor
=
container
.
querySelector
(
'[adc-action="font-color"]'
)
fontColor
.
addEventListener
(
'input'
,
changeFontColor
)
fontColorLabel
=
container
.
querySelector
(
'[adc-label="font-color"]'
)
fullScreenLoadingOverlay
=
document
.
createElement
(
'div'
)
fullScreenLoadingOverlay
=
document
.
createElement
(
'div'
)
fullScreenLoadingOverlay
.
innerText
=
'Loading...'
fullScreenLoadingOverlay
.
innerText
=
'Loading...'
...
@@ -588,6 +601,7 @@ var ADocEditor = function (customConfig) {
...
@@ -588,6 +601,7 @@ var ADocEditor = function (customConfig) {
e.preventDefault()
e.preventDefault()
caretData.style.fontFamily = fontFamily.innerText
caretData.style.fontFamily = fontFamily.innerText
caretData.style.fontSize = Number(fontSize.value)
caretData.style.fontSize = Number(fontSize.value)
caretData.style.fontColor = fontColor.value
caretData.activeData.formatedText[caretData.index] = { ...caretData.style }
caretData.activeData.formatedText[caretData.index] = { ...caretData.style }
caretData.activeData.plainContent = caretData.activeData.plainContent.slice(0, caretData.index) + e.key + caretData.activeData.plainContent.slice(caretData.index)
caretData.activeData.plainContent = caretData.activeData.plainContent.slice(0, caretData.index) + e.key + caretData.activeData.plainContent.slice(caretData.index)
...
@@ -853,9 +867,7 @@ var ADocEditor = function (customConfig) {
...
@@ -853,9 +867,7 @@ var ADocEditor = function (customConfig) {
if (e) {
if (e) {
caretData.style.fontFamily = e.target.innerText
caretData.style.fontFamily = e.target.innerText
caretData.styleModified = false
caretData.styleModified = false
if (lastFocusCanvas) {
focusLastCanvas()
lastFocusCanvas.focus({ preventScroll: true })
}
if (!caretData.activeData.plainContent.length) {
if (!caretData.activeData.plainContent.length) {
caretData.activeData.style.fontFamily = e.target.innerText
caretData.activeData.style.fontFamily = e.target.innerText
}
}
...
@@ -868,15 +880,29 @@ var ADocEditor = function (customConfig) {
...
@@ -868,15 +880,29 @@ var ADocEditor = function (customConfig) {
function changeFontSize(change){
function changeFontSize(change){
fontSize.value = change
fontSize.value = change
caretData.style.fontSize = change
caretData.style.fontSize = change
if (lastFocusCanvas) {
focusLastCanvas()
lastFocusCanvas.focus({ preventScroll: true })
}
if (!caretData.activeData.plainContent.length) {
if (!caretData.activeData.plainContent.length) {
caretData.activeData.style.fontSize = change
caretData.activeData.style.fontSize = change
}
}
}
}
function changeFontColor(e){
fontColorLabel.style.backgroundColor = e.target.value
caretData.style.fontColor = e.target.value
focusLastCanvas()
if (!caretData.activeData.plainContent.length) {
caretData.activeData.style.fontColor = e.target.value
}
}
function focusLastCanvas(){
if (!lastFocusCanvas) lastFocusCanvas = canvasList[0].el
if (lastFocusCanvas) {
lastFocusCanvas.focus({ preventScroll: true })
}
}
function reRenderFontDropdown() {
function reRenderFontDropdown() {
if (fontFamilyDropdown) {
if (fontFamilyDropdown) {
...
@@ -904,6 +930,8 @@ var ADocEditor = function (customConfig) {
...
@@ -904,6 +930,8 @@ var ADocEditor = function (customConfig) {
option.innerText = target?.children?.[0]?.innerText ? target?.children?.[0]?.innerText : ''
option.innerText = target?.children?.[0]?.innerText ? target?.children?.[0]?.innerText : ''
})
})
fontSize.value = caretData.style.fontSize
fontSize.value = caretData.style.fontSize
fontColor.value = caretData.style.fontColor
fontColorLabel.style.backgroundColor = caretData.style.fontColor
container.addEventListener('click', (e) => {
container.addEventListener('click', (e) => {
if (e.target.getAttribute('adc-type') == 'option') {
if (e.target.getAttribute('adc-type') == 'option') {
...
...
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