Commit 06f47bf5 authored by Liang Ding's avatar Liang Ding

🎨 支持配置编辑器模式 #95

parent 538802c5
...@@ -26,7 +26,7 @@ import org.json.JSONObject; ...@@ -26,7 +26,7 @@ import org.json.JSONObject;
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="https://hacpai.com/member/hzchendou">hzchendou</a> * @author <a href="https://hacpai.com/member/hzchendou">hzchendou</a>
* @version 1.6.0.5, Jan 25, 2020 * @version 1.6.0.6, Apr 6, 2020
* @since 0.6.0 * @since 0.6.0
*/ */
public final class Option { public final class Option {
...@@ -53,6 +53,17 @@ public final class Option { ...@@ -53,6 +53,17 @@ public final class Option {
// oId constants // oId constants
/**
* Key of editor mode. 支持配置编辑器模式 https://github.com/88250/solo/issues/95
* <ul>
* <li>wysiwyg:所见即所得</li>
* <li>ir:即时渲染</li>
* <li>sv:分屏预览</li>
* </ul>
* 模式细节介绍详见 <a href="https://github.com/Vanessa219/vditor">Vditor</a> 编辑器文档。
*/
public static final String ID_C_EDITOR_MODE = "editorMode";
/** /**
* Key of inline math allow digit after open marker flag. 内联数学公式是否允许起始 $ 后紧跟数字 https://github.com/88250/solo/issues/54 * Key of inline math allow digit after open marker flag. 内联数学公式是否允许起始 $ 后紧跟数字 https://github.com/88250/solo/issues/54
*/ */
......
...@@ -53,7 +53,7 @@ import java.util.List; ...@@ -53,7 +53,7 @@ import java.util.List;
* Solo initialization service. * Solo initialization service.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.5.2.38, Jan 24, 2020 * @version 1.5.2.39, Apr 6, 2020
* @since 0.4.0 * @since 0.4.0
*/ */
@Service @Service
...@@ -472,6 +472,12 @@ public class InitService { ...@@ -472,6 +472,12 @@ public class InitService {
private void initOptions(final JSONObject requestJSONObject) throws Exception { private void initOptions(final JSONObject requestJSONObject) throws Exception {
LOGGER.debug("Initializing preference...."); LOGGER.debug("Initializing preference....");
final JSONObject editorModeOpt = new JSONObject();
editorModeOpt.put(Keys.OBJECT_ID, Option.ID_C_EDITOR_MODE);
editorModeOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
editorModeOpt.put(Option.OPTION_VALUE, "wysiwyg");
optionRepository.add(editorModeOpt);
final JSONObject IMADAOMOpt = new JSONObject(); final JSONObject IMADAOMOpt = new JSONObject();
IMADAOMOpt.put(Keys.OBJECT_ID, Option.ID_C_IMADAOM); IMADAOMOpt.put(Keys.OBJECT_ID, Option.ID_C_IMADAOM);
IMADAOMOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE); IMADAOMOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
......
...@@ -40,7 +40,7 @@ import java.util.Locale; ...@@ -40,7 +40,7 @@ import java.util.Locale;
* Preference management service. * Preference management service.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.4.0.5, Jan 25, 2020 * @version 1.4.0.6, Apr 6, 2020
* @since 0.4.0 * @since 0.4.0
*/ */
@Service @Service
...@@ -253,6 +253,9 @@ public class PreferenceMgmtService { ...@@ -253,6 +253,9 @@ public class PreferenceMgmtService {
emptyPreferenceOptSave(Option.ID_C_IMADAOM, IMADAOMVal); emptyPreferenceOptSave(Option.ID_C_IMADAOM, IMADAOMVal);
Markdowns.IMADAOM = "true".equalsIgnoreCase(IMADAOMVal); Markdowns.IMADAOM = "true".equalsIgnoreCase(IMADAOMVal);
final String editorModeVal = preference.optString(Option.ID_C_EDITOR_MODE);
emptyPreferenceOptSave(Option.ID_C_EDITOR_MODE, editorModeVal);
transaction.commit(); transaction.commit();
Markdowns.clearCache(); Markdowns.clearCache();
...@@ -269,6 +272,7 @@ public class PreferenceMgmtService { ...@@ -269,6 +272,7 @@ public class PreferenceMgmtService {
} }
private void emptyPreferenceOptSave(final String optID, final String val) throws Exception { private void emptyPreferenceOptSave(final String optID, final String val) throws Exception {
// 该方法用于向后兼容,如果数据库中不存在该配置项则创建再保存
JSONObject opt = optionRepository.get(optID); JSONObject opt = optionRepository.get(optID);
if (null == opt) { if (null == opt) {
opt = new JSONObject(); opt = new JSONObject();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment