ピン留め

このサンプルでは特定のコメントをピン留めする機能を確認することができます。

コメントコンポーネントのコメントのピン留め機能について解説します。 ピン留め デフォルトでは、コメントコンポーネントのコメント情報にピン留めを制御するアイコンが表示されます。また、loadStickedCommentオプションを使用して、コメントコンポーネントが初期化される時にピン留めするコメントを設定できます。 設定例は以下の通りです。 ピン留めの解除 ピン留めを設定したコメントは、コメントコンポーネントの上部に固定表示されます。ピン留めを解除するには、ピン留めアイコンをもう一度クリックするか、固定表示部分の「…」メニューから「ピン留めを外す」を選択します。 ピン留めの置き換え ピン留めできるコメントは、1つのみとなります。他のコメントをピン留めする場合は、既にピン留めしたコメントを解除する必要があります。 ピン留めしたコメントを解除せずに他のコメントをピン留めすると、確認ダイアログが表示されます。このダイアログで「OK」を押下すると、新しいコメントが既存のピン留めコメントを置き換えます。 コマンド UI以外からもピン留めを実行するために、StickCommentとStickCommentElementコマンドをサポートします。 StickCommentコマンドを実行することで、指定したコメントをピン留め/ピン留め解除します。dataSourceが設定されている場合、サーバーにリクエストが送信され、コメントの存在や既にピン留めされているか、権限などの条件が確認されます。クライアントが成功のレスポンスを受け取ると、コメントがピン留めされます。 StickCommentElementコマンドを実行することで、クライアントのみピン留め/ピン留め解除を実行します。 設定例は以下の通りです。 注意事項 ピン留めのコメントが長すぎて一行に収まらない場合、3点リーダー(…)で省略文字を表示します。
import './styles.css'; import '@mescius/inputman.comment/CSS/gc.inputman.comment.css'; import '@mescius/inputman.richtexteditor/CSS/gc.inputman.richtexteditor.css'; import { InputMan } from '@mescius/inputman.comment'; import * as RichTextEditorControl from '@mescius/inputman.richtexteditor'; import { postedComments } from './data'; const gcComment = new InputMan.GcComment(document.getElementById('gcComment'), { openLinkMode: InputMan.OpenLinkMode.GoToComment, commentInfoAction: [ InputMan.GcCommentCommentInfoActionItem.PostTime, InputMan.GcCommentCommentInfoActionItem.StickComment, ], editorConfig: { editorType: InputMan.GcCommentEditorType.GcRichTextEditor, height: 150, menubar: [], }, userInfo: { id: '1', name: '森上 偉久馬', avatar: '$IMDEMOROOT$/ja/samples/comment/stickComment/img/avatar1.png', }, loadComments: (args) => { return { comments: postedComments, }; }, loadStickedComment: () => postedComments.find((comment) => comment.id === '2'), });
<!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/stickComment/img/avatar1.png', }, content: `<b>このサンプルではコメントをピン留めしています。</b><br>ピン留めを設定したコメントは、画面の上部に固定表示されます。`, 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: '3', name: '加藤 泰江', avatar: '$IMDEMOROOT$/ja/samples/comment/stickComment/img/avatar3.png', }, content: 'ピン留め機能を使用すると、重要なコメントは画面をスクロールしても常に上部に表示されます。また、ピン留めされたコメントをクリックすると、そのコメントの位置に移動します。', postTime: new Date(2024, 4, 20, 8, 1, 1), updateTime: new Date(2024, 4, 20, 8, 1, 1), reactions: [ { reactionChar: '👍', count: 3, currentUserReacted: true, }, ], }, { id: '3', userInfo: { id: '5', name: '松沢 誠一', avatar: '$IMDEMOROOT$/ja/samples/comment/stickComment/img/avatar5.png', }, content: '一度ピン留めできるコメントは、1つのみとなります。他のコメントをピン留めする場合は、既存のピン留めを解除する必要があります。', postTime: new Date(2024, 7, 16, 8, 1, 59), updateTime: new Date(2024, 7, 16, 8, 1, 59), reactions: [ { reactionChar: '👍', count: 1, }, ], }, { id: '4', userInfo: { id: '3', name: '加藤 泰江', avatar: '$IMDEMOROOT$/ja/samples/comment/stickComment/img/avatar3.png', }, content: 'ピン留めを解除するには、ピン留めアイコンをもう一度クリックするか、コメントの「...」メニューから「ピン留めを外す」を選択します。', postTime: new Date(2024, 7, 18, 8, 1, 50), updateTime: new Date(2024, 7, 18, 8, 1, 50), parentCommentId: '2', reactions: [ { reactionChar: '👍', count: 3, currentUserReacted: true, }, ], }, ];
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.richtexteditor/JS/plugins/advlist': 'npm:@mescius/inputman.richtexteditor/JS/plugins/advlist/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/all': 'npm:@mescius/inputman.richtexteditor/JS/plugins/all/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/autosave': 'npm:@mescius/inputman.richtexteditor/JS/plugins/autosave/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/charmap': 'npm:@mescius/inputman.richtexteditor/JS/plugins/charmap/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/directionality': 'npm:@mescius/inputman.richtexteditor/JS/plugins/directionality/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/emoticons': 'npm:@mescius/inputman.richtexteditor/JS/plugins/emoticons/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/fullscreen': 'npm:@mescius/inputman.richtexteditor/JS/plugins/fullscreen/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/htmlcode': 'npm:@mescius/inputman.richtexteditor/JS/plugins/htmlcode/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/image': 'npm:@mescius/inputman.richtexteditor/JS/plugins/image/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/link': 'npm:@mescius/inputman.richtexteditor/JS/plugins/link/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/lists': 'npm:@mescius/inputman.richtexteditor/JS/plugins/lists/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/media': 'npm:@mescius/inputman.richtexteditor/JS/plugins/media/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/pagebreak': 'npm:@mescius/inputman.richtexteditor/JS/plugins/pagebreak/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/preview': 'npm:@mescius/inputman.richtexteditor/JS/plugins/preview/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/save': 'npm:@mescius/inputman.richtexteditor/JS/plugins/save/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/searchreplace': 'npm:@mescius/inputman.richtexteditor/JS/plugins/searchreplace/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/table': 'npm:@mescius/inputman.richtexteditor/JS/plugins/table/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/template': 'npm:@mescius/inputman.richtexteditor/JS/plugins/template/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/wordcount': 'npm:@mescius/inputman.richtexteditor/JS/plugins/wordcount/plugin.js', '@mescius/inputman.comment': 'npm:@mescius/inputman.comment/index.js', '@mescius/inputman.comment/CSS': 'npm:@mescius/inputman.comment/CSS', '@mescius/wijmo': 'npm:@mescius/wijmo/index.js', '@mescius/wijmo.styles': 'npm:@mescius/wijmo.styles', '@mescius/wijmo.cultures': 'npm:@mescius/wijmo.cultures', '@mescius/wijmo.input': 'npm:@mescius/wijmo.input/index.js', '@mescius/wijmo.grid': 'npm:@mescius/wijmo.grid/index.js', '@mescius/wijmo.nav': 'npm:@mescius/wijmo.nav/index.js', '@mescius/spread-sheets': 'npm:@mescius/spread-sheets/index.js', '@mescius/spread-sheets-resources-ja': 'npm:@mescius/spread-sheets-resources-ja/index.js', '@mescius/spread-sheets/styles': 'npm:@mescius/spread-sheets/styles', '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' }, } });