Added letter spacing to text formatting tools
This commit is contained in:
@@ -685,6 +685,38 @@ export const setTextAnchorMethod = function (value) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the letter spacing value
|
||||
* @function module:svgcanvas.SvgCanvas#getLetterSpacing
|
||||
* @returns {string} The letter spacing value
|
||||
*/
|
||||
export const getLetterSpacingMethod = function () {
|
||||
const selectedElements = elemContext_.getSelectedElements();
|
||||
const selected = selectedElements[0];
|
||||
if (!isNullish(selected) && selected.tagName === 'text' && isNullish(selectedElements[1])) {
|
||||
return selected.getAttribute('letter-spacing') || 0;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the new letter spacing.
|
||||
* @function module:svgcanvas.SvgCanvas#setLetterSpacing
|
||||
* @param {string} value - The letter spacing
|
||||
* @returns {void}
|
||||
*/
|
||||
export const setLetterSpacingMethod = function (value) {
|
||||
const selectedElements = elemContext_.getSelectedElements();
|
||||
const selected = selectedElements[0];
|
||||
if (!isNullish(selected) && selected.tagName === 'text' &&
|
||||
isNullish(selectedElements[1])) {
|
||||
elemContext_.getCanvas().changeSelectedAttribute('letter-spacing', value);
|
||||
}
|
||||
if (!selectedElements[0].textContent) {
|
||||
elemContext_.getCanvas().textActions.setCursor();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @function module:svgcanvas.SvgCanvas#getFontFamily
|
||||
* @returns {string} The current font family
|
||||
|
||||
@@ -49,7 +49,7 @@ const svgWhiteList_ = {
|
||||
svg: ['class', 'clip-path', 'clip-rule', 'filter', 'id', 'height', 'mask', 'preserveAspectRatio', 'requiredFeatures', 'style', 'systemLanguage', 'viewBox', 'width', 'x', 'xmlns', 'xmlns:se', 'xmlns:xlink', 'y'],
|
||||
switch: ['class', 'id', 'requiredFeatures', 'systemLanguage'],
|
||||
symbol: ['class', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'font-family', 'font-size', 'font-style', 'font-weight', 'id', 'opacity', 'preserveAspectRatio', 'requiredFeatures', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform', 'viewBox'],
|
||||
text: ['class', 'clip-path', 'clip-rule', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'font-family', 'font-size', 'font-style', 'font-weight', 'id', 'mask', 'opacity', 'requiredFeatures', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-decoration', 'style', 'systemLanguage', 'text-anchor', 'transform', 'x', 'xml:space', 'y', 'display'],
|
||||
text: ['class', 'clip-path', 'clip-rule', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'font-family', 'font-size', 'font-style', 'font-weight', 'id', 'mask', 'opacity', 'requiredFeatures', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-decoration', 'letter-spacing', 'style', 'systemLanguage', 'text-anchor', 'transform', 'x', 'xml:space', 'y', 'display'],
|
||||
textPath: ['class', 'id', 'method', 'requiredFeatures', 'spacing', 'startOffset', 'style', 'systemLanguage', 'transform', 'xlink:href', 'display'],
|
||||
title: [],
|
||||
tspan: ['class', 'clip-path', 'clip-rule', 'dx', 'dy', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'font-family', 'font-size', 'font-style', 'font-weight', 'id', 'mask', 'opacity', 'requiredFeatures', 'rotate', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'text-anchor', 'textLength', 'transform', 'x', 'xml:space', 'y', 'display'],
|
||||
|
||||
@@ -57,8 +57,8 @@ import {
|
||||
setDocumentTitleMethod, setResolutionMethod, getEditorNSMethod, setBBoxZoomMethod,
|
||||
setZoomMethod, setColorMethod, setGradientMethod, findDuplicateGradient, setPaintMethod,
|
||||
setStrokeWidthMethod, setStrokeAttrMethod, getBoldMethod, setBoldMethod, getItalicMethod,
|
||||
setItalicMethod, hasTextDecorationMethod, addTextDecorationMethod, removeTextDecorationMethod,
|
||||
setTextAnchorMethod, getFontFamilyMethod, setFontFamilyMethod, setFontColorMethod, getFontColorMethod,
|
||||
setItalicMethod, hasTextDecorationMethod, addTextDecorationMethod, removeTextDecorationMethod, setLetterSpacingMethod,
|
||||
getLetterSpacingMethod, setTextAnchorMethod, getFontFamilyMethod, setFontFamilyMethod, setFontColorMethod, getFontColorMethod,
|
||||
getFontSizeMethod, setFontSizeMethod, getTextMethod, setTextContentMethod,
|
||||
setImageURLMethod, setLinkURLMethod, setRectRadiusMethod, makeHyperlinkMethod,
|
||||
removeHyperlinkMethod, setSegTypeMethod, setBackgroundMethod
|
||||
@@ -2240,6 +2240,23 @@ class SvgCanvas {
|
||||
*/
|
||||
this.removeTextDecoration = removeTextDecorationMethod;
|
||||
|
||||
/**
|
||||
* Returns the letter spacing.
|
||||
* @function module:svgcanvas.SvgCanvas#getLetterSpacing
|
||||
* @param {string} value - The value that should be set
|
||||
* @returns {string} The letter spacing value
|
||||
*/
|
||||
this.getLetterSpacing = getLetterSpacingMethod;
|
||||
|
||||
|
||||
/**
|
||||
* Changes the letter spacing.
|
||||
* @function module:svgcanvas.SvgCanvas#setLetterSpacing
|
||||
* @param {string} value - The value that should be set
|
||||
* @returns {void}
|
||||
*/
|
||||
this.setLetterSpacing = setLetterSpacingMethod;
|
||||
|
||||
/**
|
||||
* Set the new text anchor.
|
||||
* @function module:svgcanvas.SvgCanvas#setTextAnchor
|
||||
|
||||
Reference in New Issue
Block a user