mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 11:42:49 -06:00
minibar: adapt to changed bracket structure in linearization output
This commit is contained in:
@@ -370,23 +370,36 @@ Input.prototype.end_structural_editing=function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Input.prototype.enable_structural_editing=function(brackets,tree) {
|
Input.prototype.enable_structural_editing=function(bracketss,tree) {
|
||||||
var t=this;
|
var t=this;
|
||||||
with(t) {
|
with(t) {
|
||||||
var typed=surface.typed;
|
var typed=surface.typed;
|
||||||
function add_bs(b,parent) {
|
function add_bracket(brackets) {
|
||||||
if(b.token) {
|
function add_bs(b,parent) {
|
||||||
var fun=parent.fun,cat=parent.cat;
|
if(b.token) {
|
||||||
function showrepl() { t.show_replacements(brackets,parent,tree)}
|
var fun=parent.fun,cat=parent.cat;
|
||||||
var w= span_class("word editable",text(b.token));
|
function showrepl() {
|
||||||
if(fun && cat) w.onclick=showrepl
|
t.show_replacements(brackets,parent,tree)
|
||||||
w.title=(fun||"_")+":"+(cat||"_")+" "+parent.fid+":"+parent.index
|
}
|
||||||
surface.insertBefore(w,typed);
|
if(fun && cat) {
|
||||||
|
var w= span_class("word editable",text(b.token));
|
||||||
|
w.onclick=showrepl
|
||||||
|
}
|
||||||
|
else
|
||||||
|
var w= span_class("word",text(b.token));
|
||||||
|
w.title=(fun||"_")+":"+(cat||"_")+" "+parent.fid+":"+parent.index
|
||||||
|
surface.insertBefore(w,typed);
|
||||||
|
}
|
||||||
|
else b.children.map(function(c){add_bs(c,b)})
|
||||||
}
|
}
|
||||||
else b.children.map(function(c){add_bs(c,b)})
|
add_bs(brackets,null)
|
||||||
}
|
}
|
||||||
remove_surface_words()
|
remove_surface_words()
|
||||||
add_bs(brackets);
|
//add_bs(brackets);
|
||||||
|
if(Array.isArray(bracketss))
|
||||||
|
bracketss.map(add_bracket) // gf>3.5
|
||||||
|
else
|
||||||
|
add_bracket(bracketss) // gf<=3.5
|
||||||
t.surface.structural_editing_enabled=true;
|
t.surface.structural_editing_enabled=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ Translations.prototype.show_translations=function(translationResults) {
|
|||||||
trans.appendChild(wrap("pre",text(errs[i].msg)))
|
trans.appendChild(wrap("pre",text(errs[i].msg)))
|
||||||
}
|
}
|
||||||
if(options.show_brackets)
|
if(options.show_brackets)
|
||||||
trans.appendChild(div_class("brackets",draw_brackets(bra)));
|
trans.appendChild(div_class("brackets",draw_bracketss(bra)));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -291,3 +291,9 @@ function draw_brackets(b) {
|
|||||||
title:(b.fun||"_")+":"+b.cat+" "+b.fid+":"+b.index},
|
title:(b.fun||"_")+":"+b.cat+" "+b.fid+":"+b.index},
|
||||||
b.children.map(draw_brackets))
|
b.children.map(draw_brackets))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function draw_bracketss(bs) {
|
||||||
|
return Array.isArray(bs)
|
||||||
|
? bs.map(draw_brackets) //with gf>3.5, in some cases
|
||||||
|
: draw_brackets(b) // with gf<=3.5
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user