@HUMMEL

Are you sure you want to delete the question?

Leaving a resolved question undeleted may help others!

summer noteで最初に表示されるフォント名を変更したい

Q&A

Closed

解決したいこと

Summernote v0.8.18

summer noteでフォントのボタンに最初に表示されるフォント名を変更したいのですが、
summernote(https://summernote.org/)を見ても解決策がないようです。

現時点ではデフォルトの「sans-serif」が選択中として最初に表示されています。
この部分を変更する方法を教えて下さい。

fontNames: ["Yu Gothic","Yu Mincho","Meiryo","sans-serif", "Arial","Arial Black","Comic Sans MS","Courier New","Helvetica","Impact","Lucida Grande","Tahoma","Times New Roman","Verdana"],
上記のようにフォントを指定していますが、最初にある「Yu Gothic」を選択状態(最初に表示)にしたいのです。

どうかよろしくお願い致します。

自分で試したこと

https://summernote.org/deep-dive/#font-style-api
上記ページなどを参考にしましたが、解決に至りませんでした。

1 likes

1Answer

Summernote automatically populates the font dropdown with the available fonts that are given on fontNames option. This includes the font set on the current dom element.

現在のdom要素上のフォントセットが追加されると書いてあったので

<style>
	body {
		font-family: Yu Gothic;
	}
</style>
<head>

適当にcssを追加してあげれば Yu Gothic がデフォルト状態になりました
bodyだといい加減すぎるので、適切なclassにfont-familyを追加すれば大丈夫なんじゃないかな

See the Pen Untitled by amate (@amate-the-vuer) on CodePen.

0Like

Comments

  1. @HUMMEL

    Questioner

    ご回答有難う御座います。

    snote-1s.png
    snote-2s.png

    上記のように、問題解決には至りませんでした。残念です。

  2. @HUMMEL

    Questioner

    その後、色々トライしていて、
    「summernote-lite.min.css」のfont-family指定が「sans-serif」になっている所を
    「Yu Gothic」に変更したら、表示させることが出来ました。とりあえずご報告まで。
    snote-3s.png

Your answer might help someone💌