ウォーターマークの設定

このサンプルではコメントコンポーネントに使用されているウォーターマークを設定しています。検索欄やコメントエディタのウォーターマークなどを確認することができます。

コメントコンポーネントは、組込みのウォーターマークを文字列またはHTML要素でカスタマイズすることができます。 ウォーターマークのカスタマイズ watermarkプロパティを利用して、以下の3つのウォーターマークをカスタマイズすることができます。 オプション 説明 デフォルト値 addComment コメントエディタに表示される コメントを追加 searchBox 検索欄に表示される 検索内容を入力してください。 continueAddComment 下書きが有効の場合、コメント編集を再開する際に表示される コメントを再開 設定例は以下の通りです。 注意事項 コメントコンポーネントを初期化する前に、リソースを設定することでウォーターマークをカスタマイズすることも可能です。
import './styles.css'; import '@mescius/inputman.comment/CSS/gc.inputman.comment.css'; import { InputMan } from '@mescius/inputman.comment'; import { postedComments } from './data'; let divAddComment = document.createElement('div'); divAddComment.style.color = 'purple'; divAddComment.append('ここからコメントを追加できます。'); let divSearchBox = document.createElement('div'); divSearchBox.style.color = 'blue'; divSearchBox.append('何か検索してみませんか?'); const gcComment = new InputMan.GcComment(document.getElementById('gcComment'), { editorConfig: { editorType: InputMan.GcCommentEditorType.Common, }, userInfo: { id: '1', name: '森上 偉久馬', avatar: '$IMDEMOROOT$/ja/samples/comment/watermark/img/avatar1.png', }, loadComments: (args) => { return { comments: postedComments, }; }, watermark: { addComment: divAddComment, searchBox: divSearchBox, continueAddComment: 'コメントの編集を続きます?', }, });
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <meta name="description" content="コメントコンポーネント 使い方" lang="ja" xml:lang="ja" /> <title>コメントコンポーネント - ウォーターマークの設定</title> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> window.onload = function() { System.import('./src/app'); } </script> </head> <body> <div id="gcComment"></div> </body> </html>
body { box-sizing: content-box !important; height: 551px !important; }
export const postedComments = [ { id: '1', userInfo: { id: '1', name: '森上 偉久馬', avatar: '$IMDEMOROOT$/ja/samples/comment/watermark/img/avatar1.png', }, content: 'このサンプルではコメントコンポーネントに使用されているウォーターマークを設定しています。', postTime: new Date(2024, 1, 1, 8, 0, 0), updateTime: new Date(2024, 1, 1, 8, 0, 0), reactions: [ { reactionChar: '👍', count: 2, }, ], }, { id: '2', userInfo: { id: '6', name: '成宮 真紀', avatar: '$IMDEMOROOT$/ja/samples/comment/watermark/img/avatar6.png', }, content: '検索欄やコメントエディタのウォーターマークが設定されています。', postTime: new Date(2024, 4, 20, 8, 1, 1), updateTime: new Date(2024, 4, 20, 8, 1, 1), }, { id: '3', userInfo: { id: '2', name: '葛城 孝史', avatar: '$IMDEMOROOT$/ja/samples/comment/watermark/img/avatar2.png', }, content: '下書き機能が有効にされる場合、コメント編集を再開する際のウォーターマークを設定できます。', postTime: new Date(2024, 4, 20, 8, 1, 1), updateTime: new Date(2024, 4, 20, 8, 1, 1), }, { id: '4', userInfo: { id: '6', name: '成宮 真紀', avatar: '$IMDEMOROOT$/ja/samples/comment/watermark/img/avatar6.png', }, content: 'また、コメントコンポーネントを初期化する前に、リソースの設定でウォーターマークを変更することもできます。', postTime: new Date(2024, 4, 22, 9, 1, 1), updateTime: new Date(2024, 4, 22, 10, 15, 1), }, ];
System.config({ transpiler: 'plugin-babel', babelOptions: { es2015: true }, meta: { '*.css': { loader: 'css' } }, paths: { // paths serve as alias 'npm:': 'node_modules/' }, // map tells the System loader where to look for things map: { '@mescius/inputman': 'npm:@mescius/inputman/index.js', '@mescius/inputman/CSS': 'npm:@mescius/inputman/CSS', '@mescius/inputman.richtexteditor': 'npm:@mescius/inputman.richtexteditor/index.js', '@mescius/inputman.richtexteditor/CSS': 'npm:@mescius/inputman.richtexteditor/CSS', '@mescius/inputman.comment': 'npm:@mescius/inputman.comment/index.js', '@mescius/inputman.comment/CSS': 'npm:@mescius/inputman.comment/CSS', 'css': 'npm:systemjs-plugin-css/css.js', 'plugin-babel': 'npm:systemjs-plugin-babel/plugin-babel.js', 'systemjs-babel-build': 'npm:systemjs-plugin-babel/systemjs-babel-browser.js' }, // packages tells the System loader how to load when no filename and/or no extension packages: { src: { defaultExtension: 'js' }, "node_modules": { defaultExtension: 'js' }, } });