Commit 3ab11020 by ramdayalmunda

font size element added

parent 0e974ad6
...@@ -55,6 +55,12 @@ ...@@ -55,6 +55,12 @@
[adc-type="popover"] { [adc-type="popover"] {
pointer-events: none; pointer-events: none;
} }
.small-input {
width: 50px;
}
.small-btn {
width: 25px;
}
.option { .option {
border: 1px solid black; border: 1px solid black;
padding: 5px; padding: 5px;
......
...@@ -69,6 +69,11 @@ var ADocEditor = function (customConfig) { ...@@ -69,6 +69,11 @@ var ADocEditor = function (customConfig) {
<div class="option" adc-toggle="listing-option" value="0">1. Numbers</div> <div class="option" adc-toggle="listing-option" value="0">1. Numbers</div>
</div> </div>
</div> </div>
<div class="item">
<button adc="font-size-change" class="small-btn" value="-1">-</button>
<input type="number" adc="font-size-input" class="small-input">
<button adc="font-size-change" class="small-btn" value="+1">+</button>
</div>
</div> </div>
</div> </div>
<div class="page-list" adc="page-list"></div> <div class="page-list" adc="page-list"></div>
...@@ -170,6 +175,28 @@ var ADocEditor = function (customConfig) { ...@@ -170,6 +175,28 @@ var ADocEditor = function (customConfig) {
} }
})() })()
!(function fontSizeHandler(){
let fontSizeInput = shadow.querySelector('[adc="font-size-input"]')
fontSizeInput.value = caretData.style.fontSize
let fontSizeChangers = shadow.querySelectorAll('[adc="font-size-change"]')
fontSizeChangers.forEach( btn => {
btn.addEventListener( 'click',(e)=>{
let change = Number(e.target.getAttribute('value'))
change = change?change:0
change = caretData.style.fontSize + change
change = change?change:config.style.fontSize
caretData.style.fontSize = change
fontSizeInput.value = change
} )
} )
fontSizeInput.addEventListener('input', (e)=>{
let value = Number( e.target.value )
value = value?value:config.style.fontSize
caretData.style.fontSize = value
})
})()
reConfigure(customConfig) reConfigure(customConfig)
reRenderCanvas() reRenderCanvas()
addGlobalEvents() addGlobalEvents()
...@@ -618,15 +645,14 @@ var ADocEditor = function (customConfig) { ...@@ -618,15 +645,14 @@ var ADocEditor = function (customConfig) {
function mousedownHandler(e) { function mousedownHandler(e) {
if (focussedPage) { if (focussedPage) {
const rect = e.target.getBoundingClientRect(); // Get the position of the canvas const rect = e.target.getBoundingClientRect(); // Get the position of the canvas
// const x = e.clientX - rect.left; // Adjusted X coordinate
// const y = e.clientY - rect.top; // Adjusted Y coordinate
// const width = Math.round(rect.width)
// const height = Math.round(rect.height)
const pxX = (e.clientX - rect.left) * config.pageSetup.pxWidth / rect.width; const pxX = (e.clientX - rect.left) * config.pageSetup.pxWidth / rect.width;
const pxY = (e.clientY - rect.top) * config.pageSetup.pxHeight / rect.height; const pxY = (e.clientY - rect.top) * config.pageSetup.pxHeight / rect.height;
placeCaret({ x: pxX, y: pxY }) placeCaret({ x: pxX, y: pxY })
let style = caretData.activeData.formatedText[caretData.index]
if (style) caretData.style = { ...caretData.style,
fontSize: style.fontSize,
}
shadow.querySelector('[adc="font-size-input"]').value = caretData.style.fontSize
} }
} }
function onFocusHandler(e) { function onFocusHandler(e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment