|
|
|
@@ -6,330 +6,219 @@
|
|
|
|
|
<a-button @click="handleClickTwo1()">项二</a-button>
|
|
|
|
|
<a-button @click="handleClick('space')">字母列项</a-button>
|
|
|
|
|
<a-button @click="handleClickTwo">数字列项</a-button>
|
|
|
|
|
<!-- <a-button @click="handleClick('tab')">插入一级列项('tab')</a-button>-->
|
|
|
|
|
<!-- <a-button @click="handleClick('none')">插入一级列项('none')</a-button>-->
|
|
|
|
|
</a-button-group>
|
|
|
|
|
<!-- <a-button-group>-->
|
|
|
|
|
<!-- <a-button @click="handleClickEn">插入一级列项(英)</a-button>-->
|
|
|
|
|
<!-- </a-button-group>-->
|
|
|
|
|
<!-- <a-button-group>-->
|
|
|
|
|
<!-- <a-button @click="handleTestChapter">添加章节测试</a-button>-->
|
|
|
|
|
<!-- </a-button-group>-->
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
methods: {
|
|
|
|
|
handleClickOne() {
|
|
|
|
|
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
|
|
|
|
window.Asc.scope.suffType = ''
|
|
|
|
|
this.ctx.callCommand(() => {
|
|
|
|
|
try {
|
|
|
|
|
const oDocument = Api.GetDocument()
|
|
|
|
|
let oNumbering = oDocument.CreateNumbering('numbered')
|
|
|
|
|
const oNumLvl = oNumbering.GetLevel(0)
|
|
|
|
|
oNumLvl.SetCustomType('decimalZero', "——", "right")
|
|
|
|
|
oNumLvl.SetSuff("tab");
|
|
|
|
|
var oParaPr = oNumLvl.GetParaPr();
|
|
|
|
|
oParaPr.SetSpacingLine(280, "auto");
|
|
|
|
|
oParaPr.SetIndFirstLine(0);
|
|
|
|
|
const oParagraph = Api.CreateParagraph()
|
|
|
|
|
oParagraph.SetNumbering(oNumLvl)
|
|
|
|
|
oParagraph.SetContextualSpacing(true)
|
|
|
|
|
oParagraph.SetFontFamily('宋体')
|
|
|
|
|
export default {
|
|
|
|
|
methods: {
|
|
|
|
|
handleClickOne() {
|
|
|
|
|
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
|
|
|
|
window.Asc.scope.suffType = ''
|
|
|
|
|
this.ctx.callCommand(() => {
|
|
|
|
|
try {
|
|
|
|
|
const oDocument = Api.GetDocument()
|
|
|
|
|
let oNumbering = oDocument.CreateNumbering('numbered')
|
|
|
|
|
const oNumLvl = oNumbering.GetLevel(0)
|
|
|
|
|
oNumLvl.SetCustomType('decimalZero', '——', 'right')
|
|
|
|
|
oNumLvl.SetSuff('none')
|
|
|
|
|
var oParaPr = oNumLvl.GetParaPr()
|
|
|
|
|
oParaPr.SetSpacingLine(280, 'auto')
|
|
|
|
|
oParaPr.SetIndFirstLine(0)
|
|
|
|
|
const oParagraph = Api.CreateParagraph()
|
|
|
|
|
oParagraph.SetNumbering(oNumLvl)
|
|
|
|
|
oParagraph.SetContextualSpacing(true)
|
|
|
|
|
oParagraph.SetFontFamily('宋体')
|
|
|
|
|
|
|
|
|
|
oParagraph.SetFontSize(21)
|
|
|
|
|
oParagraph.SetHighlight(255, 255, 0);
|
|
|
|
|
oParagraph.SetIndLeft(840);
|
|
|
|
|
oDocument.InsertContent([oParagraph])
|
|
|
|
|
let text = oParagraph.GetText()
|
|
|
|
|
if (text){
|
|
|
|
|
let aSearch = oParagraph.Search(text);
|
|
|
|
|
if (aSearch && aSearch.length > 0){
|
|
|
|
|
aSearch[0].SetFontFamily('宋体')
|
|
|
|
|
aSearch[0].SetFontSize(10.5)
|
|
|
|
|
}
|
|
|
|
|
oParagraph.SetFontSize(21)
|
|
|
|
|
oParagraph.SetHighlight(255, 255, 0)
|
|
|
|
|
oParagraph.SetIndLeft(840)
|
|
|
|
|
oDocument.InsertContent([oParagraph])
|
|
|
|
|
let text = oParagraph.GetText()
|
|
|
|
|
if (text) {
|
|
|
|
|
let aSearch = oParagraph.Search(text)
|
|
|
|
|
if (aSearch && aSearch.length > 0) {
|
|
|
|
|
aSearch[0].SetFontFamily('宋体')
|
|
|
|
|
aSearch[0].SetFontSize(10.5)
|
|
|
|
|
}
|
|
|
|
|
let GetNext = oParagraph.GetNext()
|
|
|
|
|
GetNext.Delete()
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(error)
|
|
|
|
|
}
|
|
|
|
|
}, false)
|
|
|
|
|
},
|
|
|
|
|
paragraphClick(){
|
|
|
|
|
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
|
|
|
|
window.Asc.scope.suffType = ''
|
|
|
|
|
this.ctx.callCommand(() => {
|
|
|
|
|
try {
|
|
|
|
|
const oDocument = Api.GetDocument()
|
|
|
|
|
// let oNumbering = oDocument.CreateNumbering('numbered')
|
|
|
|
|
// const oNumLvl = oNumbering.GetLevel(0)
|
|
|
|
|
// oNumLvl.SetCustomType('decimalZero', " ", "left")
|
|
|
|
|
// oNumLvl.SetSuff("space");
|
|
|
|
|
// var oParaPr = oNumLvl.GetParaPr();
|
|
|
|
|
// oParaPr.SetSpacingLine(280, "auto");
|
|
|
|
|
// oParaPr.SetJc("both");
|
|
|
|
|
// oParaPr.SetIndFirstLine(-500);
|
|
|
|
|
// // oParaPr.SetIndLeft(366)
|
|
|
|
|
const oParagraph = Api.CreateParagraph()
|
|
|
|
|
// oParagraph.SetNumbering(oNumLvl)
|
|
|
|
|
oParagraph.SetContextualSpacing(true)
|
|
|
|
|
oParagraph.SetFontFamily('宋体')
|
|
|
|
|
oParagraph.SetFontSize(21)
|
|
|
|
|
oParagraph.SetHighlight(255, 255, 0);
|
|
|
|
|
oParagraph.SetIndFirstLine(420);
|
|
|
|
|
oDocument.InsertContent([oParagraph])
|
|
|
|
|
let text = oParagraph.GetText()
|
|
|
|
|
if (text){
|
|
|
|
|
let aSearch = oParagraph.Search(text);
|
|
|
|
|
if (aSearch && aSearch.length > 0){
|
|
|
|
|
aSearch[0].SetFontFamily('宋体')
|
|
|
|
|
aSearch[0].SetFontSize(10.5)
|
|
|
|
|
}
|
|
|
|
|
// let GetNext = oParagraph.GetNext()
|
|
|
|
|
// GetNext.Delete()
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(error)
|
|
|
|
|
}
|
|
|
|
|
}, false)
|
|
|
|
|
},
|
|
|
|
|
paragraphClick() {
|
|
|
|
|
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
|
|
|
|
window.Asc.scope.suffType = ''
|
|
|
|
|
this.ctx.callCommand(() => {
|
|
|
|
|
try {
|
|
|
|
|
const oDocument = Api.GetDocument()
|
|
|
|
|
// let oNumbering = oDocument.CreateNumbering('numbered')
|
|
|
|
|
// const oNumLvl = oNumbering.GetLevel(0)
|
|
|
|
|
// oNumLvl.SetCustomType('decimalZero', " ", "left")
|
|
|
|
|
// oNumLvl.SetSuff("space");
|
|
|
|
|
// var oParaPr = oNumLvl.GetParaPr();
|
|
|
|
|
// oParaPr.SetSpacingLine(280, "auto");
|
|
|
|
|
// oParaPr.SetJc("both");
|
|
|
|
|
// oParaPr.SetIndFirstLine(-500);
|
|
|
|
|
// // oParaPr.SetIndLeft(366)
|
|
|
|
|
const oParagraph = Api.CreateParagraph()
|
|
|
|
|
// oParagraph.SetNumbering(oNumLvl)
|
|
|
|
|
oParagraph.SetContextualSpacing(true)
|
|
|
|
|
oParagraph.SetFontFamily('宋体')
|
|
|
|
|
oParagraph.SetFontSize(21)
|
|
|
|
|
oParagraph.SetHighlight(255, 255, 0)
|
|
|
|
|
oParagraph.SetIndFirstLine(420)
|
|
|
|
|
oDocument.InsertContent([oParagraph])
|
|
|
|
|
let text = oParagraph.GetText()
|
|
|
|
|
if (text) {
|
|
|
|
|
let aSearch = oParagraph.Search(text)
|
|
|
|
|
if (aSearch && aSearch.length > 0) {
|
|
|
|
|
aSearch[0].SetFontFamily('宋体')
|
|
|
|
|
aSearch[0].SetFontSize(10.5)
|
|
|
|
|
}
|
|
|
|
|
let GetNext = oParagraph.GetNext()
|
|
|
|
|
GetNext.Delete()
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(error)
|
|
|
|
|
}
|
|
|
|
|
}, false)
|
|
|
|
|
},
|
|
|
|
|
handleClickTwo1() {
|
|
|
|
|
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
|
|
|
|
window.Asc.scope.suffType = ''
|
|
|
|
|
this.ctx.callCommand(() => {
|
|
|
|
|
try {
|
|
|
|
|
const oDocument = Api.GetDocument()
|
|
|
|
|
let oNumbering = oDocument.CreateNumbering('bullet')
|
|
|
|
|
const oNumLvl = oNumbering.GetLevel(0)
|
|
|
|
|
oNumLvl.SetSuff('tab')
|
|
|
|
|
const oParagraph = Api.CreateParagraph()
|
|
|
|
|
var oParaPr = oNumLvl.GetParaPr();
|
|
|
|
|
oParaPr.SetSpacingLine(280, "auto");
|
|
|
|
|
// oParaPr.SetIndRight(80)
|
|
|
|
|
// oParaPr.SetIndFirstLine(120);
|
|
|
|
|
oParagraph.SetNumbering(oNumLvl)
|
|
|
|
|
oParagraph.SetContextualSpacing(true)
|
|
|
|
|
oParagraph.SetFontFamily('宋体')
|
|
|
|
|
oParagraph.SetFontSize(21)
|
|
|
|
|
oParagraph.SetIndLeft(1270);
|
|
|
|
|
oParagraph.SetHighlight(255, 255, 0);
|
|
|
|
|
oDocument.InsertContent([oParagraph])
|
|
|
|
|
let text = oParagraph.GetText()
|
|
|
|
|
if (text){
|
|
|
|
|
let aSearch = oParagraph.Search(text);
|
|
|
|
|
if (aSearch && aSearch.length > 0){
|
|
|
|
|
aSearch[0].SetFontFamily('宋体')
|
|
|
|
|
aSearch[0].SetFontSize(10.5)
|
|
|
|
|
}
|
|
|
|
|
// let GetNext = oParagraph.GetNext()
|
|
|
|
|
// GetNext.Delete()
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(error)
|
|
|
|
|
}
|
|
|
|
|
}, false)
|
|
|
|
|
},
|
|
|
|
|
handleClickTwo1() {
|
|
|
|
|
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
|
|
|
|
window.Asc.scope.suffType = ''
|
|
|
|
|
this.ctx.callCommand(() => {
|
|
|
|
|
try {
|
|
|
|
|
const oDocument = Api.GetDocument()
|
|
|
|
|
let oNumbering = oDocument.CreateNumbering('bullet')
|
|
|
|
|
const oNumLvl = oNumbering.GetLevel(0)
|
|
|
|
|
oNumLvl.SetSuff('none')
|
|
|
|
|
const oParagraph = Api.CreateParagraph()
|
|
|
|
|
var oParaPr = oNumLvl.GetParaPr()
|
|
|
|
|
oParaPr.SetSpacingLine(280, 'auto')
|
|
|
|
|
// oParaPr.SetIndRight(80)
|
|
|
|
|
// oParaPr.SetIndFirstLine(120);
|
|
|
|
|
oParagraph.SetNumbering(oNumLvl)
|
|
|
|
|
oParagraph.SetContextualSpacing(true)
|
|
|
|
|
oParagraph.SetFontFamily('宋体')
|
|
|
|
|
oParagraph.SetFontSize(21)
|
|
|
|
|
oParagraph.SetIndLeft(1270)
|
|
|
|
|
oParagraph.SetHighlight(255, 255, 0)
|
|
|
|
|
oParagraph.AddText(' ')
|
|
|
|
|
oDocument.InsertContent([oParagraph])
|
|
|
|
|
let text = oParagraph.GetText()
|
|
|
|
|
if (text) {
|
|
|
|
|
let aSearch = oParagraph.Search(text)
|
|
|
|
|
if (aSearch && aSearch.length > 0) {
|
|
|
|
|
aSearch[0].SetFontFamily('宋体')
|
|
|
|
|
aSearch[0].SetFontSize(10.5)
|
|
|
|
|
}
|
|
|
|
|
let GetNext = oParagraph.GetNext()
|
|
|
|
|
GetNext.Delete()
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(error)
|
|
|
|
|
}
|
|
|
|
|
}, false)
|
|
|
|
|
},
|
|
|
|
|
handleClick(suffType) {
|
|
|
|
|
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
|
|
|
|
window.Asc.scope.suffType = ''
|
|
|
|
|
this.ctx.callCommand(() => {
|
|
|
|
|
try {
|
|
|
|
|
const oDocument = Api.GetDocument()
|
|
|
|
|
// const allElement = oDocument.GetElementsCount()
|
|
|
|
|
let numbering = null
|
|
|
|
|
// let currentNumbering = null
|
|
|
|
|
// for (let index = 0; index < allElement; index++) {
|
|
|
|
|
// const element = oDocument.GetElement(index)
|
|
|
|
|
// if ("paragraph" === element.GetClassType()) {
|
|
|
|
|
// const getNumbering = element.GetNumbering()
|
|
|
|
|
// const text = element.GetSpacingBefore()
|
|
|
|
|
// if (getNumbering !== null) {
|
|
|
|
|
// if (text == 1) {
|
|
|
|
|
// currentNumbering = getNumbering
|
|
|
|
|
// break
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// if (!numbering) {
|
|
|
|
|
// if (currentNumbering) {
|
|
|
|
|
// numbering = currentNumbering.GetNumbering().GetLevel(0)
|
|
|
|
|
// } else {
|
|
|
|
|
// let oNumbering = oDocument.CreateNumbering('numbered')
|
|
|
|
|
// numbering = oNumbering.GetLevel(0)
|
|
|
|
|
// numbering.SetTemplateType('a)')
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
let oNumbering = oDocument.CreateNumbering('numbered')
|
|
|
|
|
numbering = oNumbering.GetLevel(0)
|
|
|
|
|
numbering.SetTemplateType('a)')
|
|
|
|
|
const oParagraph = Api.CreateParagraph()
|
|
|
|
|
// oParagraph.SetSpacingLine(400, "auto");
|
|
|
|
|
let oTextPr = numbering.GetTextPr();
|
|
|
|
|
oTextPr.SetFontFamily("宋体");
|
|
|
|
|
var oParaPr = numbering.GetParaPr();
|
|
|
|
|
oParaPr.SetSpacingLine(240, "auto");
|
|
|
|
|
oParaPr.SetJc("tab");
|
|
|
|
|
oParaPr.SetIndFirstLine(-420);
|
|
|
|
|
// oParaPr.SetIndFirstLine(0);
|
|
|
|
|
oParagraph.SetNumbering(numbering)
|
|
|
|
|
oParagraph.SetContextualSpacing(true)
|
|
|
|
|
oParagraph.SetFontFamily('宋体')
|
|
|
|
|
oParagraph.SetIndLeft(840);
|
|
|
|
|
oParagraph.SetFontSize(21)
|
|
|
|
|
oParagraph.SetHighlight(255, 255, 0);
|
|
|
|
|
oDocument.InsertContent([oParagraph])
|
|
|
|
|
let text = oParagraph.GetText()
|
|
|
|
|
if (text){
|
|
|
|
|
let aSearch = oParagraph.Search(text);
|
|
|
|
|
if (aSearch && aSearch.length > 0){
|
|
|
|
|
aSearch[0].SetFontFamily('宋体')
|
|
|
|
|
aSearch[0].SetFontSize(10.5)
|
|
|
|
|
}
|
|
|
|
|
// let GetNext = oParagraph.GetNext()
|
|
|
|
|
// GetNext.Delete()
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(error)
|
|
|
|
|
}
|
|
|
|
|
}, false)
|
|
|
|
|
},
|
|
|
|
|
handleClick(suffType) {
|
|
|
|
|
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
|
|
|
|
window.Asc.scope.suffType = ''
|
|
|
|
|
this.ctx.callCommand(() => {
|
|
|
|
|
try {
|
|
|
|
|
const oDocument = Api.GetDocument()
|
|
|
|
|
let numbering = null
|
|
|
|
|
let oNumbering = oDocument.CreateNumbering('numbered')
|
|
|
|
|
numbering = oNumbering.GetLevel(0)
|
|
|
|
|
numbering.SetTemplateType('a)')
|
|
|
|
|
numbering.SetSuff('none')
|
|
|
|
|
const oParagraph = Api.CreateParagraph()
|
|
|
|
|
let oTextPr = numbering.GetTextPr()
|
|
|
|
|
oTextPr.SetFontFamily('宋体')
|
|
|
|
|
var oParaPr = numbering.GetParaPr()
|
|
|
|
|
oParaPr.SetSpacingLine(240, 'auto')
|
|
|
|
|
oParaPr.SetJc('none')
|
|
|
|
|
oParaPr.SetIndFirstLine(-420)
|
|
|
|
|
oParagraph.SetNumbering(numbering)
|
|
|
|
|
oParagraph.SetContextualSpacing(true)
|
|
|
|
|
oParagraph.SetFontFamily('宋体')
|
|
|
|
|
oParagraph.SetIndLeft(840)
|
|
|
|
|
oParagraph.SetFontSize(21)
|
|
|
|
|
oParagraph.SetHighlight(255, 255, 0)
|
|
|
|
|
oParagraph.AddText(' ')
|
|
|
|
|
oDocument.InsertContent([oParagraph])
|
|
|
|
|
let text = oParagraph.GetText()
|
|
|
|
|
if (text) {
|
|
|
|
|
let aSearch = oParagraph.Search(text)
|
|
|
|
|
if (aSearch && aSearch.length > 0) {
|
|
|
|
|
aSearch[0].SetFontFamily('宋体')
|
|
|
|
|
aSearch[0].SetFontSize(10.5)
|
|
|
|
|
}
|
|
|
|
|
let GetNext = oParagraph.GetNext()
|
|
|
|
|
GetNext.Delete()
|
|
|
|
|
// oNumbering = oParagraph.GetNumbering().GetNumbering()
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(error)
|
|
|
|
|
}
|
|
|
|
|
}, false)
|
|
|
|
|
},
|
|
|
|
|
handleClickTwo() {
|
|
|
|
|
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
|
|
|
|
window.Asc.scope.suffType = ''
|
|
|
|
|
this.ctx.callCommand(() => {
|
|
|
|
|
try {
|
|
|
|
|
const oDocument = Api.GetDocument()
|
|
|
|
|
const allElement = oDocument.GetElementsCount()
|
|
|
|
|
let numbering = null
|
|
|
|
|
let currentNumbering = null
|
|
|
|
|
// for (let index = 0; index < allElement; index++) {
|
|
|
|
|
// const element = oDocument.GetElement(index)
|
|
|
|
|
// if ("paragraph" === element.GetClassType()) {
|
|
|
|
|
// const getNumbering = element.GetNumbering()
|
|
|
|
|
// const text = element.GetSpacingBefore()
|
|
|
|
|
// if (getNumbering !== null) {
|
|
|
|
|
// if (text == 2) {
|
|
|
|
|
// currentNumbering = getNumbering;
|
|
|
|
|
// break
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
if (!numbering) {
|
|
|
|
|
if (currentNumbering) {
|
|
|
|
|
numbering = currentNumbering.GetNumbering().GetLevel(0)
|
|
|
|
|
} else {
|
|
|
|
|
let oNumbering = oDocument.CreateNumbering('numbered')
|
|
|
|
|
numbering = oNumbering.GetLevel(0)
|
|
|
|
|
// numbering.SetTemplateType('1)')
|
|
|
|
|
numbering.SetCustomType('decimal', "%1)", "left")
|
|
|
|
|
// numbering.SetSuff('tab')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let oTextPr = numbering.GetTextPr();
|
|
|
|
|
oTextPr.SetFontFamily("宋体");
|
|
|
|
|
const oParaPr = numbering.GetParaPr();
|
|
|
|
|
// oParaPr.SetIndLeft(1310)
|
|
|
|
|
oParaPr.SetJc("left");
|
|
|
|
|
oParaPr.SetSpacingLine(240, "auto");
|
|
|
|
|
oParaPr.SetIndFirstLine(-420);
|
|
|
|
|
const oParagraph = Api.CreateParagraph()
|
|
|
|
|
oParagraph.SetNumbering(numbering)
|
|
|
|
|
oParagraph.SetContextualSpacing(true)
|
|
|
|
|
oParagraph.SetFontFamily('宋体')
|
|
|
|
|
oParagraph.SetFontSize(21)
|
|
|
|
|
oParagraph.SetIndLeft(1260);
|
|
|
|
|
oParagraph.SetHighlight(255, 255, 0);
|
|
|
|
|
oDocument.InsertContent([oParagraph])
|
|
|
|
|
let text = oParagraph.GetText()
|
|
|
|
|
if (text){
|
|
|
|
|
let aSearch = oParagraph.Search(text);
|
|
|
|
|
if (aSearch && aSearch.length > 0){
|
|
|
|
|
aSearch[0].SetFontFamily('宋体')
|
|
|
|
|
aSearch[0].SetFontSize(10.5)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let GetNext = oParagraph.GetNext()
|
|
|
|
|
GetNext.Delete()
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(error)
|
|
|
|
|
}
|
|
|
|
|
}, false)
|
|
|
|
|
},
|
|
|
|
|
handleClickEn() {
|
|
|
|
|
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
|
|
|
|
this.ctx.callCommand(() => {
|
|
|
|
|
try {
|
|
|
|
|
const oDocument = Api.GetDocument()
|
|
|
|
|
let oNumbering = oDocument.CreateNumbering('numbered')
|
|
|
|
|
const oNumLvl = oNumbering.GetLevel(0)
|
|
|
|
|
oNumLvl.SetTemplateType('a)')
|
|
|
|
|
oNumLvl.SetSuff('space')
|
|
|
|
|
for (let nLvl = 1; nLvl < 4; nLvl++) {
|
|
|
|
|
const oParagraph = Api.CreateParagraph()
|
|
|
|
|
oParagraph.AddText('Custom numbered')
|
|
|
|
|
oParagraph.SetNumbering(oNumLvl)
|
|
|
|
|
oParagraph.SetContextualSpacing(true)
|
|
|
|
|
oParagraph.SetFontFamily('Arial')
|
|
|
|
|
oParagraph.SetFontSize(21)
|
|
|
|
|
oDocument.InsertContent([oParagraph])
|
|
|
|
|
oNumbering = oParagraph.GetNumbering().GetNumbering()
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(error)
|
|
|
|
|
}
|
|
|
|
|
}, false)
|
|
|
|
|
},
|
|
|
|
|
handleClick2() {
|
|
|
|
|
this.ctx.executeMethod('InputText', ['wx', 'wx2'])
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
handleTestChapter() {
|
|
|
|
|
this.ctx.callCommand(() => {
|
|
|
|
|
try {
|
|
|
|
|
const oDocument = Api.GetDocument()
|
|
|
|
|
const allParagraph = oDocument.Document.GetAllNumberedParagraphs()
|
|
|
|
|
console.log(allParagraph)
|
|
|
|
|
let oNumbering
|
|
|
|
|
if (allParagraph.length > 0) {
|
|
|
|
|
// oNumbering = oDocument.CreateNumbering('numbered')
|
|
|
|
|
const currentParagraph = allParagraph[0]
|
|
|
|
|
console.log(currentParagraph)
|
|
|
|
|
oNumbering = currentParagraph.GetCurrentParagraph()
|
|
|
|
|
console.log(oNumbering)
|
|
|
|
|
// let GetNext = oParagraph.GetNext()
|
|
|
|
|
// GetNext.Delete()
|
|
|
|
|
// oNumbering = oParagraph.GetNumbering().GetNumbering()
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(error)
|
|
|
|
|
}
|
|
|
|
|
}, false)
|
|
|
|
|
},
|
|
|
|
|
handleClickTwo() {
|
|
|
|
|
window.Asc.scope.guid = window.Asc.plugin.info.guid
|
|
|
|
|
window.Asc.scope.suffType = ''
|
|
|
|
|
this.ctx.callCommand(() => {
|
|
|
|
|
try {
|
|
|
|
|
const oDocument = Api.GetDocument()
|
|
|
|
|
const allElement = oDocument.GetElementsCount()
|
|
|
|
|
let numbering = null
|
|
|
|
|
let currentNumbering = null
|
|
|
|
|
if (!numbering) {
|
|
|
|
|
if (currentNumbering) {
|
|
|
|
|
numbering = currentNumbering.GetNumbering().GetLevel(0)
|
|
|
|
|
} else {
|
|
|
|
|
oNumbering = oDocument.CreateNumbering('numbered')
|
|
|
|
|
console.log('创建的:', oNumbering)
|
|
|
|
|
let oNumbering = oDocument.CreateNumbering('numbered')
|
|
|
|
|
numbering = oNumbering.GetLevel(0)
|
|
|
|
|
numbering.SetCustomType('decimal', '%1)', 'left')
|
|
|
|
|
}
|
|
|
|
|
const oParagraph = Api.CreateParagraph()
|
|
|
|
|
|
|
|
|
|
oNumLvl = oNumbering.GetLevel(oNumbering.GetLevel(0).GetLevelIndex());
|
|
|
|
|
oNumLvl.SetRestart(false)
|
|
|
|
|
oParagraph.AddText('Custom numbered')
|
|
|
|
|
oParagraph.SetNumbering(oNumLvl)
|
|
|
|
|
oDocument.InsertContent([oParagraph])
|
|
|
|
|
let text = oParagraph.GetText()
|
|
|
|
|
if (text){
|
|
|
|
|
let aSearch = oParagraph.Search(text);
|
|
|
|
|
if (aSearch && aSearch.length > 0){
|
|
|
|
|
aSearch[0].SetFontFamily('宋体')
|
|
|
|
|
aSearch[0].SetFontSize(10.5)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let GetNext = oParagraph.GetNext()
|
|
|
|
|
GetNext.Delete()
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.log(e)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
numbering.SetSuff('none')
|
|
|
|
|
let oTextPr = numbering.GetTextPr()
|
|
|
|
|
oTextPr.SetFontFamily('宋体')
|
|
|
|
|
const oParaPr = numbering.GetParaPr()
|
|
|
|
|
// oParaPr.SetIndLeft(1310)
|
|
|
|
|
oParaPr.SetJc('left')
|
|
|
|
|
oParaPr.SetSpacingLine(240, 'auto')
|
|
|
|
|
oParaPr.SetIndFirstLine(-420)
|
|
|
|
|
const oParagraph = Api.CreateParagraph()
|
|
|
|
|
oParagraph.SetNumbering(numbering)
|
|
|
|
|
oParagraph.SetContextualSpacing(true)
|
|
|
|
|
oParagraph.SetFontFamily('宋体')
|
|
|
|
|
oParagraph.SetFontSize(21)
|
|
|
|
|
oParagraph.SetIndLeft(1260)
|
|
|
|
|
oParagraph.SetHighlight(255, 255, 0)
|
|
|
|
|
oParagraph.AddText(' ')
|
|
|
|
|
oDocument.InsertContent([oParagraph])
|
|
|
|
|
let text = oParagraph.GetText()
|
|
|
|
|
if (text) {
|
|
|
|
|
let aSearch = oParagraph.Search(text)
|
|
|
|
|
if (aSearch && aSearch.length > 0) {
|
|
|
|
|
aSearch[0].SetFontFamily('宋体')
|
|
|
|
|
aSearch[0].SetFontSize(10.5)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// let GetNext = oParagraph.GetNext()
|
|
|
|
|
// GetNext.Delete()
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(error)
|
|
|
|
|
}
|
|
|
|
|
}, false)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|