TinyMCE:添加复杂格式(TinyMCE: Add complex format)
我想为Joomla的TinyMCE编辑器添加一种格式。 它应该是一种在内容周围显示可伸缩图形框的格式。 由于盒子必须随内容缩放,我不能简单地使用一个背景框图形。 相反,我必须在盒子的两侧使用图形,然后可以在x和y方向上缩放。 为了实现这一点,我需要将文本包装到多个div中。 因此,我需要添加一种将内容包装到这些div中的格式。 但是,似乎TinyMCE只允许将内容包装成一个HTML元素的格式 - 但是,如上所述,我需要不止一个。 这可能吗?
I want to add a format to the TinyMCE Editor for Joomla. It should be a format that displays a scalable graphical box around the content. Since the box must scale with the content, I cannot simply use one background box graphics. Instead, I must use graphics for the sides of the box which then can scale in x and y direction. In order to achieve this, I need to wrap the text into more than one div. Thus, I need a possibility to add a format that wraps the content into these divs. However, it seems that TinyMCE does only allow formats that wrap the content into one HTML element - but, as stated above, I need more than one. Is this possible?
原文:https://stackoverflow.com/questions/12271359
最满意答案
这是我如何做到的。 在我的
InputConnection
我重写getTextBeforeCursor
以始终返回" "
以便IME始终认为它至少可以删除一个字符。我还将连接的输入类型设置为
InputType.TYPE_NULL
以便传递关键事件(来自Google的官方解决方法)。我的自定义
EditText
:public class InterceptTextView extends EditText { public interface OnBackspacePressListener { public void onBackspacePressed(); } private OnBackspacePressListener backspaceListener; public InterceptTextView(Context context, AttributeSet attrs) { super(context, attrs); setText(" "); } public void setOnBackspacePressListener(OnBackspacePressListener backspaceListener) { this.backspaceListener = backspaceListener; } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if(keyCode == KeyEvent.KEYCODE_DEL) { if(backspaceListener != null) { backspaceListener.onBackspacePressed(); } } return super.onKeyDown(keyCode, event); } @Override public InputConnection onCreateInputConnection(EditorInfo outAttrs) { outAttrs.actionLabel = null; outAttrs.inputType = InputType.TYPE_NULL; BaseInputConnection connection = new BaseInputConnection(this, false) { @Override public String getTextBeforeCursor(int ignore, int ignore2) { return " "; } }; return connection; } }
我的
Fragment
:public class KeyFragment extends Fragment { private static volatile boolean backspacePressed = false; private InterceptTextView et; private TextWatcher textWatcher = new TextWatcher() { @Override public void afterTextChanged(Editable s) { if(backspacePressed) { backspacePressed = false; return; } else { Logger.i("" + s.charAt(s.length() - 1)); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @Override public void onTextChanged(CharSequence s, int start, int before, int count) {} }; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.keyboard, null); et = (InterceptTextView) v.findViewById(R.id.keyboard_input_sink); et.setOnBackspacePressListener(new OnBackspacePressListener() { @Override public void onBackspacePressed() { backspacePressed = true; Logger.i("BCKSPC"); } }); et.addTextChangedListener(textWatcher); return v; } }
Here's how I did it. In my
InputConnection
I overridegetTextBeforeCursor
to always to return" "
so that the IME always thinks that there's at least one character it can delete.I also set the input type of the connection to
InputType.TYPE_NULL
so that key events will be delivered (official workaround from Google).My custom
EditText
:public class InterceptTextView extends EditText { public interface OnBackspacePressListener { public void onBackspacePressed(); } private OnBackspacePressListener backspaceListener; public InterceptTextView(Context context, AttributeSet attrs) { super(context, attrs); setText(" "); } public void setOnBackspacePressListener(OnBackspacePressListener backspaceListener) { this.backspaceListener = backspaceListener; } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if(keyCode == KeyEvent.KEYCODE_DEL) { if(backspaceListener != null) { backspaceListener.onBackspacePressed(); } } return super.onKeyDown(keyCode, event); } @Override public InputConnection onCreateInputConnection(EditorInfo outAttrs) { outAttrs.actionLabel = null; outAttrs.inputType = InputType.TYPE_NULL; BaseInputConnection connection = new BaseInputConnection(this, false) { @Override public String getTextBeforeCursor(int ignore, int ignore2) { return " "; } }; return connection; } }
My
Fragment
:public class KeyFragment extends Fragment { private static volatile boolean backspacePressed = false; private InterceptTextView et; private TextWatcher textWatcher = new TextWatcher() { @Override public void afterTextChanged(Editable s) { if(backspacePressed) { backspacePressed = false; return; } else { Logger.i("" + s.charAt(s.length() - 1)); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @Override public void onTextChanged(CharSequence s, int start, int before, int count) {} }; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.keyboard, null); et = (InterceptTextView) v.findViewById(R.id.keyboard_input_sink); et.setOnBackspacePressListener(new OnBackspacePressListener() { @Override public void onBackspacePressed() { backspacePressed = true; Logger.i("BCKSPC"); } }); et.addTextChangedListener(textWatcher); return v; } }
相关问答
更多-
退格图标/表示(Backspace icon/representation)[2023-04-08]
是: \u232B是“向左擦除”字符 :⌫。 Yes: \u232B is the "erase to the left" character: ⌫. -
linux文件的退格问题(backspace issue on linux file)[2022-12-06]
您需要更改文件首选项:转到首选项 - >文件,然后将“创建新文件”更改为UNIX。 此外,您可能希望启用“检查无效的CR / LF,加载时为空字符”选项。 You need to change file preferences: go to Preferences -> Files and change "Create new file as " to UNIX. Also, your might want to enable "Check invalid CR/LF, null character whe ... -
你有没有设置onKeyListeners? 这可能是问题的原因。 尝试这个: hintDialog = new AlertDialog.Builder(activity) .setTitle("Enter Your Hint:") .setView(hintDialogView).create(); hintDialog.setOnKeyListener(new DialogInterface.OnKeyListener() { @Override public boolean onKey(Dia ...
-
我解决了我的问题。 以下是其他人需要的解决方案: public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { if (isValid(dest.toString() + source.toString())) { //input is valid return null; }else{ //The ...
-
注入击键(Inject Keystrokes)[2022-02-02]
听起来你需要InstrumentationTestCase.sendKeys() http://developer.android.com/reference/android/test/InstrumentationTestCase.html#sendKeys(java.lang.String ) http://developer.android.com/reference/android/view/KeyEvent.html Well I'm actually working on a Synergy p ... -
Curses库退格问题(Curses Library Backspace Issue)[2022-10-18]
是的,您需要在垂直条之前重新插入一个空格,或者(我不确定这是否可行)设置一个小于终端宽度的滚动区域。 Yes, you need to re-insert a space just before the vertical bar, or (I'm not sure if this is possible) setup a scrolling region that's less than the full width of the terminal. -
Android拦截来自我自己的应用程序的软击键 - 退格问题(Android Intercept Soft Keystrokes From My Own Application - Backspace Issue)[2023-02-02]
这是我如何做到的。 在我的InputConnection我重写getTextBeforeCursor以始终返回" "以便IME始终认为它至少可以删除一个字符。 我还将连接的输入类型设置为InputType.TYPE_NULL以便传递关键事件(来自Google的官方解决方法)。 我的自定义EditText : public class InterceptTextView extends EditText { public interface OnBackspacePressListener { ... -
Android Edittext中的“退格”字符'\ b'不起作用?(The “backspace” character '\b' in the Android Edittext does not work?)[2023-05-01]
我找到了答案而没有深入了解“输入连接” keyDownUp(KeyEvent.KEYCODE_DEL) 这模拟了删除键的按下! 给了我EditText所需的退格! 好极了! I have found my answer without getting into the hassel of "Inputconnections" keyDownUp(KeyEvent.KEYCODE_DEL) This simulates the pressing of the delete key! Gave me t ... -
好的,所以我不知道发生这种情况的原因。 但我确实找到了解决问题的快速方法。 而不是依靠字体来渲染Icon只需使用图像
Ok so I don't know the reason why this happens. But I did figure out a quick solution to the ... -
KR - 可视化退格(KR - visualize backspace)[2023-12-02]
我假设您在终端中运行程序,然后键入一些输入。 终端通常处于熟制模式 ,其中退格会立即被解释为请擦除前一个字符 。 getchar()不会返回退格。 如果您想测试程序是否正确处理退格,请将它们插入标准输入,这样就可以使用带有相关烹饪的终端: $ printf 'foo\bbar\n' | ./a.out foo\bbar I assume you run your program in a terminal and then type some input. The terminal is usuall ...