プロジェクト

全般

プロフィール

Vote #74417

未完了

Use a stable and modifiable data structure for jsToolbar elements

Admin Redmine さんが約4年前に追加.

ステータス:
New
優先度:
通常
担当者:
-
カテゴリ:
-
対象バージョン:
-
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
0
version_id:
0
issue_org_id:
14936
author_id:
3866
assigned_to_id:
0
comments:
4
status_id:
1
tracker_id:
2
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[New]

説明

The elements of the jsToolbar are currently stored in a javascript @{}@ (see source:/trunk/public/javascripts/jstoolbar/jstoolbar.js@12152#L153) and are read in the hopes they will come out in the same order they have been put in (see source:/trunk/public/javascripts/jstoolbar/jstoolbar.js@12152#L213). This however is not a specified behavior of javascript, it just happens to work in most browsers ("Chrome being the exception here in certain cases":http://ejohn.org/blog/javascript-in-chrome/#ig-sh-2 (sorry for the weird anchor of the link, the enclosing section has none)). The specification explicitly states:

The […] order of enumerating the properties […] is not specified.

(see "ECMA-262 12.6.4":http://www.ecma-international.org/ecma-262/5.1/#sec-12.6.4)

We ("Planio":http://plan.io) haven't seen any bugs with the current implementation but find it lacking in that we cannot add a button at a specific position in the toolbar without adding it to core js files (which has become more difficult since the @jstoolbar-textile.min.js@ is shipped with core without any apparent clues how it is generated, but that's not the point here).

Would the Redmine team be open to switching the aforementioned @jsToolBar.prototype.elements@ to a data structure with a guaranteed ordering and the ability to add elements at a specified absolute ("at position X") or relative ("after button X") place?


journals

(Note: this is related to #14937 but the button submitted in #14937 is not the only use-case we have for this, so fixing #14937 doesn't fix this)
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Felix Schäfer wrote:
> [...] but find it lacking in that we cannot add a button at a specific position in the toolbar without adding it to core js files [...]

I agree on that.

> [...] switching the aforementioned @jsToolBar.prototype.elements@ to a data structure with a guaranteed ordering and the ability to add elements at a specified absolute ("at position X") or relative ("after button X") place?

To me this sounds like a good idea. This will give plugin developers (thinking about custom macros, custom syntax, etc.; like the often used WikiNG plugin) the control they need.

--------------------------------------------------------------------------------
I have an experience of similar problem.
In that case, I want to add a special image button after the original image button.
I solved this problem by modifying/replacing `jsToolBar.prototype.elements` at runtime.
However, it is not straightforward so new API is welcome.

see: https://github.com/t-yuki/clipboard_image_paste/commit/122a9134165ecc3c6a056fdab788efd2d95bfbb3

--------------------------------------------------------------------------------


related_issues

relates,Closed,14937,Code highlighting toolbar button

表示するデータがありません

他の形式にエクスポート: Atom PDF

いいね!0