How about quill's toolbar insert bubble tip component? - quill

Sorry my native language is not English, I want to insert hints in the toolbar of quill, is there a way to do it, thanks a lot
Expected results
This is the hint component
https://element.eleme.cn/#/en-US/component/tooltip

Run it, here's my thought process, and here's the full code
var quill = new Quill('#editor', {
theme: 'snow'
});
initButtonTitle()
function initButtonTitle() {
const titleConfig = [{
Choice: ".ql-bold",
title: "加粗"
},
{
Choice: ".ql-italic",
title: "斜体"
},
{
Choice: ".ql-underline",
title: "下划线"
},
{
Choice: ".ql-header",
title: "段落格式"
},
{
Choice: ".ql-strike",
title: "删除线"
},
{
Choice: ".ql-blockquote",
title: "块引用"
},
{
Choice: ".ql-code",
title: "插入代码"
},
{
Choice: ".ql-code-block",
title: "插入代码段"
},
{
Choice: ".ql-font",
title: "字体"
},
{
Choice: ".ql-size",
title: "字体大小"
},
{
Choice: '.ql-list[value="ordered"]',
title: "编号列表"
},
{
Choice: '.ql-list[value="bullet"]',
title: "项目列表"
},
{
Choice: ".ql-direction",
title: "文本方向"
},
{
Choice: '.ql-header[value="1"]',
title: "h1"
},
{
Choice: '.ql-header[value="2"]',
title: "h2"
},
{
Choice: ".ql-align",
title: "对齐方式"
},
{
Choice: ".ql-color",
title: "字体颜色"
},
{
Choice: ".ql-background",
title: "背景颜色"
},
{
Choice: ".ql-image",
title: "图像"
},
{
Choice: ".ql-video",
title: "视频"
},
{
Choice: ".ql-link",
title: "添加链接"
},
{
Choice: ".ql-formula",
title: "插入公式"
},
{
Choice: ".ql-clean",
title: "清除字体格式"
},
{
Choice: '.ql-script[value="sub"]',
title: "下标"
},
{
Choice: '.ql-script[value="super"]',
title: "上标"
},
{
Choice: '.ql-indent[value="-1"]',
title: "向左缩进"
},
{
Choice: '.ql-indent[value="+1"]',
title: "向右缩进"
},
{
Choice: ".ql-header .ql-picker-label",
title: "标题大小"
},
{
Choice: '.ql-header .ql-picker-item[data-value="1"]',
title: "标题一",
},
{
Choice: '.ql-header .ql-picker-item[data-value="2"]',
title: "标题二",
},
{
Choice: '.ql-header .ql-picker-item[data-value="3"]',
title: "标题三",
},
{
Choice: '.ql-header .ql-picker-item[data-value="4"]',
title: "标题四",
},
{
Choice: '.ql-header .ql-picker-item[data-value="5"]',
title: "标题五",
},
{
Choice: '.ql-header .ql-picker-item[data-value="6"]',
title: "标题六",
},
{
Choice: ".ql-header .ql-picker-item:last-child",
title: "标准"
},
{
Choice: '.ql-size .ql-picker-item[data-value="small"]',
title: "小号",
},
{
Choice: '.ql-size .ql-picker-item[data-value="large"]',
title: "大号",
},
{
Choice: '.ql-size .ql-picker-item[data-value="huge"]',
title: "超大号",
},
{
Choice: ".ql-size .ql-picker-item:nth-child(2)",
title: "标准"
},
{
Choice: ".ql-align .ql-picker-item:first-child",
title: "居左对齐"
},
{
Choice: '.ql-align .ql-picker-item[data-value="center"]',
title: "居中对齐",
},
{
Choice: '.ql-align .ql-picker-item[data-value="right"]',
title: "居右对齐",
},
{
Choice: '.ql-align .ql-picker-item[data-value="justify"]',
title: "两端对齐",
},
];
for (let item of titleConfig) {
let tip = document.querySelector(item.Choice);
if (!tip) continue;
tip.setAttribute("data-tippy-content", item.title);
}
tippy('[data-tippy-content]');
}
<script src="https://unpkg.com/#popperjs/core#2"></script>
<script src="https://unpkg.com/tippy.js#6"></script>
<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet" />
<div id="editor">
</div>

Related

How to remove drill down caption? and add expand and collapse arrow

I want remove caption and add expand and collapse arrow. I can't post image here so check my codesandbox. This I want look like https://codepen.io/webdatarocks/pen/dLeZvN
My codesandbox:
https://codesandbox.io/s/react-webdatarocks-react-functional-component-jh22w6?file=/src/components/useBalanceSheet.js
Hierarchies in WebDataRocks are always displayed with captions for the next level.
If you want the behavior as in the Codepen link you provided, you should replace the hierarchy with the separate data columns and then add them to slice.rows.
Here is the example snippet
var pivot = new WebDataRocks({
container: "#wdr-component",
toolbar: true,
width: "100%",
height: 600,
report: {
dataSource: {
dataSourceType: "json",
data: getData()
},
slice: {
rows: [{
uniqueName: "baseGroup",
caption: "Balance Sheet"
},
{
uniqueName: "group"
},
{
uniqueName: "accountName"
}
],
measures: [{
uniqueName: "value",
aggregation: "sum",
}],
expands: {
expandAll: true
},
drills: {
drillAll: true
},
},
tableSizes: {
columns: [
{
idx: 0,
width: 400
},
{
idx: 1,
width: 200
}
]
},
options: {
grid: {
showHeaders: false
}
},
}
}
);
function getData() {
return [{
baseGroup: "Asset",
group: "Current Asset",
accountName: "Cash Account",
value: 100
},
{
baseGroup: "Asset",
group: "Current Asset",
accountName: "SBI Bank Account",
value: 100
},
{
baseGroup: "Asset",
group: "Current Asset",
accountName: "SBI Loan",
value: 100
},
{
baseGroup: "Equity",
group: "Shareholbers Funds",
accountName: "Reserves and Surplus",
value: 100
},
{
baseGroup: "Equity",
group: "Shareholbers Funds",
accountName: "Reserves and Surplus",
value: 100
},
{
baseGroup: "Liabilities",
group: "Current liabilities",
accountName: "Short-term borrowings",
value: 100
},
{
baseGroup: "Liabilities",
group: "Current liabilities",
accountName: "Tax payable",
value: 100
},
{
baseGroup: "Liabilities",
group: "Non-current liabilities",
accountName: "Long-term borrowings",
value: 100
}
]
}
<link href="https://cdn.webdatarocks.com/latest/webdatarocks.min.css" rel="stylesheet"/>
<script src="https://cdn.webdatarocks.com/latest/webdatarocks.toolbar.min.js"></script>
<script src="https://cdn.webdatarocks.com/latest/webdatarocks.js"></script>
<div id="wdr-component"></div>

covert list into another new list with new property name

I have one list look like allsettings. I want to convert that list to a new list. Since I am new to react I don't have much idea, I tried by doing the below way but 1st item in the new list is always empty.
const [mySetting, setMySet] = useState([]);
useEffect(() => {
const allSettings = [
{ name: "Setting1", value: true, label: 1 },
{ name: "Setting2", value: true, label: 2 },
{ name: "Setting3", value: true, label: 3 },
{ name: "Setting4", value: false, label: 4 },
{ name: "Setting5", value: true, label: 5 },
{ name: "Setting6", value: true, label: 6 },
{ name: "Setting7", value: true, label: 7 }
];
const settings = [];
const allSettingsMap = allSettings.reduce((resMap, current) => {
settings.push(resMap);
return {
...resMap,
SettingID: current.label,
Name: current.name,
value: current.value
};
}, {});
setMySet(settings);
}, []);
//I want new list like this:
const newSettings = [
{ name: "Setting1", value: true, SettingID: 1 },
{ name: "Setting2", value: true, SettingID: 2 },
{ name: "Setting3", value: true, SettingID: 3 },
{ name: "Setting4", value: false, SettingID: 4 },
{ name: "Setting5", value: true, SettingID: 5 },
{ name: "Setting6", value: true, SettingID: 6 },
{ name: "Setting7", value: true, SettingID: 7 }
];
You can use array#map to rename a key in your object and keeping other keys intact. For each object, you can pick label and rename it to SettingID and keep other key-values same.
const allSettings = [ { name: "Setting1", value: true, label: 1 }, { name: "Setting2", value: true, label: 2 }, { name: "Setting3", value: true, label: 3 }, { name: "Setting4", value: false, label: 4 }, { name: "Setting5", value: true, label: 5 }, { name: "Setting6", value: true, label: 6 }, { name: "Setting7", value: true, label: 7 } ],
result = allSettings.map(({label, ...other}) => ({...other, SettingID: label}));
console.log(result);
.as-console-wrapper { max-height: 100% !important; top: 0; }
You can easily do it by map on array
const allSettings = [
{ name: "Setting1", value: true, label: 1 },
{ name: "Setting2", value: true, label: 2 },
{ name: "Setting3", value: true, label: 3 },
{ name: "Setting4", value: false, label: 4 },
{ name: "Setting5", value: true, label: 5 },
{ name: "Setting6", value: true, label: 6 },
{ name: "Setting7", value: true, label: 7 }
];
const newAllSettings = allSettings.map(item => {
return {
name: item.name,
value: item.value,
SettingID:item.label
};
});
console.log(newAllSettings)
Replace your allSettings.reduce method with this map method
const settings = [];
allSettings.map((setting) => {
const item = { ...setting };
const tempValue = item?.label;
// delete item label
delete item["label"];
item["SettingID"] = tempValue;
settings.push(item);
});

At the same time, two identical elements can not be selected in dropDownList

Hello i am have two kendo ui drodDownList:
kendo-drop-down-list(
ng-model = 'vm.firstList'
k-data-source='vm.filterData'
k-data-text-field='"title"'
k-data-value-field='"name"'
k-value-primitive='true'
k-filter='"contains"'
k-on-change='vm.onChange($event)'
)
and
kendo-drop-down-list(
ng-model = 'vm.secondList'
k-data-source='vm.filterData'
k-data-text-field='"title"'
k-data-value-field='"name"'
k-value-primitive='true'
k-filter='"contains"'
k-on-change='vm.onChange($event)'
)
it is data source:
this.filterData = [
{ name: 'Brown', title: 'Soier' },
{ name: 'Maks', title: 'Inkl' },
{ name: 'Lint', title: 'Baks' },
{ name: 'Hover', title: 'Niyou' }
]
they have same data source, and i am want when choosing item in first dd then remove this item from other dd (and likewise for the second). At the same time, two identical elements can not be selected.
my solution:
in first dd add:
k-on-change='vm.onFirstSelect(kendoEvent)'
k-data-source='vm.firstFilterElements'
for second dd:
k-on-change='vm.onSecondSelect(kendoEvent)'
k-data-source='vm.secondFilterElements'
in controller add:
this.filterElements = [
{ name: 'Brown', title: 'Soier' },
{ name: 'Maks', title: 'Inkl' },
{ name: 'Lint', title: 'Baks' },
{ name: 'Hover', title: 'Niyou' }
]
this.firstFilterElements = this.filterElements;
this.secondFilterElements = this.filterElements;
onFirstSelect(e) {
this.secondFilterElements = this.filterByItem(e);
}
onSecondSelect(e) {
this.firstFilterElements = this.filterByItem(e);
}
filterByItem (e) {
return this.filterElements.filter(function (el) {
return el.name !== e.sender.dataItem(e.item)
[e.sender.options.dataValueField];
});
}
if someone can optimize it i will be glad)

Filter nested JSON in angular

I have mega menu that generate from JSON object like this:
[
{
"name":"Menu Item 1",
"id":"8",
"children":[
{
"name":"Sub Menu 1-1",
"id":"1",
"children":[
{
"name":"Sub Menu 1.1.1",
"id":"2"
},
{
"name":"Sub Menu 1.1.2",
"id":"3"
}
]
},
{
"name":"Sub Menu 1.2",
"id":"4"
}
]
},
{
"name":"Menu Item 2",
"id":"7",
"children":[
{
"name":"Sub Menu 2.1",
"id":"5"
},
{
"name":"Sub Menu 2.2",
"id":"6"
}
]
}
]
How can I create a custom filter to retrieve only the matched items by their name recursively without changing the original structure?
Try this.
var menuItems =[{ name: 'Menu Item 1', id: '8', children:[{ name: 'Sub Menu 1-1', id: '1', children: [{ name: 'Sub Menu 1.1.1', id: '2' }, { name: 'Sub Menu 1.1.2', id: '3' }] }, { name: 'Sub Menu 1.2', id: '4' }]},{ name: 'Menu Item 2', id: '7', children: [{ name: 'Sub Menu 2.1', id: '5' }, { name: 'Sub Menu 2.2', id: '6' }] }];
var result = [];
function isObject(obj) {
return (!!obj.name && !!obj.id);
}
function hasChildren(obj) {
return !!obj.children && Array.isArray(obj.children);
}
function getNameList(item, matchName) {
if(Array.isArray(item)) {
for(var i = 0; i < item.length; i++) {
if(hasChildren(item[i])) {
getNameList(item[i].children, matchName);
}
if(isObject(item[i])) {
if(matchName == item[i].name) result.push(item[i]);
}
}
}
}
getNameList(menuItems, 'Menu Item 1');
console.log(result);

Provide hints to user while searching

I am stuck on the functionality to show user hints while searching of products in application.I do have an Api which returns me all category-Listing with its sub-categories/child.I have save it in my local storage but i am really confused that how can i make loop to display characters in hint list just below the search bar while user is typing something in search bar.I know the process but do not know how to implement in all nested child for every category.
I have found this below mentioned example but again its working for only simple Array ..
Example :- http://codepen.io/calendee/pen/pCwyx
Can any one suggest me that how can i use the above logic for my array
[
{
id: "165",
title: "Women's Fashion",
url: "womens-fashion",
children: [
{
id: "176",
title: "Women's Aparel",
url: "women-s-aparel",
children: [
{
id: "221",
title: "Formal",
url: "formal"
},
{
id: "222",
title: "Casual",
url: "casual"
},
{
id: "223",
title: "Traditional",
url: "traditional"
},
{
id: "224",
title: "Nightwears",
url: "nightwears"
},
{
id: "225",
title: "Winter wears",
url: "winter-wears"
},
{
id: "240",
title: "Party Wear",
url: "party-wear"
}
]
},
{
id: "220",
title: "Western Wear",
url: "western-wear",
children: [
{
id: "318",
title: "Glam & Luxe Style Wears",
url: "glam-luxe-style-wears"
},
{
id: "412",
title: "Dresses",
url: "dresses"
},
{
id: "413",
title: "Tops & Tees",
url: "tops-tees"
},
{
id: "414",
title: "Bottom Wear",
url: "bottom-wear"
}
]
},
{
id: "305",
title: "Ethnic Wear",
url: "ethnic-wear",
children: [
{
id: "407",
title: "Sarees",
url: "sarees"
},
{
id: "408",
title: "Lehnga Choli",
url: "lehnga-choli"
},
{
id: "409",
title: "Gown",
url: "gown"
},
{
id: "410",
title: "Salwar Kameez & Churidar",
url: "salwar-kameez-churidar"
},
{
id: "411",
title: "Kurtis",
url: "kurtis"
}
]
},
{
id: "306",
title: "Jewellery",
url: "jewellery",
children: [
{
id: "307",
title: "Anklets",
url: "anklets"
},
{
id: "308",
title: "Bridal Set",
url: "bridal-set"
},
{
id: "309",
title: "Mala",
url: "mala"
},
{
id: "310",
title: "Mangalsutra",
url: "mangalsutra"
},
{
id: "311",
title: "Necklace Set",
url: "necklace-set"
},
{
id: "312",
title: "Ring",
url: "ring"
},
{
id: "316",
title: "Bangles",
url: "bangles"
},
{
id: "317",
title: "Earings",
url: "earings"
}
]
},
{
id: "415",
title: "Leggings & Jeggings",
url: "leggings-and-jeggings"
},
{
id: "416",
title: "Lingeries & Nightwears",
url: "lingeries-and-nightwears"
},
{
id: "417",
title: "All Women Clothing",
url: "all-women-clothing"
}
]
},
{
id: "404",
title: "Men's Fashion",
url: "mens-fashion",
children: [
{
id: "177",
title: "Men's Aparel",
url: "men-s-aparel",
children: [
{
id: "226",
title: "Casual",
url: "casual"
},
{
id: "227",
title: "Formal",
url: "formal"
},
{
id: "230",
title: "Others",
url: "others"
},
{
id: "303",
title: "Winter",
url: "winter"
},
{
id: "239",
title: "Party Wear",
url: "party-wear"
}
]
},
{
id: "229",
title: "Ethnic",
url: "ethnic",
children: [
{
id: "418",
title: "Indo Western",
url: "indo-western"
},
{
id: "419",
title: "Kurta Pyjama",
url: "kurta-pyjama"
},
{
id: "420",
title: "Kurta",
url: "kurta"
},
{
id: "421",
title: "Sherwanis",
url: "sherwanis"
}
]
},
{
id: "228",
title: "Western",
url: "western",
children: [
{
id: "422",
title: "Jeans",
url: "jeans"
},
{
id: "423",
title: "Polo & Tees",
url: "polo-tees"
},
{
id: "424",
title: "Shirts",
url: "shirts"
},
{
id: "425",
title: "Trousers",
url: "trousers"
},
{
id: "426",
title: "Shorts & 3/4",
url: "shorts-and-3-4"
}
]
},
{
id: "427",
title: "Inner wear",
url: "inner-wear"
},
{
id: "428",
title: "Sleep & Lounge Wear",
url: "sleep-and-lounge-wear"
},
{
id: "429",
title: "Knit Wear",
url: "knit-wear"
},
{
id: "430",
title: "Suits & Blazers",
url: "suits-and-blazers"
},
{
id: "431",
title: "Sweat Shirts",
url: "sweat-shirts"
}
]
}
]

Resources