mirror of
https://github.com/ONLYOFFICE/sdkjs.git
synced 2026-04-07 14:09:12 +08:00
[de] Fix blur/focus events for annotations
Add descriptions for new methods working with annotations Temporarily hard code annotation color and position for spelling and grammar checker.
This commit is contained in:
@ -2166,17 +2166,21 @@
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
let color = AscCommon.getUserColorById(handlerId, null, false);
|
let color = AscCommon.getUserColorById(handlerId, null, false);
|
||||||
|
let underlineY = 0.1 * (baseLine - y0) + baseLine;
|
||||||
|
|
||||||
|
if (-1 !== handlerId.indexOf("spelling"))
|
||||||
|
{
|
||||||
|
color = new CColor(239, 68, 68, 255);
|
||||||
|
}
|
||||||
|
else if (-1 !== handlerId.indexOf("grammar"))
|
||||||
|
{
|
||||||
|
color = new CColor(59, 130, 246, 255);
|
||||||
|
underlineY = 0.2 * (baseLine - y0) + baseLine;
|
||||||
|
}
|
||||||
|
|
||||||
this.p_color(color.r, color.g, color.b, 255);
|
this.p_color(color.r, color.g, color.b, 255);
|
||||||
this.p_width(0.5 * 1000);
|
this.p_width(0.25 * 1000);
|
||||||
|
this.drawHorLine(0, underlineY, x0, x0 + w, 0.25 );
|
||||||
let underlineY = 0.15 * (baseLine - y0) + baseLine;
|
|
||||||
this._s();
|
|
||||||
this._m(x0, underlineY);
|
|
||||||
this._l(x0 + w, underlineY);
|
|
||||||
|
|
||||||
this.ds();
|
|
||||||
this._s();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// smart methods for horizontal / vertical lines
|
// smart methods for horizontal / vertical lines
|
||||||
|
|||||||
@ -108,7 +108,7 @@
|
|||||||
"paragraphId" : paraId,
|
"paragraphId" : paraId,
|
||||||
"recalcId" : recalcId,
|
"recalcId" : recalcId,
|
||||||
"text" : text,
|
"text" : text,
|
||||||
"ranges" : []
|
"annotations" : []
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +130,7 @@
|
|||||||
if (handlerName)
|
if (handlerName)
|
||||||
range["name"] = handlerName;
|
range["name"] = handlerName;
|
||||||
|
|
||||||
objByGuid[guid]["ranges"].push(range);
|
objByGuid[guid]["annotations"].push(range);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +139,7 @@
|
|||||||
{
|
{
|
||||||
let guids = {};
|
let guids = {};
|
||||||
guids[guid] = true;
|
guids[guid] = true;
|
||||||
window.g_asc_plugins.onPluginEvent2("onAnnotateText", objByGuid[guid], guids);
|
window.g_asc_plugins.onPluginEvent2("onParagraphText", objByGuid[guid], guids);
|
||||||
|
|
||||||
excludeGuids[guid] = 1;
|
excludeGuids[guid] = 1;
|
||||||
}
|
}
|
||||||
@ -150,7 +150,7 @@
|
|||||||
"text" : text
|
"text" : text
|
||||||
};
|
};
|
||||||
|
|
||||||
window.g_asc_plugins.onPluginEvent2("onAnnotateText", _obj, null, false, false, excludeGuids);
|
window.g_asc_plugins.onPluginEvent2("onParagraphText", _obj, null, false, false, excludeGuids);
|
||||||
};
|
};
|
||||||
TextAnnotatorEventManager.prototype.onResponse = function(obj)
|
TextAnnotatorEventManager.prototype.onResponse = function(obj)
|
||||||
{
|
{
|
||||||
@ -244,7 +244,8 @@
|
|||||||
"rangeId" : rangeId
|
"rangeId" : rangeId
|
||||||
};
|
};
|
||||||
this.addNameFromHandlerId(handlerId, obj);
|
this.addNameFromHandlerId(handlerId, obj);
|
||||||
window.g_asc_plugins.onPluginEvent("onBlurAnnotation", obj, this.getGuid(handlerId));
|
let guids = {}; guids[this.getGuid(handlerId)] = true;
|
||||||
|
window.g_asc_plugins.onPluginEvent2("onBlurAnnotation", obj, guids);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -261,7 +262,8 @@
|
|||||||
"rangeId" : rangeId
|
"rangeId" : rangeId
|
||||||
};
|
};
|
||||||
this.addNameFromHandlerId(handlerId, obj);
|
this.addNameFromHandlerId(handlerId, obj);
|
||||||
window.g_asc_plugins.onPluginEvent("onFocusAnnotation", obj, this.getGuid(handlerId));
|
let guids = {}; guids[this.getGuid(handlerId)] = true;
|
||||||
|
window.g_asc_plugins.onPluginEvent2("onFocusAnnotation", obj, guids);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -284,7 +286,8 @@
|
|||||||
{
|
{
|
||||||
_ranges.push(rangeId);
|
_ranges.push(rangeId);
|
||||||
}
|
}
|
||||||
window.g_asc_plugins.onPluginEvent("onClickAnnotation", obj, this.getGuid(handlerId));
|
let guids = {}; guids[this.getGuid(handlerId)] = true;
|
||||||
|
window.g_asc_plugins.onPluginEvent2("onClickAnnotation", obj, guids);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
TextAnnotatorEventManager.prototype.getHandlerId = function(obj)
|
TextAnnotatorEventManager.prototype.getHandlerId = function(obj)
|
||||||
|
|||||||
@ -1303,7 +1303,23 @@
|
|||||||
let docPos = topDocument && topDocument.GetContentPosition ? topDocument.GetContentPosition(false) : null;
|
let docPos = topDocument && topDocument.GetContentPosition ? topDocument.GetContentPosition(false) : null;
|
||||||
return bookmarks.GetBookmarkByDocPos(docPos);
|
return bookmarks.GetBookmarkByDocPos(docPos);
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* Annotate the specified paragraph.
|
||||||
|
* @memberof Api
|
||||||
|
* @typeofeditors ["CDE"]
|
||||||
|
* @alias AnnotateParagraph
|
||||||
|
* @param {Object} obj - The response object containing annotation data
|
||||||
|
* @param {string} obj.type - The type of annotation operation (e.g., "highlightText")
|
||||||
|
* @param {string} [obj.name] - Optional name of the annotation
|
||||||
|
* @param {string} obj.paragraphId - ID of the paragraph being annotated (for highlightText type)
|
||||||
|
* @param {string} obj.recalcId - Recalculation ID for validation (for highlightText type)
|
||||||
|
* @param {Array<{start: number, length: number, id: string}>} [obj.ranges] - Array of text ranges to highlight (for highlightText type)
|
||||||
|
* @param {number} obj.ranges[].start - Starting index of the text range
|
||||||
|
* @param {number} obj.ranges[].length - Length of the text range
|
||||||
|
* @param {string} obj.ranges[].id - Unique identifier for the range
|
||||||
|
* @since 9.2.0
|
||||||
|
* @see office-js-api/Examples/Plugins/{Editor}/Api/Methods/AnnotateParagraph.js
|
||||||
|
*/
|
||||||
Api.prototype["pluginMethod_AnnotateParagraph"] = function(obj)
|
Api.prototype["pluginMethod_AnnotateParagraph"] = function(obj)
|
||||||
{
|
{
|
||||||
if (!obj)
|
if (!obj)
|
||||||
@ -1312,6 +1328,18 @@
|
|||||||
obj["guid"] = window.g_asc_plugins.getCurrentPluginGuid();
|
obj["guid"] = window.g_asc_plugins.getCurrentPluginGuid();
|
||||||
this.getTextAnnotatorEventManager().onResponse(obj);
|
this.getTextAnnotatorEventManager().onResponse(obj);
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* Selects a specific annotation range in the document.
|
||||||
|
* @memberof Api
|
||||||
|
* @typeofeditors ["CDE"]
|
||||||
|
* @alias AnnotateParagraph
|
||||||
|
* @param {Object} obj - The range selection object
|
||||||
|
* @param {string} obj.paragraphId - ID of the paragraph containing the annotation
|
||||||
|
* @param {string} obj.rangeId - ID of the specific range to select
|
||||||
|
* @param {string} [obj.name] - Optional name/type of the annotation (e.g., "grammar", "spelling", etc.)
|
||||||
|
* @since 9.2.0
|
||||||
|
* @see office-js-api/Examples/Plugins/{Editor}/Api/Methods/SelectAnnotationRange.js
|
||||||
|
*/
|
||||||
Api.prototype["pluginMethod_SelectAnnotationRange"] = function(obj)
|
Api.prototype["pluginMethod_SelectAnnotationRange"] = function(obj)
|
||||||
{
|
{
|
||||||
if (!obj)
|
if (!obj)
|
||||||
@ -1320,6 +1348,18 @@
|
|||||||
obj["guid"] = window.g_asc_plugins.getCurrentPluginGuid();
|
obj["guid"] = window.g_asc_plugins.getCurrentPluginGuid();
|
||||||
this.getTextAnnotatorEventManager().selectRange(obj);
|
this.getTextAnnotatorEventManager().selectRange(obj);
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* Remove a specific annotation range from the document.
|
||||||
|
* @memberof Api
|
||||||
|
* @typeofeditors ["CDE"]
|
||||||
|
* @alias RemoveAnnotationRange
|
||||||
|
* @param {Object} obj - The range removing object
|
||||||
|
* @param {string} obj.paragraphId - ID of the paragraph containing the annotation
|
||||||
|
* @param {string} obj.rangeId - ID of the specific range to remove
|
||||||
|
* @param {string} [obj.name] - Optional name/type of the annotation (e.g., "grammar", "spelling", etc.)
|
||||||
|
* @since 9.2.0
|
||||||
|
* @see office-js-api/Examples/Plugins/{Editor}/Api/Methods/RemoveAnnotationRange.js
|
||||||
|
*/
|
||||||
Api.prototype["pluginMethod_RemoveAnnotationRange"] = function(obj)
|
Api.prototype["pluginMethod_RemoveAnnotationRange"] = function(obj)
|
||||||
{
|
{
|
||||||
if (!obj)
|
if (!obj)
|
||||||
|
|||||||
Reference in New Issue
Block a user