Fix opening symbol dialog: select first symbol from the selected text or recent symbol

This commit is contained in:
Julia Radzhabova 2020-10-05 17:32:18 +03:00
parent 53618ed3ec
commit c769995941
4 changed files with 26 additions and 7 deletions

View file

@ -489,9 +489,18 @@ define([
var init = (aFontSelects.length<1);
init && this.initFonts();
//fill recents
this.fillRecentSymbols();
var lastfont;
if (options.font) {
lastfont = options.font;
} else if (aRecents.length>0) {
lastfont = aRecents[0].font;
}
if (lastfont) {
for(var i = 0; i < aFontSelects.length; ++i){
if(aFontSelects[i].displayValue === options.font){
if(aFontSelects[i].displayValue === lastfont){
nCurrentFont = i;
break;
}
@ -526,6 +535,8 @@ define([
nCurrentSymbol = options.code;
} else if (options.symbol) {
nCurrentSymbol = this.fixedCharCodeAt(options.symbol, 0);
} else if (aRecents.length>0) {
nCurrentSymbol = aRecents[0].symbol;
}
if (init && this.options.lang && this.options.lang != 'en') {
@ -539,6 +550,8 @@ define([
this.on('resizing', _.bind(this.onWindowResizing, this));
this.on('resize', _.bind(this.onWindowResize, this));
bMainFocus = true;
},
initFonts: function() {
@ -705,9 +718,6 @@ define([
me.updateInput();
});
//fill recents
this.fillRecentSymbols();
this.symbolTablePanel = $window.find('#symbol-table-scrollable-div');
this.previewPanel = $window.find('#id-preview-data');
this.previewParent = this.previewPanel.parent();
@ -822,7 +832,7 @@ define([
this.options.handler.call(this, this, state, settings);
}
if (state=='ok') {
!special && settings.updateRecents && this.checkRecent(nCurrentSymbol, settings.font);
!special && this.checkRecent(nCurrentSymbol, settings.font);
!special && settings.updateRecents && this.updateRecents();
if (this.type)
return;
@ -1050,7 +1060,7 @@ define([
this._handleInput('ok');
else {
var settings = this.getPasteSymbol($(e.target).attr('id'));
settings.updateRecents && this.checkRecent(nCurrentSymbol, settings.font);
this.checkRecent(nCurrentSymbol, settings.font);
settings.updateRecents && this.updateView(false, undefined, undefined, true);
this.fireEvent('symbol:dblclick', this, 'ok', settings);
}

View file

@ -2658,7 +2658,8 @@ define([
if (this.dlgSymbolTable && this.dlgSymbolTable.isVisible()) return;
if (this.api) {
var me = this;
var me = this,
selected = me.api.asc_GetSelectedText();
me.dlgSymbolTable = new Common.Views.SymbolTableDialog({
api: me.api,
lang: me.mode.lang,
@ -2666,6 +2667,8 @@ define([
type: 1,
special: true,
showShortcutKey: true,
font: selected && selected.length>0 ? this.api.get_TextProps().get_TextPr().get_FontFamily().get_Name() : undefined,
symbol: selected && selected.length>0 ? selected.charAt(0) : undefined,
buttons: [{value: 'ok', caption: this.textInsert}, 'close'],
handler: function(dlg, result, settings) {
if (result == 'ok') {

View file

@ -1866,12 +1866,15 @@ define([
onInsertSymbolClick: function() {
if (this.api) {
var me = this,
selected = me.api.asc_GetSelectedText(),
win = new Common.Views.SymbolTableDialog({
api: me.api,
lang: me.toolbar.mode.lang,
type: 1,
special: true,
buttons: [{value: 'ok', caption: this.textInsert}, 'close'],
font: selected && selected.length>0 ? me.api.get_TextProps().get_TextPr().get_FontFamily().get_Name() : undefined,
symbol: selected && selected.length>0 ? selected.charAt(0) : undefined,
handler: function(dlg, result, settings) {
if (result == 'ok') {
me.api.asc_insertSymbol(settings.font ? settings.font : me.api.get_TextProps().get_TextPr().get_FontFamily().get_Name(), settings.code, settings.special);

View file

@ -2846,12 +2846,15 @@ define([
onInsertSymbolClick: function() {
if (this.api) {
var me = this,
selected = me.api.asc_GetSelectedText(),
win = new Common.Views.SymbolTableDialog({
api: me.api,
lang: me.toolbar.mode.lang,
type: 1,
special: true,
buttons: [{value: 'ok', caption: this.textInsert}, 'close'],
font: selected && selected.length>0 ? me.api.asc_getCellInfo().asc_getXfs().asc_getFontName() : undefined,
symbol: selected && selected.length>0 ? selected.charAt(0) : undefined,
handler: function(dlg, result, settings) {
if (result == 'ok') {
me.api.asc_insertSymbol(settings.font ? settings.font : me.api.asc_getCellInfo().asc_getXfs().asc_getFontName(), settings.code, settings.special);