ส่วนขยาย:CharInsert

This page is a translated version of the page Extension:CharInsert and the translation is 85% complete.
Outdated translations are marked like this.
MediaWiki extensions manual
CharInsert
Release status: stable
Implementation Tag , Page action , MyWiki
Description อนุญาตให้สร้างกล่องแทรกอักขระ JavaScript
Author(s) Brion Vibber (Brooke Vibberคุย)
Latest version continuous updates
Compatibility policy Snapshots releases along with MediaWiki. Master is not backward compatible.
MediaWiki >= 1.42
License GNU General Public License 2.0 or later
Download
‎<charinsert>
Quarterly downloads 97 (Ranked 64th)
Public wikis using 9,224 (Ranked 15th)
Translate the CharInsert extension if it is available at translatewiki.net
Issues Open tasks · Report a bug

ส่วนขยาย CharInsert อนุญาตให้สร้างลิงก์ JavaScript ที่เมื่อคลิกแล้ว ให้แทรกข้อความที่กำหนดไว้ล่วงหน้าลงใน กล่องข้อความ

ลิงก์เหล่านี้มักใช้ในข้อความระบบ MediaWiki:Edittools (ตัวอย่างในวิกินี้)

Syntax

ใช้แท็ก ‎<charinsert> พร้อมรายการ characters ที่คั่นด้วยช่องว่างหรือแท็กที่คุณต้องการอนุญาตให้แทรก

คุณสามารถใช้ + ลงชื่อเข้าใช้ในแท็กเพื่อกำหนดสถานที่สำหรับ:

  • แทรกข้อความที่เลือก หรือ
  • วางเคอร์เซอร์หากไม่มีการเลือกข้อความ

คุณต้องใส่แม่แบบและช่องว่างภายใน ‎<nowiki>:

<charinsert><nowiki>== + ==</nowiki> <nowiki>{{stub}}</nowiki></charinsert>

การใช้งานและเอาต์พุตตัวอย่าง

อักขระแต่ละตัว

อักขระแต่ละตัวอยู่ระหว่างแท็ก "charinsert" เท่านั้น

<charinsert>Á á Ć ć É é Í í Ĺ ĺ Ń ń Ó ó Ŕ ŕ Ś ś Ú ú Ý ý Ź ź</charinsert>

ผลลัพธ์ใน

Á á Ć ć É é Í í Ĺ ĺ Ń ń Ó ó Ŕ ŕ Ś ś Ú ú Ý ý Ź ź

การคลิกลิงก์จะไม่มีผลใด ๆ เนื่องจากไม่มีการป้อนข้อมูลหรือช่องแก้ไข

อักขระรวม

อักขระที่รวมกันอยู่ระหว่างแท็ก "charinsert" และเชื่อมต่อด้วยเครื่องหมาย "+"

<charinsert>“+” ‘+’ «+» ‹+› „+“ ‚+‘ [[+]] {{+}}</charinsert>

ผลลัพธ์ใน

“” ‘’ «» ‹› „“ ‚‘ [[]] {{}}

การคลิกลิงก์จะไม่มีผลใด ๆ เนื่องจากไม่มีการป้อนข้อมูลหรือช่องแก้ไข

Overriding display text

เวอร์ชันมีเดียวิกิ:
1.38
Gerrit change 748823

A different display text can be specified in the label attribute (if you use this, you should use separate <charinsert> tags for each character in order to specify different display texts).

<charinsert label="Latin A">A</charinsert> <charinsert label="Cyrillic А">А</charinsert> <charinsert label="Greek Alpha">Α</charinsert>

results in

Latin A Cyrillic А Greek Alpha

Clicking the links will have no effect since there is no input or edit field.

หมายเหตุ

  • ลิงก์ JavaScript ที่สร้างยังทำงานในพื้นที่อื่น ๆ รอบหน้าต่างแก้ไข เช่น ใน MediaWiki:Copyrightwarning หรือ MediaWiki:Newarticletext บนหน้าที่โหลดไว้ล่วงหน้าด้วย Inputbox และแม้กระทั่งจากการแสดงตัวอย่างข้อความ
  • นอกจากนี้ยังสามารถใช้เป็น MediaWiki:Uploadtext เพื่อแทรกแม่แบบคำอธิบายรูปภาพ
  • ส่วนขยายนี้ไม่มีวิธีการระบุ "ข้อความตัวอย่าง" ที่แทรก ซึ่งแตกต่างจากปุ่มบนแถบเครื่องมือที่ด้านบน
  • ใช้ &#10; เพื่อเพิ่มบรรทัดใหม่ (\n)
  • ใส่ช่องว่างสีขาวในแท็ก ‎<nowiki>...‎</nowiki> เมื่อจำเป็น
  • เพิ่มแท็ก ‎<charinsert>...‎</charinsert> เป็น MediaWiki:Edittools

การติดตั้ง

  • ดาวน์โหลดและวางไฟล์ลงในไดเร็กทอรีที่ชื่อ CharInsert ในโฟลเดอร์ extensions/ ของคุณ
    Developers and code contributors should install the extension from Git instead, using:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/CharInsert
  • เพิ่มโค้ดต่อไปนี้ไว้ที่ด้านล่างของ LocalSettings.php ของคุณ:
    wfLoadExtension( 'CharInsert' );
    
  • หากคุณใช้ gadget Edittools ให้อัปเดตโค้ดเป็น เวอร์ชันล่าสุด (≥ 27 พฤษภาคม 2016)
  •   สำเร็จ – ตรวจสอบที่ Special:Version บนวิกิของคุณเพื่อตรวจการติดตั้งส่วนขยาย

การติดตั้งขั้นสูง

สื่งสำคัญ: คุณจำเป็นต้องมี ส่วนขยาย:อุปกรณ์เสริม จึงจะใช้งานได้

จัดแต่งรูปแบบ

 

หากต้องการให้ charinsert แสดงรายการสไตล์เพิ่มเติม ให้รวบรวมเนื้อหาของ Edittools ของคุณระหว่าง <div class="mw-charinsert-buttons"> ถึง ‎</div> และเพิ่มสไตล์สำหรับ MediaWiki:Common.css ของคุณ ไซต์นี้ (www.mediawiki.org) ทำเพื่อให้ลิงก์ปรากฏเป็นปุ่ม (ดังแสดงในภาพหน้าจอด้านข้าง) ใช้สไตล์ชีตด้านล่างสำหรับสิ่งนั้น คัดลอกไปที่ MediaWiki:Common.css ของคุณเพื่อใช้สไตล์เดียวกัน

 
/**
 * Styling for links generated by [[MediaWiki:Edittools]]
 * @source https://www.mediawiki.org/wiki/Extension:CharInsert#Styling
 * @updated 2020-03-17
 */
.mw-charinsert-buttons {
	border: 1px solid #aaa;
	margin-top: 10px;
	padding: 1px;
	font-size: 1.1em;
	text-align: center;
}

.mw-charinsert-buttons a {
	background-color: #cde !important;
	color: #000;
	border: thin #069 outset;
	padding: 0 1px 1px;
	font-weight: bold;
	font-size: 0.9em;
	text-decoration: none;
}

.mw-charinsert-buttons a:hover,
.mw-charinsert-buttons a:active {
	background-color: #bcd;
	border-style: inset;
}

.client-js .mw-edittools-section {
	display: inline;
}

.client-js .mw-edittools-section input[type="button"] {
	font-size: 0.9em;
	margin-left: 1px;
	padding-left: 1px;
	padding-right: 1px;
}

หรือคุณสามารถเลือกรูปแบบที่ใกล้เคียงกับ Wikimedia Design Style Guide และ WikimediaUI theme:

 
/**
 * Styling for links generated by [[MediaWiki:Edittools]] in WikimediaUI inspired theme.
 * @source https://www.mediawiki.org/wiki/Extension:CharInsert#Styling
 * @updated 2020-03-17
 */
.mw-charinsert-buttons {
	margin-top: 8px;
	border: 1px solid #c8ccd1;
	padding: 2px 4px 4px;
	font-size: 1.1em;
	text-align: center;
}

.mw-charinsert-buttons a {
	background-color: #f8f9fa !important;
	color: #202122;
	border: thin #36c outset;
	padding: 0 1px 2px;
	font-size: 0.9em;
	font-weight: bold;
	text-decoration: none;
}

.mw-charinsert-buttons a:hover {
	background-color: #fff;
    color: #404244;
}

.mw-charinsert-buttons a:active {
	background-color: #c8ccd1;
	border-style: inset;
}

.client-js .mw-edittools-section {
	display: inline;
}

.client-js .mw-edittools-section input[type="button"] {
	background-color: #f8f9fa;
	color: #202122;
	margin-left: 1px;
    border-radius: 2px;
	padding: 1px 6px;
	font-size: 0.9em;
    /* Apply pointer cursor to all interactive elements. */
    cursor: pointer;
}

.client-js .mw-edittools-section input[type="button"]:hover {
	background-color: #fff;
    color: #404244;
}

.client-js .mw-edittools-section input[type="button"]:active {
	background-color: #c8ccd1;
    color: #000;
}

Scripting

หากคุณมีลิงก์ CharInsert หลายลิงก์ คุณสามารถใช้ JavaScript เพื่อจัดกลุ่มแยกกันและอนุญาตให้มีการสลับแบบไดนามิกด้วยเมนูดรอปดาวน์ ตัวอย่างเช่น การแยกอักขระกำกับเสียงออกจาก wikisyntax เป็นต้น ไซต์หลายแห่ง (เช่น mediawiki.org, de.wikipedia.org และ en.wikipedia.org) ได้ดำเนินการส่วนนี้แล้ว พวกเขาทั้งหมดนำไปใช้ในหลากหลายรูปแบบ เอกสารด้านล่างนี้เป็นวิธีที่ทำการสร้างใน mediawiki.org:

1. ห่อแท็ก charinsert ทั้งหมดบน MediaWiki:Edittools ลงในคอนเทนเนอร์ ‎<div> และระบุ ID ที่สื่อความหมายและไม่ซ้ำ (เช่น "mw-edittools-charinsert"):
<div id="mw-edittools-charinsert" class="mw-charinsert-buttons" title="Click on the wanted special character.">
...
</div>
2. จัดการแต่ละบล็อกของ charinserts เป็น ‎<p> แท็กดังนี้:
<p class="mw-edittools-section" data-section-title="Wiki-Syntax" style="display: none;">
...
</p>
  หมายเหตุ::
  • อย่าเปลี่ยนแปลงคำ 'mw-edittools-section'
  • ข้อความที่อยู่เบื้องหลัง "data-section-title=" จะระบุกลุ่มนี้ในเมนูแบบดรอปดาวน์
  • ตรวจสอบให้แน่ใจว่ามีกลุ่มหนึ่งที่ไม่มีคำสั่ง 'style="display: none;"' ซึ่งจะเป็นตัวเลือกเริ่มต้นในเมนูดรอปดาวน์ บนไซต์นี้ เรียกว่า 'มาตรฐาน' ในขณะที่กลุ่มอื่น ๆ ถูกตั้งชื่อตามภาษาที่อักขระมีความสำคัญ
3. คัดลอกเนื้อหา MediaWiki:Gadget-Edittools.js ไปยังหน้าที่มีชื่อเทียบเท่าในโครงการวิกิของคุณเอง
4. เพิ่มรหัสต่อไปนี้ใน MediaWiki:Gadgets-definition ของคุณ:
* Edittools[ResourceLoader|default]|Edittools.js

เมนู CharInsert วิกิพีเดียภาษาอังกฤษ

สำหรับการนำเมนู CharInsert ไปใช้เหมือนกับที่ใช้ในวิกิพีเดียภาษาอังกฤษ ให้ส่งออกแกดเจ็ต: Charinsert-core, Charinsert-styles และ Charinsert แล้วนำเข้าบนวิกิของคุณเองจนถึง Special:Import หรือหากคุณต้องการทำด้วยตนเอง ให้คัดลอกสี่รายการต่อไปนี้ หน้าส่วนต่อประสานกับวิกิของคุณ:

  • ใน MediaWiki:Gadgets-definition ของคุณ ให้เพิ่มคำจำกัดความต่อไปนี้:
    * charinsert[ResourceLoader|default|peers=charinsert-styles]|charinsert.js
    * charinsert-core[ResourceLoader|hidden|dependencies=jquery.textSelection,user,mediawiki.storage]|charinsert-core.js
    * charinsert-styles[ResourceLoader|hidden|type=styles]|charinsert-styles.css
    
  • MediaWiki:Edittools (Wikipedia) - สำหรับผู้ใช้ที่ปิด JavaScript หรือไม่ได้รับการสนับสนุนเท่านั้น (ซึ่งปิดใช้งานส่วนขยาย WikiEditor ด้วย) ดังนั้นจึงไม่จำเป็นหรือมีประโยชน์จริง ๆ โดยจะแสดงเฉพาะสัญลักษณ์/อักขระเป็นข้อความธรรมดาด้านล่างหน้าต่างตัวแก้ไข ซึ่งสามารถคัดลอกและวางได้ จึงเป็นประโยชน์ต่อบรรณาธิการ เห็นได้ชัดว่า มันไม่ได้เปิดใช้งานในวิกิพีเดียภาษาอังกฤษสำหรับ JavaScript ที่ปิดใช้งาน

  หมายเหตุ: ชุดอักขระวิกิพีเดียภาษาอังกฤษโดยเฉพาะนี้ยังมีแม่แบบ ซึ่งจะต้องกำหนดแยกต่างหาก หากจะใช้บนโครงการวิกิของคุณ

ตรวจสอบวิธีแก้ปัญหาวิกิพีเดียภาษาอังกฤษเมื่อ: 6 พฤศจิกายน 2018